Migrate pp::Point to gfx::Point/gfx::Vector2d at PDFEngine interface
Migrate all instances of pp::Point to gfx::Point/gfx::Vector2d at PDFEngine interface. The internals still have pp::Point dependency but the interface is now independent of pp::Point. The internal dependency will be migrated in a subsequent CL. Bug: 1101101 Change-Id: Ib8a729314ec6101183281235d35afc697a243b03 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2326512 Reviewed-by: K. Moon <kmoon@chromium.org> Reviewed-by: Lei Zhang <thestig@chromium.org> Commit-Queue: Ankit Kumar 🌪️ <ankk@microsoft.com> Cr-Commit-Position: refs/heads/master@{#799361}
This commit is contained in:

committed by
Commit Bot

parent
ade27582b2
commit
7f59e785d4
@ -860,7 +860,7 @@ void OutOfProcessInstance::SetCaretPosition(const pp::FloatPoint& position) {
|
||||
pp::Point new_position(position.x(), position.y());
|
||||
ScalePoint(device_scale_, &new_position);
|
||||
new_position.set_x(new_position.x() - available_area_.x());
|
||||
engine()->SetCaretPosition(new_position);
|
||||
engine()->SetCaretPosition(PointFromPPPoint(new_position));
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::MoveRangeSelectionExtent(
|
||||
@ -868,7 +868,7 @@ void OutOfProcessInstance::MoveRangeSelectionExtent(
|
||||
pp::Point new_extent(extent.x(), extent.y());
|
||||
ScalePoint(device_scale_, &new_extent);
|
||||
new_extent.set_x(new_extent.x() - available_area_.x());
|
||||
engine()->MoveRangeSelectionExtent(new_extent);
|
||||
engine()->MoveRangeSelectionExtent(PointFromPPPoint(new_extent));
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::SetSelectionBounds(const pp::FloatPoint& base,
|
||||
@ -881,14 +881,15 @@ void OutOfProcessInstance::SetSelectionBounds(const pp::FloatPoint& base,
|
||||
ScalePoint(device_scale_, &new_extent_point);
|
||||
new_extent_point.set_x(new_extent_point.x() - available_area_.x());
|
||||
|
||||
engine()->SetSelectionBounds(new_base_point, new_extent_point);
|
||||
engine()->SetSelectionBounds(PointFromPPPoint(new_base_point),
|
||||
PointFromPPPoint(new_extent_point));
|
||||
}
|
||||
|
||||
pp::Var OutOfProcessInstance::GetLinkAtPosition(const pp::Point& point) {
|
||||
pp::Point offset_point(point);
|
||||
ScalePoint(device_scale_, &offset_point);
|
||||
offset_point.set_x(offset_point.x() - available_area_.x());
|
||||
return engine()->GetLinkAtPosition(offset_point);
|
||||
return engine()->GetLinkAtPosition(PointFromPPPoint(offset_point));
|
||||
}
|
||||
|
||||
bool OutOfProcessInstance::CanEditText() {
|
||||
@ -1202,11 +1203,11 @@ void OutOfProcessInstance::ScrollToY(int y_in_screen_coords,
|
||||
PostMessage(position);
|
||||
}
|
||||
|
||||
void OutOfProcessInstance::ScrollBy(const pp::Point& point) {
|
||||
void OutOfProcessInstance::ScrollBy(const gfx::Vector2d& scroll_delta) {
|
||||
pp::VarDictionary position;
|
||||
position.Set(kType, kJSScrollByType);
|
||||
position.Set(kJSPositionX, pp::Var(point.x() / device_scale_));
|
||||
position.Set(kJSPositionY, pp::Var(point.y() / device_scale_));
|
||||
position.Set(kJSPositionX, pp::Var(scroll_delta.x() / device_scale_));
|
||||
position.Set(kJSPositionY, pp::Var(scroll_delta.y() / device_scale_));
|
||||
PostMessage(position);
|
||||
}
|
||||
|
||||
@ -2056,7 +2057,7 @@ void OutOfProcessInstance::OnGeometryChanged(double old_zoom,
|
||||
available_area_.set_height(bottom_of_document);
|
||||
|
||||
CalculateBackgroundParts();
|
||||
engine()->PageOffsetUpdated(available_area_.point());
|
||||
engine()->PageOffsetUpdated(PointFromPPPoint(available_area_.point()));
|
||||
engine()->PluginSizeUpdated(SizeFromPPSize(available_area_.size()));
|
||||
|
||||
if (document_size_.IsEmpty())
|
||||
|
@ -114,7 +114,7 @@ class OutOfProcessInstance : public PdfViewPluginBase,
|
||||
void DidScroll(const gfx::Vector2d& offset) override;
|
||||
void ScrollToX(int x_in_screen_coords) override;
|
||||
void ScrollToY(int y_in_screen_coords, bool compensate_for_toolbar) override;
|
||||
void ScrollBy(const pp::Point& point) override;
|
||||
void ScrollBy(const gfx::Vector2d& scroll_delta) override;
|
||||
void ScrollToPage(int page) override;
|
||||
void NavigateTo(const std::string& url,
|
||||
WindowOpenDisposition disposition) override;
|
||||
|
@ -45,6 +45,7 @@ struct PP_PdfPrintSettings_Dev;
|
||||
class SkBitmap;
|
||||
|
||||
namespace gfx {
|
||||
class Point;
|
||||
class Rect;
|
||||
class Size;
|
||||
class Vector2d;
|
||||
@ -146,7 +147,7 @@ class PDFEngine {
|
||||
bool compensate_for_toolbar) {}
|
||||
|
||||
// Scroll by a given delta relative to the current position.
|
||||
virtual void ScrollBy(const pp::Point& point) {}
|
||||
virtual void ScrollBy(const gfx::Vector2d& scroll_delta) {}
|
||||
|
||||
// Scroll to zero-based |page|.
|
||||
virtual void ScrollToPage(int page) {}
|
||||
@ -323,7 +324,7 @@ class PDFEngine {
|
||||
// Most of these functions are similar to the Pepper functions of the same
|
||||
// name, so not repeating the description here unless it's different.
|
||||
virtual bool New(const char* url, const char* headers) = 0;
|
||||
virtual void PageOffsetUpdated(const pp::Point& page_offset) = 0;
|
||||
virtual void PageOffsetUpdated(const gfx::Point& page_offset) = 0;
|
||||
virtual void PluginSizeUpdated(const gfx::Size& size) = 0;
|
||||
virtual void ScrolledToXPosition(int position) = 0;
|
||||
virtual void ScrolledToYPosition(int position) = 0;
|
||||
@ -378,7 +379,7 @@ class PDFEngine {
|
||||
// Handles actions invoked by Accessibility clients.
|
||||
virtual void HandleAccessibilityAction(
|
||||
const PP_PdfAccessibilityActionData& action_data) = 0;
|
||||
virtual std::string GetLinkAtPosition(const pp::Point& point) = 0;
|
||||
virtual std::string GetLinkAtPosition(const gfx::Point& point) = 0;
|
||||
// Checks the permissions associated with this document.
|
||||
virtual bool HasPermission(DocumentPermission permission) const = 0;
|
||||
virtual void SelectAll() = 0;
|
||||
@ -468,10 +469,10 @@ class PDFEngine {
|
||||
|
||||
virtual std::vector<uint8_t> GetSaveData() = 0;
|
||||
|
||||
virtual void SetCaretPosition(const pp::Point& position) = 0;
|
||||
virtual void MoveRangeSelectionExtent(const pp::Point& extent) = 0;
|
||||
virtual void SetSelectionBounds(const pp::Point& base,
|
||||
const pp::Point& extent) = 0;
|
||||
virtual void SetCaretPosition(const gfx::Point& position) = 0;
|
||||
virtual void MoveRangeSelectionExtent(const gfx::Point& extent) = 0;
|
||||
virtual void SetSelectionBounds(const gfx::Point& base,
|
||||
const gfx::Point& extent) = 0;
|
||||
virtual void GetSelection(uint32_t* selection_start_page_index,
|
||||
uint32_t* selection_start_char_index,
|
||||
uint32_t* selection_end_page_index,
|
||||
|
@ -92,7 +92,7 @@ void PdfViewWebPlugin::ScrollToX(int x_in_screen_coords) {}
|
||||
void PdfViewWebPlugin::ScrollToY(int y_in_screen_coords,
|
||||
bool compensate_for_toolbar) {}
|
||||
|
||||
void PdfViewWebPlugin::ScrollBy(const pp::Point& point) {}
|
||||
void PdfViewWebPlugin::ScrollBy(const gfx::Vector2d& scroll_delta) {}
|
||||
|
||||
void PdfViewWebPlugin::ScrollToPage(int page) {}
|
||||
|
||||
|
@ -49,7 +49,7 @@ class PdfViewWebPlugin final : public PdfViewPluginBase,
|
||||
void DidScroll(const gfx::Vector2d& offset) override;
|
||||
void ScrollToX(int x_in_screen_coords) override;
|
||||
void ScrollToY(int y_in_screen_coords, bool compensate_for_toolbar) override;
|
||||
void ScrollBy(const pp::Point& point) override;
|
||||
void ScrollBy(const gfx::Vector2d& scroll_delta) override;
|
||||
void ScrollToPage(int page) override;
|
||||
void NavigateTo(const std::string& url,
|
||||
WindowOpenDisposition disposition) override;
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "pdf/test/test_utils.h"
|
||||
#include "ppapi/c/private/ppp_pdf.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
#include "ui/gfx/geometry/vector2d.h"
|
||||
|
||||
namespace chrome_pdf {
|
||||
|
||||
@ -187,14 +188,19 @@ class ScrollEnabledTestClient : public TestClient {
|
||||
ScrollEnabledTestClient() = default;
|
||||
~ScrollEnabledTestClient() override = default;
|
||||
|
||||
// Records the point received in a ScrollBy action request from tests.
|
||||
void ScrollBy(const pp::Point& point) override { received_point_ = point; }
|
||||
// Records the scroll delta received in a ScrollBy action request from tests.
|
||||
void ScrollBy(const gfx::Vector2d& scroll_delta) override {
|
||||
received_scroll_delta_ = scroll_delta;
|
||||
}
|
||||
|
||||
// Returns the point received in a ScrollBy action for validation in tests.
|
||||
const pp::Point& GetScrollRequestPoints() const { return received_point_; }
|
||||
// Returns the scroll delta received in a ScrollBy action for validation in
|
||||
// tests.
|
||||
const gfx::Vector2d& GetScrollRequestDelta() const {
|
||||
return received_scroll_delta_;
|
||||
}
|
||||
|
||||
private:
|
||||
pp::Point received_point_;
|
||||
gfx::Vector2d received_scroll_delta_;
|
||||
};
|
||||
|
||||
TEST_F(AccessibilityTest, TestScrollIntoViewActionHandling) {
|
||||
@ -215,42 +221,42 @@ TEST_F(AccessibilityTest, TestScrollIntoViewActionHandling) {
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_NONE;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({0, 0}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(0, 0), client.GetScrollRequestDelta());
|
||||
|
||||
action_data.horizontal_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_LEFT;
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_TOP;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({120, 0}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(120, 0), client.GetScrollRequestDelta());
|
||||
|
||||
action_data.horizontal_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_LEFT;
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_BOTTOM;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({120, -400}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(120, -400), client.GetScrollRequestDelta());
|
||||
|
||||
action_data.horizontal_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_RIGHT;
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_TOP;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({-280, 0}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(-280, 0), client.GetScrollRequestDelta());
|
||||
|
||||
action_data.horizontal_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_RIGHT;
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_BOTTOM;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({-280, -400}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(-280, -400), client.GetScrollRequestDelta());
|
||||
|
||||
action_data.horizontal_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_CENTER;
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_CENTER;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({-80, -200}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(-80, -200), client.GetScrollRequestDelta());
|
||||
|
||||
// Simulate a 150% zoom update in the PDFiumEngine.
|
||||
engine->PluginSizeUpdated({600, 600});
|
||||
@ -260,42 +266,42 @@ TEST_F(AccessibilityTest, TestScrollIntoViewActionHandling) {
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_NONE;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({0, 0}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(0, 0), client.GetScrollRequestDelta());
|
||||
|
||||
action_data.horizontal_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_LEFT;
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_TOP;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({120, 0}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(120, 0), client.GetScrollRequestDelta());
|
||||
|
||||
action_data.horizontal_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_LEFT;
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_BOTTOM;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({120, -600}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(120, -600), client.GetScrollRequestDelta());
|
||||
|
||||
action_data.horizontal_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_RIGHT;
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_TOP;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({-480, 0}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(-480, 0), client.GetScrollRequestDelta());
|
||||
|
||||
action_data.horizontal_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_RIGHT;
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_BOTTOM;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({-480, -600}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(-480, -600), client.GetScrollRequestDelta());
|
||||
|
||||
action_data.horizontal_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_CENTER;
|
||||
action_data.vertical_scroll_alignment =
|
||||
PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_CENTER;
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({-180, -300}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(-180, -300), client.GetScrollRequestDelta());
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityTest, TestScrollToNearestEdge) {
|
||||
@ -314,27 +320,27 @@ TEST_F(AccessibilityTest, TestScrollToNearestEdge) {
|
||||
// Point which is in the middle of the viewport.
|
||||
action_data.target_rect = {{200, 200}, {10, 10}};
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({200, 200}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(200, 200), client.GetScrollRequestDelta());
|
||||
|
||||
// Point which is near the top left of the viewport.
|
||||
action_data.target_rect = {{199, 199}, {10, 10}};
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({199, 199}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(199, 199), client.GetScrollRequestDelta());
|
||||
|
||||
// Point which is near the top right of the viewport
|
||||
action_data.target_rect = {{201, 199}, {10, 10}};
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({-199, 199}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(-199, 199), client.GetScrollRequestDelta());
|
||||
|
||||
// Point which is near the bottom left of the viewport.
|
||||
action_data.target_rect = {{199, 201}, {10, 10}};
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({199, -199}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(199, -199), client.GetScrollRequestDelta());
|
||||
|
||||
// Point which is near the bottom right of the viewport
|
||||
action_data.target_rect = {{201, 201}, {10, 10}};
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({-199, -199}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(-199, -199), client.GetScrollRequestDelta());
|
||||
}
|
||||
|
||||
TEST_F(AccessibilityTest, TestScrollToGlobalPoint) {
|
||||
@ -350,13 +356,13 @@ TEST_F(AccessibilityTest, TestScrollToGlobalPoint) {
|
||||
action_data.target_rect = {{201, 201}, {10, 10}};
|
||||
action_data.target_point = {230, 230};
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({-29, -29}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(-29, -29), client.GetScrollRequestDelta());
|
||||
|
||||
// Scroll down if global point is above the target rect
|
||||
action_data.target_rect = {{230, 230}, {10, 10}};
|
||||
action_data.target_point = {201, 201};
|
||||
engine->HandleAccessibilityAction(action_data);
|
||||
ComparePoint({29, 29}, client.GetScrollRequestPoints());
|
||||
EXPECT_EQ(gfx::Vector2d(29, 29), client.GetScrollRequestDelta());
|
||||
}
|
||||
|
||||
// This class is required to just override the NavigateTo
|
||||
|
@ -508,8 +508,8 @@ bool PDFiumEngine::New(const char* url, const char* headers) {
|
||||
return true;
|
||||
}
|
||||
|
||||
void PDFiumEngine::PageOffsetUpdated(const pp::Point& page_offset) {
|
||||
page_offset_ = page_offset;
|
||||
void PDFiumEngine::PageOffsetUpdated(const gfx::Point& page_offset) {
|
||||
page_offset_ = PPPointFromPoint(page_offset);
|
||||
}
|
||||
|
||||
void PDFiumEngine::PluginSizeUpdated(const gfx::Size& size) {
|
||||
@ -1452,8 +1452,7 @@ bool PDFiumEngine::OnMouseMove(const MouseInputEvent& event) {
|
||||
page_y);
|
||||
}
|
||||
|
||||
UpdateLinkUnderCursor(
|
||||
GetLinkAtPosition(PPPointFromPoint(event.GetPosition())));
|
||||
UpdateLinkUnderCursor(GetLinkAtPosition(event.GetPosition()));
|
||||
|
||||
// If in form text area while left mouse button is held down, check if form
|
||||
// text selection needs to be updated.
|
||||
@ -1467,8 +1466,9 @@ bool PDFiumEngine::OnMouseMove(const MouseInputEvent& event) {
|
||||
// moving the page, rather than the delta the mouse moved.
|
||||
// GetMovement() does not work here, as small mouse movements are
|
||||
// considered zero.
|
||||
pp::Point page_position_delta = mouse_middle_button_last_position_ -
|
||||
PPPointFromPoint(event.GetPosition());
|
||||
gfx::Vector2d page_position_delta =
|
||||
PointFromPPPoint(mouse_middle_button_last_position_) -
|
||||
event.GetPosition();
|
||||
if (page_position_delta.x() != 0 || page_position_delta.y() != 0) {
|
||||
client_->ScrollBy(page_position_delta);
|
||||
mouse_middle_button_last_position_ =
|
||||
@ -2191,7 +2191,8 @@ void PDFiumEngine::HandleAccessibilityAction(
|
||||
break;
|
||||
}
|
||||
case PP_PdfAccessibilityAction::PP_PDF_SCROLL_TO_GLOBAL_POINT: {
|
||||
ScrollToGlobalPoint(action_data.target_rect, action_data.target_point);
|
||||
ScrollToGlobalPoint(action_data.target_rect,
|
||||
PointFromPPPoint(action_data.target_point));
|
||||
break;
|
||||
}
|
||||
case PP_PdfAccessibilityAction::PP_PDF_SET_SELECTION: {
|
||||
@ -2208,14 +2209,14 @@ void PDFiumEngine::HandleAccessibilityAction(
|
||||
}
|
||||
}
|
||||
|
||||
std::string PDFiumEngine::GetLinkAtPosition(const pp::Point& point) {
|
||||
std::string PDFiumEngine::GetLinkAtPosition(const gfx::Point& point) {
|
||||
std::string url;
|
||||
int temp;
|
||||
int page_index = -1;
|
||||
int form_type = FPDF_FORMFIELD_UNKNOWN;
|
||||
PDFiumPage::LinkTarget target;
|
||||
PDFiumPage::Area area =
|
||||
GetCharIndex(point, &page_index, &temp, &form_type, &target);
|
||||
PDFiumPage::Area area = GetCharIndex(PPPointFromPoint(point), &page_index,
|
||||
&temp, &form_type, &target);
|
||||
if (area == PDFiumPage::WEBLINK_AREA)
|
||||
url = target.url;
|
||||
return url;
|
||||
@ -2344,7 +2345,8 @@ void PDFiumEngine::ScrollBasedOnScrollAlignment(
|
||||
const pp::Rect& scroll_rect,
|
||||
const PP_PdfAccessibilityScrollAlignment& horizontal_scroll_alignment,
|
||||
const PP_PdfAccessibilityScrollAlignment& vertical_scroll_alignment) {
|
||||
pp::Point scroll_offset = GetScreenRect(scroll_rect).point();
|
||||
gfx::Vector2d scroll_offset =
|
||||
PointFromPPPoint(GetScreenRect(scroll_rect).point()).OffsetFromOrigin();
|
||||
switch (horizontal_scroll_alignment) {
|
||||
case PP_PdfAccessibilityScrollAlignment::PP_PDF_SCROLL_ALIGNMENT_RIGHT:
|
||||
scroll_offset.set_x(scroll_offset.x() - plugin_size_.width());
|
||||
@ -2397,8 +2399,9 @@ void PDFiumEngine::ScrollBasedOnScrollAlignment(
|
||||
}
|
||||
|
||||
void PDFiumEngine::ScrollToGlobalPoint(const pp::Rect& target_rect,
|
||||
const pp::Point& global_point) {
|
||||
pp::Point scroll_offset = GetScreenRect(target_rect).point();
|
||||
const gfx::Point& global_point) {
|
||||
gfx::Point scroll_offset =
|
||||
PointFromPPPoint(GetScreenRect(target_rect).point());
|
||||
client_->ScrollBy(scroll_offset - global_point);
|
||||
}
|
||||
|
||||
@ -3851,16 +3854,17 @@ void PDFiumEngine::OnFocusedAnnotationUpdated(FPDF_ANNOTATION annot,
|
||||
is_form_text_area && IsAnnotationAnEditableFormTextArea(annot, form_type);
|
||||
}
|
||||
|
||||
void PDFiumEngine::SetCaretPosition(const pp::Point& position) {
|
||||
void PDFiumEngine::SetCaretPosition(const gfx::Point& position) {
|
||||
// TODO(dsinclair): Handle caret position ...
|
||||
}
|
||||
|
||||
void PDFiumEngine::MoveRangeSelectionExtent(const pp::Point& extent) {
|
||||
void PDFiumEngine::MoveRangeSelectionExtent(const gfx::Point& extent) {
|
||||
int page_index = -1;
|
||||
int char_index = -1;
|
||||
int form_type = FPDF_FORMFIELD_UNKNOWN;
|
||||
PDFiumPage::LinkTarget target;
|
||||
GetCharIndex(extent, &page_index, &char_index, &form_type, &target);
|
||||
GetCharIndex(PPPointFromPoint(extent), &page_index, &char_index, &form_type,
|
||||
&target);
|
||||
if (page_index < 0 || char_index < 0)
|
||||
return;
|
||||
|
||||
@ -3883,9 +3887,9 @@ void PDFiumEngine::MoveRangeSelectionExtent(const pp::Point& extent) {
|
||||
ExtendSelection(page_index, char_index);
|
||||
}
|
||||
|
||||
void PDFiumEngine::SetSelectionBounds(const pp::Point& base,
|
||||
const pp::Point& extent) {
|
||||
range_selection_base_ = base;
|
||||
void PDFiumEngine::SetSelectionBounds(const gfx::Point& base,
|
||||
const gfx::Point& extent) {
|
||||
range_selection_base_ = PPPointFromPoint(base);
|
||||
range_selection_direction_ = IsAboveOrDirectlyLeftOf(base, extent)
|
||||
? RangeSelectionDirection::Left
|
||||
: RangeSelectionDirection::Right;
|
||||
|
@ -84,7 +84,7 @@ class PDFiumEngine : public PDFEngine,
|
||||
|
||||
// PDFEngine:
|
||||
bool New(const char* url, const char* headers) override;
|
||||
void PageOffsetUpdated(const pp::Point& page_offset) override;
|
||||
void PageOffsetUpdated(const gfx::Point& page_offset) override;
|
||||
void PluginSizeUpdated(const gfx::Size& size) override;
|
||||
void ScrolledToXPosition(int position) override;
|
||||
void ScrolledToYPosition(int position) override;
|
||||
@ -124,7 +124,7 @@ class PDFiumEngine : public PDFEngine,
|
||||
void Redo() override;
|
||||
void HandleAccessibilityAction(
|
||||
const PP_PdfAccessibilityActionData& action_data) override;
|
||||
std::string GetLinkAtPosition(const pp::Point& point) override;
|
||||
std::string GetLinkAtPosition(const gfx::Point& point) override;
|
||||
bool HasPermission(DocumentPermission permission) const override;
|
||||
void SelectAll() override;
|
||||
const std::vector<DocumentAttachmentInfo>& GetDocumentAttachmentInfoList()
|
||||
@ -160,10 +160,10 @@ class PDFiumEngine : public PDFEngine,
|
||||
void AppendBlankPages(size_t num_pages) override;
|
||||
void AppendPage(PDFEngine* engine, int index) override;
|
||||
std::vector<uint8_t> GetSaveData() override;
|
||||
void SetCaretPosition(const pp::Point& position) override;
|
||||
void MoveRangeSelectionExtent(const pp::Point& extent) override;
|
||||
void SetSelectionBounds(const pp::Point& base,
|
||||
const pp::Point& extent) override;
|
||||
void SetCaretPosition(const gfx::Point& position) override;
|
||||
void MoveRangeSelectionExtent(const gfx::Point& extent) override;
|
||||
void SetSelectionBounds(const gfx::Point& base,
|
||||
const gfx::Point& extent) override;
|
||||
void GetSelection(uint32_t* selection_start_page_index,
|
||||
uint32_t* selection_start_char_index,
|
||||
uint32_t* selection_end_page_index,
|
||||
@ -575,7 +575,7 @@ class PDFiumEngine : public PDFEngine,
|
||||
// Scrolls top left of a rect in page |target_rect| to |global_point|.
|
||||
// Global point is point relative to viewport in screen.
|
||||
void ScrollToGlobalPoint(const pp::Rect& target_rect,
|
||||
const pp::Point& global_point);
|
||||
const gfx::Point& global_point);
|
||||
|
||||
// Set if the document has any local edits.
|
||||
void EnteredEditMode();
|
||||
|
@ -39,7 +39,7 @@ void PreviewModeClient::ScrollToY(int y_in_screen_coords,
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
void PreviewModeClient::ScrollBy(const pp::Point& point) {
|
||||
void PreviewModeClient::ScrollBy(const gfx::Vector2d& scroll_delta) {
|
||||
NOTREACHED();
|
||||
}
|
||||
|
||||
|
@ -37,7 +37,7 @@ class PreviewModeClient : public PDFEngine::Client {
|
||||
void DidScroll(const gfx::Vector2d& offset) override;
|
||||
void ScrollToX(int x_in_screen_coords) override;
|
||||
void ScrollToY(int y_in_screen_coords, bool compensate_for_toolbar) override;
|
||||
void ScrollBy(const pp::Point& point) override;
|
||||
void ScrollBy(const gfx::Vector2d& scroll_delta) override;
|
||||
void ScrollToPage(int page) override;
|
||||
void NavigateTo(const std::string& url,
|
||||
WindowOpenDisposition disposition) override;
|
||||
|
@ -4,18 +4,11 @@
|
||||
|
||||
#include "pdf/test/test_utils.h"
|
||||
|
||||
#include "ppapi/cpp/point.h"
|
||||
#include "ppapi/cpp/rect.h"
|
||||
#include "testing/gtest/include/gtest/gtest.h"
|
||||
|
||||
namespace chrome_pdf {
|
||||
|
||||
void ComparePoint(const pp::Point& expected_point,
|
||||
const pp::Point& given_point) {
|
||||
EXPECT_EQ(expected_point.x(), given_point.x());
|
||||
EXPECT_EQ(expected_point.y(), given_point.y());
|
||||
}
|
||||
|
||||
void CompareRect(const pp::Rect& expected_rect, const pp::Rect& given_rect) {
|
||||
EXPECT_EQ(expected_rect.x(), given_rect.x());
|
||||
EXPECT_EQ(expected_rect.y(), given_rect.y());
|
||||
|
@ -7,14 +7,11 @@
|
||||
|
||||
namespace pp {
|
||||
class FloatRect;
|
||||
class Point;
|
||||
class Rect;
|
||||
} // namespace pp
|
||||
|
||||
namespace chrome_pdf {
|
||||
|
||||
void ComparePoint(const pp::Point& expected_point,
|
||||
const pp::Point& given_point);
|
||||
void CompareRect(const pp::Rect& expected_rect, const pp::Rect& given_rect);
|
||||
void CompareRect(const pp::FloatRect& expected_rect,
|
||||
const pp::FloatRect& given_rect);
|
||||
|
Reference in New Issue
Block a user