From dd020d602a055e3c02b4ccdb267d4e44200ee360 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Fri, 25 Mar 2022 14:58:59 +0000 Subject: [PATCH] Bug 1760342 - Remove :-moz-lwtheme-{brighttext,darktext}. r=dao,Gijs They are just convenience for :root[lwthemetextcolor="light"] (and dark, respectively), but they generally shouldn't be used for dark mode theming. In the past it was the only way to do it but now we have prefers-color-scheme. While at it, change lwthemetextcolor to be "lwtheme-brighttext" for consistency with similar code we have for popups etc, and move it to _setDarkModeAttributes. While at it, remove layout.css.moz-lwtheme.content.enabled (which is false always, we unshipped these from content successfully). Differential Revision: https://phabricator.services.mozilla.com/D141593 --- browser/themes/shared/browser-shared.css | 16 +++---- dom/base/Document.cpp | 42 ++++--------------- dom/base/Document.h | 17 ++------ dom/xul/ChromeObserver.cpp | 6 +-- layout/base/RestyleManager.cpp | 6 --- .../test_non_content_accessible_pseudos.html | 2 - layout/style/test/test_selectors.html | 4 +- modules/libpref/init/StaticPrefList.yaml | 7 ---- servo/components/style/element_state.rs | 4 -- .../style/gecko/non_ts_pseudo_class_list.rs | 2 - .../components/style/gecko/selector_parser.rs | 22 +++------- servo/components/style/gecko/wrapper.rs | 2 - .../browser_ext_themes_chromeparity.js | 8 ++-- .../browser_ext_themes_dynamic_updates.js | 4 +- .../browser/browser_ext_themes_lwtsupport.js | 5 +-- ...browser_ext_themes_multiple_backgrounds.js | 12 +++--- .../test/browser/browser_ext_themes_pbm.js | 6 +-- .../browser/browser_ext_themes_persistence.js | 8 ++-- toolkit/modules/LightweightThemeConsumer.jsm | 14 ++++--- toolkit/themes/shared/global-shared.css | 4 +- toolkit/themes/shared/notification.css | 17 +++++--- xpcom/ds/StaticAtoms.py | 1 - 22 files changed, 71 insertions(+), 138 deletions(-) diff --git a/browser/themes/shared/browser-shared.css b/browser/themes/shared/browser-shared.css index 3c5f4c2d2a0a..a9b7aa2a4498 100644 --- a/browser/themes/shared/browser-shared.css +++ b/browser/themes/shared/browser-shared.css @@ -119,21 +119,17 @@ --focus-outline-color: #0061E0; } - :root:-moz-lwtheme-brighttext { - --focus-outline-color: #00DDFF; + @media (prefers-color-scheme: dark) { + :root:-moz-lwtheme { + --focus-outline-color: #00DDFF; + } } } -/* Increase the contrast of urlbar boxes in brighttext LWT. +/* Increase the contrast of urlbar boxes in dark mode. In practice these are bumped-up --button(-hover)-bgcolor rules */ -:root:-moz-lwtheme-brighttext:not([lwt-default-theme-in-dark-mode]) { - --urlbar-box-bgcolor: color-mix(in srgb, currentColor 16%, transparent); - --urlbar-box-focus-bgcolor: color-mix(in srgb, currentColor 16%, transparent); - --urlbar-box-hover-bgcolor: color-mix(in srgb, currentColor 22%, transparent); -} -/* Linux dark OS */ @media (prefers-color-scheme: dark) { - :root:not(:-moz-lwtheme) { + :root { --urlbar-box-bgcolor: color-mix(in srgb, currentColor 16%, transparent); --urlbar-box-focus-bgcolor: color-mix(in srgb, currentColor 16%, transparent); --urlbar-box-hover-bgcolor: color-mix(in srgb, currentColor 22%, transparent); diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 2415b2d62640..1fa86ada4a5e 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -12384,23 +12384,11 @@ void Document::UpdateDocumentStates(EventStates aMaybeChangedStates, } } - if (aMaybeChangedStates.HasAtLeastOneOfStates( - NS_DOCUMENT_STATE_ALL_LWTHEME_BITS)) { - mDocumentState &= ~NS_DOCUMENT_STATE_ALL_LWTHEME_BITS; - switch (GetDocumentLWTheme()) { - case DocumentTheme::None: - break; - case DocumentTheme::Bright: - mDocumentState |= - NS_DOCUMENT_STATE_LWTHEME | NS_DOCUMENT_STATE_LWTHEME_BRIGHTTEXT; - break; - case DocumentTheme::Dark: - mDocumentState |= - NS_DOCUMENT_STATE_LWTHEME | NS_DOCUMENT_STATE_LWTHEME_DARKTEXT; - break; - case DocumentTheme::Neutral: - mDocumentState |= NS_DOCUMENT_STATE_LWTHEME; - break; + if (aMaybeChangedStates.HasAtLeastOneOfStates(NS_DOCUMENT_STATE_LWTHEME)) { + if (ComputeDocumentLWTheme()) { + mDocumentState |= NS_DOCUMENT_STATE_LWTHEME; + } else { + mDocumentState &= ~NS_DOCUMENT_STATE_LWTHEME; } } @@ -15847,26 +15835,14 @@ void Document::SetStateObject(nsIStructuredCloneContainer* scContainer) { mStateObjectCached.reset(); } -Document::DocumentTheme Document::GetDocumentLWTheme() const { +bool Document::ComputeDocumentLWTheme() const { if (!NodePrincipal()->IsSystemPrincipal()) { - return DocumentTheme::None; + return false; } - auto theme = DocumentTheme::None; // No lightweight theme by default Element* element = GetRootElement(); - if (element && element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::lwtheme, - nsGkAtoms::_true, eCaseMatters)) { - theme = DocumentTheme::Neutral; - nsAutoString lwTheme; - element->GetAttr(kNameSpaceID_None, nsGkAtoms::lwthemetextcolor, lwTheme); - if (lwTheme.EqualsLiteral("dark")) { - theme = DocumentTheme::Dark; - } else if (lwTheme.EqualsLiteral("bright")) { - theme = DocumentTheme::Bright; - } - } - - return theme; + return element && element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::lwtheme, + nsGkAtoms::_true, eCaseMatters); } already_AddRefed Document::CreateHTMLElement(nsAtom* aTag) { diff --git a/dom/base/Document.h b/dom/base/Document.h index 03c7d7f14bfb..f734db4f8eb6 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -358,14 +358,9 @@ enum class DeprecatedOperations : uint16_t { #define NS_DOCUMENT_STATE_LTR_LOCALE NS_DEFINE_EVENT_STATE_MACRO(2) // Lightweight-theme status. #define NS_DOCUMENT_STATE_LWTHEME NS_DEFINE_EVENT_STATE_MACRO(3) -#define NS_DOCUMENT_STATE_LWTHEME_BRIGHTTEXT NS_DEFINE_EVENT_STATE_MACRO(4) -#define NS_DOCUMENT_STATE_LWTHEME_DARKTEXT NS_DEFINE_EVENT_STATE_MACRO(5) #define NS_DOCUMENT_STATE_ALL_LOCALEDIR_BITS \ (NS_DOCUMENT_STATE_RTL_LOCALE | NS_DOCUMENT_STATE_LTR_LOCALE) -#define NS_DOCUMENT_STATE_ALL_LWTHEME_BITS \ - (NS_DOCUMENT_STATE_LWTHEME | NS_DOCUMENT_STATE_LWTHEME_BRIGHTTEXT | \ - NS_DOCUMENT_STATE_LWTHEME_DARKTEXT) class ExternalResourceMap { using SubDocEnumFunc = FunctionRef; @@ -3035,17 +3030,13 @@ class Document : public nsINode, SetStateObject(aDocument->mStateObjectContainer); } - enum class DocumentTheme { None, Neutral, Dark, Bright }; - /** - * Returns DocumentTheme::None if there is no lightweight theme specified, - * Dark for a dark theme, Bright for a light theme, and Neutral for any other - * theme. This is used to determine the state of the pseudoclasses - * :-moz-lwtheme and :-moz-lwtheme-*text. + * Returns true if there is a lightweight theme specified. This is used to + * determine the state of the :-moz-lwtheme pseudo-class. */ - DocumentTheme GetDocumentLWTheme() const; + bool ComputeDocumentLWTheme() const; void ResetDocumentLWTheme() { - UpdateDocumentStates(NS_DOCUMENT_STATE_ALL_LWTHEME_BITS, true); + UpdateDocumentStates(NS_DOCUMENT_STATE_LWTHEME, true); } // Whether we're a media document or not. diff --git a/dom/xul/ChromeObserver.cpp b/dom/xul/ChromeObserver.cpp index b0ded0486feb..34e49a2c7305 100644 --- a/dom/xul/ChromeObserver.cpp +++ b/dom/xul/ChromeObserver.cpp @@ -175,8 +175,7 @@ void ChromeObserver::AttributeChanged(dom::Element* aElement, // if the localedir changed on the root element, reset the document // direction mDocument->ResetDocumentDirection(); - } else if (aName == nsGkAtoms::lwtheme || - aName == nsGkAtoms::lwthemetextcolor) { + } else if (aName == nsGkAtoms::lwtheme) { // if the lwtheme changed, make sure to reset the document lwtheme // cache mDocument->ResetDocumentLWTheme(); @@ -190,8 +189,7 @@ void ChromeObserver::AttributeChanged(dom::Element* aElement, // if the localedir changed on the root element, reset the document // direction mDocument->ResetDocumentDirection(); - } else if ((aName == nsGkAtoms::lwtheme || - aName == nsGkAtoms::lwthemetextcolor)) { + } else if (aName == nsGkAtoms::lwtheme) { // if the lwtheme changed, make sure to restyle appropriately mDocument->ResetDocumentLWTheme(); } else if (aName == nsGkAtoms::drawintitlebar) { diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index a4c74d9d8efe..80b8ba9b9476 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -3366,8 +3366,6 @@ void RestyleManager::TakeSnapshotForAttributeChange(Element& aElement, // For some attribute changes we must restyle the whole subtree: // // * is affected by the cellpadding on its ancestor table -// * lwtheme and lwthemetextcolor on root element of XUL document -// affects all descendants due to :-moz-lwtheme* pseudo-classes // * lang="" and xml:lang="" can affect all descendants due to :lang() // * exportparts can affect all descendant parts. We could certainly integrate // it better in the invalidation machinery if it was necessary. @@ -3376,10 +3374,6 @@ static inline bool AttributeChangeRequiresSubtreeRestyle( if (aAttr == nsGkAtoms::cellpadding) { return aElement.IsHTMLElement(nsGkAtoms::table); } - if (aAttr == nsGkAtoms::lwtheme || aAttr == nsGkAtoms::lwthemetextcolor) { - Document* doc = aElement.OwnerDoc(); - return doc->IsInChromeDocShell() && &aElement == doc->GetRootElement(); - } // TODO(emilio, bug 1598094): Maybe finer-grained invalidation for exportparts // attribute changes? if (aAttr == nsGkAtoms::exportparts) { diff --git a/layout/style/test/test_non_content_accessible_pseudos.html b/layout/style/test/test_non_content_accessible_pseudos.html index 640fec7b0e08..2ccefc2f48ff 100644 --- a/layout/style/test/test_non_content_accessible_pseudos.html +++ b/layout/style/test/test_non_content_accessible_pseudos.html @@ -32,8 +32,6 @@ const NON_CONTENT_ACCESIBLE_PSEUDOS = [ ":-moz-dir-attr-like-auto", ":-moz-autofill-preview", ":-moz-lwtheme", - ":-moz-lwtheme-brighttext", - ":-moz-lwtheme-darkttext", ":-moz-locale-dir(rtl)", ":-moz-locale-dir(ltr)", diff --git a/layout/style/test/test_selectors.html b/layout/style/test/test_selectors.html index fa1218c8be0b..3c5b36c449a8 100644 --- a/layout/style/test/test_selectors.html +++ b/layout/style/test/test_selectors.html @@ -1076,10 +1076,8 @@ function runTests() { test_balanced_unparseable(":dir(ltr other)"); test_balanced_unparseable(":dir"); - // Test chrome-only -moz-lwtheme and -moz-lwtheme-[darktext|brighttext] + // Test chrome-only -moz-lwtheme test_balanced_unparseable(":-moz-lwtheme"); - test_balanced_unparseable(":-moz-lwtheme-brighttext"); - test_balanced_unparseable(":-moz-lwtheme-darktext"); test_balanced_unparseable(":-moz-tree-row(selected)"); test_balanced_unparseable("::-moz-tree-row(selected)"); diff --git a/modules/libpref/init/StaticPrefList.yaml b/modules/libpref/init/StaticPrefList.yaml index 06c7137b5e03..f5edc82fd98b 100644 --- a/modules/libpref/init/StaticPrefList.yaml +++ b/modules/libpref/init/StaticPrefList.yaml @@ -7325,13 +7325,6 @@ mirror: always rust: true -# Whether the `:-moz-lwtheme` pseudo-class is exposed to content. -- name: layout.css.moz-lwtheme.content.enabled - type: RelaxedAtomicBool - value: false - mirror: always - rust: true - # Whether the `:-moz-locale-dir()` pseudo-class is exposed to content. - name: layout.css.moz-locale-dir.content.enabled type: RelaxedAtomicBool diff --git a/servo/components/style/element_state.rs b/servo/components/style/element_state.rs index 30c65dc9feb7..28d505129a1a 100644 --- a/servo/components/style/element_state.rs +++ b/servo/components/style/element_state.rs @@ -148,9 +148,5 @@ bitflags! { const LTR_LOCALE = 1 << 2; /// LWTheme status const LWTHEME = 1 << 3; - /// LWTheme status - const LWTHEME_BRIGHTTEXT = 1 << 4; - /// LWTheme status - const LWTHEME_DARKTEXT = 1 << 5; } } diff --git a/servo/components/style/gecko/non_ts_pseudo_class_list.rs b/servo/components/style/gecko/non_ts_pseudo_class_list.rs index feb28feb0df1..7d6190ba47cf 100644 --- a/servo/components/style/gecko/non_ts_pseudo_class_list.rs +++ b/servo/components/style/gecko/non_ts_pseudo_class_list.rs @@ -92,8 +92,6 @@ macro_rules! apply_non_ts_list { ("-moz-is-html", MozIsHTML, _, _), ("-moz-placeholder", MozPlaceholder, _, _), ("-moz-lwtheme", MozLWTheme, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME), - ("-moz-lwtheme-brighttext", MozLWThemeBrightText, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME), - ("-moz-lwtheme-darktext", MozLWThemeDarkText, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME), ("-moz-window-inactive", MozWindowInactive, _, _), ] } diff --git a/servo/components/style/gecko/selector_parser.rs b/servo/components/style/gecko/selector_parser.rs index 8fc0900aece7..8a3224938b9a 100644 --- a/servo/components/style/gecko/selector_parser.rs +++ b/servo/components/style/gecko/selector_parser.rs @@ -139,12 +139,6 @@ impl NonTSPseudoClass { /// Returns whether the pseudo-class is enabled in content sheets. #[inline] fn is_enabled_in_content(&self) -> bool { - if matches!( - *self, - Self::MozLWTheme | Self::MozLWThemeBrightText | Self::MozLWThemeDarkText - ) { - return static_prefs::pref!("layout.css.moz-lwtheme.content.enabled"); - } if let NonTSPseudoClass::MozLocaleDir(..) = *self { return static_prefs::pref!("layout.css.moz-locale-dir.content.enabled"); } @@ -184,8 +178,6 @@ impl NonTSPseudoClass { }, NonTSPseudoClass::MozWindowInactive => DocumentState::WINDOW_INACTIVE, NonTSPseudoClass::MozLWTheme => DocumentState::LWTHEME, - NonTSPseudoClass::MozLWThemeBrightText => DocumentState::LWTHEME_BRIGHTTEXT, - NonTSPseudoClass::MozLWThemeDarkText => DocumentState::LWTHEME_DARKTEXT, _ => DocumentState::empty(), } } @@ -208,15 +200,13 @@ impl NonTSPseudoClass { NonTSPseudoClass::MozNativeAnonymous | // :-moz-placeholder is parsed but never matches. NonTSPseudoClass::MozPlaceholder | - // :-moz-locale-dir and :-moz-window-inactive depend only on - // the state of the document, which is invariant across all - // the elements involved in a given style cache. - NonTSPseudoClass::MozLocaleDir(_) | - NonTSPseudoClass::MozWindowInactive | - // Similar for the document themes. + // :-moz-lwtheme, :-moz-locale-dir and + // :-moz-window-inactive depend only on the state of the + // document, which is invariant across all the elements + // involved in a given style cache. NonTSPseudoClass::MozLWTheme | - NonTSPseudoClass::MozLWThemeBrightText | - NonTSPseudoClass::MozLWThemeDarkText + NonTSPseudoClass::MozLocaleDir(_) | + NonTSPseudoClass::MozWindowInactive ) } } diff --git a/servo/components/style/gecko/wrapper.rs b/servo/components/style/gecko/wrapper.rs index 20f9b3706b1a..9ac1f6d1f5e6 100644 --- a/servo/components/style/gecko/wrapper.rs +++ b/servo/components/style/gecko/wrapper.rs @@ -2198,8 +2198,6 @@ impl<'le> ::selectors::Element for GeckoElement<'le> { NonTSPseudoClass::MozIsHTML => self.is_html_element_in_html_document(), NonTSPseudoClass::MozLWTheme | - NonTSPseudoClass::MozLWThemeBrightText | - NonTSPseudoClass::MozLWThemeDarkText | NonTSPseudoClass::MozLocaleDir(..) | NonTSPseudoClass::MozWindowInactive => { let state_bit = pseudo_class.document_state_flag(); diff --git a/toolkit/components/extensions/test/browser/browser_ext_themes_chromeparity.js b/toolkit/components/extensions/test/browser/browser_ext_themes_chromeparity.js index 9863995979dd..e88c78fa93f5 100644 --- a/toolkit/components/extensions/test/browser/browser_ext_themes_chromeparity.js +++ b/toolkit/components/extensions/test/browser/browser_ext_themes_chromeparity.js @@ -31,9 +31,9 @@ add_task(async function test_support_theme_frame() { ); Assert.equal( - docEl.getAttribute("lwthemetextcolor"), - "dark", - "LWT text color attribute should be set" + docEl.getAttribute("lwtheme-brighttext"), + null, + "LWT text color attribute should not be set" ); let toolbox = document.querySelector("#navigator-toolbox"); @@ -77,7 +77,7 @@ add_task(async function test_support_theme_frame() { ); Assert.ok( - !docEl.hasAttribute("lwthemetextcolor"), + !docEl.hasAttribute("lwtheme-brighttext"), "LWT text color attribute should not be set" ); }); diff --git a/toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_updates.js b/toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_updates.js index 7f4454233b0f..c6af66b5e504 100644 --- a/toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_updates.js +++ b/toolkit/components/extensions/test/browser/browser_ext_themes_dynamic_updates.js @@ -29,8 +29,8 @@ function validateTheme(backgroundImage, accentColor, textColor, isLWT) { if (isLWT) { Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set"); Assert.equal( - docEl.getAttribute("lwthemetextcolor"), - "bright", + docEl.getAttribute("lwtheme-brighttext"), + "true", "LWT text color attribute should be set" ); } diff --git a/toolkit/components/extensions/test/browser/browser_ext_themes_lwtsupport.js b/toolkit/components/extensions/test/browser/browser_ext_themes_lwtsupport.js index cf6b8478c2a7..4293e5eb199e 100644 --- a/toolkit/components/extensions/test/browser/browser_ext_themes_lwtsupport.js +++ b/toolkit/components/extensions/test/browser/browser_ext_themes_lwtsupport.js @@ -37,9 +37,8 @@ add_task(async function test_deprecated_LWT_properties_ignored() { !docEl.hasAttribute("lwtheme-image"), "LWT image attribute should not be set on deprecated headerURL alias" ); - Assert.equal( - docEl.getAttribute("lwthemetextcolor"), - "dark", + Assert.ok( + !docEl.getAttribute("lwtheme-brighttext"), "LWT text color attribute should not be set on deprecated textcolor alias" ); diff --git a/toolkit/components/extensions/test/browser/browser_ext_themes_multiple_backgrounds.js b/toolkit/components/extensions/test/browser/browser_ext_themes_multiple_backgrounds.js index 7d837bfc0d4e..03ad0316c3e9 100644 --- a/toolkit/components/extensions/test/browser/browser_ext_themes_multiple_backgrounds.js +++ b/toolkit/components/extensions/test/browser/browser_ext_themes_multiple_backgrounds.js @@ -34,8 +34,8 @@ add_task(async function test_support_backgrounds_position() { Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set"); Assert.equal( - docEl.getAttribute("lwthemetextcolor"), - "bright", + docEl.getAttribute("lwtheme-brighttext"), + "true", "LWT text color attribute should be set" ); @@ -134,8 +134,8 @@ add_task(async function test_support_backgrounds_repeat() { Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set"); Assert.equal( - docEl.getAttribute("lwthemetextcolor"), - "bright", + docEl.getAttribute("lwtheme-brighttext"), + "true", "LWT text color attribute should be set" ); @@ -233,8 +233,8 @@ add_task(async function test_additional_images_check() { Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set"); Assert.equal( - docEl.getAttribute("lwthemetextcolor"), - "bright", + docEl.getAttribute("lwtheme-brighttext"), + "true", "LWT text color attribute should be set" ); diff --git a/toolkit/components/extensions/test/browser/browser_ext_themes_pbm.js b/toolkit/components/extensions/test/browser/browser_ext_themes_pbm.js index 894c8fff0f6f..93ff0a818219 100644 --- a/toolkit/components/extensions/test/browser/browser_ext_themes_pbm.js +++ b/toolkit/components/extensions/test/browser/browser_ext_themes_pbm.js @@ -51,14 +51,14 @@ async function testWindowColorScheme({ if (expectLWTAttributes) { ok(docEl.hasAttribute("lwtheme"), "Window should have LWT attribute."); is( - docEl.getAttribute("lwthemetextcolor"), - expectDark ? "bright" : "dark", + docEl.getAttribute("lwtheme-brighttext"), + expectDark ? "true" : null, "LWT text color attribute should be set." ); } else { ok(!docEl.hasAttribute("lwtheme"), "Window should not have LWT attribute."); ok( - !docEl.hasAttribute("lwthemetextcolor"), + !docEl.hasAttribute("lwtheme-brighttext"), "LWT text color attribute should not be set." ); } diff --git a/toolkit/components/extensions/test/browser/browser_ext_themes_persistence.js b/toolkit/components/extensions/test/browser/browser_ext_themes_persistence.js index 0069d76ef428..526c3a088378 100644 --- a/toolkit/components/extensions/test/browser/browser_ext_themes_persistence.js +++ b/toolkit/components/extensions/test/browser/browser_ext_themes_persistence.js @@ -31,8 +31,8 @@ add_task(async function test_multiple_windows() { Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set"); Assert.equal( - docEl.getAttribute("lwthemetextcolor"), - "bright", + docEl.getAttribute("lwtheme-brighttext"), + "true", "LWT text color attribute should be set" ); Assert.ok( @@ -50,8 +50,8 @@ add_task(async function test_multiple_windows() { Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set"); Assert.equal( - docEl.getAttribute("lwthemetextcolor"), - "bright", + docEl.getAttribute("lwtheme-brighttext"), + "true", "LWT text color attribute should be set" ); Assert.ok( diff --git a/toolkit/modules/LightweightThemeConsumer.jsm b/toolkit/modules/LightweightThemeConsumer.jsm index 7ec9c6297ad4..37eccb07f4f1 100644 --- a/toolkit/modules/LightweightThemeConsumer.jsm +++ b/toolkit/modules/LightweightThemeConsumer.jsm @@ -60,10 +60,6 @@ const toolkitVariableMap = [ } // Remove the alpha channel const { r, g, b } = rgbaChannels; - element.setAttribute( - "lwthemetextcolor", - _isColorDark(r, g, b) ? "dark" : "bright" - ); return `rgba(${r}, ${g}, ${b})`; }, }, @@ -323,7 +319,6 @@ LightweightThemeConsumer.prototype = { } else { _determineToolbarAndContentTheme(this._doc, null); root.removeAttribute("lwtheme"); - root.removeAttribute("lwthemetextcolor"); } if (theme.id == DEFAULT_THEME_ID && useDarkTheme) { root.setAttribute("lwt-default-theme-in-dark-mode", "true"); @@ -543,6 +538,15 @@ function _determineToolbarAndContentTheme( * The `_processedColors` object from the object created for our theme. */ function _setDarkModeAttributes(doc, root, colors) { + { + let textColor = _cssColorToRGBA(doc, colors.textcolor); + if (textColor && !_isColorDark(textColor.r, textColor.g, textColor.b)) { + root.setAttribute("lwtheme-brighttext", "true"); + } else { + root.removeAttribute("lwtheme-brighttext"); + } + } + if ( _determineIfColorPairIsDark( doc, diff --git a/toolkit/themes/shared/global-shared.css b/toolkit/themes/shared/global-shared.css index 29a345af3f6e..7a7b2ad7352a 100644 --- a/toolkit/themes/shared/global-shared.css +++ b/toolkit/themes/shared/global-shared.css @@ -61,11 +61,11 @@ /* Lightweight theme roots */ -:root[lwtheme-image]:-moz-lwtheme-darktext { +:root[lwtheme-image] { text-shadow: 0 -0.5px 1.5px white; } -:root[lwtheme-image]:-moz-lwtheme-brighttext { +:root[lwtheme-image][lwtheme-brighttext] { text-shadow: 1px 1px 1.5px black; } diff --git a/toolkit/themes/shared/notification.css b/toolkit/themes/shared/notification.css index 05bcc51a064e..a24468128a39 100644 --- a/toolkit/themes/shared/notification.css +++ b/toolkit/themes/shared/notification.css @@ -40,12 +40,17 @@ notification { --notification-primary-button-text: rgb(249, 249, 250); } -notification[type="info"]:-moz-lwtheme-brighttext { - --notification-background: #38383d; - --notification-text: rgb(249, 249, 250); - --notification-button-background: rgba(249,249,250,.1); - --notification-button-background-hover: rgba(249,249,250,.2); - --notification-button-background-active: rgba(249,249,250,.3); +@media (prefers-color-scheme: dark) { + notification[type="info"]:-moz-lwtheme { + --notification-background: #38383d; + --notification-text: rgb(249, 249, 250); + } + + notification[type="info"] { + --notification-button-background: rgba(249,249,250,.1); + --notification-button-background-hover: rgba(249,249,250,.2); + --notification-button-background-active: rgba(249,249,250,.3); + } } html|notification-message.animated, diff --git a/xpcom/ds/StaticAtoms.py b/xpcom/ds/StaticAtoms.py index b03bd9686053..e78a730eb2c8 100644 --- a/xpcom/ds/StaticAtoms.py +++ b/xpcom/ds/StaticAtoms.py @@ -622,7 +622,6 @@ STATIC_ATOMS = [ Atom("lowsrc", "lowsrc"), Atom("ltr", "ltr"), Atom("lwtheme", "lwtheme"), - Atom("lwthemetextcolor", "lwthemetextcolor"), Atom("main", "main"), Atom("map", "map"), Atom("manifest", "manifest"),