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/parser/cxfa_box.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/parser/cxfa_box.cpp')
-rw-r--r-- | xfa/fxfa/parser/cxfa_box.cpp | 32 |
1 files changed, 24 insertions, 8 deletions
diff --git a/xfa/fxfa/parser/cxfa_box.cpp b/xfa/fxfa/parser/cxfa_box.cpp index 3bc641bbcd..443362f449 100644 --- a/xfa/fxfa/parser/cxfa_box.cpp +++ b/xfa/fxfa/parser/cxfa_box.cpp @@ -82,8 +82,10 @@ int32_t CXFA_Box::CountEdges() { } CXFA_Edge* CXFA_Box::GetEdge(int32_t nIndex) { - return JSObject()->GetProperty<CXFA_Edge>(nIndex, XFA_Element::Edge, - nIndex == 0); + if (nIndex == 0) + return JSObject()->GetOrCreateProperty<CXFA_Edge>(nIndex, + XFA_Element::Edge); + return JSObject()->GetProperty<CXFA_Edge>(nIndex, XFA_Element::Edge); } std::vector<CXFA_Stroke*> CXFA_Box::GetStrokes() { @@ -102,8 +104,12 @@ Optional<int32_t> CXFA_Box::GetSweepAngle() { return JSObject()->TryInteger(XFA_Attribute::SweepAngle, false); } -CXFA_Fill* CXFA_Box::GetFill(bool bModified) { - return JSObject()->GetProperty<CXFA_Fill>(0, XFA_Element::Fill, bModified); +CXFA_Fill* CXFA_Box::GetFill() const { + return JSObject()->GetProperty<CXFA_Fill>(0, XFA_Element::Fill); +} + +CXFA_Fill* CXFA_Box::GetOrCreateFill() { + return JSObject()->GetOrCreateProperty<CXFA_Fill>(0, XFA_Element::Fill); } CXFA_Margin* CXFA_Box::GetMargin() { @@ -130,8 +136,14 @@ std::vector<CXFA_Stroke*> CXFA_Box::GetStrokesInternal(bool bNull) { strokes.resize(8); for (int32_t i = 0, j = 0; i < 4; i++) { - CXFA_Corner* corner = - JSObject()->GetProperty<CXFA_Corner>(i, XFA_Element::Corner, i == 0); + CXFA_Corner* corner; + if (i == 0) { + corner = + JSObject()->GetOrCreateProperty<CXFA_Corner>(i, XFA_Element::Corner); + } else { + corner = JSObject()->GetProperty<CXFA_Corner>(i, XFA_Element::Corner); + } + if (corner || i == 0) { strokes[j] = corner; } else if (!bNull) { @@ -142,8 +154,12 @@ std::vector<CXFA_Stroke*> CXFA_Box::GetStrokesInternal(bool bNull) { } j++; - CXFA_Edge* edge = - JSObject()->GetProperty<CXFA_Edge>(i, XFA_Element::Edge, i == 0); + CXFA_Edge* edge; + if (i == 0) + edge = JSObject()->GetOrCreateProperty<CXFA_Edge>(i, XFA_Element::Edge); + else + edge = JSObject()->GetProperty<CXFA_Edge>(i, XFA_Element::Edge); + if (edge || i == 0) { strokes[j] = edge; } else if (!bNull) { |