From ce7df754b0608887a923d5083f0bbb999a735fce Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Thu, 11 Jan 2018 16:35:12 +0000 Subject: Rename CXFA_Box methods to make return clearer This CL renames the methods in CXFA_Box to make it clearer they can return nullptr. Change-Id: I521c0e06af306f69e390a4057cabb7777a0d72f5 Reviewed-on: https://pdfium-review.googlesource.com/22740 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_box.cpp | 12 ++++++++---- xfa/fxfa/parser/cxfa_box.h | 8 ++++---- xfa/fxfa/parser/cxfa_edge.h | 2 ++ 3 files changed, 14 insertions(+), 8 deletions(-) (limited to 'xfa/fxfa/parser') diff --git a/xfa/fxfa/parser/cxfa_box.cpp b/xfa/fxfa/parser/cxfa_box.cpp index 443362f449..5f8bed9aa1 100644 --- a/xfa/fxfa/parser/cxfa_box.cpp +++ b/xfa/fxfa/parser/cxfa_box.cpp @@ -81,7 +81,7 @@ int32_t CXFA_Box::CountEdges() { return CountChildren(XFA_Element::Edge, false); } -CXFA_Edge* CXFA_Box::GetEdge(int32_t nIndex) { +CXFA_Edge* CXFA_Box::GetEdgeIfExists(int32_t nIndex) { if (nIndex == 0) return JSObject()->GetOrCreateProperty(nIndex, XFA_Element::Edge); @@ -104,15 +104,15 @@ Optional CXFA_Box::GetSweepAngle() { return JSObject()->TryInteger(XFA_Attribute::SweepAngle, false); } -CXFA_Fill* CXFA_Box::GetFill() const { +CXFA_Fill* CXFA_Box::GetFillIfExists() const { return JSObject()->GetProperty(0, XFA_Element::Fill); } -CXFA_Fill* CXFA_Box::GetOrCreateFill() { +CXFA_Fill* CXFA_Box::GetOrCreateFillIfPossible() { return JSObject()->GetOrCreateProperty(0, XFA_Element::Fill); } -CXFA_Margin* CXFA_Box::GetMargin() { +CXFA_Margin* CXFA_Box::GetMarginIfExists() { return GetChild(0, XFA_Element::Margin, false); } @@ -144,6 +144,8 @@ std::vector CXFA_Box::GetStrokesInternal(bool bNull) { corner = JSObject()->GetProperty(i, XFA_Element::Corner); } + // TODO(dsinclair): If i == 0 and GetOrCreateProperty failed, we can end up + // with a null corner in the first position. if (corner || i == 0) { strokes[j] = corner; } else if (!bNull) { @@ -160,6 +162,8 @@ std::vector CXFA_Box::GetStrokesInternal(bool bNull) { else edge = JSObject()->GetProperty(i, XFA_Element::Edge); + // TODO(dsinclair): If i == 0 and GetOrCreateProperty failed, we can end up + // with a null edge in the first position. if (edge || i == 0) { strokes[j] = edge; } else if (!bNull) { diff --git a/xfa/fxfa/parser/cxfa_box.h b/xfa/fxfa/parser/cxfa_box.h index c85d0164af..216a981c83 100644 --- a/xfa/fxfa/parser/cxfa_box.h +++ b/xfa/fxfa/parser/cxfa_box.h @@ -30,10 +30,10 @@ class CXFA_Box : public CXFA_Node { std::tuple Get3DStyle(); int32_t CountEdges(); - CXFA_Edge* GetEdge(int32_t nIndex); - CXFA_Fill* GetFill() const; - CXFA_Fill* GetOrCreateFill(); - CXFA_Margin* GetMargin(); + CXFA_Edge* GetEdgeIfExists(int32_t nIndex); + CXFA_Fill* GetFillIfExists() const; + CXFA_Fill* GetOrCreateFillIfPossible(); + CXFA_Margin* GetMarginIfExists(); std::vector GetStrokes(); diff --git a/xfa/fxfa/parser/cxfa_edge.h b/xfa/fxfa/parser/cxfa_edge.h index 8bf9f6ea28..36fee55624 100644 --- a/xfa/fxfa/parser/cxfa_edge.h +++ b/xfa/fxfa/parser/cxfa_edge.h @@ -11,6 +11,8 @@ class CXFA_Edge : public CXFA_Stroke { public: + static constexpr FX_ARGB kDefaultColor = 0xFF000000; + CXFA_Edge(CXFA_Document* doc, XFA_PacketType packet); ~CXFA_Edge() override; }; -- cgit v1.2.3