New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 760425 link

Starred by 1 user

Issue metadata

Status: WontFix
Owner:
Last visit > 30 days ago
Closed: Aug 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: All
Pri: 2
Type: Bug



Sign in to add a comment

scrollTop value is wrong after page zooming.

Project Member Reported by chungsheng@google.com, Aug 30 2017

Issue description

Chrome Version: 62.0.3195.0
OS: All

What steps will reproduce the problem?
(1) Open a website which has scrollbar(www.yahoo.com).
(2) Zoom the page to maybe 70% or 150%.
(3) Open JS console. Set |document.scrollElement.scrollTop| to some value. (We test 1001, 2323)

What is the expected result?
|document.scrollElement.scrollTop| become what we set.

What happens instead?
It become some different value. 
ex:
At 75% zooming, we set it to 2323 and it become 2322.666748046875.
At 50% zooming, we set it to 1001 and it become 1000.

 
Cc: deanliao@chromium.org chungsheng@google.com
 Issue 758495  has been merged into this issue.
Components: Blink>Layout>Scrollbars Blink>Scroll

Comment 3 by vovoy@chromium.org, Aug 30 2017

Cc: bokan@chromium.org
similar issue:
https://bugs.chromium.org/p/chromium/issues/detail?id=709562

Comment 4 Deleted

Comment 5 by vovoy@chromium.org, Aug 30 2017

The wrong scrollTop value is caused by truncating to integer in ScrollableArea::ScrollOffsetChanged().

ex:
zoom: 110%
> document.scrollElement.scrollTop = 1001;
Element::setScrollTop(1001.0)
ScrollableArea::ScrollOffsetChanged() called with offset.Height() = 1101.1
the offset was truncated to 1101.0 as ShouldUseIntegerScrollOffset() returns true

> document.scrollElement.scrollTop;
in LocalDOMWindow::scrollY(), view->LayoutViewportScrollableArea()->GetScrollOffset().Height() returns 1101.0
Element::scrollTop() returns 1000.909058
Components: -Blink>JavaScript>API

Comment 7 by e...@chromium.org, Aug 30 2017

Status: WontFix (was: Untriaged)
This is due to a combination of two issues:

1) Scroll offsets need to be aligned to the device pixel grid (or everything will become blurry).
2) Scroll values are exposed as floating point with limited precision.

Say you set scrollTop to 1001px at a 75% zoom factor, that translates to ~750.75 device pixels. We can't scroll to that exact offset so instead it is truncated to 750.

When you now query the scrollTop value in JS we take the actual offset (750) and adjust it for the zoom factor resulting in 1000px.

This might be unexpected but it is working as intended from the browser point of view as we chose to have the return values match the *actual* values rather than the ideal/specified values. This to ensure that one can correctly identify whether something is within the viewport or whether one has scrolled to the bottom/right of a scroller.

Hope this helps and thanks for the report.

Sign in to add a comment