summaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)Author
2017-12-05Replace uses of bsearch().chromium/3286Lei Zhang
Either switch to std::lower_bound(), or brute force when the search space is very small. Change-Id: I54db346aeb6f2e8000e95a6a9c8fbdd512df500a Reviewed-on: https://pdfium-review.googlesource.com/20431 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-12-05Replace bsearch() in FPDFAPI_CIDFromCharCode().Lei Zhang
Use std::lower_bound() instead. Change-Id: I0bed2a90f3aa427a283cd86a050a027ec7a64358 Reviewed-on: https://pdfium-review.googlesource.com/20430 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-05Remove redundant field in struct FXCMAP_CMap.Lei Zhang
Change-Id: Ibac6398b5849820562830bb8ed95c3428496f7ef Reviewed-on: https://pdfium-review.googlesource.com/20410 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-12-05Avoid integer overflows in CPDF_FixedMatrix::Transform().Lei Zhang
Use floating point math and saturated_cast to calculate the transform. Refactor CFX_BilinearMatrix::Transform() to share common code, instead of using integer math and CheckedNumerics. BUG=chromium:791048 Change-Id: Ib3812b3b3b9373a8eb3b1dde12cb28d424e0bb3e Reviewed-on: https://pdfium-review.googlesource.com/20390 Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-12-04Simplify some CFX_FloatRect methods.chromium/3285Lei Zhang
Also add a comment about the various CFX_FloatRect to FX_RECT conversion methods. Change-Id: Ia9984797dc513cdc487fe9972b32c216c9f99ec1 Reviewed-on: https://pdfium-review.googlesource.com/20217 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-12-04Simplify color calculations in CFX_ImageTransformer.Lei Zhang
Change-Id: I14e614dbd0b7c1187b686bf574d14b94f04a3e7e Reviewed-on: https://pdfium-review.googlesource.com/20271 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-04Simplify code in CFX_ImageTransformer.Lei Zhang
Also fix lint errors. Change-Id: Iaf5fb440fd43d5c36b00630e16d700827c09fc7f Reviewed-on: https://pdfium-review.googlesource.com/20270 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-04Refactor CFX_ImageTransformer down sample calculations.Lei Zhang
Change-Id: Ib3aa0b6ce2fa7b2a643068cb9ffcaca9fe18d3de Reviewed-on: https://pdfium-review.googlesource.com/20258 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-04Refactor CFX_ImageTransformer bicubic calculations.Lei Zhang
Change-Id: I47c0ae6dbdf339ab7ade36b141c220b8a3fb2274 Reviewed-on: https://pdfium-review.googlesource.com/20257 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-04Refactor CFX_ImageTransformer bilinear calculations.Lei Zhang
Change-Id: Ia38329bf5622c0ae6f5c4173332d2140de08c567 Reviewed-on: https://pdfium-review.googlesource.com/20256 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-04Break out CFX_ImageTransformer color calculations.Lei Zhang
Change-Id: I5d3a01310bd5fcddbb8c39025b07a2e83ddae84f Reviewed-on: https://pdfium-review.googlesource.com/20255 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-04Break out CFX_ImageTransformer mono calculations.Lei Zhang
Change-Id: Ibd9ca20e902bbd2b62af12d25836497413912b1b Reviewed-on: https://pdfium-review.googlesource.com/20254 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-04Add text unit to glyph unit conversion to CPDF_Type3Char.Lei Zhang
Use it in type 3 font code. Change-Id: I8b0eb462cc0308f1700d21a62efc929babae8e20 Reviewed-on: https://pdfium-review.googlesource.com/20215 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-12-04Break out CFX_ImageTransformer alpha calculations.Lei Zhang
Change-Id: I4f221d5d6c17e8507f87d9c63b87431cc2b8f45e Reviewed-on: https://pdfium-review.googlesource.com/20253 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-04Fix nits in CPDF_Type3Font.Lei Zhang
Change-Id: Ib922184ee844e66a0b29f49025e83e13eb81fdb8 Reviewed-on: https://pdfium-review.googlesource.com/20214 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-12-04Break out CFX_ImageTransformer mask calculations.Lei Zhang
Change-Id: Iab7ff29c2ce9ed56715b5897e89da2d9d693583c Reviewed-on: https://pdfium-review.googlesource.com/20252 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-04Add functions for common code in CFX_ImageTransformer.Lei Zhang
Change-Id: I556934f61f24883e684865e4a8fc5e0519248cee Reviewed-on: https://pdfium-review.googlesource.com/20251 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-12-01Get rid of else after break/continue/return.chromium/3284chromium/3283Lei Zhang
Change-Id: I3efc57cd7325d16e3ca8ebdeeaec06012b2c56e3 Reviewed-on: https://pdfium-review.googlesource.com/20110 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-12-01Check for success of decodes to avoid infinite loopsNicolas Pena
Bug: 790693 Change-Id: I9b1d87e024229d8b01f55ec554e2cc544db6ac06 Reviewed-on: https://pdfium-review.googlesource.com/20230 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2017-12-01Add CFX_FloatRect::ToRoundedFxRect().Lei Zhang
Unlike ToFxRect(), which floors the LBRT values. Also fix some nits. Change-Id: I0680eebb09031807a14402ca30b13558ea5b56d9 Reviewed-on: https://pdfium-review.googlesource.com/20213 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-12-01Add CFX_FloatRect::Scale().Lei Zhang
Unlike ScaleFromCenterPoint(), Scale() just scales the LBRT values. Also add unit tests for CFX_FloatRect::Normalize(). Change-Id: Iebf48fa9adcf47adff3255b157d3e3056f3687fc Reviewed-on: https://pdfium-review.googlesource.com/20212 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-12-01Rename CFX_FloatRect::Scale() to ScaleFromCenterPoint().Lei Zhang
Change-Id: I6baab14c989e8ae692ed1c846b135af95c09ce37 Reviewed-on: https://pdfium-review.googlesource.com/20210 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2017-12-01Remove unused CFX_FloatRect::Substract4().Lei Zhang
Change-Id: I08706f53bf3960cbea60b09a1702bf0ba371f1ce Reviewed-on: https://pdfium-review.googlesource.com/20211 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-12-01Add some CFX_FloatRect unit tests.Lei Zhang
Change-Id: I32cc3cb0a8a987980b900a5650cc051cb50dd1cc Reviewed-on: https://pdfium-review.googlesource.com/20190 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-12-01Remove unneded structs from CFX_CTTGSUBTable part 2Nicolas Pena
This CL continues removing structs from CFX_CTTGSUBTable Change-Id: I1ede1e3e736f87292b6119406fd5f12a0bb7e7cb Reviewed-on: https://pdfium-review.googlesource.com/20170 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2017-12-01Encapsulate CPDF_Type3Char members.Lei Zhang
Change-Id: Iec4e999d76dabc9b6cd00323881c5c87afc5f629 Reviewed-on: https://pdfium-review.googlesource.com/19930 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-11-30Rewrite lower level details of extracting text from pageRyan Harrison
The current implementation of text extraction was difficult to understand, duplicated logic that existed in other methods, and wasn't clear about the units the inputs were in. It also didn't handle control characters correctly. The new implementation leans on the methods for converting indices between the text buffer index and character list index spaces to avoid duplication of code. It also makes it clear to the reader that inputs are in the character list index space. Finally, it fixes issues being seen in Chrome with respect of ranges being slightly off. This CL also adds a test for extracting text that has control characters. BUG=pdfium:942,chromium:654578 Change-Id: Id9d1f360c2d7492c7b5a48d6c9ae29f530892742 Reviewed-on: https://pdfium-review.googlesource.com/20014 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2017-11-30Fix GBK2K-H CMap usage.Lei Zhang
The data used is clearly a CID Range, but the code was interpreting it as single CID values. Change-Id: Ibb68f5ca2150d74b007a64ef5daa412fd542cecd Reviewed-on: https://pdfium-review.googlesource.com/17650 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-11-30Use initializer list in CPDF_DataAvail ctor.Lei Zhang
Or initialize members in the header. Also make m_dwFileLen member const. Change-Id: Iaaeab9a93e18e4ab313437362c0012d729b01647 Reviewed-on: https://pdfium-review.googlesource.com/9970 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-11-30Relax checks in CFX_FaceCache::LoadGlyphPath().Lei Zhang
The original fix to https://crbug.com/641333 was too strict. Relax the checks and use a std::tuple for the path map key, instead of trying to "hash" a key. BUG=chromium:788864 Change-Id: I6e6a96691bce2834c2e95baa16ebd39e6aa03140 Reviewed-on: https://pdfium-review.googlesource.com/19950 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-11-30Prevent integer overflow in CJBig2_HuffmanTable::ParseFromCodedBufferNicolas Pena
In this CL we prevent integer overflow by checking that the integers are in the appropriate range before casting from unsigned to signed. Bug: 789524 Change-Id: I41572849f18ffb0f0739c80130ee6b5061845d29 Reviewed-on: https://pdfium-review.googlesource.com/20011 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2017-11-30Run clang-tidy google-readability-casting on //third_party/pdfiumDan Sinclair
See the bugs and cxx post for justification and details: https://groups.google.com/a/chromium.org/forum/#!topic/cxx/RkOHzIK6Tq8 This change was done using clang-tidy as described here: https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_tidy.md Bug: chromium:776257 Change-Id: Iebab34f3ee97a6249e4517d1f5dec1971c36fcba Reviewed-on: https://pdfium-review.googlesource.com/19973 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-11-30Run clang-tidy modernize-use-auto on //third_party/pdfiumDan Sinclair
See the bugs and cxx post for justification and details: https://groups.google.com/a/chromium.org/forum/#!topic/cxx/RkOHzIK6Tq8 This change was done using clang-tidy as described here: https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_tidy.md Bug: chromium:776257 Change-Id: I1f6637cde8b3e41825993a736bed6763dd7beacb Reviewed-on: https://pdfium-review.googlesource.com/19971 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-11-30Run clang-tidy modernize-use-equals-{delete,default} on //third_party/pdfiumDan Sinclair
See the bugs and cxx post for justification and details: https://groups.google.com/a/chromium.org/forum/#!topic/cxx/RkOHzIK6Tq8 This change was done using clang-tidy as described here: https://chromium.googlesource.com/chromium/src/+/lkcr/docs/clang_tidy.md In some cases the the tool leaves behind a string of commas where it replaced a member initializer list (https://bugs.llvm.org/show_bug.cgi?id=35051). They were cleaned up with: git diff --name-only | \ xargs sed -E -i 's/(^\s*|\)\s*):[ ,]*= default/\1 = default/' Bug: chromium:778959, chromium:778957 Change-Id: I23e60d3d6c8bc9e8574d425710a0441cb5510d6b Reviewed-on: https://pdfium-review.googlesource.com/19970 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-11-29Allow building pdfium against the system version of libpng.Andrew Weintraub
Bug: Change-Id: I0c930ca30637f58af3b60ed8f1383bd9234a1723 Reviewed-on: https://pdfium-review.googlesource.com/19850 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-11-29Remove CollectionSize from fx_bidiDan Sinclair
Bug: pdfium:774 Change-Id: I2056583c270f1bb0046250ce2ec53a2cbe46b893 Reviewed-on: https://pdfium-review.googlesource.com/19672 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-11-29Remove unneded structs from CFX_CTTGSUBTable part 1Nicolas Pena
This CL removes some useless structs from CFX_CTTGSUBTable. Change-Id: Iaf8b58d70b36d77fea73946c6b4279b15f5726e8 Reviewed-on: https://pdfium-review.googlesource.com/19710 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2017-11-28Remove CollectionSize from string_view_templateDan Sinclair
Bug: pdfium:774 Change-Id: Id993864c4ae009e686c62e7be13e2db5d8cb4170 Reviewed-on: https://pdfium-review.googlesource.com/19572 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-11-28Remove CollectionSize from JBig2_ContextDan Sinclair
Bug: pdfium:774 Change-Id: Ie7674ac55dea6284a0d974cef107ef357197a06b Reviewed-on: https://pdfium-review.googlesource.com/19610 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-11-27Make ConvertBuffer_* voidchromium/3279Nicolas Pena
This CL makes the helper methods 'ConvertBuffer_'* in CFX_DIBSource void since they always succeed. Change-Id: I55dd714bec5ccc3695cd0bbebcf978d767acc53a Reviewed-on: https://pdfium-review.googlesource.com/19650 Commit-Queue: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-11-27Convert CFX_GifContext::GetFrameNum to size_tDan Sinclair
This CL removes the CollectionSize and updates call locations as needed. Bug: pdfium:774 Change-Id: I813c500b3a17a194407ceb1304252b9b16fe1779 Reviewed-on: https://pdfium-review.googlesource.com/19590 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-11-27Convert CPDF_StructTree to size_tDan Sinclair
This CL removes the use of CollectionSize from CPDF_StructTree and uses size_t in the callers. Bug: pdfium:774 Change-Id: I860a51a533642c949c497ca26e74ba064a8aa9ba Reviewed-on: https://pdfium-review.googlesource.com/19530 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-11-27Change FPDF_GetText to return "" when asked to get 0 charactersRyan Harrison
BUG=chromium:788103 Change-Id: I8ebdbc78eb14c358d7ac019b96de4828e6071b79 Reviewed-on: https://pdfium-review.googlesource.com/19350 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-11-27Prepend ++ in CFX_DIBSourceNicolas Pena
In this CL, we do some nit cleanup and change many var++ to ++var in CFX_DIBSource. Change-Id: I2379e6e15688cbde68415adc47b01114ad0785c1 Reviewed-on: https://pdfium-review.googlesource.com/19570 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
2017-11-27Convert CPDF_StructElement::CountKids to size_tDan Sinclair
This CL changes CountKids to not used CollectionSize and returns size_t directly. Callers updated as needed. Bug: pdfium:774 Change-Id: I8862218e62cd13be9473fa8116afd29cd3afde04 Reviewed-on: https://pdfium-review.googlesource.com/19510 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-11-27Remove CollectionSize from CPDF_RenderStatusDan Sinclair
Bug: pdfium:774 Change-Id: I4996f5526884c33d92df964045bd5467c392df5e Reviewed-on: https://pdfium-review.googlesource.com/19490 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-11-27Remove CollectionSize from CPDF_CharPosListDan Sinclair
Bug: pdfium:774 Change-Id: I7ebbcb17374b4117f92b94edbd8bcba18efe6313 Reviewed-on: https://pdfium-review.googlesource.com/19470 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-11-27Remove CollectionSize from FPDF_DataDecodeDan Sinclair
Bug: pdfium:774 Change-Id: I3fcde6fba46d21affa63d79fab2d83f47c9c5f84 Reviewed-on: https://pdfium-review.googlesource.com/19450 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-11-27Convert CPDF_TextObject to not use CollectionSizeDan Sinclair
This CL updates various methods in CPDF_TextObject to return or received size_t values. Callers have been updated as needed. Bug: pdfium:774 Change-Id: Id72511bc74637c6261add39f5414c9a4b8390b82 Reviewed-on: https://pdfium-review.googlesource.com/19430 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2017-11-27Convert CPDF_ClipPath::Get{Path|Text}Count to size_tDan Sinclair
This CL updates the various call sites to use size_t instead of other types. Bug: pdfium:774 Change-Id: Id8b75728b61c0ca1b15bc815831c885d33374f7b Reviewed-on: https://pdfium-review.googlesource.com/19410 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>