Closed Bug 1756831 Opened 3 years ago Closed 3 years ago

Overlay scrollbars are displayed above fixed elements

Categories

(Core :: Layout: Scrolling and Overflow, defect)

Firefox 99
defect

Tracking

()

RESOLVED FIXED
100 Branch
Tracking Status
firefox100 --- fixed

People

(Reporter: gterras, Assigned: tnikkel)

References

Details

Attachments

(4 files)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:99.0) Gecko/20100101 Firefox/99.0

Steps to reproduce:

Have a scrollable element and a position:fixed element inside it.

Actual results:

Overlay scrollbars are displayed above fixed element, allowing actual scroll of the underlying element.

See example https://jsfiddle.net/8vcnjy40/13/

Expected results:

The scrollbar should not be hoverable or actionable.

Maybe introduced by https://bugzilla.mozilla.org/show_bug.cgi?id=1147847

Component: Untriaged → Widget: Gtk
Product: Firefox → Core
Regressed by: 1147847

Not specific to GTK scrollbars, macOS has this too.

Component: Widget: Gtk → Panning and Zooming
No longer regressed by: 1147847

There is a bunch of code in nsGfxScrollFrame.cpp that sets the z index higher than content of overlay scrollbars that is likely responsible.

Yep, specifically this code.

We've seen some issues before where that code computes a larger z-index than we'd like (by including more items in the maximum than it should). See discussion around bug 1611872 comment 12.

Component: Panning and Zooming → Layout: Scrolling and Overflow

Does this cause significant problems for you? Can you expand on how this affects you?

Flags: needinfo?(gterras)

Yes it breaks my app modals since there are scrollbars from underlying elements over it.

In case you wonder having position:fixed here is very important as it is to my knowledge the only way to break out an overflow:hidden element boundaries, giving the ability to display a "full screen" modal from anywhere in the markup (which is priceless when composing complex interfaces).

Flags: needinfo?(gterras)

The severity field is not set for this bug.
:boris, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(boris.chiou)

Can you explain what steps you are using to reproduce? When I open your testcase I can't get the scrollbar to appear or interact with it.

Flags: needinfo?(gterras)

A hover where the scrollbar is supposed to be (on the right side of the box) is enough for me to trigger the behavior, what's your OS? I can try to reproduce.

Flags: needinfo?(gterras)

Interesting. Thanks. Might be Linux specific. I tested on macOS. I can try on Linux and Windows

I could repro on macOS too, fwiw. Though it was trickier to get the timing right because macOS only shows scrollbars for active scrollers, not when you have the mouse over the scroller like Windows and Linux do.

So to reproduce on macOS you mouse over the scrollbars right after page load?

Attached file abgh.html

This testcase scrolls the scrollable div 1 second after load, which makes the scrollbar visible in all browsers I tested. I created it to see what other browsers do when the scrollbar has been made visible on macOS (where there isn't any other convenient way to make the scrollbar visible).

Attached image addons.mozilla.org.png

This bug is affecting the gallery view on AMO.

STR:

  1. Click an image in the gallery.
  2. Hover cursor anywhere.

Expected result: The gallery scrollbar is not visible
Actual result: The scrollbar is visible and can be interacted with

When the position:fixed image is present, hovering the cursor in any part of the viewport will cause the scrollbar to appear, this does not happen when the position:fixed image is removed.

And you're on Linux?

Flags: needinfo?(kekvord)

I have a potential patch here https://hg.mozilla.org/try/rev/e328ca4be098c242a1a2741f8082232471524739
Reading code/bug history to see if there is a reason we haven't been doing that sooner.

(In reply to Timothy Nikkel (:tnikkel) from comment #14)

And you're on Linux?

Yes.

Flags: needinfo?(kekvord)
Status: UNCONFIRMED → NEW
Ever confirmed: true
Assignee: nobody → tnikkel
Status: NEW → ASSIGNED
Severity: -- → S3
Pushed by tnikkel@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c745539344fb When considering mousemoves over scroll frames to show overlay scrollbars rejects mousemove over content descendants that aren't frame descandants. r=emilio https://hg.mozilla.org/integration/autoland/rev/38e3a0e0fab7 Add test. r=emilio
Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED
Target Milestone: --- → 100 Branch

A little bit of an explanatory comment.

Linux and Windows overlay scrollbars are a little bit different from Mac overlay scrollbars. Specifically, in order to get overlay scrollbars to show up on mac you have to do some sort of scrolling activity (or have a new scrollable area created). Whereas on Linux/Windows all you have to do is mouse over the scrollable content or the where the scrollbar would be.

Although there are a few ways to make the overlay scrollbar in the testcase here show up on mac (double clicking, or reloading the page) they are fairly edge case-y. On Linux/Windows all you have to do is mouse over the fixed content. This is a bug because the fixed content is not scrollable by the scroll frame. This bug has been in the code for a long time but only more recently began to show up more because overlay scrollbars are becoming possible/more popular on Linux/Windows. This is the bug that we fixed here.

There is a different but related bug here as well, the one that is fixed by the patch in comment 15. Which is that overlay scrollbars are placed on top of all content descendants of the scrollable element, whether or not they are actually scrolled by that element (eg position absolute elements for which the scrollable element is not an absolute container). Classic scrollbars are low in the z-order, they are put in the same layer as the border/backgrounds, see here

https://searchfox.org/mozilla-central/rev/1659f76981610c1b06437e0a34c0c232b48f4c93/layout/generic/nsGfxScrollFrame.cpp#3390

This is fine because we reserve space for the scrollbars, so none of the content that they scroll can be on top of them. Overlay scrollbars on the other hand do not have space reserved for them, so in order for them to be visible at all they need to be above the content that they scroll. We add them to the display list after we have descended into the scrollframe and built it's display list. We look at that display list for any positioned descendants and if any of them have a non-auto, positive z-index we use the maximum such z-index and also insert into the positioned descendants layer. If there is no such z-index we insert into the content layer. We do this because we try not to place the scrollbars too high in the z-index so they are not over top of content that they do not scroll. However this misses one important thing which is that the items in the positioned descendants list are not all scrolled by the current scroll frame.

See this comment for a nice overview of when we implemented this behaviour https://bugzilla.mozilla.org/show_bug.cgi?id=926292#c15 which also points out that we can never do this perfectly as it creates conflicting requirements. However we can still move them down and meet all requirements in many cases (for example the test case here), so that even if the scrollbars are shown in this testcase they will not be able to be targeted by user input because they are below the fixed content (and will also be drawn that way).

I'll file a followup for that patch and link it here when I do.

Hi thanks for the fix I'm running Mozilla/5.0 (X11; Linux x86_64; rv:101.0) Gecko/20100101 Firefox/101.0 and while the bug is fixed for the base case it can still be triggered quite easily (on Linux at least) as long as you don't wait for auto-hide to happen, see https://jsfiddle.net/6fz5b04m/28/ for reproduction. Should I open a new bug for this or provide a description here?

That should be covered by the followup I mentioned in comment 21, which I haven't had a chance yet to file. Thanks for reporting that issue.

Flags: needinfo?(boris.chiou)
See Also: → 1803910
Depends on: 1827337

Bug 1827337 is the followup I mentioned.

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: