summaryrefslogtreecommitdiff
path: root/core/fpdfapi
AgeCommit message (Collapse)Author
2018-04-12Add return value to FPDF_DeviceToPage().Lei Zhang
Do the same for FPDF_PageToDevice(). Clean up the internal implementation as well. Change-Id: Ia207bfa779d144cb9f0310e768750ab10e603b8f Reviewed-on: https://pdfium-review.googlesource.com/17370 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-12Add CPDF_Page::DeviceToPage() / PageToDevice().Lei Zhang
Just like CPDFXFA_Page. Also mark the methods const. Change-Id: I6717b4b61a29663780f45bf872f76fe8e671df75 Reviewed-on: https://pdfium-review.googlesource.com/30132 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-12Change GetDisplayMatrix methods to take FX_RECT.Lei Zhang
Change-Id: I079bc3bf1242fd28fdd51930d9deb6efa34d7509 Reviewed-on: https://pdfium-review.googlesource.com/30055 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-12Make CFX_Font take FX_RECT out params by pointer.Lei Zhang
Change-Id: I6643aaf66bf3e9d53d5afab5c99a5cb7deab3661 Reviewed-on: https://pdfium-review.googlesource.com/30054 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-12Bounds check in CPDF_CMap::GetNextChar.Tom Sepez
These were kicked loose when we converted to span<>, and there isn't any reason to believe that the remaining string is long enough to complete a multibyte sequence. Bug: 831100 Change-Id: Iae4363f72b4d7ff088a73994d0fe5dab4077ee9e Reviewed-on: https://pdfium-review.googlesource.com/30291 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-04-11Fix crash when ColorSpace references itself directly.Henrique Nakashima
Also fixes any problems with cycles between colorspaces. Past fixes have solved problems with CPDF_DocPageData::GetColorSpace() calling itself and CPDF_DocPageData::GetColorSpace() calling CPDF_ColorSpace::Load() and vice versa. They have not solved CPDF_ColorSpace::Load() calling itself. This CL repurposes the |pVisited| set to ensure CPDF_ColorSpace::Load() does not try to load a colorspace as a dependency of itself and creates |pVisitedLocal| to ensure CPDF_DocPageData::GetColorSpace() does not create a similar circular dependency not involving CPDF_ColorSpace::Load(). Bug: chromium:828206 Change-Id: Ib2d0ec494be169135607f3651e0f70627b26ebd7 Reviewed-on: https://pdfium-review.googlesource.com/29810 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-04-11Fix trailing whitespace handling in CPDF_StreamParser::ReadInlineStream()Tom Sepez
After advancing past whitespace, the buffer may become empty. We were checking too early. Bug: 831498 Test: covered by fuzzers Change-Id: I6796b4723a05c2bcafe495dc7bc648213aa9cc22 Reviewed-on: https://pdfium-review.googlesource.com/30191 Commit-Queue: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-11Avoid stack overflow when loading CPDF_Function.chromium/3395Henrique Nakashima
CPDF_StitchFuncs that reference each other create a Load() loop. Maintaining a set of the visited CPDF_Objects during a Load() call tree prevents that. Bug: chromium:830221 Change-Id: I6f494da16c6d79f05870ff85cff38ff8fe69ecfe Reviewed-on: https://pdfium-review.googlesource.com/30050 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-10Load CIDToGIDMap stream for CID fonts if it exists.Lei Zhang
BUG=chromium:813705 Change-Id: I57265aad11d8f717f6ce33cc09241f4bef6381db Reviewed-on: https://pdfium-review.googlesource.com/29710 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-10Change CFX_RenderDevice::FillRect() to take FX_RECT by const-ref.Lei Zhang
It currently takes const FX_RECT*, but the pointer is never nullptr. Change-Id: I571e9e8dd04756bc4daa25a61a5af8d1f902914b Reviewed-on: https://pdfium-review.googlesource.com/30052 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-09Use ByteStringView / pdfium::span in CPDF font as appropriate.chromium/3393Tom Sepez
Change-Id: I92c7ba605bf95a9023ad046b8dddebe0a0592802 Reviewed-on: https://pdfium-review.googlesource.com/29992 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-04-09Pass FX_RECT by const-ref in rendering code.Lei Zhang
Change-Id: I1232e6c61cbe696d90d87f461ebed0a7aea40893 Reviewed-on: https://pdfium-review.googlesource.com/29973 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-09Remove RenderDeviceDriverIface::GetCTM().Lei Zhang
It has no overrides and always returns the identity matrix. Many callers that use the returned value can be simplified, because they are scaling by 1 or concatenating an identity matrix. Change-Id: I7afb7214be210d02638644dfb9b58404420c2ef2 Reviewed-on: https://pdfium-review.googlesource.com/29972 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-09Cleanup CPDF_RenderStatus::GetObjectClippedRect().Lei Zhang
- Just return the rect directly and let the caller check for emptiness. - Get rid of a boolean parameter with always false argument. Change-Id: Ia33587db34c0a628047e59b7faa390c3ac57ec8a Reviewed-on: https://pdfium-review.googlesource.com/29971 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-09Use pdfium::span<> in CFX_BitStream, CPDF_SimpleParser.Tom Sepez
Get bounds checks in parsers automatically when using spans. Change-Id: I71fbe7b838435d455376db2f89817d807a9cdcfd Reviewed-on: https://pdfium-review.googlesource.com/29830 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-06Add span.h from chromium base.chromium/3392Tom Sepez
Allows indexing with better bounds-checking to occur. Some small modifications are required to deal with PDFium being intentionally held at C++11 compliance, not C++14. Use in one place as check on correctness. Change-Id: Id2875cf0a93980112bc536a93c4f9ec5306c0dac Reviewed-on: https://pdfium-review.googlesource.com/29671 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Chris Palmer <palmer@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-05Combine if/else blocks in CPDF_DIBSource::TranslateScanline24bpp().Lei Zhang
The two branches are very similar. Change-Id: I2a9502858e9ce997f28b17bc1051b71fa058c2c4 Reviewed-on: https://pdfium-review.googlesource.com/24350 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-05Split CPDF_DIBSource::TranslateScanline24bpp().Lei Zhang
Move some code into TranslateScanline24bppDefaultDecode(). Change-Id: I7e985c2abb9b2f9e41214531321f8f3846dd3a94 Reviewed-on: https://pdfium-review.googlesource.com/29857 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-05Fix const casts in CPDF_Encryptor.Lei Zhang
Change-Id: I4d7661716116969ae80fdac52f6b400a5ff68e50 Reviewed-on: https://pdfium-review.googlesource.com/29855 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-05Get rid of a const_cast in CPDF_FlateEncoder.Lei Zhang
Change-Id: I3ee8f8e9eb33d251dc00336bcd31e578e7ce5143 Reviewed-on: https://pdfium-review.googlesource.com/29854 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-05Remove some const_casts in CPDF_Creator.Lei Zhang
Change-Id: I7c639655c003527417255c134a4393d68cda3ef1 Reviewed-on: https://pdfium-review.googlesource.com/29852 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-04-05Ignore bad data in the shared object hint table.Lei Zhang
Currently this is being treated as a case of "data not available" which leads to an infinite loop. BUG=pdfium:1055 Change-Id: I2722a5b364d56a4ad5b7cca2a4b42e6b13a933f4 Reviewed-on: https://pdfium-review.googlesource.com/29831 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-03Re-arrange so inline vectors come last in structs.Tom Sepez
This might make the memory tools more effective in finding OOBs. Change-Id: Id093bb0a88c37954c80d612ac00b5a168e75bdbf Reviewed-on: https://pdfium-review.googlesource.com/29550 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-04-03Off-by-one in CPDF_StreamParser::ParseNextElement()Tom Sepez
Limit the token to 255 bytes + NUL. Also, shuffle fields in cpdf_streamparser to allow memory tools to better check this inline array. Bug: 828049 Change-Id: I444f2b4c6958167577d9cd76c06805baf7d5c26c Reviewed-on: https://pdfium-review.googlesource.com/29530 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-03-28Use CPDF_DefaultAppearance instead of custom parsingDan Sinclair
This CL moves code over to using CPDF_DefaultAppearance instead of calling the CPDF_SimpleParser directly. This means the code for finding a specific tag start can move into CPDF_DefaultAppearance directly. Change-Id: I1dc64e54aedd03d059b963121d466f3eb75c17db Reviewed-on: https://pdfium-review.googlesource.com/28410 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-03-28Use ByteStringView in parsersDan Sinclair
This CL converts the CPDF_SimpleParser to accept a ByteStringView. Several of the callers of SimpleParser are also updated to use a ByteStringView instead of <char*,size>. Change-Id: Ic2df3a06f92e77b53745a0419b44368142f9d8e6 Reviewed-on: https://pdfium-review.googlesource.com/29351 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-03-28Remove ByteString PDF_NameDecodeDan Sinclair
This CL removes the ByteString version of PDF_NameDecode and forces the callers to use the ByteStringView variant. Change-Id: I5a955d8e909e2045ee45843af54b23e98abe00ed Reviewed-on: https://pdfium-review.googlesource.com/29350 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-03-26Do not call CPDF_PageObjectList directly in fpdfeditpage.cpp.Henrique Nakashima
Change-Id: If816c4f532f03513ad06959182b0e0edfd688e39 Reviewed-on: https://pdfium-review.googlesource.com/29170 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-03-21Use more const pointers in CPDF_ContentMarkItem.Lei Zhang
Transitively mark the same pointers as const in callers. Change-Id: I1f9669b35c6d7f4b1a11c25163480bc687fbc7f8 Reviewed-on: https://pdfium-review.googlesource.com/28870 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-03-21Explain how CPDF_Page::GetDisplayMatrix() inverts y.Henrique Nakashima
Change-Id: Ia6e9fe790065d0bfd288d425c10d1dd9e0cf8c31 Reviewed-on: https://pdfium-review.googlesource.com/28850 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-03-21Change FXSYS_RGB() to FXSYS_BGR().Lei Zhang
Also change it from a macro to a constexpr function. Change-Id: I8b2bb42c45a23da6db136abdaee24132db4471c6 Reviewed-on: https://pdfium-review.googlesource.com/28579 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-21Rename one ArgbEncode() variant to AlphaAndColorRefToArgb().Lei Zhang
Mark the other ArgbEncode() variant as constexpr. Change-Id: I84207d805766e5efc669638bd8a15cfead356a41 Reviewed-on: https://pdfium-review.googlesource.com/28577 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-20Rename "RGB" methods/variables to "ColorRef" in CPDF_ColorState.Lei Zhang
Change-Id: I196e3148d680c9efeaf9609dd3ddbfe3f6635fa6 Reviewed-on: https://pdfium-review.googlesource.com/28576 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-16Fix methods that have definition with different parameter names.Lei Zhang
Found by ClangTidy. BUG=pdfium:1039 Change-Id: I2bb9256a63d5459e959c1a3228418073245d7a86 Reviewed-on: https://pdfium-review.googlesource.com/28731 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-03-15Create FPDFPage_RemoveObject().Henrique Nakashima
This call removes a page object from a page. We currently offer an API to insert these objects, but not to remove. Bug: pdfium:1037 Change-Id: I35ff596f9e7c87a39051f0cb1de40a5bec40fee5 Reviewed-on: https://pdfium-review.googlesource.com/28492 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-03-15Rename FX_COLORREF variables from "rgb" to "bgr".Lei Zhang
FX_COLORREF should work like win32 COLORREF, which is BGR. Change-Id: I9f8bb3e2d30a64dc822ac6b8c46130358a03678a Reviewed-on: https://pdfium-review.googlesource.com/28574 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-08Remove unused constructordan sinclair
Unused. Removed. Change-Id: I493a98b22c343d44834d3648e4ef2fe9978f88b1 Reviewed-on: https://pdfium-review.googlesource.com/28250 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-08Cleanup CPDF_SimpleParserdan sinclair
Minor code cleanup. Change-Id: Ibc3ea17d270de517058c41e9b466bc8fb042ecd7 Reviewed-on: https://pdfium-review.googlesource.com/28230 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-06Rename IFX classes in core/fxge to Ifacechromium/3364Dan Sinclair
This CL renames IFX classes in core/fxge to Iface. Change-Id: I137167ddd4ff1563d8002d9501222c27183408cc Reviewed-on: https://pdfium-review.googlesource.com/27990 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-03-06Rename core/fxcrt IFX files to IfaceDan Sinclair
This CL renames the 3 IFX files in core/fxcrt to Iface instead. Change-Id: I7cee6836650b71bc5c5729a8147fda62f0910fe3 Reviewed-on: https://pdfium-review.googlesource.com/27970 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-03-05Clean up CPDF_DIBSource.Lei Zhang
- Deduplicate code. - Rearrange some functions for early returns. Change-Id: I901d9041a42ff66002b1454193e5e122e5a379cd Reviewed-on: https://pdfium-review.googlesource.com/27810 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-05Make FPDFBitmap_GetFormat() work for JBIG images.Lei Zhang
BUG=pdfium:945 Change-Id: I2a880e747b6f5a2fabed4d34ce47b69ff589ce3f Reviewed-on: https://pdfium-review.googlesource.com/27814 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-05Use CPDF_DIBSource::LoadState enum class in more places.Lei Zhang
Change-Id: Iaf124c1b1ceca86d220ae654d9d18af7475209b6 Reviewed-on: https://pdfium-review.googlesource.com/27870 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-05Change CPDF_DIBSource::LoadJpxBitmap() to return a bitmap.Lei Zhang
Change-Id: If819bee4809142e2f9c9b0830f00264b0fbaf862 Reviewed-on: https://pdfium-review.googlesource.com/27852 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-05Change return types for some rendering Start/Continue methods.Lei Zhang
Either return a bool or a CPDF_DIBSource::LoadState. Explain what the bool return value means. Change-Id: I6346d0cd61d5faee5290df181cfff3b9e4d5d84e Reviewed-on: https://pdfium-review.googlesource.com/27851 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-05Add CPDF_DIBSource::LoadState enum class.Lei Zhang
Change-Id: I97819912e564e4b52fcdae4ce7f865188fb1a520 Reviewed-on: https://pdfium-review.googlesource.com/27850 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-02-22Add namespaces to duplicated Skia code.Jonathan Feinberg
When pdfium is imported into Google's internal repository, the recently copied Skia decimal formatting code causes only-defined-once violations because many Google internal projects depends on Skia through Google's own copy. This patch puts pdfium's private copy of the needed function into a namespace. Change-Id: Id102b17f6f4652e4a50c4ff75825468fc3d90727 Reviewed-on: https://pdfium-review.googlesource.com/27530 Reviewed-by: Hal Canary <halcanary@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-02-16Fix more fallthroughs before reenabling -Wimplicit-fallthrough.Henrique Nakashima
Change-Id: Ic1d5a250fc00d6767cee7eee1b2d74d5e1caa2bb Reviewed-on: https://pdfium-review.googlesource.com/27050 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-02-16Add ASSERT to check OOB m_CharCodesNicolas Pena
It seems m_CharCodes is in rare cases being corrupted, this CL adds ASSERTS to catch whether the corruption is due to out-of-bounds element access. Bug: 782215 Change-Id: I555ad1ccc2de3c35b2e06496f7216fba770f0759 Reviewed-on: https://pdfium-review.googlesource.com/27030 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-02-16Improve performance of writing path floats.Dan Sinclair
This CL copies the SkPDF code to convert floats into strings when writing back to PDF files. Change-Id: I8f8af3924a07aa67f93b9d951af1eef5d2c705db Reviewed-on: https://pdfium-review.googlesource.com/21990 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Hal Canary <halcanary@chromium.org>