From 73eae271218c69c1b55f4ed8606975e612d30673 Mon Sep 17 00:00:00 2001 From: Dan Sinclair Date: Wed, 24 Jan 2018 16:01:05 +0000 Subject: Clarify CreateUIChild is only for Field or Draw elements This CL changes the code to only call CreateUIChild for Field and Draw elements. Other types are handled all the callsite. Change-Id: I2dd2553c14ebc1f0849b3bfd311e75ad8922aa0d Reviewed-on: https://pdfium-review.googlesource.com/23670 Reviewed-by: Ryan Harrison Commit-Queue: dsinclair --- xfa/fxfa/parser/cxfa_node.cpp | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 58d751e8e3..9ceedcc41e 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -457,11 +457,9 @@ void ReorderDataNodes(const std::set& sSet1, std::pair CreateUIChild(CXFA_Node* pNode) { XFA_Element eType = pNode->GetElementType(); - XFA_Element eWidgetType = eType; - if (eType != XFA_Element::Field && eType != XFA_Element::Draw) - return {eWidgetType, nullptr}; + ASSERT(eType == XFA_Element::Field || eType == XFA_Element::Draw); - eWidgetType = XFA_Element::Unknown; + XFA_Element eWidgetType = XFA_Element::Unknown; XFA_Element eUIType = XFA_Element::Unknown; auto* defValue = pNode->JSObject()->GetOrCreateProperty(0, XFA_Element::Value); @@ -2666,8 +2664,16 @@ Optional CXFA_Node::GetBarcodeAttribute_WideNarrowRatio() { } CXFA_Node* CXFA_Node::GetUIChild() { - if (m_eUIType == XFA_Element::Unknown) + if (m_eUIType != XFA_Element::Unknown) + return m_pUiChildNode; + + XFA_Element type = GetElementType(); + if (type == XFA_Element::Field || type == XFA_Element::Draw) { std::tie(m_eUIType, m_pUiChildNode) = CreateUIChild(this); + } else { + m_eUIType = GetElementType(); + m_pUiChildNode = nullptr; + } return m_pUiChildNode; } -- cgit v1.2.3