Open Bug 1674687 Opened 4 years ago Updated 10 months ago

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

Categories

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

Firefox 84
defect

Tracking

()

ASSIGNED

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:

  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
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: