Add BrowsingContext flag to emulate forced-colors
Categories
(Core :: Layout, task)
Tracking
()
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
Assignee | ||
Updated•2 months ago
|
Comment 1•2 months ago
|
||
Anna will probably take this.
Assignee | ||
Comment 2•2 months ago
|
||
Assignee | ||
Comment 3•2 months ago
|
||
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
Comment 4•2 months ago
|
||
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.
Updated•1 month ago
|
Assignee | ||
Comment 5•1 month ago
|
||
(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 inUpdateBrowsingContextDependentData()
.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!
Comment 6•1 month ago
|
||
Untested, but something like this is what I meant above.
Assignee | ||
Comment 7•1 month ago
|
||
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
Comment 8•1 month ago
|
||
Applying the patch to latest central doesn't cause the test to fail locally... Is it opt only somehow? Or something else?
Assignee | ||
Comment 9•1 month ago
|
||
(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 ?
Assignee | ||
Comment 10•1 month ago
|
||
Let me pull the last version from phab to confirm that though
Comment 11•1 month ago
|
||
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?
Assignee | ||
Comment 12•1 month ago
|
||
(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 👍
Comment 13•1 month ago
|
||
Comment 14•1 month ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/4e1b664de4d8
https://hg.mozilla.org/mozilla-central/rev/2c735de75ad9
Description
•