summaryrefslogtreecommitdiff
path: root/core/fpdfapi/page
AgeCommit message (Collapse)Author
2018-05-09Mark numerious pointers as const.Lei Zhang
They are mostly CPDF_Object* and derived classes, but others that should be are marked const as well. Change-Id: Ib3344d7d8db90940df8edc97c0dd6c59da080541 Reviewed-on: https://pdfium-review.googlesource.com/32180 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-05-09Add constants for PDF 1.7 spec, table 7.13.Lei Zhang
BUG=pdfium:1049 Change-Id: I3a589fe51f2e584dc130ba31faa144d4494a1b08 Reviewed-on: https://pdfium-review.googlesource.com/32179 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-08Remove almost all usages of CFX_FixedBufGrow with std::vectorNicolas Pena
Tested by running safetynet_compare.py on this patch vs master. The results were 0 regressions and 0 improvements. The two remaining usages cannot be replaced because they would cause a regression. Bug: pdfium:177 Change-Id: I43eddf4ffaac2eb063f2004d6606bc3cd6e627ac Reviewed-on: https://pdfium-review.googlesource.com/32159 Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-05-08Remove PDFTRANS_KNOCKOUT.Lei Zhang
No code actually checks to see if it is set. Change-Id: I37631713d568f116df1c0495ffd7d7d64ddce69a Reviewed-on: https://pdfium-review.googlesource.com/32186 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-08Add constants for PDF 1.7 spec, table 7.2 and 7.3.Lei Zhang
Add constants/transparency.h. The header lists constants from chapter 7 of the PDF spec. BUG=pdfium:1049 Change-Id: I66bd6fceb24807eec9c308e2e47cec3f2f836ffb Reviewed-on: https://pdfium-review.googlesource.com/32177 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-08Make one more CPDF_PageObjectHolder member protected.Lei Zhang
Change-Id: Id9288d504f063759f69632ab59b0a21569ff76d8 Reviewed-on: https://pdfium-review.googlesource.com/32113 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-07Make more CPDF_PageObjectHolder members protected.Lei Zhang
Change-Id: Id31b9f6ac33971c47cdb378ff7f9ca7d33f899b9 Reviewed-on: https://pdfium-review.googlesource.com/32112 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-07Make CPDF_PageObjectHolder::m_iTransparency protected.Lei Zhang
Also initialize members in the header. Change-Id: Id814c4c5042c9d4989fa92b78f68c17f4949f09d Reviewed-on: https://pdfium-review.googlesource.com/32111 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-07Add some getters for CPDF_PageObjectHolder.Lei Zhang
Change-Id: I3fe99ecb17d37f893ce5d0d59219c82ee31fe7ea Reviewed-on: https://pdfium-review.googlesource.com/32110 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-07Use unowned ptr for CPDF_Page::m_pView.Tom Sepez
Change-Id: I9d87cefc18a3a468e1bec797bc7711194f6444c7 Reviewed-on: https://pdfium-review.googlesource.com/32155 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-05-03Add CPDF_Page::Extension::GetDocExtension()Tom Sepez
In turn, add CPDF_Document::Extension::GetPDFDoc() so that we can use the abstract return type in more places. Mark an internal-only cpdfxfa_context method as private while we're at it. Change-Id: I08e64f4b9438bf2f731c3a37cf2a41152bbbd8fa Reviewed-on: https://pdfium-review.googlesource.com/31916 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-03Make GetPDFDocument return a CPDF_Docment*, not void*.Tom Sepez
Small oversight. Gets type safety. Change-Id: I669c2c990fdf9013f4bc4835738132ed76e734b8 Reviewed-on: https://pdfium-review.googlesource.com/31991 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-01Avoid perpetual spins for parserless CPDF_PagesTom Sepez
This is an obstacle to introducing dummy CPDF_Pages to underly all CPDFXFA_Pages, since we would then have a parserless CPDF_Page, whose parse could never succeed or fail. The m_ParseState would never change, and if the caller dutifully recalls us until that changes, we hang. Small separate CL since it might impact non-XFA cases unexpectedly. Change-Id: I002064e5d4caa44935f50bde0f3b00e3b8cb0bfe Reviewed-on: https://pdfium-review.googlesource.com/31850 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-05-01Introduce the concept of CPDF_Page::ExtensionTom Sepez
Similar tp CPDF_Document::Extension, this is a base type for fpdfsdk/ to use to improve layering. While we're at it, make pages point to documents to prove they don't outlive them. Another small step towards not passing XFA objects across FPDF. Change-Id: Idcee9da3a18c06331fa56f3d6c188e4ce27d34f2 Reviewed-on: https://pdfium-review.googlesource.com/31631 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-04-27Do validation earlier in CPDF_SampledFunc::v_Init(). (try 2)Lei Zhang
This time, correctly multiply |nTotalSampleBits| before checking it. Change-Id: I68befeedb54626314f7bb00a35e567d2cbf1cc10 Reviewed-on: https://pdfium-review.googlesource.com/31152 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-25Introduce ScopedFPDF types in public/cpp/fpdf_scopers.hTom Sepez
Applies std::remove_ptr to the public API types so that we can deduce a correct unique ptr type no matter how that API might change away from void* usage. Creates shorter names for std::unique_ptr<std::remove_pointer<>, ...> Change-Id: I04a0ff43cb7d5a4d3867939a53a54c9cef00db86 Reviewed-on: https://pdfium-review.googlesource.com/31292 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-04-23Validate the Size dictionary entry in CPDF_SampledFunc.Lei Zhang
It is required to be an array of positive integers. The existing implementation seems to accommodate non-compliant PDFs where the Size entry is an integer. Change-Id: I58faa3f84ca627f189c67bab5884d4b1f9b105ca Reviewed-on: https://pdfium-review.googlesource.com/31151 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-23Fix some nits in CPDF_SampledFunc().Lei Zhang
Change-Id: I54aae3c65ded779f1421b8f971a187979e5a204b Reviewed-on: https://pdfium-review.googlesource.com/31150 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-20Add CPDF_PatternCS::GetPatternRGB(const PatternValue& value).chromium/3404chromium/3403chromium/3402Lei Zhang
Currently, one gets data from CPDF_PatternCS via its parent class's GetRGB(const float* pBuf) method. To squeeze through this interface, the caller has to pass in a float*, and CPDF_PatternCS::GetRGB() has to cast it to PatternValue*. Instead of doing casting, add a specialized GetPatternRGB() method to CPDF_PatternCS. In its parent class, CPDF_ColorSpace, add AsPatternCS() so callers can get a CPDF_PatternCS* from a CPDF_ColorSpace*. Change existing callers to use these new methods. Change-Id: Id476c9ece7ce8d3499a718acc682bc25036a5407 Reviewed-on: https://pdfium-review.googlesource.com/31030 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-20Revert "Do validation earlier in CPDF_SampledFunc::v_Init()."Lei Zhang
This reverts commit 54e6da1ee793f436341dfcdc4e0c26b0658d1928. Reason for revert: Checks not ordered correctly. Original change's description: > Do validation earlier in CPDF_SampledFunc::v_Init(). > > Change-Id: Ib44b39aea419230f73583caf69313a2f92557397 > Reviewed-on: https://pdfium-review.googlesource.com/30932 > Commit-Queue: Lei Zhang <thestig@chromium.org> > Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> TBR=thestig@chromium.org,hnakashima@chromium.org Change-Id: I133ca5add12c173dd05ef995b5834c3058d814cd No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://pdfium-review.googlesource.com/31050 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-19Make CPDF_StitchFunc use more vectors.Lei Zhang
Change-Id: Iaa3988cea5cdc6ce723c59ad051800925216d81b Reviewed-on: https://pdfium-review.googlesource.com/30990 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-19Do more validation in CPDF_StitchFunc::v_Init().Lei Zhang
Change-Id: I8eeaf62947960d8774cb129be145fae157feb70e Reviewed-on: https://pdfium-review.googlesource.com/30970 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-19Do a bit more validation in CPDF_ExpIntFunc::v_Init().Lei Zhang
Also do some cleanup and use FX_SAFE_UINT32. Change-Id: I8e9fc49fb768cfc4b13b164c1dcf51b8ca99ec0b Reviewed-on: https://pdfium-review.googlesource.com/30934 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-19Do validation earlier in CPDF_SampledFunc::v_Init().Lei Zhang
Change-Id: Ib44b39aea419230f73583caf69313a2f92557397 Reviewed-on: https://pdfium-review.googlesource.com/30932 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-19Validate the Range key in Functions.Lei Zhang
They are required for type 0 and type 4 functions. The number of outputs should not be 0. Change-Id: I4cb1fa14a32ef0a1c92230d83461c697f389106f Reviewed-on: https://pdfium-review.googlesource.com/30931 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-17Use span<> in GetBits32().Tom Sepez
Get bounds checking "for free". Change-Id: Ic60d63836f6c223e2ee1262649d47da54bb30ecc Reviewed-on: https://pdfium-review.googlesource.com/30876 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-04-17Re-land "Return pdfium::span<char> from ByteString::GetBuffer().""Tom Sepez
This reverts commit 3d523e3cf89440e2ffc6571b1c687ad5e3f0318f. Fixes bounding errors now caught by tests. Change-Id: I4d0f1791bdcc45a10615a62abf7a4d20e7e538f2 Reviewed-on: https://pdfium-review.googlesource.com/30799 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-17Add constants for PDF 1.7 spec, table 3.4.Lei Zhang
Add constants/stream_dict_common.h. The header lists all the constants in the table in the same order. Constants that are not used at all are commented out. BUG=pdfium:1049 Change-Id: I6539090e0ad56319ea628883e388aeacef044e52 Reviewed-on: https://pdfium-review.googlesource.com/29090 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-17Fix nits in CPDF_Function and derived classes.Lei Zhang
- Switch away from FX_Alloc2D() when it is safe to do so. - Use FX_SAFE_SIZE_T to avoid a potential underflow with FX_Realloc(). - Mark the v_Call() input as const. - Check Call() and v_Call() return results. Change-Id: I6ec3122b23e0f137f88aa8d85a9675154a1b1706 Reviewed-on: https://pdfium-review.googlesource.com/30802 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-16Remove non-const CPDF_PageObjectHolder::GetPageObjectList().Henrique Nakashima
This makes it easier to control modifications to the page object list. Bug: pdfium:1051 Change-Id: Ia85c597fa6d39e89041b990b4b6c91e327ef811d Reviewed-on: https://pdfium-review.googlesource.com/30803 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-04-16Fix some checks for FX_Realloc() failures.Lei Zhang
FX_Realloc() never fails. So either remove the check or switch to FX_TryRealloc(). Change-Id: I11fd02508add50db900a7502835018c2b61bcd09 Reviewed-on: https://pdfium-review.googlesource.com/30712 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-16Consolidate Black/Whitepoint parsing code CPDF_ColorSpace.Lei Zhang
Also use more constants. Change-Id: I02cb74d5ef5a44b1772d826be63ceb64b167c0db Reviewed-on: https://pdfium-review.googlesource.com/21913 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-16Put prototypes of PDF_NameEncode/Decode in fpdf_parser_utility.hTom Sepez
Because the implementations are in fpdf_parser_utility.cpp Add unit test for both. Change-Id: Ibae90ecbe625a035c450614ddbe7f5969f9f92aa Reviewed-on: https://pdfium-review.googlesource.com/30793 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-04-16Consolidate BlackPoint parsing code in CPDF_ColorSpace.Lei Zhang
Validate the values as well. Change-Id: I9c87ae9f67650f1f384b3e8a6ca80ea2f411fe50 Reviewed-on: https://pdfium-review.googlesource.com/30796 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-16Add Black/WhitePoint array constant in CPDF_ColorSpace.Lei Zhang
Change-Id: I7068735efc6ac41420901e068dbd40f684bb88b8 Reviewed-on: https://pdfium-review.googlesource.com/30795 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-16More CPDF_Colorspace cleanup.Lei Zhang
- Mark subclass members as private. - Use more constants. Change-Id: Idc2bcb7dd2af3908d0ce1389d6832f3d6c434766 Reviewed-on: https://pdfium-review.googlesource.com/30794 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-16Revert "Return pdfium::span<char> from ByteString::GetBuffer()."Tom Sepez
This reverts commit 80a6cbe0a427e155de8555bc867af745d10f9777. Reason for revert: too many abrts in beta branch. TBR: dsinclair@chromium.org Bug: 832557, 832978, 832992, 833062, 833097 Change-Id: I7d511dbb224ddc644be96ea2f3770ad6f73debf5 Reviewed-on: https://pdfium-review.googlesource.com/30792 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-16Fix some nits in CPDF_ColorSpace.Lei Zhang
Change-Id: I23c8e82c31db0a5a0ed4cbe2131452a26492109b Reviewed-on: https://pdfium-review.googlesource.com/30714 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-16Fix a comment in CPDF_PatternCS.Lei Zhang
Change-Id: I276c726d0d657a23ac7a2202c2a5d1772d58c392 Reviewed-on: https://pdfium-review.googlesource.com/30713 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-13Add test for circular CPDF_Function::Load().Henrique Nakashima
Bug: chromium:830221 Change-Id: Ia96086a1b930600a4fb9054123c867d1c8b301eb Reviewed-on: https://pdfium-review.googlesource.com/30671 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-04-13Add CPDF_ColorState::SetPattern().Lei Zhang
A common helper method for patterns, just like SetColor(). Change-Id: Iba6a9b33143d2d1278d05bbc2ce7e26b0ae5d197 Reviewed-on: https://pdfium-review.googlesource.com/30591 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-13Get rid of CPDF_Color::GetColorSpace().Lei Zhang
Replace it with more narrowly focused methods to get specific bits from the colorspace. Change-Id: Ifd2980f0fd06230d4d94d28eddf72219d2e9e6eb Reviewed-on: https://pdfium-review.googlesource.com/30590 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-13Rename the other CPDF_Color::SetValue() variant.Lei Zhang
Rename it to SetValueForNonePattern() and combine the components parameters into a std::vector. Fix the callers to use std::vector as well. Change-Id: I0edd7e7876e47b56821e63cc5073fc21fd4098ee Reviewed-on: https://pdfium-review.googlesource.com/30470 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-12Rename one CPDF_Color::SetValue() variant.Lei Zhang
Rename it to SetValueForPattern() and combine the components parameters into a std::vector. Fix the callers to use std::vector as well. Change-Id: Ib3426e0ffdb164f0fbb10d462ad251bf91165925 Reviewed-on: https://pdfium-review.googlesource.com/30450 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-12Make some CPDF_StreamContentParser methods const.Lei Zhang
Change-Id: Idd1d865741bb487647fa823846ea5751245ed86a Reviewed-on: https://pdfium-review.googlesource.com/30453 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-04-12More CPDF_Color improvements.Lei Zhang
Make Copy() take a const-ref parameter. As is, the parameter is a pointer and it is dereferenced without any checks, and there are no crash reports as a result of that. Also mention GetPattern() should only be called when IsPattern() returns true. Change-Id: Ice3b7c941532d5a312fdd8f0c032e08d1ee1c6b5 Reviewed-on: https://pdfium-review.googlesource.com/30430 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-12Slightly simplify CPDF_Color::SetColorSpace().Lei Zhang
All the callers pass in a valid colorspace. SetColorSpace() is the only caller to CPDF_ColorSpace::GetDefaultColor(). Also adjust that method to make it harder to use incorrectly. Change-Id: I5cf7b6d2abef630e1b9443043b13d1c2b5bed18a Reviewed-on: https://pdfium-review.googlesource.com/30351 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-12Return pdfium::span<char> from ByteString::GetBuffer().Tom Sepez
Get bounds checking "for free". Change-Id: I7b14cacbc7130ced7b5cb1869b82c96ccff8e642 Reviewed-on: https://pdfium-review.googlesource.com/30451 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-04-12Make the input data to CPDF_ColorSpace::GetRGB() const.Lei Zhang
Make a copy of the input data when clamping it in CPDF_Function::Call(). Change-Id: I1d2b3d080977f0f9a4c3ccaf111780867668991a Reviewed-on: https://pdfium-review.googlesource.com/30350 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-04-12Change CPDF{XFA}_Page::PageToDevice() to take a CFX_PointF.Lei Zhang
Instead of taking two doubles. The doubles get casted to floats anyway. Change-Id: Ie16dc60fa5d6412026a5fda08c8c64d4fa2d56c4 Reviewed-on: https://pdfium-review.googlesource.com/30410 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>