summaryrefslogtreecommitdiff
path: root/core/fpdfapi
AgeCommit message (Collapse)Author
2017-06-01Fix content generation to only generate dirty page objects.wileyrya
BUG=pdfium:717 R=dsinclair@chromium.org,thestig@chromium.org Change-Id: I7e0e6fd301d40f9b5341d40cf11167b7748af243 Reviewed-on: https://pdfium-review.googlesource.com/6071 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-30Fix small ordering issue in CFX_ProgressiveDecoder cleanup.chromium/3116Tom Sepez
Ensure the renderstatus and image renderers are gone before trying to reset the device. Bug: 726755 Change-Id: Id69402a90aaf6eb03f9e3e7e51ad2f735ddb92d0 Reviewed-on: https://pdfium-review.googlesource.com/6081 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-26Fix CPDF_PageRenderContext cleanupTom Sepez
Make CFX_RenderDevice, which owns the IFX_RenderDeviceDriver, responsible for restoring driver state as part of its destruction so that its callers don't have to do so out of turn. Then re-order CPDF_PageRenderContext destruction order so that the progressive renderer is destroyed before the device, and the device destroyed before the options because of unowned pointers to objects owned by these. Bug: 726755 Change-Id: I9a6f23da12140b2758b86e6f33f715ad1c679c3f Reviewed-on: https://pdfium-review.googlesource.com/6073 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-26Add public API for setting the blend mode on a page object.wileyrya
BUG=pdfium:720 R=npm@chromium.org Change-Id: I2a43b34da6946265ca06502b9ff19ad352fd18cb Reviewed-on: https://pdfium-review.googlesource.com/5953 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-05-26Release unowned CS reference before maybe destroying owned oneTom Sepez
Colorspaces need to be properly refcounted but in the mean time, get rid of an obvious dangling pointer. Bug: 726728 Change-Id: I6bd879b18f61f7f5defd2679ce896013eb218b9b Reviewed-on: https://pdfium-review.googlesource.com/6072 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-26Use proper file names in core/fpdfapi/fontNicolas Pena
This CL splits up font_int.h into files by classes. It also renames the unittests to match the class being tested. Finally, it renames the ttgsubtable files to match the class name. Change-Id: I6187caa9e82d12b9a66e955113fe327d52042ae0 Reviewed-on: https://pdfium-review.googlesource.com/6090 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-26Avoid dangling encrypt dict pointer in CPDF_ParserTom Sepez
CPDF_Parser::StartParse should release the current encrypt dict before trashing it by calling RebuildCrossRef() at cpdf_parser.cpp:195. This gives rise to the pattern that calls to ReleaseEncryptHandler() are followed by SetEncryptDict(nullptr), so just move the later into the former. Bug: 726503 Change-Id: I38bc81f0c0416812035a8a2541c09e875f1fb49a Reviewed-on: https://pdfium-review.googlesource.com/6030 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-26Simplify CPDF_Page ctor.Lei Zhang
Add a GetBox() helper method. Change-Id: I171b2e6714b6c001fad60baa0d4dff2f3c3c978f Reviewed-on: https://pdfium-review.googlesource.com/6011 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-05-26Add public API for setting the fill color on a text objectwileyrya
BUG=pdfium:719 R=npm@chromium.org Change-Id: Ifd9330de265f8419d588b65fbd6a6187f17badd1 Reviewed-on: https://pdfium-review.googlesource.com/5950 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-26Add public API for setting LineJoin and LineCap on a pathwileyrya
BUG=pdfium:718 R=npm@chromium.org Change-Id: Icdc1546c87a676a7d05330dece2c5eacd92c0c92 Reviewed-on: https://pdfium-review.googlesource.com/5951 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-25Mass conversion of remaining class members (non-xfa)Tom Sepez
Change-Id: I8365ba80e3395d59a3cf35dbd9d9162e86e712e3 Reviewed-on: https://pdfium-review.googlesource.com/5970 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-25Mass conversion of all const-lifetime class membersTom Sepez
Sed + minimal conversions to compile, including moving some constructors into the .cpp file. Any that caused ASAN issues during the tests were omitted rather than trying to resolve the underlying issue. Change-Id: I00a421f33b253eb4071ffd9af3f2922c7443b335 Reviewed-on: https://pdfium-review.googlesource.com/5891 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-25Break apart the pageint.h file.Dan Sinclair
This CL separates pageint.h and the supporting cpp files into indivudal class files. Change-Id: Idcadce41976a8cd5f0d916e6a5ebbc283fd36527 Reviewed-on: https://pdfium-review.googlesource.com/5930 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-24Convert to CFX_UnownedPtr, part 9Tom Sepez
Change-Id: Ia1151e0855accda0873251938a521df1913c73fa Reviewed-on: https://pdfium-review.googlesource.com/5852 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-24Convert to CFX_UnownedPtr, part 8chromium/3110Tom Sepez
Change-Id: I99d6b4df72e369652301c36e4046f03ef95ed07d Reviewed-on: https://pdfium-review.googlesource.com/5837 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-24Use CheckedNumeric in BiInterpolImplNicolas Pena
This CL splits up BiInterpolImpl into the three interpolations its made of. In the interpolation, safe math is used, and a boolean keeps track of whether an overflow has occurred. If it does, we consider the patch to be invalid and immediately terminate the Draw method. Bug: chromium:724885 Change-Id: I4944ee1d821d8dd46c04e6b145eabe19d2ad8a5a Reviewed-on: https://pdfium-review.googlesource.com/5851 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-24Convert to CFX_UnownedPtr, part 4.Tom Sepez
Fix strange ownership issue in cpdf_type3char.cpp, and describe the absolutely insane stuff happening there. Change-Id: Iae70f9eca8f125ed3ef677729f1776ba9f10183c Reviewed-on: https://pdfium-review.googlesource.com/5830 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-24Convert to CFX_UnownedPtr, part 3.Tom Sepez
Remove an explicit clear to re-order the member destruction order. Change-Id: I33da3f3de4b8e8e0cfbdceaf5140e98f5d6f904a Reviewed-on: https://pdfium-review.googlesource.com/5791 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-23Make CPDF_ImageCacheEntry retain CPDF_ImageTom Sepez
CPDF_PageRenderCache::m_ImageCache is a map from streams to an image cache entry containing a clump of data associated with the stream. Oddly, the clump includes the stream key (which we already have in order to get to the clump), but worse doesn't ensure the existence of the CPDF_Image object which (maybe) owns the stream key in question. So replace the stream with a retained ptr to the image. Also renamed an unrelated member to avoid confusion with the CPDF_Object in play. Bug: 724460 Change-Id: Id13d2c246918d4ff78c12b5bdb927f99c3f5e4e1 Reviewed-on: https://pdfium-review.googlesource.com/5771 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-23Use NOTREACHED() in more places.Lei Zhang
Change-Id: I88466943171f19259f84add69679741d44c8e123 Reviewed-on: https://pdfium-review.googlesource.com/5551 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-22Convert more c-style pointers to CFX_UnownedPtrTom Sepez
Change-Id: I551b4210c95db0b916e9fe6cddf11e6c3d015c50 Reviewed-on: https://pdfium-review.googlesource.com/5790 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-20Use std::vector and std::sort() in CPDF_PageRenderCache.Lei Zhang
Instead of allocating a chunk of memory and using qsort(). Change-Id: I95041f79cfe609a9d99493d59eb074599ec49230 Reviewed-on: https://pdfium-review.googlesource.com/5690 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-19Fix off-by-one introduced at ab20404Tom Sepez
Building a little-endian n-byte value via a single byte store and a memset(0) is dubious, but don't clobber the value we just stored. Bug: 723625 Change-Id: I015ea3e01c63a534f2ca0a1c085ed67777330d82 Reviewed-on: https://pdfium-review.googlesource.com/5732 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-19Move CCodec_ModuleMgr ownership to CPDF_ModuleMgr.Lei Zhang
More straight forward than CFX_GEModule owning in and CPDF_ModuleMgr holding a pointer to it. Remove assumptions that the codec modules may return nullptr, and do IWYU. Change-Id: Iba7fc3c7ec223fd6d29a1ab74ed13d35689bc5d5 Reviewed-on: https://pdfium-review.googlesource.com/5654 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-05-19Remove image dimension params that are never used.Lei Zhang
Change-Id: Ib219e23efdcb128772c4c3138531363af53780a1 Reviewed-on: https://pdfium-review.googlesource.com/5652 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-18Add more CFX_UnownedPtr usage.Tom Sepez
One lifetime issue was fixed by passing CPDF_RenderStatus into Continue() methods rather than holidng a pointer which was going stale. Bug: Change-Id: I63b9dce4c1a0d1377cc407b5460535f7c916a040 Reviewed-on: https://pdfium-review.googlesource.com/5659 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-05-18Fix a situation where images are not properly rendered.Lei Zhang
This regressed in commit e21fe98. When the image's bpc is a multiple of 8, there exists a colorspace, and there is a Decode parameter, the image data source was incorrectly pointing to a data structure that only contained black pixels. BUG=chromium:718762 Change-Id: I5d3fa739e41726b4ed1ebc16465e17f83fff9f8d Reviewed-on: https://pdfium-review.googlesource.com/5333 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-17Reland: Small fix in CPDF_TrueTypeFont loadNicolas Pena
The ToUnicode map should not be ignored when it exists. Doing so can cause a charcode to be assigned an incorrect glyph index, and will result in garbled text. Previously, some bots failed with 'unable to open' the .png file. Bug: chromium:665467 Change-Id: I435a73647eadcc3ba37bb0120f3b5cee381ae7a3 Reviewed-on: https://pdfium-review.googlesource.com/5610 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-17Revert "Small fix in CPDF_TrueTypeFont load"Nicolás Peña
This reverts commit dde95d8be9bc2817e34429fc38ee6d89d6d5ab75. Reason for revert: the test added is flaky Original change's description: > Small fix in CPDF_TrueTypeFont load > > The ToUnicode map should not be ignored when it exists. Doing so can cause a > charcode to be assigned an incorrect glyph index, and will result in garbled > text. > > Bug: chromium:665467 > Change-Id: I21c1bf560a0731d974191d4189ea730ef9868334 > Reviewed-on: https://pdfium-review.googlesource.com/5512 > Reviewed-by: Lei Zhang <thestig@chromium.org> > Commit-Queue: Nicolás Peña <npm@chromium.org> > TBR=thestig@chromium.org,tsepez@chromium.org,dsinclair@chromium.org,npm@chromium.org NOPRESUBMIT=true NOTREECHECKS=true NOTRY=true Bug: chromium:665467 Change-Id: I704a34f326d31018061bcfd857fb25f7e4ee4cc2 Reviewed-on: https://pdfium-review.googlesource.com/5493 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-16Small fix in CPDF_TrueTypeFont loadNicolas Pena
The ToUnicode map should not be ignored when it exists. Doing so can cause a charcode to be assigned an incorrect glyph index, and will result in garbled text. Bug: chromium:665467 Change-Id: I21c1bf560a0731d974191d4189ea730ef9868334 Reviewed-on: https://pdfium-review.googlesource.com/5512 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-16Introduce CFX_UnownedPtr to detect lifetime inversion issues.Tom Sepez
There are places where an object "child" has a raw pointer back to object "owner" with the understanding that owner will always outlive child. Violating this constraint can lead to use after free, but this requires finding two paths: one that frees the objects in the wrong order, and one that uses the object after the free. The purpose of this patch is to detect the constraint violation even when the second path is not hit. We create a template that is used in place of TYPE*. It's dtor, when a memory tool is present, goes out and probes the first byte of the object to which it points. Used in "child", this allows the memory tool to prove that the "owner" is still alive at the time the child is destroyed, and hence the constraint is never violated. Change-Id: I2a6d696d51dda4a79ee2f00a6752965e058a6417 Reviewed-on: https://pdfium-review.googlesource.com/5475 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-05-15Remove unused flags from CPDF_CreatorNicolas Pena
The only user of CPDF_Creator is FPDF_Doc_Save, and it only uses flags 1 or 2 when calling Create. Thus, the other two flags will never be set. Change-Id: Ib2eb0ce5585469c7749f0ab350855f1c6a2bba08 Reviewed-on: https://pdfium-review.googlesource.com/5491 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-05-11Use clamp() in a couple more places.Lei Zhang
Change-Id: I9b7a1c101e3c73d0270f9216225e5a13d9937b97 Reviewed-on: https://pdfium-review.googlesource.com/5332 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-11Rename render device classesDan Sinclair
This Cl renames the CFX_RenderDevice subclasses to make their usage clearer. Change-Id: Ie820b57df9a3743ce8c6893fb483b398a1f1bdbe Reviewed-on: https://pdfium-review.googlesource.com/5390 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-11Move map and codec loading into managerDan Sinclair
This Cl consolidates the code to load maps and codecs into the CPDF_ModuleMgr class instead of putting it directly into fpdfview. Change-Id: Ia08f212f43a33e51ab1c7832051ee4f28eecb50d Reviewed-on: https://pdfium-review.googlesource.com/5335 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-10Split DCT decoder creation from CPDF_DIBSource::CreateDecoder().Lei Zhang
Change-Id: Ia0ea49f0460fcb8e55542f237d321bb9207aa8e1 Reviewed-on: https://pdfium-review.googlesource.com/5250 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-10Replace operator bool with HasRef() in classes with a CFX_SharedCopyOnWrite ↵Lei Zhang
member. Change-Id: I51e30d298e87b9ae0d5aca83b2f1d6787efce70a Reviewed-on: https://pdfium-review.googlesource.com/5290 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-05-10Store the offset in the archive bufferDan Sinclair
This Cl moves the implementation of the archive buffer behind an IFX_ArchiveStream interface. The buffer holds the current offset and the offset parameter is removed from the CPDF_Creator and various other methods. Change-Id: Ia54e803b58bbfb6ef03fec4a940d2c056d541356 Reviewed-on: https://pdfium-review.googlesource.com/5255 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-10Cleaning up Edit codeDan Sinclair
This Cl conslidates if statements, converts int returns to bools where possible and various other cleanups in fpdfapi/edit. Change-Id: Ia31ecc69843117eb5ebfff449a6046a267d08e89 Reviewed-on: https://pdfium-review.googlesource.com/5190 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-10Simplify CPDF_ImageRenderer::StartRenderDIBSource().Lei Zhang
Change-Id: Ia0a78be3320c5d6c3d0c40d4199cae1473e0e8dc Reviewed-on: https://pdfium-review.googlesource.com/5253 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-10Use FXSYS_IntToTwoHexChars() in more places.Lei Zhang
Change-Id: I84cd8e91a296119ecf80b7a092b886f291bebb45 Reviewed-on: https://pdfium-review.googlesource.com/4953 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-10Fix typos for the word start.Lei Zhang
Change-Id: Ic602126dc5407fcbb56dca5ec43e1824a5ca55b6 Reviewed-on: https://pdfium-review.googlesource.com/5251 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-05-09Edit code cleanupDan Sinclair
Minor cleans in the fpdfapi/edit code. Change-Id: I7bb2f4add7c6e84f072501035b1f77c218174cca Reviewed-on: https://pdfium-review.googlesource.com/5152 Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-09Move FPDF_FILEWRITE adapter to own fileDan Sinclair
This Cl moves the adapater out of the fpdfsave.cpp file into its own h/cpp files. The adapter was renamed for clarity. The CPDF_Creator was modified to take the adapter as a constructor param and the Create methods consolidated. Change-Id: Icb104f195ef532dda053c859aae356a8d4a7a54c Reviewed-on: https://pdfium-review.googlesource.com/5151 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-09Rename fpdf_edit_create.cpp to cpdf_creator.cppDan Sinclair
This Cl renames the fpdf_edit_create file to better match the cpdf_creator content. The CPDF_ObjectStream and CPDF_XRefStream code is moved out to their own .cpp files. Needed anonymous classes are split out as well. Change-Id: Ic83fb319ce28c816db82a4286e22032dc68811bc Reviewed-on: https://pdfium-review.googlesource.com/5171 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-05-09Remove editint.h and create individual headerschromium/3095Dan Sinclair
This Cl creates a cpdf_objectstream and cpdf_xrefstream headers from the editint header. Change-Id: I857981fa055ee9296cbd344860e55c67acf200ce Reviewed-on: https://pdfium-review.googlesource.com/5113 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-05-09Remove CPDF_Creator friendsDan Sinclair
This CL removes the friend declarations from CPDF_Creator and adds accessor methods instead. Change-Id: I6d8f67b5944aed34af00ff6ea9d23fe7d17cec18 Reviewed-on: https://pdfium-review.googlesource.com/5112 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-09Remove AppendObject from CPDF_CreatorDan Sinclair
The AppendObject method has been removed and the functionality moved to the individual CPDF_Object classes. Change-Id: I5446c6cc3e792d849acf77caed34b63a88f3a2d2 Reviewed-on: https://pdfium-review.googlesource.com/5072 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-05-09Cleanup CPDF_Creator defines and method namesDan Sinclair
This Cl removes un-needed prefixes from anonymous method names and cleans up various defines. Change-Id: If46a04c80460bb675af68d1e08d3093855d8fb19 Reviewed-on: https://pdfium-review.googlesource.com/5111 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-05-08Remove default params in CFX_DIBSourceNicolas Pena
Change-Id: I9306afed2747e3b0054adeea1d39916cac47f5c5 Reviewed-on: https://pdfium-review.googlesource.com/5091 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>