summaryrefslogtreecommitdiff
path: root/core/fpdfapi
AgeCommit message (Collapse)Author
2018-08-17Use more UnownedPtr<> in cpdf_renderstatus.h.chromium/3526Tom Sepez
This immediately flags a case where a pointer from a heap object to a caller's stack object is persisted past the caller's lifetime. Fix it the simplest way via AutoRestorer<> so we'll get a nice safe segv should it be used. Change-Id: I554304b235e73c279fa0cd79c9e3ee0138be45f9 Reviewed-on: https://pdfium-review.googlesource.com/40592 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-17Add FPDFText_GetFontInfoNicolas Pena
Bug: pdfium:929 Change-Id: I9da03a1e317cff69ec4c76b69289cfa753b6bb77 Reviewed-on: https://pdfium-review.googlesource.com/40531 Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2018-08-16Remove optional bool bType from GetFillArgb()Tom Sepez
Two variants make the intention much clearer. Change-Id: Ied0d8e6fa8c5524c19cafe8036d7c1b470fda86d Reviewed-on: https://pdfium-review.googlesource.com/40352 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-16Remove more optional args in core/Tom Sepez
Change-Id: I6a2bd03e00ad4e3d57f6931c0c6cf4ae0c760afb Reviewed-on: https://pdfium-review.googlesource.com/40290 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-15Make CPDF_RenderStatus::Initialize() saner.Tom Sepez
Move mandatory arguments to ctor. Replace long list of positional parameters with setter methods. Make Initialize() return void since it can't fail. Change-Id: I490118923855158891cf45eecd5de1e922a3a1fe Reviewed-on: https://pdfium-review.googlesource.com/40170 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-14Remove default args from CPDF_DIBSource::StartLoadDIBSource().Tom Sepez
Change-Id: I13f53f581487f643acf160f53d02e9af7d54cfd1 Reviewed-on: https://pdfium-review.googlesource.com/40151 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-14Remove unreachable vertical text code in CPDF_Document.Lei Zhang
Change-Id: I64b34da202a0f1c30a38cba2f24490aad4063828 Reviewed-on: https://pdfium-review.googlesource.com/40150 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-14Remove unused form/args of AddWindowsFont()Tom Sepez
Change-Id: I38b508b5518568ff134b70e0e494e5267571c1ca Reviewed-on: https://pdfium-review.googlesource.com/40110 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-14Add CPDF_Type1Font::IsBase14Font() to replace GetBase14Font().Lei Zhang
IsBase14Font() is what its only caller really needs. Also use it in Load() which does the same check, and restructure Load() to have an early return. Change-Id: I1d051d10b80aa82bcf590c79169ffe29607b3c13 Reviewed-on: https://pdfium-review.googlesource.com/39970 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
2018-08-14Remove CFX_BufferSeekableReadStream.Lei Zhang
Replace it with CFX_ReadOnlyMemoryStream, which does the same thing. Take some checks from CFX_BufferSeekableReadStream and add them CFX_ReadOnlyMemoryStream. Change-Id: I25554c3aec3ec96967f8df16ca68a64dba121b6f Reviewed-on: https://pdfium-review.googlesource.com/40070 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-14Remove more default arg = nullptr cases.Tom Sepez
Bring in line with standards. Remove argument entirely for mac code that is always nullptr. Change-Id: I0710bdbd51fc0bc2e1d428ef44976be39a631147 Reviewed-on: https://pdfium-review.googlesource.com/40091 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-14Remove |bTakeOver| parameter from CFX_MemoryStream ctor.Lei Zhang
It is always true now. BUG=pdfium:263 Change-Id: I74fd0091f5815701718e8cd5acc6e7a0de772a85 Reviewed-on: https://pdfium-review.googlesource.com/40031 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-13Make CFX_ReadOnlyMemoryStream take a span.Lei Zhang
Change-Id: Id097320ab2d9b5d1579582e5797e29c701499501 Reviewed-on: https://pdfium-review.googlesource.com/39991 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-08-13Change CFDF_Document::ParseMemory() to use pdfium::span.Lei Zhang
Change-Id: I1e9b02f0cb2628d41bc1c6bdcfcfa09c36faf97e Reviewed-on: https://pdfium-review.googlesource.com/39990 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-13Use CFX_ReadOnlyMemoryStream in more places.Lei Zhang
More const pointers, less const_casts. BUG=pdfium:263 Change-Id: I47fc6d8f2f837390e40ad22d8b67946065294eaa Reviewed-on: https://pdfium-review.googlesource.com/39879 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-13Mark CPDF_Font::GlyphFromCharCodeExt() and friends Mac only.Lei Zhang
Change-Id: I4906351a6e21fb8480670a6daf15bd7cb9e441c5 Reviewed-on: https://pdfium-review.googlesource.com/39911 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
2018-08-11Cleanup CFX_CTTGSUBTable.chromium/3521chromium/3520Lei Zhang
Do all the parsing inside the constructor. Make GetVerticalGlyph() and related getters const methods. Change-Id: I21118cf98048cb6bbfc0999604d2434d4acafef6 Reviewed-on: https://pdfium-review.googlesource.com/39496 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
2018-08-11Initialize CPDF_CIDFont members.Lei Zhang
Given POD members default values, rather than hoping Load() will. Also reorder members to pack better. Change-Id: I493db11eb3d115e49f4e914e53a1eb55fa2046f0 Reviewed-on: https://pdfium-review.googlesource.com/39495 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
2018-08-11Simplify CPDF_SimpleFont::LoadPDFEncoding().Lei Zhang
Remove parameters that always refer to the same member variables. Also mark the input object as const since it is only read from. Change-Id: I136ece1ce5b0c00b02d1a76e1540ff26e6f01858 Reviewed-on: https://pdfium-review.googlesource.com/39494 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org>
2018-08-10Kill some optional parameters that are always supplied.Tom Sepez
No need to even bring any .cpp files in line with these headers. Change-Id: I934169d77ae09adc11f02e5ea92b1f8b078c9477 Reviewed-on: https://pdfium-review.googlesource.com/39876 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-10Remove unused form of PDF_EncodeText().Tom Sepez
Perform indexing via WideString::operator[] which will at least assert bounds, if not enforce them. Change-Id: I7b03cfd718c4acd642af910c2ca06f86d178e5fd Reviewed-on: https://pdfium-review.googlesource.com/39873 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-10Make the 4th parameter in CPDF_Form non-optional.Lei Zhang
Instead, add a 3-parameter constructor that delegates to the 4-parameter constructor. Change-Id: Ied6c55360084ea26b07dbaa449bf155b5db182f0 Reviewed-on: https://pdfium-review.googlesource.com/39872 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-10Minor cleanup in CPDF_ContentParser.Lei Zhang
Add more asserts and use more constants. Change-Id: I51f1d9d1b501f4e99d9793b6c803676b7221be17 Reviewed-on: https://pdfium-review.googlesource.com/39871 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-10Make CPDF_PSFunc::m_PS mutable.Tom Sepez
Preferred over const_cast<> to show how that state is used. Change-Id: Ia6fe6bf46fb7fa8e701481b1604073b5d7f222fa Reviewed-on: https://pdfium-review.googlesource.com/39870 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-10Remove const args and const_casts where not required.Tom Sepez
Introduce const/non-const versions of method where required. Part of the war on const_cast<>. Tidy one expression to use [] instead of .data(). Change-Id: I41e45669c79eee242ff2244c7dc3afcf6386a433 Reviewed-on: https://pdfium-review.googlesource.com/39852 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-10Remove direct calls to timechromium/3519Ryan Harrison
Replaces them with calles to the proxy function, FXSYS_time, so that tests may use a stable time value instead of the wall clock value. BUG=pdfium:1104 Change-Id: I4743c4634f56d4a6cba1f1130c4562a35cee1887 Reviewed-on: https://pdfium-review.googlesource.com/39853 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-08-10Consolidate const_casts<> in FXFT_Get_Name_Index()Tom Sepez
There's a missing const in a qualifier in the third party FT library header, so rather than casting on every invocation, consolidate these into our wrapper macro. This may be easier to remove should the API ever get corrected. Part of the war on const_cast<>. Change-Id: I80cdb220730f40297e54aee10acc8bbd2c983b6d Reviewed-on: https://pdfium-review.googlesource.com/39850 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-10Add CFX_DIBSource::GetWritableScanline().Tom Sepez
Remove a bunch of const_cast<uint8_t*> or equivalent. This will also help when we convert to span<>, since casting spans is a nuisance. Change-Id: I330e5041cbaf33a84425fc4242a3dfacf5ca8011 Reviewed-on: https://pdfium-review.googlesource.com/39831 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-09Change CPDF_Font::GetNextChar()'s in-out parameter to pass by pointer.chromium/3518Lei Zhang
Instead of passing by non-const reference. Adjust the override in CPDF_CIDFont and CPDF_CMap::GetNextChar() as well. Change-Id: I0ee6dc21077101cbeeb0e334498075fc463a2d65 Reviewed-on: https://pdfium-review.googlesource.com/39492 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-09Revert "Rework of CPDF_Parser::GetLastObjNum."Lei Zhang
This reverts commit b07deb3fc1f54bd700a66df573bfcbc4bcc1d787. Reason for revert: Causing https://crbug.com/870467 Original change's description: > Rework of CPDF_Parser::GetLastObjNum. > > 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> TBR=thestig@chromium.org,art-snake@yandex-team.ru # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: I58e23c752a582c21be8ba45e3538e63c0fa64504 Reviewed-on: https://pdfium-review.googlesource.com/39810 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-08Move ByteString::FromUnicode() to WideString::ToDefANSI()Tom Sepez
Turns out that "FromUnicode" is misleading in that, on linux, it simply removes any characters beyond 0xFF and passes the rest unchanged, so no unicode decoding actually takes place. On Windows, it passes it into the system function specifying FX_CODEPAGE_DefANSI, converting it into the so-called "default ANSI code plane", passing some characters, converting others to '?' and still others to 'A'. Either way, nothing resembling UTF8 comes out of this, so pick a better name. These now immediately look suspicious, so a follow-up CL will see which ones should really be WideString::UTF8Encode() instead. Making this a normal method on a widestring rather than a static method on a bytestring feels more natural; this is parallel to the UTF8Encode and UTF16LE_Encode functions. Add a test that shows these conversions. Change-Id: Ia7551b47199eba61b5c328a97bfe9176ac8e583c Reviewed-on: https://pdfium-review.googlesource.com/39690 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-07Move CPDF_Font::LoadPDFEncoding() to CPDF_SimpleFont.Lei Zhang
It is not used in the CPDF_Font base class. Change-Id: I6033a5dd422179eb95f19a2f2ecf06d007f3223f Reviewed-on: https://pdfium-review.googlesource.com/39493 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-07Change CPDF_Font::GetFace() to HasFace().Lei Zhang
Callers do not actually need the returned handle. Change-Id: I1b8c0be00809eb7fdae9f6e95b4b325e75f4b847 Reviewed-on: https://pdfium-review.googlesource.com/39491 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-07Make CPDF_Font::GetFontBBox() return the bounding box.Lei Zhang
Instead of using an out parameter. Fix nits in the only caller as well. Change-Id: I04eb92705b2fbda001191c36da972eee499acbc7 Reviewed-on: https://pdfium-review.googlesource.com/39490 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-06Avoid invalid object numbers in CPDF_Parser::LoadCrossRefV5().chromium/3515Lei Zhang
BUG=chromium:865272 Change-Id: I4606bdfd78ebd6553c36b985b4f49d07b579ac40 Reviewed-on: https://pdfium-review.googlesource.com/39438 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Art Snake <art-snake@yandex-team.ru>
2018-08-06Check for null object type in CPDF_Parser::LoadCrossRefV5().Lei Zhang
BUG=chromium:871042 Change-Id: Id4566b29270ab738c69d46cb96fc134485d6ee2f Reviewed-on: https://pdfium-review.googlesource.com/39510 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-06Do more CPDF_Parser::LoadCrossRefV5() cleanup.Lei Zhang
- Use range for-loop to avoid needing "i" and "j". - Avoid repeatedly calculating "startnum + j". - Reduce levels of nested ifs. - Remove variable that is only used once. Change-Id: I9d08cef1082812fcfaa2699f65720165c52ebcff Reviewed-on: https://pdfium-review.googlesource.com/39437 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-04Use more text object state in DrawTextPathWithPattern().chromium/3514chromium/3513chromium/3512Lei Zhang
BUG=chromium:668762 Change-Id: Iaf3fc9bcf68b8da2c947bbd78c5d72f78195b621 Reviewed-on: https://pdfium-review.googlesource.com/35991 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-04Clarify integer types in CPDF_Parser::LoadCrossRefV5().Lei Zhang
GetVarInt() returns uint32_t. So assign the results to variables of type uint32_t. Then make sure those results get passed on as uint32_t, or use pdfium::base::IsValueInRangeForNumericType<T>() to make sure they can be converted to type T safely. Change-Id: I4556f0b89b4e5cdb99ab530119c8051ec8a9411d Reviewed-on: https://pdfium-review.googlesource.com/39436 Reviewed-by: Art Snake <art-snake@yandex-team.ru> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-08-04Set the CPDF_Font doc / font dict in the ctor.Lei Zhang
Then we can mark the doc pointer as const because it never changes again. Also move initialization to headers when possible, add missing dtors, and fix some nits. Change-Id: I461affc8dce14d805b935fb4d8b5aaafb058a789 Reviewed-on: https://pdfium-review.googlesource.com/39413 Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Commit-Queue: 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-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-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-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-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-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-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-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>