diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2018-01-10 16:28:57 +0000 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2018-01-10 16:28:57 +0000 |
commit | 640d8ffad8536c789103892c7a4e69e5d30172c8 (patch) | |
tree | ebd3f4013383a2319c95d29a10097f4bdb28ea30 /xfa/fxfa/cxfa_widgetacc.cpp | |
parent | 594b3eeeaa61a2c0a6d84df3e17ea587f3b15c23 (diff) | |
download | pdfium-640d8ffad8536c789103892c7a4e69e5d30172c8.tar.xz |
Make methods which create nodes more obvious
This CL converts the various methods Get methods which take a boolean
value to explicit Get* and GetOrCreate* methods to make the usage
clearer.
Change-Id: I2af68448b1b69b95713e739bf7fe14a4336d2b65
Reviewed-on: https://pdfium-review.googlesource.com/22590
Reviewed-by: Ryan Harrison <rharrison@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/cxfa_widgetacc.cpp')
-rw-r--r-- | xfa/fxfa/cxfa_widgetacc.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/xfa/fxfa/cxfa_widgetacc.cpp b/xfa/fxfa/cxfa_widgetacc.cpp index 0531c0fcb0..11b7e23d5c 100644 --- a/xfa/fxfa/cxfa_widgetacc.cpp +++ b/xfa/fxfa/cxfa_widgetacc.cpp @@ -219,7 +219,7 @@ std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) { eWidgetType = XFA_Element::Unknown; XFA_Element eUIType = XFA_Element::Unknown; auto* defValue = - pNode->JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value, true); + pNode->JSObject()->GetOrCreateProperty<CXFA_Value>(0, XFA_Element::Value); XFA_Element eValueType = defValue ? defValue->GetChildValueClassID() : XFA_Element::Unknown; switch (eValueType) { @@ -257,7 +257,7 @@ std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) { CXFA_Node* pUIChild = nullptr; CXFA_Ui* pUI = - pNode->JSObject()->GetProperty<CXFA_Ui>(0, XFA_Element::Ui, true); + pNode->JSObject()->GetOrCreateProperty<CXFA_Ui>(0, XFA_Element::Ui); CXFA_Node* pChild = pUI->GetNodeItem(XFA_NODEITEM_FirstChild); for (; pChild; pChild = pChild->GetNodeItem(XFA_NODEITEM_NextSibling)) { XFA_Element eChildType = pChild->GetElementType(); @@ -303,10 +303,11 @@ std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) { if (!pUIChild) { if (eUIType == XFA_Element::Unknown) { eUIType = XFA_Element::TextEdit; - defValue->JSObject()->GetProperty<CXFA_Text>(0, XFA_Element::Text, true); + defValue->JSObject()->GetOrCreateProperty<CXFA_Text>(0, + XFA_Element::Text); } return {eWidgetType, - pUI->JSObject()->GetProperty<CXFA_Node>(0, eUIType, true)}; + pUI->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eUIType)}; } if (eUIType != XFA_Element::Unknown) @@ -349,7 +350,7 @@ std::pair<XFA_Element, CXFA_Node*> CreateUIChild(CXFA_Node* pNode) { eValueType = XFA_Element::Text; break; } - defValue->JSObject()->GetProperty<CXFA_Node>(0, eValueType, true); + defValue->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eValueType); return {eWidgetType, pUIChild}; } @@ -510,7 +511,7 @@ void CXFA_WidgetAcc::CalcCaptionSize(CXFA_FFDoc* doc, CFX_SizeF& szCap) { if (font) { fFontSize = font->GetFontSize(); } else { - CXFA_Font* widgetfont = m_pNode->GetFont(false); + CXFA_Font* widgetfont = m_pNode->GetFont(); if (widgetfont) fFontSize = widgetfont->GetFontSize(); } @@ -1284,7 +1285,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(false); + CXFA_Font* font = m_pNode->GetFont(); if (font) { if (font->IsBold()) dwFontStyle |= FXFONT_BOLD; @@ -1339,7 +1340,7 @@ std::vector<CXFA_Event*> CXFA_WidgetAcc::GetEventByActivity( CXFA_Border* CXFA_WidgetAcc::GetUIBorder() { CXFA_Node* pUIChild = GetUIChild(); return pUIChild ? pUIChild->JSObject()->GetProperty<CXFA_Border>( - 0, XFA_Element::Border, false) + 0, XFA_Element::Border) : nullptr; } @@ -1347,8 +1348,8 @@ CFX_RectF CXFA_WidgetAcc::GetUIMargin() { CXFA_Node* pUIChild = GetUIChild(); CXFA_Margin* mgUI = nullptr; if (pUIChild) { - mgUI = pUIChild->JSObject()->GetProperty<CXFA_Margin>( - 0, XFA_Element::Margin, false); + mgUI = + pUIChild->JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin); } if (!mgUI) |