Closed Bug 1916589 Opened 2 months ago Closed 1 month ago

Add BrowsingContext flag to emulate forced-colors

Categories

(Core :: Layout, task)

task

Tracking

()

RESOLVED FIXED
132 Branch
Tracking Status
firefox132 --- fixed

People

(Reporter: nchevobbe, Assigned: nchevobbe)

References

(Blocks 1 open bug)

Details

Attachments

(2 files)

This could then be used by DevTools to emulate forced-colors/HCM on a single page

Blocks: 1591539
No longer blocks: 1651400

Anna will probably take this.

In https://bugzilla.mozilla.org/show_bug.cgi?id=1591539#c2

The platform bits of this aren't too complicated, fwiw, happy to help / mentor.

Emilio, since you offered some mentoring, I'll gladly take it :)

I started a WIP patch (https://phabricator.services.mozilla.com/D221334), which is basically copying all the same bits we had in BrowsingContext for preferedColorSchemeOverride. Now I guess is a matter or where to use this new flag in the code to actually override the forced-colors media query

Flags: needinfo?(emilio)

I left some comments. But basically, you need to store either the browsing-context flag or the resolved forced-colors value somewhere in the pres context (probably mMediaEmulationData for the former, and an enum for the later), then change this to honor it, and update it in UpdateBrowsingContextDependentData().

My suggestion would be to add the resolved value in the pres context which should be slightly cheaper when using it from style.

Flags: needinfo?(emilio)
Assignee: nobody → nchevobbe
Attachment #9423234 - Attachment description: WIP: Bug 1916589 - Add forcedColorsOverride flag to BrowsingContext. → Bug 1916589 - Add forcedColorsOverride flag to BrowsingContext. r=emilio.
Status: NEW → ASSIGNED

(In reply to Emilio Cobos Álvarez (:emilio) from comment #4)

I left some comments. But basically, you need to store either the browsing-context flag or the resolved forced-colors value somewhere in the pres context (probably mMediaEmulationData for the former, and an enum for the later), then change this to honor it, and update it in UpdateBrowsingContextDependentData().

My suggestion would be to add the resolved value in the pres context which should be slightly cheaper when using it from style.

Thanks for the pointers Emilio!

Untested, but something like this is what I meant above.

Not sure if you saw my comment on Phabricator, so putting a needinfo so it's visible:

looks like layout/style/test/test_dont_use_document_colors.html is failing with this patch: https://treeherder.mozilla.org/logviewer?job_id=474223582&repo=try&lineNumber=8796

Flags: needinfo?(emilio)

Applying the patch to latest central doesn't cause the test to fail locally... Is it opt only somehow? Or something else?

Flags: needinfo?(emilio)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #8)

Applying the patch to latest central doesn't cause the test to fail locally... Is it opt only somehow? Or something else?

It does fail for me locally, I don't have anything specific in my mozconfig. Do you want me to check something specific ?

Flags: needinfo?(emilio)

Let me pull the last version from phab to confirm that though

Hmm, I guess I'll try on macOS, but it works for me. I think I missed one place where I had to call UpdateForcedColors(), mind pulling the latest version and confirming it fixes it for you?

Flags: needinfo?(emilio)

(In reply to Emilio Cobos Álvarez (:emilio) from comment #11)

Hmm, I guess I'll try on macOS, but it works for me. I think I missed one place where I had to call UpdateForcedColors(), mind pulling the latest version and confirming it fixes it for you?

last version works fine 👍

Pushed by nchevobbe@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/4e1b664de4d8 Move forced-colors computation to nsPresContext. r=nchevobbe https://hg.mozilla.org/integration/autoland/rev/2c735de75ad9 Add forcedColorsOverride flag to BrowsingContext. r=emilio.
Status: ASSIGNED → RESOLVED
Closed: 1 month ago
Resolution: --- → FIXED
Target Milestone: --- → 132 Branch
Regressions: 1919611
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: