summaryrefslogtreecommitdiff
path: root/xfa
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-10 19:43:56 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-10 19:43:56 +0000
commit948879d23226aea31aa9ae5f6eb1fb8572f0fc05 (patch)
treee40d527c3f8757d8038ef7f7cd26dca7a83e3574 /xfa
parente844cccc8419dae40720aad57c3bcd7ced14a925 (diff)
downloadpdfium-948879d23226aea31aa9ae5f6eb1fb8572f0fc05.tar.xz
Rename GetFont to GetFontIfExists
This CL makes it explicit that GetFont may return nullptr. Change-Id: Icb7ec5ad4ed6c5f7a728230d1237898b8f2fd778 Reviewed-on: https://pdfium-review.googlesource.com/22673 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa')
-rw-r--r--xfa/fxfa/cxfa_textlayout.cpp2
-rw-r--r--xfa/fxfa/cxfa_textparser.cpp20
-rw-r--r--xfa/fxfa/cxfa_textprovider.cpp6
-rw-r--r--xfa/fxfa/cxfa_textprovider.h2
-rw-r--r--xfa/fxfa/cxfa_widgetacc.cpp4
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp6
-rw-r--r--xfa/fxfa/parser/cxfa_node.h2
7 files changed, 21 insertions, 21 deletions
diff --git a/xfa/fxfa/cxfa_textlayout.cpp b/xfa/fxfa/cxfa_textlayout.cpp
index 3be45352f7..15ac909e2e 100644
--- a/xfa/fxfa/cxfa_textlayout.cpp
+++ b/xfa/fxfa/cxfa_textlayout.cpp
@@ -150,7 +150,7 @@ void CXFA_TextLayout::InitBreak(float fLineWidth) {
m_pBreak->SetLineBoundary(fStart, fLineWidth);
m_pBreak->SetLineStartPos(fStartPos);
- CXFA_Font* font = m_pTextProvider->GetFont();
+ CXFA_Font* font = m_pTextProvider->GetFontIfExists();
if (font) {
m_pBreak->SetHorizontalScale(
static_cast<int32_t>(font->GetHorizontalScale()));
diff --git a/xfa/fxfa/cxfa_textparser.cpp b/xfa/fxfa/cxfa_textparser.cpp
index 03cba8e8e2..0fd59a0852 100644
--- a/xfa/fxfa/cxfa_textparser.cpp
+++ b/xfa/fxfa/cxfa_textparser.cpp
@@ -60,7 +60,7 @@ void CXFA_TextParser::InitCSSData(CXFA_TextProvider* pTextProvider) {
if (!m_pSelector) {
m_pSelector = pdfium::MakeUnique<CFX_CSSStyleSelector>();
- CXFA_Font* font = pTextProvider->GetFont();
+ CXFA_Font* font = pTextProvider->GetFontIfExists();
m_pSelector->SetDefFontSize(font ? font->GetFontSize() : 10.0f);
}
@@ -132,7 +132,7 @@ RetainPtr<CFX_CSSComputedStyle> CXFA_TextParser::CreateRootStyle(
pStyle->SetMarginWidth(rtMarginWidth);
}
- CXFA_Font* font = pTextProvider->GetFont();
+ CXFA_Font* font = pTextProvider->GetFontIfExists();
if (font) {
pStyle->SetColor(font->GetColor());
pStyle->SetFontStyle(font->IsItalic() ? CFX_CSSFontStyle::Italic
@@ -330,7 +330,7 @@ RetainPtr<CFGAS_GEFont> CXFA_TextParser::GetFont(
CFX_CSSComputedStyle* pStyle) const {
WideString wsFamily = L"Courier";
uint32_t dwStyle = 0;
- CXFA_Font* font = pTextProvider->GetFont();
+ CXFA_Font* font = pTextProvider->GetFontIfExists();
if (font) {
wsFamily = font->GetTypeface();
if (font->IsBold())
@@ -360,7 +360,7 @@ float CXFA_TextParser::GetFontSize(CXFA_TextProvider* pTextProvider,
if (pStyle)
return pStyle->GetFontSize();
- CXFA_Font* font = pTextProvider->GetFont();
+ CXFA_Font* font = pTextProvider->GetFontIfExists();
return font ? font->GetFontSize() : 10;
}
@@ -386,7 +386,7 @@ int32_t CXFA_TextParser::GetHorScale(CXFA_TextProvider* pTextProvider,
}
}
- CXFA_Font* font = pTextProvider->GetFont();
+ CXFA_Font* font = pTextProvider->GetFontIfExists();
return font ? static_cast<int32_t>(font->GetHorizontalScale()) : 100;
}
@@ -398,7 +398,7 @@ int32_t CXFA_TextParser::GetVerScale(CXFA_TextProvider* pTextProvider,
return wsValue.GetInteger();
}
- CXFA_Font* font = pTextProvider->GetFont();
+ CXFA_Font* font = pTextProvider->GetFontIfExists();
return font ? static_cast<int32_t>(font->GetVerticalScale()) : 100;
}
@@ -408,7 +408,7 @@ void CXFA_TextParser::GetUnderline(CXFA_TextProvider* pTextProvider,
XFA_AttributeEnum& iPeriod) const {
iUnderline = 0;
iPeriod = XFA_AttributeEnum::All;
- CXFA_Font* font = pTextProvider->GetFont();
+ CXFA_Font* font = pTextProvider->GetFontIfExists();
if (!pStyle) {
if (font) {
iUnderline = font->GetUnderline();
@@ -441,7 +441,7 @@ void CXFA_TextParser::GetLinethrough(CXFA_TextProvider* pTextProvider,
return;
}
- CXFA_Font* font = pTextProvider->GetFont();
+ CXFA_Font* font = pTextProvider->GetFontIfExists();
if (font)
iLinethrough = font->GetLineThrough();
}
@@ -451,7 +451,7 @@ FX_ARGB CXFA_TextParser::GetColor(CXFA_TextProvider* pTextProvider,
if (pStyle)
return pStyle->GetColor();
- CXFA_Font* font = pTextProvider->GetFont();
+ CXFA_Font* font = pTextProvider->GetFontIfExists();
return font ? font->GetColor() : 0xFF000000;
}
@@ -461,7 +461,7 @@ float CXFA_TextParser::GetBaseline(CXFA_TextProvider* pTextProvider,
if (pStyle->GetVerticalAlign() == CFX_CSSVerticalAlign::Number)
return pStyle->GetNumberVerticalAlign();
} else {
- CXFA_Font* font = pTextProvider->GetFont();
+ CXFA_Font* font = pTextProvider->GetFontIfExists();
if (font)
return font->GetBaselineShift();
}
diff --git a/xfa/fxfa/cxfa_textprovider.cpp b/xfa/fxfa/cxfa_textprovider.cpp
index e3222a9c8b..6b4198ec1e 100644
--- a/xfa/fxfa/cxfa_textprovider.cpp
+++ b/xfa/fxfa/cxfa_textprovider.cpp
@@ -124,14 +124,14 @@ CXFA_Para* CXFA_TextProvider::GetPara() {
return pNode->GetChild<CXFA_Para>(0, XFA_Element::Para, false);
}
-CXFA_Font* CXFA_TextProvider::GetFont() {
+CXFA_Font* CXFA_TextProvider::GetFontIfExists() {
if (m_eType == XFA_TEXTPROVIDERTYPE_Text)
- return m_pWidgetAcc->GetNode()->GetFont();
+ return m_pWidgetAcc->GetNode()->GetFontIfExists();
CXFA_Caption* pNode = m_pWidgetAcc->GetNode()->GetChild<CXFA_Caption>(
0, XFA_Element::Caption, false);
CXFA_Font* font = pNode->GetChild<CXFA_Font>(0, XFA_Element::Font, false);
- return font ? font : m_pWidgetAcc->GetNode()->GetFont();
+ return font ? font : m_pWidgetAcc->GetNode()->GetFontIfExists();
}
bool CXFA_TextProvider::IsCheckButtonAndAutoWidth() {
diff --git a/xfa/fxfa/cxfa_textprovider.h b/xfa/fxfa/cxfa_textprovider.h
index 8a69d87812..423e99cf33 100644
--- a/xfa/fxfa/cxfa_textprovider.h
+++ b/xfa/fxfa/cxfa_textprovider.h
@@ -32,7 +32,7 @@ class CXFA_TextProvider {
CXFA_Node* GetTextNode(bool& bRichText);
CXFA_Para* GetPara();
- CXFA_Font* GetFont();
+ CXFA_Font* GetFontIfExists();
bool IsCheckButtonAndAutoWidth();
bool GetEmbbedObj(bool bURI,
bool bRaw,
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp
index 222de47e89..034f59113d 100644
--- a/xfa/fxfa/cxfa_widgetacc.cpp
+++ b/xfa/fxfa/cxfa_widgetacc.cpp
@@ -513,7 +513,7 @@ void CXFA_WidgetAcc::CalcCaptionSize(CXFA_FFDoc* doc, CFX_SizeF& szCap) {
if (font) {
fFontSize = font->GetFontSize();
} else {
- CXFA_Font* widgetfont = m_pNode->GetFont();
+ CXFA_Font* widgetfont = m_pNode->GetFontIfExists();
if (widgetfont)
fFontSize = widgetfont->GetFontSize();
}
@@ -1292,7 +1292,7 @@ void CXFA_WidgetAcc::SetImageEditImage(
RetainPtr<CFGAS_GEFont> CXFA_WidgetAcc::GetFDEFont(CXFA_FFDoc* doc) {
WideString wsFontName = L"Courier";
uint32_t dwFontStyle = 0;
- CXFA_Font* font = m_pNode->GetFont();
+ CXFA_Font* font = m_pNode->GetFontIfExists();
if (font) {
if (font->IsBold())
dwFontStyle |= FXFONT_BOLD;
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index a8de4907e0..8c0b1956fe 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1546,12 +1546,12 @@ CXFA_Font* CXFA_Node::GetOrCreateFont() {
return JSObject()->GetOrCreateProperty<CXFA_Font>(0, XFA_Element::Font);
}
-CXFA_Font* CXFA_Node::GetFont() const {
+CXFA_Font* CXFA_Node::GetFontIfExists() const {
return JSObject()->GetProperty<CXFA_Font>(0, XFA_Element::Font);
}
float CXFA_Node::GetFontSize() const {
- CXFA_Font* font = GetFont();
+ CXFA_Font* font = GetFontIfExists();
float fFontSize = font ? font->GetFontSize() : 10.0f;
return fFontSize < 0.1f ? 10.0f : fFontSize;
}
@@ -1568,7 +1568,7 @@ float CXFA_Node::GetLineHeight() const {
}
FX_ARGB CXFA_Node::GetTextColor() const {
- CXFA_Font* font = GetFont();
+ CXFA_Font* font = GetFontIfExists();
return font ? font->GetColor() : 0xFF000000;
}
diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h
index 57ab3cae8c..673c430dbb 100644
--- a/xfa/fxfa/parser/cxfa_node.h
+++ b/xfa/fxfa/parser/cxfa_node.h
@@ -240,7 +240,7 @@ class CXFA_Node : public CXFA_Object {
CXFA_Border* GetOrCreateBorderIfPossible();
CXFA_Caption* GetCaptionIfExists() const;
- CXFA_Font* GetFont() const;
+ CXFA_Font* GetFontIfExists() const;
CXFA_Font* GetOrCreateFont();
float GetFontSize() const;
FX_ARGB GetTextColor() const;