зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
35916358ca
Коммит
dd020d602a
|
@ -119,21 +119,17 @@
|
||||||
--focus-outline-color: #0061E0;
|
--focus-outline-color: #0061E0;
|
||||||
}
|
}
|
||||||
|
|
||||||
:root:-moz-lwtheme-brighttext {
|
@media (prefers-color-scheme: dark) {
|
||||||
--focus-outline-color: #00DDFF;
|
: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 */
|
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) {
|
@media (prefers-color-scheme: dark) {
|
||||||
:root:not(:-moz-lwtheme) {
|
:root {
|
||||||
--urlbar-box-bgcolor: color-mix(in srgb, currentColor 16%, transparent);
|
--urlbar-box-bgcolor: color-mix(in srgb, currentColor 16%, transparent);
|
||||||
--urlbar-box-focus-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);
|
--urlbar-box-hover-bgcolor: color-mix(in srgb, currentColor 22%, transparent);
|
||||||
|
|
|
@ -12384,23 +12384,11 @@ void Document::UpdateDocumentStates(EventStates aMaybeChangedStates,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (aMaybeChangedStates.HasAtLeastOneOfStates(
|
if (aMaybeChangedStates.HasAtLeastOneOfStates(NS_DOCUMENT_STATE_LWTHEME)) {
|
||||||
NS_DOCUMENT_STATE_ALL_LWTHEME_BITS)) {
|
if (ComputeDocumentLWTheme()) {
|
||||||
mDocumentState &= ~NS_DOCUMENT_STATE_ALL_LWTHEME_BITS;
|
mDocumentState |= NS_DOCUMENT_STATE_LWTHEME;
|
||||||
switch (GetDocumentLWTheme()) {
|
} else {
|
||||||
case DocumentTheme::None:
|
mDocumentState &= ~NS_DOCUMENT_STATE_LWTHEME;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15847,26 +15835,14 @@ void Document::SetStateObject(nsIStructuredCloneContainer* scContainer) {
|
||||||
mStateObjectCached.reset();
|
mStateObjectCached.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
Document::DocumentTheme Document::GetDocumentLWTheme() const {
|
bool Document::ComputeDocumentLWTheme() const {
|
||||||
if (!NodePrincipal()->IsSystemPrincipal()) {
|
if (!NodePrincipal()->IsSystemPrincipal()) {
|
||||||
return DocumentTheme::None;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto theme = DocumentTheme::None; // No lightweight theme by default
|
|
||||||
Element* element = GetRootElement();
|
Element* element = GetRootElement();
|
||||||
if (element && element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::lwtheme,
|
return element && element->AttrValueIs(kNameSpaceID_None, nsGkAtoms::lwtheme,
|
||||||
nsGkAtoms::_true, eCaseMatters)) {
|
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
already_AddRefed<Element> Document::CreateHTMLElement(nsAtom* aTag) {
|
already_AddRefed<Element> Document::CreateHTMLElement(nsAtom* aTag) {
|
||||||
|
|
|
@ -358,14 +358,9 @@ enum class DeprecatedOperations : uint16_t {
|
||||||
#define NS_DOCUMENT_STATE_LTR_LOCALE NS_DEFINE_EVENT_STATE_MACRO(2)
|
#define NS_DOCUMENT_STATE_LTR_LOCALE NS_DEFINE_EVENT_STATE_MACRO(2)
|
||||||
// Lightweight-theme status.
|
// Lightweight-theme status.
|
||||||
#define NS_DOCUMENT_STATE_LWTHEME NS_DEFINE_EVENT_STATE_MACRO(3)
|
#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 \
|
#define NS_DOCUMENT_STATE_ALL_LOCALEDIR_BITS \
|
||||||
(NS_DOCUMENT_STATE_RTL_LOCALE | NS_DOCUMENT_STATE_LTR_LOCALE)
|
(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 {
|
class ExternalResourceMap {
|
||||||
using SubDocEnumFunc = FunctionRef<CallState(Document&)>;
|
using SubDocEnumFunc = FunctionRef<CallState(Document&)>;
|
||||||
|
@ -3035,17 +3030,13 @@ class Document : public nsINode,
|
||||||
SetStateObject(aDocument->mStateObjectContainer);
|
SetStateObject(aDocument->mStateObjectContainer);
|
||||||
}
|
}
|
||||||
|
|
||||||
enum class DocumentTheme { None, Neutral, Dark, Bright };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns DocumentTheme::None if there is no lightweight theme specified,
|
* Returns true if there is a lightweight theme specified. This is used to
|
||||||
* Dark for a dark theme, Bright for a light theme, and Neutral for any other
|
* determine the state of the :-moz-lwtheme pseudo-class.
|
||||||
* theme. This is used to determine the state of the pseudoclasses
|
|
||||||
* :-moz-lwtheme and :-moz-lwtheme-*text.
|
|
||||||
*/
|
*/
|
||||||
DocumentTheme GetDocumentLWTheme() const;
|
bool ComputeDocumentLWTheme() const;
|
||||||
void ResetDocumentLWTheme() {
|
void ResetDocumentLWTheme() {
|
||||||
UpdateDocumentStates(NS_DOCUMENT_STATE_ALL_LWTHEME_BITS, true);
|
UpdateDocumentStates(NS_DOCUMENT_STATE_LWTHEME, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Whether we're a media document or not.
|
// Whether we're a media document or not.
|
||||||
|
|
|
@ -175,8 +175,7 @@ void ChromeObserver::AttributeChanged(dom::Element* aElement,
|
||||||
// if the localedir changed on the root element, reset the document
|
// if the localedir changed on the root element, reset the document
|
||||||
// direction
|
// direction
|
||||||
mDocument->ResetDocumentDirection();
|
mDocument->ResetDocumentDirection();
|
||||||
} else if (aName == nsGkAtoms::lwtheme ||
|
} else if (aName == nsGkAtoms::lwtheme) {
|
||||||
aName == nsGkAtoms::lwthemetextcolor) {
|
|
||||||
// if the lwtheme changed, make sure to reset the document lwtheme
|
// if the lwtheme changed, make sure to reset the document lwtheme
|
||||||
// cache
|
// cache
|
||||||
mDocument->ResetDocumentLWTheme();
|
mDocument->ResetDocumentLWTheme();
|
||||||
|
@ -190,8 +189,7 @@ void ChromeObserver::AttributeChanged(dom::Element* aElement,
|
||||||
// if the localedir changed on the root element, reset the document
|
// if the localedir changed on the root element, reset the document
|
||||||
// direction
|
// direction
|
||||||
mDocument->ResetDocumentDirection();
|
mDocument->ResetDocumentDirection();
|
||||||
} else if ((aName == nsGkAtoms::lwtheme ||
|
} else if (aName == nsGkAtoms::lwtheme) {
|
||||||
aName == nsGkAtoms::lwthemetextcolor)) {
|
|
||||||
// if the lwtheme changed, make sure to restyle appropriately
|
// if the lwtheme changed, make sure to restyle appropriately
|
||||||
mDocument->ResetDocumentLWTheme();
|
mDocument->ResetDocumentLWTheme();
|
||||||
} else if (aName == nsGkAtoms::drawintitlebar) {
|
} else if (aName == nsGkAtoms::drawintitlebar) {
|
||||||
|
|
|
@ -3366,8 +3366,6 @@ void RestyleManager::TakeSnapshotForAttributeChange(Element& aElement,
|
||||||
// For some attribute changes we must restyle the whole subtree:
|
// For some attribute changes we must restyle the whole subtree:
|
||||||
//
|
//
|
||||||
// * <td> is affected by the cellpadding on its ancestor table
|
// * <td> 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()
|
// * lang="" and xml:lang="" can affect all descendants due to :lang()
|
||||||
// * exportparts can affect all descendant parts. We could certainly integrate
|
// * exportparts can affect all descendant parts. We could certainly integrate
|
||||||
// it better in the invalidation machinery if it was necessary.
|
// it better in the invalidation machinery if it was necessary.
|
||||||
|
@ -3376,10 +3374,6 @@ static inline bool AttributeChangeRequiresSubtreeRestyle(
|
||||||
if (aAttr == nsGkAtoms::cellpadding) {
|
if (aAttr == nsGkAtoms::cellpadding) {
|
||||||
return aElement.IsHTMLElement(nsGkAtoms::table);
|
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
|
// TODO(emilio, bug 1598094): Maybe finer-grained invalidation for exportparts
|
||||||
// attribute changes?
|
// attribute changes?
|
||||||
if (aAttr == nsGkAtoms::exportparts) {
|
if (aAttr == nsGkAtoms::exportparts) {
|
||||||
|
|
|
@ -32,8 +32,6 @@ const NON_CONTENT_ACCESIBLE_PSEUDOS = [
|
||||||
":-moz-dir-attr-like-auto",
|
":-moz-dir-attr-like-auto",
|
||||||
":-moz-autofill-preview",
|
":-moz-autofill-preview",
|
||||||
":-moz-lwtheme",
|
":-moz-lwtheme",
|
||||||
":-moz-lwtheme-brighttext",
|
|
||||||
":-moz-lwtheme-darkttext",
|
|
||||||
":-moz-locale-dir(rtl)",
|
":-moz-locale-dir(rtl)",
|
||||||
":-moz-locale-dir(ltr)",
|
":-moz-locale-dir(ltr)",
|
||||||
|
|
||||||
|
|
|
@ -1076,10 +1076,8 @@ function runTests() {
|
||||||
test_balanced_unparseable(":dir(ltr other)");
|
test_balanced_unparseable(":dir(ltr other)");
|
||||||
test_balanced_unparseable(":dir");
|
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");
|
||||||
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)");
|
||||||
test_balanced_unparseable("::-moz-tree-row(selected)");
|
test_balanced_unparseable("::-moz-tree-row(selected)");
|
||||||
|
|
|
@ -7325,13 +7325,6 @@
|
||||||
mirror: always
|
mirror: always
|
||||||
rust: true
|
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.
|
# Whether the `:-moz-locale-dir()` pseudo-class is exposed to content.
|
||||||
- name: layout.css.moz-locale-dir.content.enabled
|
- name: layout.css.moz-locale-dir.content.enabled
|
||||||
type: RelaxedAtomicBool
|
type: RelaxedAtomicBool
|
||||||
|
|
|
@ -148,9 +148,5 @@ bitflags! {
|
||||||
const LTR_LOCALE = 1 << 2;
|
const LTR_LOCALE = 1 << 2;
|
||||||
/// LWTheme status
|
/// LWTheme status
|
||||||
const LWTHEME = 1 << 3;
|
const LWTHEME = 1 << 3;
|
||||||
/// LWTheme status
|
|
||||||
const LWTHEME_BRIGHTTEXT = 1 << 4;
|
|
||||||
/// LWTheme status
|
|
||||||
const LWTHEME_DARKTEXT = 1 << 5;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,8 +92,6 @@ macro_rules! apply_non_ts_list {
|
||||||
("-moz-is-html", MozIsHTML, _, _),
|
("-moz-is-html", MozIsHTML, _, _),
|
||||||
("-moz-placeholder", MozPlaceholder, _, _),
|
("-moz-placeholder", MozPlaceholder, _, _),
|
||||||
("-moz-lwtheme", MozLWTheme, _, PSEUDO_CLASS_ENABLED_IN_UA_SHEETS_AND_CHROME),
|
("-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, _, _),
|
("-moz-window-inactive", MozWindowInactive, _, _),
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -139,12 +139,6 @@ impl NonTSPseudoClass {
|
||||||
/// Returns whether the pseudo-class is enabled in content sheets.
|
/// Returns whether the pseudo-class is enabled in content sheets.
|
||||||
#[inline]
|
#[inline]
|
||||||
fn is_enabled_in_content(&self) -> bool {
|
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 {
|
if let NonTSPseudoClass::MozLocaleDir(..) = *self {
|
||||||
return static_prefs::pref!("layout.css.moz-locale-dir.content.enabled");
|
return static_prefs::pref!("layout.css.moz-locale-dir.content.enabled");
|
||||||
}
|
}
|
||||||
|
@ -184,8 +178,6 @@ impl NonTSPseudoClass {
|
||||||
},
|
},
|
||||||
NonTSPseudoClass::MozWindowInactive => DocumentState::WINDOW_INACTIVE,
|
NonTSPseudoClass::MozWindowInactive => DocumentState::WINDOW_INACTIVE,
|
||||||
NonTSPseudoClass::MozLWTheme => DocumentState::LWTHEME,
|
NonTSPseudoClass::MozLWTheme => DocumentState::LWTHEME,
|
||||||
NonTSPseudoClass::MozLWThemeBrightText => DocumentState::LWTHEME_BRIGHTTEXT,
|
|
||||||
NonTSPseudoClass::MozLWThemeDarkText => DocumentState::LWTHEME_DARKTEXT,
|
|
||||||
_ => DocumentState::empty(),
|
_ => DocumentState::empty(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,15 +200,13 @@ impl NonTSPseudoClass {
|
||||||
NonTSPseudoClass::MozNativeAnonymous |
|
NonTSPseudoClass::MozNativeAnonymous |
|
||||||
// :-moz-placeholder is parsed but never matches.
|
// :-moz-placeholder is parsed but never matches.
|
||||||
NonTSPseudoClass::MozPlaceholder |
|
NonTSPseudoClass::MozPlaceholder |
|
||||||
// :-moz-locale-dir and :-moz-window-inactive depend only on
|
// :-moz-lwtheme, :-moz-locale-dir and
|
||||||
// the state of the document, which is invariant across all
|
// :-moz-window-inactive depend only on the state of the
|
||||||
// the elements involved in a given style cache.
|
// document, which is invariant across all the elements
|
||||||
NonTSPseudoClass::MozLocaleDir(_) |
|
// involved in a given style cache.
|
||||||
NonTSPseudoClass::MozWindowInactive |
|
|
||||||
// Similar for the document themes.
|
|
||||||
NonTSPseudoClass::MozLWTheme |
|
NonTSPseudoClass::MozLWTheme |
|
||||||
NonTSPseudoClass::MozLWThemeBrightText |
|
NonTSPseudoClass::MozLocaleDir(_) |
|
||||||
NonTSPseudoClass::MozLWThemeDarkText
|
NonTSPseudoClass::MozWindowInactive
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2198,8 +2198,6 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
|
||||||
NonTSPseudoClass::MozIsHTML => self.is_html_element_in_html_document(),
|
NonTSPseudoClass::MozIsHTML => self.is_html_element_in_html_document(),
|
||||||
|
|
||||||
NonTSPseudoClass::MozLWTheme |
|
NonTSPseudoClass::MozLWTheme |
|
||||||
NonTSPseudoClass::MozLWThemeBrightText |
|
|
||||||
NonTSPseudoClass::MozLWThemeDarkText |
|
|
||||||
NonTSPseudoClass::MozLocaleDir(..) |
|
NonTSPseudoClass::MozLocaleDir(..) |
|
||||||
NonTSPseudoClass::MozWindowInactive => {
|
NonTSPseudoClass::MozWindowInactive => {
|
||||||
let state_bit = pseudo_class.document_state_flag();
|
let state_bit = pseudo_class.document_state_flag();
|
||||||
|
|
|
@ -31,9 +31,9 @@ add_task(async function test_support_theme_frame() {
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
docEl.getAttribute("lwthemetextcolor"),
|
docEl.getAttribute("lwtheme-brighttext"),
|
||||||
"dark",
|
null,
|
||||||
"LWT text color attribute should be set"
|
"LWT text color attribute should not be set"
|
||||||
);
|
);
|
||||||
|
|
||||||
let toolbox = document.querySelector("#navigator-toolbox");
|
let toolbox = document.querySelector("#navigator-toolbox");
|
||||||
|
@ -77,7 +77,7 @@ add_task(async function test_support_theme_frame() {
|
||||||
);
|
);
|
||||||
|
|
||||||
Assert.ok(
|
Assert.ok(
|
||||||
!docEl.hasAttribute("lwthemetextcolor"),
|
!docEl.hasAttribute("lwtheme-brighttext"),
|
||||||
"LWT text color attribute should not be set"
|
"LWT text color attribute should not be set"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
|
@ -29,8 +29,8 @@ function validateTheme(backgroundImage, accentColor, textColor, isLWT) {
|
||||||
if (isLWT) {
|
if (isLWT) {
|
||||||
Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
docEl.getAttribute("lwthemetextcolor"),
|
docEl.getAttribute("lwtheme-brighttext"),
|
||||||
"bright",
|
"true",
|
||||||
"LWT text color attribute should be set"
|
"LWT text color attribute should be set"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,9 +37,8 @@ add_task(async function test_deprecated_LWT_properties_ignored() {
|
||||||
!docEl.hasAttribute("lwtheme-image"),
|
!docEl.hasAttribute("lwtheme-image"),
|
||||||
"LWT image attribute should not be set on deprecated headerURL alias"
|
"LWT image attribute should not be set on deprecated headerURL alias"
|
||||||
);
|
);
|
||||||
Assert.equal(
|
Assert.ok(
|
||||||
docEl.getAttribute("lwthemetextcolor"),
|
!docEl.getAttribute("lwtheme-brighttext"),
|
||||||
"dark",
|
|
||||||
"LWT text color attribute should not be set on deprecated textcolor alias"
|
"LWT text color attribute should not be set on deprecated textcolor alias"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -34,8 +34,8 @@ add_task(async function test_support_backgrounds_position() {
|
||||||
|
|
||||||
Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
docEl.getAttribute("lwthemetextcolor"),
|
docEl.getAttribute("lwtheme-brighttext"),
|
||||||
"bright",
|
"true",
|
||||||
"LWT text color attribute should be set"
|
"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.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
docEl.getAttribute("lwthemetextcolor"),
|
docEl.getAttribute("lwtheme-brighttext"),
|
||||||
"bright",
|
"true",
|
||||||
"LWT text color attribute should be set"
|
"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.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
docEl.getAttribute("lwthemetextcolor"),
|
docEl.getAttribute("lwtheme-brighttext"),
|
||||||
"bright",
|
"true",
|
||||||
"LWT text color attribute should be set"
|
"LWT text color attribute should be set"
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -51,14 +51,14 @@ async function testWindowColorScheme({
|
||||||
if (expectLWTAttributes) {
|
if (expectLWTAttributes) {
|
||||||
ok(docEl.hasAttribute("lwtheme"), "Window should have LWT attribute.");
|
ok(docEl.hasAttribute("lwtheme"), "Window should have LWT attribute.");
|
||||||
is(
|
is(
|
||||||
docEl.getAttribute("lwthemetextcolor"),
|
docEl.getAttribute("lwtheme-brighttext"),
|
||||||
expectDark ? "bright" : "dark",
|
expectDark ? "true" : null,
|
||||||
"LWT text color attribute should be set."
|
"LWT text color attribute should be set."
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
ok(!docEl.hasAttribute("lwtheme"), "Window should not have LWT attribute.");
|
ok(!docEl.hasAttribute("lwtheme"), "Window should not have LWT attribute.");
|
||||||
ok(
|
ok(
|
||||||
!docEl.hasAttribute("lwthemetextcolor"),
|
!docEl.hasAttribute("lwtheme-brighttext"),
|
||||||
"LWT text color attribute should not be set."
|
"LWT text color attribute should not be set."
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,8 +31,8 @@ add_task(async function test_multiple_windows() {
|
||||||
|
|
||||||
Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
docEl.getAttribute("lwthemetextcolor"),
|
docEl.getAttribute("lwtheme-brighttext"),
|
||||||
"bright",
|
"true",
|
||||||
"LWT text color attribute should be set"
|
"LWT text color attribute should be set"
|
||||||
);
|
);
|
||||||
Assert.ok(
|
Assert.ok(
|
||||||
|
@ -50,8 +50,8 @@ add_task(async function test_multiple_windows() {
|
||||||
|
|
||||||
Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
Assert.ok(docEl.hasAttribute("lwtheme"), "LWT attribute should be set");
|
||||||
Assert.equal(
|
Assert.equal(
|
||||||
docEl.getAttribute("lwthemetextcolor"),
|
docEl.getAttribute("lwtheme-brighttext"),
|
||||||
"bright",
|
"true",
|
||||||
"LWT text color attribute should be set"
|
"LWT text color attribute should be set"
|
||||||
);
|
);
|
||||||
Assert.ok(
|
Assert.ok(
|
||||||
|
|
|
@ -60,10 +60,6 @@ const toolkitVariableMap = [
|
||||||
}
|
}
|
||||||
// Remove the alpha channel
|
// Remove the alpha channel
|
||||||
const { r, g, b } = rgbaChannels;
|
const { r, g, b } = rgbaChannels;
|
||||||
element.setAttribute(
|
|
||||||
"lwthemetextcolor",
|
|
||||||
_isColorDark(r, g, b) ? "dark" : "bright"
|
|
||||||
);
|
|
||||||
return `rgba(${r}, ${g}, ${b})`;
|
return `rgba(${r}, ${g}, ${b})`;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -323,7 +319,6 @@ LightweightThemeConsumer.prototype = {
|
||||||
} else {
|
} else {
|
||||||
_determineToolbarAndContentTheme(this._doc, null);
|
_determineToolbarAndContentTheme(this._doc, null);
|
||||||
root.removeAttribute("lwtheme");
|
root.removeAttribute("lwtheme");
|
||||||
root.removeAttribute("lwthemetextcolor");
|
|
||||||
}
|
}
|
||||||
if (theme.id == DEFAULT_THEME_ID && useDarkTheme) {
|
if (theme.id == DEFAULT_THEME_ID && useDarkTheme) {
|
||||||
root.setAttribute("lwt-default-theme-in-dark-mode", "true");
|
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.
|
* The `_processedColors` object from the object created for our theme.
|
||||||
*/
|
*/
|
||||||
function _setDarkModeAttributes(doc, root, colors) {
|
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 (
|
if (
|
||||||
_determineIfColorPairIsDark(
|
_determineIfColorPairIsDark(
|
||||||
doc,
|
doc,
|
||||||
|
|
|
@ -61,11 +61,11 @@
|
||||||
|
|
||||||
/* Lightweight theme roots */
|
/* Lightweight theme roots */
|
||||||
|
|
||||||
:root[lwtheme-image]:-moz-lwtheme-darktext {
|
:root[lwtheme-image] {
|
||||||
text-shadow: 0 -0.5px 1.5px white;
|
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;
|
text-shadow: 1px 1px 1.5px black;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -40,12 +40,17 @@ notification {
|
||||||
--notification-primary-button-text: rgb(249, 249, 250);
|
--notification-primary-button-text: rgb(249, 249, 250);
|
||||||
}
|
}
|
||||||
|
|
||||||
notification[type="info"]:-moz-lwtheme-brighttext {
|
@media (prefers-color-scheme: dark) {
|
||||||
--notification-background: #38383d;
|
notification[type="info"]:-moz-lwtheme {
|
||||||
--notification-text: rgb(249, 249, 250);
|
--notification-background: #38383d;
|
||||||
--notification-button-background: rgba(249,249,250,.1);
|
--notification-text: rgb(249, 249, 250);
|
||||||
--notification-button-background-hover: rgba(249,249,250,.2);
|
}
|
||||||
--notification-button-background-active: rgba(249,249,250,.3);
|
|
||||||
|
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,
|
html|notification-message.animated,
|
||||||
|
|
|
@ -622,7 +622,6 @@ STATIC_ATOMS = [
|
||||||
Atom("lowsrc", "lowsrc"),
|
Atom("lowsrc", "lowsrc"),
|
||||||
Atom("ltr", "ltr"),
|
Atom("ltr", "ltr"),
|
||||||
Atom("lwtheme", "lwtheme"),
|
Atom("lwtheme", "lwtheme"),
|
||||||
Atom("lwthemetextcolor", "lwthemetextcolor"),
|
|
||||||
Atom("main", "main"),
|
Atom("main", "main"),
|
||||||
Atom("map", "map"),
|
Atom("map", "map"),
|
||||||
Atom("manifest", "manifest"),
|
Atom("manifest", "manifest"),
|
||||||
|
|
Загрузка…
Ссылка в новой задаче