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

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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>.

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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/

4 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.

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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.

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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.

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 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 .

4 years agoRemove some abstractions in fxjs_v8.h.
Tom Sepez [Thu, 10 Sep 2015 18:56:37 +0000]
Remove some abstractions in fxjs_v8.h.

It's too hard to keep mapping between v8 and fx abstractions; the lack
of transparency prevents those skilled in v8 only from working on this
code.

Apparently, the original intention was to confine v8 types to
fpdfsdk/{include,src}/jsapi, but fpdfsdk/{include,src}/javascript
is already well-polluted with v8 types.

Also remove no-op JS_SetThisObj().

Also remove unused ParserParams() [noticed because it was incorrectly
passing handles as pointers].

Also remove cast operator from CJS_Runtime and call GetIsolate()
explicitly.

R=thestig@chromium.org

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

4 years agoFix JS_GetArrayElement to not return an empty handle on success
Jochen Eisinger [Thu, 10 Sep 2015 11:44:04 +0000]
Fix JS_GetArrayElement to not return an empty handle on success

BUG=chromium:528376
R=ulan@chromium.org, tsepez@chromium.org

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

4 years agoResolve bad cast to CJS_EventHandler
foxit [Thu, 10 Sep 2015 06:57:54 +0000]
Resolve bad cast to CJS_EventHandler

At line 2026 in pdfsdk/src/javascript/PublicMethods.cpp,
the writer wants to perform type cast like line 2027 but
he made a mistake to make type conversion on m_pValue.
Even at line 2027, it's redundant to make type conversion.
The returned type of pContext->GetEventHandler() is
CJS_EventHandler*.

BUG=529310
R=tsepez@chromium.org

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

4 years agoRemove existing generated images before running a test.
Lei Zhang [Wed, 9 Sep 2015 19:49:19 +0000]
Remove existing generated images before running a test.

R=tsepez@chromium.org

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

4 years agoFix heap use after free in CPDFSDK_Annot::GetPDFAnnot.
Tom Sepez [Wed, 9 Sep 2015 16:58:10 +0000]
Fix heap use after free in CPDFSDK_Annot::GetPDFAnnot.

Use two seperate loops to kill current focus annot and to release annots
in current page. Loop to kill current focus annot is run first, so it
will not access deleted annots.

BUG=507316

R=tsepez@chromium.org

TEST=Reproduction steps mentioned in issue 507316 should not crash
     chrome.
     Unit test added to pdfium.
     Run pdfium_embeddertests.exe.

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

4 years agoTest files for issue 507316
Tom Sepez [Wed, 9 Sep 2015 16:53:32 +0000]
Test files for issue 507316
Upload pdf test files for codereview 1312313006.

BUG=507316
R=tsepez@chromium.org

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

4 years agoBeef up app_props.in and tidy app.cpp.
Tom Sepez [Tue, 8 Sep 2015 23:23:39 +0000]
Beef up app_props.in and tidy app.cpp.

Some of the values returned are dubious; capture the
current state of affairs.

R=thestig@chromium.org

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

4 years agoChange the JS app.viewerType() return value to "pdfium"
Lei Zhang [Tue, 8 Sep 2015 22:17:51 +0000]
Change the JS app.viewerType() return value to "pdfium"

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

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

4 years agoRemove unneeded checks for CPDF_Object::GetDict() return values.
Lei Zhang [Tue, 8 Sep 2015 17:17:25 +0000]
Remove unneeded checks for CPDF_Object::GetDict() return values.

CPDF_Object::GetDict() always returns a valid pointer for dictionaries.

R=tsepez@chromium.org

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

4 years agoFix typos, nits and remove dead code in fpdf_text_int.cpp.
Lei Zhang [Fri, 4 Sep 2015 21:11:03 +0000]
Fix typos, nits and remove dead code in fpdf_text_int.cpp.

R=tsepez@chromium.org

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

4 years agoRemove CJBig2_Module::JBig2_Error and friends.
Lei Zhang [Fri, 4 Sep 2015 01:00:27 +0000]
Remove CJBig2_Module::JBig2_Error and friends.

R=tsepez@chromium.org

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

4 years agoMake a bunch of JBig2 classes independent of CJBig2_Object.
Lei Zhang [Thu, 3 Sep 2015 23:03:42 +0000]
Make a bunch of JBig2 classes independent of CJBig2_Object.

R=tsepez@chromium.org

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

4 years agoTurn a failing assert into an actual check.
Lei Zhang [Thu, 3 Sep 2015 21:13:19 +0000]
Turn a failing assert into an actual check.

BUG=522131
R=tsepez@chromium.org

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

4 years agoChange fixup_pdf_template.py to open files in binary mode.
Lei Zhang [Wed, 2 Sep 2015 23:31:33 +0000]
Change fixup_pdf_template.py to open files in binary mode.

Fix for the pixel test failure on Windows from commit 870b5b6793fa.
Seems to work for me on Windows.

TBR=tsepez@chromium.org

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