pdfium.git
4 years agoKill remaining sprintfs
Tom Sepez [Tue, 10 Mar 2015 22:23:02 +0000]
Kill remaining sprintfs

I thought I had done this already, apart from the third-party
libraries, but there were a couple remaining (the third-party
libraries will still call this, they should be tweaked
upstream as needed).

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/999543002

4 years agoFix multiply defined macro in zlib.h on linux_chromium_clobber_rel_ng builder.
Tom Sepez [Fri, 6 Mar 2015 22:34:20 +0000]
Fix multiply defined macro in zlib.h on linux_chromium_clobber_rel_ng builder.

Speculative fix since the issue doesn't reproduce locally.

TBR=brettw@chromium.org

Review URL: https://codereview.chromium.org/988883002

4 years agoMake conversions for CPDF_Link explicit.
Tom Sepez [Fri, 6 Mar 2015 20:28:34 +0000]
Make conversions for CPDF_Link explicit.

Precursor to taking a second shot at cleaning up the FPDF_*
APIs.  A FPDF_LINK is a CPDF_Dictionary, and a CPDF_Link
is a structure holding a FPDF_LINK.  This goes against the
convention that FPDF_ types get cast to CPDF_* types, so we
want to make it clear where objects are getting constructed.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/985503005

4 years agoFix the pdfium component build.
Brett Wilson [Fri, 6 Mar 2015 19:06:38 +0000]
Fix the pdfium component build.

It has a component with no object files in it. When compiled as a shared library, this fails.

This changes the target to a source set which can handle empty sources. It also changes the other static libraries in pdfium to source_sets (it should be very rare to need real static libraries).

Runs "gn format" over the BUILD files.

Renames the arg bundle_freetype to pdfium_bundle_freetype which makes more sense in the context of a larger build like Chrome.

R=jam@chromium.org

Review URL: https://codereview.chromium.org/985543002

4 years agoMake conversion between CPDF_Dest and its object explicit.
Tom Sepez [Fri, 6 Mar 2015 18:34:48 +0000]
Make conversion between CPDF_Dest and its object explicit.

Precursor to taking a second shot at cleaning up the FPDF_*
APIs.  A FPDF_Dest is a CPDF_Array, and a CPDF_Dest
is a structure holding a FPDF_Dest.  This goes against the
convention that FPDF_ types get cast to CPDF_* types, so we
want to make it clear where objects are getting constructed,
etc.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/984703004

4 years agoAdd gmock to .gitignore
Tom Sepez [Fri, 6 Mar 2015 17:38:36 +0000]
Add gmock to .gitignore

This is an attempt to fix git rebase-update, which complains
about uncommitted changes.

TBR=halyavin@chromium.org

Review URL: https://codereview.chromium.org/985833002

4 years agoMake conversion between CPDF_Action and its dictionary explicit.
Tom Sepez [Fri, 6 Mar 2015 00:30:09 +0000]
Make conversion between CPDF_Action and its dictionary explicit.

Precursor to taking a second shot at cleaning up the FPDF_*
APIs.  A FPDF_Action is a CPDF_Dictionary, and a CPDF_Action
is a structure holding a FPDF_Action.  This goes against the
convention that FPDF_ types get cast to CPDF_* types, so we
want to make it clear where objects are getting constructed,
etc.

Also tidy fpdf_actionhandler.cpp because it bugs me.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/984773002

4 years agoMerge to Master: Fix a compiling error in fxjs_v8.h
Tom Sepez [Wed, 4 Mar 2015 19:40:10 +0000]
Merge to Master: Fix a compiling error in fxjs_v8.h

Original Review URL: https://codereview.chromium.org/965423004

TBR=thestig@chromium.org
TBR=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/976033005

4 years agoKill off JS_ErrorString type.
Tom Sepez [Mon, 2 Mar 2015 22:20:10 +0000]
Kill off JS_ErrorString type.

This provides no benefit, and reduces transparency.

Along the way:
Kill off some unused/commented-out code.
Return void where a bool return doesn't make sense.
Remove a pointless template type.
Remove now unused constants and types.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/971033002

4 years agoReturn error information from pdfium to JS.
Tom Sepez [Mon, 2 Mar 2015 20:18:50 +0000]
Return error information from pdfium to JS.

This implements the previously unimplemented JS_Error() function.

Along the way:
- fix some IWYU when the include order in global.cpp was perturbed.
- remove some uses of JS_ErrorString, to increase transparency.
- use vp.IsSetting() in place of !vp.IsGetting() for clarity.
- specify an error string on several error return paths.
- add an error string for writing readonly properties.
- rename an error string constant to reflect the actual message.
- replace calls to variadic Format() with a function doing string appends.
- remove unused JS_GetClassName()

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/963193003

4 years agoDo hit tests against Annots in reverse order.
Lei Zhang [Sat, 28 Feb 2015 00:29:50 +0000]
Do hit tests against Annots in reverse order.

BUG=chromium:445408
R=jun_fang@foxitsoftware.com

Review URL: https://codereview.chromium.org/952423002

4 years agoRemove unused IDS_ constants from pdfium.
Tom Sepez [Fri, 27 Feb 2015 21:48:38 +0000]
Remove unused IDS_ constants from pdfium.

Along the way, I noticed that one of these is used in a header file
that isn't included anywhere and describes no actual code (JS_Console.h).

Also add missing header guards, and IWYU to resources.h

Also move a static function from a header to the new resources.cpp file.

Also fix the grammar on some of the error messages. Most of these
appear to be JS error messages destined for a JS error handler or (someday)
a console (which can remain in english), and oddly, some appear to be about
failed form validation, which smells user-facing.

Also check that the message makes sense for the point the C++ code
wants to use it, and reword accordingly.

As it turns out, these currently don't make it back to JS due to the
unimplemented JS_Error() function; this is an enabling step towards
implementing it.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/955273003

4 years agoPull in gmock for standalone pdfium builds.
Tom Sepez [Fri, 27 Feb 2015 20:56:25 +0000]
Pull in gmock for standalone pdfium builds.

For chromium checkouts, the top-level gmock is used instead.
Verify build with a simple test that ensures neither mock
method is fired.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/955513009

4 years agoUpgrade openjpeg to revision 2997.
JUN FANG [Fri, 27 Feb 2015 18:00:00 +0000]
Upgrade openjpeg to revision 2997.

BUG=457493
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/960183004

4 years agoImplement a delegate for EmbedderTests.
Tom Sepez [Thu, 26 Feb 2015 00:00:06 +0000]
Implement a delegate for EmbedderTests.

This is the first step in allowing an embedder test to
someday gMock its callbacks, so that it can check that they
fired as expected. gMock wants a class, not a C-style
function-based API, and EmbedderTest is made to bridge
between the two.

The EmbedderTest class itself is modified to inherit from
the C JS API classes themselves, to make finding the
delegate easier.

For example, a future embedder test might send a keystroke
to a page, which would then trigger JS, which would then
trigger an Alert().  Mocking the Alert() callback would
allow the test to check that the alert happened as
expected.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/960663002

4 years agoKill off unused IFXJS interface methods.
Tom Sepez [Wed, 25 Feb 2015 22:38:06 +0000]
Kill off unused IFXJS interface methods.

Re-work of original CL at:
https://codereview.chromium.org/933043002/

Much of the IFXJS interface appears completely unused, so
Kill off unused IFXJS interface methods.  The code itself
appears incomplete against all of the objects present
in the paths that actually do register objects with JS.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/954923004

4 years agoFix compilation error on Windows.
John Abd-El-Malek [Wed, 25 Feb 2015 19:05:30 +0000]
Fix compilation error on Windows.

The build fails due to implicit double to integer conversion warning on width *= scale line
and warnings being treated as errors.

TEST= ninja
BUG= none
R=jam@chromium.org

Review URL: https://codereview.chromium.org/935663003

4 years agoAdd small flate decode unit test.
Tom Sepez [Tue, 24 Feb 2015 22:59:35 +0000]
Add small flate decode unit test.

As we remove flate encoded sections from test cases (to
promote clarity), we should first have a simple unit test
for the underlying functionality.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/845313006

4 years agoKill multi-byte comments in fxet_list.h
Tom Sepez [Tue, 24 Feb 2015 22:27:00 +0000]
Kill multi-byte comments in fxet_list.h

No functional changes, just tidying some stray characters,
plus kill trailing whitespace while we're at it.

TBR=thestig@chromium.org
BUG=https://code.google.com/p/pdfium/issues/detail?id=123

Review URL: https://codereview.chromium.org/953143002

4 years agoConvert pdfium expected test results to PNG format.
Tom Sepez [Tue, 24 Feb 2015 20:31:29 +0000]
Convert pdfium expected test results to PNG format.

Required to save space vs. raw bitmap.  Land prior to adding
substantial number of tests.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/953723004

4 years agoFix GN build after PNG support backport
Tom Sepez [Tue, 24 Feb 2015 01:55:58 +0000]
Fix GN build after PNG support backport

Follow-on from https://codereview.chromium.org/950113002.
This would block a pdfium roll until corrected.

TBR=jam@chromium.org

Review URL: https://codereview.chromium.org/948233002

4 years agoBackport PNG output format to origin/master branch.
Tom Sepez [Mon, 23 Feb 2015 23:59:57 +0000]
Backport PNG output format to origin/master branch.

The pdfium library itself does not support the format, but the test utility
can convert to this output format.

GN build can't be tested standalone, so push this out to the next CL.

R=jam@chromium.org

Review URL: https://codereview.chromium.org/950113002

4 years agoReplace second set of #defines with templates in JS_Define.h
Tom Sepez [Mon, 23 Feb 2015 18:03:12 +0000]
Replace second set of #defines with templates in JS_Define.h

Continuation of effort now that a test case is present on origin/master.

R=brucedawson@chromium.org

Review URL: https://codereview.chromium.org/945623002

4 years agoUpdate GN build files w/ cpu_arch -> current_cpu changes.
Dirk Pranke [Fri, 20 Feb 2015 21:46:34 +0000]
Update GN build files w/ cpu_arch -> current_cpu changes.

R=jam@chromium.org
BUG=344767

Review URL: https://codereview.chromium.org/945723004

4 years agoAdd test for PDF's JS "global".
Tom Sepez [Thu, 19 Feb 2015 23:58:19 +0000]
Add test for PDF's JS "global".

Exercises a separate code path that stores some JS objects
outside of JS.  Needed before re-writing some other portions
of the JS_Defines.h code.

R=jam@chromium.org

Review URL: https://codereview.chromium.org/943783002

4 years agoReplace ugly JS_Define macros with templates.
Tom Sepez [Wed, 18 Feb 2015 20:42:45 +0000]
Replace ugly JS_Define macros with templates.

This allows us to step through the JS bindings code with the
debugger, which I could not do (but wanted to) the other day.

In the process, get rid of some else after returns, and one
unreachable code path.

I also get rid of some tracing macros that we would never
use for the sake of clarity, and some plain unused
definitions.

R=brucedawson@chromium.org

Review URL: https://codereview.chromium.org/908033002

4 years agoTidy up JS_Defines.h
Tom Sepez [Tue, 17 Feb 2015 21:21:34 +0000]
Tidy up JS_Defines.h

This is a purely mechanical change, no new functionality.

- Expand some macros which were merely a short-cut to save
  typing but reduced transparency.

- Put GET_VALUE_TYPE() implementation into a .cpp file.

This is a portion of the patch from issue 908033002 at
patchset 40001 (http://crrev.com/908033002#ps40001)

R=brucedawson@chromium.org

Review URL: https://codereview.chromium.org/927263003

4 years agoRun pixel tests via automated script.
Tom Sepez [Sat, 14 Feb 2015 00:47:22 +0000]
Run pixel tests via automated script.

On origin/master, we only have .ppm format support, so the
expected output files would take up a lot of space. Hence,
this may not get going until XFA hits with its .png
support.

Nor is there a good way to diff these; XFA provides this
for .png as well.

But this will provide at least one automated test to ensure
that we've got non-blank output, at least for one trivially
simple case.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/926173002

4 years agorun_javascript_tests.py: Be more flexible about directory layout.
Tom Sepez [Sat, 14 Feb 2015 00:37:13 +0000]
run_javascript_tests.py: Be more flexible about directory layout.

The top-level directory name isn't part of the repository, and we
can't count on it always being "pdfium" (though many people will
choose to do it this way).

R=jam@chromium.org

Review URL: https://codereview.chromium.org/921043005

4 years agoTest top-level Document JS properties.
Tom Sepez [Fri, 13 Feb 2015 20:08:44 +0000]
Test top-level Document JS properties.

Along the way, I rename some functions in pdfium_test.cc to
match the style guide's FunctionName() syntax, adding
"Example" to make them obviously different from the PDF
internal code with similar name fragments.

The purpose is to at least have some coverage for the
setter/getter macros from JS_Define.h

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/928573002

4 years agoFix JPX image rendering that regressed due to several security fixes.
Lei Zhang [Fri, 13 Feb 2015 20:02:38 +0000]
Fix JPX image rendering that regressed due to several security fixes.

BUG=453723
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/892553002

4 years agoFix an error 'Use-of-uninitialized-value in CPDF_Function::Call'
JUN FANG [Thu, 12 Feb 2015 12:38:03 +0000]
Fix an error 'Use-of-uninitialized-value in CPDF_Function::Call'

This issue was introduced in https://codereview.chromium.org/886953002/.

BUG=454280
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/869343008

4 years agoCreate run_javascript_tests.py
Tom Sepez [Thu, 12 Feb 2015 18:19:52 +0000]
Create run_javascript_tests.py

Top level script driver for testing/resources/javascript.
Converts each input template file in that directory to a
.pdf file in the working directory (typically
out/Debug/gen/pdfium/testing/resources/javascript), invokes
pdfium_test on it to generate , and crudely diffs the
expected output.

We can now remove generated .pdfs from source control,
keeping only the hand-editable .in templates.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/912803004

4 years agoCPDF_Object() constructor should set its internal m_Type variable.
Tom Sepez [Wed, 11 Feb 2015 20:44:01 +0000]
CPDF_Object() constructor should set its internal m_Type variable.

Follow-on from https://codereview.chromium.org/911293002/

Currently, all the subclass constructors are reaching up
into the parent class to do this.  Fix this, just because.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/880233005

4 years agoFix uninitialized value in CFX_ByteString::FormatInteger
JUN FANG [Tue, 10 Feb 2015 16:13:01 +0000]
Fix uninitialized value in CFX_ByteString::FormatInteger

BUG=449845
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/911293002

4 years agoAdd JavaScript test for constants in Consts.cpp.
Tom Sepez [Tue, 10 Feb 2015 17:03:30 +0000]
Add JavaScript test for constants in Consts.cpp.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/908023003

4 years agoFix some typos in fpdf_render_loadimage.cpp.
Lei Zhang [Tue, 10 Feb 2015 02:49:56 +0000]
Fix some typos in fpdf_render_loadimage.cpp.

R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/885223004

4 years agoCleanup: Fix some unused-function warnings.
Lei Zhang [Sat, 7 Feb 2015 00:51:37 +0000]
Cleanup: Fix some unused-function warnings.

BUG=pdfium:29
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/891113002

4 years agoCleanup parts of fpdf_render_loadimage.cpp.
Lei Zhang [Sat, 7 Feb 2015 00:44:10 +0000]
Cleanup parts of fpdf_render_loadimage.cpp.

- Add functions to do pitch calculation.
- Delete dead code.
- Don't bother checking pointers before deleting them.
- Don't bother setting pointers to NULL in dtors.

R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/890883006

4 years agoFirst JavaScript testing implementation.
Tom Sepez [Fri, 6 Feb 2015 23:58:40 +0000]
First JavaScript testing implementation.

This is a plan for testing JS inside of pdf files under pdfium:

Communication of results will be done via app.alert(), rather than
console.println(), since the latter is not hooked up to any API
callbacks.

pdfium_test.cc is modified to be more careful about use of stdout/stderr,
so that only the app.alert() and the unsupported feature callback use
stdout.  Diffing stdout against ..._expected.txt files gives the result.

I added a /javascript directory to separate these from the embeddertest
resources.

The alert callback is backported from XFA.  This was an omission.

BUG=https://code.google.com/p/pdfium/issues/detail?id=62
R=jam@chromium.org, thestig@chromium.org

Review URL: https://codereview.chromium.org/872103003

4 years agoFix GN build, fpdf_font_utility.cpp no longer present.
Tom Sepez [Fri, 6 Feb 2015 01:51:39 +0000]
Fix GN build, fpdf_font_utility.cpp no longer present.

Clean in standalone pdfium, but this would block a pdfium
roll into chromium.

TBR=jam@chromium.org

Review URL: https://codereview.chromium.org/903903003

4 years agoKill off some more unreachable fopen's.
Tom Sepez [Fri, 6 Feb 2015 01:33:27 +0000]
Kill off some more unreachable fopen's.

The bstring's read from file is unused.
The load from file paths aren't taken.

R=jam@chromium.org

Review URL: https://codereview.chromium.org/902943003

4 years agoMerge to master: Kill off some dodgy JS callbacks
Tom Sepez [Thu, 5 Feb 2015 23:52:15 +0000]
Merge to master: Kill off some dodgy JS callbacks

Note that this work was done opposite the usual branch order, because I
didn't want to kill things in master that turned out to be in use in XFA.

Original Review URL: https://codereview.chromium.org/883393007
TBR=jam@chromium.org

Review URL: https://codereview.chromium.org/903893002

4 years agoFix segv in CPDF_DataAvail::CheckRoot() when /Root object is a string.
Tom Sepez [Thu, 5 Feb 2015 18:41:08 +0000]
Fix segv in CPDF_DataAvail::CheckRoot() when /Root object is a string.

Handles the case of this malformed PDF without crashing. Note that to
get a reproducible test case, a small fix is applied to our .py script
which results in some whitespace/numbering difs across the resources
(down the road, we ought to generate them on the fly in an intermediate
directory).

BUG=454695
R=jun_fang@foxitsoftware.com, thestig@chromium.org

Review URL: https://codereview.chromium.org/895933003

4 years agoAdd namespace and-re-arrange PDFium's local copy of chromium /base.
Tom Sepez [Thu, 5 Feb 2015 17:46:23 +0000]
Add namespace and-re-arrange PDFium's local copy of chromium /base.

Any projects DEPS'd into chromium and requiring a /base
subset should have a local copy of that subset in a
separate namespace. This will avoid future naming conflicts.

Re-arrange the directory structure to better identify what
came from chromium's base, and to make drop-in replacement
easier for files that contain hard-coded "base/" in their
#include directives.

R=jam@chromium.org

Review URL: https://codereview.chromium.org/900753002

4 years agoUpdate GN files from previous commit as well.
John Abd-El-Malek [Thu, 5 Feb 2015 00:59:22 +0000]
Update GN files from previous commit as well.

TBR=tsepez@chromium.org
BUG=455399

Review URL: https://codereview.chromium.org/902753002

4 years agoInitialize V8 outside of PDFium.
John Abd-El-Malek [Thu, 5 Feb 2015 00:04:05 +0000]
Initialize V8 outside of PDFium.

This is similar to how we initialize ICU for V8 inside PDFium.

BUG=455399
R=wfh@chromium.org

Review URL: https://codereview.chromium.org/897973002

4 years agoPrevent base::CheckedNumeric from leaking outside of pdfium.
Tom Sepez [Wed, 4 Feb 2015 18:37:17 +0000]
Prevent base::CheckedNumeric from leaking outside of pdfium.

Headers in /include directories should be free of implementation details
from third_party.  Put the types into a new header outside of /include.

Requires https://codereview.chromium.org/902443003/ before a version containing this patch is rolled into chromium.

R=jam@chromium.org

Review URL: https://codereview.chromium.org/896023003

4 years agoReplace CFX_SmartPointer cast operator with Get() method.
Tom Sepez [Wed, 4 Feb 2015 00:28:43 +0000]
Replace CFX_SmartPointer cast operator with Get() method.

This is part of the project to kill off C-style casts in the code base.

Remove implict T* cast operator, and replace potentially unsafe C-style
casts with Get() method.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/889673003

4 years agoFix stack exhaustion in CPDF_DataAvail::HaveResourceAncestor()
Tom Sepez [Wed, 4 Feb 2015 00:18:19 +0000]
Fix stack exhaustion in CPDF_DataAvail::HaveResourceAncestor()

BUG=https://code.google.com/p/pdfium/issues/detail?id=113
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/880043004

4 years agoRemove OpenJPEG header generator binary from PDFium build.
John Abd-El-Malek [Tue, 3 Feb 2015 17:12:23 +0000]
Remove OpenJPEG header generator binary from PDFium build.

This is giving duplicate symbols for main when linking PDFium into Chromium.

BUG=453844
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/897463003

4 years agoAdd embedder test for fix to bug_452455.
Tom Sepez [Mon, 2 Feb 2015 18:23:58 +0000]
Add embedder test for fix to bug_452455.

BUG=452455
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/887063003

4 years agoFix GN PDFium build when building all.
John Abd-El-Malek [Mon, 2 Feb 2015 00:19:29 +0000]
Fix GN PDFium build when building all.

The problem was FT_INTERNAL_DEBUG_H wasn't being defined because FT2_BUILD_LIBRARY wasn't set. So even if PDFium isn't using bundled FreeType, the FreeType target needs FT2_BUILD_LIBRARY defined. The GYP build was already correct.

BUG=453844
TBR=brettw

Review URL: https://codereview.chromium.org/891993003

4 years agoAlways use the FreeType headers included in PDFium.
John Abd-El-Malek [Sun, 1 Feb 2015 19:22:25 +0000]
Always use the FreeType headers included in PDFium.

The problem with trying to use the system headers sometimes is that we'll need to use pkg-config which is pretty slow.

BUG=453844
TBR=brettw

Review URL: https://codereview.chromium.org/865333003

4 years agoFix heap buffer overflow in CPDF_SampledFunc::v_Call
JUN FANG [Sat, 31 Jan 2015 18:12:50 +0000]
Fix heap buffer overflow in CPDF_SampledFunc::v_Call

This issue was caused by integer overflow in CPDF_SampledFunc::v_Call.
The root cause of this issue is that the content in the test pdf file
was damaged. The solution is to check whether an integer is overflow
before using it.

BUG=452455
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/886953002

4 years agoDon't export any OpenJPEG methods from PDFium.
John Abd-El-Malek [Sat, 31 Jan 2015 01:16:27 +0000]
Don't export any OpenJPEG methods from PDFium.

It's only used internally. This also avoids errors from the verify_order script when linking PDFium into Chromium

BUG=453844
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/887193002

4 years agoUse system FreeType on Linux.
John Abd-El-Malek [Sat, 31 Jan 2015 00:55:08 +0000]
Use system FreeType on Linux.

This saves 406KB in the binary size of the plugin. More importantly, it gets rid of the linker flag preventing bundling PDFium into the Chromium binary.

BUG=453844
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/826613004

4 years agoTrack formhandles in EmbedderTest class itself
Tom Sepez [Fri, 30 Jan 2015 22:31:58 +0000]
Track formhandles in EmbedderTest class itself

This removes some duplicated code from each individual test.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/885403002

4 years agoFix infinite recursion in CPDF_RenderStatus::RenderSingleObject().
Tom Sepez [Fri, 30 Jan 2015 02:02:20 +0000]
Fix infinite recursion in CPDF_RenderStatus::RenderSingleObject().

Introduce a local static to track the recursion depth, thereby removing
the burden for callers to track and pass a level parameter correctly through
all call paths.  Also increase the depth tolerated, since we know there
were paths that were under-counting this value.

BUG=451265
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/868253009

4 years agoAdd minimized test cases for stack exhaustion crash to repository.
Tom Sepez [Fri, 30 Jan 2015 01:39:26 +0000]
Add minimized test cases for stack exhaustion crash to repository.

These reproduce under pdfium_test with a scale factor < 1.0.  Add
them to the repository now for the sake of posterity, even if we
are not automatically testing them.

BUG=451265
R=thestig@chromium.org
TBR=thestig@chromium.org

Review URL: https://codereview.chromium.org/869923003

4 years agoMerge to Master: Add output scale factor command line parameter to pdfium_test.
Tom Sepez [Thu, 29 Jan 2015 23:48:15 +0000]
Merge to Master: Add output scale factor command line parameter to pdfium_test.

Original Review URL: https://codereview.chromium.org/861203003

TBR=thestig@chromium.org

Review URL: https://codereview.chromium.org/889733002

4 years agoMerge to Master: Cover fpdftext.h API with embeddertests.
Tom Sepez [Wed, 28 Jan 2015 23:55:04 +0000]
Merge to Master: Cover fpdftext.h API with embeddertests.

Original Review URL: https://codereview.chromium.org/878333003

TBR=thestig@chromium.org

Review URL: https://codereview.chromium.org/884873002

4 years agoAdd embedder test for stream length beyond end of file.
Tom Sepez [Tue, 27 Jan 2015 20:30:19 +0000]
Add embedder test for stream length beyond end of file.

This was fixed by https://codereview.chromium.org/743263002, but the
bug remained open due to confusion.

BUG=https://code.google.com/p/pdfium/issues/detail?id=57
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/878523003

4 years agoKill scattered extern _PDF_CharType declarations.
Tom Sepez [Tue, 27 Jan 2015 17:47:45 +0000]
Kill scattered extern _PDF_CharType declarations.

While we're at it, avoid an indirection through a pointer, and
use a name that isn't reserved for the compiler (leading _ CAP).
This is a small portion of the associated bug:

BUG=https://code.google.com/p/pdfium/issues/detail?id=112
R=brucedawson@chromium.org

Review URL: https://codereview.chromium.org/880663003

4 years agoFix infinite recursion in CPDF_Parser::ParseIndirectObjectAt().
Tom Sepez [Tue, 27 Jan 2015 00:51:21 +0000]
Fix infinite recursion in CPDF_Parser::ParseIndirectObjectAt().

A suitably corrupted file can cause the parser(s) to repeatedly re-read
sections of the file at increasing parser recursion depth until the
stack is exhausted.  There is supposed to be a check for this based upon
the parser "level", but not all call paths pass or update the level as
required.

Much as I hate per-class statics, this introduces one to track the depth
so that the check is enforced no matter how screwy the call path might be
that leads the parser to re-enter itself. This is more palatable than trying
to find all these paths and fix them. We know this is OK since there is
only one thread in here modifying the static.

BUG=451830
R=thestig@chromium.org

Review URL: https://codereview.chromium.org/875263002

4 years agoFix test naming in previous commit.
Tom Sepez [Fri, 23 Jan 2015 23:22:57 +0000]
Fix test naming in previous commit.

The embeddertests binary should have source files ending in
_embeddertest, not _unittest.

TBR=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/871093004

4 years agoFix null crash in CheckTrailer.
Tom Sepez [Fri, 23 Jan 2015 23:05:43 +0000]
Fix null crash in CheckTrailer.

We are making checks in the incorrect order.  Also adds two test
cases, one for the this crash, and another for the original issue
that motivated the patch.

Original Patch by Bo at https://codereview.chromium.org/866003003/

BUG=450871
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/872563002

4 years agoAdd pdfium_embeddertests to BUILD.gn
Tom Sepez [Fri, 23 Jan 2015 01:25:59 +0000]
Add pdfium_embeddertests to BUILD.gn

This brings BUILD.gn into equivalence with pdfium.gyp.
Blocked on https://codereview.chromium.org/851283006/

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/871453004

4 years agoFix build of pdfium_embeddertest under V8_USE_EXTERNAL_STARTUP_DATA.
Tom Sepez [Fri, 23 Jan 2015 01:18:46 +0000]
Fix build of pdfium_embeddertest under V8_USE_EXTERNAL_STARTUP_DATA.

Currently, this is a difference between the standalone pdfium environment
vs. pdfium as part of a chromium checkout.

Locating the external data files is a nusiance when you don't have the
binary's argv[0] line, so we create a new main that preserves this for
us.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/851283006

4 years agoUse IPDF_DataAvail interface to hide CPDF_DataAvail.
Tom Sepez [Fri, 23 Jan 2015 00:57:58 +0000]
Use IPDF_DataAvail interface to hide CPDF_DataAvail.

Currently, no callers go through the Interface, which makes having a
separate interface class kind of pointless.  After converting callers
away from using the CPDF_DataAvail concrete class, it can be moved
from the header to the .cpp file.

R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/873523002

4 years agoAdd API tests: NamedDestsByName, DestGetPageIndex.
Tom Sepez [Thu, 22 Jan 2015 19:11:45 +0000]
Add API tests: NamedDestsByName, DestGetPageIndex.

This also adds a fpdfdoc_embeddertest.cpp to keep the test
file name matching with the API call under test.

R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/812933004

4 years agoAdd tests for GetNamedDests() API.
Tom Sepez [Wed, 21 Jan 2015 22:38:33 +0000]
Add tests for GetNamedDests() API.

Follow-on work from patch at https://codereview.chromium.org/845643008. This
incorporates that patch, plus adds tests for it and similar conditions.  A few
changes are introduced to correct expected behaviour.

This also incoprorates Deepak's fix in https://codereview.chromium.org/845643008/

This incorporates a formerly unlanded tool to generate small valid PDF
files from template input, which is needed to cover all the error cases
here. See https://codereview.chromium.org/791993006/

BUG=450133
R=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/837723009

4 years agoUse signed long for FPDF_GetNamedDest buffer length.
Bo Xu [Wed, 21 Jan 2015 22:20:28 +0000]
Use signed long for FPDF_GetNamedDest buffer length.

Need to have return value -1 indicating insufficient buffer.

R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/862163002

4 years agoSimplify UTF16LE_Encode and add unittest.
Bo Xu [Wed, 21 Jan 2015 20:17:23 +0000]
Simplify UTF16LE_Encode and add unittest.

Previously, UTF16LE_Encode take an optional flag to indicate
if the returned byte string has trailing zeros. In fact, no where
needs the flag to be false. So just get rid of it so callers won't
misuse.

The bug is found by https://codereview.chromium.org/837723009

R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/860973002

4 years agoFix missing call to destroy library in embedder test.
Tom Sepez [Fri, 16 Jan 2015 17:43:49 +0000]
Fix missing call to destroy library in embedder test.

This was somehow lost along the way to creating embedder tests.  Presumably
this silently leaks in origin/master, but triggers an assert under XFA. Fixing
this on master is a pre-requisite for merging all the embedder test code onto
XFA.

TBR=jam@chromium.org

Review URL: https://codereview.chromium.org/856773003

4 years agoFollow-on to pdfium_embeddertests.
Tom Sepez [Fri, 16 Jan 2015 16:55:17 +0000]
Follow-on to pdfium_embeddertests.

This includes:
- Fix TestLoader lifetime.
- Rename test file to match the equivalent .cpp under test
- Re-organize a few tests to avoid duplicate loading
- add tests for a few additional functions.

R=jam@chromium.org

Review URL: https://codereview.chromium.org/857483005

4 years agoAllow FPDFBookmark_GetFirstChild to return the top level bookmark
Tom Sepez [Fri, 16 Jan 2015 02:14:43 +0000]
Allow FPDFBookmark_GetFirstChild to return the top level bookmark

Previously when passing a NULL bookmark to FPDFBookmark_GetFirstChild it returned NULL instead of returning the top level bookmark. This change removes the early exit in this case allowing the top level bookmark to be retrieved.

BUG=https://code.google.com/p/pdfium/issues/detail?id=110
R=bo_xu@foxitsoftware.com, tsepez@chromium.org

Review URL: https://codereview.chromium.org/847243005

4 years agoCreate first pdfium embedder test.
Tom Sepez [Fri, 16 Jan 2015 00:31:51 +0000]
Create first pdfium embedder test.

BUG=https://code.google.com/p/pdfium/issues/detail?id=62
R=jam@chromium.org

Review URL: https://codereview.chromium.org/827733006

4 years agoLand patch from issue 854603005 at patchset 1 (http://crrev.com/854603005#ps1)
Tom Sepez [Thu, 15 Jan 2015 17:30:50 +0000]
Land patch from issue 854603005 at patchset 1 (crrev.com/854603005#ps1)
on behalf of qsr@

TBR=qsr@chromium.org

Review URL: https://codereview.chromium.org/852983003

4 years agoEnsure unittests are built when building all.
John Abd-El-Malek [Wed, 14 Jan 2015 21:34:22 +0000]
Ensure unittests are built when building all.

R=scottmg@chromium.org

Review URL: https://codereview.chromium.org/849113002

4 years agoFix v8 external snapshot code for Windows.
Ross McIlroy [Wed, 14 Jan 2015 12:05:13 +0000]
Fix v8 external snapshot code for Windows.

Needed to land https://codereview.chromium.org/826083004/.

BUG=421063, 439661
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/848443002

Patch from Ross McIlroy <rmcilroy@chromium.org>.

4 years agoMerge to master: Fix include paths for pdfium_unittests under chromium checkout
Tom Sepez [Mon, 12 Jan 2015 23:00:28 +0000]
Merge to master: Fix include paths for pdfium_unittests under chromium checkout

Orignal CL at https://codereview.chromium.org/852493002/

TBR=bo_xu@foxitsoftware.com

Review URL: https://codereview.chromium.org/849603003

4 years agoAdd APIs for getting bookmarks and named destinations.
Bo Xu [Sun, 11 Jan 2015 06:52:59 +0000]
Add APIs for getting bookmarks and named destinations.

R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/834703002

4 years agoCheck for NULL pointers in CJBig2_SymbolDict::DeepCopy().
Lei Zhang [Fri, 9 Jan 2015 23:33:19 +0000]
Check for NULL pointers in CJBig2_SymbolDict::DeepCopy().

BUG=445475
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/837093002

4 years agoAdd pdfium_unittests to BUILD.gn
Tom Sepez [Fri, 9 Jan 2015 21:54:33 +0000]
Add pdfium_unittests to BUILD.gn

Brings GN build up to sync with GYP build for this test binary.

R=thestig@chromium.org

Review URL: https://codereview.chromium.org/840343005

4 years agoOnly request C++11 when compiling C++ code.
Bruce Dawson [Fri, 9 Jan 2015 19:51:09 +0000]
Only request C++11 when compiling C++ code.

Linux pdfium builds have 215 warnings of this form:
command line option -std=gnu++11 is valid for C++/ObjC++ but not for C

The obvious fix is to not request C++11 for C compilations. The only
complication was the the switch we are using is actually gnu++0x, not
gnu++11.

BUG=https://code.google.com/p/pdfium/issues/detail?id=102
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/839163002

4 years agoFix -Wnon-virtual-dtor compiler warnings.
Tom Sepez [Fri, 9 Jan 2015 18:46:50 +0000]
Fix -Wnon-virtual-dtor compiler warnings.

This is done by explicitly adding a virtual dtor to interface classes,
since the cost is small given that there are already virtual functions.

The exceptions are for classes that have a Release() or Delete() method,
in which case it is non-virtual and protected to indicate that the virtual
class is never the deletion point.

BUG=
R=brucedawson@chromium.org, thestig@chromium.org

Review URL: https://codereview.chromium.org/810883005

4 years agoLand: Protect against a seg fault in CPDF_StructElementImpl constructor.
Tom Sepez [Fri, 9 Jan 2015 00:37:24 +0000]
Land: Protect against a seg fault in CPDF_StructElementImpl constructor.
patch from issue 680873002 at patchset 40001 (http://crrev.com/680873002#ps40001)

TBR=jam@chromium.org

Review URL: https://codereview.chromium.org/841943003

4 years agoFinish unit test for CFX_ByteStringC class.
Tom Sepez [Wed, 7 Jan 2015 20:31:41 +0000]
Finish unit test for CFX_ByteStringC class.

This fixes a few cut-n-paste errors in the previous version, plus
adds more corner cases.  The implementation is fixed to handle a
few of these that failed.

R=brucedawson@chromium.org

Review URL: https://codereview.chromium.org/808553013

4 years agoAdd ostream helpers for FX String classes.
Tom Sepez [Wed, 7 Jan 2015 20:25:07 +0000]
Add ostream helpers for FX String classes.

This allows integration with the gtest EXPECT_* macros.

R=brucedawson@chromium.org

Review URL: https://codereview.chromium.org/837843002

4 years agoResolve all but two VC++ build warnings in pdfium.
Bruce Dawson [Tue, 6 Jan 2015 21:12:09 +0000]
Resolve all but two VC++ build warnings in pdfium.

pdfium builds on Win32 have about 85 warnings (250 in the XFA
branch, totaling over 480 lines!), mostly from four lines in
a header file and a warning that should be disabled. This
change resolves all but two of them and turns on
warning-as-errors. Bugs have been filed for the two
remaining warnings:
https://code.google.com/p/pdfium/issues/detail?id=100
the 64-bit warnings:
https://code.google.com/p/pdfium/issues/detail?id=101
and the Linux warnings:
https://code.google.com/p/pdfium/issues/detail?id=102

The fix to the double->float truncation bugs will also
improve code-generation.

R=bo_xu@foxitsoftware.com, scottmg@chromium.org, tsepez@chromium.org

Review URL: https://codereview.chromium.org/792953005

4 years agoCleanup: Get rid of CRLF line endings.
Lei Zhang [Tue, 6 Jan 2015 00:54:03 +0000]
Cleanup: Get rid of CRLF line endings.

R=brucedawson@chromium.org

Review URL: https://codereview.chromium.org/837533003

4 years agoRe-enable pdfium_unittests.
Tom Sepez [Mon, 5 Jan 2015 23:30:26 +0000]
Re-enable pdfium_unittests.

In order for the standalone pdfium build to succeed,
DEPS is updated to pull in gtest, and a stub gtest.gyp
file is provided (which is unused under a chromium
checkout).

R=brucedawson@chromium.org, thakis@chromium.org

Review URL: https://codereview.chromium.org/835233002

4 years agoUpdate externs in unicodenormalization.cpp to not have array sizes.
Lei Zhang [Mon, 5 Jan 2015 23:27:37 +0000]
Update externs in unicodenormalization.cpp to not have array sizes.

This is a follow-up to f9640495.

R=brucedawson@chromium.org

Review URL: https://codereview.chromium.org/825983004

4 years agoGet rid of g_timeMap global object.
Bruce Dawson [Mon, 5 Jan 2015 23:09:10 +0000]
Get rid of g_timeMap global object.

g_timeMap is a global variable with a constructor and destructor so it
must be removed.

BUG=441899
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/832703003

4 years agoFix an array size mismatch.
Lei Zhang [Mon, 5 Jan 2015 22:35:41 +0000]
Fix an array size mismatch.

The g_UnicodeData_Normalization_Map2 array is initialized with a size of
1724 in core\src\fpdftext\unicodenormalizationdata.cpp but its size is
1734 (+10) in core\src\fpdftext\unicodenormalization.cpp, 1724 seems to be
the real size (i.e. there's 1724 values in the initialization list).

BUG=446057

Original Author: sebmarchand@chromium.org
Original CL: https://codereview.chromium.org/837523002/

Review URL: https://codereview.chromium.org/812843004

4 years agoRemove run-time calculation of hash constants in pdfium.
Bruce Dawson [Mon, 5 Jan 2015 22:11:00 +0000]
Remove run-time calculation of hash constants in pdfium.

PDFium static initializers must go. Static initializers are prohibited
by the style guide. They have negative consequences including increased
startup time (from pulling in additional code pages) and reduced sharing
of data pages (since the variables can't go in the read-only data
segment).

This change uses a template struct and typed enums to reproduce
JS_CalcHash at run-time. An unsigned long long constant and masking with
0xFFFFFFFF are used to avoid compile errors due to integer overflow of
compile-time constants.

The HashVerify class is used to check the results, necessary since none
of the functions in global.cpp are called when pdfium_test.exe runs.

const_expr would be a much cleaner way to implement this change but it
is not yet widely supported.

On the Windows release build this reduces the code size (.text
virtual size) by 0x240 (576) bytes, the .data section by 0x20 bytes
(for eight unsigned globals), and the .rdata section by 0x20 bytes
(the unneeded string savings, minus the eight unsigned globals now
being there).

BUG=441899
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/792043005

4 years agoGet rid of fifteen copies of m_sTimeMap and their initializers.
Bruce Dawson [Mon, 5 Jan 2015 21:21:46 +0000]
Get rid of fifteen copies of m_sTimeMap and their initializers.

m_sTimeMap is a global variable with a constructor and destructor, which
is not allowed. This change moves it to a function with a static pointer
so that it is constructed on demand and then leaked, thus avoiding
having startup and shutdown code.

This also fixes a worrisome bug caused by having m_sTimeMap defined in
a header file. Because m_sTimeMap was defined (and marked as static) in
a header file there were fifteen separate copies of it, one for each
source file which included the header file. This could easily lead to
bugs because a timer that was added from one source file would be
invisible to other source files.

Each instance of m_sTimeMap added four entries to the
dump-static-initializers.py report, for a total of sixty, so this fix
significantly cleans up that report.

BUG=441899
R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/831903002

4 years agoClean up bookmark related codes.
Bo Xu [Mon, 5 Jan 2015 20:39:36 +0000]
Clean up bookmark related codes.

Remove CPDF_Dictionary*() operator in CPDF_Bookmark class.
Unify naming conventions and coding styles.
Change some functions to const.

Change the name of function argument to |pDict| for FPDF_xxx type variable.
This makes the code more clear and gives better variable naming

R=tsepez@chromium.org

Review URL: https://codereview.chromium.org/828203002

4 years agoRemove static declared SymbolDictCache.
Bo Xu [Mon, 5 Jan 2015 18:48:34 +0000]
Remove static declared SymbolDictCache.

This is a follow up CL on https://codereview.chromium.org/761313004/

BUG=https://code.google.com/p/pdfium/issues/detail?id=93
R=brucedawson@chromium.org, tsepez@chromium.org

Review URL: https://codereview.chromium.org/828183002