summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_itemlayoutprocessor.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_itemlayoutprocessor.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_itemlayoutprocessor.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
index 332bed2a9f..bf950ab543 100644
--- a/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
+++ b/xfa/fxfa/parser/cxfa_itemlayoutprocessor.cpp
@@ -483,9 +483,10 @@ float InsertPendingItems(CXFA_ItemLayoutProcessor* pProcessor,
XFA_ATTRIBUTEENUM GetLayout(CXFA_Node* pFormNode, bool* bRootForceTb) {
*bRootForceTb = false;
- XFA_ATTRIBUTEENUM eLayoutMode;
- if (pFormNode->JSNode()->TryEnum(XFA_Attribute::Layout, eLayoutMode, false))
- return eLayoutMode;
+ pdfium::Optional<XFA_ATTRIBUTEENUM> layoutMode =
+ pFormNode->JSNode()->TryEnum(XFA_Attribute::Layout, false);
+ if (layoutMode)
+ return *layoutMode;
CXFA_Node* pParentNode = pFormNode->GetNodeItem(XFA_NODEITEM_Parent);
if (pParentNode && pParentNode->GetElementType() == XFA_Element::Form) {
@@ -510,14 +511,15 @@ bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) {
CXFA_Node* pKeep = pCurNode->GetFirstChildByClass(XFA_Element::Keep);
if (pKeep) {
- XFA_ATTRIBUTEENUM ePrevious;
XFA_Attribute eKeepType = XFA_Attribute::Previous;
if (!bPreFind)
eKeepType = XFA_Attribute::Next;
- if (pKeep->JSNode()->TryEnum(eKeepType, ePrevious, false)) {
- if (ePrevious == XFA_ATTRIBUTEENUM_ContentArea ||
- ePrevious == XFA_ATTRIBUTEENUM_PageArea) {
+ pdfium::Optional<XFA_ATTRIBUTEENUM> previous =
+ pKeep->JSNode()->TryEnum(eKeepType, false);
+ if (previous) {
+ if (*previous == XFA_ATTRIBUTEENUM_ContentArea ||
+ *previous == XFA_ATTRIBUTEENUM_PageArea) {
return true;
}
}
@@ -531,11 +533,12 @@ bool ExistContainerKeep(CXFA_Node* pCurNode, bool bPreFind) {
if (!bPreFind)
eKeepType = XFA_Attribute::Previous;
- XFA_ATTRIBUTEENUM eNext;
- if (!pKeep->JSNode()->TryEnum(eKeepType, eNext, false))
+ pdfium::Optional<XFA_ATTRIBUTEENUM> next =
+ pKeep->JSNode()->TryEnum(eKeepType, false);
+ if (!next)
return false;
- if (eNext == XFA_ATTRIBUTEENUM_ContentArea ||
- eNext == XFA_ATTRIBUTEENUM_PageArea) {
+ if (*next == XFA_ATTRIBUTEENUM_ContentArea ||
+ *next == XFA_ATTRIBUTEENUM_PageArea) {
return true;
}
return false;