scroll position of subpixel is not reported by scrollTop /scrollLeft correctly
Categories
(Core :: DOM: CSS Object Model, defect)
Tracking
()
People
(Reporter: mmis1000, Assigned: emilio)
References
(Depends on 1 open bug, Blocks 3 open bugs)
Details
Attachments
(2 files)
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:84.0) Gecko/20100101 Firefox/84.0
Firefox for Android
Steps to reproduce:
- Make a scroll container that have a non integer scroll height.
- load the page in a
real
hidpi device. (this is important, or you can't reproduce it) - scroll the container to bottom.
- read the scrollTop of the container.
<div class="c">
<div class="d">
max scrollTop is: <span class="st"></span>
<br>
rect offset (real scroll top)is: <span class="br"></span>
<br>
dpi is: <span class="dpi"></span>
</div>
</div>
body, html {
padding: 0;
margin: 0;
}
.c {
height: 99px;
overflow-y: auto;
position: realtive;
background: blue;
color: white;
}
.d {
height: 150%;
}
document.querySelector('.dpi').textContent = window.devicePixelRatio
const el = document.querySelector('.c')
const elInner = document.querySelector('.d')
el.scrollTop = 9999
document.querySelector('.st').textContent = el.scrollTop
document.querySelector('.br').textContent = -( elInner.getBoundingClientRect().y - el.getBoundingClientRect().y)
el.scrollTop = 0
Actual results:
The scrollTop was always rounded to integer 50
regardless of whether the container have a non integer height.
Expected results:
The scrollTop reports correct scroll position like 49.5
as the getBoundingClientRect() suggests.
Note: The chrome reports it correctly.
Updated•4 years ago
|
Assignee | ||
Comment 1•4 years ago
|
||
We use integers for scrollTop
and such, but the spec made them unrestricted double
at some point looks like... https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface
Generally in favor of making these return doubles, see https://github.com/w3c/csswg-drafts/issues/5260.
Assignee | ||
Comment 2•4 years ago
|
||
Assignee | ||
Comment 3•4 years ago
|
||
As per the latest draft:
https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface
This matches Chrome. WebKit bug is:
Updated•4 years ago
|
Comment 4•4 years ago
|
||
There's a r+ patch which didn't land and no activity in this bug for 2 weeks.
:emilio, could you have a look please?
For more information, please visit auto_nag documentation.
Assignee | ||
Comment 5•4 years ago
|
||
Yeah, there are some issues with WPT on android that I need to figure out. For some reason we're using fractional scaling there, which breaks some tests.
Updated•2 years ago
|
Updated•2 years ago
|
Updated•2 years ago
|
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Comment 7•2 years ago
|
||
So there are various android tests that still need work, but they seem just rounding errors: https://treeherder.mozilla.org/jobs?repo=try&revision=99bd1537d329eced1d231983c6a89aeb0462ab50
Assignee | ||
Comment 8•2 years ago
|
||
Ah, there's also some errors on macOS which are bug 1674687.
Updated•1 year ago
|
Description
•