Closed Bug 1308775 Opened 8 years ago Closed 8 years ago

scroll-behavior: smooth interacts badly with auto scroll

Categories

(Toolkit :: General, defect)

49 Branch
x86_64
Windows 7
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla52
Tracking Status
firefox52 --- fixed

People

(Reporter: 5silentrain, Assigned: arai)

References

()

Details

Attachments

(2 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:49.0) Gecko/20100101 Firefox/49.0
Build ID: 20160922113459

Steps to reproduce:

Activate autoscrolling on the forum: http://nightmarish-dream.ru/forum/


Actual results:

Something strange is happening with the autoscroll on this forum


Expected results:

Autoscroll on this forum should work just like on all other sites
OS: Unspecified → Windows 7
Hardware: Unspecified → x86_64
The website has the following style on body:
  scroll-behavior: smooth;

it interacts badly with auto scroll.
Status: UNCONFIRMED → NEW
Component: Untriaged → Layout
Ever confirmed: true
Product: Firefox → Core
Summary: Strange problem with Autoscroll on the forum: nightmarish-dream.ru/forum/ → scroll-behavior: smooth interacts badly with auto scroll
Attached file simplified testcase
simplified testcase with |scroll-behavior: smooth| style on body, and long content
See Also: → 1010538
the issue is that, setting scrollTop or scrollLeft doesn't actually change the value until it gets scrolled visually.

  console.log(document.documentElement.scrollTop); /// 0
  document.documentElement.scrollTop = 1000;
  console.log(document.documentElement.scrollTop); /// 0

https://dxr.mozilla.org/mozilla-central/rev/7a7ba250bb2f5a7cc7acf4b97145425c5292e894/toolkit/content/browser-content.js#221-222
>       this._scrollable.scrollLeft += actualScrollX;
>       this._scrollable.scrollTop += actualScrollY;

auto scroll is implemented by adding diff to scrollTop and scrollLeft incrementally.
it means, if scrollTop doesn't return the value that is set last time, the value is not updated correctly.
(In reply to Tooru Fujisawa [:arai] from comment #2)
> Created attachment 8799228 [details]
> simplified testcase
> 
> simplified testcase with |scroll-behavior: smooth| style on body, and long
> content

Can you confirm this bug?
https://bugzilla.mozilla.org/show_bug.cgi?id=1306925
(In reply to 5silentrain from comment #4)
> Can you confirm this bug?
> https://bugzilla.mozilla.org/show_bug.cgi?id=1306925

I cannot.
on Chrome, setting scrollTop or scrollLeft doesn't start smooth scroll, but just changes the scroll position, when #smooth-scrolling flag is enabled.

kip, which behavior matches to the spec?
If Firefox's behavior matches to the spec, this might be a bug in auto scroll.
Flags: needinfo?(kgilbert)
It seems to me CSSOM View spec is mostly written according to Gecko's behavior. Setting scrollTop on Chrome doesn't really works.

But autoscroll should not be affected by scroll-behavior anyway, as it is a scrolling performed by user.

Then it comes to me that it should actually be a bug of toolkit that, toolkit should always use "scrollBy" even for elements, with "behavior" set to "instant" (or "smooth" if it looks better, but should never be "auto" since that would depend on value of scroll-behavior from the page).
Given comment 7, clear ni? for kip, and move this bug to Toolkit component.
Component: Layout → General
Flags: needinfo?(kgilbert)
Product: Core → Toolkit
Changed to use Element.scrollBy instead of scrollTop/scrollLeft.
I choose |behavior: "instant"| as |behavior: "smooth"| makes it more like *delayed* instead of smooth, and I cannot stop at the point that I want to stop.

Added somewhat corresponding testcase to browser_bug295977_autoscroll_overflow.js, but the test will be passed even without this patch.
actually it's hard to test this fix, as this bug is about smoothness, and checking smoothness will cause intermittent failure...
Assignee: nobody → arai.unmht
Attachment #8799289 - Flags: review?(dtownsend)
Comment on attachment 8799289 [details] [diff] [review]
Use Element.scrollBy with behavior: "instant" in auto scroll.

Mike might be a better reviewer here
Attachment #8799289 - Flags: review?(dtownsend) → review?(mconley)
Comment on attachment 8799289 [details] [diff] [review]
Use Element.scrollBy with behavior: "instant" in auto scroll.

Review of attachment 8799289 [details] [diff] [review]:
-----------------------------------------------------------------

I'm going to redirect this to felipe who originally reviewed the e10s middle-sclick autoscroll behaviour added by billm in bug 938359.

If felipe is overloaded, I guess you can send it back to me and I can try to swap in how all of this stuff works.
Attachment #8799289 - Flags: review?(mconley) → review?(felipc)
Comment on attachment 8799289 [details] [diff] [review]
Use Element.scrollBy with behavior: "instant" in auto scroll.

Review of attachment 8799289 [details] [diff] [review]:
-----------------------------------------------------------------

Looks good. Since this changes behavior, it's hard to predict how it can affect webpages, so let's pay extra attention for possible fall out from this. But the change and the rationale for it are reasonable.
Attachment #8799289 - Flags: review?(felipc) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/9d11e38b5fcfd0573945b810ceb49e83e0ba5386
Bug 1308775 - Use Element.scrollBy with behavior: "instant" in auto scroll. r=felipe
Looks like the testcase wasn't working as expected.
will investigate shortly.
apparently I should set middlemousepastepref to false to make the test does autoscroll on linux, after the other tests.
triggered try run
  https://treeherder.mozilla.org/#/jobs?repo=try&revision=732e0e1d1474
so, the pref for middle click affects the tests, and it should be better testing this before that part.
moved the test before tests with middlemousepastepref.
Attachment #8799289 - Attachment is obsolete: true
Attachment #8802164 - Flags: review?(felipc)
Attachment #8802164 - Flags: review?(felipc) → review+
Pushed by arai_a@mac.com:
https://hg.mozilla.org/integration/mozilla-inbound/rev/b63951fa8add
Use Element.scrollBy with behavior: "instant" in auto scroll. r=felipe
https://hg.mozilla.org/integration/mozilla-inbound/rev/b63951fa8addd9dd1011a1d95319437a364512a2
Bug 1308775 - Use Element.scrollBy with behavior: "instant" in auto scroll. r=felipe
https://hg.mozilla.org/mozilla-central/rev/b63951fa8add
Status: NEW → RESOLVED
Closed: 8 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla52
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: