summaryrefslogtreecommitdiff
path: root/core/fxcrt
AgeCommit message (Collapse)Author
2018-08-08Remove unused codepage from WideString::GetWideString().Tom Sepez
Consolidate code into sole caller, which always retrieves a string from the "default ANSI code page". Add unit test for this code path. Fix sign extension bug giving bogus 0xffffff80 codepoint uncovered by unit test on non-windows. Note windows result is different because the system conversion routine does actually work. Change-Id: I1c1246b203ee66e9ff0b6fccf97594788bcd0fca Reviewed-on: https://pdfium-review.googlesource.com/39730 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@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-07Remove unused codepage code from GetByteString().Tom Sepez
It is only called ever called from one place with 0 (FX_CODEPAGE_DefANSI), with more complicated usage being funneled directly into FXSYS_ code. Next, fold it into ByteString::FromUnicode(). Change-Id: I85aa0dd3a4ca8cddcff22533e0a284ff3f5535ee Reviewed-on: https://pdfium-review.googlesource.com/39670 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-07Add test for {Byte,Wide}String Operator+().Tom Sepez
Precursor to converting some Format() operations to simple string addition. Change-Id: I3a159f5ac548ea14586d87e7d56d1ec288898b0d Reviewed-on: https://pdfium-review.googlesource.com/39590 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-08-07Speculative fix for null deref above ThrowNoDefaultPropertyExceptionTom Sepez
Avoid possibility of an unterminated string or nullptr by avoiding stringviews, since the non-view classes copy and always provide a suitable result. Always use %ls and widestrings in wprintf() variants, since that combination is consistent across our platforms (%s, %S, etc. have idiosyncracies). Bug: 870952 Change-Id: Ief62a42c3486e8298f9583b56e9333db1a74972a Reviewed-on: https://pdfium-review.googlesource.com/39551 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-06Clean up a nit that was identified after CQing an earlier CLRyan Harrison
Change check to use empty instead of size <= 0. Also added a comment to the check to make it clear what is being guarded against BUG=chromium:863098 Change-Id: I993085c04ab66a9e2869c83d8fb48883ec0bbf71 Reviewed-on: https://pdfium-review.googlesource.com/39497 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-08-03Make CFX_XMLParser less permissiveRyan Harrison
Currently the parser will accept arbitrary garbage before the first element begins. This is causing issues with ClusterFuzz since it generates a lot of trash inputs which take a long time to parse inspite of being invalid. This CL adds in a check of how deep the parse is when dealing with text, and if it is at the top level scope, then only accept the beginning of the root node. BUG=chromium:863098 Change-Id: Ie45114ecf488f7e8a68a120d153033c7089d5cdc Reviewed-on: https://pdfium-review.googlesource.com/39470 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-07-28Add ToXML{Instruction,Text,CharData}() checked conversion functionsTom Sepez
All usages were previously checked correctly, but this consolidates some code as well. Change-Id: I63711748b31b698a3f21f98fdb536db1e9e0b1cf Reviewed-on: https://pdfium-review.googlesource.com/39010 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-26Use moar ToXMLElement() in place of static_cast<>.Tom Sepez
Introduces checks in a few new places, but mainly just consolidates checking/casting logic. Change-Id: I634a03060d254db099972c6978249992367e146c Reviewed-on: https://pdfium-review.googlesource.com/38900 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
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-25Only build cfx_fileaccess_windows.cpp on Windows.Lei Zhang
- Remove #if guards in the .cpp file and flip the #if guard in the header to produce an error when incorrectly included. - Do the same for cfx_fileaccess_posix.cpp. - Also remove forward declarations for win32 APIs. Change-Id: I81056ea6198d342e62744bd3240b3a28ac53d5c0 Reviewed-on: https://pdfium-review.googlesource.com/38410 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-25Introduce ToXMLElement() checked downcast helper functionTom Sepez
And use it in place of ASSERT() that the type was correct. Since we can check it, doing so at runtime may help avoid type confusion, and we'll get a nice safe SEGV if the asserted condition ever fails. Change-Id: I46b65a4b70e819a670d7cad7966e0d100f0d9a63 Reviewed-on: https://pdfium-review.googlesource.com/38810 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-19Make FX stream internal details more private to .cpp files.Tom Sepez
Makes the generic fx_streams.h header pull in lots less OS-specific cluter. Combine and de-virtualize the windows struct. Change-Id: I836b9efb00b25dbd1b8f814645dd31a0f04bb4f4 Reviewed-on: https://pdfium-review.googlesource.com/38330 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-18Add pdfium::span::as_bytes() and as_writable_bytes().Tom Sepez
Picks up some enhancements from base/span.h. In turn, also adds the size_bytes() helper. Differs from base version in that it works around C++14 enable_if_t<>, and avoids the dynamic_extent template specialization tricks. Use it in a few places where appropriate. Change-Id: I86f72cf0023f2d4317a7afa351fddee601c8f86c Reviewed-on: https://pdfium-review.googlesource.com/38251 Reviewed-by: Daniel Cheng <dcheng@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-10Fix duplicate symbols in Chromium builds.Lei Zhang
Commit 43f6bc80 copied over Chromium's base/debug/alias.cc, but that confuses Windows builds and Linux jumbo builds in Chromium. To fix this, wrap PDFium's copy in the pdfium namespace. BUG=chromium:860850 TBR=dsinclair@chromium.org Change-Id: I1ceec28b9ce6c2893bf030a5b6564dce6d6ec376 Reviewed-on: https://pdfium-review.googlesource.com/37430 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org>
2018-07-09Prevent FX_OutOfMemoryTerminate() from being folded by the linker.Lei Zhang
Copy base::debug::Alias() from Chromium. Use it to prevent ICF from combining FX_OutOfMemoryTerminate() with similar functions. BUG=chromium:860850 Change-Id: Ifccb05c0218f86e44b9bb235847e01383ec36b3f Reviewed-on: https://pdfium-review.googlesource.com/37290 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-07-03Test {Byte,Wide}String works with std::begin().Tom Sepez
Test-only CL. Building another container from the string in the manner in the test is desirable. Change-Id: I8f41aecfd82fd27f8b9af159b887b66b566f9ac7 Reviewed-on: https://pdfium-review.googlesource.com/36910 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-07-02Virtualize Observable<T>::ObservedPtr::OnDestroy() for CPDF_Avail cleanupTom Sepez
This enables more complicated cleanup when an observed object is destroyed. Use it to make documents observable and to allow the CPDF_Avail to cleanup without the need for intermediate class. Change-Id: I3a8e758b7ff542e0a58710eff1ac8017205cbd45 Reviewed-on: https://pdfium-review.googlesource.com/36373 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-27Add fxcrt::AutoRestorer<T>::AbandonRestoration().chromium/3475Tom Sepez
Kinda like reaching a commit point, makes going forward more useful. Change-Id: I7695b6e627d4cd8ed2bccb667d0cabd7f42c7b1c Reviewed-on: https://pdfium-review.googlesource.com/35970 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-26Fix uninit value in CFX_CSSComputedStyle::InheritedData.Lei Zhang
BUG=chromium:856054 Change-Id: Ieacb7be324f290c91623ed1bd97744150fbfa6e7 Reviewed-on: https://pdfium-review.googlesource.com/36090 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-20Avoid more .c_str() usage, part 3Tom Sepez
Change-Id: I5dfadcb68e640235be6e3eb7c8d57ae3b8013d26 Reviewed-on: https://pdfium-review.googlesource.com/35691 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-19Speculative fix for segv destroying CPDF_PageObjectHolder::m_GraphicsMapTom Sepez
We speculate that the bug that makes the comparison operator irreflexive might be the cause of the segv on windows production code, should a NaN sneak into the GraphicsData struct. In any event, should this happen, the tree won't be correct with some nodes erroneously replaced. Add a test which fails prior to the patch, but alas does not elicit the segv. Also move operator<() methods to .cpp file corresponding to .h file in which they are delcared. Bug: 852273 Change-Id: Ib7929881e7ffbed8b09f6e2c9fb7898cbde58946 Reviewed-on: https://pdfium-review.googlesource.com/35171 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Tom Sepez <tsepez@chromium.org>
2018-06-19fxcrt::{Byte,Wide}String missing move-assign operatorTom Sepez
This hasn't been a big deal, since no data is copied, but avoids some ref-count churn in the process. Change-Id: I53c059284aa6806793c59a0c19b3e0d7fe4191d6 Reviewed-on: https://pdfium-review.googlesource.com/35350 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-06-08Avoid undefined behavior in FX_atonum().Lei Zhang
BUG=chromium:664730 Change-Id: Ie46221382ffed7a16366c484c249d2571c7be5c4 Reviewed-on: https://pdfium-review.googlesource.com/34696 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-06-05Revert "Convert (void) to static_cast<void> in C++ code"Ryan Harrison
This reverts commit 80c6ab7b99bcbd7b940f78dc0cac52c30249f59c. Reason for revert: (void) idiom is prevalent through out C++ code. Original change's description: > Convert (void) to static_cast<void> in C++ code > > Converting instances of old C-style void casts to suppress return > values to use C++ style static cases. There are a few examples of > (void) that remain, since they are in C code, and the third_party/ > instances are not touched at all. > > Change-Id: I72b3fc0e1d713db669b76135e03d1cf87873a2fe > Reviewed-on: https://pdfium-review.googlesource.com/33790 > Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> > Commit-Queue: Ryan Harrison <rharrison@chromium.org> TBR=thestig@chromium.org,tsepez@chromium.org,dsinclair@chromium.org,hnakashima@chromium.org,rharrison@chromium.org Change-Id: Ib6cc021c97cb1ea7c71b90346fa9b500659f565d No-Presubmit: true No-Tree-Checks: true No-Try: true Reviewed-on: https://pdfium-review.googlesource.com/33890 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-06-04Convert (void) to static_cast<void> in C++ codechromium/3450Ryan Harrison
Converting instances of old C-style void casts to suppress return values to use C++ style static cases. There are a few examples of (void) that remain, since they are in C code, and the third_party/ instances are not touched at all. Change-Id: I72b3fc0e1d713db669b76135e03d1cf87873a2fe Reviewed-on: https://pdfium-review.googlesource.com/33790 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-06-02IWYU: std::begin() and std::end() need <iterator>Raphael Kubo da Costa
This fixes the libstdc++ build after 656eb84f8 ("Move codepage/charset methods into related places"): ../../third_party/pdfium/core/fxcrt/fx_codepage.cpp: In function ‘uint16_t FX_GetCodePageFromCharset(uint8_t)’: ../../third_party/pdfium/core/fxcrt/fx_codepage.cpp:212:60: error: no matching function for call to ‘begin(const {anonymous}::FX_CHARSET_MAP [31])’ std::lower_bound(std::begin(g_FXCharset2CodePageTable), ^ In file included from /usr/include/c++/7/utility:76:0, from /usr/include/c++/7/algorithm:60, from ../../third_party/pdfium/core/fxcrt/fx_codepage.cpp:9: /usr/include/c++/7/initializer_list:89:5: note: candidate: template<class _Tp> constexpr const _Tp* std::begin(std::initializer_list<_Tp>) begin(initializer_list<_Tp> __ils) noexcept ^~~~~ /usr/include/c++/7/initializer_list:89:5: note: template argument deduction/substitution failed: ../../third_party/pdfium/core/fxcrt/fx_codepage.cpp:212:60: note: mismatched types ‘std::initializer_list<_Tp>’ and ‘const {anonymous}::FX_CHARSET_MAP*’ std::lower_bound(std::begin(g_FXCharset2CodePageTable), ^ Bug: chromium:819294 Change-Id: I3c0368af81ae274d62bf51eb6dc17d9bd71951eb Reviewed-on: https://pdfium-review.googlesource.com/33490 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-06-01GCC6: workaround bug with external class template linking.José Dapena Paz
In the case of ByteStringView and WideStringView, non official build fails to link in GCC 6.3 or older. But it works in GCC 7.2. A workaround for this problem is avoiding declaring in same file extern and explicit class template for them. It seems to be related to https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57728 though that bug is supposed to be already fixed in 6.3.0. Change-Id: Ia6323f23138c0c11e59ce7aa31da1f6c11bc4a5a Reviewed-on: https://pdfium-review.googlesource.com/33270 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org>
2018-06-01Fix XFA guardsRyan Harrison
These guards are using #if, when they should be using #ifdef. Caught using Clang's static analyzer. Change-Id: I86e99c5e4142cf84fff5f2365ad534f09ae40511 Reviewed-on: https://pdfium-review.googlesource.com/33510 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-05-31Move codepage/charset methods into related places.Artem Strygin
Change-Id: I71417cc5b1bd00f77d42740198cc17487ebd686e Reviewed-on: https://pdfium-review.googlesource.com/33330 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Art Snake <art-snake@yandex-team.ru>
2018-05-30Remove unused CFX_MemoryStream::{Attach,Detach}Buffer() methodsTom Sepez
Also, EstimateSize() is similarly unused. Change-Id: Idbbb5a4a1105448731d3541365c30ba37ff7eb29 Reviewed-on: https://pdfium-review.googlesource.com/33314 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-24Improve constness for more CPDF_Objects pointers.Lei Zhang
Most of them can be marked const. A couple are marked non-const because eventually something inside gets modified. Change-Id: I5415ca8d1efdac451cde340272436cd1e6ec433f Reviewed-on: https://pdfium-review.googlesource.com/32184 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org>
2018-05-23Remove GetBits32().Lei Zhang
Replace it with CFX_BitStream. Change-Id: Ib74657f888b8dec8b6fdad7b49e28d250991c590 Reviewed-on: https://pdfium-review.googlesource.com/32852 Commit-Queue: Lei Zhang <thestig@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-23Avoid repeated calculations in CFX_BitStream::GetBits().Lei Zhang
Change-Id: Icfb7c6933625436b9fcf6a9fdfd0e5f655108eca Reviewed-on: https://pdfium-review.googlesource.com/32851 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-23Add unit test for CFX_BitStream.Lei Zhang
Change-Id: I764196b9cc1d437313aac18ee9d5dbed642c7119 Reviewed-on: https://pdfium-review.googlesource.com/32850 Reviewed-by: dsinclair <dsinclair@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-22Make friend RetainPtr<T> statements consistently public.Lei Zhang
Also make destructors private for RetainPtr sub-classes, and add missing destructors. Change-Id: I451bf0aae2dae943b1f450d0aa4ca5124dc578fd Reviewed-on: https://pdfium-review.googlesource.com/32853 Reviewed-by: Tom Sepez <tsepez@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-17Update third_party/base/compiler_specific.h.Lei Zhang
Import Chromium's base/compiler_specific.h from r537069. Now that FALLTHROUGH is available via compiler_specific.h, remove FX_FALLTHROUGH. Change-Id: I8b9631a4f007673e10e0c26951dfd61e9dcada30 Reviewed-on: https://pdfium-review.googlesource.com/32639 Reviewed-by: Nico Weber <thakis@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-16Add support for PartionRealloc to return nullptrRyan Harrison
Currently the PartitionRealloc code path will only exit, with no option to return nullptr on failure, unlike PartitionAlloc code path. This CL refactors the realloc code path to be similar to alloc code path, following the upstream patch: https://chromium-review.googlesource.com/c/chromium/src/+/1044971 This also changes the version of realloc exposed to third party C libs to have the nullptr behaviour, like the exposed version of alloc. This CL is a redo of https://pdfium-review.googlesource.com/c/pdfium/+/31990 BUG=chromium:783022 Change-Id: Ib1b659079585dfd0423d683b8a2c7b6758a22a01 Reviewed-on: https://pdfium-review.googlesource.com/32613 Commit-Queue: Ryan Harrison <rharrison@chromium.org> Reviewed-by: Tom Sepez <tsepez@chromium.org> Reviewed-by: Chris Palmer <palmer@chromium.org>
2018-05-16core: allow building against system icu-ucMiklos Vajna
Use the system ICU header when USE_SYSTEM_ICUUC is defined. Change-Id: Ieeb0e4a11ae86da871644dd0fd84de07e9917fde Reviewed-on: https://pdfium-review.googlesource.com/32490 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Lei Zhang <thestig@chromium.org>
2018-05-16Remove CFX_BidiLineDan Sinclair
The CFX_BidiLine class is just a thin wrapper to hold a set of methods. This CL moves the methods into the anonymous namespace and calls them directly from FX_BidiLine. Change-Id: Iea2ba178fb08339445702c9af4251f3c8ba2beb6 Reviewed-on: https://pdfium-review.googlesource.com/32617 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-16Verify bidi pos is within range before accessingDan Sinclair
This CL verifies that the provided BidiPos is within the acceptable size for the vector before accessing. Bug: chromium:843100 Change-Id: I2955a3ca628b19ee51dd4233726b859729c125af Reviewed-on: https://pdfium-review.googlesource.com/32593 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-15Cap size of exponent when converting floatsDan Sinclair
When detecting the exponent on a floating point number, cap the maximum amount we'll multiply by otherwise we can get excessivly large numbers. Bug: chromium:843074 Change-Id: I6a8d1b4c20b66e305d2727f464119b1e74beb699 Reviewed-on: https://pdfium-review.googlesource.com/32570 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-14Use internal wcstof instead of system wcstod in formcalc lexerDan Sinclair
This CL switches the usage of wcstod to use the FXSYS_wcstof to determine if a given string is a valid floating point number. Using the internal method makes linux slightly slower (10's of ms) makes mac a lot faster 900ms to 60ms for the test case in the bug. The FXSYS_wcstof method has been extended to handle the parsing of float exponents. Unittests were added for FXSYS_wcstof. Bug: chromium:813646 Change-Id: Ie68287a336e3b95a0c0b845d5bf39db6fc82b39c Reviewed-on: https://pdfium-review.googlesource.com/32510 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-10Fixup ASSERT in Bidi handling; Add bidi fuzzer.Dan Sinclair
This CL converts several asserts in the FX_Bidi code to continue instead of asserting in the face of unexpected input. A BIDI fuzzer has been added as well. Bug: chromium:839695 Change-Id: If61f822bde7442c008d50be58f7cecffb6e5d658 Reviewed-on: https://pdfium-review.googlesource.com/32191 Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-08[fm2js] Create fewer CFX_WideTextBuf classesDan Sinclair
This CL modifies the formcalc transpiler to create less CFX_WideTextBuf classes as we convert to JavaScript. This can take some pathalogical formcal from 20sec to convert to .5sec. Bug: chromium:834575 Change-Id: I428883297bbc3a6a325a4ab0ad51834f2f02ab82 Reviewed-on: https://pdfium-review.googlesource.com/32154 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-07Move codepage tables from cpdf_document.cpp to fx_codepage.cppTom Sepez
Avoids scrolling past this noise when looking at document code. No functional changes. Change-Id: I4684a8cf4d8894c699cd1c980bc5fc41b2179ad1 Reviewed-on: https://pdfium-review.googlesource.com/32156 Commit-Queue: Tom Sepez <tsepez@chromium.org> Reviewed-by: dsinclair <dsinclair@chromium.org>
2018-05-07Use checked large integer in ContinueQuickStretchchromium/3424Ryan Harrison
This existing code has the potential for an integer overflow in it. When overflow occurs in this function scaling may partially succeed. This is due to how out of range values are being clamped, which implicitly swallows the overflow. This CL changes the calculation to be performed in a 64-bit space and then attempts to down cast it back to 32-bit space at the end. Because there are multiple steps it is possible for an intermediate value to cause an overflow in 32 bit space, but the final value to be valid. If the downcast is not possible then the stretch operation is failed. An existing test case has been updated, since it encoded an incorrect result. BUG=chromium:839245 Change-Id: I637cc1e2d6c6c2d5394599104f76352c20ead021 Reviewed-on: https://pdfium-review.googlesource.com/32056 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: Ryan Harrison <rharrison@chromium.org>
2018-05-07[xml] Move members to method variables in CFX_XMLParserDan Sinclair
This CL moves several of the member variables to CFX_XMLParser::DoSyntaxParse as they are only used in that method. The names of the members have been updated to make their usage clearer. Change-Id: I460f2bad0181ece278752bd8d93d6bf63dc6d70a Reviewed-on: https://pdfium-review.googlesource.com/32050 Commit-Queue: dsinclair <dsinclair@chromium.org> Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Reviewed-by: Ryan Harrison <rharrison@chromium.org>
2018-05-02[xml] Simplify the CFX_XMLParser parse methodsDan Sinclair
This CL moves the switch from CFX_XMLParse::Parse into CFX_XMLParser::DoSyntaxParse. This means all the work to build the tree is now done in one place instead of spread between the two methods. Change-Id: Ie9c6cd67795c3fcbd3e305187a06cd727d386a7c Reviewed-on: https://pdfium-review.googlesource.com/31950 Reviewed-by: Henrique Nakashima <hnakashima@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>
2018-05-02[xml] Rename CFX_XMLParser::ParseTextCharDan Sinclair
This CL renames ParseTextChar to ProcessTextChar to make the usage clearer. The method does not do any parsing, it just decides if the char is part of an entity or not. Change-Id: I9b70a82a421b02e2352cd07bd88b1e581d8578b7 Reviewed-on: https://pdfium-review.googlesource.com/31930 Reviewed-by: Ryan Harrison <rharrison@chromium.org> Commit-Queue: dsinclair <dsinclair@chromium.org>