Граф коммитов

18 Коммитов

Автор SHA1 Сообщение Дата
Emilio Cobos Álvarez e47024038c Bug 1762018 - Derive a color scheme when forcing preference colors. r=morgan
This patch is a bit bigger than I'd like, but it's mostly moving code
around to centralize the color/color-scheme decisions we make when
forcing colors.

In practice, the only behavior change should be that when "use system
colors" is false and we force colors, we force a color-scheme that
matches the user-chosen background (via the LookAndFeel::IsDarkColor
check).

That should make sure that text from system colors is light and matches
the user expectations.

Before this patch, we used to force the color-scheme to light, but that
was just so that we ended up looking at mLightColors. Instead, we
achieve that via a separate bit (mForcedLightColorSet, naming up for
debate, not a fan), so that we can use the right system colors
otherwise.

Another alternative I considered is making all non-link system colors
return mDefaultBackground / mDefault depending on whether they are
background / foreground colors. That seemed a lot more work and
potentially a regression in various ways. I think this should be
strictly an improvement instead.

Differential Revision: https://phabricator.services.mozilla.com/D142423
2022-04-01 01:21:22 +00:00
Cristian Tuns da85cd4a66 Backed out changeset 5d97c7b1b9b5 (bug 1762018) for causing mochitest failures in test_bug232227.html CLOSED TREE 2022-03-31 19:12:48 -04:00
Emilio Cobos Álvarez 0555de1ae2 Bug 1762018 - Derive a color scheme when forcing preference colors. r=morgan
This patch is a bit bigger than I'd like, but it's mostly moving code
around to centralize the color/color-scheme decisions we make when
forcing colors.

In practice, the only behavior change should be that when "use system
colors" is false and we force colors, we force a color-scheme that
matches the user-chosen background (via the LookAndFeel::IsDarkColor
check).

That should make sure that text from system colors is light and matches
the user expectations.

Before this patch, we used to force the color-scheme to light, but that
was just so that we ended up looking at mLightColors. Instead, we
achieve that via a separate bit (mForcedLightColorSet, naming up for
debate, not a fan), so that we can use the right system colors
otherwise.

Another alternative I considered is making all non-link system colors
return mDefaultBackground / mDefault depending on whether they are
background / foreground colors. That seemed a lot more work and
potentially a regression in various ways. I think this should be
strictly an improvement instead.

Differential Revision: https://phabricator.services.mozilla.com/D142423
2022-03-31 22:03:09 +00:00
Emilio Cobos Álvarez 2d8ab09b73 Bug 1739699 - Use preferred color scheme when forcing colors with system colors (except windows HCM). r=morgan
This causes (among other things) pages to be dark when using regular
windows system colors and forcing colors to "always", which is nice.

Differential Revision: https://phabricator.services.mozilla.com/D131165
2021-11-16 22:30:26 +00:00
Emilio Cobos Álvarez 1421e7f545 Bug 1525107 - Make Canvas/CanvasText and Link colors color-scheme-aware. r=dholbert
For that, add `.dark` version of the browser.display* prefs that control
the light version of these colors.

The default for background/foreground colors are taken from the
GenericDarkColors used in LookAndFeel.

The defaults for links are based on this discussion:

  https://github.com/whatwg/html/issues/5426#issuecomment-904021675

(So they effectively match Chrome).

Whether the dark colors should be exposed in about:preferences (like the
light colors are) is TBD.

With this patch, we pass all the tests in:

  /html/semantics/document-metadata/the-meta-element/color-scheme/

Use the colors to paint the default canvas background and the default
colors.

There are three "regressions", though they are really progressions: we
now render the reference as the test expects (before we rendered a light
canvas background even for the reference).

Apart of these iframe tests (which we should look into, I filed
https://bugzilla.mozilla.org/show_bug.cgi?id=1738380), there are three
remaining test failures.

Two of them are due to `color: initial` not changing based on the
color-scheme. Safari also fails these tests, and the thing they're
really testing is whether system colors are preserved at computed-value
time:

  https://github.com/w3c/csswg-drafts/issues/3847

Regarding that change, I'm not so sure the trade-offs there are worth
it, as that not only complicates interpolation (we wouldn't be able to
use system colors in color-mix among others, see
https://github.com/w3c/csswg-drafts/issues/5780) plus it changes
inheritance behavior in sorta unexpected ways, see:

  https://github.com/w3c/csswg-drafts/issues/6773

Which I just filed because apparently no browser implements this
correctly. So for now will punt on those (keep matching Safari).

There's an svg-as-image test:

  https://searchfox.org/mozilla-central/rev/f8576fec48d866c5f988baaf1fa8d2f8cce2a82f/testing/web-platform/tests/css/css-color-adjust/rendering/dark-color-scheme/svg-as-image.html

Which isn't using the feature at all and I'm not sure why is it supposed
to pass (why prefers-color-scheme: dark is supposed to match that SVG
image). This test fails in all browsers apparently:

  https://wpt.fyi/results/css/css-color-adjust/rendering/dark-color-scheme/svg-as-image.html?label=master&label=experimental&aligned

I sent https://github.com/web-platform-tests/wpt/pull/31407 to remove
it and hopefully get it reviewed by some Chromium folks.

Differential Revision: https://phabricator.services.mozilla.com/D129746
2021-10-29 19:58:25 +00:00
Emilio Cobos Álvarez e50c80851e Bug 1734115 - Add basic support for dark form controls to nsNativeBasicTheme. r=mstange
For that:

 * Tweak the standin system colors to match the non-native theme.

 * Use those system colors for button and field backgrounds.

 * Rename the "should use system colors" bit to "is high contrast",
   which is what it really is (specially now that we use system colors
   also in non-high-contrast).

Border colors and other colors like the <input type=range> and such
might need some extra tweaking perhaps, but this is a decent start and
looks good in https://crisal.io/tmp/form-controls.html afaict (dark mode
toggle needs the color-scheme pref enabled of course).

Differential Revision: https://phabricator.services.mozilla.com/D127533
2021-10-05 14:40:52 +00:00
Emilio Cobos Álvarez 4abd90b054 Bug 1728187 - Make the non-native theme not use standins for system colors if forcing colors. r=morgan
We allow using system colors when forcing colors so it makes sense to do this.

Differential Revision: https://phabricator.services.mozilla.com/D125271
2021-09-12 23:37:47 +00:00
Iulian Moraru ebdc13da8f Backed out 2 changesets (bug 1728187) for causing reftest failures on backplate-select-001.html. CLOSED TREE
Backed out changeset 3a8197599a5c (bug 1728187)
Backed out changeset d26328903485 (bug 1728187)
2021-09-11 04:08:21 +03:00
Emilio Cobos Álvarez 694fef2dcb Bug 1728187 - Make the non-native theme not use standins for system colors if forcing colors. r=morgan
We allow using system colors when forcing colors so it makes sense to do this.

Differential Revision: https://phabricator.services.mozilla.com/D125271
2021-09-10 23:10:52 +00:00
Emilio Cobos Álvarez 8d2808b5c9 Bug 1722487 - Improve preference change handling code to be faster. r=jfkthame
Remove the need to post a runnable to coalesce them (we still coalesce
theme changes because those do non-trivial work).

What can go on is that on cold load we load the font list async, and
that goes through this code via a faked font.internaluseonly.changed
pref change, which stores a reframe change hint in
mChangeHintForPrefChange.

If the page flushes after this code runs, but before the next refresh
driver tick, we will be just wasting work. So instead do the
RebuildAllStyleData call synchronously. It just schedules a flush and
posts a hint, so it doesn't do the work right there, but makes the next
flush do the work as needed, so it should be faster and also more
correct.

Also improve handling of preference sheet prefs and such to avoid more
wasted work when we go through this code, as the assumption their
handling was doing was that it gets called infrequently, but it's not
the case due to the font list updates.

Differential Revision: https://phabricator.services.mozilla.com/D123103
2021-08-20 13:03:40 +00:00
Emilio Cobos Álvarez 5512bfda91 Bug 1717873 - Print documents shouldn't use system colors when in hcm. r=morgan
Instead, use default colors.

Testing this properly requires writing test infrastructure for paged tests with
"print backgrounds" settings turned off, not sure if worth it.

Depends on D120679

Differential Revision: https://phabricator.services.mozilla.com/D120680
2021-07-24 21:10:44 +00:00
Emilio Cobos Álvarez 4fe6efa8c9 Bug 1717873 - Factor PreferenceSheet colors to its own struct. r=morgan
This will come handy in the next patch.

Depends on D120678

Differential Revision: https://phabricator.services.mozilla.com/D120679
2021-07-24 21:10:44 +00:00
Emilio Cobos Álvarez febd7c37d5 Bug 1717873 - Remove some things that don't change per document from PreferenceSheet. r=morgan
It's just needless indirection.

Depends on D120677

Differential Revision: https://phabricator.services.mozilla.com/D120678
2021-07-24 21:10:43 +00:00
Emilio Cobos Alvarez ab368a8926 Bug 1698284 - Make the non-native theme not use system colors if we're not overriding the pages' colors. r=morgan
This prevents contrast issues with high contrast themes when the page only
specifies some of the colors (which is an issue which we have historically
had on GTK with dark themes for a long time).

Feel free to push back on this if you prefer this, as on GTK we force a light
theme on content anyways, but this is a problem on windows for users that use a
high contrast theme but allow pages to override colors.

Differential Revision: https://phabricator.services.mozilla.com/D108324
2021-03-16 16:46:05 +00:00
Emilio Cobos Álvarez dbb16b3158 Bug 1596050 - Centralize logic to ignore document colors. r=jfkthame
This was a follow-up from the backplate stuff which I requested but didn't
happen.

Differential Revision: https://phabricator.services.mozilla.com/D53170

--HG--
extra : moz-landing-system : lando
2019-11-15 13:39:08 +00:00
Emilio Cobos Álvarez 759875a3fe Bug 1530193 - followup: Fix default type and value of browser.display.focus_ring_style.
It warns on debug builds.
2019-03-07 15:06:35 +01:00
Emilio Cobos Álvarez 2028cb1479 Bug 1530751 - Make the pres context optional in the style system. r=jwatt
Differential Revision: https://phabricator.services.mozilla.com/D21239

--HG--
extra : moz-landing-system : lando
2019-03-06 21:36:12 +00:00
Emilio Cobos Álvarez 8c9a745531 Bug 1530193 - Refactor preference stylesheet prefs to not require a pres context. r=jwatt
We really only have two sets of prefs, one for chrome-like documents
(stuff in chrome docshells + chrome-origin images), and one for the rest.

Differential Revision: https://phabricator.services.mozilla.com/D20946

--HG--
extra : moz-landing-system : lando
2019-03-06 21:34:30 +00:00