summaryrefslogtreecommitdiff
path: root/core
AgeCommit message (Collapse)Author
2017-03-27Cleanup fx_dib_composite part 6chromium/3054Nicolas Pena
Simplify two more methods. Change-Id: I1bb4c827a14f63c743336df152ff88a6b4e52934 Reviewed-on: https://pdfium-review.googlesource.com/3214 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-27Convert new into MakeUniqueDan Sinclair
This Cl converts some new calls into pdfium::MakeUnique calls. Change-Id: Ifa4a67e305ffa75e2be560447ece21ccfa70bf3f Reviewed-on: https://pdfium-review.googlesource.com/3232 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-27Verify available bits in bit streamDan Sinclair
The methods to read n bits from the huffman stream are not correctly checking that the bits are available. This means, we'll end up reading 0 bits due to the checks below and pretend like the read worked. This Cl adds the check that we are not at the end of the bit buffer before attempting the bit read. Bug: chromium:672176 Change-Id: I206f2d54da31c344cf649ca024644d1cce762fe7 Reviewed-on: https://pdfium-review.googlesource.com/3231 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-27Fix some ASAN issues in fx_skia_deviceNicolas Pena
- Flush is needed in ~CFX_FxgeDevice, otherwise it may be called after deleting the bitmap, when calling the destructor of the skia device driver. - SkDashPathEffect::Make copies the given intervals instead of owning them, so free the input to that method. - If StartDIBits creates a new CFX_ImageRenderer, then the corresponding CancelDIBits needs to delete the handle. Bug: chromium:705131 Change-Id: I22c7c51a4070e73538eb8af51a60afeaa67f8bb7 Reviewed-on: https://pdfium-review.googlesource.com/3230 Commit-Queue: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-27Guard against lengths greater then input sizeDan Sinclair
If we get a requested length that is longer then the available buffer size we bail as we won't be able to read the needed data anyway. Bug: chromium:672177 Change-Id: Idb41671c07fe758ec0c1d4d6f84ead0a58fa8339 Reviewed-on: https://pdfium-review.googlesource.com/3221 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-27Remove old test expectations after the Mac 10.12 upgrade.Lei Zhang
BUG=chromium:703912 Change-Id: I5b4e582afc95b845e8e5e7a4e14581127c18de2d Reviewed-on: https://pdfium-review.googlesource.com/3193 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-27Update to zlib 1.2.11Adenilson Cavalcanti
This is the same version used by Chromium (as also the latest release of zlib). BUG=687631 Change-Id: Ia4bcdee3c36443ba01914d157ea795d7fb881a45 Reviewed-on: https://pdfium-review.googlesource.com/3096 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-27fix new tab crash in skia clip stackCary Clark
The crash on the new tab page is triggered by processing a transparency. This creates a new Skia device in CPDF_RenderStatus::LoadSMask(): // cpdf_renderstatus.cpp # 2557 if (!bitmap_device.Create(width, height, format, nullptr)) which sets the Skia clip stack to empty. It then calls RenderObjectList() RenderSingleObject() ProcessClipPath() which resets the clip stack; // cpdf_renderstatus.cpp # 1882 m_LastClipPath = ClipPath; m_pDevice->RestoreState(true); At this point m_LastClipPath contains {m_Ref={m_pObject={m_pObj=empty } } } The impelemntation in CFX_AggDeviceDriver::RestoreState() is // fx_agg_driver.cpp # 1283 if (m_StateStack.empty()) return; This hides unbalanced save/restores, but reworking PDFium to balance is nontrivial. R=dsinclair@chromium.org BUG=chromium:704442 Bug: Change-Id: Ia70d4dd7bd118e40adc5c029acbaa0b66372d3aa Reviewed-on: https://pdfium-review.googlesource.com/3191 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-26Use PartitionAlloc for JavaScript ArrayBuffers and strings.Chris Palmer
BUG=pdfium:681 Change-Id: I5073d80d9bd623b73e578d5ba2226c39c371bab0 Reviewed-on: https://pdfium-review.googlesource.com/3097 Commit-Queue: Chris Palmer <palmer@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-24Use unique_ptr in CFieldTree::NodeNicolas Pena
Bug: chromium:704824 Change-Id: I3de1a0bcee3317cfaa7e56578b637e427098230a Reviewed-on: https://pdfium-review.googlesource.com/3213 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-24Refcount CPDF_CMap all the time.chromium/3052chromium/3051Tom Sepez
Change-Id: I85ea9529f4188bf818ee96c37944e4546411f79c Reviewed-on: https://pdfium-review.googlesource.com/3211 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-03-24Fix CFX_FxgeDevice constructor and destructor in SkiaNicolas Pena
Attach and Create methods may be called without _SKIA_SUPPORT_, so the bitmap ownership code can't be if def'd to _SKIA_SUPPORT_. Bug:chromium:704835 Change-Id: If6a7da508156ca3c45898bf101d84dd8295e479f Reviewed-on: https://pdfium-review.googlesource.com/3210 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-23Fix CFX_RetainPtr move-assign semantics.Tom Sepez
Ensure moved value becomes a nullptr after the move. Update comment while we're at it. Change-Id: I7a2999d5f5c5142cc7826cd7880b1e2317b5445f Reviewed-on: https://pdfium-review.googlesource.com/3163 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-03-23Cleanup fx_dib_composite part 5Nicolas Pena
Simplify CompositeRow_Argb2Argb method. Change-Id: I8febf50375d5a0a56ba0eb77e921a506a6e327de Reviewed-on: https://pdfium-review.googlesource.com/3161 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-23fix skia path debugCary Clark
SHOW_SKIA_PATH code had bit-rotted. R=dsinclair@chromium.org BUG= Change-Id: I8961853aa0373fb0a04f829b8e78722197e8f5af Reviewed-on: https://pdfium-review.googlesource.com/3122 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-23Fix two CloneNonCycle issuesWei Li
CloneNonCycle() tries to detect cyclic object references without copying them. There are two issues: -- for elements in an array or a dictionary, they should be able to refer to the same object, which are not cyclic; -- for cyclic referenced elements in an array or a dictionary, do not clone the element at all. Having nullptr or <key, nullptr> as an element, like we did before, might cause crash when the element being accessed. BUG=chromium:701860 Change-Id: Id0304accde76ed06fa5ce640994c7628359600fb Reviewed-on: https://pdfium-review.googlesource.com/3156 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-23Handle the Clip command list being emptyDan Sinclair
If the command list is already empty when we attempt to restore the clip we will access outside the command array. BUG=chromium:704442 Change-Id: Ib7c44e14f0de175f1c10c1a538d16987aa49bf8a Reviewed-on: https://pdfium-review.googlesource.com/3159 Reviewed-by: Cary Clark <caryclark@google.com> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-23Revert "Remove CFX_FixedBufGrow"Nicolás Peña
This reverts commit 55d1d0191ea8316df32858d8cc62fb7c620e8613. Reason for revert: Slowing down corpus tests by a lot on Mac/Win Original change's description: > Remove CFX_FixedBufGrow > > This Cl replaces the CFX_FixedBufGrow class with std::vector. > > Change-Id: I85c85b7a8de4794840b561e09841bb464cfa9dfe > Reviewed-on: https://pdfium-review.googlesource.com/3138 > Reviewed-by: Tom Sepez <tsepez@chromium.org> > Commit-Queue: dsinclair <dsinclair@chromium.org> > TBR=tsepez@chromium.org,dsinclair@chromium.org,pdfium-reviews@googlegroups.com # Not skipping CQ checks because original CL landed > 1 day ago. Change-Id: Iaee27570f140b2033b5d8fb8f3077fc839558d64 Reviewed-on: https://pdfium-review.googlesource.com/3158 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-23Remove dead CFX_Edit code and fix some typos.Lei Zhang
Change-Id: Ieaac36e06db3d1e2b857d999a7d3d9cd5c5a9506 Reviewed-on: https://pdfium-review.googlesource.com/3118 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-22Return errors after validation instead of ASSERT in CPDF_DataAvailNicolas Pena
Change-Id: I909deca1d0bfc6de5ac0fd2e6956f9b918caf17a Reviewed-on: https://pdfium-review.googlesource.com/3157 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-22Cleanup fx_dib_composite Part 4Nicolas Pena
More method simplification, new helper GetGrayWithBlend Change-Id: Ice28591c590e2210f3b2864ac16b2d57abedeeb0 Reviewed-on: https://pdfium-review.googlesource.com/3145 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-22Fix ASSERT in CPDF_Data_AvailNicolas Pena
If ParseIndirectObjectAt fails, the replaced object will be null. So we can't ASSERT the output of ValidatePage. CL introducing the ASSERT: https://codereview.chromium.org/2483633002/ BUG=chromium:702897 Change-Id: Ib6e8c0bccaf2c05893f0abef27d431e112064865 Reviewed-on: https://pdfium-review.googlesource.com/3146 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-22Remove CFX_FixedBufGrowDan Sinclair
This Cl replaces the CFX_FixedBufGrow class with std::vector. Change-Id: I85c85b7a8de4794840b561e09841bb464cfa9dfe Reviewed-on: https://pdfium-review.googlesource.com/3138 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-21Make CPVT_WordPlace more conformant with the prevailing idioms.Tom Sepez
Add relational operators to replace CmpWord(). Leave CmpLine() for the moment as it saves some work. Remove CmpSec() and just inline comparison of the one member. Invert IsExist() as IsEmpty(). There is a big philosophical discussion as to whether things that are empty exist. I say they do, but they're just empty. Rename Default() to Reset(). Default sounds like a noun. Add AdvanceSection() method and call as appropriate. Change-Id: I01d9479f63a4860e0fd228255540d6d94dc24a9f Reviewed-on: https://pdfium-review.googlesource.com/3139 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-21Move colorspace specific code to colorspace classDan Sinclair
This Cl moves the Matrix and Vector code which is only used by the colorspace code into the colorspace cpp file. Change-Id: Ie37bcee0978278a56d345e63704494b5b67e5b24 Reviewed-on: https://pdfium-review.googlesource.com/3137 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-21Replace CFX_FileSizeListArray with a std::mapDan Sinclair
This CL replaces the FileSizeListArray code with a std::map. Change-Id: Ic158ad95e7055693168d186ba428806a59b04c95 Reviewed-on: https://pdfium-review.googlesource.com/3136 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-21Cleanup fx_dib_composite part 3Nicolas Pena
- Merged two methods into CompositeRow_AToMask - Simplified CompositeRow_Argb2Graya a lot Change-Id: Icc96ac30121082ef4d6cb170d1e4f918b109b1be Reviewed-on: https://pdfium-review.googlesource.com/3134 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-21Pop when Pages is malformed and has no kidsNicolas Pena
If the Kids array for the Pages dictionary does not exist, just treat this dictionary as the unique page in the document. BUG=chromium:702883 Change-Id: I9cb9645a53d60306ffe563f9b27cbbd37442f4ec Reviewed-on: https://pdfium-review.googlesource.com/3135 Commit-Queue: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-21Replace CPVT_ArrayTemplate in cpdf_variabletext.cpp and remove it.chromium/3048Tom Sepez
Change-Id: I4354a841d6e2d4f30ccb298d13dffa49b9f3a3b3 Reviewed-on: https://pdfium-review.googlesource.com/3131 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-03-21Cleanup fx_dib_composite part 2Nicolas Pena
Fix some nits, add helper methods GetAlpha and GetGray to reduce code duplication. Change-Id: I5ea7e9ae306a4fc83f861f0e65879731e680f4f8 Reviewed-on: https://pdfium-review.googlesource.com/3109 Commit-Queue: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-20Cleanup fx_dib_composite part 1: simplify lum and sat methods.chromium/3047Nicolas Pena
Change-Id: I4c00324990a62b624596110f442969a988631cb3 Reviewed-on: https://pdfium-review.googlesource.com/3105 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-20Use std::vector<std::unique_ptr<CPVT_WordInfo>> as word array.Tom Sepez
We never push nullptrs into this array, so remove some checks for nullness, but be really careful about bounds checking. Change-Id: I79960a4cc9a729b3d5985f297aea8c4b03ceb601 Reviewed-on: https://pdfium-review.googlesource.com/3103 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-03-20Allow processing fonts with indirect dictNicolas Pena
BUG=pdfium:667 Change-Id: I6e7620948086f3f620e4cde778a4144570e1bd6d Reviewed-on: https://pdfium-review.googlesource.com/3106 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-17Add pdfium::clamp() as a placeholder for std::clamp().chromium/3046Lei Zhang
Ue it to fix a typo as well. BUG=pdfium:634 Change-Id: I2d686242ffb841aedc2fae6a3cf7a00bea667404 Reviewed-on: https://pdfium-review.googlesource.com/3113 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-17Use std::vector in CPDF_StreamContentParser.Lei Zhang
Change-Id: I2e1bc6cd8ba45fef2bde55bcc3f0c19947d46ed5 Reviewed-on: https://pdfium-review.googlesource.com/3111 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2017-03-17Bring CPDF_ICCBasedCS closer to PDF spec.Lei Zhang
The spec says the N dictionary field is required and must be set to a valid value. Adjust the code based on this assertion. BUG=pdfium:675,chromium:691967,chromium:702238 Change-Id: Iaa76fa0e16ce4aaa9822ad471668cbf8af5fb7cb Reviewed-on: https://pdfium-review.googlesource.com/3112 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-17Replace CLines class with std::vector<Cline>.Tom Sepez
m_LineArray only grows via push_back of non-null pointer, so remove some null checks. Another little idiosyncrasy is CLines::Clear() doesn't clear the items in CLines, only the things that were once in CLines but aren't anymore. So don't call it. Change-Id: Icc434be94b1b0522533c7533b8f6b2736bb864c4 Reviewed-on: https://pdfium-review.googlesource.com/3099 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2017-03-17HardClip points a bit better in fx_agg_driverNicolas Pena
In agg, the length is of type coord_type, which we have as int16. So having points bigger than the max short will not work properly. BUG=chromium:699982 Change-Id: I0e4cab6ae2b6aa023359aec4b5b3d611f8a8eb4f Reviewed-on: https://pdfium-review.googlesource.com/3101 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Nicolás Peña <npm@chromium.org>
2017-03-17Handle web links across lineschromium/3045Wei Li
When a web link has a hyphen at the end of line, we consider it to be continued to the next line. For example, "http://www.abc.com/my-\r\ntest" should be extracted as "http://www.abc.com/my-test". BUG=pdfium:650 Change-Id: I64a93d9c66faf2be0abdaf8cfe8ee496c435d0ca Reviewed-on: https://pdfium-review.googlesource.com/3092 Commit-Queue: Wei Li <weili@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2017-03-17Coalesce redundant path points.Lei Zhang
There exists PDFs with many redundant path points, and keeping track of them all uses a lot of memory. BUG=chromium:679353 Change-Id: I514610cbba181658b6396e30f5bf58a3661359f5 Reviewed-on: https://pdfium-review.googlesource.com/3110 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-03-17Cleanup in fx_agg_driver part 2Nicolas Pena
Moved CFX_Renderer to namespace and added some private auxiliary methods to reduce duplicated code. Also, more nit cleanup (casts, brackets, etc). Change-Id: I66f36177767325068a8a9ebf04a5d9b3a1762d94 Reviewed-on: https://pdfium-review.googlesource.com/3093 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-16Remove some nested statements in CPDF_DataAvail.Lei Zhang
Change-Id: I959dbfebdc7a5a1ec9b201a80ff6cfdc031572b0 Reviewed-on: https://pdfium-review.googlesource.com/2833 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-16Fix nits in CPDF_DIBSource.Lei Zhang
Change-Id: Icfeb3a6dce20e8c2b619aaff1e19cde56347cb52 Reviewed-on: https://pdfium-review.googlesource.com/3011 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-16Create common base class for TxtBreak and RTFBreak.Dan Sinclair
This CL starts extracting common members between the two break classes into a common base class. This also normalizes some of the member names to be the same across classes. Change-Id: I7f4e5065f2dac79eb4ebba397458236cc0609d38 Reviewed-on: https://pdfium-review.googlesource.com/3058 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2017-03-16Use EXPECT_FLOAT_EQ in cpdf_devicecs_unittestNicolas Pena
Change-Id: I2e4eba78c5764de108c203b0e0efcd4e81b7bab2 Reviewed-on: https://pdfium-review.googlesource.com/3068 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-16Compare to epsilon instead of 0 in CFX_Matrix::SetReverseNicolas Pena
Since we are going to divide i by 0, it is better to compare it to epsilon and avoid wonkiness from division by something too close to 0. BUG=chromium:702041 Change-Id: I8136d6063f8debd41cef37eaab7e4097b3f32f4b Reviewed-on: https://pdfium-review.googlesource.com/3090 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-15Reset tree traversal when we think we're at the startchromium/3043Nicolas Pena
If the PDF declares it has a gazillion pages when it does not, we just start traversing again from the start. This CL fixes that. BUG=chromium:680222 Change-Id: Ie9b55abc0aaa372429b3d995a7e1e7ab58fb7965 Reviewed-on: https://pdfium-review.googlesource.com/3060 Commit-Queue: Nicolás Peña <npm@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2017-03-15Refactor some CPDF_ColorSpace code.Lei Zhang
Change-Id: I1e30d68dae3bf70cf3c426f6126d593b7f1c3ba4 Reviewed-on: https://pdfium-review.googlesource.com/2991 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Nicolás Peña <npm@chromium.org>
2017-03-15Clean up more CPDF_PSEngine code.Lei Zhang
Change-Id: I229a3108a787725bbf2f000c39ee19d0680e9150 Reviewed-on: https://pdfium-review.googlesource.com/2968 Reviewed-by: Nicolás Peña <npm@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2017-03-15Fix botch introduced at 193e6ca, try 2.Tom Sepez
Change-Id: I9eb6e8c621b0562413873ac67b362efa68fc3ab8 Reviewed-on: https://pdfium-review.googlesource.com/3061 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>