Closed Bug 2035564 Opened 3 months ago Closed 2 months ago

Scrollbar color-scheme detection fails to detect opaque light `<body>` gradient completely covering dark root background

Categories

(Core :: Widget, defect)

Firefox 149
Desktop
All
defect

Tracking

()

RESOLVED WONTFIX

People

(Reporter: oss, Assigned: spohl)

References

(Regression)

Details

(Keywords: regression)

Attachments

(2 files, 1 obsolete file)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/147.0.0.0 Safari/537.36

Steps to reproduce:

  1. Visit the iframe section of the attached reproduction
  2. Observe scrollbars are dark themed

Actual results:

Scrollbars are dark themed, while WebKit and Blink render them system color themed, just like regular scroll containers.

Expected results:

Scrollbars should have the same color as normal divs or top level window root.

PS: When testing, make sure to enable "classic" scrollbar style (aka. "always" on OSX).

Component: Untriaged → Widget
OS: Unspecified → All
Product: Firefox → Core
Regressed by: 1710324
Hardware: Unspecified → Desktop
Keywords: platform-parity
Flags: needinfo?(emilio)

ColorSchemeForWidget routes scrollbar parts through
IsDarkBackgroundForScrollbar, which inspects the effective background
under the scrolled frame and themes the scrollbar dark on dark
backgrounds. Applied to a nested document, the heuristic walks the
iframe's own page (its <html>/<body>) and themes the scrollbar to
match — even though the scrollbar visually belongs to the embedder's
chrome, not the embedded content.

This surfaces clearly when an iframe sets html { background: #222 }
on an otherwise-light embedding page (the bug's reproduction): the
iframe's root scrollbar themes dark while every other scrollbar on
the page (top-level root, divs with overflow) themes light, which
matches what WebKit and Blink do for the same content.

When the scrolled frame we resolved is the root scroll container of a
sub-document, redirect detection to the embedder's iframe element
frame in the outer document. FindEffectiveBackgroundColor then walks
from there — through the embedder's CSS rules (e.g., the testbench's
iframe { background: white } rule) and up the outer document — and
returns a color that reflects the chrome the scrollbar actually sits
in.

Preserved behavior:

  • Top-level scrollbars: IsRootContentDocumentInProcess returns
    true, so the new branch is skipped and the heuristic runs as
    before on the top-level page.
  • Inner div scrollbars (e.g., a <div style="overflow: scroll">
    inside an iframe): scrollContainerFrame is not the doc's root
    scroll, branch skipped — the heuristic still runs on the div's
    own background.
  • XUL <tree> and other widgets that don't have a scroll
    container: scrollContainerFrame is null, branch never reached.

The fix is in the widget layer rather than the layout layer because
the right starting point for "what's behind this scrollbar visually"
is a widget concern — FindEffectiveBackgroundColor itself is still a
faithful query on the frame it's given.

Assignee: nobody → spohl.mozilla.bugs
Status: UNCONFIRMED → ASSIGNED
Ever confirmed: true
Flags: needinfo?(emilio)
Attached file Reduced test-case.

This has nothing to do with subdocuments. the <body> has a gradient background that we can't reason about. Giving it a background-color: white; or so in the original test-case will get the wanted behavior.

The issue is that our background-color-scheme detection only looks at background-color, not background-image (which is expected, it's hard to reason about gradients or arbitrary images).

I think this is bordering WONTFIX tbh, but we could try to fix it for simple opaque gradients where all color stops match the desired scheme, or return the default background-color for opaque background-images, or so...

Summary: scrollbar wrongly themed on nested document roots → Scrollbar color-scheme detection fails to detect opaque light `<body>` gradient completely covering dark root background
Attachment #9575309 - Attachment description: Bug 2035564: Treat sub-document root scrollbars as embedder chrome for dark-bg detection. r=emilio! → Bug 2035564: Stop FindEffectiveBackgroundColor's walk at frames with a non-empty background-image. r=emilio!
Attachment #9575407 - Attachment mime type: text/plain → text/html

Curious, did you find in a real website? The issue here is that your iframes have a dark background-color which is completely obscured by the <body> background-image. I'm not convinced we should change our behavior here, see the discussion in https://bugzilla.mozilla.org/attachment.cgi?id=9575309

Other browsers don't have heuristics to theme the scrollbars light / dark. We now have the color-scheme property, and we could implement something like that, but I'm not convinced it'd be a net benefit for real websites.

Flags: needinfo?(oss)

(In reply to Emilio Cobos Álvarez [:emilio] from comment #5)

Curious, did you find in a real website? The issue here is that your iframes have a dark background-color which is completely obscured by the <body> background-image. I'm not convinced we should change our behavior here, see the discussion in https://bugzilla.mozilla.org/attachment.cgi?id=9575309

Other browsers don't have heuristics to theme the scrollbars light / dark. We now have the color-scheme property, and we could implement something like that, but I'm not convinced it'd be a net benefit for real websites.

No, I found it during interop testing for scrollbar(-gutter) positioning in various render scenarios. I was scaffolding a bunch of test benches with Gemini and it just so happened to style one like that, prompting me to raise the issue.

I'm ok with closing this one as wont fix.

Flags: needinfo?(oss)

Thanks, Emilio, for all the feedback. Closing.

Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → WONTFIX
Attachment #9575309 - Attachment is obsolete: true
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: