Open Bug 1874091 Opened 6 months ago Updated 6 days ago

Highlighted area is shifted to the right when "scrollbar-gutter: both-edges" is used (top-layer fixed-pos cb affected by scrollbar-gutter)

Categories

(Core :: Layout: Positioned, defect, P3)

Firefox 97
defect

Tracking

()

ASSIGNED

People

(Reporter: 6k64x4ma, Assigned: TYLin)

References

Details

Attachments

(7 files)

Attached file test.html

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:122.0) Gecko/20100101 Firefox/122.0

Steps to reproduce:

  1. Load the attached file.
  2. Open the Inspector and hover over the node in the HTML tree.

Actual results:

  • Higilighted area is shifted to the right.

Expected results:

  • Not so.

I can reproduce this on Nightly 2021-12-16.

Attached image screenshot.webp
See Also: → 1715112

Thanks for the report, I can reproduce easily.
I think that what's happening is that the .moz-custom-content-container element also get reserved space because of the scrollbar-gutter: both-edges set on the <html>.

Emilio, am I correct here?

Flags: needinfo?(emilio)

It seems like this is impacting the Firefox Screenshot overlay as well

Attached image modal

And maybe ::backdrop ?
Navigate to data:text/html,<meta charset=utf8><style>::backdrop { background: tomato; } html { scrollbar-gutter: stable both-edges; background: gold; } </style><html>hello<dialog id=d>modal</dialog><script>d.showModal()</script>, the backdrop doesn't cover the whole page

Summary: Higilighted area is shifted to the right when "scrollbar-gutter: both-edges" is used → Highlighted area is shifted to the right when "scrollbar-gutter: both-edges" is used

Yeah, probably the top layer fixed-pos containing block shouldn't be affected by scrollbar-gutter...

Severity: -- → S3
Component: Inspector → Layout: Positioned
Flags: needinfo?(emilio)
Priority: -- → P3
Product: DevTools → Core
Summary: Highlighted area is shifted to the right when "scrollbar-gutter: both-edges" is used → Highlighted area is shifted to the right when "scrollbar-gutter: both-edges" is used (top-layer fixed-pos cb affected by scrollbar-gutter)
Status: UNCONFIRMED → NEW
Ever confirmed: true

Yeah, so all the way from bug 1715112. Ting-Yu, it seems scrollbar-gutter doesn't play nice with fixed pos. In fact, using scrollbar-gutter: stable both-edges on the root triggers this assert.

Can you take a look?

Flags: needinfo?(aethanyc)
See Also: → 1874093

Some observation:

I added a blue border to ::backdrop for the testcase in comment 4, and notice the blue left border is missing

data:text/html,<meta charset=utf8><style>::backdrop { background: tomato; border: 5px solid blue} html { scrollbar-gutter: stable both-edges; background: gold; } </style><html>hello<dialog id=d>modal</dialog><script>d.showModal()</script>

By looking at the frame tree, Backdrop frame has x=0 while Canvas has x=720.

    Canvas(html)(-1)@7f7b0609f0c8 parent=7f7b0609f198 (x=720, y=0, w=60000, h=41190) [content=7f7b02703040] [cs=7f7b0609c408:-moz-scrolled-canvas] <

...

  FixedList@7f7b07dd9d80 <
    Backdrop(dialog id=d)(1)@7f7b060a04e0 parent=7f7b0609f020 next=7f7b0609fbd8 (x=0, y=0, w=60000, h=41190) [content=7f7b02709020] [cs=7f7b0609e308:backdrop]

So it seems the scrollbar-gutter on the left hand side breaks the assumption that a root frame (and its top-layer fixed-pos cb) is always at x=0.

Clear the regressionwindow-wanted keyword since setting scrollbar-gutter: stable both-edges never works properly on root element.

Depends on: 1715112

I can reproduce the devtools highlight shift without scrollbar-gutter, so this bug is older.

  1. Set pref layout.scrollbar.side=3 [1] to force the root scrollbar on the left, and restart the browser.
  2. Open a page with tall content (e.g. test 2) to make the scrollbar appear.
  3. Open the Inspector and hover over any node.

[1] https://searchfox.org/mozilla-central/rev/15f758f06d97ee3c4e382b174836395442c38f71/layout/generic/nsGfxScrollFrame.cpp#6019-6021,6034-6035

Flags: needinfo?(aethanyc)
See Also: → 728807
Duplicate of this bug: 1876420

I think there are few separate issues here.

(A) For devtools highlight shifts bug: .moz-custom-content-container is abs-pos under nsCanvasFrame. When <html> has scrollbar-gutter: stable both-edges, the canvas frame is not positioned at (0, 0), but at (scrollbar-width, 0) due to the gutter space at the left edge of the viewport. Per discussion with Nicolas on #DevTools channel on matrix, the highligher's position is obtained via getBoxQuads() and the coordinate is relative to root frame, not nsCanvasFrame. That's why the highlighter's position is off.

Out of curiosity, I also test AccessibleCaret, which is also an anonymous content under the .custom-content-container, but it doesn't have this position shift bug because its position has been transformed to be relative to custom-content-container.

(B) For top-layer fixed position elements such as ::backdrop, its containing block is placed relative to (0, 0) of the viewport, but with scrollbar or scrollbar-gutter on the left edge of the viewport, they really should be relative to (scrollbar-width, 0) of the viewport. I'm going to fix it in bug 728807.

(C) For screenshot overlay offset issue: it looks like the overlay is correct while moving mouse to select the region on elements, but once clicking on an element, the overlay is off. The bug occurs on a simple abspos <html> or abspos <body> without scrollbar-gutter. I've filed bug 1876592.

Depends on: 1878435
Assignee: nobody → aethanyc
Status: NEW → ASSIGNED
Attachment #9378076 - Attachment description: Bug 1874091 - Provide customize absolute containing block for custom content container under nsCanvasFrame. → WIP: Bug 1874091 - Provide customize absolute containing block for custom content container under nsCanvasFrame.

Quote https://github.com/w3c/csswg-drafts/issues/9904#issuecomment-2161022451,

The CSS Working Group just discussed [css-overflow] Top layer containing block and scrollbar-gutter, and agreed to the following:

RESOLVED: (top layer or fullscreen) elements with 'position: fixed' cover the scrollbars/gutters
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: