diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-01-11 16:31:27 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-01-11 21:45:02 +0000 |
commit | 96f482c9cd3c99425fd3422251903b1218253c66 (patch) | |
tree | 5d089e55f47ab5e46b993026a5f961b44fed04e9 /xfa/fxfa | |
parent | a63dd01d2fdda06f96e6188dbc3b415447bf2bc9 (diff) | |
download | pdfium-96f482c9cd3c99425fd3422251903b1218253c66.tar.xz |
Convert FDE CSS enums to enum classes.
This CL updates the possible FDE CSS enums to enum classes and fixes up any
instances of incorrect values being used. A few other cleanups and changes
were needed to complete the conversion.
Change-Id: Ibcca5229a9ca8de1f4beb6462535f61705fd4f8c
Reviewed-on: https://pdfium-review.googlesource.com/2170
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa')
-rw-r--r-- | xfa/fxfa/app/cxfa_textlayout.cpp | 45 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textlayout.h | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textparsecontext.cpp | 2 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textparsecontext.h | 6 | ||||
-rw-r--r-- | xfa/fxfa/app/cxfa_textparser.cpp | 36 |
5 files changed, 46 insertions, 45 deletions
diff --git a/xfa/fxfa/app/cxfa_textlayout.cpp b/xfa/fxfa/app/cxfa_textlayout.cpp index c123668993..47f40ac04f 100644 --- a/xfa/fxfa/app/cxfa_textlayout.cpp +++ b/xfa/fxfa/app/cxfa_textlayout.cpp @@ -172,7 +172,7 @@ void CXFA_TextLayout::InitBreak(FX_FLOAT fLineWidth) { } void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, - FDE_CSSDISPLAY eDisplay, + FDE_CSSDisplay eDisplay, FX_FLOAT fLineWidth, CFDE_XMLNode* pXMLNode, IFDE_CSSComputedStyle* pParentStyle) { @@ -182,19 +182,20 @@ void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, } IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); - if (eDisplay == FDE_CSSDISPLAY_Block || eDisplay == FDE_CSSDISPLAY_ListItem) { + if (eDisplay == FDE_CSSDisplay::Block || + eDisplay == FDE_CSSDisplay::ListItem) { int32_t iAlign = FX_RTFLINEALIGNMENT_Left; switch (pParaStyle->GetTextAlign()) { - case FDE_CSSTEXTALIGN_Right: + case FDE_CSSTextAlign::Right: iAlign = FX_RTFLINEALIGNMENT_Right; break; - case FDE_CSSTEXTALIGN_Center: + case FDE_CSSTextAlign::Center: iAlign = FX_RTFLINEALIGNMENT_Center; break; - case FDE_CSSTEXTALIGN_Justify: + case FDE_CSSTextAlign::Justify: iAlign = FX_RTFLINEALIGNMENT_Justified; break; - case FDE_CSSTEXTALIGN_JustifyAll: + case FDE_CSSTextAlign::JustifyAll: iAlign = FX_RTFLINEALIGNMENT_Distributed; break; default: @@ -212,7 +213,7 @@ void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, fStart += pPaddingRect->left.GetValue(); fLineWidth -= pPaddingRect->right.GetValue(); } - if (eDisplay == FDE_CSSDISPLAY_ListItem) { + if (eDisplay == FDE_CSSDisplay::ListItem) { const FDE_CSSRECT* pParRect = pParentStyle->GetBoundaryStyles()->GetMarginWidth(); const FDE_CSSRECT* pParPaddingRect = @@ -226,10 +227,10 @@ void CXFA_TextLayout::InitBreak(IFDE_CSSComputedStyle* pStyle, } } FDE_CSSRECT pNewRect; - pNewRect.left.Set(FDE_CSSLENGTHUNIT_Point, fStart); - pNewRect.right.Set(FDE_CSSLENGTHUNIT_Point, pRect->right.GetValue()); - pNewRect.top.Set(FDE_CSSLENGTHUNIT_Point, pRect->top.GetValue()); - pNewRect.bottom.Set(FDE_CSSLENGTHUNIT_Point, pRect->bottom.GetValue()); + pNewRect.left.Set(FDE_CSSLengthUnit::Point, fStart); + pNewRect.right.Set(FDE_CSSLengthUnit::Point, pRect->right.GetValue()); + pNewRect.top.Set(FDE_CSSLengthUnit::Point, pRect->top.GetValue()); + pNewRect.bottom.Set(FDE_CSSLengthUnit::Point, pRect->bottom.GetValue()); pStyle->GetBoundaryStyles()->SetMarginWidth(pNewRect); } } @@ -736,7 +737,7 @@ bool CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, CXFA_TextParseContext* pContext = m_textParser.GetParseContextFromMap(pXMLNode); - FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_None; + FDE_CSSDisplay eDisplay = FDE_CSSDisplay::None; bool bContentNode = false; FX_FLOAT fSpaceBelow = 0; IFDE_CSSComputedStyle* pStyle = nullptr; @@ -762,17 +763,17 @@ bool CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, } if (m_bBlockContinue || bContentNode == false) { eDisplay = pContext->GetDisplay(); - if (eDisplay != FDE_CSSDISPLAY_Block && - eDisplay != FDE_CSSDISPLAY_Inline && - eDisplay != FDE_CSSDISPLAY_ListItem) { + if (eDisplay != FDE_CSSDisplay::Block && + eDisplay != FDE_CSSDisplay::Inline && + eDisplay != FDE_CSSDisplay::ListItem) { return true; } pStyle = m_textParser.ComputeStyle(pXMLNode, pParentStyle); InitBreak(bContentNode ? pParentStyle : pStyle, eDisplay, szText.x, pXMLNode, pParentStyle); - if ((eDisplay == FDE_CSSDISPLAY_Block || - eDisplay == FDE_CSSDISPLAY_ListItem) && + if ((eDisplay == FDE_CSSDisplay::Block || + eDisplay == FDE_CSSDisplay::ListItem) && pStyle && (wsName.IsEmpty() || (wsName != FX_WSTRC(L"body") && wsName != FX_WSTRC(L"html") && @@ -829,9 +830,9 @@ bool CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { wsText.TrimLeft(0x20); } - if (FDE_CSSDISPLAY_Block == eDisplay) { + if (FDE_CSSDisplay::Block == eDisplay) { m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; - } else if (FDE_CSSDISPLAY_Inline == eDisplay && + } else if (FDE_CSSDisplay::Inline == eDisplay && (m_pLoader->m_dwFlags & XFA_LOADERCNTXTFLG_FILTERSPACE)) { m_pLoader->m_dwFlags &= ~XFA_LOADERCNTXTFLG_FILTERSPACE; } else if (wsText.GetLength() > 0 && @@ -884,7 +885,7 @@ bool CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, } if (m_pLoader) { - if (FDE_CSSDISPLAY_Block == eDisplay) + if (FDE_CSSDisplay::Block == eDisplay) m_pLoader->m_dwFlags |= XFA_LOADERCNTXTFLG_FILTERSPACE; } if (bCurLi) @@ -896,11 +897,11 @@ bool CXFA_TextLayout::LoadRichText(CFDE_XMLNode* pXMLNode, if (m_bBlockContinue) { if (pContext && !bContentNode) { - uint32_t dwStatus = (eDisplay == FDE_CSSDISPLAY_Block) + uint32_t dwStatus = (eDisplay == FDE_CSSDisplay::Block) ? FX_RTFBREAK_ParagraphBreak : FX_RTFBREAK_PieceBreak; EndBreak(dwStatus, fLinePos, bSavePieces); - if (eDisplay == FDE_CSSDISPLAY_Block) { + if (eDisplay == FDE_CSSDisplay::Block) { fLinePos += fSpaceBelow; if (m_pTabstopContext) m_pTabstopContext->RemoveAll(); diff --git a/xfa/fxfa/app/cxfa_textlayout.h b/xfa/fxfa/app/cxfa_textlayout.h index e73005afb5..7c34d0d323 100644 --- a/xfa/fxfa/app/cxfa_textlayout.h +++ b/xfa/fxfa/app/cxfa_textlayout.h @@ -65,7 +65,7 @@ class CXFA_TextLayout { CFX_RTFBreak* CreateBreak(bool bDefault); void InitBreak(FX_FLOAT fLineWidth); void InitBreak(IFDE_CSSComputedStyle* pStyle, - FDE_CSSDISPLAY eDisplay, + FDE_CSSDisplay eDisplay, FX_FLOAT fLineWidth, CFDE_XMLNode* pXMLNode, IFDE_CSSComputedStyle* pParentStyle = nullptr); diff --git a/xfa/fxfa/app/cxfa_textparsecontext.cpp b/xfa/fxfa/app/cxfa_textparsecontext.cpp index b0dc655f00..c1747c2c18 100644 --- a/xfa/fxfa/app/cxfa_textparsecontext.cpp +++ b/xfa/fxfa/app/cxfa_textparsecontext.cpp @@ -12,7 +12,7 @@ CXFA_TextParseContext::CXFA_TextParseContext() : m_pParentStyle(nullptr), m_ppMatchedDecls(nullptr), m_dwMatchedDecls(0), - m_eDisplay(FDE_CSSDISPLAY_None) {} + m_eDisplay(FDE_CSSDisplay::None) {} CXFA_TextParseContext::~CXFA_TextParseContext() { if (m_pParentStyle) diff --git a/xfa/fxfa/app/cxfa_textparsecontext.h b/xfa/fxfa/app/cxfa_textparsecontext.h index 94265fb0db..db39af7c54 100644 --- a/xfa/fxfa/app/cxfa_textparsecontext.h +++ b/xfa/fxfa/app/cxfa_textparsecontext.h @@ -17,8 +17,8 @@ class CXFA_TextParseContext { CXFA_TextParseContext(); ~CXFA_TextParseContext(); - void SetDisplay(FDE_CSSDISPLAY eDisplay) { m_eDisplay = eDisplay; } - FDE_CSSDISPLAY GetDisplay() const { return m_eDisplay; } + void SetDisplay(FDE_CSSDisplay eDisplay) { m_eDisplay = eDisplay; } + FDE_CSSDisplay GetDisplay() const { return m_eDisplay; } void SetDecls(const CFDE_CSSDeclaration** ppDeclArray, int32_t iDeclCount); const CFDE_CSSDeclaration** GetDecls() { @@ -31,7 +31,7 @@ class CXFA_TextParseContext { protected: CFDE_CSSDeclaration** m_ppMatchedDecls; uint32_t m_dwMatchedDecls; - FDE_CSSDISPLAY m_eDisplay; + FDE_CSSDisplay m_eDisplay; }; #endif // XFA_FXFA_APP_CXFA_TEXTPARSECONTEXT_H_ diff --git a/xfa/fxfa/app/cxfa_textparser.cpp b/xfa/fxfa/app/cxfa_textparser.cpp index 50f6cbaea2..ec2b7c3cb0 100644 --- a/xfa/fxfa/app/cxfa_textparser.cpp +++ b/xfa/fxfa/app/cxfa_textparser.cpp @@ -75,7 +75,7 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) { if (!m_pUASheet) { m_pUASheet = LoadDefaultSheetStyle(); - m_pSelector->SetStyleSheet(FDE_CSSSTYLESHEETGROUP_UserAgent, m_pUASheet); + m_pSelector->SetStyleSheet(FDE_CSSStyleSheetGroup::UserAgent, m_pUASheet); m_pSelector->UpdateStyleIndex(FDE_CSSMEDIATYPE_ALL); } } @@ -107,42 +107,42 @@ IFDE_CSSComputedStyle* CXFA_TextParser::CreateRootStyle( if (para) { fLineHeight = para.GetLineHeight(); FDE_CSSLENGTH indent; - indent.Set(FDE_CSSLENGTHUNIT_Point, para.GetTextIndent()); + indent.Set(FDE_CSSLengthUnit::Point, para.GetTextIndent()); pParaStyle->SetTextIndent(indent); - FDE_CSSTEXTALIGN hAlign = FDE_CSSTEXTALIGN_Left; + FDE_CSSTextAlign hAlign = FDE_CSSTextAlign::Left; switch (para.GetHorizontalAlign()) { case XFA_ATTRIBUTEENUM_Center: - hAlign = FDE_CSSTEXTALIGN_Center; + hAlign = FDE_CSSTextAlign::Center; break; case XFA_ATTRIBUTEENUM_Right: - hAlign = FDE_CSSTEXTALIGN_Right; + hAlign = FDE_CSSTextAlign::Right; break; case XFA_ATTRIBUTEENUM_Justify: - hAlign = FDE_CSSTEXTALIGN_Justify; + hAlign = FDE_CSSTextAlign::Justify; break; case XFA_ATTRIBUTEENUM_JustifyAll: - hAlign = FDE_CSSTEXTALIGN_JustifyAll; + hAlign = FDE_CSSTextAlign::JustifyAll; break; } pParaStyle->SetTextAlign(hAlign); FDE_CSSRECT rtMarginWidth; - rtMarginWidth.left.Set(FDE_CSSLENGTHUNIT_Point, para.GetMarginLeft()); - rtMarginWidth.top.Set(FDE_CSSLENGTHUNIT_Point, para.GetSpaceAbove()); - rtMarginWidth.right.Set(FDE_CSSLENGTHUNIT_Point, para.GetMarginRight()); - rtMarginWidth.bottom.Set(FDE_CSSLENGTHUNIT_Point, para.GetSpaceBelow()); + rtMarginWidth.left.Set(FDE_CSSLengthUnit::Point, para.GetMarginLeft()); + rtMarginWidth.top.Set(FDE_CSSLengthUnit::Point, para.GetSpaceAbove()); + rtMarginWidth.right.Set(FDE_CSSLengthUnit::Point, para.GetMarginRight()); + rtMarginWidth.bottom.Set(FDE_CSSLengthUnit::Point, para.GetSpaceBelow()); pStyle->GetBoundaryStyles()->SetMarginWidth(rtMarginWidth); } if (font) { pFontStyle->SetColor(font.GetColor()); - pFontStyle->SetFontStyle(font.IsItalic() ? FDE_CSSFONTSTYLE_Italic - : FDE_CSSFONTSTYLE_Normal); + pFontStyle->SetFontStyle(font.IsItalic() ? FDE_CSSFontStyle::Italic + : FDE_CSSFontStyle::Normal); pFontStyle->SetFontWeight(font.IsBold() ? FXFONT_FW_BOLD : FXFONT_FW_NORMAL); pParaStyle->SetNumberVerticalAlign(-font.GetBaselineShift()); fFontSize = font.GetFontSize(); FDE_CSSLENGTH letterSpacing; - letterSpacing.Set(FDE_CSSLENGTHUNIT_Point, font.GetLetterSpacing()); + letterSpacing.Set(FDE_CSSLengthUnit::Point, font.GetLetterSpacing()); pParaStyle->SetLetterSpacing(letterSpacing); uint32_t dwDecoration = 0; if (font.GetLineThrough() > 0) @@ -170,7 +170,7 @@ IFDE_CSSComputedStyle* CXFA_TextParser::CreateStyle( IFDE_CSSParagraphStyle* pParaStyle = pParentStyle->GetParagraphStyles(); uint32_t dwDecoration = pParaStyle->GetTextDecoration(); FX_FLOAT fBaseLine = 0; - if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) + if (pParaStyle->GetVerticalAlign() == FDE_CSSVerticalAlign::Number) fBaseLine = pParaStyle->GetNumberVerticalAlign(); pParaStyle = pNewStyle->GetParagraphStyles(); @@ -240,7 +240,7 @@ void CXFA_TextParser::ParseRichText(CFDE_XMLNode* pXMLNode, if ((tagProvider.GetTagName() != FX_WSTRC(L"body")) || (tagProvider.GetTagName() != FX_WSTRC(L"html"))) { CXFA_TextParseContext* pTextContext = new CXFA_TextParseContext; - FDE_CSSDISPLAY eDisplay = FDE_CSSDISPLAY_Inline; + FDE_CSSDisplay eDisplay = FDE_CSSDisplay::Inline; if (!tagProvider.m_bContent) { pNewStyle = CreateStyle(pParentStyle); CFDE_CSSAccelerator* pCSSAccel = m_pSelector->InitAccelerator(); @@ -364,7 +364,7 @@ CFX_RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont( dwStyle = 0; if (pFontStyle->GetFontWeight() > FXFONT_FW_NORMAL) dwStyle |= FX_FONTSTYLE_Bold; - if (pFontStyle->GetFontStyle() == FDE_CSSFONTSTYLE_Italic) + if (pFontStyle->GetFontStyle() == FDE_CSSFontStyle::Italic) dwStyle |= FX_FONTSTYLE_Italic; } @@ -482,7 +482,7 @@ FX_FLOAT CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider, IFDE_CSSComputedStyle* pStyle) const { if (pStyle) { IFDE_CSSParagraphStyle* pParaStyle = pStyle->GetParagraphStyles(); - if (pParaStyle->GetVerticalAlign() == FDE_CSSVERTICALALIGN_Number) + if (pParaStyle->GetVerticalAlign() == FDE_CSSVerticalAlign::Number) return pParaStyle->GetNumberVerticalAlign(); } else if (CXFA_Font font = pTextProvider->GetFontNode()) { return font.GetBaselineShift(); |