summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_node.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2017-11-16 14:07:17 +0000
committerChromium commit bot <commit-bot@chromium.org>2017-11-16 14:07:17 +0000
commit9d47de6b27b167db46b6aba38352fc42a8b6adae (patch)
tree5e29b94aa126a890cf9c2741b505c4dce9dae42e /xfa/fxfa/parser/cxfa_node.cpp
parent0bf9aef229ae2c4f2f16ab753d6d2e9e6d718a44 (diff)
downloadpdfium-9d47de6b27b167db46b6aba38352fc42a8b6adae.tar.xz
Convert TryEnum to return an optional
This CL converts CJX_Node::TryEnum to return a pdfium::Optional instead of a bool with an out parameter. Change-Id: Icc1b063ce51656cc5e467aba358eb9e7d6754fea Reviewed-on: https://pdfium-review.googlesource.com/18512 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_node.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 5a375c7f2a..90579ff5e2 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -568,9 +568,10 @@ XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() {
CXFA_Node* pKeep = GetFirstChildByClass(XFA_Element::Keep);
XFA_ATTRIBUTEENUM eLayoutType = JSNode()->GetEnum(XFA_Attribute::Layout);
if (pKeep) {
- XFA_ATTRIBUTEENUM eIntact;
- if (pKeep->JSNode()->TryEnum(XFA_Attribute::Intact, eIntact, false)) {
- if (eIntact == XFA_ATTRIBUTEENUM_None &&
+ pdfium::Optional<XFA_ATTRIBUTEENUM> intact =
+ pKeep->JSNode()->TryEnum(XFA_Attribute::Intact, false);
+ if (intact) {
+ if (*intact == XFA_ATTRIBUTEENUM_None &&
eLayoutType == XFA_ATTRIBUTEENUM_Row &&
m_pDocument->GetCurVersionMode() < XFA_VERSION_208) {
CXFA_Node* pPreviewRow = GetNodeItem(XFA_NODEITEM_PrevSibling,
@@ -578,24 +579,25 @@ XFA_ATTRIBUTEENUM CXFA_Node::GetIntact() {
if (pPreviewRow &&
pPreviewRow->JSNode()->GetEnum(XFA_Attribute::Layout) ==
XFA_ATTRIBUTEENUM_Row) {
- XFA_ATTRIBUTEENUM eValue;
- if (pKeep->JSNode()->TryEnum(XFA_Attribute::Previous, eValue,
- false) &&
- (eValue == XFA_ATTRIBUTEENUM_ContentArea ||
- eValue == XFA_ATTRIBUTEENUM_PageArea)) {
+ pdfium::Optional<XFA_ATTRIBUTEENUM> value =
+ pKeep->JSNode()->TryEnum(XFA_Attribute::Previous, false);
+ if (value && (*value == XFA_ATTRIBUTEENUM_ContentArea ||
+ *value == XFA_ATTRIBUTEENUM_PageArea)) {
return XFA_ATTRIBUTEENUM_ContentArea;
}
+
CXFA_Node* pNode =
pPreviewRow->GetFirstChildByClass(XFA_Element::Keep);
- if (pNode &&
- pNode->JSNode()->TryEnum(XFA_Attribute::Next, eValue, false) &&
- (eValue == XFA_ATTRIBUTEENUM_ContentArea ||
- eValue == XFA_ATTRIBUTEENUM_PageArea)) {
+ pdfium::Optional<XFA_ATTRIBUTEENUM> ret;
+ if (pNode)
+ ret = pNode->JSNode()->TryEnum(XFA_Attribute::Next, false);
+ if (ret && (*ret == XFA_ATTRIBUTEENUM_ContentArea ||
+ *ret == XFA_ATTRIBUTEENUM_PageArea)) {
return XFA_ATTRIBUTEENUM_ContentArea;
}
}
}
- return eIntact;
+ return *intact;
}
}
switch (GetElementType()) {