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>
1 file changed
tree: be1b7ac0e6918be8afd3a6476c5ad5c107fdb732
  1. build_overrides/
  2. core/
  3. docs/
  4. fpdfsdk/
  5. fxbarcode/
  6. fxjs/
  7. infra/
  8. public/
  9. samples/
  10. skia/
  11. testing/
  12. third_party/
  13. tools/
  14. xfa/
  15. .clang-format
  16. .gitignore
  17. .gn
  18. AUTHORS
  19. BUILD.gn
  20. codereview.settings
  21. DEPS
  22. LICENSE
  23. navbar.md
  24. OWNERS
  25. pdfium.gni
  26. PRESUBMIT.py
  27. README.md
README.md

PDFium

Prerequisites

Get the chromium depot tools via the instructions at http://www.chromium.org/developers/how-tos/install-depot-tools (this provides the gclient utility needed below).

Also install Python, Subversion, and Git and make sure they're in your path.

Windows development

PDFium uses the same build tool as Chromium:

Open source contributors

Please refer to Chromium's Visual Studio set up for requirements and instructions on build environment configuration.

Run set DEPOT_TOOLS_WIN_TOOLCHAIN=0, or set that variable in your global environment.

Compilation is done through ninja, not Visual Studio.

CPU Architectures supported

The default architecture for Windows, Linux, and Mac is "x64". On Windows, "x86" is also supported. GN parameter "target_cpu = "x86"" can be used to override the default value. If you specify Android build, the default CPU architecture will be "arm".

It is expected that there are still some places lurking in the code which will not function properly on big-endian architectures. Bugs and/or patches are welcome, however providing this support is not a priority at this time.

Google employees

Run: download_from_google_storage --config and follow the authentication instructions. Note that you must authenticate with your @google.com credentials. Enter "0" if asked for a project-id.

Once you've done this, the toolchain will be installed automatically for you in the Generate the build files step below.

The toolchain will be in depot_tools\win_toolchain\vs_files\<hash>, and windbg can be found in depot_tools\win_toolchain\vs_files\<hash>\win_sdk\Debuggers.

If you want the IDE for debugging and editing, you will need to install it separately, but this is optional and not needed for building PDFium.

Get the code

The name of the top-level directory does not matter. In our examples, we use "repo". This directory must not have been used before by gclient config as each directory can only house a single gclient configuration.

mkdir repo
cd repo
gclient config --unmanaged https://pdfium.googlesource.com/pdfium.git
gclient sync
cd pdfium

Additional build dependencies need to be installed by running:

./build/install-build-deps.sh

Generate the build files

We use GN to generate the build files and Ninja to execute the build files. Both of these are included with the depot_tools checkout.

Selecting build configuration

PDFium may be built either with or without JavaScript support, and with or without XFA forms support. Both of these features are enabled by default. Also note that the XFA feature requires JavaScript.

Configuration is done by executing gn args <directory> to configure the build. This will launch an editor in which you can set the following arguments. A typical <directory> name is out/Debug.

use_goma = true  # Googlers only. Make sure goma is installed and running first.
is_debug = true  # Enable debugging features.

pdf_use_skia = false  # Set true to enable experimental skia backend.
pdf_use_skia_paths = false  # Set true to enable experimental skia backend (paths only).

pdf_enable_xfa = true  # Set false to remove XFA support (implies JS support).
pdf_enable_v8 = true  # Set false to remove Javascript support.
pdf_is_standalone = true  # Set for a non-embedded build.
is_component_build = false # Disable component build (must be false)

clang_use_chrome_plugins = false  # Currently must be false.

Note, you must set pdf_is_standalone = true if you want the sample applications like pdfium_test to build.

When complete the arguments will be stored in <directory>/args.gn, and GN will automatically use the new arguments to generate build files. Should your files fail to generate, please double-check that you have set use_sysroot as indicated above.

Building the code

You can build the sample program by running: ninja -C <directory> pdfium_test You can build the entire product (which includes a few unit tests) by running: ninja -C <directory> pdfium_all.

Running the sample program

The pdfium_test program supports reading, parsing, and rasterizing the pages of a .pdf file to .ppm or .png output image files (windows supports two other formats). For example: <directory>/pdfium_test --ppm path/to/myfile.pdf. Note that this will write output images to path/to/myfile.pdf.<n>.ppm.

Testing

There are currently several test suites that can be run:

  • pdfium_unittests
  • pdfium_embeddertests
  • testing/tools/run_corpus_tests.py
  • testing/tools/run_javascript_tests.py
  • testing/tools/run_pixel_tests.py

It is possible the tests in the testing directory can fail due to font differences on the various platforms. These tests are reliable on the bots. If you see failures, it can be a good idea to run the tests on the tip-of-tree checkout to see if the same failures appear.

Code Coverage

Code coverage reports for PDFium can be generated in Linux development environments. Details can be found here.

Waterfall

The current health of the source tree can be found at http://build.chromium.org/p/client.pdfium/console

Community

There are several mailing lists that are setup:

Note, the Reviews and Bugs lists are typically read-only.

Bugs

We use this bug tracker, but for security bugs, please use [Chromium's security bug template] (https://code.google.com/p/chromium/issues/entry?template=Security%20Bug) and add the "Cr-Internals-Plugins-PDF" label.

Contributing code

For contributing code, we will follow Chromium's process as much as possible. The main exceptions are:

  1. Code has to conform to the existing style and not Chromium/Google style.
  2. PDFium uses a different tool for code reviews, and credentials for the tool need to be generated before uploading a CL.
  3. PDFium is currently holding at C++11 compatibility, rejecting features that are only present in C++14 (onto which Chromium is now slowly moving).