summaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)Author
2018-07-10Create API for adding content marks and setting their params.chromium/3488Henrique Nakashima
This CL creates the following new functions in the public API: - FPDFPageObj_AddMark - FPDFPageObjMark_SetIntParam - FPDFPageObjMark_SetStringParam Bug: pdfium:1037 Change-Id: Icabf3fdd8e8153b9156bab807a3708d38a9365d8 Reviewed-on: https://pdfium-review.googlesource.com/37330 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-10Make CPDF_StreamContentParser::m_pResources a const pointer.Lei Zhang
Move the code to select what it points at to a separate function, so the CPDF_StreamContentParser constructor only sets it once. Change-Id: I60013e77c8f37246282f94227a4aeb17270ee23c Reviewed-on: https://pdfium-review.googlesource.com/37450 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-10Fix m_ExtGID usage in CPDF_CharPosListNicolás Peña
This CL allows Apple to use m_GlyphIndex as a replacement for m_ExtGID when it is invalid. Bug: pdfium:1121 Change-Id: I49e7936201815bae5a2c8a26680fc1e542a60c43 Reviewed-on: https://pdfium-review.googlesource.com/37390 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-07-10Fix duplicate symbols in Chromium builds.Lei Zhang
Commit 43f6bc80 copied over Chromium's base/debug/alias.cc, but that confuses Windows builds and Linux jumbo builds in Chromium. To fix this, wrap PDFium's copy in the pdfium namespace. BUG=chromium:860850 TBR=dsinclair@chromium.org Change-Id: I1ceec28b9ce6c2893bf030a5b6564dce6d6ec376 Reviewed-on: https://pdfium-review.googlesource.com/37430 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-09Prevent FX_OutOfMemoryTerminate() from being folded by the linker.Lei Zhang
Copy base::debug::Alias() from Chromium. Use it to prevent ICF from combining FX_OutOfMemoryTerminate() with similar functions. BUG=chromium:860850 Change-Id: Ifccb05c0218f86e44b9bb235847e01383ec36b3f Reviewed-on: https://pdfium-review.googlesource.com/37290 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-06Fix regression in CJBig2_TRDProc.chromium/3486chromium/3485chromium/3484Lei Zhang
Commit 7695dd0f mistakenly changed a signed integer to unsigned. This is incorrect because right shifts for negative integers behave differently. BUG=chromium:859284 Change-Id: Id9c54848b15ace1de080c174f261dd2c064018e0 Reviewed-on: https://pdfium-review.googlesource.com/37230 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-06Maintain a stack of CPDF_ContentMark while parsing a stream.Henrique Nakashima
This avoids copying the CPDF_ContentMark every time a mark is closed. Another benefit is that the same CPDF_ContentMarkItem vector will be shared by page objects before and after a nested mark. Bug: pdfium:1037 Change-Id: I6197f0b9a4693ef84da9269f86a2629aa50d8685 Reviewed-on: https://pdfium-review.googlesource.com/37190 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-07-06Make MarkData::mMarks a vector of RetainPtr<CPDF_ContentMarkItem>Henrique Nakashima
It is currently a vector of CPDF_ContentMarkItem. Copying MarkData whenever a content mark is opened or closed is inefficient since each MarkData will have copies of the same CPDF_ContentMarkItems. This CL changes the vector inside MarkData to contains only pointers to the CPDF_ContentMarkItems rather than copies of those items. More importantly, this unifies the dictionaries of each content mark. Previously, there were as many copies of those dictionaries as content marks scope changes inside the mark with parameters. Bug: pdfium:1037 Change-Id: Ia6f79b401d4e14ac07dbba81bbd97df965b77c94 Reviewed-on: https://pdfium-review.googlesource.com/37135 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-07-06Revert "Avoid duplicate data buffering in CPDF_SyntaxParser::ReadStream()."Henrique Nakashima
This reverts commit 77f15f7883638a4ced131d74c053af10a5970ce9. Reason for revert: Causes crbug.com/860210 Bug: chromium:860210 Original change's description: > Avoid duplicate data buffering in CPDF_SyntaxParser::ReadStream(). > > Allow sub-streams created from an IFX_SeekableReadStream to provide > stream data without copying memory. > The data will only reside in the top-level stream. > > For example: > For file > http://www.major-landrover.ru/upload/attachments/f/9/f96aab07dab04ae89c8a509ec1ef2b31.pdf > (18 Mb) > > The memory usage is reduced by ~13 Mb. > > Change-Id: I2595c014d0fbe1fdd181cc04965cfd7d901c2d88 > Reviewed-on: https://pdfium-review.googlesource.com/35930 > Commit-Queue: Art Snake <art-snake@yandex-team.ru> > Reviewed-by: dsinclair <dsinclair@chromium.org> TBR=tsepez@chromium.org,dsinclair@chromium.org,art-snake@yandex-team.ru # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: I947fca17052765935a952a4f25ca48f6599c4af9 Reviewed-on: https://pdfium-review.googlesource.com/37210 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-07-05Fix integer overflow in CPDF_Type3Cachechromium/3483Nicolas Pena
Bug: chromium:845800 Change-Id: Ib878dd991e435a76b63b662ef3d9d33c2cc61a19 Reviewed-on: https://pdfium-review.googlesource.com/37191 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-07-05Rename CPDF_ContentMark::m_Ref to ::m_pMarkData.Henrique Nakashima
Bug: pdfium:1037 Change-Id: I94efc14ce5f8d0d407853cce025f0184b3866cc4 Reviewed-on: https://pdfium-review.googlesource.com/37134 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-07-05Delete CPDF_ContentMark::HasRef()Henrique Nakashima
This is called by many client to make sure CountItems() does not crash. Moving the check to CountItems() makes HasRef() unnecessary. Bug: pdfium:1037 Change-Id: I4f21f33a88c9aad54f0dae18a38b370c6ceaec80 Reviewed-on: https://pdfium-review.googlesource.com/37133 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-07-05Replace SharedCopyOnWrite<MarkData> with RetainPtrHenrique Nakashima
A RetainPtr is already used inside SharedCopyOnWrite, and the API that CPDF_ContentMark offers is not intuitive. AddMark() and RemoveLastMark() currently copy the MarkData. The new API does not perform these copies, but rather leaves it to the client code. This is the first step to make CPDF_ContentMarkItems modifiable. As long as they are inside a SharedCopyOnWrite, they cannot be changed. Bug: pdfium:1037 Change-Id: I0cd6334b0b8db62070b4412f1d6d1c88bce9891f Reviewed-on: https://pdfium-review.googlesource.com/37132 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-07-03Use std::vector<float> in CPDF_Function.Tom Sepez
Change-Id: Ia994118f93f34b5c0c2f2f5ddfd70fe11e9ec549 Reviewed-on: https://pdfium-review.googlesource.com/37010 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-03Remove a parameter from CPDF_SyntaxParser::FindTag().Lei Zhang
The limit parameter is always set to 0. Change-Id: Idf7f44e1c5a895e05ad474932d3e9df85f435e3f Reviewed-on: https://pdfium-review.googlesource.com/36990 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-07-03Avoid duplicate data buffering in CPDF_SyntaxParser::ReadStream().Artem Strygin
Allow sub-streams created from an IFX_SeekableReadStream to provide stream data without copying memory. The data will only reside in the top-level stream. For example: For file http://www.major-landrover.ru/upload/attachments/f/9/f96aab07dab04ae89c8a509ec1ef2b31.pdf (18 Mb) The memory usage is reduced by ~13 Mb. Change-Id: I2595c014d0fbe1fdd181cc04965cfd7d901c2d88 Reviewed-on: https://pdfium-review.googlesource.com/35930 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-07-03Test {Byte,Wide}String works with std::begin().Tom Sepez
Test-only CL. Building another container from the string in the manner in the test is desirable. Change-Id: I8f41aecfd82fd27f8b9af159b887b66b566f9ac7 Reviewed-on: https://pdfium-review.googlesource.com/36910 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-03Do data request for CPDF_Stream more smoothly.Artem Strygin
For DocumentLoader we should do reconnect to skip non-requested blocks on each requested offset jump. To reduce reconnections, read stream data first, then do all checks. Thereby the DocumentLoader will continue loading data without reconnections. Change-Id: I344d045e59c5de9e1a4aed0002ea122caa92f240 Reviewed-on: https://pdfium-review.googlesource.com/13450 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-03Use unowned ptr in cpdf_stream_accTom Sepez
Change-Id: Ide081e462c83a5a209a2e6462dd12b298993f36f Reviewed-on: https://pdfium-review.googlesource.com/36850 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-07-03Forward declare CPDF_SyntaxParser when possible.Lei Zhang
Change-Id: Ib9b30f7f4e1c41b0e2e2c1757252736599055c96 Reviewed-on: https://pdfium-review.googlesource.com/36870 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-03Use GetPos() and SetPos() in CPDF_SyntaxParser::ReadStream().Lei Zhang
Change-Id: I711508cdffd9756837657390d73b88c2d8c62db5 Reviewed-on: https://pdfium-review.googlesource.com/36891 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-07-03Fix indentation in CPDF_SyntaxParser.Lei Zhang
Change-Id: I293730ea5981ba8e2dca7a522b9036fa62d7cd35 Reviewed-on: https://pdfium-review.googlesource.com/36890 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-07-02Virtualize Observable<T>::ObservedPtr::OnDestroy() for CPDF_Avail cleanupTom Sepez
This enables more complicated cleanup when an observed object is destroyed. Use it to make documents observable and to allow the CPDF_Avail to cleanup without the need for intermediate class. Change-Id: I3a8e758b7ff542e0a58710eff1ac8017205cbd45 Reviewed-on: https://pdfium-review.googlesource.com/36373 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-02Use std::vector<float> in cpdf_expintfunc.cppTom Sepez
Fix some {} along the way. Change-Id: I5277c03328b63e0cead058fc07dc65311d7b97b0 Reviewed-on: https://pdfium-review.googlesource.com/36791 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-02Access a span properly in DetectSRGB().Lei Zhang
Change-Id: Ifeaac7141bd377daa9cf657149937be22b2aa48a Reviewed-on: https://pdfium-review.googlesource.com/36730 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-02Check for more integer overflows in CJBig2_TRDProc.Lei Zhang
BUG=chromium:859284 Change-Id: I41ce5de4cca0a863dc6e60b64fd69d36c2672a64 Reviewed-on: https://pdfium-review.googlesource.com/36790 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-02Use std::vector in one more place in cpdf_colorspace.cppTom Sepez
Change-Id: Ifbce02a65b68b0526866d5a08a9edf58bd89e434 Reviewed-on: https://pdfium-review.googlesource.com/36792 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-02Comment some raw pointers that cant become UnownedPtr<>.Tom Sepez
These appear in compile-time const data. Adding the comment makes it easier to see what work remains when using grep. Change-Id: Ibb5fe920dc9fc99dd4c866f9ddf800a58f6a67a8 Reviewed-on: https://pdfium-review.googlesource.com/36690 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-02Add pdfium::Vector2D<>()Tom Sepez
Many of the FX_Alloc's that have not been converted to std::vector are using FX_Alloc2D and the safe math it performs under the covers. Make an equivalent function for returning a vector to avoid burdening callers with the safe math equivalents. Use it in one place. Change-Id: Ie4a280351b7370b755f2a1928f8b2d84fe007c03 Reviewed-on: https://pdfium-review.googlesource.com/36770 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-06-29Use pdfium::span with CPDF_IccProfile and friends.Lei Zhang
Change-Id: I88d3e86a1dad75ef9c6bfb3401af6606479031a7 Reviewed-on: https://pdfium-review.googlesource.com/36634 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-29Remove out param from CCodec_IccModule::CreateTransform_sRGB().Lei Zhang
Its return value contains the same data. Change-Id: I2bf4e72faf978e5d491bec573babc8099cda4e5a Reviewed-on: https://pdfium-review.googlesource.com/36633 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-29Add ScopedCmsProfile.Lei Zhang
Using this unique_ptr avoids the need for explicit cmsCloseProfile() calls in CCodec_IccModule::CreateTransform_sRGB(). Change-Id: I5b2d5d9800ea344aceb0ed5c6b745a2925bab9c9 Reviewed-on: https://pdfium-review.googlesource.com/36632 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-29Clean up CLcmsCmm.Lei Zhang
Make members const and private. Fix nits. Change-Id: I945bc26438f8fbd6904dc1b15513ab9e51170dc7 Reviewed-on: https://pdfium-review.googlesource.com/36631 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-29Delete dead code in CCodec_IccModule.Lei Zhang
Change-Id: I711654cfb1ab43a5d17afbe6f877c1860dd1b7f0 Reviewed-on: https://pdfium-review.googlesource.com/36630 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-06-29Better determine if ICC colorspaces can be used for blending.Lei Zhang
Implement CPDF_ColorSpace::IsNormal() and check it when rendering. While IsNormal() is trivial for most colorspaces, it needs to be implemented separately for ICC colorspaces. This fixes a rendering regression from commit 1c0de38c. BUG=chromium:847346 Change-Id: Iaafed3f8ee40b26ac2cbfbdf2251407f7935311b Reviewed-on: https://pdfium-review.googlesource.com/36571 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-29Limit image size in CJBig2_PDDProc.Lei Zhang
CJBig2_PDDProc internally creates a CJBig2_GRDProc to create an image. If the image is too big, then processing it can use up too much memory. BUG=chromium:857106 Change-Id: I06a9eaed6941be1cbb7481d21048e6a1681696b7 Reviewed-on: https://pdfium-review.googlesource.com/36490 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-06-29Clean up CJBig2_PDDProc.Lei Zhang
Change-Id: Ia83ac5dae0dedf55f1b0f0cf2a728c64474f72db Reviewed-on: https://pdfium-review.googlesource.com/36450 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-06-29Implement CPDF_HintsTable::PageInfo.Artem Strygin
Merge page info data from Hints Table into CPDF_HintsTable::PageInfo class. Change-Id: I468996346ee153e3fa8ada6a83770614362d1b92 Reviewed-on: https://pdfium-review.googlesource.com/15813 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-06-28Use unique_ptr in ccodec_tiffmodule.cppTom Sepez
Change-Id: I9c829a09a1c5ecdf011b1a9804a65e77b0e199b7 Reviewed-on: https://pdfium-review.googlesource.com/36371 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-28Use spans and std::unique_ptrs in fx_codec_flate.cppTom Sepez
Also avoid needless use of void* in place of actual type. Also free context with free function corresponding to its allocator, in case the m_ functions change down the road. Change-Id: I384f6b309c2522eb0faafbe73b94cc3bf582dbb8 Reviewed-on: https://pdfium-review.googlesource.com/36370 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-06-28Replace DCHECKs with ASSERTs.Lei Zhang
Change-Id: I0f2bf1cb44b4cba872a719f0a75d8776f413812c Reviewed-on: https://pdfium-review.googlesource.com/36250 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-28Use UnownedPtr for document within CPDF_XXXAvail.Artem Strygin
Change-Id: I9ded1664564c330132f43047293e18696d77fc7d Reviewed-on: https://pdfium-review.googlesource.com/36310 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-06-27Remove useless code.Artem Strygin
No longer needed after commit 20eca1e3 Change-Id: Ica4f67d2a2df760ebf9fd507283791271ad407cd Reviewed-on: https://pdfium-review.googlesource.com/36351 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-06-27Remove CPDF_Parser::ParseIndirectObjectAtByStrict().Lei Zhang
Commit 0145b89a removed the only caller. Change-Id: Ib3b7eaa0bc8be986f7d290f1efaea519d68daf6b Reviewed-on: https://pdfium-review.googlesource.com/36251 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-06-27Add fxcrt::AutoRestorer<T>::AbandonRestoration().chromium/3475Tom Sepez
Kinda like reaching a commit point, makes going forward more useful. Change-Id: I7695b6e627d4cd8ed2bccb667d0cabd7f42c7b1c Reviewed-on: https://pdfium-review.googlesource.com/35970 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-27Remove unused m_bGif* fields from CFX_DIBAttributeTom Sepez
Two are completely unused, and two are set but never referenced. Change-Id: I0173123e33a4240aef9ed24aaee9e1df6cf9aa0a Reviewed-on: https://pdfium-review.googlesource.com/36290 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-27Rework of loading of CPDF_Document.Artem Strygin
Improve CPDF_Document interface. Fix relationship between CPDF_Document and CPDF_Parser. This CL changes CPDF_Document to internally create the CPDF_Parser and removes the need for the CPDF_Parser to know about the CPDF_Document. Change-Id: Iec7aef19575c90f30b9a6c919dfd4f4417e4caf2 Reviewed-on: https://pdfium-review.googlesource.com/35630 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-27Use spans and UnownedPtrs in cjpx_decoder.hTom Sepez
Change-Id: I1c9f8221ce7a0e42407e93deec481be2e941cfde Reviewed-on: https://pdfium-review.googlesource.com/36210 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-27Implement CPDF_CrossRefTableArtem Strygin
Change-Id: I5ac61ab323adb5eec2de8660064fff95ee877b5e Reviewed-on: https://pdfium-review.googlesource.com/35432 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-06-26Use UnownedPtr<> in cpdf_streamcontentparserchromium/3474Tom Sepez
Change-Id: I558ac625d842d1b3d9dfdaf4d7661d4c02c6244a Reviewed-on: https://pdfium-review.googlesource.com/36133 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>