From d4ae37be89d348ee6668884b71b1a2d1147e574c Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 24 Jan 2018 20:08:18 +0000 Subject: Move retrieval of UIChild earlier in CreateUIChild This CL shifts the retrieval of the UI child earlier in the method so we can group all of the code which sets the widget type. Change-Id: Iabdbd7ae2e6d3f648ce78e93c263be66f62946ba Reviewed-on: https://pdfium-review.googlesource.com/23790 Reviewed-by: Henrique Nakashima Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_node.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index f9452c046c..9312b6dc2b 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -2520,6 +2520,22 @@ std::pair CXFA_Node::CreateUIChild() { XFA_Element eType = GetElementType(); ASSERT(eType == XFA_Element::Field || eType == XFA_Element::Draw); + // 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(0, XFA_Element::Ui); + ASSERT(pUI); + + 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; + } + } + XFA_Element eWidgetType = XFA_Element::Unknown; XFA_Element valueNodeType = XFA_Element::Unknown; @@ -2569,22 +2585,6 @@ std::pair CXFA_Node::CreateUIChild() { } } - // 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(0, XFA_Element::Ui); - ASSERT(pUI); - - 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; - } - } - if (eType == XFA_Element::Draw) { if (pUIChild && pUIChild->GetElementType() == XFA_Element::TextEdit) { eWidgetType = XFA_Element::Text; -- cgit v1.2.3