pdfium.git
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

4 years agoIn windows printing, convert src bitmap to dest bitmap using CompositeBitmap.
Bo Xu [Mon, 5 Jan 2015 18:11:47 +0000]
In windows printing, convert src bitmap to dest bitmap using CompositeBitmap.

When dealing with transparency, the printing procedure will generate a bitmap first,
then draw this bitmap in windows DC.
The format of source bitmap is argb, but the destination bitmap is rgb.
Simply doing memcpy will lose the alpha channel information, so CompositeBitmap function is needed.

BUG=412908
R=vitalybuka@chromium.org

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

4 years agoRemove g_NaN global variable and its constructor.
Bruce Dawson [Fri, 2 Jan 2015 19:59:15 +0000]
Remove g_NaN global variable and its constructor.

Doing the type conversion on demand is just as efficient as doing it at
startup time, and makes for more efficient startup.

Also mark g_nan as const, to reduce .data section size and enforce
desired semantics.

BUG=441899
R=bo_xu@foxitsoftware.com

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

4 years agoGet rid of FX_LPCSTR cast.
Bo Xu [Wed, 31 Dec 2014 00:56:12 +0000]
Get rid of FX_LPCSTR cast.

Follow up on https://codereview.chromium.org/733693003

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

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

4 years agoRevert build of pdfium_unittests.
Tom Sepez [Mon, 29 Dec 2014 23:40:32 +0000]
Revert build of pdfium_unittests.

Buildbot fails with the recent changes.

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

4 years agoFix pdfium buildbot build breakage from 336991d.
Tom Sepez [Mon, 29 Dec 2014 22:46:48 +0000]
Fix pdfium buildbot build breakage from 336991d.

Looks like some dependencies were missing during the run at
http://build.chromium.org/p/client.pdfium/builders/linux/builds/31/steps/gyp_pdfium/logs/stdio

TBR=brucedawson@chromium.org
TBR=thestig@chromium.org

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

4 years agoCreate pdfium_unittests binary.
Tom Sepez [Mon, 29 Dec 2014 21:56:16 +0000]
Create pdfium_unittests binary.

PDFium has not yet had a unit-tests binary, so introduce one based on
the typical gtest framework. Also provide a small initial test fragment
for fxcrt strings for instructional purposes.

Naturally, doing so kicked out one corner case that isn't handled, we'll
fix that in a separate patch.

This is a small part of the testing strategy tracking bug.
BUG=https://code.google.com/p/pdfium/issues/detail?id=62
R=brucedawson@chromium.org, palmer@chromium.org

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

4 years agoRefactor some code in CPDF_TextPage::ProcessTextObject().
Lei Zhang [Sat, 20 Dec 2014 05:54:15 +0000]
Refactor some code in CPDF_TextPage::ProcessTextObject().

Fix a memory leak while we are at it.

R=bo_xu@foxitsoftware.com

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

4 years agoFix new third_party/BUILD.gn to use the right build configuration.
Lei Zhang [Sat, 20 Dec 2014 05:21:35 +0000]
Fix new third_party/BUILD.gn to use the right build configuration.

TBR=tsepez@chromium.org

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

4 years agoSet the freetype options missing in the recent update.
Bo Xu [Sat, 20 Dec 2014 03:29:46 +0000]
Set the freetype options missing in the recent update.

Turn on the FT_CONFIG_OPTION_SUBPIXEL_RENDERING to enable sub-pixel rendering.

Also undef some other options to match what they look like before.

BUG=444243
R=thestig@chromium.org

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

4 years agoAdd the license back to ftmodule.h after the freetype 2.5.4 upgrade.
Lei Zhang [Sat, 20 Dec 2014 02:26:28 +0000]
Add the license back to ftmodule.h after the freetype 2.5.4 upgrade.

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

4 years agoTransform font size to user space for valid text size comparison.
Bo Xu [Fri, 19 Dec 2014 16:56:16 +0000]
Transform font size to user space for valid text size comparison.

BUG=438441
R=thestig@chromium.org

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

4 years agoUpdate freetype to 2.5.4.
Bo Xu [Fri, 19 Dec 2014 22:29:17 +0000]
Update freetype to 2.5.4.

Put freetype into third_party directory, cleaning up header files.

Previously freetype header files are in core/src/fxge/freetype and core/include/thirdparties. There were also multiple fx_freetype.h.

This patch removes the additional Foxit wrapper to make further update easier.

Notice, for original freetype source code, the following files are modified and need to be updated accordingly in future update:

third_party/freetype/include/config/ftmodule.h
third_party/freetype/include/config/ftoption.h

BUG=407341
R=thestig@chromium.org

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

4 years agoFix a few windows compile warnings
Bo Xu [Fri, 19 Dec 2014 10:27:25 +0000]
Fix a few windows compile warnings

R=tsepez@chromium.org

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

4 years agoCleanup: Refactor some code into its own function in fpdf_text_int.cpp.
Lei Zhang [Thu, 18 Dec 2014 22:03:45 +0000]
Cleanup: Refactor some code into its own function in fpdf_text_int.cpp.

Also use stdlib algorithms in a few places.

R=tsepez@chromium.org

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

4 years agoMerge: Fix obvious compilation breakage on win32 in previous version.
Tom Sepez [Thu, 18 Dec 2014 19:18:15 +0000]
Merge: Fix obvious compilation breakage on win32 in previous version.

TBR=thestig@chromium.org

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

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

4 years agoCleanup: Remove a shadow variable in CPDF_TextPage::CloseTempLine().
Lei Zhang [Thu, 18 Dec 2014 04:10:00 +0000]
Cleanup: Remove a shadow variable in CPDF_TextPage::CloseTempLine().

R=bo_xu@foxitsoftware.com

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

4 years agoAdd a small LRU cache for the JBIG2 symbol dictionary.
Bo Xu [Thu, 18 Dec 2014 01:51:00 +0000]
Add a small LRU cache for the JBIG2 symbol dictionary.
This reduces rendering time on my test document by over
10 seconds. It is super common for a JBIG2 dictionary to
span multiple pages, so we don't want to decode the same
dictionary over and over again.

Original patch from Jeff Breidenbach (breidenbach@gmail.com)

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

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

4 years agoMerge Initialize V8 external data back to master.
Tom Sepez [Thu, 18 Dec 2014 01:18:17 +0000]
Merge Initialize V8 external data back to master.
BUG=439793
R=thestig@chromium.org

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

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

4 years agoCleanup: Pass by const reference in fpdftext.
Lei Zhang [Thu, 18 Dec 2014 00:54:04 +0000]
Cleanup: Pass by const reference in fpdftext.

R=tsepez@chromium.org

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

4 years agoFix a bug that occurs when an object has the same object number with the root object
JUN FANG [Wed, 17 Dec 2014 21:58:56 +0000]
Fix a bug that occurs when an object has the same object number with the root object

Before this fix, the root will be released when an indirect object has the
same object number with the root. However, the root object is loaded when
the trailer is parsed. It shall not be updated or replaced anymore.

BUG=425040
R=tsepez@chromium.org

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

4 years agoAvoid duplicate definitions of JSCONST_n*Hash and QeTable variables.
Bruce Dawson [Sat, 13 Dec 2014 05:30:37 +0000]
Avoid duplicate definitions of JSCONST_n*Hash and QeTable variables.

QeTable is a 752 byte array that was defined in a header file. This
caused it to be instantiated by the VC++ compiler 12 times, wasting
8,272 bytes of space in the data segment. Because 'const' implies
'static' this did not cause any duplicate symbol errors.

JSCONST_n*HASH are a set of eight variables that are defined in a header
file. This causes them to be replicated 15 times. The variables
themselves are tiny but they are dynamically initialized and this
dynamic initialization code is replicated 15 times.

When tested on pdfium_test.exe the effect of this change is to:
Reduce the .text (code) segment by 3,616 bytes.
Reduce the .rdata section by 8,656 bytes.
Reduce the total binary file size by 13312 bytes.

These are the worst offenders for pdf.dll as shown in:
https://drive.google.com/open?id=1BvubxoA2SU_2e4T5cq7jHTjc1TlT0qOndpIfX3DMeA8&authuser=0

This will also drastically simplify the list of work to be done
for bug 441899 (getting rid of initializers).

BUG=441988
R=bo_xu@foxitsoftware.com

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

4 years agoFix build after previous commit.
John Abd-El-Malek [Sat, 13 Dec 2014 01:47:56 +0000]
Fix build after previous commit.

TBR=tsepez

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

4 years agoSimplify PDFium by removing code that's not used in the open source repo.
John Abd-El-Malek [Sat, 13 Dec 2014 00:42:18 +0000]
Simplify PDFium by removing code that's not used in the open source repo.

-remove parameter from FPDF_InitLibrary
-remove a bunch of ifdefs that are unused

R=tsepez@chromium.org

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

4 years agom_pColorSpace can not be NULL for image object with DCTDecode filter
Bo Xu [Thu, 11 Dec 2014 22:24:35 +0000]
m_pColorSpace can not be NULL for image object with DCTDecode filter

BUG=411842
R=tsepez@chromium.org

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

4 years agoDo not do strict check of BitsPerComponent for RunLengthDecode filter
Bo Xu [Thu, 11 Dec 2014 00:45:46 +0000]
Do not do strict check of BitsPerComponent for RunLengthDecode filter

BUG=438421
R=tsepez@chromium.org

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

4 years agoLab colorspace needs to be 3 component
Bo Xu [Thu, 11 Dec 2014 00:00:29 +0000]
Lab colorspace needs to be 3 component

BUG=429134
R=tsepez@chromium.org

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

4 years agoTrailer should be a dictionary object
Bo Xu [Tue, 9 Dec 2014 18:13:59 +0000]
Trailer should be a dictionary object

BUG=https://code.google.com/p/pdfium/issues/detail?id=86

a "<<" token should follow "trailer" but "<" will trick the parser to make trailer a hex string object.

R=tsepez@chromium.org

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

4 years agoReplace manual/error-prone/hard-to-verify arraysize calculations with safe FX_ArraySi...
Bruce Dawson [Tue, 9 Dec 2014 00:19:45 +0000]
Replace manual/error-prone/hard-to-verify arraysize calculations with safe FX_ArraySize macro.

pdfium has numerous places where the number of elements in an array is
calculated with expressions like:

    sizeof(cFormats)/sizeof(FX_LPCWSTR)

This is suboptimal because it is verbose, it is easy to get wrong, and
it cannot be determined through casual inspection whether the code is
correct. It will give incorrect results if cFormats is a pointer instead
of an array and it will give incorrect results if FX_LPCWSTR is not the
type of the array elements.

The FX_WSTRC macro in fx_string.h which I fixed was particularly scary
because it would silently misbehave if passed a pointer.

The FX_ArraySize macro which I have added and started using (taken from
arraysize in v8's macros.h) is easier to use and will always give correct
results. If passed a pointer it will fail to compile.

For this change I only fixed instances of sizeof(FX_LPCWSTR). There
appear to be about 150 other places in the pdfium code that could
benefit from using FX_ArraySize.

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

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

4 years agoGetting rid of more (FX_LPCWSTR) casts and fixing two bugs revealed by this.
Bruce Dawson [Mon, 8 Dec 2014 21:10:02 +0000]
Getting rid of more (FX_LPCWSTR) casts and fixing two bugs revealed by this.

Since casts to FX_LPCWSTR have been shown to hide bugs I tried removing
more of them, targeting those places where a cast was used to force a
conversion from CFX_WideString to FX_LPCWSTR, replacing these casts with
calls to the newly added .c_str() function. This revealed two places
where the cast was hiding a bug -- where ->c_str() was required instead!

This removes ~33 FX_LPCWSTR casts and there are ~31 left, many of which
will go away in some future change.

Also includes this change:

Removing unnecessary casts from wchar_t* to wchar_t*, by various names.

Original patch from Bruce Dawson(brucedawson@chromium.org)

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

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

4 years agoCleanup: Remove an unused function.
Lei Zhang [Thu, 4 Dec 2014 02:22:40 +0000]
Cleanup: Remove an unused function.

R=bo_xu@foxitsoftware.com

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

4 years agoAdd a missing 'using' keyword in big integer library
Bo Xu [Wed, 3 Dec 2014 00:48:41 +0000]
Add a missing 'using' keyword in big integer library

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

4 years agoModify big integer library
Bo Xu [Wed, 3 Dec 2014 00:34:20 +0000]
Modify big integer library

This patch follows https://pdfium.googlesource.com/pdfium/+/44047c3300d07192a67b1714084cc2d43b1e9bd9

Modify the library to resolve compile error,
add copyright notice and change pdfium.gyp and BUILD.gn

R=tsepez@chromium.org

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

4 years agoRemove unnecessary files in third_party/bigint
Bo Xu [Tue, 2 Dec 2014 22:28:36 +0000]
Remove unnecessary files in third_party/bigint

This patch follows the initial check in of big integer library at
https://pdfium.googlesource.com/pdfium/+/7504b3d87d6143661746d85c3c3e4052939b4e52

R=tsepez@chromium.org

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

4 years agoInitial check in of big integer library, v2010.04.30
Bo Xu [Tue, 2 Dec 2014 21:06:22 +0000]
Initial check in of big integer library, v2010.04.30

R=tsepez@chromium.org

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

4 years agoUpdate to openjpeg r2944
Bo Xu [Mon, 24 Nov 2014 21:58:10 +0000]
Update to openjpeg r2944

BUG=429139,430566,431288
R=tsepez@chromium.org

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