Commit bf2991fb authored by Hui Yingst's avatar Hui Yingst Committed by Chromium LUCI CQ

Rename "scroll offset" to "scroll position" in OutOfProcessInstance.

Change-Id: I660cee5c3c59c263a01935ee6b16a283f7680cfb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2634008Reviewed-by: default avatarDaniel Hosseinian <dhoss@chromium.org>
Commit-Queue: Hui Yingst <nigi@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844282}
parent 0fb74337
...@@ -855,7 +855,7 @@ void OutOfProcessInstance::DidChangeView(const pp::View& view) { ...@@ -855,7 +855,7 @@ void OutOfProcessInstance::DidChangeView(const pp::View& view) {
} }
if (!stop_scrolling_) { if (!stop_scrolling_) {
scroll_offset_ = PointFromPPPoint(view.GetScrollOffset()); scroll_position_ = PointFromPPPoint(view.GetScrollOffset());
UpdateScroll(); UpdateScroll();
} }
} }
...@@ -867,12 +867,12 @@ void OutOfProcessInstance::UpdateScroll() { ...@@ -867,12 +867,12 @@ void OutOfProcessInstance::UpdateScroll() {
// are 0-based (i.e. they do not correspond to the viewport's coordinates in // are 0-based (i.e. they do not correspond to the viewport's coordinates in
// JS), so we need to subtract the toolbar height to convert them into // JS), so we need to subtract the toolbar height to convert them into
// viewport coordinates. // viewport coordinates.
gfx::PointF scroll_offset_float( gfx::PointF scroll_position_float(
scroll_offset_.x(), scroll_position_.x(),
scroll_offset_.y() - top_toolbar_height_in_viewport_coords()); scroll_position_.y() - top_toolbar_height_in_viewport_coords());
scroll_offset_float = BoundScrollOffsetToDocument(scroll_offset_float); scroll_position_float = BoundScrollPositionToDocument(scroll_position_float);
engine()->ScrolledToXPosition(scroll_offset_float.x() * device_scale()); engine()->ScrolledToXPosition(scroll_position_float.x() * device_scale());
engine()->ScrolledToYPosition(scroll_offset_float.y() * device_scale()); engine()->ScrolledToYPosition(scroll_position_float.y() * device_scale());
} }
void OutOfProcessInstance::DidChangeFocus(bool has_focus) { void OutOfProcessInstance::DidChangeFocus(bool has_focus) {
...@@ -1972,7 +1972,7 @@ void OutOfProcessInstance::HandleUpdateScrollMessage( ...@@ -1972,7 +1972,7 @@ void OutOfProcessInstance::HandleUpdateScrollMessage(
int x = dict.Get(pp::Var(kJSUpdateScrollX)).AsInt(); int x = dict.Get(pp::Var(kJSUpdateScrollX)).AsInt();
int y = dict.Get(pp::Var(kJSUpdateScrollY)).AsInt(); int y = dict.Get(pp::Var(kJSUpdateScrollY)).AsInt();
scroll_offset_ = gfx::Point(x, y); scroll_position_ = gfx::Point(x, y);
UpdateScroll(); UpdateScroll();
} }
...@@ -2001,11 +2001,11 @@ void OutOfProcessInstance::HandleViewportMessage( ...@@ -2001,11 +2001,11 @@ void OutOfProcessInstance::HandleViewportMessage(
double new_zoom = dict.Get(pp::Var(kJSZoom)).AsDouble(); double new_zoom = dict.Get(pp::Var(kJSZoom)).AsDouble();
double zoom_ratio = new_zoom / zoom(); double zoom_ratio = new_zoom / zoom();
gfx::PointF scroll_offset(dict.Get(pp::Var(kJSXOffset)).AsDouble(), gfx::PointF scroll_position(dict.Get(pp::Var(kJSXOffset)).AsDouble(),
dict.Get(pp::Var(kJSYOffset)).AsDouble()); dict.Get(pp::Var(kJSYOffset)).AsDouble());
if (pinch_phase == PINCH_START) { if (pinch_phase == PINCH_START) {
scroll_offset_at_last_raster_ = scroll_offset; scroll_position_at_last_raster_ = scroll_position;
last_bitmap_smaller_ = false; last_bitmap_smaller_ = false;
needs_reraster_ = false; needs_reraster_ = false;
return; return;
...@@ -2044,9 +2044,9 @@ void OutOfProcessInstance::HandleViewportMessage( ...@@ -2044,9 +2044,9 @@ void OutOfProcessInstance::HandleViewportMessage(
// We want to keep the paint in the middle but it must stay in the same // We want to keep the paint in the middle but it must stay in the same
// position relative to the scroll bars. // position relative to the scroll bars.
paint_offset = gfx::Vector2d(0, (1 - zoom_ratio) * pinch_center.y()); paint_offset = gfx::Vector2d(0, (1 - zoom_ratio) * pinch_center.y());
scroll_delta = gfx::Vector2d( scroll_delta =
0, gfx::Vector2d(0, (scroll_position.y() -
(scroll_offset.y() - scroll_offset_at_last_raster_.y() * zoom_ratio)); scroll_position_at_last_raster_.y() * zoom_ratio));
pinch_vector = gfx::Vector2d(); pinch_vector = gfx::Vector2d();
last_bitmap_smaller_ = true; last_bitmap_smaller_ = true;
...@@ -2059,9 +2059,11 @@ void OutOfProcessInstance::HandleViewportMessage( ...@@ -2059,9 +2059,11 @@ void OutOfProcessInstance::HandleViewportMessage(
(1 - new_zoom / zoom_when_doc_covers_plugin_width) * pinch_center.x(), (1 - new_zoom / zoom_when_doc_covers_plugin_width) * pinch_center.x(),
(1 - zoom_ratio) * pinch_center.y()); (1 - zoom_ratio) * pinch_center.y());
pinch_vector = gfx::Vector2d(); pinch_vector = gfx::Vector2d();
scroll_delta = gfx::Vector2d( scroll_delta =
(scroll_offset.x() - scroll_offset_at_last_raster_.x() * zoom_ratio), gfx::Vector2d((scroll_position.x() -
(scroll_offset.y() - scroll_offset_at_last_raster_.y() * zoom_ratio)); scroll_position_at_last_raster_.x() * zoom_ratio),
(scroll_position.y() -
scroll_position_at_last_raster_.y() * zoom_ratio));
} }
paint_manager().SetTransform(zoom_ratio, PointFromPPPoint(pinch_center), paint_manager().SetTransform(zoom_ratio, PointFromPPPoint(pinch_center),
...@@ -2081,9 +2083,9 @@ void OutOfProcessInstance::HandleViewportMessage( ...@@ -2081,9 +2083,9 @@ void OutOfProcessInstance::HandleViewportMessage(
needs_reraster_ = true; needs_reraster_ = true;
// If we're rerastering due to zooming out, we need to update // If we're rerastering due to zooming out, we need to update
// |scroll_offset_at_last_raster_|, in case the user continues the // |scroll_position_at_last_raster_|, in case the user continues the
// gesture by zooming in. // gesture by zooming in.
scroll_offset_at_last_raster_ = scroll_offset; scroll_position_at_last_raster_ = scroll_position;
} }
// Bound the input parameters. // Bound the input parameters.
...@@ -2091,9 +2093,9 @@ void OutOfProcessInstance::HandleViewportMessage( ...@@ -2091,9 +2093,9 @@ void OutOfProcessInstance::HandleViewportMessage(
DCHECK(dict.Get(pp::Var(kJSUserInitiated)).is_bool()); DCHECK(dict.Get(pp::Var(kJSUserInitiated)).is_bool());
SetZoom(new_zoom); SetZoom(new_zoom);
scroll_offset = BoundScrollOffsetToDocument(scroll_offset); scroll_position = BoundScrollPositionToDocument(scroll_position);
engine()->ScrolledToXPosition(scroll_offset.x() * device_scale()); engine()->ScrolledToXPosition(scroll_position.x() * device_scale());
engine()->ScrolledToYPosition(scroll_offset.y() * device_scale()); engine()->ScrolledToYPosition(scroll_position.y() * device_scale());
} }
void OutOfProcessInstance::PreviewDocumentLoadComplete() { void OutOfProcessInstance::PreviewDocumentLoadComplete() {
...@@ -2493,17 +2495,17 @@ void OutOfProcessInstance::UserMetricsRecordAction(const std::string& action) { ...@@ -2493,17 +2495,17 @@ void OutOfProcessInstance::UserMetricsRecordAction(const std::string& action) {
pp::PDF::UserMetricsRecordAction(this, pp::Var(action)); pp::PDF::UserMetricsRecordAction(this, pp::Var(action));
} }
gfx::PointF OutOfProcessInstance::BoundScrollOffsetToDocument( gfx::PointF OutOfProcessInstance::BoundScrollPositionToDocument(
const gfx::PointF& scroll_offset) { const gfx::PointF& scroll_position) {
float max_x = std::max( float max_x = std::max(
document_size().width() * float{zoom()} - plugin_dip_size().width(), document_size().width() * float{zoom()} - plugin_dip_size().width(),
0.0f); 0.0f);
float x = base::ClampToRange(scroll_offset.x(), 0.0f, max_x); float x = base::ClampToRange(scroll_position.x(), 0.0f, max_x);
float min_y = -top_toolbar_height_in_viewport_coords(); float min_y = -top_toolbar_height_in_viewport_coords();
float max_y = std::max( float max_y = std::max(
document_size().height() * float{zoom()} - plugin_dip_size().height(), document_size().height() * float{zoom()} - plugin_dip_size().height(),
min_y); min_y);
float y = base::ClampToRange(scroll_offset.y(), min_y, max_y); float y = base::ClampToRange(scroll_position.y(), min_y, max_y);
return gfx::PointF(x, y); return gfx::PointF(x, y);
} }
......
...@@ -292,8 +292,8 @@ class OutOfProcessInstance : public PdfViewPluginBase, ...@@ -292,8 +292,8 @@ class OutOfProcessInstance : public PdfViewPluginBase,
// Sends the thumbnail image data. // Sends the thumbnail image data.
void SendThumbnail(const std::string& message_id, Thumbnail thumbnail); void SendThumbnail(const std::string& message_id, Thumbnail thumbnail);
// Bound the given scroll offset to the document. // Bound the given scroll position to the document.
gfx::PointF BoundScrollOffsetToDocument(const gfx::PointF& scroll_offset); gfx::PointF BoundScrollPositionToDocument(const gfx::PointF& scroll_position);
// These values are persisted to logs. Entries should not be renumbered and // These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused. // numeric values should never be reused.
...@@ -344,8 +344,8 @@ class OutOfProcessInstance : public PdfViewPluginBase, ...@@ -344,8 +344,8 @@ class OutOfProcessInstance : public PdfViewPluginBase,
// The current cursor. // The current cursor.
PP_CursorType_Dev cursor_ = PP_CURSORTYPE_POINTER; PP_CursorType_Dev cursor_ = PP_CURSORTYPE_POINTER;
// The scroll offset in CSS pixels. // The scroll position in CSS pixels.
gfx::Point scroll_offset_; gfx::Point scroll_position_;
// Enumeration of pinch states. // Enumeration of pinch states.
// This should match PinchPhase enum in // This should match PinchPhase enum in
...@@ -362,7 +362,7 @@ class OutOfProcessInstance : public PdfViewPluginBase, ...@@ -362,7 +362,7 @@ class OutOfProcessInstance : public PdfViewPluginBase,
bool needs_reraster_ = true; bool needs_reraster_ = true;
// The scroll position for the last raster, before any transformations are // The scroll position for the last raster, before any transformations are
// applied. // applied.
gfx::PointF scroll_offset_at_last_raster_; gfx::PointF scroll_position_at_last_raster_;
// True if last bitmap was smaller than screen. // True if last bitmap was smaller than screen.
bool last_bitmap_smaller_ = false; bool last_bitmap_smaller_ = false;
// True if the plugin is full-page. // True if the plugin is full-page.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment