Revert "Remove CXFA nodes instead of CFX_XML nodes"
This reverts commit 2b4ad9ff5bf1727d12ef2bcce7e3fa925bbe8978.
Reason for revert: Causing crashes on windows:
Rendering PDF file E:\b\build\slave\windows_xfa\build\pdfium\out\debug_xfa_v8\gen\pdfium\testing\pixel\static_list_box_caption.pdf.
==== C stack trace ===============================
diff: 0.00% passed
std::tuple<CXFA_Node * __ptr64 const & __ptr64>::tuple<CXFA_Node * __ptr64 const & __ptr64> [0x0000000141785700+48]
??@875fbed02c72fe689afc0ad24a247bf8@ [0x000000013F7BB443+131]
??$_Buynode@AEBUpiecewise_construct_t@std@@V?$tuple@AEBQEAVCXFA_Node@@@2@V?$tuple@$$V@2@@?$_Tree_comp_alloc@V?$_Tmap_traits@PEAVCXFA_Node@@V?$unique_ptr@V?$map@IV?$unique_ptr@U?$pair@V?$set@PEAVCXFA_Node@@U?$less@PEAVCXFA_Node@@@std@@V?$allocator@PEAVCXFA [0x0000000141785309+169]
??@2b14910fe4cc3866ca68e10bfed05253@ [0x000000013F7CCB09+185]
CJX_Object::SetAttributeValue [0x000000013FAE0F7E+302]
v8::internal::compiler::Int64Lowering::LowerNode [0x000000013FBB04C0+31920]
CXFA_Document::DataMerge_CopyContainer [0x00000001417A43A3+9603]
CXFA_Document::DataMerge_CopyContainer [0x00000001417A2048+552]
CXFA_Document::DataMerge_CopyContainer [0x00000001417A3436+5654]
CXFA_Document::DataMerge_CopyContainer [0x00000001417A1FEE+462]
CXFA_Document::DoDataMerge [0x00000001417A5F96+3142]
CXFA_FFDocView::StartLayout [0x00000001416BECCD+93]
CPDFXFA_Context::LoadXFADoc [0x000000014169162D+669]
FPDF_LoadXFA [0x0000000140AC5A2A+42]
std::_Compressed_pair<std::default_delete<CFWL_WidgetProperties>,CFWL_WidgetProperties * __ptr64,1>::_Get_first [0x000000013F72A648+1432]
main [0x000000013F727C05+1685]
invoke_main [0x0000000141CDB924+52] (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:79)
__scrt_common_main_seh [0x0000000141CDB817+295] (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283)
__scrt_common_main [0x0000000141CDB6DE+14] (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:326)
mainCRTStartup [0x0000000141CDB9B9+9] (f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp:17)
BaseThreadInitThunk [0x0000000077415A4D+13]
RtlUserThreadStart [0x000000007764B831+33]
Rendering PDF file E:\b\build\slave\windows_xfa\build\pdfium\out\debug_xfa_v8\gen\pdfium\testing\pixel\resolve_nodes.pdf.
==== C stack trace ===============================
std::tuple<CXFA_Node * __ptr64 const & __ptr64>::tuple<CXFA_Node * __ptr64 const & __ptr64> [0x0000000141785700+48]
??@875fbed02c72fe689afc0ad24a247bf8@ [0x000000013F7BB443+131]
??$_Buynode@AEBUpiecewise_construct_t@std@@V?$tuple@AEBQEAVCXFA_Node@@@2@V?$tuple@$$V@2@@?$_Tree_comp_alloc@V?$_Tmap_traits@PEAVCXFA_Node@@V?$unique_ptr@V?$map@IV?$unique_ptr@U?$pair@V?$set@PEAVCXFA_Node@@U?$less@PEAVCXFA_Node@@@std@@V?$allocator@PEAVCXFA [0x0000000141785309+169]
??@2b14910fe4cc3866ca68e10bfed05253@ [0x000000013F7CCB09+185]
CJX_Object::SetAttributeValue [0x000000013FAE0F7E+302]
v8::internal::compiler::Int64Lowering::LowerNode [0x000000013FBB03F6+31718]
CXFA_Document::DataMerge_UpdateBindingRelations [0x00000001417A48DA+1066]
CXFA_Document::DataMerge_UpdateBindingRelations [0x00000001417A4ED8+2600]
CXFA_Document::DataMerge_UpdateBindingRelations [0x00000001417A4ED8+2600]
CXFA_Document::DataMerge_UpdateBindingRelations [0x00000001417A4ED8+2600]
CXFA_Document::DataMerge_UpdateBindingRelations [0x00000001417A4ED8+2600]
CXFA_Document::DataMerge_UpdateBindingRelations [0x00000001417A4512+98]
CXFA_Document::DoDataMerge [0x00000001417A5FF8+3240]
CXFA_FFDocView::StartLayout [0x00000001416BECCD+93]
CPDFXFA_Context::LoadXFADoc [0x000000014169162D+669]
FPDF_LoadXFA [0x0000000140AC5A2A+42]
std::_Compressed_pair<std::default_delete<CFWL_WidgetProperties>,CFWL_WidgetProperties * __ptr64,1>::_Get_first [0x000000013F72A648+1432]
main [0x000000013F727C05+1685]
invoke_main [0x0000000141CDB924+52] (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:79)
__scrt_common_main_seh [0x0000000141CDB817+295] (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283)
__scrt_common_main [0x0000000141CDB6DE+14] (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:326)
mainCRTStartup [0x0000000141CDB9B9+9] (f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp:17)
BaseThreadInitThunk [0x0000000077415A4D+13]
RtlUserThreadStart [0x000000007764B831+33]
FAILURE: static_list_box_caption.pdf; Command '['E:\\b\\build\\slave\\windows_xfa\\build\\pdfium\\out\\debug_xfa_v8\\pdfium_test.exe', '--send-events', '--png', '--md5', 'E:\\b\\build\\slave\\windows_xfa\\build\\pdfium\\out\\debug_xfa_v8\\gen\\pdfium\\testing\\pixel\\static_list_box_caption.pdf']' returned non-zero exit status -1073741819
Rendering PDF file E:\b\build\slave\windows_xfa\build\pdfium\out\debug_xfa_v8\gen\pdfium\testing\pixel\standard_symbols.pdf.
==== C stack trace ===============================
std::tuple<CXFA_Node * __ptr64 const & __ptr64>::tuple<CXFA_Node * __ptr64 const & __ptr64> [0x0000000141785700+48]
FAILURE: resolve_nodes.pdf; Command '['E:\\b\\build\\slave\\windows_xfa\\build\\pdfium\\out\\debug_xfa_v8\\pdfium_test.exe', '--send-events', '--png', '--md5', 'E:\\b\\build\\slave\\windows_xfa\\build\\pdfium\\out\\debug_xfa_v8\\gen\\pdfium\\testing\\pixel\\resolve_nodes.pdf']' returned non-zero exit status -1073741819
??@875fbed02c72fe689afc0ad24a247bf8@ [0x000000013F7BB443+131]
??$_Buynode@AEBUpiecewise_construct_t@std@@V?$tuple@AEBQEAVCXFA_Node@@@2@V?$tuple@$$V@2@@?$_Tree_comp_alloc@V?$_Tmap_traits@PEAVCXFA_Node@@V?$unique_ptr@V?$map@IV?$unique_ptr@U?$pair@V?$set@PEAVCXFA_Node@@U?$less@PEAVCXFA_Node@@@std@@V?$allocator@PEAVCXFA [0x0000000141785309+169]
??@2b14910fe4cc3866ca68e10bfed05253@ [0x000000013F7CCB09+185]
CJX_Object::SetAttributeValue [0x000000013FAE0F7E+302]
v8::internal::compiler::Int64Lowering::LowerNode [0x000000013FBB04C0+31920]
CXFA_Document::DataMerge_CopyContainer [0x00000001417A43A3+9603]
CXFA_Document::DataMerge_CopyContainer [0x00000001417A2048+552]
CXFA_Document::DataMerge_CopyContainer [0x00000001417A3436+5654]
CXFA_Document::DataMerge_CopyContainer [0x00000001417A1FEE+462]
CXFA_Document::DoDataMerge [0x00000001417A5F96+3142]
CXFA_FFDocView::StartLayout [0x00000001416BECCD+93]
CPDFXFA_Context::LoadXFADoc [0x000000014169162D+669]
FPDF_LoadXFA [0x0000000140AC5A2A+42]
std::_Compressed_pair<std::default_delete<CFWL_WidgetProperties>,CFWL_WidgetProperties * __ptr64,1>::_Get_first [0x000000013F72A648+1432]
main [0x000000013F727C05+1685]
invoke_main [0x0000000141CDB924+52] (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:79)
__scrt_common_main_seh [0x0000000141CDB817+295] (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:283)
__scrt_common_main [0x0000000141CDB6DE+14] (f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:326)
mainCRTStartup [0x0000000141CDB9B9+9] (f:\dd\vctools\crt\vcstartup\src\startup\exe_main.cpp:17)
BaseThreadInitThunk [0x0000000077415A4D+13]
RtlUserThreadStart [0x000000007764B831+33]
FAILURE: standard_symbols.pdf; Command '['E:\\b\\build\\slave\\windows_xfa\\build\\pdfium\\out\\debug_xfa_v8\\pdfium_test.exe', '--send-events', '--png', '--md5', 'E:\\b\\build\\slave\\windows_xfa\\build\\pdfium\\out\\debug_xfa_v8\\gen\\pdfium\\testing\\pixel\\standard_symbols.pdf']' returned non-zero exit status -1073741819
Original change's description:
> Remove CXFA nodes instead of CFX_XML nodes
>
> When we set data into the CJX nodes, we need to update the backing store
> of the XFA nodes, which are the XML nodes. When we update the backing
> store, there are cases where we need to remove the children (setting
> CData on a node or setting the value of an Attribute which is backed by
> a real node).
>
> Currently we call DeleteChildren on the XML node. This causes issues
> when we cleanup the tree as XFA nodes may point to these deleted XML
> nodes.
>
> Instead, this CL cleans up the XFA nodes which will in turn clean up the
> XML nodes. This seems like the right thing to do as we no longer have
> the backing nodes, so we should no longer have the XFA nodes on top of
> them.
>
> Bug: chromium:813155
> Change-Id: I63d53fd56999ec9d3b3af2ab5952b374663f040c
> Reviewed-on: https://pdfium-review.googlesource.com/29950
> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
> Commit-Queue: dsinclair <dsinclair@chromium.org>
TBR=thestig@chromium.org,dsinclair@chromium.org,hnakashima@chromium.org
Change-Id: Ic6b2fbeb9f8217292da0a722e143d96f9972056a
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Bug: chromium:813155
Reviewed-on: https://pdfium-review.googlesource.com/29974
Reviewed-by: dsinclair <dsinclair@chromium.org>
Commit-Queue: dsinclair <dsinclair@chromium.org>
diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp
index 7122d95..3823d2e 100644
--- a/xfa/fxfa/parser/cxfa_node.cpp
+++ b/xfa/fxfa/parser/cxfa_node.cpp
@@ -4678,10 +4678,8 @@
}
}
}
- if (bDeleteChildren) {
- while (auto* child = GetLastChild())
- RemoveChild(child, false);
- }
+ if (bDeleteChildren)
+ elem->DeleteChildren();
elem->SetTextData(value);
break;