pdfium.git
4 years agoMake (and verify) public/ files compile under C.
Tom Sepez [Tue, 12 May 2015 23:17:04 +0000]
Make (and verify) public/ files compile under C.

This involves adding some missing extern "C" { } declarations,
using FPDF_ types instead of C++ types, and converting pass
by reference arguments into pointers.

Test this using fpdfview_embedertest for simplicity.

BUG=pdfium:158
R=thestig@chromium.org

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

4 years agoDescribe required properties of public/ files with a README.
Tom Sepez [Tue, 12 May 2015 22:44:39 +0000]
Describe required properties of public/ files with a README.

R=thestig@chromium.org

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

4 years agoRestore checked strlen conversions.
Tom Sepez [Tue, 12 May 2015 21:49:29 +0000]
Restore checked strlen conversions.

The checked conversion can be re-enabled now that there is a public
API free of private headers like this one.

This reverts commit 6661fd4c26106cd530d187b36f29be7e5c98b70f.

R=thestig@chromium.org

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

4 years agoNEW public API for pdfwindow font manipulation.
Tom Sepez [Tue, 12 May 2015 19:24:22 +0000]
NEW public API for pdfwindow font manipulation.

PDFium side of fix to make chromium free of private header
includes.  This moves the one snippet of contaminating code
from chrome to PDFium itself.

BUG=486818
R=thestig@chromium.org

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

4 years agoAdd owners file for PDFium.
Tom Sepez [Mon, 11 May 2015 23:32:41 +0000]
Add owners file for PDFium.

This is currently blocking a PDFium roll in chrome, see
http://build.chromium.org/p/tryserver.chromium.linux/builders/chromium_presubmit/builds/62816/steps/presubmit/logs/stdio

R=thestig@chromium.org

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

4 years agoCreate top-level public/ header directory.
Tom Sepez [Mon, 11 May 2015 21:27:24 +0000]
Create top-level public/ header directory.

These are the only files that embedders of PDFium should be including.
They are entirely self-contained, and compile cleanly against -Wall so
as to not offend the code that may include them.

Having done this, we can see that chromium is pulling in two additional
files from the fpdfsdk/include/pdfwindow directory, which is not guaranteed
to work.

A few files are renamed, adding an "_" to make the names consistent.
The exception is fpdfview, which is doc'd as such in the doc.

Naturally, paths will need updating in a handful of files in chrome
when this rolls in.

BUG=pdfium:154
R=thestig@chromium.org

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

4 years agoMove function prototypes to new doc_utils.h file
Tom Sepez [Fri, 8 May 2015 20:36:50 +0000]
Move function prototypes to new doc_utils.h file

... rather than redundantly declaring them in several .cpp files, and
hoping that the linker lines things up for you.

R=thestig@chromium.org

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

4 years agoFix compilation under chromium checkouts.
Tom Sepez [Fri, 8 May 2015 20:21:18 +0000]
Fix compilation under chromium checkouts.

This is a fix to hide pdfium's safe_conversions.h from the
higher-level callers.

R=thestig@chromium.org

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

4 years agoBetter error from pdfium_test when page too big to render.
Tom Sepez [Fri, 8 May 2015 18:53:53 +0000]
Better error from pdfium_test when page too big to render.

BUG=pdfium:114
R=thestig@chromium.org

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

4 years agoFix errors from commit f0a169e.
Lei Zhang [Fri, 8 May 2015 18:33:26 +0000]
Fix errors from commit f0a169e.

- fread() returns the number of items read.
- fix a memory leak in error handling.

R=tsepez@chromium.org

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

4 years agoFix a bunch of -Wunused-but-set-variable warnings.
Lei Zhang [Fri, 8 May 2015 18:03:55 +0000]
Fix a bunch of -Wunused-but-set-variable warnings.

Also fix a few nits and other errors along the way.

R=tsepez@chromium.org

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

4 years agoSupport arrays in nonstd::unique_ptr<>.
Tom Sepez [Thu, 7 May 2015 00:29:29 +0000]
Support arrays in nonstd::unique_ptr<>.

This mimics the std:: behaviour.

R=thestig@chromium.org

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

4 years agoManual revert of ad2a822ce5c3
Tom Sepez [Wed, 6 May 2015 23:09:05 +0000]
Manual revert of ad2a822ce5c3

Reason for revert: No longer needed in face of 9ea57a43faea
TBR=thestig@chromium.org

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

4 years agoRemove FX_STRSIZE casts, use safe conversions
Tom Sepez [Wed, 6 May 2015 22:58:32 +0000]
Remove FX_STRSIZE casts, use safe conversions

BUG=pdfium:153
R=thestig@chromium.org

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

4 years agoFix fx_string.h compile error under chromium checkouts.
Tom Sepez [Wed, 6 May 2015 19:40:23 +0000]
Fix fx_string.h compile error under chromium checkouts.

This gets included in chromium's pdfium_engine.cc, and thus must pass a
higher error level.  There's probably a follow-up to check why the FPDF_ api
doesn't insulate chromium from this file.

TBR=thestig@chromium.org

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

4 years agoFix a couple of divide by zero crashes in PNG/TIFF predictors.
Lei Zhang [Wed, 6 May 2015 19:34:26 +0000]
Fix a couple of divide by zero crashes in PNG/TIFF predictors.

BUG=484002
R=tsepez@chromium.org

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

4 years agoExpose additional flags for rasterization.
Scott Byer [Wed, 6 May 2015 00:02:40 +0000]
Expose additional flags for rasterization.

These flags are unused in Chromium, but are needed for the Cloud Print
conversion process, which takes PDF and produces a raster for low-end
printers. Certain low-end printers (e.g., B&W laser printers) will
turn anti-aliased text into a mess. The existing printing flag isn't
sufficient, as other kinds of printers will still want some kinds of
anti-aliasing to occur for best results.

BUG=482253
TEST=none
R=vitalybuka@chromium.org

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

Patch from Scott Byer <scottbyer@chromium.org>.

4 years agoMake sure string constructors are efficient on literals
Tom Sepez [Tue, 5 May 2015 22:15:38 +0000]
Make sure string constructors are efficient on literals

Separate out the overload when the length is not known, and be sure that
strlen() call is in the header so that strlen("foo") => 3 (since many
compilers support this optimization).

Also delete some unused types.

BUG=pdfium:151
R=thestig@chromium.org

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

4 years agoFix issues with != and == in fx_basic_wstring
Tom Sepez [Mon, 4 May 2015 22:20:29 +0000]
Fix issues with != and == in fx_basic_wstring

Part two.  Fix same issue in wide strings as in their bytestring
counterparts.

R=thestig@chromium.org

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

4 years agoKill FX_DEFINEHANDLE
Tom Sepez [Mon, 4 May 2015 21:53:09 +0000]
Kill FX_DEFINEHANDLE

I spent at least 2 minutes grep'ing for a class or struct (on the other
branch) that was delcared using this.

R=thestig@chromium.org

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

4 years agoFix issuse with != and == shown by fx_basic_bstring unit tests.
Tom Sepez [Mon, 4 May 2015 21:03:25 +0000]
Fix issuse with != and == shown by fx_basic_bstring unit tests.

R=thestig@chromium.org

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

4 years agoBackfill some FX StringC unit tests for == and !=.
Tom Sepez [Fri, 1 May 2015 23:55:45 +0000]
Backfill some FX StringC unit tests for == and !=.

Continuation of https://codereview.chromium.org/1122573002
Applies similar test to immutable versions of strings.

R=thestig@chromium.org

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

4 years agoBackfill some FX String unit tests for == and !=.
Tom Sepez [Fri, 1 May 2015 23:24:04 +0000]
Backfill some FX String unit tests for == and !=.

... and there are a few inconsistencies which we can now fix. Also add a
comment about why these strings aren't headed for the dust-bin long term.

R=thestig@chromium.org

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

4 years agoSave 4 bytes per CFX_ByteString where intptr_t smaller than long.
Tom Sepez [Fri, 1 May 2015 23:04:32 +0000]
Save 4 bytes per CFX_ByteString where intptr_t smaller than long.

Also prevent theoretical roll-over where long smaller than intptr_t.
See bug for discussion.

BUG=pdfium:149
R=thestig@chromium.org

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

4 years agoSave 8 bytes in each CFX_ByteString/WideString (on "LP64" platforms).
Tom Sepez [Fri, 1 May 2015 21:48:58 +0000]
Save 8 bytes in each CFX_ByteString/WideString (on "LP64" platforms).

(Also makes the calculation robust in face of changes to the header).
BUG=pdfium:149
R=thestig@chromium.org

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

4 years agoAdjust the visibility of the standalone targets in the GN build.
Dirk Pranke [Fri, 1 May 2015 21:26:13 +0000]
Adjust the visibility of the standalone targets in the GN build.

As part of the migration from GYP->GN, we want to make sure that we
can track when new targets are added to either the GYP or GN builds
and that we are building everything we expect to build.

In GN, unlike GYP, if a build file gets referenced from other files,
building 'all' will cause every target to be built in it. This means in
particular, that we can end up trying to build targets that are not
necessarily intended to be visible to the rest of the build. To get
around this, any target that is defined but hidden (like 'pdfium_unittests',
) should still be visible to a top-level target called
"//:gn_visibility".

R=tsepez@chromium.org, brettw@chromium.org
BUG=461019

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

4 years agoTake adavange of unused bytes at end of widestring
Tom Sepez [Thu, 30 Apr 2015 22:28:51 +0000]
Take adavange of unused bytes at end of widestring

Follow-on to https://codereview.chromium.org/1120703003/

R=thestig@chromium.org

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

4 years agoTry to take advantage of unused bytes at end of CFX_ByteString.
Tom Sepez [Thu, 30 Apr 2015 22:21:18 +0000]
Try to take advantage of unused bytes at end of CFX_ByteString.

Given the representation of StringData, it seems sub-optimal not to be doing this.

R=thestig@chromium.org

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

4 years agoProvide an array buffer allocator to V8.
Tom Sepez [Thu, 30 Apr 2015 21:30:29 +0000]
Provide an array buffer allocator to V8.

This allows PDFium to work with current V8, so unpin v8 in the
pdfium DEPS file.

(I also re-ordered one field in CJS_Runtime, just to put two bools
together (may pack tighter), and to put all the v8 stuff together).

BUG=pdfium:146
R=thestig@chromium.org

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

4 years agoAdd suppressions for all new failing corpus tests.
Tom Sepez [Thu, 30 Apr 2015 00:07:40 +0000]
Add suppressions for all new failing corpus tests.

TBR=thestig@chromium.org

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

4 years agoCorpus roll to pick up the 2015-04-28 Foxit drop.
Tom Sepez [Wed, 29 Apr 2015 23:50:07 +0000]
Corpus roll to pick up the 2015-04-28 Foxit drop.

This will undoubtedly red up the tree, as we don't have trybots. A follow-up
CL will add the suppressions required for each platform at the moment.

The new suppressions in this CL are for cases where we didn't generate an
expected result file (due to the issue in fx/FRC_3.5_part1/Introduction.txt).

R=thestig@chromium.org

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

4 years agoMake CFX_WideString::LockBuffer() completely unused.
Tom Sepez [Tue, 28 Apr 2015 21:10:30 +0000]
Make CFX_WideString::LockBuffer() completely unused.

Then remove CFX_{Wide,Byte}String::LockBuffer().  Prelude to a vast
simplification. There's an additional copy now in one place, so
shoot me.

BUG=pdfium:144
R=thestig@chromium.org

Committed: https://pdfium.googlesource.com/pdfium/+/ee7412f5aef353e5c6f1a64d0e1708ed926869d9

Committed: https://pdfium.googlesource.com/pdfium/+/5a256ad29483eb2b13e6e2c89fe0f77a9103f68f

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

4 years agoPin V8 version until initialization issue in b584bab resolved.
Tom Sepez [Tue, 28 Apr 2015 20:29:01 +0000]
Pin V8 version until initialization issue in b584bab resolved.

TBR=thestig@chromium.org

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

4 years agoRevert "Make CFX_WideString::LockBuffer() completely unused."
Tom Sepez [Tue, 28 Apr 2015 19:33:56 +0000]
Revert "Make CFX_WideString::LockBuffer() completely unused."

This reverts commit 5a256ad29483eb2b13e6e2c89fe0f77a9103f68f.
Reason for revert: broke JS tests.

TBR=thestig@chromium.org

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

4 years agoMake CFX_WideString::LockBuffer() completely unused.
Tom Sepez [Tue, 28 Apr 2015 19:25:39 +0000]
Make CFX_WideString::LockBuffer() completely unused.

Then remove CFX_{Wide,Byte}String::LockBuffer().  Prelude to a vast
simplification. There's an additional copy now in one place, so
shoot me.

BUG=pdfium:144
R=thestig@chromium.org

Committed: https://pdfium.googlesource.com/pdfium/+/ee7412f5aef353e5c6f1a64d0e1708ed926869d9

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

4 years agoRevert "Make CFX_WideString::LockBuffer() completely unused."
Tom Sepez [Mon, 27 Apr 2015 22:10:00 +0000]
Revert "Make CFX_WideString::LockBuffer() completely unused."

This reverts commit ee7412f5aef353e5c6f1a64d0e1708ed926869d9.
Reason for revert: VS compile broke.

TBR=thestig@chromium.org

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

4 years agoMake CFX_WideString::LockBuffer() completely unused.
Tom Sepez [Mon, 27 Apr 2015 22:00:04 +0000]
Make CFX_WideString::LockBuffer() completely unused.

Then remove CFX_{Wide,Byte}String::LockBuffer().  Prelude to a vast
simplification. There's an additional copy now in one place, so
shoot me.

BUG=pdfium:144
R=thestig@chromium.org

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

4 years agoSEGV in CFX_BaseSegmentedArray::Iterate() when CS has malformed dictionary.
Tom Sepez [Mon, 27 Apr 2015 20:24:03 +0000]
SEGV in CFX_BaseSegmentedArray::Iterate() when CS has malformed dictionary.

Failure to check document-controlled value before using it.

BUG=481363
R=palmer@chromium.org, thestig@chromium.org

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

4 years agoFix windows-specific usage of CFX_WideStr::operator LPCWSTR().
Tom Sepez [Mon, 27 Apr 2015 20:12:53 +0000]
Fix windows-specific usage of CFX_WideStr::operator LPCWSTR().

Carry-on from https://codereview.chromium.org/1108903002/

R=brucedawson@chromium.org

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

4 years agoReduce usage of operator LPCWSTR from CFX_WideString().
Tom Sepez [Mon, 27 Apr 2015 18:47:29 +0000]
Reduce usage of operator LPCWSTR from CFX_WideString().

This involves adding some explicit c_str() calls. Doing so flagged
PDF_EncodeText() and FindOptionValue() as having suboptimal signatures, in
that we are often throwing away a perfectly fine length and recomputing it.

There are still some platform-specific code that needs the operator.

R=brucedawson@chromium.org

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

4 years agoRevert "Kill operator LPCWSTR from CFX_WideString()."
Tom Sepez [Mon, 27 Apr 2015 18:31:26 +0000]
Revert "Kill operator LPCWSTR from CFX_WideString()."

This reverts commit 15a62973b9b89c3e229cc0ab501c45967f91b325.
Reason for revert: broke build on windows, mac.  I must have missed
some platform-specific conversions.

TBR=brucedawson@chromium.org

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

4 years agoKill operator LPCWSTR from CFX_WideString().
Tom Sepez [Mon, 27 Apr 2015 18:22:20 +0000]
Kill operator LPCWSTR from CFX_WideString().

This involves adding some explicit c_str() calls. Doing so flagged
PDF_EncodeText() and FindOptionValue() as having suboptimal signatures, in
that we are often throwing away a perfectly fine length and recomputing it.

R=brucedawson@chromium.org

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

4 years agoRemove unused nParamNum values from JS method tables.
Tom Sepez [Fri, 24 Apr 2015 00:50:57 +0000]
Remove unused nParamNum values from JS method tables.

The code to validate the number of parameters happens inside each particular
method, rather than prior to method dispatch. As such, there's no point in
having this number take up space in the table.

Add some test to cover at least some of the per-method validations, and
update error messages to be more useful.

R=thestig@chromium.org

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

4 years agoKill overloaded cast operators in CJS_Value.
Tom Sepez [Thu, 23 Apr 2015 18:23:10 +0000]
Kill overloaded cast operators in CJS_Value.

The red-flag here is the explicit invocation of things like
    params[1].operator CFX_WideString()

rather than
    static_cast<CFX_WideString>(params[1])

to invoke the conversion.  Turns out the above won't compile due to
ambiguity given the number of implicit constructors for widestrings.
CJS_Value has both constructors and assignment operators for the
primitive types, which means that conversions can take place
unexpectedly in both directions, a second red flag.

We don't want the compiler invoking these at will since it may hide
bugs. In fact, when they are removed, three such places were
discovered.

Also rename ToJSValue to ToV8Value to match the other ToV8xxxxx
functions added.

R=thestig@chromium.org

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

4 years agoFix segmentation fault 'denial of service condition'
JUN FANG [Thu, 23 Apr 2015 17:12:19 +0000]
Fix segmentation fault 'denial of service condition'

BUG=467392
R=thestig@chromium.org, tsepez@chromium.org

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

4 years agoAdd missing operators for CFX_WideStringC.
Tom Sepez [Wed, 22 Apr 2015 19:16:31 +0000]
Add missing operators for CFX_WideStringC.

Part 2 of 4.

R=thestig@chromium.org
TBR=brucedawson@chromium.org
BUG=pdfium:142

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

4 years agoAdd missing operators for CFX_ByteStringC.
Tom Sepez [Wed, 22 Apr 2015 19:04:14 +0000]
Add missing operators for CFX_ByteStringC.

Removing the implicit cast operator forces a build breakage should we
use ByteStringC in STL containers. Adding an operator< restores correct
behaviour. Adding an operator[] avoids re-writing some code to call
GetPtr() prior to array indexing.

Part 1 of 4.

R=thestig@chromium.org
TBR=brucedawson@chromium.org
BUG=pdfium:142.

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

4 years agoAdd missing operators for CFX_WideString
Tom Sepez [Wed, 22 Apr 2015 17:23:07 +0000]
Add missing operators for CFX_WideString

Part 4 of 4.

BUG=pdfium:142
R=brucedawson@chromium.org, thestig@chromium.org

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

4 years agoAdd missing operators for CFX_ByteString.
Tom Sepez [Wed, 22 Apr 2015 17:09:35 +0000]
Add missing operators for CFX_ByteString.

Part 3 of 4.

BUG=pdfium:142
R=brucedawson@chromium.org, thestig@chromium.org

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

4 years agoFix a regression with cut off images.
Lei Zhang [Wed, 22 Apr 2015 01:35:03 +0000]
Fix a regression with cut off images.

This regressed in commit 3f41851 due to shadow variables.

BUG=478164
R=tsepez@chromium.org

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

4 years agoKill CFX_StringBufTemplate.
Tom Sepez [Tue, 21 Apr 2015 22:09:19 +0000]
Kill CFX_StringBufTemplate.

It's unused.

R=thestig@chromium.org

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

4 years agoFix a crashier due to images with abnormal size
JUN FANG [Tue, 21 Apr 2015 16:58:09 +0000]
Fix a crashier due to images with abnormal size

BUG=453553
R=thestig@chromium.org, tsepez@chromium.org

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

4 years agoRemove Release() from IFX_Edit_UndoItem.
Tom Sepez [Mon, 20 Apr 2015 22:12:39 +0000]
Remove Release() from IFX_Edit_UndoItem.

Also delete unused CFFL_Edit_UndoItem class.

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

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

4 years agoRemove release method from CBA_AnnotItetator.
Tom Sepez [Mon, 20 Apr 2015 20:38:38 +0000]
Remove release method from CBA_AnnotItetator.

Also remove virtual methods, since this is neither subclassed nor a
subclass.

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

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

4 years agoRemove Release() from CPDF_PageObject
Tom Sepez [Mon, 20 Apr 2015 19:29:12 +0000]
Remove Release() from CPDF_PageObject

BUG=pdfium:140
R=thestig@chromium.org

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

4 years agoRemove unused FX_NEW definition.
Tom Sepez [Fri, 17 Apr 2015 23:03:41 +0000]
Remove unused FX_NEW definition.

R=thestig@chromium.org

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

4 years agoFix all remaining instances of FX_NEW.
Tom Sepez [Fri, 17 Apr 2015 22:15:08 +0000]
Fix all remaining instances of FX_NEW.

R=thestig@chromium.org

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

4 years agoReplace FX_NEW with new, remove tests from fpdfsdk
Tom Sepez [Fri, 17 Apr 2015 20:57:46 +0000]
Replace FX_NEW with new, remove tests from fpdfsdk

R=thestig@chromium.org

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

4 years agoSet m_FontType in CPDF_Font() constructor.
Tom Sepez [Fri, 17 Apr 2015 20:07:49 +0000]
Set m_FontType in CPDF_Font() constructor.

This can't change for the life of the object, so tidy up some wild uses
throughout the code. Also kill pointless Initialize() method.

R=thestig@chromium.org

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

4 years agoAdd nonstd::unique_ptr as a workaround until std::unique_ptr is allowed.
Tom Sepez [Fri, 17 Apr 2015 19:55:39 +0000]
Add nonstd::unique_ptr as a workaround until std::unique_ptr is allowed.

This is a copy of breakpad's standalone scoped_ptr, which has been
renamed to nonstd::unique_ptr, and from which more complicated classes
have been removed. The reset() method has also been tweaked to more
closely match c++11, and an implicit conversion to bool has been added.

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

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

4 years agoMake CFX_StockFontArray more robust.
Lei Zhang [Thu, 16 Apr 2015 23:42:51 +0000]
Make CFX_StockFontArray more robust.

- Check bounds when accessing array.
- Remove potential memory leak.
- Merge duplicate code.

R=tsepez@chromium.org

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

4 years agoReplace FX_NEW with new, remove tests from fpdfapi
Tom Sepez [Thu, 16 Apr 2015 21:37:47 +0000]
Replace FX_NEW with new, remove tests from fpdfapi

Very few places where a change is required, but remove FX_NEW to show
they've been audited.

R=thestig@chromium.org

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

4 years agoReplace FX_NEW with new, remove tests from fpdftext
Tom Sepez [Thu, 16 Apr 2015 21:29:43 +0000]
Replace FX_NEW with new, remove tests from fpdftext

R=thestig@chromium.org

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

4 years agoReplace FX_NEW with new, remote tests from fxcodec
Tom Sepez [Thu, 16 Apr 2015 21:21:25 +0000]
Replace FX_NEW with new, remote tests from fxcodec

R=thestig@chromium.org

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

4 years agoReplace FX_NEW with new, remove tests in fpdfdoc.
Tom Sepez [Thu, 16 Apr 2015 21:13:14 +0000]
Replace FX_NEW with new, remove tests in fpdfdoc.

R=thestig@chromium.org

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

4 years agoSupress the two noisiest warnings on linux standalone builds.
Tom Sepez [Thu, 16 Apr 2015 20:58:51 +0000]
Supress the two noisiest warnings on linux standalone builds.

Code might someday be made clean for -Wmissing-field-initializers
and -Wsign-compare, but for now this produces too much noise to be
useful.

The -Wmissing-field-initializers warning is misguided in a high
percentage of cases, and actually leads to bad fixes.

R=brucedawson@chromium.org

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

4 years agoFix pdfium standalone to compile with VS 2015.
Bruce Dawson [Thu, 16 Apr 2015 20:45:33 +0000]
Fix pdfium standalone to compile with VS 2015.

This change disables several warnings that fire frequently
in pdfium and are not practical to fix at this time.

R=tsepez@chromium.org
BUG=440500

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

4 years agoRemove checks in fxge/{apple,win32,skia,dib} now that FX_NEW cant return 0
Tom Sepez [Thu, 16 Apr 2015 16:13:02 +0000]
Remove checks in fxge/{apple,win32,skia,dib} now that FX_NEW cant return 0

R=thestig@chromium.org

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

4 years agoRemove checks in fxge/ge now that FX_NEW can't return 0.
Tom Sepez [Thu, 16 Apr 2015 15:31:30 +0000]
Remove checks in fxge/ge now that FX_NEW can't return 0.

R=thestig@chromium.org

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

4 years agoRemove checks in fxcrt now that FX_NEW can't return 0.
Tom Sepez [Wed, 15 Apr 2015 21:17:33 +0000]
Remove checks in fxcrt now that FX_NEW can't return 0.

Replace them with |new| so that we can tell by the presence of FX_NEW
the places that still need to be audited.

R=thestig@google.com, thestig@chromium.org

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

4 years agoFix offset outside bounds of constant string warnings
JUN FANG [Wed, 15 Apr 2015 19:00:53 +0000]
Fix offset outside bounds of constant string warnings

BUG=380476
R=tsepez@chromium.org

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

4 years agoDon't use NEON optimized code in lpng_v163
Sam Clegg [Wed, 15 Apr 2015 17:53:07 +0000]
Don't use NEON optimized code in lpng_v163

The source files required to use the NEON function are not
included so we should not try to reference those symbols.

BUG=477162
TEST=ninja -C out_arm/Release/ pdfium_diff
R=tsepez@chromium.org

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

4 years agoMake FX_NEW throw on OOM.
Tom Sepez [Wed, 15 Apr 2015 17:11:12 +0000]
Make FX_NEW throw on OOM.

Restores default behavior of new.

R=thestig@chromium.org

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

4 years agoLand on Master: Fix two new / free mismatches
Tom Sepez [Tue, 14 Apr 2015 23:00:03 +0000]
Land on Master: Fix two new / free mismatches

Note: Landed on XFA first by mistake.

Original review: https://codereview.chromium.org/1085963002/
TBR=brucedawson@chromium.org

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

4 years agoKill CFX_Object.
Tom Sepez [Tue, 14 Apr 2015 19:54:38 +0000]
Kill CFX_Object.

CFX_Object is a type that implements its own new operators that return
NULL on error. There's no need for this given the |new (std::nothrow)|
syntax; in fact, the current code can only work if there is no activity
in the constructors.  This may explain the pervasive lack of
constructors and reliance on Init() methods throughout the codebase.

The activity takes place in fx_memory.h, where FX_NEW is mapped onto
the std::nothrow syntax.  The rest is just cleanup.

Down the road, we will simply throw and remove all the error-checking
paths for new objects. Landing this patch first will at least show a
simple path back to the old behaviour without having to re-introduce
CFX_Object should someone want to do so in their own fork.

R=thestig@chromium.org

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

4 years agoFix a heap overflow in CJBig2_Context::parseSymbolDict
JUN FANG [Mon, 13 Apr 2015 17:34:10 +0000]
Fix a heap overflow in CJBig2_Context::parseSymbolDict

BUG=476107
R=tsepez@chromium.org

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

4 years agoFix compiling warnings on Windows
Jun Fang [Sat, 11 Apr 2015 18:34:43 +0000]
Fix compiling warnings on Windows

TBR=tsepez@chromium.org

BUG=N/A

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

4 years agoFix a heap buffer overflow issue in CPDF_CMap::GetNextChar
JUN FANG [Sat, 11 Apr 2015 16:33:23 +0000]
Fix a heap buffer overflow issue in CPDF_CMap::GetNextChar

Add a check to make sure offset is less than the size of string in the function of GetNextChar().

BUG=471651
R=tsepez@chromium.org

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

4 years agoFix the noisiest variable shadowing warnings in pdfium.
Bruce Dawson [Fri, 10 Apr 2015 21:49:35 +0000]
Fix the noisiest variable shadowing warnings in pdfium.

Three functions in fx_coordinates.h account for 60% of the warnings
when building with VS 2015, due to variable shadowing. Renaming the
function parameters is safe, resolves the warnings, and reduces
confusion.

R=tsepez@chromium.org
BUG=440500

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

4 years agoBetter fix for snprintf non-termination on windows.
Tom Sepez [Fri, 10 Apr 2015 21:43:15 +0000]
Better fix for snprintf non-termination on windows.

Replaces https://codereview.chromium.org/1062983002/
BUG=469244
R=brucedawson@chromium.org

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

4 years agoFix a stack overflow in CPDF_Parser::LoadCrossRefV5
JUN FANG [Fri, 10 Apr 2015 20:45:43 +0000]
Fix a stack overflow in CPDF_Parser::LoadCrossRefV5

A stack overflow was triggered by checked_cast due to
invalid index in pdf files like 'Index[45 -1661]'.

BUG=473400
R=tsepez@chromium.org

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

4 years agoDon't call FPDF_InitLibrary() in individual unit_tests.
Tom Sepez [Fri, 10 Apr 2015 17:29:21 +0000]
Don't call FPDF_InitLibrary() in individual unit_tests.

The initialization sequence becomes more complicated as v8 evolves
and when we move to XFA (where pdfium_unittests are currently broken).
Centralize this initialization in a few places, like the embedder_test
framework and the pdfium_test binary, and convert tests that require
it into embedder_tests rather than unit_tests.

Change on master first before moving to XFA.

R=thestig@chromium.org

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

4 years agoUpdate DEPS to pull V8 from the new repository.
Tom Sepez [Thu, 9 Apr 2015 21:05:37 +0000]
Update DEPS to pull V8 from the new repository.

Also update build files to deal with the new revision.  The main issue
is the external startup files for v8.  The default is not to use them
(simpler for standalone users to deploy), but can be built either way.

R=thestig@chromium.org

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

4 years agoInclude windows.h instead of the MFC header afxres.h
Bruce Dawson [Thu, 9 Apr 2015 20:44:54 +0000]
Include windows.h instead of the MFC header afxres.h

VS 2015 RC ships without afxres.h, so fpdfsdkdll.rc fails to
compile. afxres.h is really intended for MFC apps so depending on
it is a bad idea anyway, so I changed both references to
windows.h. See http://stackoverflow.com/questions/1575559 for
some other perspective on this.

R=tsepez@chromium.org
BUG=440500

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

4 years agoConsider platform-specific expected .png files.
Tom Sepez [Thu, 9 Apr 2015 19:35:01 +0000]
Consider platform-specific expected .png files.

Rolls DEPS to pull in the first windows-specific .png files, and
unsupresses the corresponding tests.

R=thestig@chromium.org

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

4 years agoFix a global buffer overflow in GCPDF_CIDFont::_CharCodeFromUnicode
Jun Fang [Thu, 9 Apr 2015 16:59:41 +0000]
Fix a global buffer overflow in GCPDF_CIDFont::_CharCodeFromUnicode

There is not a code page (CP) used for converting unicode to mutli-bytes
if the coding scheme is CID coding. Only return 0 if CID can't be retrieved.
The difference on Windows and other platforms should be the function used
for converting rather than others.

BUG=466790
R=tsepez@chromium.org

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

4 years agoFix reference to timezone variable - removed in VS 2015
Bruce Dawson [Thu, 9 Apr 2015 16:36:34 +0000]
Fix reference to timezone variable - removed in VS 2015

It turns out that 'timezone' has been deprecated for a while. If
deprecation messages are enabled then VS 2013 says this when 'timezone'
is referenced:

warning C4996: 'timezone': This function or variable may be unsafe.
Consider using _get_timezone instead.

Sometimes features stay deprecated for decades, but in this case
'timezone' is now gone.

R=tsepez@chromium.org
BUG=440500

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

4 years agoFix IWYU in formfiller/ directory.
Tom Sepez [Wed, 8 Apr 2015 23:08:00 +0000]
Fix IWYU in formfiller/ directory.

R=thestig@chromium.org

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

4 years agoUse pdfium-specific tree closer for gating landings
Tom Sepez [Wed, 8 Apr 2015 16:01:00 +0000]
Use pdfium-specific tree closer for gating landings

R=jam@chromium.org

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

4 years agoFix a stack overflow issue caused by an invalid usage of snprintf
Jun Fang [Tue, 7 Apr 2015 23:59:05 +0000]
Fix a stack overflow issue caused by an invalid usage of snprintf

BUG=469244
R=tsepez@chromium.org

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

4 years agoLand on master: FFL_MIN and FFL_MAX are pointless and stupid.
Tom Sepez [Tue, 7 Apr 2015 23:58:02 +0000]
Land on master: FFL_MIN and FFL_MAX are pointless and stupid.

Original CL was accidentally based off of XFA.  This CL is
off of master.

TBR=thestig@chromium.org

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

4 years agoFix windows compile class vs. struct confusion in e300c8c32d73
Tom Sepez [Tue, 7 Apr 2015 23:05:12 +0000]
Fix windows compile class vs. struct confusion in e300c8c32d73

TBR=thestig@chromium.org

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

4 years agoFix IWYU in pdfwindow/ directory.
Tom Sepez [Tue, 7 Apr 2015 22:53:50 +0000]
Fix IWYU in pdfwindow/ directory.

This also fixes some IWYU in dependent files.
BUG=https://code.google.com/p/pdfium/issues/detail?id=66
R=thestig@chromium.org

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

4 years agoFix (nearly all) IWYU in fpdfskd/include/javascript/ headers.
Tom Sepez [Tue, 7 Apr 2015 22:26:59 +0000]
Fix (nearly all) IWYU in fpdfskd/include/javascript/ headers.

Move some typedefs for v8 types into fxjs_v8.h wrapper to
avoid circular inclusions. Also delete JS_Module.h, as no
other file includes it.

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

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

4 years agofix missing semicolons
JUN FANG [Mon, 6 Apr 2015 20:10:59 +0000]
fix missing semicolons

TBR=tsepez@chromium.org

BUG=N/A

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

4 years agoFix a fatal error due to cloning a global document object
JUN FANG [Mon, 6 Apr 2015 19:39:51 +0000]
Fix a fatal error due to cloning a global document object

BUG=454595
R=tsepez@chromium.org

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

4 years agoFix IWYU in fxcrt headers.
Tom Sepez [Mon, 6 Apr 2015 19:28:23 +0000]
Fix IWYU in fxcrt headers.

Confirmed manually that:
  g++ --std=c++0x -o /dev/null -I. ... -c fx_xxxxx.h
is now error-free for the files in this directory. Also kill
some ifndef's around inclusion since we know this doesn't
provide benefit with modern compilers.

R=thestig@chromium.org

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

4 years agoUpdate the path of header file to avoid a compiling error in chrome
JUN FANG [Fri, 3 Apr 2015 21:39:18 +0000]
Update the path of header file to avoid a compiling error in chrome

BUG=N/A
R=tsepez@chromium.org

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

4 years agoRefactor PDFium python test utilities.
Tom Sepez [Fri, 3 Apr 2015 20:21:53 +0000]
Refactor PDFium python test utilities.

Extract a common portions for determining suppressions and comparing pngs.

R=thestig@chromium.org

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

4 years agoNo-op change to poke the bots after being out of sequence.
Tom Sepez [Fri, 3 Apr 2015 19:59:41 +0000]
No-op change to poke the bots after being out of sequence.

Adds a comment and changes some whitespace.
TBR=jun_fang@foxitsoftware.com

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