Closed Bug 1400094 Opened 7 years ago Closed 4 years ago

Why does scroll propagation to viewport take anything other than overflow values into account?

Categories

(Core :: Layout, enhancement, P3)

53 Branch
enhancement

Tracking

()

RESOLVED DUPLICATE of bug 1586600
Tracking Status
firefox57 --- fix-optional

People

(Reporter: bzbarsky, Unassigned)

References

Details

Per http://searchfox.org/mozilla-central/rev/6326724982c66aaeaf70bb7c7ee170f7a38ca226/layout/base/nsPresContext.cpp#1457-1465 we also take into account smoothscroll and scrollsnap styles.

So for example, this testcase:

  <!DOCTYPE html>
  <html>
    <head>
      <style>
        body { overflow: scroll; border: 1px solid green; }
        html { scroll-behavior: smooth; }
      </style>
    </head>
    <body>
      Should this have a body scrollbar?
    </body>
  </head>
  </html>

shows extra body scrollbars in Gecko, and I don't think it really should.

Looking at the history, the scroll-snap bits were added in bug 945584.  The smoothscroll bits were added in bug 1010538.

Per 1010538 comment 37, scroll-behavior should propagate from the root to the viewport, but there's no mention of <body> in that spec (<https://drafts.csswg.org/cssom-view/#smooth-scrolling>), nor anything about scroll-behavior on the root preventing overflow propagation from the <body>...  I've found no mention of any sort of propagation in https://drafts.csswg.org/css-scroll-snap/ at all.
Flags: needinfo?(kgilbert)
Oh, and to be clear that testcase I pasted above will assert, as per bug 1398500, if you try to get the body's scrollWidth.
Priority: -- → P3
https://bugzilla.mozilla.org/show_bug.cgi?id=1010538#c106 seems relevant, though I can't find the follow-up bug mentioned in that comment.
(In reply to Boris Zbarsky [:bz] (still digging out from vacation mail) from comment #0)
> Per
> http://searchfox.org/mozilla-central/rev/
> 6326724982c66aaeaf70bb7c7ee170f7a38ca226/layout/base/nsPresContext.cpp#1457-
> 1465 we also take into account smoothscroll and scrollsnap styles.
> 
> So for example, this testcase:
> 
>   <!DOCTYPE html>
>   <html>
>     <head>
>       <style>
>         body { overflow: scroll; border: 1px solid green; }
>         html { scroll-behavior: smooth; }
>       </style>
>     </head>
>     <body>
>       Should this have a body scrollbar?
>     </body>
>   </head>
>   </html>
> 
> shows extra body scrollbars in Gecko, and I don't think it really should.
> 
> Looking at the history, the scroll-snap bits were added in bug 945584.  The
> smoothscroll bits were added in bug 1010538.
> 
> Per 1010538 comment 37, scroll-behavior should propagate from the root to
> the viewport, but there's no mention of <body> in that spec
> (<https://drafts.csswg.org/cssom-view/#smooth-scrolling>), nor anything
> about scroll-behavior on the root preventing overflow propagation from the
> <body>...  I've found no mention of any sort of propagation in
> https://drafts.csswg.org/css-scroll-snap/ at all.

Any connection between overflow propagation and scroll-behavior would have been inadvertent.  If other browsers are not showing the scrollbars in this case, I would suggest updating Firefox to match.
Flags: needinfo?(kgilbert)
So I dug into the code some more.  It looks like we copy scroll snap and scroll behavior information from the element that propagation happens from into the ScrollbarStyles.

I guess the intent is that in my comment 0 testcase the viewport scrollbars do smooth scrolling.  And in this testcase:

  <!DOCTYPE html>
  <html>
    <body style="scroll-behavior: smooth;">
      <div style="height: 6000px" onclick="window.scrollTo(0, 100000)">Click me please</div>
    </body>
  </html>

We also do smooth scrolling.  I just tested Chrome, and it does NOT do smooth scrolling in that situation, though it does if you set "scroll-behavior: smooth" on the root.  Safari doesn't do it in either case (and generally seems to not support scroll-behavior).

kip, what is the actual behavior we want for this stuff?
Flags: needinfo?(kgilbert)
Blocks: 1415373
(In reply to Boris Zbarsky [:bz] (no decent commit message means r-) from comment #4)
> So I dug into the code some more.  It looks like we copy scroll snap and
> scroll behavior information from the element that propagation happens from
> into the ScrollbarStyles.
> 
> I guess the intent is that in my comment 0 testcase the viewport scrollbars
> do smooth scrolling.  And in this testcase:
> 
>   <!DOCTYPE html>
>   <html>
>     <body style="scroll-behavior: smooth;">
>       <div style="height: 6000px" onclick="window.scrollTo(0, 100000)">Click
> me please</div>
>     </body>
>   </html>
> 
> We also do smooth scrolling.  I just tested Chrome, and it does NOT do
> smooth scrolling in that situation, though it does if you set
> "scroll-behavior: smooth" on the root.  Safari doesn't do it in either case
> (and generally seems to not support scroll-behavior).
> 
> kip, what is the actual behavior we want for this stuff?

I apologize as I have been out of this space for a while and am not familiar with how this has been used outside of Mozilla since landing.  If there is little impact to sites and the spec isn't explicit in this case, I would be included to disregard / modify the test and follow the behavior of the other browsers.
Flags: needinfo?(kgilbert)

This got fixed, in more or less the way proposed above, in bug 1586600.

Status: NEW → RESOLVED
Closed: 4 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.