summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_node.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-10 16:28:57 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-10 16:28:57 +0000
commit640d8ffad8536c789103892c7a4e69e5d30172c8 (patch)
treeebd3f4013383a2319c95d29a10097f4bdb28ea30 /xfa/fxfa/parser/cxfa_node.cpp
parent594b3eeeaa61a2c0a6d84df3e17ea587f3b15c23 (diff)
downloadpdfium-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/parser/cxfa_node.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp68
1 files changed, 39 insertions, 29 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 1da6f56781..e3ece5d57a 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -1556,46 +1556,54 @@ int32_t CXFA_Node::GetRotate() {
return degrees ? XFA_MapRotation(*degrees) / 90 * 90 : 0;
}
-CXFA_Border* CXFA_Node::GetBorder(bool bModified) {
- return JSObject()->GetProperty<CXFA_Border>(0, XFA_Element::Border,
- bModified);
+CXFA_Border* CXFA_Node::GetBorder() const {
+ return JSObject()->GetProperty<CXFA_Border>(0, XFA_Element::Border);
}
-CXFA_Caption* CXFA_Node::GetCaption() {
- return JSObject()->GetProperty<CXFA_Caption>(0, XFA_Element::Caption, false);
+CXFA_Border* CXFA_Node::GetOrCreateBorder() {
+ return JSObject()->GetOrCreateProperty<CXFA_Border>(0, XFA_Element::Border);
}
-CXFA_Font* CXFA_Node::GetFont(bool bModified) {
- return JSObject()->GetProperty<CXFA_Font>(0, XFA_Element::Font, bModified);
+CXFA_Caption* CXFA_Node::GetCaption() const {
+ return JSObject()->GetProperty<CXFA_Caption>(0, XFA_Element::Caption);
}
-float CXFA_Node::GetFontSize() {
- CXFA_Font* font = GetFont(false);
+CXFA_Font* CXFA_Node::GetOrCreateFont() {
+ return JSObject()->GetOrCreateProperty<CXFA_Font>(0, XFA_Element::Font);
+}
+
+CXFA_Font* CXFA_Node::GetFont() const {
+ return JSObject()->GetProperty<CXFA_Font>(0, XFA_Element::Font);
+}
+
+float CXFA_Node::GetFontSize() const {
+ CXFA_Font* font = GetFont();
float fFontSize = font ? font->GetFontSize() : 10.0f;
return fFontSize < 0.1f ? 10.0f : fFontSize;
}
-float CXFA_Node::GetLineHeight() {
+float CXFA_Node::GetLineHeight() const {
float fLineHeight = 0;
CXFA_Para* para = GetPara();
if (para)
fLineHeight = para->GetLineHeight();
+
if (fLineHeight < 1)
fLineHeight = GetFontSize() * 1.2f;
return fLineHeight;
}
-FX_ARGB CXFA_Node::GetTextColor() {
- CXFA_Font* font = GetFont(false);
+FX_ARGB CXFA_Node::GetTextColor() const {
+ CXFA_Font* font = GetFont();
return font ? font->GetColor() : 0xFF000000;
}
-CXFA_Margin* CXFA_Node::GetMargin() {
- return JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin, false);
+CXFA_Margin* CXFA_Node::GetMargin() const {
+ return JSObject()->GetProperty<CXFA_Margin>(0, XFA_Element::Margin);
}
-CXFA_Para* CXFA_Node::GetPara() {
- return JSObject()->GetProperty<CXFA_Para>(0, XFA_Element::Para, false);
+CXFA_Para* CXFA_Node::GetPara() const {
+ return JSObject()->GetProperty<CXFA_Para>(0, XFA_Element::Para);
}
bool CXFA_Node::IsOpenAccess() {
@@ -1611,26 +1619,28 @@ bool CXFA_Node::IsOpenAccess() {
CXFA_Value* CXFA_Node::GetDefaultValue() {
CXFA_Node* pTemNode = GetTemplateNode();
- return pTemNode->JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value,
- false);
+ return pTemNode->JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value);
+}
+
+CXFA_Value* CXFA_Node::GetFormValue() const {
+ return JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value);
}
-CXFA_Value* CXFA_Node::GetFormValue() {
- return JSObject()->GetProperty<CXFA_Value>(0, XFA_Element::Value, false);
+CXFA_Calculate* CXFA_Node::GetCalculate() const {
+ return JSObject()->GetProperty<CXFA_Calculate>(0, XFA_Element::Calculate);
}
-CXFA_Calculate* CXFA_Node::GetCalculate() {
- return JSObject()->GetProperty<CXFA_Calculate>(0, XFA_Element::Calculate,
- false);
+CXFA_Validate* CXFA_Node::GetValidate() const {
+ return JSObject()->GetProperty<CXFA_Validate>(0, XFA_Element::Validate);
}
-CXFA_Validate* CXFA_Node::GetValidate(bool bModified) {
- return JSObject()->GetProperty<CXFA_Validate>(0, XFA_Element::Validate,
- bModified);
+CXFA_Validate* CXFA_Node::GetOrCreateValidate() {
+ return JSObject()->GetOrCreateProperty<CXFA_Validate>(0,
+ XFA_Element::Validate);
}
-CXFA_Bind* CXFA_Node::GetBind() {
- return JSObject()->GetProperty<CXFA_Bind>(0, XFA_Element::Bind, false);
+CXFA_Bind* CXFA_Node::GetBind() const {
+ return JSObject()->GetProperty<CXFA_Bind>(0, XFA_Element::Bind);
}
Optional<float> CXFA_Node::TryWidth() {
@@ -1890,7 +1900,7 @@ int32_t CXFA_Node::ProcessValidate(CXFA_FFDocView* docView, int32_t iFlags) {
if (GetElementType() == XFA_Element::Draw)
return XFA_EVENTERROR_NotExist;
- CXFA_Validate* validate = GetValidate(false);
+ CXFA_Validate* validate = GetValidate();
if (!validate)
return XFA_EVENTERROR_NotExist;