summaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)Author
2018-08-02Use more helper macros/methods in JBig2_Image.cpp.Tom Sepez
Bundling the test with the accessor is a safer pattern than performing the check externally. Add test for CopyLine(). Change-Id: I7056bf33bdca40cb84a89e4928567a389d88ff1c Reviewed-on: https://pdfium-review.googlesource.com/39431 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-02Fix some nits in SkiaState.Lei Zhang
Change-Id: Id52bb57efea2a6a46bea645e4f3e54957982a40b Reviewed-on: https://pdfium-review.googlesource.com/39154 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-02Skia Path: Fix text/xform size mismatch when calling drawTextRSXform().Lei Zhang
BUG=chromium:751423 Change-Id: I2fcc46b80e89cb651e255bd1fd2d6883a05cf9c7 Reviewed-on: https://pdfium-review.googlesource.com/39153 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-02Tidy JBig2_Image.cppchromium/3511Tom Sepez
Add checked/unchecked GetLine(y) methods and use them. Introduce BIT_INDEX_TO_ALIGNED_BYTE() to de-mystify some shifting. Move local declarations to spot of use. Remove spurious Fill(), as we initialize to 0s. Initialize members in header where possible. Add unit tests. Change-Id: I41ccb91b57320dbc790fd0f680f6d98571280343 Reviewed-on: https://pdfium-review.googlesource.com/39370 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-02Rework of CPDF_DataAvail::CheckHintTables.Artem Strygin
Move HintTables parsing logic into CPDF_HintTables. Change-Id: I9748179fe9fc3ac44f88c19c347e30c0e7e3ac67 Reviewed-on: https://pdfium-review.googlesource.com/38771 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-08-02Introduce JBIG2_PUTDWORD() macro in CJBIG2_Image.hTom Sepez
Provide symmetry with JBIG2_GETDWORD(). Avoid potential illegal undefined signed shift in JBIG2_GETDWORD(). Get better column alignment under cl-format via pointless shift by zeros for consistency. Change-Id: I13d46fe7976074e26df72b58a055788390191364 Reviewed-on: https://pdfium-review.googlesource.com/39430 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-02Remove some checks in IsLinearizedHeaderValid().Lei Zhang
One check can never fail. The other check can be done earlier, before creating the CPDF_LinearizedHeader. Change-Id: I0bccb2a9e19e0d5517daf96684adba6bb3a203bf Reviewed-on: https://pdfium-review.googlesource.com/39412 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-02Rework of CPDF_Parser::GetLastObjNum.Artem Strygin
Change-Id: I0481774858a9d9823580e1207807e35be8a9eea9 Reviewed-on: https://pdfium-review.googlesource.com/36270 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-08-01Bounds check lineSrc in JBig2_Image.cpp.Tom Sepez
No matter how the dimensions might be determined, we know the hard end of the source line, and can use it for a bounds check. We expect the size is quantized to a multiple of m_stride, so as long as each block operates within an m_stride, the initial check should be sufficient. Bug: 867501 Change-Id: Iaf9936557b856f3eb09fef522f3e6738aa4f38f0 Reviewed-on: https://pdfium-review.googlesource.com/39310 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-30Check maximum bit count of shared group object numbers.Artem Strygin
Bug: chromium:868477 Change-Id: I5957c5ef051bc4fa8eb51efa6a7fc142996742c5 Reviewed-on: https://pdfium-review.googlesource.com/39130 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-07-28Add ToXML{Instruction,Text,CharData}() checked conversion functionsTom Sepez
All usages were previously checked correctly, but this consolidates some code as well. Change-Id: I63711748b31b698a3f21f98fdb536db1e9e0b1cf Reviewed-on: https://pdfium-review.googlesource.com/39010 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-27Make pdfium_embeddertests pass on Windows 10.Lei Zhang
BUG=chromium:828177 NOTRY=true Change-Id: I30123087bbe11aaaa6175b5f729b7ab55107a975 Reviewed-on: https://pdfium-review.googlesource.com/38902 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-07-27Merge several methods into JBig2GrdProc::DecodeArithTemplateUnoptchromium/3505Nicolas Pena
This CL merges DecodeArithTemplateXUnopt for X=0,1,2. This is similar to how three methods were merged into DecodeArithOpt3. Change-Id: Ib0d4f14de6a8c924517d82eaec7577961503a325 Reviewed-on: https://pdfium-review.googlesource.com/38935 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-07-27Parse obj nums range within Hint tables for shared groups.Artem Strygin
Change-Id: Ib22db6c57d2066ef70c0ef12e44d1e5eee6611a5 Reviewed-on: https://pdfium-review.googlesource.com/36410 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-26Use moar ToXMLElement() in place of static_cast<>.Tom Sepez
Introduces checks in a few new places, but mainly just consolidates checking/casting logic. Change-Id: I634a03060d254db099972c6978249992367e146c Reviewed-on: https://pdfium-review.googlesource.com/38900 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-25Remove some ASSERT (and cast) in favor of checked cases.Tom Sepez
Because it is a stronger pattern at runtime. These were found by essentially: grep -ni '\bassert\b.*type' Change-Id: I913d77139053e8980528597a6633e1859e5204c4 Reviewed-on: https://pdfium-review.googlesource.com/38890 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-25Use incomplete type CFX_BmpContext in place of void*chromium/3503Tom Sepez
Allows killing off static_cast<> in two places. Change-Id: I467b69d92e8cbda5c2916b6ed2e97c173d8b4f2f Reviewed-on: https://pdfium-review.googlesource.com/38897 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-25Change GetHeaderOffset() to return Optional<FX_FILESIZE>.Lei Zhang
Remove |kInvalidHeaderOffset|. Change-Id: I5978e745e97aa4e13299dd21028721725ac0c996 Reviewed-on: https://pdfium-review.googlesource.com/38853 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Art Snake <art-snake@yandex-team.ru>
2018-07-25Create popup with Contents only for same annotations subtypes.Henrique Nakashima
The subtypes are listed in "PDF Reference 1.7", page 617. Bug: chromium:856331 Change-Id: I41d6094949ff22007a72ef7c1493c413c5af5f7b Reviewed-on: https://pdfium-review.googlesource.com/38790 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-07-25Remove CFX_MemoryStream uses in tests.Lei Zhang
Replace with CFX_BufferSeekableReadStream, which allows for spans and const inputs. Change CXFA_DocumentParser to take IFX_SeekableReadStream instead of IFX_SeekableStream in the process. Change-Id: I0168451350c9fc250231f0414c38738a4d86ca42 Reviewed-on: https://pdfium-review.googlesource.com/38852 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-07-25Use struct {Single,Range}Cmap in FPDFAPI_CIDFromCharCode().Tom Sepez
Clearer that just using indexing off of raw pointers, and makes the code more closely resemble other functions. Change-Id: I7cc8363b505e66120bc1c686bb23b2bdf8fc401f Reviewed-on: https://pdfium-review.googlesource.com/38894 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-25Change CFX_BufferSeekableReadStream to take a span.Lei Zhang
Change-Id: Ib9e20fdfc637b2ba0358586e23ad72454b0b8ad1 Reviewed-on: https://pdfium-review.googlesource.com/38851 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-07-25Only build cfx_fileaccess_windows.cpp on Windows.Lei Zhang
- Remove #if guards in the .cpp file and flip the #if guard in the header to produce an error when incorrectly included. - Do the same for cfx_fileaccess_posix.cpp. - Also remove forward declarations for win32 APIs. Change-Id: I81056ea6198d342e62744bd3240b3a28ac53d5c0 Reviewed-on: https://pdfium-review.googlesource.com/38410 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-25Move CPDF_SyntaxParser init methods into ctor.Lei Zhang
- CPDF_SyntaxParser can no longer be initialized multiple times. - Make the file length and header offset const. - Make the header offset type FX_FILESIZE consistently. - Simplify for the common case where the header offset is 0. Change-Id: I7138db1fbcec3b7578b0239b92fc1154fa4dc4ce Reviewed-on: https://pdfium-review.googlesource.com/38850 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-25Introduce ToXMLElement() checked downcast helper functionTom Sepez
And use it in place of ASSERT() that the type was correct. Since we can check it, doing so at runtime may help avoid type confusion, and we'll get a nice safe SEGV if the asserted condition ever fails. Change-Id: I46b65a4b70e819a670d7cad7966e0d100f0d9a63 Reviewed-on: https://pdfium-review.googlesource.com/38810 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-25Fix hint tables parsing.Artem Strygin
Sample PDF: https://yadi.sk/d/oWLtAEfy3YbEb3 For offsets, equal to the hint stream offset, added hint stream length to determine the actual offset, because linearization inserted the hint stream at the original location of the object. Also the number of bits needed to represent the numerator of the fractional position for each shared object reference may be zero, if each shared group contains only one object with obj num, incremented on 1. Change-Id: I4754d603f388354821e8d0cac97ad99a7578fe4b Reviewed-on: https://pdfium-review.googlesource.com/36610 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-25Use document size instead of file size while parsing.Artem Strygin
We should use document size instead of File size, because all offsets and sizes was read from document should take into account of header offset. Added some tests of parsing of documents with header offset. Also drop friendship of CPDF_SyntaxParser with CPDF_Parser. Change-Id: Iebec75ab2ee07fb644a6c653b4ef5c2e09af09fe Reviewed-on: https://pdfium-review.googlesource.com/35830 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-24Fix encryption dictionary owning.Artem Strygin
Return encryption dictionary as const reference from CPDF_Parser. Create a copy in CPDF_Creator if needed. Change-Id: I270f71d307d818fba7f65ebe379f5942ae816934 Reviewed-on: https://pdfium-review.googlesource.com/38390 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-07-23Rework of CPDF_Object writing.Artem Strygin
Move writing logic into implementation of related clases. Change-Id: If70dc418b352b562ee681ea34fa6595d6f52eee3 Reviewed-on: https://pdfium-review.googlesource.com/36350 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-07-23Add support of rebuilding crossrefs with compressed objects.Artem Strygin
Change-Id: I0743c34f0206f85828570430edb9f62b6b0cdbb5 Reviewed-on: https://pdfium-review.googlesource.com/37315 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-07-20Rework of CPDF_Parser::RebuildCrossRef.chromium/3498Artem Strygin
Use CPDF_SyntaxParser logic to rebuild crossref. Change-Id: I394f64e76294b97c6a7c2b8984a880712fd193a7 Reviewed-on: https://pdfium-review.googlesource.com/37314 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-07-19Make FX stream internal details more private to .cpp files.Tom Sepez
Makes the generic fx_streams.h header pull in lots less OS-specific cluter. Combine and de-virtualize the windows struct. Change-Id: I836b9efb00b25dbd1b8f814645dd31a0f04bb4f4 Reviewed-on: https://pdfium-review.googlesource.com/38330 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-18Add pdfium::span::as_bytes() and as_writable_bytes().Tom Sepez
Picks up some enhancements from base/span.h. In turn, also adds the size_bytes() helper. Differs from base version in that it works around C++14 enable_if_t<>, and avoids the dynamic_extent template specialization tricks. Use it in a few places where appropriate. Change-Id: I86f72cf0023f2d4317a7afa351fddee601c8f86c Reviewed-on: https://pdfium-review.googlesource.com/38251 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-18Use casts to deduplicate implementation of const/non-const methods.Henrique Nakashima
Change-Id: Ia5a4e89bff8a1dbc46246f5a734170765b7ee74e Reviewed-on: https://pdfium-review.googlesource.com/38250 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-07-18Fix skia_paths build.Henrique Nakashima
The SkColorSetARGBInline alias was removed, use simply SkColorSetARGB instead. Bug: pdfium:11 Change-Id: I8636e305cf938df9427d01a6ca63b3d492a087f3 Reviewed-on: https://pdfium-review.googlesource.com/38252 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-07-18Do not add invalid objects to the cross reference table.chromium/3496Lei Zhang
BUG=chromium:851994 Change-Id: I2e14401271c70afa204221e0f3d469f0b82ce8cf Reviewed-on: https://pdfium-review.googlesource.com/37871 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Art Snake <art-snake@yandex-team.ru>
2018-07-18Avoid writing const/non-const versions of the same function.Lei Zhang
Use const_cast for the non-const version to call the const version. Change-Id: Ibdf5fe53255ee6e983555080336f5d63e683afd1 Reviewed-on: https://pdfium-review.googlesource.com/37490 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-18Use CPDF_CrossRefTable within CPDF_ParserArtem Strygin
Change-Id: I354e8bed12606abdc67427bbc7928e3b1f11e243 Reviewed-on: https://pdfium-review.googlesource.com/35433 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-18Make CPDF_Parser::GetTrailer const method.Artem Strygin
Use own copy of encryption dictionary within CPDF_Parser, to prevent modification of original trailer. Change-Id: I6246b872d431b94411fcec694c5176f8d85dfe26 Reviewed-on: https://pdfium-review.googlesource.com/35450 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-18Improve image size validation in CPDF_ScaledRenderBuffer.Lei Zhang
In CPDF_ScaledRenderBuffer::Initialize(), use the existing CFX_DIBitmap::CalculatePitchAndSize() function to figure out the pitch and size. Unlike the existing code, CalculatePitchAndSize() does a better job of checking for integer overflows. BUG=pdfium:1123 Change-Id: Ic8fe7226bc56fed0456486d88e02a7af2928bc94 Reviewed-on: https://pdfium-review.googlesource.com/38010 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-07-18Simplify CPDF_Creator::InitID().Lei Zhang
Remove checks for impossible conditions. Change-Id: I7a6607675899bfde6179e93da0c9139dfec19984 Reviewed-on: https://pdfium-review.googlesource.com/38070 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-16Fix some nits in CPDF_Document.Lei Zhang
Change-Id: I57f89b9f2a8ef3f351e7574a76d6064ffde150d3 Reviewed-on: https://pdfium-review.googlesource.com/37870 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-16Remove unused member from CPDF_DataAvail.Tom Sepez
Change-Id: I3686bd3d28a84aae39c750a371902e1e5d62b365 Reviewed-on: https://pdfium-review.googlesource.com/37050 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-16Get rid of some loose allocs/free in CPDF_Document.chromium/3494Tom Sepez
Use std::vector<> as a manager for contiguous buffers. Change-Id: Icaacbd4b7010b928237aa71485411ade7539412a Reviewed-on: https://pdfium-review.googlesource.com/37012 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-14Use more ternary operators in content mark code.chromium/3493chromium/3492Lei Zhang
Change-Id: Ibf09905523ae2d80ce48bfe7337733d8dc718669 Reviewed-on: https://pdfium-review.googlesource.com/37850 Commit-Queue: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-07-13Create API to remove a content mark from a page object.Henrique Nakashima
- FPDFPageObj_RemoveMark() Bug: pdfium:1037 Change-Id: I7ff320261d64e3ead45375ccc72301e7c64dd6e3 Reviewed-on: https://pdfium-review.googlesource.com/37710 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-07-13Fix mark parameters not saved if nothing changed.Henrique Nakashima
Bug: pdfium:1037 Change-Id: Ia2cd0d6ef99495dda3289988123489e3a2ad6e82 Reviewed-on: https://pdfium-review.googlesource.com/37750 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-07-12Rename 'ori' to 'backdrop' in rendering code.Lei Zhang
Change-Id: I6fa3fd93638bc3aeaaef854676fe31476888433b Reviewed-on: https://pdfium-review.googlesource.com/37671 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-12Remove CPDF_HintTables::GetItemLength()Artem Strygin
Commit {Insert later} removed the last caller to this method. Change-Id: I1689b33486396cc3a41139f984f819b39ab02b2a Reviewed-on: https://pdfium-review.googlesource.com/35130 Commit-Queue: Art Snake <art-snake@yandex-team.ru> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-07-12Implement CPDF_HintsTable::SharedObjGroupInfo.Artem Strygin
Merge shared objects related data into CPDF_HintsTable::SharedObjGroupInfo. Change-Id: I53bb7fc42ea6bcd26b3ebf91b8c6aa402108d086 Reviewed-on: https://pdfium-review.googlesource.com/15830 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>