summaryrefslogtreecommitdiff
path: root/xfa/fxfa/parser
diff options
context:
space:
mode:
authorHenrique Nakashima <hnakashima@chromium.org>2018-05-07 22:44:26 +0000
committerChromium commit bot <commit-bot@chromium.org>2018-05-07 22:44:26 +0000
commitc732e9aa64a82c06c0ad369088d0481dd2636b86 (patch)
treee496e58b0c2676e8182a7e01f68742037a1fb814 /xfa/fxfa/parser
parentaff0dfd7f4b8644ff34a4e4334ee2b25555a6e7a (diff)
downloadpdfium-c732e9aa64a82c06c0ad369088d0481dd2636b86.tar.xz
Restore logic of CreateChildUIAndValueNodesIfNeeded().
CreateUIChild() was changed and renamed to CreateChildUIAndValueNodesIfNeeded() in: https://pdfium-review.googlesource.com/c/pdfium/+/24390 This caused some bugs but it's too far back for a rollback. This cl restores the logic of CreateUIChild() keeping the new signature. Bug: chromium:838994 Change-Id: I44ce741fdb90f8b0fd11379b5e881e376c307f0c Reviewed-on: https://pdfium-review.googlesource.com/32090 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
Diffstat (limited to 'xfa/fxfa/parser')
-rw-r--r--xfa/fxfa/parser/cxfa_node.cpp87
1 files changed, 40 insertions, 47 deletions
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index e2bde5ca00..91e78dc485 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -2355,10 +2355,8 @@ CXFA_Node::CreateChildUIAndValueNodesIfNeeded() {
}
}
- XFA_FFWidgetType ff_widget_type =
- pUIChild ? pUIChild->GetDefaultFFWidgetType() : XFA_FFWidgetType::kNone;
- XFA_Element ui_child_type =
- pUIChild ? pUIChild->GetElementType() : XFA_Element::Unknown;
+ XFA_FFWidgetType widget_type = XFA_FFWidgetType::kNone;
+ XFA_Element expected_ui_child_type = XFA_Element::Unknown;
// 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
@@ -2371,82 +2369,77 @@ CXFA_Node::CreateChildUIAndValueNodesIfNeeded() {
// that child must be the type we want to use.
CXFA_Node* child = value->GetFirstChild();
if (child) {
- XFA_FFWidgetType tmp_widget_type = XFA_FFWidgetType::kNone;
switch (child->GetElementType()) {
case XFA_Element::Boolean:
- ui_child_type = XFA_Element::CheckButton;
- tmp_widget_type = XFA_FFWidgetType::kCheckButton;
+ expected_ui_child_type = XFA_Element::CheckButton;
break;
case XFA_Element::Integer:
case XFA_Element::Decimal:
case XFA_Element::Float:
- ui_child_type = XFA_Element::NumericEdit;
- tmp_widget_type = XFA_FFWidgetType::kNumericEdit;
+ expected_ui_child_type = XFA_Element::NumericEdit;
break;
case XFA_Element::ExData:
case XFA_Element::Text:
- ui_child_type = XFA_Element::TextEdit;
- tmp_widget_type = XFA_FFWidgetType::kTextEdit;
+ expected_ui_child_type = XFA_Element::TextEdit;
+ widget_type = XFA_FFWidgetType::kText;
break;
case XFA_Element::Date:
case XFA_Element::Time:
case XFA_Element::DateTime:
- ui_child_type = XFA_Element::DateTimeEdit;
- tmp_widget_type = XFA_FFWidgetType::kDateTimeEdit;
+ expected_ui_child_type = XFA_Element::DateTimeEdit;
break;
case XFA_Element::Image:
- ui_child_type = XFA_Element::ImageEdit;
- tmp_widget_type = XFA_FFWidgetType::kImageEdit;
+ expected_ui_child_type = XFA_Element::ImageEdit;
+ widget_type = XFA_FFWidgetType::kImage;
break;
case XFA_Element::Arc:
- ui_child_type = XFA_Element::DefaultUi;
- tmp_widget_type = XFA_FFWidgetType::kArc;
+ expected_ui_child_type = XFA_Element::DefaultUi;
+ widget_type = XFA_FFWidgetType::kArc;
break;
case XFA_Element::Line:
- ui_child_type = XFA_Element::DefaultUi;
- tmp_widget_type = XFA_FFWidgetType::kLine;
+ expected_ui_child_type = XFA_Element::DefaultUi;
+ widget_type = XFA_FFWidgetType::kLine;
break;
case XFA_Element::Rectangle:
- ui_child_type = XFA_Element::DefaultUi;
- tmp_widget_type = XFA_FFWidgetType::kRectangle;
+ expected_ui_child_type = XFA_Element::DefaultUi;
+ widget_type = XFA_FFWidgetType::kRectangle;
break;
default:
NOTREACHED();
break;
}
-
- // Only set the FFWidget if we didn't already set it from the UI child.
- if (ff_widget_type == XFA_FFWidgetType::kNone)
- ff_widget_type = tmp_widget_type;
- }
-
- if (!pUIChild) {
- if (ui_child_type == XFA_Element::Unknown)
- ui_child_type = XFA_Element::TextEdit;
-
- pUIChild = CreateUINodeIfNeeded(pUI, ui_child_type);
- if (ff_widget_type == XFA_FFWidgetType::kNone)
- ff_widget_type = pUIChild->GetDefaultFFWidgetType();
}
- // When handling draw children, change the image and text edit items to
- // be non-edit.
if (eType == XFA_Element::Draw) {
- switch (pUIChild->GetElementType()) {
- case XFA_Element::TextEdit:
- ff_widget_type = XFA_FFWidgetType::kText;
- break;
- case XFA_Element::ImageEdit:
- ff_widget_type = XFA_FFWidgetType::kImage;
- break;
- default:
- break;
+ if (pUIChild && pUIChild->GetElementType() == XFA_Element::TextEdit) {
+ widget_type = XFA_FFWidgetType::kText;
+ } else if (pUIChild &&
+ pUIChild->GetElementType() == XFA_Element::ImageEdit) {
+ widget_type = XFA_FFWidgetType::kImage;
+ } else if (widget_type == XFA_FFWidgetType::kNone) {
+ widget_type = XFA_FFWidgetType::kText;
+ }
+ } else if (eType == XFA_Element::Field) {
+ if (pUIChild && pUIChild->GetElementType() == XFA_Element::DefaultUi) {
+ widget_type = XFA_FFWidgetType::kTextEdit;
+ } else if (pUIChild) {
+ widget_type = pUIChild->GetDefaultFFWidgetType();
+ } else if (expected_ui_child_type == XFA_Element::Unknown) {
+ widget_type = XFA_FFWidgetType::kTextEdit;
}
+ } else {
+ NOTREACHED();
+ }
+
+ if (!pUIChild) {
+ if (expected_ui_child_type == XFA_Element::Unknown)
+ expected_ui_child_type = XFA_Element::TextEdit;
+ pUIChild = pUI->JSObject()->GetOrCreateProperty<CXFA_Node>(
+ 0, expected_ui_child_type);
}
- ASSERT(ff_widget_type != XFA_FFWidgetType::kNone);
CreateValueNodeIfNeeded(value, pUIChild);
- return {ff_widget_type, pUI};
+ return {widget_type, pUI};
}
XFA_FFWidgetType CXFA_Node::GetDefaultFFWidgetType() const {