Closed Bug 1674687 Opened 5 years ago Closed 2 months ago

scroll position of subpixel is not reported by scrollTop /scrollLeft correctly

Categories

(Core :: DOM: CSS Object Model, defect)

Firefox 84
defect

Tracking

()

RESOLVED FIXED
141 Branch
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:

  1. Make a scroll container that have a non integer scroll height.
  2. load the page in a real hidpi device. (this is important, or you can't reproduce it)
  3. scroll the container to bottom.
  4. 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.

Component: Untriaged → DOM: CSS Object Model
Product: Firefox → Core

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: nobody → emilio
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Severity: -- → S3

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.

Flags: needinfo?(emilio)

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.

Flags: needinfo?(emilio)
Attachment #9185099 - Attachment description: Bug 1674687 - [cssom-view] Make scroll-related OM properties doubles. r=mats → WIP: Bug 1674687 - [cssom-view] Make scroll-related OM properties doubles. r=mats
Attachment #9185099 - Attachment description: WIP: Bug 1674687 - [cssom-view] Make scroll-related OM properties doubles. r=mats → Bug 1674687 - [cssom-view] Make scroll-related OM properties doubles. r=mats
Depends on: 1774315
Attachment #9185099 - Attachment description: Bug 1674687 - [cssom-view] Make scroll-related OM properties doubles. r=mats → Bug 1674687 - [cssom-view] Make scroll-related OM properties doubles. r=smaug
Flags: needinfo?(emilio)

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

Ah, there's also some errors on macOS which are bug 1674687.

Flags: needinfo?(emilio)
See Also: → 1851066
Blocks: 1851066
See Also: 1851066
Blocks: 1556685
Depends on: 1946610
No longer depends on: 1774315
See Also: → 1959553
Blocks: 1964517
Depends on: 1965953
Depends on: 1965988
Depends on: 1966267
Depends on: 1966276
Depends on: 1967169
Depends on: 1967340
Depends on: 1967343
Depends on: 1967357
Depends on: 1967635

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.

Assignee: emilio → hikezoe.birchill
Pushed by hikezoe.birchill@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/3dbdd49c22ca [cssom-view] Make scroll-related OM properties doubles. r=mats,webidl,smaug
Pushed by chorotan@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a96008e0c883 Revert "Bug 1674687 - [cssom-view] Make scroll-related OM properties doubles. r=mats,webidl,smaug" for causing dt failures at browser_dbg-editor-scroll.js
Depends on: 1968837

Filed bug 1968629 and bug 1968837 for the failures.

Depends on: 1968629
Flags: needinfo?(hikezoe.birchill)
Pushed by sstanca@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/cc5186e898c9 https://hg.mozilla.org/integration/autoland/rev/2c000fc5e0b9 Revert "Bug 1674687 - [cssom-view] Make scroll-related OM properties doubles. r=mats,webidl,smaug" for causing mochitests-plain failures in test_bug795785.html.

Reverted this because it was causing mochitests-plain failures in test_bug795785.html.

Also, there are some wpt failures.

Flags: needinfo?(hikezoe.birchill)
Depends on: 1970050
Depends on: 1970540
Flags: needinfo?(hikezoe.birchill)
Pushed by nbeleuzu@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/6d17a21a18da https://hg.mozilla.org/integration/autoland/rev/96bd92b2e4fb Revert "Bug 1674687 - [cssom-view] Make scroll-related OM properties doubles. r=mats,webidl,smaug" for multiple mochitest failures related to scroll
Depends on: 1971056
Depends on: 1971057
Flags: needinfo?(hikezoe.birchill)
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 141 Branch
QA Whiteboard: [qa-triage-done-c142/b141]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: