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

5 years agoFix blank page issues caused by too strict check
Jun Fang [Thu, 20 Nov 2014 02:58:01 +0000]
Fix blank page issues caused by too strict check

Before this fix, PDF parser aborts the parsering process when detecting an error.
For this case, PDF parser just gives up parsering when it detects that the length of
image stream is incorrect. The solution to this case is to find the tag "endstream"
and "endobj" to calculate the length rather than aborting the parsering process.

BUG=433339
R=tsepez@chromium.org

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

5 years agoFixed crash on NULL de-referencing.
Vitaly Buka [Wed, 19 Nov 2014 01:17:31 +0000]
Fixed crash on NULL de-referencing.

BUG=433992
R=bo_xu@foxitsoftware.com

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

5 years agoFixing operator so that bCheckRight isn't always true. Unknown effect!
Bruce Dawson [Tue, 18 Nov 2014 21:50:28 +0000]
Fixing operator so that bCheckRight isn't always true. Unknown effect!

VC++'s /analyze points out that this expression:
    FX_BOOL bCheckRight = type != 'D' || type != 'W';"
is always true. This means that the tests for the right edge of a word

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

BUG=427616
R=jun_fang@foxitsoftware.com

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

5 years agoFixing format strings to remove 'z' size specifier.
Bruce Dawson [Tue, 18 Nov 2014 17:55:38 +0000]
Fixing format strings to remove 'z' size specifier.

As of the 2013 version VC++ still doesn't support the 'z' size specifier. This makes portable printing of size_t types frustrating. The simplest general solution is to use %u and cast to unsigned. If there was any possibility of the numbers getting larger than 32-bit then we would need better alternatives, but there is not.

This was found through code inspection, through /analyze, and through pdfium_test print this non-helpful message:

Loaded, parsed and rendered zu pages.
Skipped zu bad pages.

I can confirm that the fix works on Windows and it should work identically on mac. This is a follow-on to change 02e6ca4c4f.

R=tsepez@chromium.org

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

5 years agoRemoving unnecessary casts from wchar_t* to wchar_t*, by various names.
Bruce Dawson [Mon, 17 Nov 2014 23:33:04 +0000]
Removing unnecessary casts from wchar_t* to wchar_t*, by various names.

Remove casts that merely cast from wchar_t* to wchar_t*. Sometimes the
types or casts are FX_LPCWSTR but the idea is the same. Excess casts
can (and have) hidden bugs so removing these may prevent future problems.

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

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

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

5 years agoZero initialize ch to avoid possible bug - conditions are very subtle.
Bruce Dawson [Mon, 17 Nov 2014 23:22:03 +0000]
Zero initialize ch to avoid possible bug - conditions are very subtle.

Whether ch and iRet are read without being initialized depends on complex
preconditions and cannot be determined by looking at these function.
Therefore it seems prudent to zero initialize them to avoid any risk.

BUG=427616
R=bo_xu@foxitsoftware.com

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

5 years agoAdd Bruce to AUTHORS
Bo Xu [Mon, 17 Nov 2014 22:33:34 +0000]
Add Bruce to AUTHORS

R=jam@chromium.org

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

5 years agoRename functions in test code also -- fixing build-break from 2c021e0
Bo Xu [Mon, 17 Nov 2014 00:46:31 +0000]
Rename functions in test code also -- fixing build-break from 2c021e0

Change 2c021e0 fixed spelling errors in a couple of functions, but didn't
update the test code leading to two compilation errors. Fixed in this
change.

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

R=bo_xu@foxitsoftware.com

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

5 years agoCorrect typo in form fill environment functions
Bo Xu [Sat, 15 Nov 2014 01:40:50 +0000]
Correct typo in form fill environment functions

Complementary patch in chromium is in https://codereview.chromium.org/711553003

R=thestig@chromium.org

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

5 years agoRemove FX_LPCWSTR cast to wchar_t* literals
Bo Xu [Sat, 15 Nov 2014 01:03:50 +0000]
Remove FX_LPCWSTR cast to wchar_t* literals

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

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

5 years agoChange from 'this' to L'this' and remove the cast that was hiding this mismatch.
Bo Xu [Fri, 14 Nov 2014 22:18:05 +0000]
Change from 'this' to L'this' and remove the cast that was hiding this mismatch.

Found by VC++'s /analyze. Warning was:

fpdfsdk\src\javascript\js_runtime.cpp(352) : warning C6276:
Cast between semantically different string types:  char * to wchar_t *.
Use of invalid string can lead to undefined behavior.

This mismatch has been there as far back as the history goes (to May of this year).

It looks like a real bug to me. However I don't know the implications of this bug and why it would not have been noticed at run-time.

The code has been this way as far back as the git history goes, but that is only to May 2014.

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

BUG=427616
R=bo_xu@foxitsoftware.com

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

5 years agoFix build warning on android under stricter compilation rules.
Tom Sepez [Fri, 14 Nov 2014 19:29:28 +0000]
Fix build warning on android under stricter compilation rules.

Error is "converting to non-pointer type 'FX_DWORD'".
TBR=bo_xu@foxitsoftware.com

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

5 years agoBuild pdfium_test executable under GN.
Tom Sepez [Fri, 14 Nov 2014 00:59:03 +0000]
Build pdfium_test executable under GN.

This is the first side of a two-sided patch;
the dependency on //third_party/pdfium/samples will be included from //pdf/BUILD.gn in the chrome repo.

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

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

5 years agoMake DEPS use relative paths to fix recipe
Aneesh Mulye [Thu, 13 Nov 2014 21:59:20 +0000]
Make DEPS use relative paths to fix recipe

Context: DEPS was originally added to pdfium to allow its recipe to
automatically check out its dependencies. The recipe used absolute
paths, and so the checkout directory's name ('pdfium') had to be
prefixed to the directory checkout of every dependency, as gclient in
the recipe worked one level above the pdfium checkout itself.

After change fe4537269fc7133320a5131638757f2ffa6bd854, the recipe no
longer worked. To fix this, I'm making DEPS use relative paths.

BUG=375773
R=jam@chromium.org

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

5 years agoFix a bug when performing StretchDIBits on bit mask
Bo Xu [Mon, 10 Nov 2014 21:34:05 +0000]
Fix a bug when performing StretchDIBits on bit mask

BUG=401988
R=vitalybuka@chromium.org

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

5 years agoFix bug with reading from uninitialized variable found by VC++'s /analyze.
Tom Sepez [Thu, 6 Nov 2014 23:00:36 +0000]
Fix bug with reading from uninitialized variable found by VC++'s /analyze.

The flag variable is conditionally initialized but unconditionally read.

Warning was:
src\fpdfapi\fpdf_page\fpdf_page_pattern.cpp(274) : warning C6001:
Using uninitialized memory 'flag'.

BUG=427616
R=tsepez@chromium.org

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

5 years agoAdding constructor to _FX_SYSTEMTIME to resolve uninitialized read bugs found by...
Tom Sepez [Thu, 6 Nov 2014 22:38:12 +0000]
Adding constructor to _FX_SYSTEMTIME to resolve uninitialized read bugs found by /analyze on some error paths

Warning from /analyze was:
src\third_party\pdfium\fpdfsdk\include\fsdk_mgr.h(96) : warning C6001: Using uninitialized memory 'fxtime'.

Other error paths can also lead to reading from an uninitialized _FX_SYSTEMTIME object.

Code-gen for the constructor is small enough (four writes of zeroed EAX with VC++, less with gcc) to make putting the constructor in a .cc file unnecessary.

Approval of in-class member initialization would make this fix simpler but that has not quite been approved yet.

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

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

5 years agoFix PDFium build with Windows GN.
John Abd-El-Malek [Thu, 6 Nov 2014 18:42:39 +0000]
Fix PDFium build with Windows GN.

R=scottmg@chromium.org

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

5 years agoUndo an old change in freetype to account for size of USHORT
Bo Xu [Thu, 30 Oct 2014 23:02:56 +0000]
Undo an old change in freetype to account for size of USHORT

BUG=418582
R=tsepez@chromium.org

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

5 years agoFor v8 Global Object, do not copy in CJS_Value constructor.
Tom Sepez [Thu, 30 Oct 2014 20:23:42 +0000]
For v8 Global Object, do not copy in CJS_Value constructor.

BUG=425129
R=bo_xu@foxitsoftware.com

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

5 years agoUpdate openjpeg to r2920
Bo Xu [Thu, 30 Oct 2014 20:10:50 +0000]
Update openjpeg to r2920

BUG=414036, 425151
R=tsepez@chromium.org

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

5 years agoResolve compilation error with G++ 4.9.
Tom Sepez [Wed, 29 Oct 2014 22:31:20 +0000]
Resolve compilation error with G++ 4.9.

Add a check for zero-length keys to avoid hitting the equivalent of |""[1]|.
BUG=https://code.google.com/p/pdfium/issues/detail?id=58
R=jun_fang@foxitsoftware.com

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

5 years agoupdate openjpeg to r2911
Bo Xu [Wed, 22 Oct 2014 22:32:43 +0000]
update openjpeg to r2911

BUG=418976, 425150, 414525
R=tsepez@chromium.org

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

5 years agoChange the clear order of pDocPage and pDocRender
Bo Xu [Tue, 21 Oct 2014 21:50:16 +0000]
Change the clear order of pDocPage and pDocRender

pTransfer function is released in pDocRender cleanup but is still being accessed in
~CPDF_GeneralStateData in pDocPage cleanup.

BUG=419320
R=tsepez@chromium.org

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

5 years agoUpdate openjpeg to r2908
Bo Xu [Tue, 21 Oct 2014 20:05:17 +0000]
Update openjpeg to r2908

BUG=414089, 414310, 414606
R=tsepez@chromium.org

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

5 years agoMore fixes in sycc422_to_rgb and sycc420_to_rgb when image width is odd
Bo Xu [Tue, 21 Oct 2014 19:17:39 +0000]
More fixes in sycc422_to_rgb and sycc420_to_rgb when image width is odd

This patch is supplementary to issue 418881

R=tsepez@chromium.org

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

5 years agoAdd missing parenthesis in FXARGB_GETDIB macro
Bo Xu [Tue, 21 Oct 2014 19:04:41 +0000]
Add missing parenthesis in FXARGB_GETDIB macro

You can get warning when using FXARGB_GETDIB() with & operation in
the same statement like: FXARGB_GETDIB(src_scan) & 0xffffff in
fx_dib_composite.cpp:

../../third_party/pdfium/core/src/fxge/dib/fx_dib_composite.cpp:737:205:
error: '&' within '|' [-Werror,-Wbitwise-op-parentheses]

Original patch from jiangj@opera.com

R=thakis@chromium.org

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

5 years agoMake DEPS not add an extra pdfium directory.
John Abd-El-Malek [Thu, 16 Oct 2014 22:32:26 +0000]
Make DEPS not add an extra pdfium directory.

This makes gclient config and gclient sync work.

BUG=423896
TBR=aneeshm@chromium.org

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

5 years agoFix standalone build on Linux and Mac.
John Abd-El-Malek [Thu, 16 Oct 2014 21:26:18 +0000]
Fix standalone build on Linux and Mac.

BUG=423883
R=scottmg@chromium.org

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

5 years agoFix licenses in headers to pass Chromium's checklicenses tool.
Tom Sepez [Wed, 15 Oct 2014 17:16:45 +0000]
Fix licenses in headers to pass Chromium's checklicenses tool.

This is a re-landing of the changes in https://pdfium.googlesource.com/pdfium/+/6387aff
which were lost during a libopenjpeg library roll.

TBR=thestig@chromium.org

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

5 years agoStore the address of the page data map's value for proper referencing.
Bo Xu [Wed, 15 Oct 2014 00:10:06 +0000]
Store the address of the page data map's value for proper referencing.

CPDF_Pattern objects are counted and maintained in m_PatternedMap.
When a CPDF_Pattern object "pattern" is deleted, it's address is marked as NULL in m_PatternMap.
This patch stores the address of CPDF_Pattern's adderss in all objects that references "pattern",
to ensure valid referencing after deletion.

BUG=416319, 419976, 418392
R=tsepez@chromium.org

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

5 years agoDon't leave dangling pointer to out-of-scope local in CPDF_StreamContentParser::Parse.
Tom Sepez [Tue, 14 Oct 2014 21:40:57 +0000]
Don't leave dangling pointer to out-of-scope local in CPDF_StreamContentParser::Parse.

This is just a bit of defensive programming; I'm not sure the situation can
occur in the current code, but the following code is likely to set off a red
flag to anyone who reads it:
    CPDF_StreamParser syntax(pData, dwSize);
    m_pSyntax = &syntax;
since the extent of the local |syntax| is far less than the pointer member
|m_pSyntax|.  NULL it out before syntax goes out of scope.

R=jun_fang@foxitsoftware.com

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

5 years agoGlyph index is out of range in cff_get_glyph_name.
Jun Fang [Tue, 14 Oct 2014 20:57:19 +0000]
Glyph index is out of range in cff_get_glyph_name.
Glyph index shall be less than number of glyphs.

BUG=418585
R=tsepez@chromium.org

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

5 years agoFix off-by-one in sizing of m_EmbeddedToUnicodes.
Tom Sepez [Mon, 13 Oct 2014 20:16:32 +0000]
Fix off-by-one in sizing of m_EmbeddedToUnicodes.

BUG=421196
R=bo_xu@foxitsoftware.com

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

5 years agoFix a bug when image width is odd in sycc422_to_rgb
Bo Xu [Fri, 10 Oct 2014 22:57:36 +0000]
Fix a bug when image width is odd in sycc422_to_rgb

BUG=418881
R=tsepez@chromium.org

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

5 years agoEnable C linkage in fpdfppo.h
Bo Xu [Fri, 3 Oct 2014 20:18:55 +0000]
Enable C linkage in fpdfppo.h

BUG=pdfium-52
R=jun_fang@foxitsoftware.com

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