summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-06-14Merge 3 methods of CJBig2_GRDProc togetherchromium/3465chromium/3464chromium/3463chromium/3462chromium/3461Nicolas Pena
This CL merges 3 methods into a single DecodeArithOpt3(). The code is the same, except for some constants which are extracted out as namespace variables. Change-Id: I6d9127d71b5e7c4c75e31a736b0f3307bb78a076 Reviewed-on: https://pdfium-review.googlesource.com/35170 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-14[formcalc] Calculate length of string when calling FXSYS_wcstofDan Sinclair
When calling the FXSYS_wctof method we currently pass in -1 from AdvanceForNumber. This tells the method to calculate the string length. This can be slow for a formcalc string with a lot of numbers. This CL changes the call to pass in the length of remaining data in the original string. This takes the MSAN runtime of the case in the linked bug from ~21seconds to ~500ms. The debug runtime goes from ~2s to ~500ms. Bug: chromium:846104 Change-Id: Idbd19a728160f35982e21c0d97567fbbeefe667a Reviewed-on: https://pdfium-review.googlesource.com/35210 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-14Move definition of XFA_SCRIPTATTRIBUTEINFO into cjx_object.h.Peter Collingbourne
This allows compilers targeting the MS ABI to select the correct inheritance model for the member function pointer type XFA_ATTRIBUTE_CALLBACK using the complete type of CJX_Object. It will allow us to enable the new Clang flag -fcomplete-member-pointers globally. Bug: chromium:847724 Change-Id: I90cedde8c5355e5eb896a93f0e43e6a1e1d09dbc Reviewed-on: https://pdfium-review.googlesource.com/35190 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-06-14Rewrite content stream regeneration.Henrique Nakashima
Loop through the dirty page objects and streams and regenerate all streams that are dirty. Bug: pdfium:1051 Change-Id: I837b5a7cd9542b7777e7c7ae7ac9cc75f69f30b5 Reviewed-on: https://pdfium-review.googlesource.com/34330 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-14Simplify the calculation of Pages Offsets within CPDF_HintsTable.chromium/3460Artem Strygin
Change-Id: I020fd5ae11b32f753d681e7e0c26b7f95e920bff Reviewed-on: https://pdfium-review.googlesource.com/15812 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-06-13Collapse some more xfa/non-xfa code in cpdfsdk annots.chromium/3459chromium/3458Tom Sepez
cpdfsdk_annot.cpp:315 and cpdfsdk_annot.cpp:338 are nearly identical, except that the #ifdef XFA code passed along the correct type from the argument. Prefer this behaviour even when non-XFA. Change-Id: Id4d5fbcc773ffd10746c4ddc77a571e818e5a957 Reviewed-on: https://pdfium-review.googlesource.com/35030 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-13Mark modified content streams as dirty in CPDF_PageObjectHolder.Henrique Nakashima
Bug: pdfium:1051 Change-Id: Ib3376eea32336437d148f8f9c0017d6b8f9fb556 Reviewed-on: https://pdfium-review.googlesource.com/33770 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-06-13Remove CFX_FixedBufGrow from cpdf_renderstatus.cppNicolas Pena
Bug: pdfium:177 Change-Id: I58fe339d5a0a962215c5cb29c963b37b86832637 Reviewed-on: https://pdfium-review.googlesource.com/35113 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-13Remove CFX_FixedBufGrow from cpdf_colorspace.cppNicolas Pena
Bug: pdfium:177 Change-Id: I92e71fd0f2445736680e1cf9e7cc41bda8e6505e Reviewed-on: https://pdfium-review.googlesource.com/35114 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-06-13Remove almost all usages of CFX_FixedBufGrow from cpdf_dibsource.cppNicolas Pena
This CL removes all the usages of CFX_FixedBufGrow, except for one that would cause performance issues for our corpus tests. Bug: pdfium:177 Change-Id: I0ad76c14f713b116cf7dce50606554e3b03d9f2c Reviewed-on: https://pdfium-review.googlesource.com/35150 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-13Make CJBig2_Context::GetHuffmanTable return constNicolas Pena
This CL changes GetHuffmanTable() to return a const pointer and fixes other members / functions accordingly. Change-Id: Ie62fe044b3156f67885dd4fa1f6512cbd35a83d3 Reviewed-on: https://pdfium-review.googlesource.com/35116 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-06-13Remove CFX_FixedBufGrow from fx_codec_icc.cppNicolas Pena
Bug: pdfium:177 Change-Id: Ib4de4f258ebd98a53b309c30b7e4aa28f0c581eb Reviewed-on: https://pdfium-review.googlesource.com/35112 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-13Merge the offset calculation logic within CPDF_HintsTable.Artem Strygin
Change-Id: If120ee16c53117ae148447e141cbbd8143194b36 Reviewed-on: https://pdfium-review.googlesource.com/15811 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-13Add FPDFText_LoadStandardFont to public APINicolas Pena
Bug: pdfium:978 Change-Id: I0dcffdfd1b19b83e5234da7791cb3f3e52cc257b Reviewed-on: https://pdfium-review.googlesource.com/35110 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-13Remove CFX_FixedBufGrow from fx_apple_platform.cppNicolas Pena
Bug: pdfium:177 Change-Id: I63f2e7579de37f52fd67f02988d72de7e1b3c7ba Reviewed-on: https://pdfium-review.googlesource.com/35111 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-13Guard some non-windows only code in cfx_font with ifdefs.Tom Sepez
The callers are all in blocks controlled by the same ifdef. Change-Id: I2bf1dfd8725eefcfab5b05460fc31b0e7e08c75e Reviewed-on: https://pdfium-review.googlesource.com/35090 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-13Tidy FFLCommon()Tom Sepez
The polymorphic IPDF_Page::GetDocument() allows getting the document without special cases. The subsequent retrieval of the page view via the helper function is equivalent to the inline code in the other branch of the ifdef. Change-Id: I8c7008c18610e11e7dcc4151fa7369cfc3625049 Reviewed-on: https://pdfium-review.googlesource.com/35070 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-13Refactor GetOrCreateDefaultGraphics out of ProcessDefaultGraphics.Henrique Nakashima
GetOrCreateDefaultGraphics() has a side effect, and it needs to be called regardless of whether a stream is generated of not. Failing to do so causes default graphics to not exist in some cases. Bug: pdfium:1051 Change-Id: I039cb6b755cc15c8ca667c92e581d085f3f2a124 Reviewed-on: https://pdfium-review.googlesource.com/35010 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-13CPDFSDK_Widget(): bDisplay arg always passed as true (default).Tom Sepez
So remove it and combine the XFA/non-XFA cases. Change-Id: I13d718de13ec31bf4f5c045164ea5791bf22f92d Reviewed-on: https://pdfium-review.googlesource.com/35050 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-12Refactor modification of Contents in CPDF_PageContentGenerator.Henrique Nakashima
This is a pure refactor, there should be no change in behavior. It prepares for the next CL, which will allow modification of content streams. Bug: pdfium:1051 Change-Id: I01ca3e897efe423e89df75e1f31cd67539cc3d08 Reviewed-on: https://pdfium-review.googlesource.com/34470 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-12Comment some more #else // PDF_ENABLE_XFATom Sepez
This is an anti-pattern when XFA can be configured at runtime. Make it easier to find some more remaining cases. Change-Id: I1ee8d95b2fd52be5e37ef4e859e3e9179ea25975 Reviewed-on: https://pdfium-review.googlesource.com/34990 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-12Fill m_ContentStream field in CPDF_PageObject.Henrique Nakashima
From the comment of CPDF_PageObject::GetContentStream(): """ Get what content stream the object was parsed from in its page. This number is the index of the content stream in the "Contents" array, or 0 if there is a single content stream. If the object is newly created, -1 is returned. If the object is spread among more than one content stream, this is the index of the last one. """ Bug: pdfium:1051 Change-Id: I9f7804af4f263dda0422e9542e025e3320ff7c31 Reviewed-on: https://pdfium-review.googlesource.com/34250 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-12FPDFPage_New(), FPDF_LoadPage(): Fallthru into PDF case if no XFA context.Tom Sepez
Now that there is a consistent underlying page type, we can unify these actions. Change-Id: I13fdfe775c540baaa0cd8085f8a7999fa6a3d276 Reviewed-on: https://pdfium-review.googlesource.com/34970 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-12CheckUnSupportError() always called with FPDF_ERR_SUCCESS.Tom Sepez
So remove the argument, and the logic dependent upon it being otherwise. Rename function to more accurately reflect its purpose. Remove needless null check while we're at it. Change-Id: I7e119429fd159334eabcc250b5dac215580882ea Reviewed-on: https://pdfium-review.googlesource.com/34950 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-12Remove some #ifdef XFA in favor of runtime checks.chromium/3457Tom Sepez
Make LoadDocumentImpl() logic match FPDFAvail_GetDocument() logic, so that the XFA extension is loaded before checking unsupported features. Add some comments along the way. Change-Id: I040e40fcca872f7c0a46e921bce1146f0fe42588 Reviewed-on: https://pdfium-review.googlesource.com/34931 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-12Make empty document always have empty privilegesTom Sepez
This landed earlier as part of a larger change that got reverted for unrelated reasons. Now re-land it by itself. See https://pdfium-review.googlesource.com/c/pdfium/+/33370 If we don't have a document, then we can't dynamically tell if it is an XFA doc, so there's no reason to believe it should have all permissions. If there is an XFA doc under the covers, then the extension will give us the value. Change-Id: I6e007ab659914c39d2e5f3fe7a25d9d13439d358 Reviewed-on: https://pdfium-review.googlesource.com/34932 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-12Remove explicit calls to FXFT_Clear_Face_External_Stream().Tom Sepez
This landed earlier as part of a larger change that got reverted for unrelated reasons. Now re-land it by itself. See https://pdfium-review.googlesource.com/c/pdfium/+/33370 The current code could cause FT to try to free memory allocated by the caller, with potentially a different allocator. It appears that this may have been added ages ago as a way to kludge around a leak. If we're leaking, msan will find it, and we can deal with it properly rather than trying to force FT to tidy after us. Change-Id: I20abf4cd35d465de1f435ebe6d94b10c3ff74002 Reviewed-on: https://pdfium-review.googlesource.com/34930 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-12Rework "Make common page base class."Tom Sepez
Re-landing of https://pdfium-review.googlesource.com/c/pdfium/+/32892 This time, however, we do not build on the previous CL which cached pages. This CL by itself should be OK but was reverted only because it was blocking earlier reverts. Change-Id: I067d5f07373eeac6cced5d0c113ea40e5f8dcd15 Reviewed-on: https://pdfium-review.googlesource.com/34910 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-12[fm2js] Convert formcalc tests to use raw literalsDan Sinclair
This CL updates some of the formcal tests to use raw literals instead of escaping lots of things. Change-Id: I539063b6c98aae318147b7103a0fd84e6b76054f Reviewed-on: https://pdfium-review.googlesource.com/34190 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-06-11Implement CPDF_Object::MakeReference method.chromium/3456Artem Strygin
Change-Id: I153747ef587a184eaef58ff09dbf8f214c9ddfb3 Reviewed-on: https://pdfium-review.googlesource.com/17230 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-06-11Move some CFXJS_Engine methods to CFXJS_ObjDefinition.Tom Sepez
Partial move, we'll clean up the engine side later. Change-Id: I07fdae150de9e834d11ed242a7f9a007aae266ac Reviewed-on: https://pdfium-review.googlesource.com/34810 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-11Move some FXJS methods onto the per-isolate object.Tom Sepez
This more clearly shows how information is flowing out of V8 and into our C++ callbacks. Change-Id: I5c37d2c28c166443eb9983076fbb0e944bebbf47 Reviewed-on: https://pdfium-review.googlesource.com/34790 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-11Remove explicit calls to x->operator[]Tom Sepez
Because its a code smell of a sort. Change-Id: Id1c1b124f539e31a929701fb9486da9d396d3563 Reviewed-on: https://pdfium-review.googlesource.com/34695 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-11Replace FPDF_PAGE_MAX_NUM with class scoped constant.Tom Sepez
Also avoids confusion with unrelated FPDF_PAGE API type. Bug: pdfium:1085 Change-Id: I36569573f020f0b87f13630bbab91caf351e4994 Reviewed-on: https://pdfium-review.googlesource.com/34830 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-06-11Use spans in CJX_Object.Tom Sepez
Avoid explicitly finding array sizes. Change-Id: Id51e3d10ea4db0a6375807a53309ce8d68b3b413 Reviewed-on: https://pdfium-review.googlesource.com/34750 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-11Use spans in CJS_Object.Tom Sepez
Avoid explicitly having to count items in arrays. Change-Id: I24a91db45e8a8530f38afcc273e824ffb70a6cb9 Reviewed-on: https://pdfium-review.googlesource.com/34710 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-09Consolidate bounding box logic.chromium/3455chromium/3454Lei Zhang
Move all the checks into the shared helper functions for getting/setting bounding boxes. Change-Id: I6f597f478fd3510e0528d20a0a7820949600fd2a Reviewed-on: https://pdfium-review.googlesource.com/34692 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-08Avoid undefined behavior in FX_atonum().Lei Zhang
BUG=chromium:664730 Change-Id: Ie46221382ffed7a16366c484c249d2571c7be5c4 Reviewed-on: https://pdfium-review.googlesource.com/34696 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-06-08Remove CJS_Object::InitInstance().Tom Sepez
Because constructors can do all this. Change-Id: I4f7ff6c26b17d9bddd326333a66e1bd38b2ea377 Reviewed-on: https://pdfium-review.googlesource.com/34693 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-08Add constants for PDF 1.7 spec, table 3.27.Lei Zhang
BUG=pdfium:1049 Change-Id: Ie8bdb893d2af8d63420027a7ef95baf58cd97aa6 Reviewed-on: https://pdfium-review.googlesource.com/34691 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-08Move getting the CPDF_CryptoHandler into CPDF_Creator::WriteStream()Henrique Nakashima
No reason to get it outside and pass it in. Change-Id: I75e3bbd361c04e195004d7c538145dfd56294816 Reviewed-on: https://pdfium-review.googlesource.com/34731 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-06-08Move member initializations to cpdf_creator.hHenrique Nakashima
Change-Id: If19338b63b09ca79aa07c6fbb8eb7e42a689360e Reviewed-on: https://pdfium-review.googlesource.com/34730 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-06-08Instead of CPDF_Creator::m_dwFlags, store its two supported bits.Henrique Nakashima
m_IsIncremental and m_IsOriginal are extracted as soon as the flags are set, so there is no more need for getters. Change-Id: I34331a33d83c1fcbdea6ea1f3e39dfc58d6f85ea Reviewed-on: https://pdfium-review.googlesource.com/34711 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-06-08Remove unused methods in CPDF_Creator, mark others as private.Henrique Nakashima
Also remove the member variable m_dwEncryptObjNum which is never read. Change-Id: Ieb674d6d9783ef298ba3ece1544437b15ad0afe2 Reviewed-on: https://pdfium-review.googlesource.com/34694 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-06-08Remove CPDF_Creator::InitOldObjNumOffsets(). It does nothing.Henrique Nakashima
This method is called, but it returns void and has no side effects: all called methods are const, and no member or static variable is modified. Change-Id: I12084000621728b9994fe7b487852928e7b1180e Reviewed-on: https://pdfium-review.googlesource.com/34690 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-06-08Allow setting current page on Foreground XFA docsRyan Harrison
This changes the check from being for a Full XFA document to any XFA document. Though the value correctly ends up in Chrome, adjusting the current page appears to not be working correctly in Chrome, so this doesn't fully resolve the related bug. BUG=pdfium:1108 Change-Id: I2a5c37e2c64db96cabe8b5b1c277698ebca21949 Reviewed-on: https://pdfium-review.googlesource.com/34650 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-06-08Ensure CJS_Return() with error always includes a message.Tom Sepez
Change the signature of the constructors to make it impossible to do this otherwise. Change-Id: I14e88d98a1128f2d599459ce9337cd6d079469fe Reviewed-on: https://pdfium-review.googlesource.com/34531 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-08Fix issue with resolveNodes() not found off global proxy object.Tom Sepez
We used to assume that a global proxy object could be distinguished by it not having two internal fields, but that invariant isn't correct. Instead, flag it as such so the block of code at line 126 will check the prototype to find an actual object. Squeeze some bytes out of the tags while were at it, no reason for them to be wide. Also remove GetGlobalObjectFromContext() helper, for transparency into what's really going on in v8. This then shows a needless retrieval of an object we already have in one case. Bug: pdfium:1097 Change-Id: Iafc356373166fe5fda76ea7d64193826ee69a6c3 Reviewed-on: https://pdfium-review.googlesource.com/34630 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-08Do not crash if FPDFPage_Get{Media,Crop}Box() gets a NULL out parameter.Lei Zhang
Change-Id: I4b61d4c7239caaf6081bcba80cc0d8ad61569474 Reviewed-on: https://pdfium-review.googlesource.com/34590 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-08Write some FPDFTransformEmbedderTests.Lei Zhang
Test FPDFPage_GetMediaBox() and FPDFPage_GetCropBox(). Change-Id: Ia5ba3d95c0c859acb5c2576781cca90d3e60b40e Reviewed-on: https://pdfium-review.googlesource.com/34570 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>