summaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)Author
2018-06-25Clean up CPDF_StreamContentParser::AddTextObject().chromium/3473Lei Zhang
Change-Id: I1794848607f2db3f1ef39dbd221b7219feb9254c Reviewed-on: https://pdfium-review.googlesource.com/35990 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-25Combine common code into CPDF_RenderStatus::ClipPattern().Lei Zhang
Change-Id: I53ce4ee699644b0a30132e642b8f466cd9b6e7b1 Reviewed-on: https://pdfium-review.googlesource.com/35972 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-25Make DrawRadialShading() slightly more compact.Lei Zhang
Change-Id: Ic0e528d01338a349deb1ee5a91372b132959e4ae Reviewed-on: https://pdfium-review.googlesource.com/35971 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-23Fix some nits from commit 27cf78d8.chromium/3472chromium/3471Lei Zhang
Change-Id: I52d7b9692c19af1aafab7d572d0a274726bd37f5 Reviewed-on: https://pdfium-review.googlesource.com/35911 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-22Avoid some duplicate const/non-const getters.Tom Sepez
Getters should nearly always be const when they return a non-const pointer to an unowned object. Saves a bit of code along the way. Grep for similar occurrences and add "const". Change-Id: I492bf962a7d62452fa40310146226dc0c8ebb753 Reviewed-on: https://pdfium-review.googlesource.com/35890 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-06-22Fix overflow in CFX_RenderDevice::DrawFillStrokePath().Henrique Nakashima
Bug: chromium:853430 Change-Id: I1c42de1e3db10dfb6399cd8abdd13c56addc8827 Reviewed-on: https://pdfium-review.googlesource.com/35850 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-06-22CPDF_PageObjectHolder::GetDirtyStreams() returns const ref.Henrique Nakashima
This is safer since a ref cannot be deleted. Change-Id: Ib8d76ae2adb7c59e6955881eee0d2bd4db448b68 Reviewed-on: https://pdfium-review.googlesource.com/35950 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-06-22Rework of Fixing metadata not read from linearized file.Artem Strygin
Move receiving "Info" dictionary form API implementation to CPDF_Document. Also added test. Bug: pdfium:664 Change-Id: I273980750fbdd4d20711f651245780fc9ba02789 Reviewed-on: https://pdfium-review.googlesource.com/35490 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-21Use enum for stages of CPDF_Creator.Henrique Nakashima
Change-Id: Ic750e04a24524d47ba77b9b7cd5a29605965f68b Reviewed-on: https://pdfium-review.googlesource.com/35390 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-21Do not save content stream if all page objects were removed from it.Henrique Nakashima
Bug: pdfium:1051 Change-Id: Ia990a47eeceb47fd2b15fe4ea7226861507484db Reviewed-on: https://pdfium-review.googlesource.com/35115 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-06-21Remove WideString::c_str() calls where possible.Tom Sepez
Many of these cause a string duplication as we go from Widestring => c_str => Widestring Change-Id: I0dfa952e66f89138e719ff9200db3d9397839e28 Reviewed-on: https://pdfium-review.googlesource.com/35790 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-21Avoid const-refs to implicitly constructed strings.Tom Sepez
Because the invisible temporary goes out of scope at the next semicolon. Also avoid returning const string references since the cost is low to properly keep the string alive. Change-Id: Id283e4fd99f79a02d79d739a533a4ce05e831e2a Reviewed-on: https://pdfium-review.googlesource.com/35710 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-20Fix a couple of CPDF_DefaultAppearance::GetFont usageschromium/3467Nicolas Pena
Bug: 853238 Change-Id: I133be340fd877e9acd2733845d454924dc86d295 Reviewed-on: https://pdfium-review.googlesource.com/35711 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-06-20Avoid more .c_str() usage, part 3Tom Sepez
Change-Id: I5dfadcb68e640235be6e3eb7c8d57ae3b8013d26 Reviewed-on: https://pdfium-review.googlesource.com/35691 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-20Re-work some more c_str() usage.Tom Sepez
Many of these are converting ByteString => c_str => ByteStringView, since the ByteStringView ctor is implicit. This is unfortunate, since that involves a strlen() which the ByteString already knows if we use AsStringView() instead. This changed one test result where we can now return the string "\0" instead of "" -- since strlen no longer eats the NUL. This seems consistent, say, with String.fromCharCode(). Change-Id: I17f68d1a1f4b352960208f9148e68ab4c4d78bd2 Reviewed-on: https://pdfium-review.googlesource.com/35590 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-20Replace SkTSwap with std::swap/swap.Ben Wagner
Skia is moving to normalize on std::swap instead of its own SkTSwap. This removes the use of SkTSwap from PDFium so that Skia can remove it. Change-Id: If77708c1f363f4fd82a4c7905c7fbb2060900532 Reviewed-on: https://pdfium-review.googlesource.com/35470 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-20c_str() calls not needed when writing to ostreamTom Sepez
c_str() is a bit of a code smell, esp. since Byte/Wide strings know how to do this all by themselves. Change-Id: I9c86cee42c12a3f72ddb1d410a91cf25647d0ce6 Reviewed-on: https://pdfium-review.googlesource.com/35530 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-20Add in a size guard to JPX fuzzerRyan Harrison
Setting an upper limit to the size of images being processed in the JPX fuzzer to reduce timeouts due to images just being really big. Also cleaned the types for passing pitch down to reduce the signedness conversions. BUG=chromium:834561 Change-Id: I28b7a2537a922ed7a9ca2f8ed049ae78dd471f49 Reviewed-on: https://pdfium-review.googlesource.com/35570 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-06-19Move fxcrt::{Byte,Wide}Strings with std::move().chromium/3466Tom Sepez
Remove some string copies in barcode that were noticed whilst looking for moves. Change-Id: Ieda34d00f633576ba1f0dca283dcdabfb36f236c Reviewed-on: https://pdfium-review.googlesource.com/35410 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-19Speculative fix for segv destroying CPDF_PageObjectHolder::m_GraphicsMapTom Sepez
We speculate that the bug that makes the comparison operator irreflexive might be the cause of the segv on windows production code, should a NaN sneak into the GraphicsData struct. In any event, should this happen, the tree won't be correct with some nodes erroneously replaced. Add a test which fails prior to the patch, but alas does not elicit the segv. Also move operator<() methods to .cpp file corresponding to .h file in which they are delcared. Bug: 852273 Change-Id: Ib7929881e7ffbed8b09f6e2c9fb7898cbde58946 Reviewed-on: https://pdfium-review.googlesource.com/35171 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-19Use const pointers within GetDirectInteger function.Artem Strygin
Change-Id: I4a2905f9ce4433e8c00b274fa9703ff4dc459e95 Reviewed-on: https://pdfium-review.googlesource.com/35510 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-19fxcrt::{Byte,Wide}String missing move-assign operatorTom Sepez
This hasn't been a big deal, since no data is copied, but avoids some ref-count churn in the process. Change-Id: I53c059284aa6806793c59a0c19b3e0d7fe4191d6 Reviewed-on: https://pdfium-review.googlesource.com/35350 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
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-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-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-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-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-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-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-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-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-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-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-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>