Commit 76a886bb authored by Ella Ge's avatar Ella Ge Committed by Commit Bot

make scroll_offset not stored in dip scale in BrowserViewRenderer

The scroll amount passed into BrowserViewRenderer::ScrollTo is
physical pixel with page_scale_factor applied.
Before --use-zoom-for-dsf enabled, the scroll amount was divided by
both dip_scale_ and page_scale_factor_ to convert to scroll amount
in dip. With the flag enabled, it still need to divide by the
page_scale_factor, but it incorrectly passed the original offset
without take page_scale_factor into account, causes scroll amount
larger than the max_scroll_offset.

When --use-zoom-for-dsf is enabled, scroll_offset_dip_ and
max_scroll_offset_dip_ are convert from/to physical pixel in
every it get used. We shouldn't stored them in dip.

So, this cl changes scroll_offset_dip_ to scroll_offset_unscaled_
and max_scroll_offset_dip_ to max_scroll_offset_unscaled_,
as they were in physical pixel when zoom-for-dsf enabled, and
dip otherwise. Instead of having dip_scale applied every time it
was set.

TEST: webview_ui_test.test.DropDownListTest#testDropDownScaledViewPortUseWideViewPort
Bug: 869995, 873617
Change-Id: I694ca54438620e7afdf8db210704f40fb2c1ba54
Reviewed-on: https://chromium-review.googlesource.com/1162519Reviewed-by: default avatarBo <boliu@chromium.org>
Reviewed-by: default avatarDavid Bokan <bokan@chromium.org>
Commit-Queue: Ella Ge <eirage@chromium.org>
Cr-Commit-Position: refs/heads/master@{#582692}
parent 62dd4bf8
...@@ -100,7 +100,8 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient, ...@@ -100,7 +100,8 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient,
float dip_scale() const { return dip_scale_; } float dip_scale() const { return dip_scale_; }
float page_scale_factor() const { return page_scale_factor_; } float page_scale_factor() const { return page_scale_factor_; }
// Set the root layer scroll offset to |new_value|. // Set the root layer scroll offset to |new_value|. The |new_value| here is in
// physical pixel.
void ScrollTo(const gfx::Vector2d& new_value); void ScrollTo(const gfx::Vector2d& new_value);
// Android views hierarchy gluing. // Android views hierarchy gluing.
...@@ -224,11 +225,13 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient, ...@@ -224,11 +225,13 @@ class BrowserViewRenderer : public content::SynchronousCompositorClient,
gfx::SizeF scrollable_size_dip_; gfx::SizeF scrollable_size_dip_;
// TODO(miletus): Make scroll_offset_dip_ a gfx::ScrollOffset. // When zoom-for-dsf enabled |max_scroll_offset_unscaled_| and
gfx::Vector2dF scroll_offset_dip_; // |scroll_offset_unscaled_| is in physical pixel; otherwise, they are in dip
// TODO(miletus): Make scroll_offset_unscaled_ a gfx::ScrollOffset.
gfx::Vector2dF scroll_offset_unscaled_;
// TODO(miletus): Make max_scroll_offset_dip_ a gfx::ScrollOffset. // TODO(miletus): Make max_scroll_offset_unscaled_ a gfx::ScrollOffset.
gfx::Vector2dF max_scroll_offset_dip_; gfx::Vector2dF max_scroll_offset_unscaled_;
// Used to prevent rounding errors from accumulating enough to generate // Used to prevent rounding errors from accumulating enough to generate
// visible skew (especially noticeable when scrolling up and down in the same // visible skew (especially noticeable when scrolling up and down in the same
......
...@@ -131,7 +131,8 @@ class SynchronousCompositorHost : public SynchronousCompositor, ...@@ -131,7 +131,8 @@ class SynchronousCompositorHost : public SynchronousCompositor,
// Indicates begin frames are paused from the browser. // Indicates begin frames are paused from the browser.
bool begin_frame_paused_ = false; bool begin_frame_paused_ = false;
// Updated by both renderer and browser. // Updated by both renderer and browser. This is in physical pixel when
// use-zoom-for-dsf is enabled, otherwise in dip.
gfx::ScrollOffset root_scroll_offset_; gfx::ScrollOffset root_scroll_offset_;
// Indicates that whether OnComputeScroll is called or overridden. The // Indicates that whether OnComputeScroll is called or overridden. The
...@@ -146,6 +147,7 @@ class SynchronousCompositorHost : public SynchronousCompositor, ...@@ -146,6 +147,7 @@ class SynchronousCompositorHost : public SynchronousCompositor,
bool invalidate_needs_draw_; bool invalidate_needs_draw_;
uint32_t did_activate_pending_tree_count_; uint32_t did_activate_pending_tree_count_;
uint32_t frame_metadata_version_ = 0u; uint32_t frame_metadata_version_ = 0u;
// Physical pixel when use-zoom-for-dsf is enabled, otherwise in dip.
gfx::ScrollOffset max_scroll_offset_; gfx::ScrollOffset max_scroll_offset_;
gfx::SizeF scrollable_size_; gfx::SizeF scrollable_size_;
float page_scale_factor_ = 0.f; float page_scale_factor_ = 0.f;
......
...@@ -130,6 +130,8 @@ class SynchronousCompositorProxy : public ui::SynchronousInputHandler, ...@@ -130,6 +130,8 @@ class SynchronousCompositorProxy : public ui::SynchronousInputHandler,
// To browser. // To browser.
uint32_t version_ = 0; uint32_t version_ = 0;
// |total_scroll_offset_| and |max_scroll_offset_| are in physical pixel when
// use-zoom-for-dsf is enabled, otherwise in dip.
gfx::ScrollOffset total_scroll_offset_; // Modified by both. gfx::ScrollOffset total_scroll_offset_; // Modified by both.
gfx::ScrollOffset max_scroll_offset_; gfx::ScrollOffset max_scroll_offset_;
gfx::SizeF scrollable_size_; gfx::SizeF scrollable_size_;
......
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