summaryrefslogtreecommitdiff
path: root/core/fxcrt
AgeCommit message (Collapse)Author
2018-10-24Add CFX_Matrix::AsTuple().chromium/3591Lei Zhang
Change-Id: I53c1b148cb8cdc77461766fc9996a0a3ce5f4cb7 Reviewed-on: https://pdfium-review.googlesource.com/c/44536 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-22Fix timezone inconsistency in document methods test.Tom Sepez
We do this by adding an override that forces GM time on everyone when run from the test harness. Generalize presubmit warnings so that the new function passes. De-duplicate lambda capture in place of static function. Change-Id: I15b34bea558baf1763476b36f0bca76614984107 Reviewed-on: https://pdfium-review.googlesource.com/c/44390 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-18Do IWYU for core/fxcrt/xml headers.Lei Zhang
Also make more core/fxcrt/xml member variable names consistent in style. Change-Id: I892841b4026df302aa28f754441bf21707e96764 Reviewed-on: https://pdfium-review.googlesource.com/c/44171 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-18Remove unused form of CFX_Matrix::TransformRect().Lei Zhang
Change-Id: I8e6c5fdf301ca408e76d9acfe6e62db9afd3d7a7 Reviewed-on: https://pdfium-review.googlesource.com/c/43575 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-18Remove some useless calls to the CFX_XMLNode ctor from subclasses.Lei Zhang
Also fix some nits: - Make member variable names consistent. - Make member variables const. - Make trivial getters return const-ref. Change-Id: Ibd34c9bc58ec0eed3edfc3a8ea39b533a41cad73 Reviewed-on: https://pdfium-review.googlesource.com/c/44151 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-10-18Do IWYU in core/fxcrt/css and fix lint errors.Lei Zhang
Change-Id: I6d2b35849e9f1935277986b6c72e6f507d976974 Reviewed-on: https://pdfium-review.googlesource.com/c/43948 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-10-18Add unit tests for CFX_Matrix::TransformRect().Lei Zhang
Change-Id: Id4bebae05116422b15019e7b972f5e8594317afe Reviewed-on: https://pdfium-review.googlesource.com/c/43949 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-10-17Optimize appends in CFX_XMLNode::InsertChildNode().Lei Zhang
Skip to the end of the linked list instead of traversing it. BUG=chromium:895234 Change-Id: I56d6bee3cd099a1a7343eb2b067d522ec69c261a Reviewed-on: https://pdfium-review.googlesource.com/c/44172 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-17Fix the static initialization order problem for PartitionAlloc.Lei Zhang
Inside fx_memory.cpp, the PartitionAllocatorGeneric objects are globals, so their initialization order is not well defined. BUG=chromium:896117 Change-Id: If4a345d6d7549b0e99a055859eaa67d5ec32c788 Reviewed-on: https://pdfium-review.googlesource.com/c/44170 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-16Use PartitionAllocZeroFill in FX_SafeAlloc().Lei Zhang
Avoid a manual memset(). BUG=pdfium:1171 Change-Id: I4f7708d8ad75ca7fa697f69a24fa0de55286b5fa Reviewed-on: https://pdfium-review.googlesource.com/c/44075 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-16Update PartitionAlloc from Chromium at r599712.Lei Zhang
BUG=pdfium:1170 Change-Id: I0f8dfb3d517beaa682a9ca7ad4831c5a7a10dc3b Reviewed-on: https://pdfium-review.googlesource.com/c/44073 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-15Split pdfium_unittests sources.Lei Zhang
Move foo_unittest.cpp to the same BUILD.gn file as foo.cpp. Set up dependencies to make pdfium_unittests pass gn check. Change-Id: Id9f649d5d0c76fe4254f3887778516abb75fcbce Reviewed-on: https://pdfium-review.googlesource.com/c/43995 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-15Restrict fxcrt's visibility to third_party.Lei Zhang
Change-Id: I4b4b1a8e78e2405791aca915e4d48a88e79444d5 Reviewed-on: https://pdfium-review.googlesource.com/c/43993 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-13Add missing config to core/fxcrt:seekablemultistream target.Lei Zhang
Should have been part of commit e421d384. TBR=tsepez@chromium.org Change-Id: I042c1c85f915798dd393f5ea136edb86d644ca11 Reviewed-on: https://pdfium-review.googlesource.com/c/43982 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-12Split core/fpdfapi build rules into various sub-directories.Lei Zhang
Change-Id: I98e2e913f11ff63e70cb841de00a4f56b06ca03b Reviewed-on: https://pdfium-review.googlesource.com/c/43974 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-12Make core/fxcrt pass gn check.Lei Zhang
Split some XFA-only code into their own targets to avoid circular dependencies. Make CFX_SeekableMultiStream XFA-only. Change-Id: I88f49556623d52dddd4d0013cc3308b694c01d42 Reviewed-on: https://pdfium-review.googlesource.com/c/43973 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-12Split core/fxcrt build rules into core/fxcrt/BUILD.gn.Lei Zhang
Change-Id: I9b3608bd76ec4911a4bb820fcda62c5d9533fb4f Reviewed-on: https://pdfium-review.googlesource.com/c/43947 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-12Remove more unnecessary includes and do IWYU as needed.Lei Zhang
Also move some implementations out of headers. Change-Id: I321fc26970c440d874b135bd28e8bc8156b9afee Reviewed-on: https://pdfium-review.googlesource.com/c/43890 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-10Add Observable::ObservedPtr::HasObservable().Lei Zhang
if (pObserved->HasObservable()) is more readable than if (*pObserved). Change-Id: I61ad3deb8e9f30cdc120a05555c2558f34489681 Reviewed-on: https://pdfium-review.googlesource.com/c/43811 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-10Fix some random nits.Lei Zhang
Change-Id: I735c057d4900bcd58c1041df16b885dc7c9ed27d Reviewed-on: https://pdfium-review.googlesource.com/c/43793 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-09Do IWYU for retain_ptr.h and unowned_ptr.hLei Zhang
Change-Id: I2897feee27f80c85f0328f0b220ae5be93686170 Reviewed-on: https://pdfium-review.googlesource.com/c/43610 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-09Do IWYU for ptr_util.h.Lei Zhang
Change-Id: Ib96a66eb47bea791f061e1d6da8aadad8037a99d Reviewed-on: https://pdfium-review.googlesource.com/c/43609 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-09Kill off some memset()s following FX_Alloc()Tom Sepez
Change-Id: I92aa74c86aef890fcb991f039b9707d680fdb83c Reviewed-on: https://pdfium-review.googlesource.com/c/43652 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-06Simplify CFX_FloatRect::Inflate() and Deflate().Lei Zhang
Make all the other Inflate() methods to call the 4 parameters version. Make all the other Deflate() methods to call the 4 parameters version. Make the 4 parameters version of Deflate() call Inflate(). Change-Id: I1d2702898206bf9845f0bb176c2bf4d5a315cf96 Reviewed-on: https://pdfium-review.googlesource.com/c/43573 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-06Move CFX_FloatRect method impls out of the header.Lei Zhang
Change-Id: Ice814a84f699ea32325e98bbcea1a5b7db065fc6 Reviewed-on: https://pdfium-review.googlesource.com/c/43572 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-06Encapsulate CPDF_PageObject's rect member.Lei Zhang
At the same time, change it from 4 floats to a CFX_FloatRect. Change-Id: I00ded941723d6a264b7a17c73fd337e66b449308 Reviewed-on: https://pdfium-review.googlesource.com/c/43570 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-10-04Change |virtual ~Foo(){}| to |virtual ~Foo()=default;|chromium/3571Tom Sepez
Otherwise code coverage flags the empty body as unreachable. Change-Id: Iee1d9a876d68276529c70d9b8c7a28276f271767 Reviewed-on: https://pdfium-review.googlesource.com/c/43514 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-04Remove some unused code in fxcrt strings.Tom Sepez
Unused static method in StringDataTemplate<>. Unused WideString::GetFloat(), which in turn allows us to remove another custom string to float parser. Change-Id: If7ae60a0ba90563598232bad229f97cb74d682ba Reviewed-on: https://pdfium-review.googlesource.com/c/43513 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-03Tidy CFX_UTF8Decoder.Tom Sepez
Remove unused method, make ctor/dtor out-of-line. Change-Id: I77bb7c1da8e9d369085072639ca388247f2b9225 Reviewed-on: https://pdfium-review.googlesource.com/c/43455 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-10-03Add FxFolderHandleCloser for use with std::unique_ptr.Lei Zhang
Use it in a couple of places. Make the similar code in the two places even more so. Change-Id: I3fc6a567088217e24506cdf7ab927b94cb5a4d52 Reviewed-on: https://pdfium-review.googlesource.com/43330 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-10-01Fix #include ordering / formatting.Lei Zhang
Change-Id: I996c9b32d767960a5388e44e13180e1f6577ce38 Reviewed-on: https://pdfium-review.googlesource.com/43190 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-09-25Add FxAlignToBoundary<>() template helper function.Tom Sepez
Because I nearly botched this trivial calculation in the previous CL. Change-Id: I7438f9d3476d93b7899c2d7d761234769f53f9e3 Reviewed-on: https://pdfium-review.googlesource.com/43010 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-20Change CFX_FixedBufGrow to take a size_t.Lei Zhang
Thanks to Qihoo 360 Vulcan Team for pointing this out. Change-Id: Ib6dd77307b3759e54168127dc0e17aa42698d852 Reviewed-on: https://pdfium-review.googlesource.com/42830 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-20Fix misc lint errors and other cleanups.Lei Zhang
Change-Id: I00ce0109251d1231858e87ffc3889abe6937fa26 Reviewed-on: https://pdfium-review.googlesource.com/42811 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-09-20Remove more unneeded STL #includes from headers.Lei Zhang
Remove some variables named "string" to avoid false positives from the linter. Change-Id: I00a53e6970451fd0cea8ab2f8178183650ca00d2 Reviewed-on: https://pdfium-review.googlesource.com/42810 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-20Remove many unneeded STL #includes from headers.Lei Zhang
Change-Id: I7010cedee8d17d05b2c37a94d767e6f3a9c48f7d Reviewed-on: https://pdfium-review.googlesource.com/42790 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-09-18Transfer ownership of nodes to top-level XML docRyan Harrison
For XFA, XML nodes are owned by the XML doc that they were created by, but references to them are stored elsewhere. For a PDF document there is one top-level XML document created and retained when the initial XFA XML is parsed. Another can be created if loadXML is called by JS. In the existing code the XML doc that owns the newly created nodes is local to loadXML. So the nodes are destroyed right after putting refernces to them into the main XFA data structures. This CL adds in a method to transfer ownership of the XML nodes from one doc to another, and uses it to correctly retain the newly created nodes, by having them owned by the top-level XML doc. BUG=chromium:884664 Change-Id: Id29b4edbfe44aefb9713328e4e217e830f7e9e14 Reviewed-on: https://pdfium-review.googlesource.com/42690 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-09-17Make fxcrt::Retainable non-copyable.Tom Sepez
Because copying ref-counts from one object to another is a bad idea and sure to leak. Change-Id: I5f2c0891d08c893eb1ac8fb8a5908d975295ae2e Reviewed-on: https://pdfium-review.googlesource.com/42670 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-17Fix final/protected conflicts.Tom Sepez
Classes marked |final| should not have |protected| members. In turn, "private field m_dwEncryptObjNum is not used" warning is produced. Change-Id: I51a96aca5a5f499381a6764d892962f7f2dc0327 Reviewed-on: https://pdfium-review.googlesource.com/42611 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-13Use safe math in MatchFloatRange().Tom Sepez
Bug: 882959 Change-Id: I3ce17916da1346158dbf5282be6696879a22567a Reviewed-on: https://pdfium-review.googlesource.com/42355 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-13Reland "Introduce FX_Number class as a replacement for FX_atonum()."Tom Sepez
This reverts commit 29e180342e18873babf1c74f7c5c056f90a191b0. Reason for revert: probably harmless Original change's description: > Revert "Introduce FX_Number class as a replacement for FX_atonum()." > > This reverts commit a5d7ad3aa8feb08a14b5cca173d673054c1ade23. > > Reason for revert: Speculative revert to get back before flake. > > Original change's description: > > Introduce FX_Number class as a replacement for FX_atonum(). > > > > The issue with FX_atonum() is that it doesn't return any information > > about whether it range-checked its integer values as a signed or > > unsigned type, even though it knows this as part of its processing. > > > > Rather than adding another out parameter to that function, create > > a class to hold all this information together. > > > > This is the first place things went astray while diagnosing > > bug 882959, in that a large positive value was cast to float as a > > negative value. Unfortunately, this doesn't affect the related bug, > > but is a step in the right direction. > > > > Change-Id: I0977ec8fccf85e2632a962507bdd30a1cbe6d33c > > Reviewed-on: https://pdfium-review.googlesource.com/42353 > > Reviewed-by: Lei Zhang <thestig@chromium.org> > > Commit-Queue: Tom Sepez <tsepez@chromium.org> > > TBR=thestig@chromium.org,tsepez@chromium.org > > Change-Id: Ia56270c3daa80408fc2b23eb4384a77f03f45b82 > Reviewed-on: https://pdfium-review.googlesource.com/42392 > Reviewed-by: Tom Sepez <tsepez@chromium.org> > Commit-Queue: Tom Sepez <tsepez@chromium.org> TBR=thestig@chromium.org,tsepez@chromium.org Change-Id: I83c37aa3040a8890f2117753f19ab1d452d411e7 Reviewed-on: https://pdfium-review.googlesource.com/42410 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-09-13Revert "Introduce FX_Number class as a replacement for FX_atonum()."Tom Sepez
This reverts commit a5d7ad3aa8feb08a14b5cca173d673054c1ade23. Reason for revert: Speculative revert to get back before flake. Original change's description: > Introduce FX_Number class as a replacement for FX_atonum(). > > The issue with FX_atonum() is that it doesn't return any information > about whether it range-checked its integer values as a signed or > unsigned type, even though it knows this as part of its processing. > > Rather than adding another out parameter to that function, create > a class to hold all this information together. > > This is the first place things went astray while diagnosing > bug 882959, in that a large positive value was cast to float as a > negative value. Unfortunately, this doesn't affect the related bug, > but is a step in the right direction. > > Change-Id: I0977ec8fccf85e2632a962507bdd30a1cbe6d33c > Reviewed-on: https://pdfium-review.googlesource.com/42353 > Reviewed-by: Lei Zhang <thestig@chromium.org> > Commit-Queue: Tom Sepez <tsepez@chromium.org> TBR=thestig@chromium.org,tsepez@chromium.org Change-Id: Ia56270c3daa80408fc2b23eb4384a77f03f45b82 No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://pdfium-review.googlesource.com/42392 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-13Test that FX_TryRealloc failure leaves original contents intactTom Sepez
Change-Id: I2b1e5cc7a9576b5bb3bf3888225d1f6e54e0c95b Reviewed-on: https://pdfium-review.googlesource.com/42051 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-09-13Introduce FX_Number class as a replacement for FX_atonum().Tom Sepez
The issue with FX_atonum() is that it doesn't return any information about whether it range-checked its integer values as a signed or unsigned type, even though it knows this as part of its processing. Rather than adding another out parameter to that function, create a class to hold all this information together. This is the first place things went astray while diagnosing bug 882959, in that a large positive value was cast to float as a negative value. Unfortunately, this doesn't affect the related bug, but is a step in the right direction. Change-Id: I0977ec8fccf85e2632a962507bdd30a1cbe6d33c Reviewed-on: https://pdfium-review.googlesource.com/42353 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-09-04Fix some more span/memcpy interactions.Tom Sepez
Use the preferred idiom of creating a subspan, which makes the proper checks prior to the copy. Change-Id: Ia7f25b5760dea5707df66cf421195b23a1ce0ad0 Reviewed-on: https://pdfium-review.googlesource.com/41911 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-30Add unit test for AutoRestorer<> on smart pointer types.Tom Sepez
Test UnownedPtr<> and RetainPtr<>. We cannot operate against std::unique_ptr<> because we need a copyable type. Add test for self-reassignment on going out of scope. Move one test helper class to testing/ so it can be shared among unit tests. Allow it to recognize if it ever gets "destroyed", otherwise we can't be sure Retain/Release applied in the correct order. Change-Id: I13056094c70079f7283cbc7600948f81a64874b4 Reviewed-on: https://pdfium-review.googlesource.com/41690 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-27The final game: mark everything final.Tom Sepez
Then revert the ones that break compilation. Fix one IWYU noticed during presubmit. Change-Id: I881a8a72818e55dbc4816247e35ff5e3015194e7 Reviewed-on: https://pdfium-review.googlesource.com/41470 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Use pdfium::span<> in CPDF_Stream::SetData().Tom Sepez
Conversion to span makes this more elegant in a number of places, owing to std::vector directly converting to span, and the bytestring's ToRawSpan(). Disambiguate single-argument forms to allow passing {} as an argument. Change-Id: Ibd5eaadca8d8cbbd589338f375c7ee8439fd3eb2 Reviewed-on: https://pdfium-review.googlesource.com/41272 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Pass unique_ptr<> to CFX_MemoryStream constructorTom Sepez
Proves we own the memory that the class will eventually free. Change-Id: Ie9523da8db738e7478a1c73e3e1a6b24aed38442 Reviewed-on: https://pdfium-review.googlesource.com/41290 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-23Fix GCC build with V8 disabled.Lei Zhang
- Remove set, but otherwise unused variables. - Mark some pdfium_test code as V8-enabled only. - Do not build one unit test with GCC. Change-Id: I3f04273a7731086e08386478a62769bf06f6d8a4 Reviewed-on: https://pdfium-review.googlesource.com/41271 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>