summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-11 16:35:12 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-11 16:35:12 +0000
commitce7df754b0608887a923d5083f0bbb999a735fce (patch)
tree03c73474e98e7832eb6601e5933707f3ec087653 /xfa/fxfa/parser
parentb800d149de09ac7d73aa3d1ff8558e33a4c56009 (diff)
downloadpdfium-ce7df754b0608887a923d5083f0bbb999a735fce.tar.xz
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 <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_box.cpp12
-rw-r--r--xfa/fxfa/parser/cxfa_box.h8
-rw-r--r--xfa/fxfa/parser/cxfa_edge.h2
3 files changed, 14 insertions, 8 deletions
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<CXFA_Edge>(nIndex,
XFA_Element::Edge);
@@ -104,15 +104,15 @@ Optional<int32_t> 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<CXFA_Fill>(0, XFA_Element::Fill);
}
-CXFA_Fill* CXFA_Box::GetOrCreateFill() {
+CXFA_Fill* CXFA_Box::GetOrCreateFillIfPossible() {
return JSObject()->GetOrCreateProperty<CXFA_Fill>(0, XFA_Element::Fill);
}
-CXFA_Margin* CXFA_Box::GetMargin() {
+CXFA_Margin* CXFA_Box::GetMarginIfExists() {
return GetChild<CXFA_Margin>(0, XFA_Element::Margin, false);
}
@@ -144,6 +144,8 @@ std::vector<CXFA_Stroke*> CXFA_Box::GetStrokesInternal(bool bNull) {
corner = JSObject()->GetProperty<CXFA_Corner>(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_Stroke*> CXFA_Box::GetStrokesInternal(bool bNull) {
else
edge = JSObject()->GetProperty<CXFA_Edge>(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<XFA_AttributeEnum, bool, float> 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<CXFA_Stroke*> 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;
};