diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2017-11-21 21:59:45 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2017-11-21 21:59:45 +0000 |
commit | 96d6f741b3c106ba0e48a05692910f64cf1e5e09 (patch) | |
tree | 07fc97f427a308bffd995ae9a77aa2dbac9972eb | |
parent | b06d3f8d7658eeab6624f66aef690a7f4b44936e (diff) | |
download | pdfium-96d6f741b3c106ba0e48a05692910f64cf1e5e09.tar.xz |
Cleanup CXFA_ParaData
This CL fixes the return types and makes the CXFA_ParaData methods
const.
Change-Id: Ifb63b46e826d9741682d992d7fc1ee37c772fb41
Reviewed-on: https://pdfium-review.googlesource.com/19070
Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
-rw-r--r-- | xfa/fxfa/cxfa_ffcheckbutton.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffimage.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffimageedit.cpp | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.cpp | 17 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffwidget.h | 4 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textlayout.cpp | 16 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textparser.cpp | 9 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_textparser.h | 3 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.cpp | 3 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_paradata.cpp | 16 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_paradata.h | 16 |
11 files changed, 58 insertions, 38 deletions
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp index 7d82fc6e9f..48a4857980 100644 --- a/xfa/fxfa/cxfa_ffcheckbutton.cpp +++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp @@ -113,8 +113,8 @@ bool CXFA_FFCheckButton::PerformLayout() { } } - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; + XFA_ATTRIBUTEENUM iHorzAlign = XFA_ATTRIBUTEENUM_Left; + XFA_ATTRIBUTEENUM iVertAlign = XFA_ATTRIBUTEENUM_Top; CXFA_ParaData paraData = m_pDataAcc->GetParaData(); if (paraData.HasValidNode()) { iHorzAlign = paraData.GetHorizontalAlign(); diff --git a/xfa/fxfa/cxfa_ffimage.cpp b/xfa/fxfa/cxfa_ffimage.cpp index 063d3aef5b..79b7d9dd6f 100644 --- a/xfa/fxfa/cxfa_ffimage.cpp +++ b/xfa/fxfa/cxfa_ffimage.cpp @@ -53,8 +53,8 @@ void CXFA_FFImage::RenderWidget(CXFA_Graphics* pGS, if (marginData.HasValidNode()) XFA_RectWidthoutMargin(rtImage, marginData); - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; + XFA_ATTRIBUTEENUM iHorzAlign = XFA_ATTRIBUTEENUM_Left; + XFA_ATTRIBUTEENUM iVertAlign = XFA_ATTRIBUTEENUM_Top; CXFA_ParaData paraData = m_pDataAcc->GetParaData(); if (paraData.HasValidNode()) { iHorzAlign = paraData.GetHorizontalAlign(); diff --git a/xfa/fxfa/cxfa_ffimageedit.cpp b/xfa/fxfa/cxfa_ffimageedit.cpp index 1f3be60c32..9a1d1e12cf 100644 --- a/xfa/fxfa/cxfa_ffimageedit.cpp +++ b/xfa/fxfa/cxfa_ffimageedit.cpp @@ -68,8 +68,8 @@ void CXFA_FFImageEdit::RenderWidget(CXFA_Graphics* pGS, return; CFX_RectF rtImage = m_pNormalWidget->GetWidgetRect(); - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left; - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top; + XFA_ATTRIBUTEENUM iHorzAlign = XFA_ATTRIBUTEENUM_Left; + XFA_ATTRIBUTEENUM iVertAlign = XFA_ATTRIBUTEENUM_Top; CXFA_ParaData paraData = m_pDataAcc->GetParaData(); if (paraData.HasValidNode()) { iHorzAlign = paraData.GetHorizontalAlign(); diff --git a/xfa/fxfa/cxfa_ffwidget.cpp b/xfa/fxfa/cxfa_ffwidget.cpp index c66d705623..a5d19f05ac 100644 --- a/xfa/fxfa/cxfa_ffwidget.cpp +++ b/xfa/fxfa/cxfa_ffwidget.cpp @@ -1677,8 +1677,8 @@ void XFA_DrawImage(CXFA_Graphics* pGS, XFA_ATTRIBUTEENUM iAspect, int32_t iImageXDpi, int32_t iImageYDpi, - int32_t iHorzAlign, - int32_t iVertAlign) { + XFA_ATTRIBUTEENUM iHorzAlign, + XFA_ATTRIBUTEENUM iVertAlign) { if (rtImage.IsEmpty()) return; if (!pDIBitmap || !pDIBitmap->GetBuffer()) @@ -1717,16 +1717,17 @@ void XFA_DrawImage(CXFA_Graphics* pGS, default: break; } - if (iHorzAlign == XFA_ATTRIBUTEENUM_Center) { + + if (iHorzAlign == XFA_ATTRIBUTEENUM_Center) rtFit.left += (rtImage.width - rtFit.width) / 2; - } else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right) { + else if (iHorzAlign == XFA_ATTRIBUTEENUM_Right) rtFit.left = rtImage.right() - rtFit.width; - } - if (iVertAlign == XFA_ATTRIBUTEENUM_Middle) { + + if (iVertAlign == XFA_ATTRIBUTEENUM_Middle) rtFit.top += (rtImage.height - rtFit.height) / 2; - } else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom) { + else if (iVertAlign == XFA_ATTRIBUTEENUM_Bottom) rtFit.top = rtImage.bottom() - rtImage.height; - } + CFX_RenderDevice* pRenderDevice = pGS->GetRenderDevice(); CFX_RenderDevice::StateRestorer restorer(pRenderDevice); CFX_PathData path; diff --git a/xfa/fxfa/cxfa_ffwidget.h b/xfa/fxfa/cxfa_ffwidget.h index 3de3d49293..5729654a2b 100644 --- a/xfa/fxfa/cxfa_ffwidget.h +++ b/xfa/fxfa/cxfa_ffwidget.h @@ -45,8 +45,8 @@ void XFA_DrawImage(CXFA_Graphics* pGS, XFA_ATTRIBUTEENUM iAspect, int32_t iImageXDpi, int32_t iImageYDpi, - int32_t iHorzAlign = XFA_ATTRIBUTEENUM_Left, - int32_t iVertAlign = XFA_ATTRIBUTEENUM_Top); + XFA_ATTRIBUTEENUM iHorzAlign = XFA_ATTRIBUTEENUM_Left, + XFA_ATTRIBUTEENUM iVertAlign = XFA_ATTRIBUTEENUM_Top); RetainPtr<CFX_DIBitmap> XFA_LoadImageData(CXFA_FFDoc* pDoc, CXFA_ImageData* pImageData, diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp index 7ff86bafeb..e951e3fe3a 100644 --- a/xfa/fxfa/cxfa_textlayout.cpp +++ b/xfa/fxfa/cxfa_textlayout.cpp @@ -120,6 +120,12 @@ void CXFA_TextLayout::InitBreak(float fLineWidth) { case XFA_ATTRIBUTEENUM_JustifyAll: iAlign = CFX_RTFLineAlignment::Distributed; break; + case XFA_ATTRIBUTEENUM_Left: + case XFA_ATTRIBUTEENUM_Radix: + break; + default: + NOTREACHED(); + break; } m_pBreak->SetAlignment(iAlign); @@ -649,17 +655,19 @@ void CXFA_TextLayout::LoadText(CXFA_Node* pNode, float fSpaceAbove = 0; if (paraData.HasValidNode()) { fSpaceAbove = paraData.GetSpaceAbove(); - if (fSpaceAbove < 0.1f) { + if (fSpaceAbove < 0.1f) fSpaceAbove = 0; - } - int32_t verAlign = paraData.GetVerticalAlign(); - switch (verAlign) { + + switch (paraData.GetVerticalAlign()) { case XFA_ATTRIBUTEENUM_Top: case XFA_ATTRIBUTEENUM_Middle: case XFA_ATTRIBUTEENUM_Bottom: { fLinePos += fSpaceAbove; break; } + default: + NOTREACHED(); + break; } } diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp index 8981799d83..433531373c 100644 --- a/xfa/fxfa/cxfa_textparser.cpp +++ b/xfa/fxfa/cxfa_textparser.cpp @@ -115,6 +115,12 @@ RetainPtr<CFX_CSSComputedStyle> CXFA_TextParser::CreateRootStyle( case XFA_ATTRIBUTEENUM_JustifyAll: hAlign = CFX_CSSTextAlign::JustifyAll; break; + case XFA_ATTRIBUTEENUM_Left: + case XFA_ATTRIBUTEENUM_Radix: + break; + default: + NOTREACHED(); + break; } pStyle->SetTextAlign(hAlign); CFX_CSSRect rtMarginWidth; @@ -291,7 +297,8 @@ std::unique_ptr<CXFA_TextParser::TagProvider> CXFA_TextParser::ParseTagInfo( return tagProvider; } -int32_t CXFA_TextParser::GetVAlign(CXFA_TextProvider* pTextProvider) const { +XFA_ATTRIBUTEENUM CXFA_TextParser::GetVAlign( + CXFA_TextProvider* pTextProvider) const { CXFA_ParaData paraData = pTextProvider->GetParaData(); return paraData.HasValidNode() ? paraData.GetVerticalAlign() : XFA_ATTRIBUTEENUM_Top; diff --git a/xfa/fxfa/cxfa_textparser.h b/xfa/fxfa/cxfa_textparser.h index 9a2232efa1..09ef8dbbb2 100644 --- a/xfa/fxfa/cxfa_textparser.h +++ b/xfa/fxfa/cxfa_textparser.h @@ -15,6 +15,7 @@ #include "core/fxcrt/retain_ptr.h" #include "core/fxge/fx_dib.h" #include "xfa/fgas/font/cfgas_gefont.h" +#include "xfa/fxfa/fxfa_basic.h" class CFX_CSSComputedStyle; class CFX_CSSStyleSelector; @@ -40,7 +41,7 @@ class CXFA_TextParser { bool IsParsed() const { return m_bParsed; } - int32_t GetVAlign(CXFA_TextProvider* pTextProvider) const; + XFA_ATTRIBUTEENUM GetVAlign(CXFA_TextProvider* pTextProvider) const; float GetTabInterval(CFX_CSSComputedStyle* pStyle) const; int32_t CountTabs(CFX_CSSComputedStyle* pStyle) const; diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 26ba231533..816e2a2204 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -1257,6 +1257,9 @@ bool CXFA_WidgetAcc::FindSplitPos(int32_t iBlockIndex, float& fCalcHeight) { case XFA_ATTRIBUTEENUM_Bottom: fStartOffset += (fHeight - fTextHeight + fSpaceAbove); break; + default: + NOTREACHED(); + break; } } if (fStartOffset < 0.1f) diff --git a/xfa/fxfa/parser/cxfa_paradata.cpp b/xfa/fxfa/parser/cxfa_paradata.cpp index 95dc80a934..cb960f8dca 100644 --- a/xfa/fxfa/parser/cxfa_paradata.cpp +++ b/xfa/fxfa/parser/cxfa_paradata.cpp @@ -11,49 +11,49 @@ CXFA_ParaData::CXFA_ParaData(CXFA_Node* pNode) : CXFA_DataData(pNode) {} -int32_t CXFA_ParaData::GetHorizontalAlign() { +XFA_ATTRIBUTEENUM CXFA_ParaData::GetHorizontalAlign() const { return m_pNode->JSNode() ->TryEnum(XFA_Attribute::HAlign, true) .value_or(XFA_ATTRIBUTEENUM_Left); } -int32_t CXFA_ParaData::GetVerticalAlign() { +XFA_ATTRIBUTEENUM CXFA_ParaData::GetVerticalAlign() const { return m_pNode->JSNode() ->TryEnum(XFA_Attribute::VAlign, true) .value_or(XFA_ATTRIBUTEENUM_Top); } -float CXFA_ParaData::GetLineHeight() { +float CXFA_ParaData::GetLineHeight() const { return m_pNode->JSNode() ->GetMeasure(XFA_Attribute::LineHeight) .ToUnit(XFA_Unit::Pt); } -float CXFA_ParaData::GetMarginLeft() { +float CXFA_ParaData::GetMarginLeft() const { return m_pNode->JSNode() ->GetMeasure(XFA_Attribute::MarginLeft) .ToUnit(XFA_Unit::Pt); } -float CXFA_ParaData::GetMarginRight() { +float CXFA_ParaData::GetMarginRight() const { return m_pNode->JSNode() ->GetMeasure(XFA_Attribute::MarginRight) .ToUnit(XFA_Unit::Pt); } -float CXFA_ParaData::GetSpaceAbove() { +float CXFA_ParaData::GetSpaceAbove() const { return m_pNode->JSNode() ->GetMeasure(XFA_Attribute::SpaceAbove) .ToUnit(XFA_Unit::Pt); } -float CXFA_ParaData::GetSpaceBelow() { +float CXFA_ParaData::GetSpaceBelow() const { return m_pNode->JSNode() ->GetMeasure(XFA_Attribute::SpaceBelow) .ToUnit(XFA_Unit::Pt); } -float CXFA_ParaData::GetTextIndent() { +float CXFA_ParaData::GetTextIndent() const { return m_pNode->JSNode() ->GetMeasure(XFA_Attribute::TextIndent) .ToUnit(XFA_Unit::Pt); diff --git a/xfa/fxfa/parser/cxfa_paradata.h b/xfa/fxfa/parser/cxfa_paradata.h index 20c371ed51..b08c5c471f 100644 --- a/xfa/fxfa/parser/cxfa_paradata.h +++ b/xfa/fxfa/parser/cxfa_paradata.h @@ -16,14 +16,14 @@ class CXFA_ParaData : public CXFA_DataData { public: explicit CXFA_ParaData(CXFA_Node* pNode); - int32_t GetHorizontalAlign(); - int32_t GetVerticalAlign(); - float GetLineHeight(); - float GetMarginLeft(); - float GetMarginRight(); - float GetSpaceAbove(); - float GetSpaceBelow(); - float GetTextIndent(); + XFA_ATTRIBUTEENUM GetHorizontalAlign() const; + XFA_ATTRIBUTEENUM GetVerticalAlign() const; + float GetLineHeight() const; + float GetMarginLeft() const; + float GetMarginRight() const; + float GetSpaceAbove() const; + float GetSpaceBelow() const; + float GetTextIndent() const; }; #endif // XFA_FXFA_PARSER_CXFA_PARADATA_H_ |