summaryrefslogtreecommitdiff
path: root/chromium/pdf/pdfium
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/pdf/pdfium')
-rw-r--r--chromium/pdf/pdfium/DEPS7
-rw-r--r--chromium/pdf/pdfium/findtext_unittest.cc12
-rw-r--r--chromium/pdf/pdfium/pdfium_api_string_buffer_adapter.cc12
-rw-r--r--chromium/pdf/pdfium/pdfium_api_string_buffer_adapter.h21
-rw-r--r--chromium/pdf/pdfium/pdfium_assert_matching_enums.cc12
-rw-r--r--chromium/pdf/pdfium/pdfium_engine.cc128
-rw-r--r--chromium/pdf/pdfium/pdfium_engine.h8
-rw-r--r--chromium/pdf/pdfium/pdfium_engine_exports.cc6
-rw-r--r--chromium/pdf/pdfium/pdfium_engine_unittest.cc2
-rw-r--r--chromium/pdf/pdfium/pdfium_form_filler.cc7
-rw-r--r--chromium/pdf/pdfium/pdfium_page.cc29
-rw-r--r--chromium/pdf/pdfium/pdfium_page.h10
-rw-r--r--chromium/pdf/pdfium/pdfium_page_unittest.cc2
-rw-r--r--chromium/pdf/pdfium/pdfium_range.cc10
-rw-r--r--chromium/pdf/pdfium/pdfium_range.h9
15 files changed, 140 insertions, 135 deletions
diff --git a/chromium/pdf/pdfium/DEPS b/chromium/pdf/pdfium/DEPS
index 446fbe1bfa7..16ff3841b22 100644
--- a/chromium/pdf/pdfium/DEPS
+++ b/chromium/pdf/pdfium/DEPS
@@ -1,10 +1,5 @@
include_rules = [
- "+gin/array_buffer.h",
- "+gin/v8_initializer.h",
- "+printing/nup_parameters.h",
- "+printing/page_setup.h",
- "+printing/pdf_render_settings.h",
"+third_party/pdfium/public",
- "+ui/gfx/codec/jpeg_codec.h",
+ "+ui/gfx/codec",
"+v8/include/cppgc/platform.h",
]
diff --git a/chromium/pdf/pdfium/findtext_unittest.cc b/chromium/pdf/pdfium/findtext_unittest.cc
index 818a6f606d4..acca90d79c8 100644
--- a/chromium/pdf/pdfium/findtext_unittest.cc
+++ b/chromium/pdf/pdfium/findtext_unittest.cc
@@ -27,19 +27,19 @@ class FindTextTestClient : public TestClient {
MOCK_METHOD(void, NotifyNumberOfFindResultsChanged, (int, bool), (override));
MOCK_METHOD(void, NotifySelectedFindResultChanged, (int), (override));
- std::vector<SearchStringResult> SearchString(const base::char16* string,
- const base::char16* term,
+ std::vector<SearchStringResult> SearchString(const char16_t* string,
+ const char16_t* term,
bool case_sensitive) override {
EXPECT_TRUE(case_sensitive);
- base::string16 haystack = base::string16(string);
- base::string16 needle = base::string16(term);
+ std::u16string haystack = std::u16string(string);
+ std::u16string needle = std::u16string(term);
std::vector<SearchStringResult> results;
size_t pos = 0;
while (1) {
pos = haystack.find(needle, pos);
- if (pos == base::string16::npos)
+ if (pos == std::u16string::npos)
break;
SearchStringResult result;
@@ -145,7 +145,7 @@ TEST_F(FindTextTest, FindFancyQuotationMarkText) {
}
// don't, using right apostrophe instead of a single quotation mark
- base::string16 term = {'d', 'o', 'n', 0x2019, 't'};
+ std::u16string term = {'d', 'o', 'n', 0x2019, 't'};
engine->StartFind(base::UTF16ToUTF8(term), /*case_sensitive=*/true);
}
diff --git a/chromium/pdf/pdfium/pdfium_api_string_buffer_adapter.cc b/chromium/pdf/pdfium/pdfium_api_string_buffer_adapter.cc
index 9e02e34906f..35da69a615e 100644
--- a/chromium/pdf/pdfium/pdfium_api_string_buffer_adapter.cc
+++ b/chromium/pdf/pdfium/pdfium_api_string_buffer_adapter.cc
@@ -52,11 +52,11 @@ void PDFiumAPIStringBufferAdapter<StringType>::Close(size_t actual_size) {
}
PDFiumAPIStringBufferSizeInBytesAdapter::
- PDFiumAPIStringBufferSizeInBytesAdapter(base::string16* str,
+ PDFiumAPIStringBufferSizeInBytesAdapter(std::u16string* str,
size_t expected_size,
bool check_expected_size)
- : adapter_(str, expected_size / sizeof(base::char16), check_expected_size) {
- DCHECK(expected_size % sizeof(base::char16) == 0);
+ : adapter_(str, expected_size / sizeof(char16_t), check_expected_size) {
+ DCHECK(expected_size % sizeof(char16_t) == 0);
}
PDFiumAPIStringBufferSizeInBytesAdapter::
@@ -67,13 +67,13 @@ void* PDFiumAPIStringBufferSizeInBytesAdapter::GetData() {
}
void PDFiumAPIStringBufferSizeInBytesAdapter::Close(size_t actual_size) {
- DCHECK(actual_size % sizeof(base::char16) == 0);
- adapter_.Close(actual_size / sizeof(base::char16));
+ DCHECK(actual_size % sizeof(char16_t) == 0);
+ adapter_.Close(actual_size / sizeof(char16_t));
}
// explicit instantiations
template class PDFiumAPIStringBufferAdapter<std::string>;
-template class PDFiumAPIStringBufferAdapter<base::string16>;
+template class PDFiumAPIStringBufferAdapter<std::u16string>;
} // namespace internal
diff --git a/chromium/pdf/pdfium/pdfium_api_string_buffer_adapter.h b/chromium/pdf/pdfium/pdfium_api_string_buffer_adapter.h
index 320488b855a..4eaaf3c7663 100644
--- a/chromium/pdf/pdfium/pdfium_api_string_buffer_adapter.h
+++ b/chromium/pdf/pdfium/pdfium_api_string_buffer_adapter.h
@@ -12,7 +12,6 @@
#include "base/callback.h"
#include "base/numerics/safe_math.h"
#include "base/optional.h"
-#include "base/strings/string16.h"
namespace chrome_pdf {
@@ -20,7 +19,7 @@ namespace internal {
// Helper to deal with the fact that many PDFium APIs write the null-terminator
// into string buffers that are passed to them, but the PDF code likes to use
-// std::strings / base::string16s, where one should not count on the internal
+// std::strings / std::u16strings, where one should not count on the internal
// string buffers to be null-terminated.
template <class StringType>
class PDFiumAPIStringBufferAdapter {
@@ -63,7 +62,7 @@ class PDFiumAPIStringBufferAdapter {
// Helper to deal with the fact that many PDFium APIs write the null-terminator
// into string buffers that are passed to them, but the PDF code likes to use
-// std::strings / base::string16s, where one should not count on the internal
+// std::strings / std::u16strings, where one should not count on the internal
// string buffers to be null-terminated. This version is suitable for APIs that
// work in terms of number of bytes instead of the number of characters. Though
// for std::strings, PDFiumAPIStringBufferAdapter is equivalent.
@@ -75,17 +74,17 @@ class PDFiumAPIStringBufferSizeInBytesAdapter {
// character in bytes.
// |check_expected_size| whether to check the actual number of bytes
// written into |str| against |expected_size| when calling Close().
- PDFiumAPIStringBufferSizeInBytesAdapter(base::string16* str,
+ PDFiumAPIStringBufferSizeInBytesAdapter(std::u16string* str,
size_t expected_size,
bool check_expected_size);
~PDFiumAPIStringBufferSizeInBytesAdapter();
// Returns a pointer to |str_|'s buffer. The buffer's size is large enough to
- // hold |expected_size_| + sizeof(base::char16) bytes, so the PDFium API that
+ // hold |expected_size_| + sizeof(char16_t) bytes, so the PDFium API that
// uses the pointer has space to write a null-terminator.
void* GetData();
- // Resizes |str_| to |actual_size| - sizeof(base::char16) bytes, thereby
+ // Resizes |str_| to |actual_size| - sizeof(char16_t) bytes, thereby
// removing the extra null-terminator. This must be called prior to the
// adapter's destruction. The pointer returned by GetData() should be
// considered invalid.
@@ -97,7 +96,7 @@ class PDFiumAPIStringBufferSizeInBytesAdapter {
}
private:
- PDFiumAPIStringBufferAdapter<base::string16> adapter_;
+ PDFiumAPIStringBufferAdapter<std::u16string> adapter_;
};
template <class AdapterType,
@@ -136,23 +135,23 @@ StringType CallPDFiumStringBufferApi(
// Helper function to call PDFium APIs where the output buffer is expected to
// hold UTF-16 data, and the buffer length is specified in bytes.
template <typename BufferType>
-base::string16 CallPDFiumWideStringBufferApi(
+std::u16string CallPDFiumWideStringBufferApi(
base::RepeatingCallback<unsigned long(BufferType*, unsigned long)> api,
bool check_expected_size) {
using adapter_type = internal::PDFiumAPIStringBufferSizeInBytesAdapter;
- return internal::CallPDFiumStringBufferApi<adapter_type, base::string16>(
+ return internal::CallPDFiumStringBufferApi<adapter_type, std::u16string>(
api, check_expected_size);
}
// Variant of CallPDFiumWideStringBufferApi() that distinguishes between API
// call failures and empty string return values.
template <typename BufferType>
-base::Optional<base::string16> CallPDFiumWideStringBufferApiAndReturnOptional(
+base::Optional<std::u16string> CallPDFiumWideStringBufferApiAndReturnOptional(
base::RepeatingCallback<unsigned long(BufferType*, unsigned long)> api,
bool check_expected_size) {
using adapter_type = internal::PDFiumAPIStringBufferSizeInBytesAdapter;
return internal::CallPDFiumStringBufferApiAndReturnOptional<adapter_type,
- base::string16>(
+ std::u16string>(
api, check_expected_size);
}
diff --git a/chromium/pdf/pdfium/pdfium_assert_matching_enums.cc b/chromium/pdf/pdfium/pdfium_assert_matching_enums.cc
index 0943ce91409..49faf44e9cb 100644
--- a/chromium/pdf/pdfium/pdfium_assert_matching_enums.cc
+++ b/chromium/pdf/pdfium/pdfium_assert_matching_enums.cc
@@ -4,6 +4,7 @@
#include "build/build_config.h"
#include "pdf/accessibility_structs.h"
+#include "pdf/content_restriction.h"
#include "pdf/document_metadata.h"
#include "pdf/ppapi_migration/input_event_conversions.h"
#include "ppapi/c/pp_input_event.h"
@@ -394,3 +395,14 @@ STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityScrollAlignment::kClosestToEdge,
PP_PDF_SCROLL_ALIGNMENT_CLOSEST_EDGE);
STATIC_ASSERT_ENUM(chrome_pdf::AccessibilityScrollAlignment::kMaxValue,
PP_PDF_ACCESSIBILITYSCROLLALIGNMENT_LAST);
+
+STATIC_ASSERT_ENUM(chrome_pdf::kContentRestrictionCopy,
+ PP_CONTENT_RESTRICTION_COPY);
+STATIC_ASSERT_ENUM(chrome_pdf::kContentRestrictionCut,
+ PP_CONTENT_RESTRICTION_CUT);
+STATIC_ASSERT_ENUM(chrome_pdf::kContentRestrictionPaste,
+ PP_CONTENT_RESTRICTION_PASTE);
+STATIC_ASSERT_ENUM(chrome_pdf::kContentRestrictionPrint,
+ PP_CONTENT_RESTRICTION_PRINT);
+STATIC_ASSERT_ENUM(chrome_pdf::kContentRestrictionSave,
+ PP_CONTENT_RESTRICTION_SAVE);
diff --git a/chromium/pdf/pdfium/pdfium_engine.cc b/chromium/pdf/pdfium/pdfium_engine.cc
index 5490772654c..64b4133ff95 100644
--- a/chromium/pdf/pdfium/pdfium_engine.cc
+++ b/chromium/pdf/pdfium/pdfium_engine.cc
@@ -20,6 +20,7 @@
#include "base/check_op.h"
#include "base/debug/alias.h"
#include "base/feature_list.h"
+#include "base/location.h"
#include "base/notreached.h"
#include "base/stl_util.h"
#include "base/strings/string_util.h"
@@ -62,6 +63,7 @@
#include "third_party/pdfium/public/fpdf_ppo.h"
#include "third_party/pdfium/public/fpdf_searchex.h"
#include "third_party/skia/include/core/SkBitmap.h"
+#include "ui/base/cursor/mojom/cursor_type.mojom-shared.h"
#include "ui/events/keycodes/keyboard_codes.h"
#include "ui/gfx/geometry/point.h"
#include "ui/gfx/geometry/point_conversions.h"
@@ -145,7 +147,7 @@ int CalculateCenterForZoom(int center, int length, double zoom) {
// as Adobe Reader. When a hyphen is encountered, the next non-CR/LF whitespace
// becomes CR+LF and the hyphen is erased. If there is no whitespace between
// two hyphens, the latter hyphen is erased and ignored.
-void FormatStringWithHyphens(base::string16* text) {
+void FormatStringWithHyphens(std::u16string* text) {
// First pass marks all the hyphen positions.
struct HyphenPosition {
HyphenPosition() : position(0), next_whitespace_position(0) {}
@@ -155,10 +157,10 @@ void FormatStringWithHyphens(base::string16* text) {
std::vector<HyphenPosition> hyphen_positions;
HyphenPosition current_hyphen_position;
bool current_hyphen_position_is_valid = false;
- constexpr base::char16 kPdfiumHyphenEOL = 0xfffe;
+ constexpr char16_t kPdfiumHyphenEOL = 0xfffe;
for (size_t i = 0; i < text->size(); ++i) {
- const base::char16& current_char = (*text)[i];
+ const char16_t& current_char = (*text)[i];
if (current_char == kPdfiumHyphenEOL) {
if (current_hyphen_position_is_valid)
hyphen_positions.push_back(current_hyphen_position);
@@ -179,7 +181,7 @@ void FormatStringWithHyphens(base::string16* text) {
// With all the hyphen positions, do the search and replace.
while (!hyphen_positions.empty()) {
- static constexpr base::char16 kCr[] = {L'\r', L'\0'};
+ static constexpr char16_t kCr[] = {L'\r', L'\0'};
const HyphenPosition& position = hyphen_positions.back();
if (position.next_whitespace_position != 0) {
(*text)[position.next_whitespace_position] = L'\n';
@@ -190,16 +192,16 @@ void FormatStringWithHyphens(base::string16* text) {
}
// Adobe Reader also get rid of trailing spaces right before a CRLF.
- static constexpr base::char16 kSpaceCrCn[] = {L' ', L'\r', L'\n', L'\0'};
- static constexpr base::char16 kCrCn[] = {L'\r', L'\n', L'\0'};
+ static constexpr char16_t kSpaceCrCn[] = {L' ', L'\r', L'\n', L'\0'};
+ static constexpr char16_t kCrCn[] = {L'\r', L'\n', L'\0'};
base::ReplaceSubstringsAfterOffset(text, 0, kSpaceCrCn, kCrCn);
}
// Replace CR/LF with just LF on POSIX.
-void FormatStringForOS(base::string16* text) {
+void FormatStringForOS(std::u16string* text) {
#if defined(OS_POSIX)
- static constexpr base::char16 kCr[] = {L'\r', L'\0'};
- static constexpr base::char16 kBlank[] = {L'\0'};
+ static constexpr char16_t kCr[] = {L'\r', L'\0'};
+ static constexpr char16_t kBlank[] = {L'\0'};
base::ReplaceChars(*text, kCr, kBlank, text);
#elif defined(OS_WIN)
// Do nothing
@@ -213,7 +215,7 @@ void FormatStringForOS(base::string16* text) {
// For triple clicks, look for line breaks.
// The actual algorithm used in Blink is much more complicated, so do a simple
// approximation.
-bool FindMultipleClickBoundary(bool is_double_click, base::char16 cur) {
+bool FindMultipleClickBoundary(bool is_double_click, char16_t cur) {
if (!is_double_click)
return cur == '\n';
@@ -377,20 +379,21 @@ PP_PrivateFocusObjectType GetAnnotationFocusType(
}
}
-base::string16 GetAttachmentAttribute(FPDF_ATTACHMENT attachment,
+std::u16string GetAttachmentAttribute(FPDF_ATTACHMENT attachment,
FPDF_BYTESTRING field) {
return CallPDFiumWideStringBufferApi(
base::BindRepeating(&FPDFAttachment_GetStringValue, attachment, field),
/*check_expected_size=*/true);
}
-base::string16 GetAttachmentName(FPDF_ATTACHMENT attachment) {
+std::u16string GetAttachmentName(FPDF_ATTACHMENT attachment) {
return CallPDFiumWideStringBufferApi(
base::BindRepeating(&FPDFAttachment_GetName, attachment),
/*check_expected_size=*/true);
}
std::string GetXYZParamsString(FPDF_DEST dest, PDFiumPage* page) {
+ std::string xyz_params;
FPDF_BOOL has_x_coord;
FPDF_BOOL has_y_coord;
FPDF_BOOL has_zoom;
@@ -399,28 +402,26 @@ std::string GetXYZParamsString(FPDF_DEST dest, PDFiumPage* page) {
FS_FLOAT zoom;
if (!FPDFDest_GetLocationInPage(dest, &has_x_coord, &has_y_coord, &has_zoom,
&x, &y, &zoom)) {
- return "";
+ return xyz_params;
}
- // Handle out-of-range page coordinates.
- x = has_x_coord ? page->PreProcessInPageCoordX(x) : 0;
- y = has_y_coord ? page->PreProcessInPageCoordY(y) : 0;
-
- // Convert in-page coordinates to in-screen coordinates.
- gfx::PointF xy(x, y);
- gfx::PointF screen_coords = page->TransformPageToScreenXY(xy);
-
// Generate a string of the parameters
- std::string xyz_params;
- if (has_x_coord)
- xyz_params = base::NumberToString(screen_coords.x()) + ",";
- else
+ if (has_x_coord) {
+ // Handle out-of-range page coordinates and convert in-page coordinates to
+ // in-screen coordinates.
+ xyz_params =
+ base::NumberToString(page->PreProcessAndTransformInPageCoordX(x)) + ",";
+ } else {
xyz_params = "null,";
+ }
- if (has_y_coord)
- xyz_params += base::NumberToString(screen_coords.y()) + ",";
- else
+ if (has_y_coord) {
+ // Same conversions as x coordinates above.
+ xyz_params +=
+ base::NumberToString(page->PreProcessAndTransformInPageCoordY(y)) + ",";
+ } else {
xyz_params += "null,";
+ }
if (has_zoom) {
if (zoom == 0.0f)
@@ -1130,7 +1131,7 @@ bool PDFiumEngine::ReadLoadedBytes(uint32_t length, void* buffer) {
void PDFiumEngine::SetFormSelectedText(FPDF_FORMHANDLE form_handle,
FPDF_PAGE page) {
- base::string16 selected_form_text16 = CallPDFiumWideStringBufferApi(
+ std::u16string selected_form_text16 = CallPDFiumWideStringBufferApi(
base::BindRepeating(&FORM_GetSelectedText, form_handle, page),
/*check_expected_size=*/false);
@@ -1213,7 +1214,7 @@ void PDFiumEngine::OnMultipleClick(int click_count,
// now it doesn't.
int start_index = char_index;
do {
- base::char16 cur = pages_[page_index]->GetCharAtIndex(start_index);
+ char16_t cur = pages_[page_index]->GetCharAtIndex(start_index);
if (FindMultipleClickBoundary(is_double_click, cur))
break;
} while (--start_index >= 0);
@@ -1223,7 +1224,7 @@ void PDFiumEngine::OnMultipleClick(int click_count,
int end_index = char_index;
int total = pages_[page_index]->GetCharCount();
while (end_index++ <= total) {
- base::char16 cur = pages_[page_index]->GetCharAtIndex(end_index);
+ char16_t cur = pages_[page_index]->GetCharAtIndex(end_index);
if (FindMultipleClickBoundary(is_double_click, cur))
break;
}
@@ -1324,7 +1325,7 @@ bool PDFiumEngine::OnMiddleMouseDown(const MouseInputEvent& event) {
if (kViewerImplementedPanning) {
// Switch to hand cursor when panning.
- client_->UpdateCursor(PP_CURSORTYPE_HAND);
+ client_->UpdateCursor(ui::mojom::CursorType::kHand);
}
// Prevent middle mouse button from selecting texts.
@@ -1544,18 +1545,17 @@ bool PDFiumEngine::OnMouseMove(const MouseInputEvent& event) {
return ExtendSelection(page_index, char_index);
}
-PP_CursorType_Dev PDFiumEngine::DetermineCursorType(PDFiumPage::Area area,
- int form_type) const {
- if (kViewerImplementedPanning && mouse_middle_button_down_) {
- return PP_CURSORTYPE_HAND;
- }
+ui::mojom::CursorType PDFiumEngine::DetermineCursorType(PDFiumPage::Area area,
+ int form_type) const {
+ if (kViewerImplementedPanning && mouse_middle_button_down_)
+ return ui::mojom::CursorType::kHand;
switch (area) {
case PDFiumPage::TEXT_AREA:
- return PP_CURSORTYPE_IBEAM;
+ return ui::mojom::CursorType::kIBeam;
case PDFiumPage::WEBLINK_AREA:
case PDFiumPage::DOCLINK_AREA:
- return PP_CURSORTYPE_HAND;
+ return ui::mojom::CursorType::kHand;
case PDFiumPage::NONSELECTABLE_AREA:
case PDFiumPage::FORM_TEXT_AREA:
default:
@@ -1565,9 +1565,9 @@ PP_CursorType_Dev PDFiumEngine::DetermineCursorType(PDFiumPage::Area area,
case FPDF_FORMFIELD_RADIOBUTTON:
case FPDF_FORMFIELD_COMBOBOX:
case FPDF_FORMFIELD_LISTBOX:
- return PP_CURSORTYPE_HAND;
+ return ui::mojom::CursorType::kHand;
case FPDF_FORMFIELD_TEXTFIELD:
- return PP_CURSORTYPE_IBEAM;
+ return ui::mojom::CursorType::kIBeam;
#if defined(PDF_ENABLE_XFA)
case FPDF_FORMFIELD_XFA_CHECKBOX:
case FPDF_FORMFIELD_XFA_COMBOBOX:
@@ -1575,12 +1575,12 @@ PP_CursorType_Dev PDFiumEngine::DetermineCursorType(PDFiumPage::Area area,
case FPDF_FORMFIELD_XFA_LISTBOX:
case FPDF_FORMFIELD_XFA_PUSHBUTTON:
case FPDF_FORMFIELD_XFA_SIGNATURE:
- return PP_CURSORTYPE_HAND;
+ return ui::mojom::CursorType::kHand;
case FPDF_FORMFIELD_XFA_TEXTFIELD:
- return PP_CURSORTYPE_IBEAM;
+ return ui::mojom::CursorType::kIBeam;
#endif
default:
- return PP_CURSORTYPE_POINTER;
+ return ui::mojom::CursorType::kPointer;
}
}
}
@@ -1718,7 +1718,7 @@ bool PDFiumEngine::OnChar(const KeyboardInputEvent& event) {
if (last_focused_page_ == -1)
return false;
- base::string16 str = base::UTF8ToUTF16(event.GetKeyChar());
+ std::u16string str = base::UTF8ToUTF16(event.GetKeyChar());
bool rv = !!FORM_OnChar(form(), pages_[last_focused_page_]->GetPage(), str[0],
event.GetModifiers());
@@ -1770,7 +1770,7 @@ void PDFiumEngine::StartFind(const std::string& text, bool case_sensitive) {
int current_page = next_page_to_search_;
if (pages_[current_page]->available()) {
- base::string16 str = base::UTF8ToUTF16(text);
+ std::u16string str = base::UTF8ToUTF16(text);
// Don't use PDFium to search for now, since it doesn't support unicode
// text. Leave the code for now to avoid bit-rot, in case it's fixed later.
// The extra parens suppress a -Wunreachable-code warning.
@@ -1818,14 +1818,14 @@ void PDFiumEngine::StartFind(const std::string& text, bool case_sensitive) {
ContinueFind(case_sensitive ? 1 : 0);
} else {
client_->ScheduleTaskOnMainThread(
- base::TimeDelta(),
+ FROM_HERE,
base::BindOnce(&PDFiumEngine::ContinueFind,
find_weak_factory_.GetWeakPtr()),
- case_sensitive ? 1 : 0);
+ case_sensitive ? 1 : 0, base::TimeDelta());
}
}
-void PDFiumEngine::SearchUsingPDFium(const base::string16& term,
+void PDFiumEngine::SearchUsingPDFium(const std::u16string& term,
bool case_sensitive,
bool first_search,
int character_to_start_searching_from,
@@ -1857,7 +1857,7 @@ void PDFiumEngine::SearchUsingPDFium(const base::string16& term,
FPDFText_FindClose(find);
}
-void PDFiumEngine::SearchUsingICU(const base::string16& term,
+void PDFiumEngine::SearchUsingICU(const std::u16string& term,
bool case_sensitive,
bool first_search,
int character_to_start_searching_from,
@@ -1866,8 +1866,8 @@ void PDFiumEngine::SearchUsingICU(const base::string16& term,
// 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)
+ std::u16string adjusted_term = term;
+ for (char16_t& c : adjusted_term)
c = SimplifyForSearch(c);
const int original_text_length = pages_[current_page]->GetCharCount();
@@ -1881,8 +1881,8 @@ void PDFiumEngine::SearchUsingICU(const base::string16& term,
if (text_length <= 0)
return;
- base::string16 page_text;
- PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(
+ std::u16string page_text;
+ PDFiumAPIStringBufferAdapter<std::u16string> api_string_adapter(
&page_text, text_length, false);
unsigned short* data =
reinterpret_cast<unsigned short*>(api_string_adapter.GetData());
@@ -1891,7 +1891,7 @@ void PDFiumEngine::SearchUsingICU(const base::string16& term,
character_to_start_searching_from, text_length, data);
api_string_adapter.Close(written);
- base::string16 adjusted_page_text;
+ std::u16string adjusted_page_text;
adjusted_page_text.reserve(page_text.size());
// Values in |removed_indices| are in the adjusted text index space and
// indicate a character was removed from the page text before the given
@@ -1905,7 +1905,7 @@ void PDFiumEngine::SearchUsingICU(const base::string16& term,
// whitespace characters. Calculating where the collapsed regions are after
// the fact is as complex as collapsing them manually.
for (size_t i = 0; i < page_text.size(); i++) {
- base::char16 c = page_text[i];
+ char16_t c = page_text[i];
// Collapse whitespace regions by inserting a ' ' into the
// adjusted text and recording any removed whitespace indices as preceding
// it.
@@ -2177,10 +2177,10 @@ std::string PDFiumEngine::GetSelectedText() {
if (!HasPermission(PDFEngine::PERMISSION_COPY))
return std::string();
- base::string16 result;
+ std::u16string result;
for (size_t i = 0; i < selection_.size(); ++i) {
- static constexpr base::char16 kNewLineChar = L'\n';
- base::string16 current_selection_text = selection_[i].GetText();
+ static constexpr char16_t kNewLineChar = L'\n';
+ std::u16string current_selection_text = selection_[i].GetText();
if (i != 0) {
if (selection_[i - 1].page_index() > selection_[i].page_index())
std::swap(current_selection_text, result);
@@ -2210,7 +2210,7 @@ bool PDFiumEngine::HasEditableText() {
void PDFiumEngine::ReplaceSelection(const std::string& text) {
DCHECK(CanEditText());
if (last_focused_page_ != -1) {
- base::string16 text_wide = base::UTF8ToUTF16(text);
+ std::u16string text_wide = base::UTF8ToUTF16(text);
FPDF_WIDESTRING text_pdf_wide =
reinterpret_cast<FPDF_WIDESTRING>(text_wide.c_str());
@@ -2364,7 +2364,7 @@ base::Value PDFiumEngine::GetBookmarks() {
base::Value PDFiumEngine::TraverseBookmarks(FPDF_BOOKMARK bookmark,
unsigned int depth) {
base::Value dict(base::Value::Type::DICTIONARY);
- base::string16 title = CallPDFiumWideStringBufferApi(
+ std::u16string title = CallPDFiumWideStringBufferApi(
base::BindRepeating(&FPDFBookmark_GetTitle, bookmark),
/*check_expected_size=*/true);
dict.SetStringKey("title", title);
@@ -2487,7 +2487,7 @@ base::Optional<PDFEngine::NamedDestination> PDFiumEngine::GetNamedDestination(
FPDF_DEST dest = FPDF_GetNamedDestByName(doc(), destination.c_str());
if (!dest) {
// Look for a bookmark with the same name.
- base::string16 destination_wide = base::UTF8ToUTF16(destination);
+ std::u16string destination_wide = base::UTF8ToUTF16(destination);
FPDF_WIDESTRING destination_pdf_wide =
reinterpret_cast<FPDF_WIDESTRING>(destination_wide.c_str());
FPDF_BOOKMARK bookmark = FPDFBookmark_Find(doc(), destination_pdf_wide);
@@ -3761,7 +3761,7 @@ void PDFiumEngine::SetSelecting(bool selecting) {
bool was_selecting = selecting_;
selecting_ = selecting;
if (selecting_ != was_selecting)
- client_->IsSelectingChanged(selecting);
+ client_->SetIsSelecting(selecting);
}
void PDFiumEngine::EnteredEditMode() {
@@ -4055,7 +4055,7 @@ std::string PDFiumEngine::GetTrimmedMetadataByField(
FPDF_BYTESTRING field) const {
DCHECK(doc());
- base::string16 metadata = CallPDFiumWideStringBufferApi(
+ std::u16string metadata = CallPDFiumWideStringBufferApi(
base::BindRepeating(&FPDF_GetMetaText, doc(), field),
/*check_expected_size=*/false);
diff --git a/chromium/pdf/pdfium/pdfium_engine.h b/chromium/pdf/pdfium/pdfium_engine.h
index 3f3cf14ce10..b9996a3b4d3 100644
--- a/chromium/pdf/pdfium/pdfium_engine.h
+++ b/chromium/pdf/pdfium/pdfium_engine.h
@@ -383,14 +383,14 @@ class PDFiumEngine : public PDFEngine,
// Search a page using PDFium's methods. Doesn't work with unicode. This
// function is just kept arount in case PDFium code is fixed.
- void SearchUsingPDFium(const base::string16& term,
+ void SearchUsingPDFium(const std::u16string& term,
bool case_sensitive,
bool first_search,
int character_to_start_searching_from,
int current_page);
// Search a page ourself using ICU.
- void SearchUsingICU(const base::string16& term,
+ void SearchUsingICU(const std::u16string& term,
bool case_sensitive,
bool first_search,
int character_to_start_searching_from,
@@ -406,8 +406,8 @@ class PDFiumEngine : public PDFEngine,
bool OnChar(const KeyboardInputEvent& event);
// Decide what cursor should be displayed.
- PP_CursorType_Dev DetermineCursorType(PDFiumPage::Area area,
- int form_type) const;
+ ui::mojom::CursorType DetermineCursorType(PDFiumPage::Area area,
+ int form_type) const;
bool ExtendSelection(int page_index, int char_index);
diff --git a/chromium/pdf/pdfium/pdfium_engine_exports.cc b/chromium/pdf/pdfium/pdfium_engine_exports.cc
index 4234d87cc26..780361bab26 100644
--- a/chromium/pdf/pdfium/pdfium_engine_exports.cc
+++ b/chromium/pdf/pdfium/pdfium_engine_exports.cc
@@ -153,7 +153,7 @@ base::Value RecursiveGetStructTree(FPDF_STRUCTELEMENT struct_elem) {
if (children_count <= 0)
return base::Value(base::Value::Type::NONE);
- base::Optional<base::string16> opt_type =
+ base::Optional<std::u16string> opt_type =
CallPDFiumWideStringBufferApiAndReturnOptional(
base::BindRepeating(FPDF_StructElement_GetType, struct_elem), true);
if (!opt_type)
@@ -162,14 +162,14 @@ base::Value RecursiveGetStructTree(FPDF_STRUCTELEMENT struct_elem) {
base::Value result(base::Value::Type::DICTIONARY);
result.SetStringKey("type", *opt_type);
- base::Optional<base::string16> opt_alt =
+ base::Optional<std::u16string> opt_alt =
CallPDFiumWideStringBufferApiAndReturnOptional(
base::BindRepeating(FPDF_StructElement_GetAltText, struct_elem),
true);
if (opt_alt)
result.SetStringKey("alt", *opt_alt);
- base::Optional<base::string16> opt_lang =
+ base::Optional<std::u16string> opt_lang =
CallPDFiumWideStringBufferApiAndReturnOptional(
base::BindRepeating(FPDF_StructElement_GetLang, struct_elem), true);
if (opt_lang)
diff --git a/chromium/pdf/pdfium/pdfium_engine_unittest.cc b/chromium/pdf/pdfium/pdfium_engine_unittest.cc
index 8df1438ebcf..cf976dc1374 100644
--- a/chromium/pdf/pdfium/pdfium_engine_unittest.cc
+++ b/chromium/pdf/pdfium/pdfium_engine_unittest.cc
@@ -22,7 +22,7 @@
#include "pdf/ppapi_migration/input_event_conversions.h"
#include "pdf/test/test_client.h"
#include "pdf/test/test_document_loader.h"
-#include "pdf/thumbnail.h"
+#include "pdf/ui/thumbnail.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/gfx/geometry/point.h"
diff --git a/chromium/pdf/pdfium/pdfium_form_filler.cc b/chromium/pdf/pdfium/pdfium_form_filler.cc
index b0c57366af4..b2ac56ae874 100644
--- a/chromium/pdf/pdfium/pdfium_form_filler.cc
+++ b/chromium/pdf/pdfium/pdfium_form_filler.cc
@@ -10,6 +10,7 @@
#include "base/bind.h"
#include "base/feature_list.h"
+#include "base/location.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "pdf/pdf_features.h"
@@ -25,7 +26,7 @@ namespace {
int g_last_timer_id = 0;
std::string WideStringToString(FPDF_WIDESTRING wide_string) {
- return base::UTF16ToUTF8(reinterpret_cast<const base::char16*>(wide_string));
+ return base::UTF16ToUTF8(reinterpret_cast<const char16_t*>(wide_string));
}
} // namespace
@@ -610,8 +611,8 @@ int PDFiumFormFiller::Form_Response(IPDF_JSPLATFORM* param,
PDFiumEngine* engine = GetEngine(param);
std::string rv = engine->client_->Prompt(question_str, default_str);
- base::string16 rv_16 = base::UTF8ToUTF16(rv);
- int rv_bytes = rv_16.size() * sizeof(base::char16);
+ std::u16string rv_16 = base::UTF8ToUTF16(rv);
+ int rv_bytes = rv_16.size() * sizeof(char16_t);
if (response) {
int bytes_to_copy = rv_bytes < length ? rv_bytes : length;
memcpy(response, rv_16.c_str(), bytes_to_copy);
diff --git a/chromium/pdf/pdfium/pdfium_page.cc b/chromium/pdf/pdfium/pdfium_page.cc
index b809e442904..cfbaa0a5767 100644
--- a/chromium/pdf/pdfium/pdfium_page.cc
+++ b/chromium/pdf/pdfium/pdfium_page.cc
@@ -27,7 +27,7 @@
#include "pdf/pdfium/pdfium_engine.h"
#include "pdf/pdfium/pdfium_unsupported_features.h"
#include "pdf/ppapi_migration/geometry_conversions.h"
-#include "pdf/thumbnail.h"
+#include "pdf/ui/thumbnail.h"
#include "ppapi/c/private/ppb_pdf.h"
#include "printing/units.h"
#include "third_party/pdfium/public/cpp/fpdf_scopers.h"
@@ -847,10 +847,10 @@ PDFiumPage::Area PDFiumPage::FormTypeToArea(int form_type) {
}
}
-base::char16 PDFiumPage::GetCharAtIndex(int index) {
+char16_t PDFiumPage::GetCharAtIndex(int index) {
if (!available_)
return L'\0';
- return static_cast<base::char16>(FPDFText_GetUnicode(GetTextPage(), index));
+ return char16_t{FPDFText_GetUnicode(GetTextPage(), index)};
}
int PDFiumPage::GetCharCount() {
@@ -879,12 +879,10 @@ PDFiumPage::Area PDFiumPage::GetDestinationTarget(FPDF_DEST destination,
GetPageDestinationTarget(destination, &x, &y, &target->zoom);
if (x) {
- target->x_in_pixels =
- TransformPageToScreenX(PreProcessInPageCoordX(x.value()));
+ target->x_in_pixels = PreProcessAndTransformInPageCoordX(x.value());
}
if (y) {
- target->y_in_pixels =
- TransformPageToScreenY(PreProcessInPageCoordY(y.value()));
+ target->y_in_pixels = PreProcessAndTransformInPageCoordY(y.value());
}
return DOCLINK_AREA;
@@ -920,16 +918,17 @@ void PDFiumPage::GetPageDestinationTarget(FPDF_DEST destination,
*zoom_value = zoom;
}
-float PDFiumPage::PreProcessInPageCoordX(float x) {
+float PDFiumPage::PreProcessAndTransformInPageCoordX(float x) {
// If `x` < 0, scroll to the left side of the page.
- // If `x` > width, scroll to the right side of the page.
- return std::max<float>(std::min<float>(x, FPDF_GetPageWidthF(GetPage())), 0);
+ // If `x` > page width, scroll to the right side of the page.
+ return TransformPageToScreenX(
+ std::max(std::min(x, FPDF_GetPageWidthF(GetPage())), 0.0f));
}
-float PDFiumPage::PreProcessInPageCoordY(float y) {
+float PDFiumPage::PreProcessAndTransformInPageCoordY(float y) {
// If `y` < 0, it is a valid input, no extra handling is needed.
- // If `y` > height, scroll to the top of the page.
- return std::min<float>(y, FPDF_GetPageHeightF(GetPage()));
+ // If `y` > page height, scroll to the top of the page.
+ return TransformPageToScreenY(std::min(y, FPDF_GetPageHeightF(GetPage())));
}
gfx::PointF PDFiumPage::TransformPageToScreenXY(const gfx::PointF& xy) {
@@ -1008,10 +1007,10 @@ void PDFiumPage::PopulateWebLinks() {
for (int i = 0; i < count; ++i) {
// WARNING: FPDFLink_GetURL() is not compatible with
// CallPDFiumWideStringBufferApi().
- base::string16 url;
+ std::u16string url;
int url_length = FPDFLink_GetURL(links.get(), i, nullptr, 0);
if (url_length > 0) {
- PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(
+ PDFiumAPIStringBufferAdapter<std::u16string> api_string_adapter(
&url, url_length, true);
unsigned short* data =
reinterpret_cast<unsigned short*>(api_string_adapter.GetData());
diff --git a/chromium/pdf/pdfium/pdfium_page.h b/chromium/pdf/pdfium/pdfium_page.h
index 41bbd6c43d6..7be403a785c 100644
--- a/chromium/pdf/pdfium/pdfium_page.h
+++ b/chromium/pdf/pdfium/pdfium_page.h
@@ -14,7 +14,6 @@
#include "base/callback_forward.h"
#include "base/gtest_prod_util.h"
#include "base/optional.h"
-#include "base/strings/string16.h"
#include "pdf/page_orientation.h"
#include "pdf/pdf_engine.h"
#include "ppapi/cpp/private/pdf.h"
@@ -126,9 +125,10 @@ class PDFiumPage {
base::Optional<float>* zoom_value);
// For a named destination with "XYZ" view fit type, pre-processes the in-page
- // x/y coordinate in case it's out of the range of the page dimension.
- float PreProcessInPageCoordX(float x);
- float PreProcessInPageCoordY(float y);
+ // x/y coordinate in case it's out of the range of the page dimension. Then
+ // transform it to a screen coordinate.
+ float PreProcessAndTransformInPageCoordX(float x);
+ float PreProcessAndTransformInPageCoordY(float y);
// Transforms an (x, y) position in page coordinates to screen coordinates.
gfx::PointF TransformPageToScreenXY(const gfx::PointF& xy);
@@ -153,7 +153,7 @@ class PDFiumPage {
static Area FormTypeToArea(int form_type);
// Gets the character at the given index.
- base::char16 GetCharAtIndex(int index);
+ char16_t GetCharAtIndex(int index);
// Gets the number of characters in the page.
int GetCharCount();
diff --git a/chromium/pdf/pdfium/pdfium_page_unittest.cc b/chromium/pdf/pdfium/pdfium_page_unittest.cc
index 2ecb25573a4..98a329d71e5 100644
--- a/chromium/pdf/pdfium/pdfium_page_unittest.cc
+++ b/chromium/pdf/pdfium/pdfium_page_unittest.cc
@@ -21,7 +21,7 @@
#include "pdf/pdfium/pdfium_test_base.h"
#include "pdf/ppapi_migration/geometry_conversions.h"
#include "pdf/test/test_client.h"
-#include "pdf/thumbnail.h"
+#include "pdf/ui/thumbnail.h"
#include "ppapi/c/private/ppb_pdf.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/pdfium/public/fpdf_formfill.h"
diff --git a/chromium/pdf/pdfium/pdfium_range.cc b/chromium/pdf/pdfium/pdfium_range.cc
index 437b478b412..eda743c256b 100644
--- a/chromium/pdf/pdfium/pdfium_range.cc
+++ b/chromium/pdf/pdfium/pdfium_range.cc
@@ -25,7 +25,7 @@ void AdjustForBackwardsRange(int* index, int* count) {
} // namespace
-bool IsIgnorableCharacter(base::char16 c) {
+bool IsIgnorableCharacter(char16_t c) {
return (c == kZeroWidthSpace) || (c == kPDFSoftHyphenMarker);
}
@@ -94,16 +94,16 @@ const std::vector<gfx::Rect>& PDFiumRange::GetScreenRects(
return cached_screen_rects_;
}
-base::string16 PDFiumRange::GetText() const {
+std::u16string PDFiumRange::GetText() const {
int index = char_index_;
int count = char_count_;
- base::string16 rv;
+ std::u16string rv;
if (count == 0)
return rv;
AdjustForBackwardsRange(&index, &count);
if (count > 0) {
- PDFiumAPIStringBufferAdapter<base::string16> api_string_adapter(&rv, count,
+ PDFiumAPIStringBufferAdapter<std::u16string> api_string_adapter(&rv, count,
false);
unsigned short* data =
reinterpret_cast<unsigned short*>(api_string_adapter.GetData());
@@ -111,7 +111,7 @@ base::string16 PDFiumRange::GetText() const {
api_string_adapter.Close(written);
}
- base::EraseIf(rv, [](base::char16 c) { return IsIgnorableCharacter(c); });
+ base::EraseIf(rv, [](char16_t c) { return IsIgnorableCharacter(c); });
return rv;
}
diff --git a/chromium/pdf/pdfium/pdfium_range.h b/chromium/pdf/pdfium/pdfium_range.h
index 75512ec124a..17a5dbd24df 100644
--- a/chromium/pdf/pdfium/pdfium_range.h
+++ b/chromium/pdf/pdfium/pdfium_range.h
@@ -8,7 +8,6 @@
#include <string>
#include <vector>
-#include "base/strings/string16.h"
#include "pdf/page_orientation.h"
#include "pdf/pdfium/pdfium_page.h"
#include "ui/gfx/geometry/point.h"
@@ -16,13 +15,13 @@
namespace chrome_pdf {
-constexpr base::char16 kZeroWidthSpace = 0x200B;
-constexpr base::char16 kPDFSoftHyphenMarker = 0xFFFE;
+constexpr char16_t kZeroWidthSpace = 0x200B;
+constexpr char16_t kPDFSoftHyphenMarker = 0xFFFE;
// Helper for identifying characters that PDFium outputs, via FPDFText_GetText,
// that have special meaning, but should not be included in things like copied
// text or when running find.
-bool IsIgnorableCharacter(base::char16 c);
+bool IsIgnorableCharacter(char16_t c);
// Describes location of a string of characters.
class PDFiumRange {
@@ -46,7 +45,7 @@ class PDFiumRange {
PageOrientation orientation) const;
// Gets the string of characters in this range.
- base::string16 GetText() const;
+ std::u16string GetText() const;
private:
PDFiumPage* page_;