summaryrefslogtreecommitdiff
path: root/xfa/fxfa/cxfa_textparser.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-20 21:19:13 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-20 21:19:13 +0000
commit2501ae2474c1f097a06634d647de2eb3fb730864 (patch)
tree3ac7d386a3e73f3c848c203c3f0e61af9d284c1f /xfa/fxfa/cxfa_textparser.cpp
parent89453e92d5d0b7aaf9e0c3890a90a21adc94a0ce (diff)
downloadpdfium-2501ae2474c1f097a06634d647de2eb3fb730864.tar.xz
Remove CXFA_DataData operator bool override
This CL removes CXFA_DataData::operator bool in favour of an explicit HasValidNode method. This makes the call sites a lot clearer. Change-Id: I6fae14fdeec4674ca7916e21b9e5703070fc3069 Reviewed-on: https://pdfium-review.googlesource.com/18830 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Diffstat (limited to 'xfa/fxfa/cxfa_textparser.cpp')
-rw-r--r--xfa/fxfa/cxfa_textparser.cpp45
1 files changed, 28 insertions, 17 deletions
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index 0877d21ab1..b74df3d14e 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -59,7 +59,8 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
m_pSelector = pdfium::MakeUnique<CFX_CSSStyleSelector>();
CXFA_FontData fontData = pTextProvider->GetFontData();
- m_pSelector->SetDefFontSize(fontData ? fontData.GetFontSize() : 10.0f);
+ m_pSelector->SetDefFontSize(fontData.HasValidNode() ? fontData.GetFontSize()
+ : 10.0f);
}
if (m_cssInitialized)
@@ -95,7 +96,7 @@ RetainPtr<CFX_CSSComputedStyle> CXFA_TextParser::CreateRootStyle(
float fLineHeight = 0;
float fFontSize = 10;
- if (paraData) {
+ if (paraData.HasValidNode()) {
fLineHeight = paraData.GetLineHeight();
CFX_CSSLength indent;
indent.Set(CFX_CSSLengthUnit::Point, paraData.GetTextIndent());
@@ -127,7 +128,7 @@ RetainPtr<CFX_CSSComputedStyle> CXFA_TextParser::CreateRootStyle(
}
CXFA_FontData fontData = pTextProvider->GetFontData();
- if (fontData) {
+ if (fontData.HasValidNode()) {
pStyle->SetColor(fontData.GetColor());
pStyle->SetFontStyle(fontData.IsItalic() ? CFX_CSSFontStyle::Italic
: CFX_CSSFontStyle::Normal);
@@ -292,7 +293,8 @@ std::unique_ptr<CXFA_TextParser::TagProvider> CXFA_TextParser::ParseTagInfo(
int32_t CXFA_TextParser::GetVAlign(CXFA_TextProvider* pTextProvider) const {
CXFA_ParaData paraData = pTextProvider->GetParaData();
- return paraData ? paraData.GetVerticalAlign() : XFA_ATTRIBUTEENUM_Top;
+ return paraData.HasValidNode() ? paraData.GetVerticalAlign()
+ : XFA_ATTRIBUTEENUM_Top;
}
float CXFA_TextParser::GetTabInterval(CFX_CSSComputedStyle* pStyle) const {
@@ -324,7 +326,7 @@ RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont(
WideString wsFamily = L"Courier";
uint32_t dwStyle = 0;
CXFA_FontData fontData = pTextProvider->GetFontData();
- if (fontData) {
+ if (fontData.HasValidNode()) {
fontData.GetTypeface(wsFamily);
if (fontData.IsBold())
dwStyle |= FXFONT_BOLD;
@@ -355,7 +357,7 @@ float CXFA_TextParser::GetFontSize(CXFA_TextProvider* pTextProvider,
return pStyle->GetFontSize();
CXFA_FontData fontData = pTextProvider->GetFontData();
- return fontData ? fontData.GetFontSize() : 10;
+ return fontData.HasValidNode() ? fontData.GetFontSize() : 10;
}
int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider,
@@ -381,7 +383,9 @@ int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider,
}
CXFA_FontData fontData = pTextProvider->GetFontData();
- return fontData ? static_cast<int32_t>(fontData.GetHorizontalScale()) : 100;
+ return fontData.HasValidNode()
+ ? static_cast<int32_t>(fontData.GetHorizontalScale())
+ : 100;
}
int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider,
@@ -393,7 +397,9 @@ int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider,
}
CXFA_FontData fontData = pTextProvider->GetFontData();
- return fontData ? static_cast<int32_t>(fontData.GetVerticalScale()) : 100;
+ return fontData.HasValidNode()
+ ? static_cast<int32_t>(fontData.GetVerticalScale())
+ : 100;
}
void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider,
@@ -404,7 +410,7 @@ void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider,
iPeriod = XFA_ATTRIBUTEENUM_All;
CXFA_FontData fontData = pTextProvider->GetFontData();
if (!pStyle) {
- if (fontData) {
+ if (fontData.HasValidNode()) {
iUnderline = fontData.GetUnderline();
iPeriod = fontData.GetUnderlinePeriod();
}
@@ -421,7 +427,7 @@ void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider,
if (pStyle->GetCustomStyle(L"underlinePeriod", wsValue)) {
if (wsValue == L"word")
iPeriod = XFA_ATTRIBUTEENUM_Word;
- } else if (fontData) {
+ } else if (fontData.HasValidNode()) {
iPeriod = fontData.GetUnderlinePeriod();
}
}
@@ -436,7 +442,7 @@ void CXFA_TextParser::GetLinethrough(CXFA_TextProvider* pTextProvider,
}
CXFA_FontData fontData = pTextProvider->GetFontData();
- if (fontData)
+ if (fontData.HasValidNode())
iLinethrough = fontData.GetLineThrough();
}
@@ -446,7 +452,7 @@ FX_ARGB CXFA_TextParser::GetColor(CXFA_TextProvider* pTextProvider,
return pStyle->GetColor();
CXFA_FontData fontData = pTextProvider->GetFontData();
- return fontData ? fontData.GetColor() : 0xFF000000;
+ return fontData.HasValidNode() ? fontData.GetColor() : 0xFF000000;
}
float CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider,
@@ -454,8 +460,10 @@ float CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider,
if (pStyle) {
if (pStyle->GetVerticalAlign() == CFX_CSSVerticalAlign::Number)
return pStyle->GetNumberVerticalAlign();
- } else if (CXFA_FontData fontData = pTextProvider->GetFontData()) {
- return fontData.GetBaselineShift();
+ } else {
+ CXFA_FontData fontData = pTextProvider->GetFontData();
+ if (fontData.HasValidNode())
+ return fontData.GetBaselineShift();
}
return 0;
}
@@ -465,10 +473,13 @@ float CXFA_TextParser::GetLineHeight(CXFA_TextProvider* pTextProvider,
bool bFirst,
float fVerScale) const {
float fLineHeight = 0;
- if (pStyle)
+ if (pStyle) {
fLineHeight = pStyle->GetLineHeight();
- else if (CXFA_ParaData paraData = pTextProvider->GetParaData())
- fLineHeight = paraData.GetLineHeight();
+ } else {
+ CXFA_ParaData paraData = pTextProvider->GetParaData();
+ if (paraData.HasValidNode())
+ fLineHeight = paraData.GetLineHeight();
+ }
if (bFirst) {
float fFontSize = GetFontSize(pTextProvider, pStyle);