summaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)Author
2018-03-20Simplify code in CPDF_TextPage.Lei Zhang
- Augment/reuse existing NormalizeThreshold() function. - Use std::min() / std::max(). Change-Id: I709e246c58bf8a69638e1d77dcc2a79ae8a27e77 Reviewed-on: https://pdfium-review.googlesource.com/28736 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-03-20Change ArgbToColorRef() to ArgbToAlphaAndColorRef().chromium/3377Lei Zhang
Since that is what it really returns. Add a replacement ArgbToColorRef() that only returns a FX_COLORREF, and remove a duplicate implementation. Then update callers and only use ArgbToAlphaAndColorRef() where appropriate. Also update comments to explain what FX_COLORREF is. Change-Id: I5ed3d71683898dc2b3a66395dea0ec2562c14a68 Reviewed-on: https://pdfium-review.googlesource.com/28575 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-03-19Calculate AP for multi-line markup annotations correctlyRalf Sippl
Currently, when constructing AP for multi-line markup annotations, we only take into account the first set of quadpoints, resulting in only the first line of the annotation being displayed if the annotation spans multiple lines. This CL, initially written by Jane Liu <janeliulwq@google.com> (https://pdfium-review.googlesource.com/12010) takes into account all the quadpoints, so multi-line annotations can be displayed correctly. BUG=pdfium:876 Change-Id: I8be10ee38e01eb6525ddef556df1b727189455c7 Reviewed-on: https://pdfium-review.googlesource.com/28590 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-03-19Remove non-const ref parameters in CPDF_TextPage.Lei Zhang
Change-Id: Ia6cb19269ef93440669b68d76c3c378a5d4da7a5 Reviewed-on: https://pdfium-review.googlesource.com/28735 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-03-19Remove redundant code in CPDF_TextPage::CountRects().Lei Zhang
CountRects() calls GetRectArray(), which performs the same calculation. Change-Id: I79dcd8e82f6d0fe7ed992da06237f31d0761a902 Reviewed-on: https://pdfium-review.googlesource.com/28734 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-03-19Avoid crashing in FPDFText_CountRects() for invalid start values.Lei Zhang
BUG=chromium:821305 Change-Id: I371572f60ea3984ce044e25125d882b3c2d03115 Reviewed-on: https://pdfium-review.googlesource.com/28733 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-03-19Avoid crashing in FPDFText_CountRects() for negative count values.Lei Zhang
Treat values less than -1 as -1. BUG=chromium:821305 Change-Id: Ieaced045473fa51097400e5af1286f0d3f4d0143 Reviewed-on: https://pdfium-review.googlesource.com/28732 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@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-16Make more variables const-ref.chromium/3373Lei Zhang
Found by ClangTidy. BUG=pdfium:1040 Change-Id: I6d7cb26ae2d12f5650f73596d0b991234b076f57 Reviewed-on: https://pdfium-review.googlesource.com/28712 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-03-15Add a CFX_PathData::AppendRect() variant.chromium/3372Lei Zhang
One that takes a CFX_FloatRect instead of LBRT floats. Use it where appropriate. Change-Id: I8ba19e86c61c91d8b4ef685b5cb65c8fb717f013 Reviewed-on: https://pdfium-review.googlesource.com/28581 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-15Fixing order of guards to avoid potential segvsRyan Harrison
Per tspepez's drive by: str, in theory, might not be terminated, and might have been allocated right up to a guard page at the end of the heap, say, so that str[len] could segv. Change-Id: I6cba7b6d12b23f69e6f150c1b5296df65c2e0086 Reviewed-on: https://pdfium-review.googlesource.com/28610 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@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-15Use Width()/Height() methods from rectangles.Lei Zhang
Change-Id: I07f4363046be920816e8d0dae766c7af833284db Reviewed-on: https://pdfium-review.googlesource.com/28582 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-15Fix a red-blue channel flip when rendering masks to EMF.Lei Zhang
Use BGR instead of RGB in CGdiDeviceDriver::GDI_StretchBitMask(). Many win32 GDI APIs take COLORREF as input, and COLORREF is BGR. In this case, a win32 API was being called with RGB data. BUG=chromium:821672 Change-Id: Ia530c7ef5582eed13ac7119935851cfe0ad57323 Reviewed-on: https://pdfium-review.googlesource.com/28573 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-15Cleanup CStretchEngine.Lei Zhang
- Make members const. - Change some ints to enum classes. - Add helper function to calculate pitch. Change-Id: I32f94e1189d54a2c365530166fb5c9c0857b7c97 Reviewed-on: https://pdfium-review.googlesource.com/28571 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-14Fix bad return value in WideString::Compare().chromium/3371Lei Zhang
When comparing L"a" vs L"ab", the return value should be -1 or 1, not 0 or 1. Add a regression test for this case. BUG=chromium:821454 Change-Id: I38e2d7ca62319b7a62f8d8afeb231b8ed3bd9e86 Reviewed-on: https://pdfium-review.googlesource.com/28570 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-14Fix blend mode in generated APRalf Sippl
When adding an annotation, an appearance stream (AP) is generated. According to the PDF spec, the Subtype, Type and BM entries it contains should be names rather than strings. Type should be set to XObject. BUG=pdfium:1038 Change-Id: I0131eec33c257ab3a3a48c7e0dfeac5ca8dfbe2b Reviewed-on: https://pdfium-review.googlesource.com/28550 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-03-13Remove usage of FXSYS_*ASCIIlower/upper methodschromium/3370Ryan Harrison
This replaces them with equivalent FXSYS_*wlower/upper methods, which uses ICU to perform the correct Unicode operations. BUG=pdfium:1035 Change-Id: I432db5bef9eda71762016b619d93155949d054db Reviewed-on: https://pdfium-review.googlesource.com/28530 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-03-12Remove all usages of FXSYS_iswASCIIspacechromium/3369Ryan Harrison
This replaces it with FXSYS_iswspace, which uses ICU to perform correct Unicode space checking. BUG=pdfium:1035 Change-Id: I7a4ed01a6b50f56a6f9d1434a7f0b01596fe42db Reviewed-on: https://pdfium-review.googlesource.com/28510 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-03-12Fix crash when creating a CFX_DIBitmap with FXDIB_Invalid.Henrique Nakashima
Bug: chromium:820885 Change-Id: I3886c636b91a8499924d95ad47f4c832db9f9754 Reviewed-on: https://pdfium-review.googlesource.com/28491 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Henrique Nakashima <hnakashima@chromium.org>
2018-03-12Remove all usages of FXSYS_iswASCIIalphaRyan Harrison
Instances are either replaced with FXSYS_iswalpha, which calls out to the ICU library to do the proper Unicode operations, or have been converted to a isascii && isalpha pair, if ASCII alpha is actually what was wanted. BUG=pdfium:1035 Change-Id: I971ff639ee1ff818ad08793a1900a8bcbb0a3e04 Reviewed-on: https://pdfium-review.googlesource.com/28450 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-03-12Remove all usages of FXSYS_iswASCIIalnumRyan Harrison
Instances are either replaced with FXSYS_iswalnum, which calls out to the ICU library to do the proper Unicode operations, or have been converted to a isascii && isalnum pair, if ASCII alnum is actually what was wanted. BUG=pdfium:1035 Change-Id: I959ec8739a4d020e61562180393ab8113a81577c Reviewed-on: https://pdfium-review.googlesource.com/28430 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-03-09Cleanup CPDF_DefaultAppearancedan sinclair
Minor cleanups and refactoring of the CPDF_DefaultAppearance class. Change-Id: I7b3de021e8a6a1e9ca1d70ae413f3c433627f3fd Reviewed-on: https://pdfium-review.googlesource.com/28390 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-09Remove default params from CPDF_DefaultAppearance methodschromium/3368chromium/3367dan sinclair
This CL removes default params from CPDF_DefaultAppearance methods. Change-Id: Iaeebc7b35ebb6140850f3f0e0828c3ae9e3c5548 Reviewed-on: https://pdfium-review.googlesource.com/28350 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-03-09Explicitly mark helper methods that only operate on ASCII rangesRyan Harrison
A number of our character helper methods take in wide character types, but only do tests/operations on the ASCII range of characters. As a very quick first pass I am renaming all of the foot-gun methods to explictly call out this behaviour, while I do a bigger cleanup/refactor. BUG=pdfium:1035 Change-Id: Ia035dfa1cb6812fa6d45155c4565475032c4c165 Reviewed-on: https://pdfium-review.googlesource.com/28330 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-09Remove unused methods from CPDF_DefaultAppearancedan sinclair
Methods unused. Removed. Change-Id: I059b1e321b7d57f631368b77ace1d62cb75596c8 Reviewed-on: https://pdfium-review.googlesource.com/28310 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-08CPDF_InterForm::ResetForm always returns truedan sinclair
This method always returns true, so remove the return value. Change-Id: I3da93fc5face39a53b589787873839c06c9fcfab Reviewed-on: https://pdfium-review.googlesource.com/28210 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-08Convert Before{Selection|Value}Change to return a boolchromium/3366dan sinclair
Both of these IPDF_FormNotify methods return {-1, 0, 1} but all callsites only care about < 0 and >= 0. Convert to return a bool that treats the 0 and 1 case as the same. This also makse sense in terms of the API because false means validation failure. The case where 0 was used was a place holder for we didn't try for this field type, which also implicitly means validation passed. Change-Id: I0950c678191b83caffd755d4a87b2f0efee71c89 Reviewed-on: https://pdfium-review.googlesource.com/28192 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-08Remove BeforeFormImportData and BeforeFormResetdan sinclair
Both of these IPDF_FormNotify callbacks have empty implementations which just return 0. Removed. Change-Id: I3324113222f19d2f7a2323ab5086e446d2064451 Reviewed-on: https://pdfium-review.googlesource.com/28191 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-03-08Remove uncalled AfterFormImportDatadan sinclair
The IPDF_FormNotify::AfterFormImportData method is never called. Removed. Change-Id: I0c436193a0af7bc94077bb719e48682bbf7a9b2b Reviewed-on: https://pdfium-review.googlesource.com/28190 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-03-01Break up CFX_DIBSource::ConvertBuffer().Lei Zhang
Change-Id: If93b4782016c7f27c1533417d019f3271c807941 Reviewed-on: https://pdfium-review.googlesource.com/27813 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-03-01Fix some nits in CFX_DIBSource::CloneConvert().Lei Zhang
Change-Id: I25c16b7159d168bd6deb4fd9936bb242d7e8c590 Reviewed-on: https://pdfium-review.googlesource.com/27812 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-02-26Shrink some tables and kill dead code in xfa.Tom Sepez
Change-Id: Ic1260417e7d1475dd518655b2ab08f0184955d88 Reviewed-on: https://pdfium-review.googlesource.com/27170 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-02-26Get rid of some static variables.Tom Sepez
These are generally cheap enough to compute as needed, rather than keeping around in memory all the time (plus the memory for the static flag the compiler generates to check if initialized). Change-Id: If3a5365521f6a7781e66fb11f04883a5c673ee11 Reviewed-on: https://pdfium-review.googlesource.com/27150 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-02-26Add some more missing consts.chromium/3356Tom Sepez
Get things out of the .data section. Change-Id: I375cf00186a3d5d8d10f5d147bd4b692f5db3683 Reviewed-on: https://pdfium-review.googlesource.com/27130 Commit-Queue: Tom Sepez <tsepez@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-16Correct mapping text to characters for characters missing from fontRyan Harrison
When parsing text streams there is an internal character list that is generated of all the characters in the stream. Additionally a text string is generated that is exposed via the public API. This string will have all of the printing, i.e. non-control characters, in it. For characters that are not in the font of the stream the unicode, but printable, the character 0xFFFE is used in the text to indicate a missing character. This a non-printing character to indicate non-unicode. The internal character list gets a Unicode value 0x0 when there isn't a glyph in the font for it and the original character code is preserved. This means that when generating the mapping between text string and character list, the code is mistakenly thinking that the unprintable character was not present in the text string. I have changed the check in the mapping generation code to correctly account for this. Additional investigation is needed to determine if inserting 0xFFFE in the text is the correct behaviour. This patch resolves an issue where the find highlights in Chrome for a PDF would be offset when there are unprintable characters in a stream. BUG=pdfium:1010 Change-Id: I7547c46c5645e039a4b5138f2ce1137fa31990a5 Reviewed-on: https://pdfium-review.googlesource.com/27051 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@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>