diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-13 15:05:36 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2019-02-14 10:33:47 +0000 |
commit | e684a3455bcc29a6e3e66a004e352dea4e1141e7 (patch) | |
tree | d55b4003bde34d7d05f558f02cfd82b2a66a7aac /chromium/pdf | |
parent | 2b94bfe47ccb6c08047959d1c26e392919550e86 (diff) | |
download | qtwebengine-chromium-e684a3455bcc29a6e3e66a004e352dea4e1141e7.tar.gz |
BASELINE: Update Chromium to 72.0.3626.110 and Ninja to 1.9.0
Change-Id: Ic57220b00ecc929a893c91f5cc552f5d3e99e922
Reviewed-by: Michael BrĂ¼ning <michael.bruning@qt.io>
Diffstat (limited to 'chromium/pdf')
-rw-r--r-- | chromium/pdf/BUILD.gn | 17 | ||||
-rw-r--r-- | chromium/pdf/out_of_process_instance.cc | 87 | ||||
-rw-r--r-- | chromium/pdf/pdf_engine.h | 3 | ||||
-rw-r--r-- | chromium/pdf/pdf_features.cc | 17 | ||||
-rw-r--r-- | chromium/pdf/pdf_features.h | 22 | ||||
-rw-r--r-- | chromium/pdf/pdfium/findtext_unittest.cc | 39 | ||||
-rw-r--r-- | chromium/pdf/pdfium/fuzzers/BUILD.gn | 268 | ||||
-rw-r--r-- | chromium/pdf/pdfium/pdfium_engine.cc | 53 | ||||
-rw-r--r-- | chromium/pdf/pdfium/pdfium_engine.h | 2 | ||||
-rw-r--r-- | chromium/pdf/pdfium/pdfium_engine_exports.cc | 4 | ||||
-rw-r--r-- | chromium/pdf/pdfium/pdfium_print.cc | 2 |
11 files changed, 328 insertions, 186 deletions
diff --git a/chromium/pdf/BUILD.gn b/chromium/pdf/BUILD.gn index eccebb6f9de..91d1c8dd9e8 100644 --- a/chromium/pdf/BUILD.gn +++ b/chromium/pdf/BUILD.gn @@ -33,6 +33,7 @@ if (enable_pdf) { jumbo_static_library("pdf") { configs += [ ":pdf_common_config" ] deps = [ + ":features", "//base", "//gin", "//net", @@ -112,6 +113,22 @@ if (enable_pdf) { } } + source_set("features") { + configs += [ ":pdf_common_config" ] + deps = [ + "//base", + ] + + public = [ + "pdf_features.h", + ] + + sources = [ + "pdf_features.cc", + "pdf_features.h", + ] + } + source_set("pdf_test_utils") { testonly = true sources = [ diff --git a/chromium/pdf/out_of_process_instance.cc b/chromium/pdf/out_of_process_instance.cc index 788082cd637..ef12260b6a7 100644 --- a/chromium/pdf/out_of_process_instance.cc +++ b/chromium/pdf/out_of_process_instance.cc @@ -22,6 +22,7 @@ #include "chrome/common/content_restriction.h" #include "net/base/escape.h" #include "pdf/pdf.h" +#include "pdf/pdf_features.h" #include "ppapi/c/dev/ppb_cursor_control_dev.h" #include "ppapi/c/pp_errors.h" #include "ppapi/c/pp_rect.h" @@ -50,16 +51,12 @@ namespace chrome_pdf { namespace { -const base::Feature kSaveEditedPDFFormExperiment{ - "SaveEditedPDFForm", base::FEATURE_DISABLED_BY_DEFAULT}; - constexpr char kChromePrint[] = "chrome://print/"; constexpr char kChromeExtension[] = "chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai"; // Constants used in handling postMessage() messages. constexpr char kType[] = "type"; -constexpr char kJSId[] = "id"; // Beep messge arguments. (Plugin -> Page). constexpr char kJSBeepType[] = "beep"; // Viewport message arguments. (Page -> Plugin). @@ -160,9 +157,6 @@ constexpr char kJSGetNamedDestination[] = "namedDestination"; constexpr char kJSGetNamedDestinationReplyType[] = "getNamedDestinationReply"; constexpr char kJSNamedDestinationPageNumber[] = "pageNumber"; -constexpr char kJSTransformPagePointType[] = "transformPagePoint"; -constexpr char kJSTransformPagePointReplyType[] = "transformPagePointReply"; - // Selecting text in document (Plugin -> Page) constexpr char kJSSetIsSelectingType[] = "setIsSelecting"; constexpr char kJSIsSelecting[] = "isSelecting"; @@ -544,10 +538,14 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) { std::string type = dict.Get(kType).AsString(); - if (type == kJSViewportType && dict.Get(pp::Var(kJSXOffset)).is_number() && - dict.Get(pp::Var(kJSYOffset)).is_number() && - dict.Get(pp::Var(kJSZoom)).is_number() && - dict.Get(pp::Var(kJSPinchPhase)).is_number()) { + if (type == kJSViewportType) { + if (!(dict.Get(pp::Var(kJSXOffset)).is_number() && + dict.Get(pp::Var(kJSYOffset)).is_number() && + dict.Get(pp::Var(kJSZoom)).is_number() && + dict.Get(pp::Var(kJSPinchPhase)).is_number())) { + NOTREACHED(); + return; + } received_viewport_message_ = true; stop_scrolling_ = false; PinchPhase pinch_phase = @@ -652,8 +650,11 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) { scroll_offset = BoundScrollOffsetToDocument(scroll_offset); engine_->ScrolledToXPosition(scroll_offset.x() * device_scale_); engine_->ScrolledToYPosition(scroll_offset.y() * device_scale_); - } else if (type == kJSGetPasswordCompleteType && - dict.Get(pp::Var(kJSPassword)).is_string()) { + } else if (type == kJSGetPasswordCompleteType) { + if (!dict.Get(pp::Var(kJSPassword)).is_string()) { + NOTREACHED(); + return; + } if (password_callback_) { pp::CompletionCallbackWithOutput<pp::Var> callback = *password_callback_; password_callback_.reset(); @@ -664,7 +665,11 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) { } } else if (type == kJSPrintType) { Print(); - } else if (type == kJSSaveType && dict.Get(pp::Var(kJSToken)).is_string()) { + } else if (type == kJSSaveType) { + if (!dict.Get(pp::Var(kJSToken)).is_string()) { + NOTREACHED(); + return; + } Save(dict.Get(pp::Var(kJSToken)).AsString()); } else if (type == kJSRotateClockwiseType) { RotateClockwise(); @@ -672,10 +677,14 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) { RotateCounterclockwise(); } else if (type == kJSSelectAllType) { engine_->SelectAll(); - } else if (type == kJSResetPrintPreviewModeType && - dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && - dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() && - dict.Get(pp::Var(kJSPrintPreviewPageCount)).is_int()) { + } else if (type == kJSResetPrintPreviewModeType) { + if (!(dict.Get(pp::Var(kJSPrintPreviewUrl)).is_string() && + dict.Get(pp::Var(kJSPrintPreviewGrayscale)).is_bool() && + dict.Get(pp::Var(kJSPrintPreviewPageCount)).is_int())) { + NOTREACHED(); + return; + } + // For security reasons, crash if the URL that is trying to be loaded here // isn't a print preview one. std::string url = dict.Get(pp::Var(kJSPrintPreviewUrl)).AsString(); @@ -721,9 +730,13 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) { paint_manager_.InvalidateRect(pp::Rect(pp::Point(), plugin_size_)); PrintPreviewHistogramEnumeration(PRINT_PREVIEW_SHOWN); - } else if (type == kJSLoadPreviewPageType && - dict.Get(pp::Var(kJSPreviewPageUrl)).is_string() && - dict.Get(pp::Var(kJSPreviewPageIndex)).is_int()) { + } else if (type == kJSLoadPreviewPageType) { + if (!(dict.Get(pp::Var(kJSPreviewPageUrl)).is_string() && + dict.Get(pp::Var(kJSPreviewPageIndex)).is_int())) { + NOTREACHED(); + return; + } + std::string url = dict.Get(pp::Var(kJSPreviewPageUrl)).AsString(); // For security reasons we crash if the URL that is trying to be loaded here // isn't a print preview one. @@ -740,8 +753,11 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) { reply.Set(pp::Var(kType), pp::Var(kJSGetSelectedTextReplyType)); reply.Set(pp::Var(kJSSelectedText), selected_text); PostMessage(reply); - } else if (type == kJSGetNamedDestinationType && - dict.Get(pp::Var(kJSGetNamedDestination)).is_string()) { + } else if (type == kJSGetNamedDestinationType) { + if (!dict.Get(pp::Var(kJSGetNamedDestination)).is_string()) { + NOTREACHED(); + return; + } base::Optional<PDFEngine::NamedDestination> named_destination = engine_->GetNamedDestination( dict.Get(pp::Var(kJSGetNamedDestination)).AsString()); @@ -751,22 +767,6 @@ void OutOfProcessInstance::HandleMessage(const pp::Var& message) { pp::Var(kJSNamedDestinationPageNumber), named_destination ? static_cast<int>(named_destination->page) : -1); PostMessage(reply); - } else if (type == kJSTransformPagePointType && - dict.Get(pp::Var(kJSPageNumber)).is_int() && - dict.Get(pp::Var(kJSPageX)).is_int() && - dict.Get(pp::Var(kJSPageY)).is_int() && - dict.Get(pp::Var(kJSId)).is_int()) { - gfx::PointF page_xy(dict.Get(pp::Var(kJSPageX)).AsInt(), - dict.Get(pp::Var(kJSPageY)).AsInt()); - gfx::PointF device_xy = engine_->TransformPagePoint( - dict.Get(pp::Var(kJSPageNumber)).AsInt(), page_xy); - - pp::VarDictionary reply; - reply.Set(pp::Var(kType), pp::Var(kJSTransformPagePointReplyType)); - reply.Set(pp::Var(kJSPositionX), device_xy.x()); - reply.Set(pp::Var(kJSPositionY), device_xy.y()); - reply.Set(pp::Var(kJSId), dict.Get(pp::Var(kJSId)).AsInt()); - PostMessage(reply); } else { NOTREACHED(); } @@ -1360,7 +1360,7 @@ void OutOfProcessInstance::ScrollBy(const pp::Point& point) { } void OutOfProcessInstance::ScrollToPage(int page) { - if (engine_->GetNumberOfPages() == 0) + if (!engine_ || engine_->GetNumberOfPages() == 0) return; pp::VarDictionary message; @@ -1476,7 +1476,7 @@ void OutOfProcessInstance::GetDocumentPassword( void OutOfProcessInstance::Save(const std::string& token) { engine_->KillFormFocus(); - if (!base::FeatureList::IsEnabled(kSaveEditedPDFFormExperiment) || + if (!base::FeatureList::IsEnabled(features::kSaveEditedPDFForm) || !edit_mode_) { ConsumeSaveToken(token); pp::PDF::SaveAs(this); @@ -1557,8 +1557,9 @@ void OutOfProcessInstance::Email(const std::string& to, } void OutOfProcessInstance::Print() { - if (!engine_->HasPermission(PDFEngine::PERMISSION_PRINT_LOW_QUALITY) && - !engine_->HasPermission(PDFEngine::PERMISSION_PRINT_HIGH_QUALITY)) { + if (!engine_ || + (!engine_->HasPermission(PDFEngine::PERMISSION_PRINT_LOW_QUALITY) && + !engine_->HasPermission(PDFEngine::PERMISSION_PRINT_HIGH_QUALITY))) { return; } diff --git a/chromium/pdf/pdf_engine.h b/chromium/pdf/pdf_engine.h index 047f24611e1..64ed8eeb066 100644 --- a/chromium/pdf/pdf_engine.h +++ b/chromium/pdf/pdf_engine.h @@ -343,9 +343,6 @@ class PDFEngine { // Gets the named destination by name. virtual base::Optional<PDFEngine::NamedDestination> GetNamedDestination( const std::string& destination) = 0; - // Transforms an (x, y) point in page coordinates to screen coordinates. - virtual gfx::PointF TransformPagePoint(int page_index, - const gfx::PointF& page_xy) = 0; // Gets the index of the most visible page, or -1 if none are visible. virtual int GetMostVisiblePage() = 0; // Gets the rectangle of the page including shadow. diff --git a/chromium/pdf/pdf_features.cc b/chromium/pdf/pdf_features.cc new file mode 100644 index 00000000000..2b9d28a7afd --- /dev/null +++ b/chromium/pdf/pdf_features.cc @@ -0,0 +1,17 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "pdf/pdf_features.h" + +namespace chrome_pdf { +namespace features { + +const base::Feature kSaveEditedPDFForm{"SaveEditedPDFForm", + base::FEATURE_DISABLED_BY_DEFAULT}; + +const base::Feature kPDFAnnotations{"PDFAnnotations", + base::FEATURE_DISABLED_BY_DEFAULT}; + +} // namespace features +} // namespace chrome_pdf diff --git a/chromium/pdf/pdf_features.h b/chromium/pdf/pdf_features.h new file mode 100644 index 00000000000..43644313e7d --- /dev/null +++ b/chromium/pdf/pdf_features.h @@ -0,0 +1,22 @@ +// Copyright 2018 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// This file defines all the public base::FeatureList features for the pdf +// module. + +#ifndef PDF_PDF_FEATURES_H_ +#define PDF_PDF_FEATURES_H_ + +#include "base/feature_list.h" + +namespace chrome_pdf { +namespace features { + +extern const base::Feature kSaveEditedPDFForm; +extern const base::Feature kPDFAnnotations; + +} // namespace features +} // namespace chrome_pdf + +#endif // PDF_PDF_FEATURES_H_ diff --git a/chromium/pdf/pdfium/findtext_unittest.cc b/chromium/pdf/pdfium/findtext_unittest.cc index 895fc39d66a..c77e7f2b7ae 100644 --- a/chromium/pdf/pdfium/findtext_unittest.cc +++ b/chromium/pdf/pdfium/findtext_unittest.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include "base/optional.h" +#include "base/strings/utf_string_conversions.h" #include "pdf/pdfium/pdfium_engine.h" #include "pdf/pdfium/pdfium_test_base.h" #include "pdf/test/test_client.h" @@ -111,4 +112,42 @@ TEST_F(FindTextTest, FindLineBreakText) { engine->StartFind("is the first system", /*case_sensitive=*/true); } +TEST_F(FindTextTest, FindSimpleQuotationMarkText) { + FindTextTestClient client; + std::unique_ptr<PDFiumEngine> engine = + InitializeEngine(&client, FILE_PATH_LITERAL("bug_142627.pdf")); + ASSERT_TRUE(engine); + + { + InSequence sequence; + + EXPECT_CALL(client, NotifyNumberOfFindResultsChanged(1, false)); + EXPECT_CALL(client, NotifySelectedFindResultChanged(0)); + EXPECT_CALL(client, NotifyNumberOfFindResultsChanged(2, false)); + EXPECT_CALL(client, NotifyNumberOfFindResultsChanged(2, true)); + } + + engine->StartFind("don't", /*case_sensitive=*/true); +} + +TEST_F(FindTextTest, FindFancyQuotationMarkText) { + FindTextTestClient client; + std::unique_ptr<PDFiumEngine> engine = + InitializeEngine(&client, FILE_PATH_LITERAL("bug_142627.pdf")); + ASSERT_TRUE(engine); + + { + InSequence sequence; + + EXPECT_CALL(client, NotifyNumberOfFindResultsChanged(1, false)); + EXPECT_CALL(client, NotifySelectedFindResultChanged(0)); + EXPECT_CALL(client, NotifyNumberOfFindResultsChanged(2, false)); + EXPECT_CALL(client, NotifyNumberOfFindResultsChanged(2, true)); + } + + // don't, using right apostrophe instead of a single quotation mark + base::string16 term = {'d', 'o', 'n', 0x2019, 't'}; + engine->StartFind(base::UTF16ToUTF8(term), /*case_sensitive=*/true); +} + } // namespace chrome_pdf diff --git a/chromium/pdf/pdfium/fuzzers/BUILD.gn b/chromium/pdf/pdfium/fuzzers/BUILD.gn index 124139ea78b..e6e9f0f7af8 100644 --- a/chromium/pdf/pdfium/fuzzers/BUILD.gn +++ b/chromium/pdf/pdfium/fuzzers/BUILD.gn @@ -6,8 +6,8 @@ # When adding a fuzzer_test target make sure to add it to the group # 'pdf_fuzzers' -import("//testing/test.gni") import("//testing/libfuzzer/fuzzer_test.gni") +import("//testing/test.gni") import("//third_party/pdfium/pdfium.gni") group("fuzzers") { @@ -27,33 +27,39 @@ group("pdf_fuzzers") { ":pdf_jpx_fuzzer", ":pdf_psengine_fuzzer", ":pdf_streamparser_fuzzer", + ":pdf_xml_fuzzer", ":pdfium_fuzzer", ] - if (pdf_enable_xfa) { + if (pdf_enable_v8) { deps += [ - ":pdf_bidi_fuzzer", - ":pdf_cfx_barcode_fuzzer", - ":pdf_codec_jpeg_fuzzer", - ":pdf_css_fuzzer", - ":pdf_fm2js_fuzzer", - ":pdf_formcalc_fuzzer", - ":pdf_xml_fuzzer", - ":pdfium_xfa_fuzzer", + ":pdf_cjs_util_fuzzer", + ":pdf_fx_date_helpers_fuzzer", ] - if (pdf_enable_xfa_bmp) { - deps += [ ":pdf_codec_bmp_fuzzer" ] - } - if (pdf_enable_xfa_gif) { + if (pdf_enable_xfa) { deps += [ - ":pdf_codec_gif_fuzzer", - ":pdf_lzw_fuzzer", + ":pdf_bidi_fuzzer", + ":pdf_cfx_barcode_fuzzer", + ":pdf_codec_jpeg_fuzzer", + ":pdf_css_fuzzer", + ":pdf_fm2js_fuzzer", + ":pdf_formcalc_fuzzer", + ":pdfium_xfa_fuzzer", ] - } - if (pdf_enable_xfa_png) { - deps += [ ":pdf_codec_png_fuzzer" ] - } - if (pdf_enable_xfa_tiff) { - deps += [ ":pdf_codec_tiff_fuzzer" ] + if (pdf_enable_xfa_bmp) { + deps += [ ":pdf_codec_bmp_fuzzer" ] + } + if (pdf_enable_xfa_gif) { + deps += [ + ":pdf_codec_gif_fuzzer", + ":pdf_lzw_fuzzer", + ] + } + if (pdf_enable_xfa_png) { + deps += [ ":pdf_codec_png_fuzzer" ] + } + if (pdf_enable_xfa_tiff) { + deps += [ ":pdf_codec_tiff_fuzzer" ] + } } } } @@ -65,10 +71,6 @@ fuzzer_test("pdfium_fuzzer") { ] dict = "dicts/pdf.dict" seed_corpus = "//third_party/pdfium/testing/resources" - deps += [ - "//third_party/pdfium", - "//third_party/pdfium:test_support", - ] } fuzzer_test("pdf_cmap_fuzzer") { @@ -114,6 +116,13 @@ fuzzer_test("pdf_codec_jbig2_fuzzer") { ] } +fuzzer_test("pdf_font_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/fuzzers:pdf_font_fuzzer_src", + ] +} + fuzzer_test("pdf_hint_table_fuzzer") { sources = [] deps = [ @@ -129,146 +138,155 @@ fuzzer_test("pdf_jpx_fuzzer") { seed_corpus = "corpora/pdf_jpx" } -fuzzer_test("pdf_font_fuzzer") { +fuzzer_test("pdf_psengine_fuzzer") { sources = [] deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_font_fuzzer_src", + "//third_party/pdfium/testing/fuzzers:pdf_psengine_fuzzer_src", ] } -fuzzer_test("pdf_psengine_fuzzer") { +fuzzer_test("pdf_streamparser_fuzzer") { sources = [] deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_psengine_fuzzer_src", + "//third_party/pdfium/testing/fuzzers:pdf_streamparser_fuzzer_src", ] } -fuzzer_test("pdf_streamparser_fuzzer") { +fuzzer_test("pdf_xml_fuzzer") { sources = [] deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_streamparser_fuzzer_src", + "//third_party/pdfium/testing/fuzzers:pdf_xml_fuzzer_src", ] + dict = "dicts/pdf_xml.dict" } -if (pdf_enable_xfa) { - if (pdf_enable_xfa_bmp) { - fuzzer_test("pdf_codec_bmp_fuzzer") { +if (pdf_enable_v8) { + fuzzer_test("pdf_cjs_util_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/fuzzers:pdf_cjs_util_fuzzer_src", + ] + } + + fuzzer_test("pdf_fx_date_helpers_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/fuzzers:pdf_fx_date_helpers_fuzzer_src", + ] + } + + if (pdf_enable_xfa) { + if (pdf_enable_xfa_bmp) { + fuzzer_test("pdf_codec_bmp_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/fuzzers:pdf_codec_bmp_fuzzer_src", + ] + seed_corpus = "corpora/pdf_codec_bmp" + } + } + + if (pdf_enable_xfa_gif) { + fuzzer_test("pdf_codec_gif_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/fuzzers:pdf_codec_gif_fuzzer_src", + ] + dict = "dicts/pdf_codec_gif.dict" + seed_corpus = "corpora/pdf_codec_gif" + } + } + + fuzzer_test("pdf_codec_jpeg_fuzzer") { sources = [] deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_codec_bmp_fuzzer_src", + "//third_party/pdfium/testing/fuzzers:pdf_codec_jpeg_fuzzer_src", ] - seed_corpus = "corpora/pdf_codec_bmp" + dict = "dicts/pdf_codec_jpeg.dict" + seed_corpus = "corpora/pdf_codec_jpeg" + } + + if (pdf_enable_xfa_png) { + fuzzer_test("pdf_codec_png_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/fuzzers:pdf_codec_png_fuzzer_src", + ] + dict = "dicts/pdf_codec_png.dict" + seed_corpuses = [ + "corpora/pdf_codec_png", + "//components/viz/test/data", + "//third_party/blink/web_tests/images/png-suite/samples", + "//third_party/blink/web_tests/images/resources/pngfuzz", + ] + } + } + + if (pdf_enable_xfa_tiff) { + fuzzer_test("pdf_codec_tiff_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/fuzzers:pdf_codec_tiff_fuzzer_src", + ] + dict = "dicts/pdf_codec_tiff.dict" + seed_corpus = "corpora/pdf_codec_tiff" + } } - } - if (pdf_enable_xfa_gif) { - fuzzer_test("pdf_codec_gif_fuzzer") { + fuzzer_test("pdf_css_fuzzer") { sources = [] deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_codec_gif_fuzzer_src", + "//third_party/pdfium/testing/fuzzers:pdf_css_fuzzer_src", ] - dict = "dicts/pdf_codec_gif.dict" - seed_corpus = "corpora/pdf_codec_gif" + dict = "dicts/pdf_css.dict" } - } - fuzzer_test("pdf_codec_jpeg_fuzzer") { - sources = [] - deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_codec_jpeg_fuzzer_src", - ] - dict = "dicts/pdf_codec_jpeg.dict" - seed_corpus = "corpora/pdf_codec_jpeg" - } - - if (pdf_enable_xfa_png) { - fuzzer_test("pdf_codec_png_fuzzer") { + fuzzer_test("pdf_fm2js_fuzzer") { sources = [] deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_codec_png_fuzzer_src", - ] - dict = "dicts/pdf_codec_png.dict" - seed_corpuses = [ - "corpora/pdf_codec_png", - "//components/viz/test/data", - "//third_party/WebKit/LayoutTests/images/png-suite/samples", - "//third_party/WebKit/LayoutTests/images/resources/pngfuzz", + "//third_party/pdfium/testing/fuzzers:pdf_fm2js_fuzzer_src", ] + dict = "dicts/pdf_formcalc.dict" } - } - if (pdf_enable_xfa_tiff) { - fuzzer_test("pdf_codec_tiff_fuzzer") { + fuzzer_test("pdf_formcalc_fuzzer") { sources = [] deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_codec_tiff_fuzzer_src", + "//third_party/pdfium/testing/fuzzers:pdf_formcalc_fuzzer_src", ] - dict = "dicts/pdf_codec_tiff.dict" - seed_corpus = "corpora/pdf_codec_tiff" + dict = "dicts/pdf_formcalc.dict" } - } - - fuzzer_test("pdf_css_fuzzer") { - sources = [] - deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_css_fuzzer_src", - ] - dict = "dicts/pdf_css.dict" - } - fuzzer_test("pdf_fm2js_fuzzer") { - sources = [] - deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_fm2js_fuzzer_src", - ] - dict = "dicts/pdf_formcalc.dict" - } - - fuzzer_test("pdf_formcalc_fuzzer") { - sources = [] - deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_formcalc_fuzzer_src", - ] - dict = "dicts/pdf_formcalc.dict" - } + if (pdf_enable_xfa_gif) { + fuzzer_test("pdf_lzw_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/fuzzers:pdf_lzw_fuzzer_src", + ] + } + } - if (pdf_enable_xfa_gif) { - fuzzer_test("pdf_lzw_fuzzer") { + fuzzer_test("pdf_bidi_fuzzer") { sources = [] deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_lzw_fuzzer_src", + "//third_party/pdfium/testing/fuzzers:pdf_bidi_fuzzer_src", ] } - } - fuzzer_test("pdf_xml_fuzzer") { - sources = [] - deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_xml_fuzzer_src", - ] - dict = "dicts/pdf_xml.dict" - } - - fuzzer_test("pdf_bidi_fuzzer") { - sources = [] - deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_bidi_fuzzer_src", - ] - } - - fuzzer_test("pdf_cfx_barcode_fuzzer") { - sources = [] - deps = [ - "//third_party/pdfium/testing/fuzzers:pdf_cfx_barcode_fuzzer_src", - ] - } + fuzzer_test("pdf_cfx_barcode_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/fuzzers:pdf_cfx_barcode_fuzzer_src", + ] + } - fuzzer_test("pdfium_xfa_fuzzer") { - sources = [] - deps = [ - "//third_party/pdfium/testing/fuzzers:pdfium_xfa_fuzzer_src", - ] - dict = "dicts/pdf.dict" - seed_corpus = "//third_party/pdfium/testing/resources" + fuzzer_test("pdfium_xfa_fuzzer") { + sources = [] + deps = [ + "//third_party/pdfium/testing/fuzzers:pdfium_xfa_fuzzer_src", + ] + dict = "dicts/pdf.dict" + seed_corpus = "//third_party/pdfium/testing/resources" + } } } diff --git a/chromium/pdf/pdfium/pdfium_engine.cc b/chromium/pdf/pdfium/pdfium_engine.cc index 80fd5a03f3d..51f7b4f6c5c 100644 --- a/chromium/pdf/pdfium/pdfium_engine.cc +++ b/chromium/pdf/pdfium/pdfium_engine.cc @@ -533,6 +533,9 @@ std::string GetDocumentMetadata(FPDF_DOCUMENT doc, const std::string& key) { gin::IsolateHolder* g_isolate_holder = nullptr; void SetUpV8() { + static const char kNoExposeWasm[] = "--no-expose-wasm"; + v8::V8::SetFlagsFromString(kNoExposeWasm, strlen(kNoExposeWasm)); + gin::IsolateHolder::Initialize(gin::IsolateHolder::kNonStrictMode, gin::IsolateHolder::kStableV8Extras, gin::ArrayBufferAllocator::SharedInstance()); @@ -625,6 +628,31 @@ std::string ConvertViewIntToViewString(unsigned long view_int) { } } +// Simplify to \" for searching +constexpr wchar_t kHebrewPunctuationGershayimCharacter = 0x05F4; +constexpr wchar_t kLeftDoubleQuotationMarkCharacter = 0x201C; +constexpr wchar_t kRightDoubleQuotationMarkCharacter = 0x201D; + +// Simplify \' for searching +constexpr wchar_t kHebrewPunctuationGereshCharacter = 0x05F3; +constexpr wchar_t kLeftSingleQuotationMarkCharacter = 0x2018; +constexpr wchar_t kRightSingleQuotationMarkCharacter = 0x2019; + +wchar_t SimplifyForSearch(wchar_t c) { + switch (c) { + case kHebrewPunctuationGershayimCharacter: + case kLeftDoubleQuotationMarkCharacter: + case kRightDoubleQuotationMarkCharacter: + return L'\"'; + case kHebrewPunctuationGereshCharacter: + case kLeftSingleQuotationMarkCharacter: + case kRightSingleQuotationMarkCharacter:; + return L'\''; + default: + return c; + } +} + } // namespace bool InitializeSDK() { @@ -1343,7 +1371,12 @@ bool PDFiumEngine::OnLeftMouseDown(const pp::MouseInputEvent& event) { is_form_text_area && IsPointInEditableFormTextArea(page, page_x, page_y, form_type); - FORM_OnLButtonDown(form(), page, event.GetModifiers(), page_x, page_y); + if (event.GetClickCount() == 1) { + FORM_OnLButtonDown(form(), page, event.GetModifiers(), page_x, page_y); + } else if (event.GetClickCount() == 2) { + FORM_OnLButtonDoubleClick(form(), page, event.GetModifiers(), page_x, + page_y); + } if (form_type != FPDF_FORMFIELD_UNKNOWN) { // Destroy SelectionChangeInvalidator object before SetInFormTextArea() // changes plugin's focus to be in form text area. This way, regular text @@ -1913,6 +1946,12 @@ void PDFiumEngine::SearchUsingICU(const base::string16& term, int current_page) { DCHECK(!term.empty()); + // Various types of quotions marks need to be converted to the simple ASCII + // version for searching to get better matching. + base::string16 adjusted_term = term; + for (base::char16& c : adjusted_term) + c = SimplifyForSearch(c); + const int original_text_length = pages_[current_page]->GetCharCount(); int text_length = original_text_length; if (character_to_start_searching_from) { @@ -1969,11 +2008,11 @@ void PDFiumEngine::SearchUsingICU(const base::string16& term, if (IsIgnorableCharacter(c)) removed_indices.push_back(adjusted_page_text.size()); else - adjusted_page_text.push_back(c); + adjusted_page_text.push_back(SimplifyForSearch(c)); } std::vector<PDFEngine::Client::SearchStringResult> results = - client_->SearchString(adjusted_page_text.c_str(), term.c_str(), + client_->SearchString(adjusted_page_text.c_str(), adjusted_term.c_str(), case_sensitive); for (const auto& result : results) { // Need to convert from adjusted page text start to page text start, by @@ -2399,12 +2438,6 @@ base::Optional<PDFEngine::NamedDestination> PDFiumEngine::GetNamedDestination( return result; } -gfx::PointF PDFiumEngine::TransformPagePoint(int page_index, - const gfx::PointF& page_xy) { - DCHECK(PageIndexInBounds(page_index)); - return pages_[page_index]->TransformPageToScreenXY(page_xy); -} - int PDFiumEngine::GetMostVisiblePage() { if (in_flight_visible_page_) return *in_flight_visible_page_; @@ -3185,7 +3218,7 @@ void PDFiumEngine::GetPDFiumRect(int page_index, } int PDFiumEngine::GetRenderingFlags() const { - int flags = FPDF_LCD_TEXT | FPDF_NO_CATCH; + int flags = FPDF_LCD_TEXT; if (render_grayscale_) flags |= FPDF_GRAYSCALE; if (client_->IsPrintPreview()) diff --git a/chromium/pdf/pdfium/pdfium_engine.h b/chromium/pdf/pdfium/pdfium_engine.h index 4d931205046..792b0548c95 100644 --- a/chromium/pdf/pdfium/pdfium_engine.h +++ b/chromium/pdf/pdfium/pdfium_engine.h @@ -95,8 +95,6 @@ class PDFiumEngine : public PDFEngine, pp::VarArray GetBookmarks() override; base::Optional<PDFEngine::NamedDestination> GetNamedDestination( const std::string& destination) override; - gfx::PointF TransformPagePoint(int page_index, - const gfx::PointF& page_xy) override; int GetMostVisiblePage() override; pp::Rect GetPageRect(int index) override; pp::Rect GetPageBoundsRect(int index) override; diff --git a/chromium/pdf/pdfium/pdfium_engine_exports.cc b/chromium/pdf/pdfium/pdfium_engine_exports.cc index e0465a84911..aa3c6630be0 100644 --- a/chromium/pdf/pdfium/pdfium_engine_exports.cc +++ b/chromium/pdf/pdfium/pdfium_engine_exports.cc @@ -192,7 +192,7 @@ bool PDFiumEngineExports::RenderPDFPageToDC( settings.bounds.x() + settings.bounds.width(), settings.bounds.y() + settings.bounds.height()); - int flags = FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH; + int flags = FPDF_ANNOT | FPDF_PRINTING; if (!settings.use_color) flags |= FPDF_GRAYSCALE; @@ -272,7 +272,7 @@ bool PDFiumEngineExports::RenderPDFPageToBitmap( // Shift top-left corner of bounds to (0, 0) if it's not there. dest.set_point(dest.point() - settings.bounds.point()); - int flags = FPDF_ANNOT | FPDF_PRINTING | FPDF_NO_CATCH; + int flags = FPDF_ANNOT | FPDF_PRINTING; if (!settings.use_color) flags |= FPDF_GRAYSCALE; diff --git a/chromium/pdf/pdfium/pdfium_print.cc b/chromium/pdf/pdfium/pdfium_print.cc index 73e034ca9d6..c3961e3ff36 100644 --- a/chromium/pdf/pdfium/pdfium_print.cc +++ b/chromium/pdf/pdfium/pdfium_print.cc @@ -413,7 +413,7 @@ ScopedFPDFDocument PDFiumPrint::CreateSinglePageRasterPdf( FPDF_RenderPageBitmap(bitmap.get(), page_to_print, 0, 0, bitmap_size.width(), bitmap_size.height(), print_settings.orientation, - FPDF_PRINTING | FPDF_NO_CATCH); + FPDF_PRINTING); unsigned char* bitmap_data = static_cast<unsigned char*>(FPDFBitmap_GetBuffer(bitmap.get())); |