summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser/cxfa_node.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2018-01-24 16:01:54 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-01-24 16:01:54 +0000
commit701d21682af1aa3f7f449d2da9681ee01dc8990d (patch)
tree1a391a0230fae55d36066be9fb68579a2ef640f8 /xfa/fxfa/parser/cxfa_node.cpp
parent35347ab00b5a768e37d5b3a49ddb5b7dbeb6a53e (diff)
downloadpdfium-701d21682af1aa3f7f449d2da9681ee01dc8990d.tar.xz
Update code to assume a Value node exists.
When we retrieve the first Value node from a Field or a Draw element it either must exist, or must be created. If that doesn't happen something has gone very wrong. Change-Id: I818aaf9d361336c898035fe542e5b37a33fef0ea Reviewed-on: https://pdfium-review.googlesource.com/23710 Reviewed-by: Ryan Harrison <rharrison@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.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 1fd96f427b..970459f6ed 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -2522,10 +2522,15 @@ std::pair<XFA_Element, CXFA_Node*> CXFA_Node::CreateUIChild() {
XFA_Element eWidgetType = XFA_Element::Unknown;
XFA_Element eUIType = XFA_Element::Unknown;
- auto* defValue =
+
+ // Both Field and Draw nodes have a Value child. So, we should either always
+ // have it, or always create it. If we don't get the Value child for some
+ // reason something has gone really wrong.
+ CXFA_Value* value =
JSObject()->GetOrCreateProperty<CXFA_Value>(0, XFA_Element::Value);
- XFA_Element eValueType =
- defValue ? defValue->GetChildValueClassID() : XFA_Element::Unknown;
+ ASSERT(value);
+
+ XFA_Element eValueType = value->GetChildValueClassID();
switch (eValueType) {
case XFA_Element::Boolean:
eUIType = XFA_Element::CheckButton;
@@ -2606,10 +2611,7 @@ std::pair<XFA_Element, CXFA_Node*> CXFA_Node::CreateUIChild() {
if (!pUIChild) {
if (eUIType == XFA_Element::Unknown) {
eUIType = XFA_Element::TextEdit;
- if (defValue) {
- defValue->JSObject()->GetOrCreateProperty<CXFA_Text>(0,
- XFA_Element::Text);
- }
+ value->JSObject()->GetOrCreateProperty<CXFA_Text>(0, XFA_Element::Text);
}
return {eWidgetType,
pUI ? pUI->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eUIType)
@@ -2656,8 +2658,7 @@ std::pair<XFA_Element, CXFA_Node*> CXFA_Node::CreateUIChild() {
eValueType = XFA_Element::Text;
break;
}
- if (defValue)
- defValue->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eValueType);
+ value->JSObject()->GetOrCreateProperty<CXFA_Node>(0, eValueType);
return {eWidgetType, pUIChild};
}