summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_node.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-24 19:51:06 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-24 19:51:06 +0000
commit4327b48d249ad61020e353c794a08b2969949eba (patch)
tree00b387c48e88c4379baab8a4f6fab1c2d6762e21 /xfa/fxfa/parser/cxfa_node.cpp
parent4ad801bdc86405888290037065de5d3a3b447167 (diff)
downloadpdfium-4327b48d249ad61020e353c794a08b2969949eba.tar.xz
Cleanup CreateUIChild pUI usage
This CL cleans up the usage of pUI in CreateUIChild. The node can't be null per spec so ASSERT that's true. Cleanup the search for children to make it clearer what is happening. Change-Id: I856de8ebf89fe0bc61942e7ad2a1131a7878c511 Reviewed-on: https://pdfium-review.googlesource.com/23730 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser/cxfa_node.cpp')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp23
1 files changed, 10 insertions, 13 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 970459f6ed..9a07ef3cac 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -2564,19 +2564,17 @@ std::pair<XFA_Element, CXFA_Node*> CXFA_Node::CreateUIChild() {
break;
}
- CXFA_Node* pUIChild = nullptr;
+ // Both Field and Draw have a UI property. We should always be able to
+ // retrieve or create the UI element. If we can't something is wrong.
CXFA_Ui* pUI = JSObject()->GetOrCreateProperty<CXFA_Ui>(0, XFA_Element::Ui);
- CXFA_Node* pChild = pUI ? pUI->GetFirstChild() : nullptr;
- for (; pChild; pChild = pChild->GetNextSibling()) {
- XFA_Element eChildType = pChild->GetElementType();
- if (eChildType == XFA_Element::Extras ||
- eChildType == XFA_Element::Picture) {
- continue;
- }
+ ASSERT(pUI);
- auto node = CXFA_Node::Create(pChild->GetDocument(), XFA_Element::Ui,
- XFA_PacketType::Form);
- if (node && node->HasPropertyFlags(eChildType, XFA_PROPERTYFLAG_OneOf)) {
+ CXFA_Node* pUIChild = nullptr;
+ // Search through the children of the UI node to see if we have any of our
+ // One-Of entries. If so, that is the node associated with our UI.
+ for (CXFA_Node* pChild = pUI->GetFirstChild(); pChild;
+ pChild = pChild->GetNextSibling()) {
+ if (pUI->IsAOneOfChild(pChild)) {
pUIChild = pChild;
break;
}
@@ -2614,8 +2612,7 @@ std::pair<XFA_Element, CXFA_Node*> CXFA_Node::CreateUIChild() {
value->JSObject()->GetOrCreateProperty<CXFA_Text>(0, XFA_Element::Text);
}
return {eWidgetType,
- pUI ? pUI->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eUIType)
- : nullptr};
+ pUI->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eUIType)};
}
if (eUIType != XFA_Element::Unknown)