pdfium.git
3 years agoAllow compiling PDFium without V8.
Tom Sepez [Fri, 9 Oct 2015 19:45:15 +0000]
Allow compiling PDFium without V8.

Original patch from issue 1391843004 at patchset 1
(http://crrev.com/1391843004#ps1)

Introduce a pdf_enable_v8 GYP variable, which controls a
corresponding PDF_ENABLE_V8 #define, and bring in the real
JS library when set. Otherwise, link against a stub JS
runtime.

BUG=pdfium:211
R=dml@google.com, jochen@chromium.org, thestig@chromium.org

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

3 years agoFix a bad refactoring error from commit 8a9ce57.
Lei Zhang [Fri, 9 Oct 2015 17:04:37 +0000]
Fix a bad refactoring error from commit 8a9ce57.

BUG=541323
R=tsepez@chromium.org

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

3 years agoFix a compiling error on Mac
Jun Fang [Fri, 9 Oct 2015 05:40:38 +0000]
Fix a compiling error on Mac

BUG=497357

TBR=tsepez@chromium.org

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

3 years agoFix heap-buffer-overflow in color_sycc_to_rgb
Jun Fang [Fri, 9 Oct 2015 05:14:54 +0000]
Fix heap-buffer-overflow in color_sycc_to_rgb

It's a bug existing in the conversion from YUV420 to RGB.
For YUV 420 format, four pixels have 4 Y but only one U and
one V. In some cases, there are odd columns or lines in
some images. The pixels on last line or column may have Y
but no U or V data. For this case, We shall extend U or V
using the data on previous column or line.

BUG=497357
R=tsepez@chromium.org

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

3 years agoMinimal revert from commit d03ba8d.
Lei Zhang [Thu, 8 Oct 2015 23:45:13 +0000]
Minimal revert from commit d03ba8d.

The values that were changed to size_t can go negative.

TBR=tsepez@chromium.org

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

3 years agoFix a bunch of sign mismatch warnings.
Lei Zhang [Thu, 8 Oct 2015 22:51:29 +0000]
Fix a bunch of sign mismatch warnings.

Also remove some gotos and move code into an anonymous namespace.

R=tsepez@chromium.org

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

3 years agoFix a malloc/delete mismatch introduced in commit 8a9ce57.
Lei Zhang [Thu, 8 Oct 2015 22:27:28 +0000]
Fix a malloc/delete mismatch introduced in commit 8a9ce57.

Just get rid of the malloc altogether and use CJBig2_List instead.

BUG=540873
R=tsepez@chromium.org

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

3 years agoVarious changes to JBig2 cache:
David Lattimore [Thu, 8 Oct 2015 21:18:20 +0000]
Various changes to JBig2 cache:
- Makes the cache be per-document
- Keys the cache on ObjNum and stream offset instead of keying on a pointer to the data (which can result in false cache hits).
- Makes it so the cache is only used for the globals stream.
- Reenable the cache.

R=thestig@chromium.org

BUG=pdfium:207

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

3 years agoPut CJBig2_SymbolDict's images in a CJBig2_List container.
Lei Zhang [Thu, 8 Oct 2015 19:13:10 +0000]
Put CJBig2_SymbolDict's images in a CJBig2_List container.

Also mark it private.

R=tsepez@chromium.org

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

3 years agoWean CJS_Value off of v8::Isolate.
Tom Sepez [Thu, 8 Oct 2015 19:04:40 +0000]
Wean CJS_Value off of v8::Isolate.

CJS_Values should belong to CJS_Runtimes so that we may
eventually cram much of the v8 dependencies down into fxjs.

This is a first step; the remaining split in this code between
isolate and CJS_Runtime goes away when fxjs provides a CFXJS_Runtime
object, and the CJS_Runtime is-a/has-a CFXJS_Runtime. But that can't
happen until this is resolved.

R=thestig@chromium.org

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

3 years agoRelax the check on 0 length streams.
Lei Zhang [Thu, 8 Oct 2015 17:34:28 +0000]
Relax the check on 0 length streams.

CPDF_SyntaxParser::ReadStream() originally created stream objects when
the length is 0. Commit 2526930 tightened the constraint and returned
NULL. This has some adverse affects, as seen in Chromium's print
preview of PDFs.

Instead, relax the constraint a little so when the length is 0, return a
CPDF_Stream with NULL data and size 0.

BUG=531835

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

3 years agoRemove some dead code from CCodec_Jbig2Module. Variable was only ever set to false.
David Lattimore [Wed, 7 Oct 2015 23:13:44 +0000]
Remove some dead code from CCodec_Jbig2Module. Variable was only ever set to false.

R=thestig@chromium.org

BUG=

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

3 years agoRename IFXJS_Runtime and IFXJS_Context to IJS_.
Tom Sepez [Wed, 7 Oct 2015 19:52:13 +0000]
Rename IFXJS_Runtime and IFXJS_Context to IJS_.

Nothing but sed.

FXJS is a layer that makes it easier to define objects in V8, but has
no knowledge of PDF-specific native objects.  It could in theory be used
to implement other sets of native objects.

JS is the layer that implements PDF-specific native objects on top of
FXJS.

Therefore, the classes used to interface to JS should be named using
IJS_. IFXJS_ is reserved for someday adding better API for FXJS iteslf.

R=thestig@chromium.org

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

3 years agoUpdate README.md to reflect added .png support
Tom Sepez [Wed, 7 Oct 2015 19:33:31 +0000]
Update README.md to reflect added .png support

R=thestig@chromium.org

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

3 years agoStop inlining CJBig2_BitStream.
Lei Zhang [Wed, 7 Oct 2015 18:12:06 +0000]
Stop inlining CJBig2_BitStream.

R=tsepez@chromium.org

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

3 years agoFix the Windows build after commit 8a9ce57.
Lei Zhang [Wed, 7 Oct 2015 17:44:43 +0000]
Fix the Windows build after commit 8a9ce57.

TBR=tsepez@chromium.org

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

3 years agoRemove gotos in JBig2 code.
Lei Zhang [Wed, 7 Oct 2015 17:37:07 +0000]
Remove gotos in JBig2 code.

R=tsepez@chromium.org

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

3 years agoMove build instructions to README.md
Jochen Eisinger [Wed, 7 Oct 2015 09:20:58 +0000]
Move build instructions to README.md

That way, they'll be automatically displayed on gitiles

BUG=
R=andybons@chromium.org, tsepez@chromium.org

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

3 years agoRoll DEPS for v8 to 9081ee1.
Lei Zhang [Tue, 6 Oct 2015 22:44:31 +0000]
Roll DEPS for v8 to 9081ee1.

TBR=tsepez@chromium.org

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

3 years agoFix include paths for fx_system.h
David Lattimore [Tue, 6 Oct 2015 22:20:13 +0000]
Fix include paths for fx_system.h

R=thestig@chromium.org

BUG=

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

3 years agoRemove unused global argument from FXJS_CONSTRUCTOR.
Tom Sepez [Tue, 6 Oct 2015 18:47:51 +0000]
Remove unused global argument from FXJS_CONSTRUCTOR.

R=thestig@chromium.org

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

3 years agoStore object definition ID in each js_class.
Tom Sepez [Tue, 6 Oct 2015 18:10:52 +0000]
Store object definition ID in each js_class.

Avoids doing a lookup via FXJS_V8 for something already
known in CJS layer.

Also:
Consolidate repeated code in JS macros.
Remove knowledge that Document is global from FXJS layer

R=thestig@chromium.org

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

3 years agoRun FXJS_V8 embedder tests against a shared isolate.
Tom Sepez [Tue, 6 Oct 2015 15:53:13 +0000]
Run FXJS_V8 embedder tests against a shared isolate.

Start to back-fill some tests for the recent isolate work.

R=thestig@chromium.org

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

3 years agoMake the vast majority of JS headers private to src/javascript.
Tom Sepez [Tue, 6 Oct 2015 14:50:47 +0000]
Make the vast majority of JS headers private to src/javascript.

The fpdfsdk/include/javascript/IJavascript.h is the sole API.
This required moving a creaton method to it from JS_Runtime.

R=thestig@chromium.org

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

3 years agoFix regression in JBIG2 decoding from commit ce37d73.
Lei Zhang [Tue, 6 Oct 2015 06:02:25 +0000]
Fix regression in JBIG2 decoding from commit ce37d73.

many callers can tolerate CJBig2_ArithIntDecoder::decode() OOB failure.

BUG=539749, pdfium:209
R=tsepez@chromium.org

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

3 years agoRemove JavaScript.h
Tom Sepez [Mon, 5 Oct 2015 23:18:28 +0000]
Remove JavaScript.h

It merely includes a bunch of other .h files which are handled
better since we fixed IWYU.

R=thestig@chromium.org

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

3 years agoOriginal patch by forshaw.
Tom Sepez [Mon, 5 Oct 2015 19:57:17 +0000]
Original patch by forshaw.

Added a fallback Win32 font information class for win32k lockdown.
This is to support running PDFIUM within the Win32k lockdown by
removing dependancies on USER32/GDI for the font information code.
It falls back to using a freetype/directory enumeration implementation
if it detects the win32k system calls have been disabled by policy.

BUG=523278
R=tsepez@chromium.org

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

3 years agoDisable JBIG2 cache; prevent data corruption - try 2.
Lei Zhang [Mon, 5 Oct 2015 17:16:20 +0000]
Disable JBIG2 cache; prevent data corruption - try 2.

Also change CJBig2_SymbolDict::DeepCopy() to return a unique_ptr to
prevent a potential leak if the cache size was 0.

BUG=pdfium:207
R=tsepez@chromium.org, jbreiden@google.com

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

3 years agoFix a leak with g_DefaultGlobalObjectTemplate.
Lei Zhang [Mon, 5 Oct 2015 03:42:33 +0000]
Fix a leak with g_DefaultGlobalObjectTemplate.

As seen when running FXJSV8Embeddertest.Getters.

R=tsepez@chromium.org

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

3 years agoRemove pointless CPDFSDK_PageView usage in CJS_Object / CJS_EmbedObj.
Lei Zhang [Mon, 5 Oct 2015 03:41:53 +0000]
Remove pointless CPDFSDK_PageView usage in CJS_Object / CJS_EmbedObj.

R=tsepez@chromium.org

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

3 years agoOnly call DefineJSObjects() once for the global V8 isolate.
Lei Zhang [Mon, 5 Oct 2015 03:40:15 +0000]
Only call DefineJSObjects() once for the global V8 isolate.

BUG=539106
R=tsepez@chromium.org

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

3 years agoCJS_Timer should observe CJS_Runtime destruction.
Lei Zhang [Sun, 4 Oct 2015 23:01:52 +0000]
CJS_Timer should observe CJS_Runtime destruction.

Also remove dead CJS_EmbedObj::{Begin,End}Timer code.

BUG=539107
R=tsepez@chromium.org

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

3 years agoFix NULL pointer dereference in CPDF_InterForm.
Lei Zhang [Sat, 3 Oct 2015 17:06:25 +0000]
Fix NULL pointer dereference in CPDF_InterForm.

BUG=537772
R=tsepez@chromium.org

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

3 years agoRefcount external V8 isolate initialization / release.
Lei Zhang [Sat, 3 Oct 2015 17:00:24 +0000]
Refcount external V8 isolate initialization / release.

BUG=531339
R=tsepez@chromium.org

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

3 years agoPass v8::Isolate to PDFium at init time.
Tom Sepez [Fri, 2 Oct 2015 23:43:15 +0000]
Pass v8::Isolate to PDFium at init time.

Move the external isolate and embedder slot from the
IPDF_JSPlatforms struct supplied at the
FPDFDOC_InitFormFillEnvironment() call time to arguments to
the FPDF_InitLibraryWithConfig() call.

This has several benefits:
-- Avoids the crash that could happen if multiple
FPDFDOC_InitFormFillEnvironmen() calls should happen to be
made by an embedder with different slot values.
-- Down the road, for XFA, there may be XFA but no FormFill
environment.

We support both forms for the time being, until the chrome
side catches up, at which point we will deprecate the old
way.

R=thestig@chromium.org

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

3 years agoDo not call into formfiller code with a NULL PageView.
Lei Zhang [Fri, 2 Oct 2015 21:01:37 +0000]
Do not call into formfiller code with a NULL PageView.

BUG=537173
R=jun_fang@foxitsoftware.com, tsepez@chromium.org

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

3 years agoGet rid of gotos in CPDF_SyntaxParser and FlateUncompress().
Lei Zhang [Fri, 2 Oct 2015 18:26:58 +0000]
Get rid of gotos in CPDF_SyntaxParser and FlateUncompress().

R=tsepez@chromium.org

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

3 years agoPrevent divide by zeros in CJBig2_GSIDProc::decode_MMR().
Lei Zhang [Fri, 2 Oct 2015 17:58:42 +0000]
Prevent divide by zeros in CJBig2_GSIDProc::decode_MMR().

Check the image size before attempting to decode.

BUG=538103
R=tsepez@chromium.org

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

3 years agoFix a leak in PDF_DataDecode() on failure.
Lei Zhang [Fri, 2 Oct 2015 17:56:30 +0000]
Fix a leak in PDF_DataDecode() on failure.

Found using the test examples from https://crbug.com/537780

R=tsepez@chromium.org

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

3 years agoTurn a couple functions that always return true to return void.
Lei Zhang [Fri, 2 Oct 2015 17:29:50 +0000]
Turn a couple functions that always return true to return void.

R=tsepez@chromium.org

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

3 years agoFix PNG decoding divide by zero error due to zero row count.
Lei Zhang [Fri, 2 Oct 2015 17:27:44 +0000]
Fix PNG decoding divide by zero error due to zero row count.

BUG=537790
R=tsepez@chromium.org

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

3 years agoCorrect mistakes in test case for 507316
Tom Sepez [Fri, 2 Oct 2015 16:05:53 +0000]
Correct mistakes in test case for 507316

Original patch by chamalsl.

Trailer size in bug_507316 was wrong.

embedder_test.cpp's GetPageTrampoline passed null parameter.
It will affect future test cases even if it does not affect
this.

BUG=507316
R=tsepez@chromium.org

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

3 years agoFix static initializer in fxjs_v8.cpp
Tom Sepez [Fri, 2 Oct 2015 00:40:14 +0000]
Fix static initializer in fxjs_v8.cpp

R=thestig@chromium.org

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

3 years agoDisable JBIG2 cache; prevent data corruption
Lei Zhang [Thu, 1 Oct 2015 22:12:49 +0000]
Disable JBIG2 cache; prevent data corruption

BUG=pdfium:207

Original author: jbreiden@google.com
Original CL: http://codereview.chromium.org/1362133003/

R=jbreiden@google.com

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

3 years agoClean up some image decoder classes:
Lei Zhang [Thu, 1 Oct 2015 20:49:28 +0000]
Clean up some image decoder classes:

- Use std::vector<uint8_t> instead of raw uint8_t*
- Make ICodec_ScanlineDecoder::GetScanline() return const uint8_t*
- Add FxFreeDeleter, use it in CCodec_ImageDataCache.
- Make CCodec_ImageDataCache encapsulate its data members.

R=tsepez@chromium.org

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

3 years agoCleanup JBig2_ArithIntDecoder.
Lei Zhang [Thu, 1 Oct 2015 20:16:29 +0000]
Cleanup JBig2_ArithIntDecoder.

R=tsepez@chromium.org

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

3 years agoRevert "Leak per-isolate data in pdfium"
Raymes Khoury [Thu, 1 Oct 2015 05:12:08 +0000]
Revert "Leak per-isolate data in pdfium"

This reverts commit 3e144b8c23d7c52ed36329e87f0cb01f38ec1ed7.

This may be causing the failures seen in crbug.com/537799.

BUG=537799

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

3 years agoAdd signatures to FXJS_V8.
Tom Sepez [Wed, 30 Sep 2015 22:39:57 +0000]
Add signatures to FXJS_V8.

BUG=chromium:529012
R=jochen@chromium.org, krasin@google.com

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

3 years agoLeak per-isolate data in pdfium
Raymes Khoury [Wed, 30 Sep 2015 09:46:41 +0000]
Leak per-isolate data in pdfium

Right now we're freeing per-isolate data everytime a document is destroyed even
though it may be in use by other documents. For now we leak the per-isolate
data until crbug.com/531339 is fixed.

BUG=531339
R=jochen@chromium.org

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

Patch from Raymes Khoury <raymes@chromium.org>.

3 years agoCleanup CJBig2_ArithDecoder.
Lei Zhang [Wed, 30 Sep 2015 04:14:58 +0000]
Cleanup CJBig2_ArithDecoder.

R=tsepez@chromium.org

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

3 years agoRoll DEPS for v8 to d7f813b.
Lei Zhang [Tue, 29 Sep 2015 22:28:43 +0000]
Roll DEPS for v8 to d7f813b.

TBR=tsepez@chromium.org

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

3 years agoRefactor some common code for bounding boxes.
Lei Zhang [Tue, 29 Sep 2015 21:34:22 +0000]
Refactor some common code for bounding boxes.

R=tsepez@chromium.org

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

3 years agoFix blank page issue caused by too strict correction on bpc
Jun Fang [Tue, 29 Sep 2015 02:24:54 +0000]
Fix blank page issue caused by too strict correction on bpc

For bit per component (bpc), PDF spec mentions that a RunLengthDecode or DCTDecode filter shall always deliver 8-bit samples. However, some PDF files don't follow this rule. We can find that filter is RunLengthDecode but bpc is 1 in the provided test file. In this case, pdfium will correct bpc to 8 but the actual bpc is 1. It causes a failure because the data is much more than the expected. To handle this case, pdfium doesn't correct bpc to 8 when the original bpc is 1.

BUG=512557
R=tsepez@chromium.org

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

3 years agoCleanup some fx_codec_fax.cpp code.
Lei Zhang [Mon, 28 Sep 2015 18:52:19 +0000]
Cleanup some fx_codec_fax.cpp code.

R=tsepez@chromium.org

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

3 years agoFix test diff caused by v8 version update
Tom Sepez [Mon, 28 Sep 2015 17:20:16 +0000]
Fix test diff caused by v8 version update

Also changes DEPS to specify a specific v8 version, this will
require us to manually update this version from time to time,
but also solves a longstanding problem where going back to an
older version (say for bisecting) wouldn't always work.

R=thestig@chromium.org

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

3 years agoIntroduce kPerIsolateDataIndex and tidy JS_Define.h
Tom Sepez [Mon, 28 Sep 2015 16:44:56 +0000]
Introduce kPerIsolateDataIndex and tidy JS_Define.h

Follow-up from https://codereview.chromium.org/1366053003/

- use kPerIsolateDataIndex rather than magic constant 1.
- make a helper function for common code in JS_Define.h
- remove dead prototypes missed in earlier CL.
- fxjs_v8 can't include generic fpdfsdk includes (layering).

R=jochen@chromium.org

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

3 years agoAdd Mac-specific pixel test expectations.
Lei Zhang [Sat, 26 Sep 2015 05:18:23 +0000]
Add Mac-specific pixel test expectations.

The font is slightly different from Linux/Windows.

BUG=524043
R=jun_fang@foxitsoftware.com

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

3 years agoRevert "Revert "Fix the issue that pdfium swallows 'fi' or 'ff' in some pdf files""
Jun Fang [Sat, 26 Sep 2015 05:03:26 +0000]
Revert "Revert "Fix the issue that pdfium swallows 'fi' or 'ff' in some pdf files""

This reverts commit fa9756f77ad6145940d3dc697814b84f5755ae17.

TBR=thestig@chromium.org
Review URL: https://codereview.chromium.org/1307353005/

3 years agoRevert "Fix the issue that pdfium swallows 'fi' or 'ff' in some pdf files"
Jun Fang [Sat, 26 Sep 2015 04:12:51 +0000]
Revert "Fix the issue that pdfium swallows 'fi' or 'ff' in some pdf files"

This reverts commit 9bd18183ba8210c91d71c3060146235750a4c71c.

3 years agoFix the issue that pdfium swallows 'fi' or 'ff' in some pdf files
Jun Fang [Sat, 26 Sep 2015 03:32:46 +0000]
Fix the issue that pdfium swallows 'fi' or 'ff' in some pdf files

Pdfium swallows 'fi' or 'ff' in some tested files because it doesn't load the embedded font file correctly. The root cause is that there is incorrect keyword like 'ngendstream' in the stream of the embedded font file. Pdfium tries to find another correct keyword but uses wrong offset rather than accumulated offset.

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

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

3 years agoRevert "Revert "Merge to master: contention over isolate data slots""
Tom Sepez [Fri, 25 Sep 2015 16:29:47 +0000]
Revert "Revert "Merge to master: contention over isolate data slots""

This reverts commit 3b4382a847b5a7439a3107512dbe54c317108579.
The difference between this CL and the one that failed is
fxjs_v8.cpp:271. In master, we pass the runtime information
as:
  v8::isolate -> v8::Context -> FXJS Runtime,

but in XFA:
  V8::Isolate -> PerIsolate struct -> FXJS Runtime.

The master way is more correct, in that FXJS_Runtime is 1:1
with v8 contexts and many:1 (in theory) with isolates.
It looks like the XFA branch missed a patch along the way.
I'll do that next.

Having made this change, the only data in the per-isolate
struct will be the ptr array (on master); it will also
include the XFA context (on XFA). I've kept the struct on
master for the sake of similarity.

R=thestig@chromium.org

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

3 years agoFix a leak in CJBig2_Context.
Lei Zhang [Thu, 24 Sep 2015 19:56:29 +0000]
Fix a leak in CJBig2_Context.

- Remove dead code
- Use unique_ptr

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

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

3 years agoSplit up JBig2_GeneralDecoder.cpp.
Lei Zhang [Thu, 24 Sep 2015 08:09:57 +0000]
Split up JBig2_GeneralDecoder.cpp.

R=tsepez@chromium.org

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

3 years agoFix a leak in CJBig2_CachePair.
Lei Zhang [Wed, 23 Sep 2015 23:50:51 +0000]
Fix a leak in CJBig2_CachePair.

R=jbreiden@google.com

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

3 years agoFlip conditionals to positive logic in pdfium_test.
Lei Zhang [Wed, 23 Sep 2015 22:10:05 +0000]
Flip conditionals to positive logic in pdfium_test.

Also merge a check for failed document loads from XFA.

R=tsepez@chromium.org

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

3 years agoFix a couple potential file handle leaks in pdfium_test.
Lei Zhang [Wed, 23 Sep 2015 21:26:51 +0000]
Fix a couple potential file handle leaks in pdfium_test.

Fix lint issues / git cl format.

R=tsepez@chromium.org

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

3 years agoChange nonstd::unique_ptr to take a custom deleter.
Lei Zhang [Wed, 23 Sep 2015 02:15:49 +0000]
Change nonstd::unique_ptr to take a custom deleter.

Code is mostly stolen from Chromium's scoped_ptr.

- Add unit tests.
- Use this to fix a leak.

BUG=chromium:531408
R=jyasskin@chromium.org, tsepez@chromium.org

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

3 years agoRevert "Merge to master: contention over isolate data slots"
Tom Sepez [Tue, 22 Sep 2015 22:54:26 +0000]
Revert "Merge to master: contention over isolate data slots"

Reason for revert: embeddertests failed.
This reverts commit 70bc04b16646c92f221c5aa56831b01d6ec7c1ca.

TBR=thestig@chromium.org

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

3 years agoMerge to master: contention over isolate data slots
Tom Sepez [Tue, 22 Sep 2015 22:49:14 +0000]
Merge to master: contention over isolate data slots

Work on this was first performed on the XFA branch, since
it has additional requirements (FXJSE layer) that needed
to be accomodated by the solution.

(cherry picked from commit ed7b2b50aa1744e0bc5a60bef12c61fa91d863b7)
Original Review URL: https://codereview.chromium.org/1351173002 .

R=thestig@chromium.org

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

3 years agoUse std::set<> to track active event handlers.
Tom Sepez [Tue, 22 Sep 2015 22:39:15 +0000]
Use std::set<> to track active event handlers.

This avoids some custom linked-list code. Also note that
we use a local copy to be sure we removed the same thing
that was added no matter how our callees may muck with the
handler.

R=thestig@chromium.org

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

3 years agoAdd nonstd::unique_ptr move assigment operator.
Tom Sepez [Tue, 22 Sep 2015 22:06:59 +0000]
Add nonstd::unique_ptr move assigment operator.

std::unique_ptr supports move assignment as in:
  ptr2 = std::move(ptr1);

R=jyasskin@chromium.org

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

3 years agoAdd missing 'return' keyword.
Lei Zhang [Tue, 22 Sep 2015 20:45:00 +0000]
Add missing 'return' keyword.

Discovered with experimental Clang plugin that flags temporary objects
that are immediately destroyed.

patch from issue 1359063003 at patchset 1 (http://crrev.com/1359063003#ps1)

A=mdempsky@chromium.org
R=mdempsky@chromium.org

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

3 years ago[Docs] Add wiki content to Markdown docs
Tom Sepez [Tue, 22 Sep 2015 15:50:20 +0000]
[Docs] Add wiki content to Markdown docs

BUG=none
R=tsepez@chromium.org, jam@chromium.org, thestig@chromium.org

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

3 years agoRemove CJS_RuntimeFactory
Tom Sepez [Mon, 21 Sep 2015 23:29:20 +0000]
Remove CJS_RuntimeFactory

The Factory Design Pattern isn't buying us anything here over just new'ing
the object we want.

R=thestig@chromium.org

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

3 years agoMore tidy of CJS_Object, kill implicit cast operator
Tom Sepez [Mon, 21 Sep 2015 16:01:56 +0000]
More tidy of CJS_Object, kill implicit cast operator

R=thestig@chromium.org

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

3 years agoDon't pass null isolates to FXJS_ when we have a real isolate.
Tom Sepez [Thu, 17 Sep 2015 22:30:14 +0000]
Don't pass null isolates to FXJS_ when we have a real isolate.

Kill some now unused functions as a result.

R=thestig@chromium.org

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

3 years agoFix a #include in fpdf_page_func.cpp.
David Lattimore [Thu, 17 Sep 2015 21:39:39 +0000]
Fix a #include in fpdf_page_func.cpp.

Not sure why building with gyp was working despite the missing '../' but
it wasn't working in stricter build systems.

BUG=
R=thestig@chromium.org

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

3 years agoRemove several dead functions from fxjs_v8.{cpp,h}.
Tom Sepez [Wed, 16 Sep 2015 22:16:42 +0000]
Remove several dead functions from fxjs_v8.{cpp,h}.

Re-arrange things in the header so function overloads are
next to each other, and related things are near each other.

R=thestig@chromium.org

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

3 years agoMake pdfium_embeddertests link in debug component builds.
Nico Weber [Wed, 16 Sep 2015 20:53:42 +0000]
Make pdfium_embeddertests link in debug component builds.

Target v8 has:

          'direct_dependent_settings': {
            'defines': [
              'V8_SHARED',
              'USING_V8_SHARED',
            ],
          },

For this to work, targets using v8 headers have to depend on v8
directly, else the V8_EXPORT macro won't work. Add a direct
dependency on v8.

BUG=none
TEST=do a debug component build of pdfium_embeddertests on Win,
should work without linker errors

R=tsepez@chromium.org

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

3 years agoFix build broken at 506df426d5d6.
Tom Sepez [Wed, 16 Sep 2015 18:00:38 +0000]
Fix build broken at 506df426d5d6.

Move header file includes when usage moved.
Windows-only section missing a ")".

TBR=thestig@chromium.org

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

3 years agoEnsure functions in FXJS_V8 are prefixed by FXJS_.
Tom Sepez [Wed, 16 Sep 2015 17:42:08 +0000]
Ensure functions in FXJS_V8 are prefixed by FXJS_.

Currently, its hard to tell which functions come from the JS_
layer at fpdfsdk/include/javascript vs. which functions come
from the FXJS_V8 layer at fpdfsdk/include/jsapi.  Until we
take up the task of using namespaces, at least make the
prefix consistent.

Move objects out of FXJS_V8 that are really part of JS_.

R=thestig@chromium.org

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

3 years agoCheck for empty embedder data before using it in PDFium JS bindings.
Tom Sepez [Tue, 15 Sep 2015 22:42:25 +0000]
Check for empty embedder data before using it in PDFium JS bindings.

This was guarded by an assert, but the path is hit.

BUG=528015
R=thestig@chromium.org

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

3 years agogyp_pdfium should use ninja by default.
Lei Zhang [Tue, 15 Sep 2015 22:41:25 +0000]
gyp_pdfium should use ninja by default.

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

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

3 years agoFix typo from commit a9d4bc5. (Autocomplete fail)
Lei Zhang [Tue, 15 Sep 2015 22:28:58 +0000]
Fix typo from commit a9d4bc5. (Autocomplete fail)

TBR=tsepez@chromium.org

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

3 years agoFix build on Windows after commit 0b3c8f7.
Lei Zhang [Tue, 15 Sep 2015 22:13:18 +0000]
Fix build on Windows after commit 0b3c8f7.

MSVS can't figure out the value of strlen(kConstString) at compile time.

TBR=tsepez@chromium.org

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

3 years agoImplement FPDFAction_GetFilePath().
Lei Zhang [Tue, 15 Sep 2015 21:45:29 +0000]
Implement FPDFAction_GetFilePath().

The API is the same as the Foxit version, except the encoding is
specified as UTF-8 instead of local encoding.

Also remove CPDF_LWinParam since it's unused.

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

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

3 years agoFix build broken at 09ed30750282
Tom Sepez [Tue, 15 Sep 2015 21:14:25 +0000]
Fix build broken at 09ed30750282

Wrong parameter set to nullptr during one of the CL revisions.

TBR=thestig@chromium.org

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

3 years agoRefactor fxjs_v8 and add embeddertests for it.
Tom Sepez [Tue, 15 Sep 2015 21:03:52 +0000]
Refactor fxjs_v8 and add embeddertests for it.

This forces the layer defined by fxjs_v8.h to be (more)
self-contained, so that it can be tested apart from the
CJS_* objects (in fpdfsdk/{src,include}/javascript. This
implies the array buffer allocator must be part of fxjs_v8.

One wrinkle is that we'd like to be able to test an isolate
upon which no native objects have been added, so some
initialization that would have occurred as part of object
definition must be made explicit.

R=thestig@chromium.org

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

3 years agoFix build broken at ac8fda05418b on windows
Tom Sepez [Tue, 15 Sep 2015 17:28:01 +0000]
Fix build broken at ac8fda05418b on windows

|constexpr| not supported on windows.

TBR=thestig@chromium.org

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

3 years agoAdd move ctor to nonstd::unique_ptr.
Tom Sepez [Tue, 15 Sep 2015 17:18:52 +0000]
Add move ctor to nonstd::unique_ptr.

R=jyasskin@chromium.org

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

3 years agoCleanup JBig2_GeneralDecoder.cpp.
Lei Zhang [Tue, 15 Sep 2015 08:12:55 +0000]
Cleanup JBig2_GeneralDecoder.cpp.

- FX_Alloc() can't fail and return.
- Use unique_ptr / remove gotos.
- NULL -> nullptr.
- Combine common code.

R=tsepez@chromium.org

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

3 years agoCleanup: Fix a typo. s/Processive/Processing/
Lei Zhang [Tue, 15 Sep 2015 08:11:58 +0000]
Cleanup: Fix a typo. s/Processive/Processing/

R=tsepez@chromium.org

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

3 years agoAdd a missing #include that's needed for call to FXSYS_tolower.
David Lattimore [Mon, 14 Sep 2015 21:40:12 +0000]
Add a missing #include that's needed for call to FXSYS_tolower.

BUG=
R=thestig@chromium.org

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

3 years agoGet CJS_RuntimeFactory out of the CJS_GlobalData management business.
Tom Sepez [Mon, 14 Sep 2015 21:32:33 +0000]
Get CJS_RuntimeFactory out of the CJS_GlobalData management business.

First part of getting rid of CJS_RuntimeFactory.  The factory design
pattern isn't appropriate here since we only ever make one kind of
object.

CJS_GlobalData is now perfectly capable of managing itself through
internal ref counts. I'm philosophically opposed to keeping ref-counts
outside the object (do you hear me std::shared_ptr, you're bad!)

R=thestig@chromium.org

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

3 years agoConvert some unneeded gotos into returns.
Lei Zhang [Fri, 11 Sep 2015 20:15:02 +0000]
Convert some unneeded gotos into returns.

R=tsepez@chromium.org

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

3 years agoCleanup casting of FX_Alloc() return values.
Lei Zhang [Fri, 11 Sep 2015 20:13:31 +0000]
Cleanup casting of FX_Alloc() return values.

Also convert some FX_AllocOrDie() calls to FX_Alloc().

R=tsepez@chromium.org

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

3 years agoFix strings, remove stringify macros, void return types for Consts.h.
Tom Sepez [Fri, 11 Sep 2015 20:04:48 +0000]
Fix strings, remove stringify macros, void return types for Consts.h.

Replace multiple #defines of the same strings with externs.
Fix strings mangled by interaction of # and clang-format.
Remove macros as possible.
Make more JS_ functions void and simplify.

R=thestig@chromium.org

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

3 years agoRename Init methods to more accurately describe purpose
Tom Sepez [Fri, 11 Sep 2015 15:18:47 +0000]
Rename Init methods to more accurately describe purpose

R=thestig@chromium.org

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

3 years agoGuard against null image data in CJBig2_GRRDProc.
Lei Zhang [Thu, 10 Sep 2015 23:13:31 +0000]
Guard against null image data in CJBig2_GRRDProc.

Credit to karl at skomski.com for the initial version of the CL.

BUG=527174
R=tsepez@chromium.org

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

3 years agoRemove CJBig2_Object, CJBig2_Module, and friends.
Lei Zhang [Thu, 10 Sep 2015 23:12:44 +0000]
Remove CJBig2_Object, CJBig2_Module, and friends.

R=tsepez@chromium.org

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