scroll position of subpixel is not reported by scrollTop /scrollLeft correctly
Categories
(Core :: DOM: CSS Object Model, defect)
Tracking
()
Tracking | Status | |
---|---|---|
firefox141 | --- | fixed |
People
(Reporter: mmis1000, Assigned: hiro)
References
(Depends on 1 open bug, Blocks 2 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•5 years ago
|
Comment 1•5 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.
Comment 2•5 years ago
|
||
Comment 3•5 years ago
|
||
As per the latest draft:
https://drafts.csswg.org/cssom-view/#extension-to-the-element-interface
This matches Chrome. WebKit bug is:
Assignee | ||
Updated•5 years ago
|
Comment 4•5 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.
Comment 5•5 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•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Updated•2 years ago
|
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
Comment 8•2 years ago
|
||
Ah, there's also some errors on macOS which are bug 1674687.
Assignee | ||
Updated•2 years ago
|
Assignee | ||
Comment 9•3 months ago
|
||
There's a concerns that landing this change without bug 1946610 may cause jitter scrolling or some such if the site implements its own scroll operation logic in JS.
That's being said, such things should have been there since scrollTo
and scrollBy
operations have already double precision.
Anyways, I am going to land this change right now to see what happens. Since it's an early state of the current nightly, if something bad happens we will back the change out.
Changing "Assignee" to me.
Comment 10•3 months ago
|
||
Comment 11•3 months ago
|
||
Comment 12•3 months ago
|
||
Backed out for causing multiple failures
Failure log browser_dbg-editor-scroll.js
Failure log test_wheel_default_action.html
Assignee | ||
Comment 13•2 months ago
|
||
Filed bug 1968629 and bug 1968837 for the failures.
Comment 14•2 months ago
|
||
Comment 15•2 months ago
|
||
Comment 16•2 months ago
|
||
Reverted this because it was causing mochitests-plain failures in test_bug795785.html.
Also, there are some wpt failures.
Assignee | ||
Updated•2 months ago
|
Comment 17•2 months ago
|
||
Comment 18•2 months ago
|
||
Comment 19•2 months ago
|
||
Backed out for multiple mochitest failures related to scroll
Backout link: https://hg-edge.mozilla.org/integration/autoland/rev/96bd92b2e4fb987ae5d7acdb636d00d65ab13f8d
Fail link: https://treeherder.mozilla.org/logviewer?job_id=512067787&repo=autoland&lineNumber=5136
Fail link2: https://treeherder.mozilla.org/logviewer?job_id=512067838&repo=autoland&lineNumber=2918
Fail link3: https://treeherder.mozilla.org/logviewer?job_id=512067778&repo=autoland&lineNumber=5120
Fail link4: https://treeherder.mozilla.org/logviewer?job_id=512069059&repo=autoland&lineNumber=2710
Fail link5: https://treeherder.mozilla.org/logviewer?job_id=512068019&repo=autoland&lineNumber=3647
Assignee | ||
Updated•2 months ago
|
Comment 20•2 months ago
|
||
Comment 21•2 months ago
|
||
bugherder |
Updated•2 months ago
|
Description
•