Skip to content
Permalink
Browse files
Rename initial value of color-scheme from auto to normal
https://bugs.webkit.org/show_bug.cgi?id=205799
<rdar://58388530>

Reviewed by Darin Adler and Timothy Hatcher.

* LayoutTests/css-dark-mode/color-scheme-css-parse.html:
* LayoutTests/css-dark-mode/color-scheme-css-expected.txt:
* LayoutTests/css-dark-mode/color-scheme-css.html:
* LayoutTests/css-dark-mode/older-syntax/supported-color-schemes-css-expected.txt:
* LayoutTests/css-dark-mode/older-syntax/supported-color-schemes-css.html:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/inheritance-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/meta/meta-color-scheme-attribute-changes-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/meta/meta-color-scheme-empty-content-value-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/meta/meta-color-scheme-first-valid-applies-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/meta/meta-color-scheme-insert-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/meta/meta-color-scheme-no-content-value-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/meta/meta-color-scheme-remove-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/meta/meta-color-scheme-remove-head-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/meta/meta-color-scheme-single-value-in-body-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/meta/meta-color-scheme-single-value-in-head-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/meta/meta-color-scheme-single-value-in-shadow-tree-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/parsing/color-scheme-computed-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/parsing/color-scheme-invalid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/css/css-color-adjust/parsing/color-scheme-valid-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-attribute-changes-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-empty-content-value-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-insert-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-no-content-value-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-remove-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-remove-head-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-body-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-head-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/semantics/document-metadata/the-meta-element/color-scheme/meta-color-scheme-single-value-in-shadow-tree-expected.txt:
* Source/WebCore/css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* Source/WebCore/css/CSSProperties.json:
* Source/WebCore/css/CSSValueKeywords.in:
* Source/WebCore/css/parser/CSSPropertyParser.cpp:
(WebCore::consumeColorScheme):
* Source/WebCore/rendering/style/StyleColorScheme.h:
(WebCore::StyleColorScheme::isNormal const):
(WebCore::StyleColorScheme::isAuto const): Deleted.

Canonical link: https://commits.webkit.org/253659@main
  • Loading branch information
nt1m committed Aug 22, 2022
1 parent 4176494 commit 1ec4bb7857c49cd2b87e74a7de28db34368e913d
Show file tree
Hide file tree
Showing 33 changed files with 82 additions and 81 deletions.
@@ -14,7 +14,7 @@ PASS Dark color scheme enabled 3
PASS Element colors are correct in dark color scheme with only dark supported color scheme
PASS Color schemes changed to light and a bogus value
PASS Element colors are correct in dark color scheme with only light supported color scheme 2
PASS Color schemes changed to auto value
PASS Color schemes changed to normal value
PASS Element colors are correct in dark color scheme with implicit light supported color scheme
PASS Color schemes changed to light and dark via <meta> element
PASS Element colors are correct in dark color scheme with light and dark supported color scheme via <meta> element
@@ -4,8 +4,8 @@
<script src="../resources/testharnessreport.js"></script>

<style>
#testAuto {
color-scheme: auto;
#testNormal {
color-scheme: normal;
}

#testOnly {
@@ -52,12 +52,12 @@
color-scheme: light baz only;
}

#testInvalidLightAuto {
color-scheme: light auto;
#testInvalidLightNormal {
color-scheme: light normal;
}

#testInvalidAutoDark {
color-scheme: auto dark;
#testInvalidNormalDark {
color-scheme: normal dark;
}

#testInvalidLightDarkLight {
@@ -77,7 +77,7 @@
}
</style>

<div id="testAuto"></div>
<div id="testNormal"></div>
<div id="testOnly"></div>
<div id="testLight"></div>
<div id="testDark"></div>
@@ -89,8 +89,8 @@
<div id="testLightUnknown"></div>
<div id="testUnknownDarkOnly"></div>

<div id="testInvalidLightAuto"></div>
<div id="testInvalidAutoDark"></div>
<div id="testInvalidLightNormal"></div>
<div id="testInvalidNormalDark"></div>
<div id="testInvalidLightDarkLight"></div>
<div id="testInvalidNumber"></div>
<div id="testInvalidString"></div>
@@ -102,7 +102,7 @@
}

test(function() {
test_prop("testAuto", "color-scheme", "auto");
test_prop("testNormal", "color-scheme", "normal");
test_prop("testOnly", "color-scheme", "light only");
test_prop("testLight", "color-scheme", "light");
test_prop("testDark", "color-scheme", "dark");
@@ -116,11 +116,11 @@
}, "Test valid values");

test(function() {
test_prop("testInvalidLightAuto", "color-scheme", "auto");
test_prop("testInvalidAutoDark", "color-scheme", "auto");
test_prop("testInvalidLightDarkLight", "color-scheme", "auto");
test_prop("testInvalidNumber", "color-scheme", "auto");
test_prop("testInvalidString", "color-scheme", "auto");
test_prop("testInvalidLightString", "color-scheme", "auto");
test_prop("testInvalidLightNormal", "color-scheme", "normal");
test_prop("testInvalidNormalDark", "color-scheme", "normal");
test_prop("testInvalidLightDarkLight", "color-scheme", "normal");
test_prop("testInvalidNumber", "color-scheme", "normal");
test_prop("testInvalidString", "color-scheme", "normal");
test_prop("testInvalidLightString", "color-scheme", "normal");
}, "Test invalid values");
</script>
@@ -100,9 +100,9 @@
}, "Element colors are correct in dark color scheme with only light supported color scheme 2");

test(function() {
document.body.style.setProperty("color-scheme", "auto");
test_prop(document.body, "color-scheme", "auto");
}, "Color schemes changed to auto value");
document.body.style.setProperty("color-scheme", "normal");
test_prop(document.body, "color-scheme", "normal");
}, "Color schemes changed to normal value");

test(function() {
// The semantic text color should be black still.
@@ -14,7 +14,7 @@ PASS Dark color scheme enabled 3
PASS Element colors are correct in dark color scheme with only dark supported color scheme
PASS Supported color schemes changed to light and a bogus value
PASS Element colors are correct in dark color scheme with only light supported color scheme 2
PASS Supported color schemes changed to auto value
PASS Supported color schemes changed to normal value
PASS Element colors are correct in dark color scheme with implicit light supported color scheme
PASS Supported color schemes changed to light and dark via <meta> element
PASS Element colors are correct in dark color scheme with light and dark supported color scheme via <meta> element
@@ -103,10 +103,10 @@
}, "Element colors are correct in dark color scheme with only light supported color scheme 2");

test(function() {
document.body.style.setProperty("supported-color-schemes", "auto");
test_prop(document.body, "supported-color-schemes", "auto");
test_prop(document.body, "color-scheme", "auto");
}, "Supported color schemes changed to auto value");
document.body.style.setProperty("supported-color-schemes", "normal");
test_prop(document.body, "supported-color-schemes", "normal");
test_prop(document.body, "color-scheme", "normal");
}, "Supported color schemes changed to normal value");

test(function() {
// The semantic text color should be black still.
@@ -1,5 +1,5 @@

FAIL Property color-scheme has initial value normal assert_equals: expected "normal" but got "auto"
PASS Property color-scheme has initial value normal
PASS Property color-scheme inherits
PASS Property color-adjust has initial value economy
PASS Property color-adjust inherits
@@ -1,9 +1,9 @@

FAIL Meta color-scheme initially 'dark'. assert_equals: expected "dark" but got "auto"
FAIL Removed name attribute from meta color-scheme. assert_equals: expected "normal" but got "auto"
FAIL Set meta name to color-scheme. assert_equals: expected "dark" but got "auto"
FAIL Set content attribute of meta color-scheme to empty string. assert_equals: expected "normal" but got "auto"
FAIL Set content attribute of meta color-scheme to an invalid value. assert_equals: expected "normal" but got "auto"
FAIL Set content attribute of meta color-scheme to 'light'. assert_equals: expected "light" but got "auto"
FAIL Removed the content attribute of meta color-scheme. assert_equals: expected "normal" but got "auto"
FAIL Meta color-scheme initially 'dark'. assert_equals: expected "dark" but got "normal"
PASS Removed name attribute from meta color-scheme.
FAIL Set meta name to color-scheme. assert_equals: expected "dark" but got "normal"
PASS Set content attribute of meta color-scheme to empty string.
PASS Set content attribute of meta color-scheme to an invalid value.
FAIL Set content attribute of meta color-scheme to 'light'. assert_equals: expected "light" but got "normal"
PASS Removed the content attribute of meta color-scheme.

@@ -1,3 +1,3 @@

FAIL Meta color-scheme with empty content attribute has no effect. assert_equals: expected "normal" but got "auto"
PASS Meta color-scheme with empty content attribute has no effect.

@@ -1,3 +1,3 @@

FAIL Tree order decides which meta color-scheme applies. assert_equals: expected "dark" but got "auto"
FAIL Tree order decides which meta color-scheme applies. assert_equals: expected "dark" but got "normal"

@@ -1,5 +1,5 @@

FAIL Initial color-scheme assert_equals: expected "normal" but got "auto"
FAIL Inserted meta color-scheme applies assert_equals: expected "light" but got "auto"
FAIL Inserted meta color-scheme before existing in head applies assert_equals: expected "dark" but got "auto"
PASS Initial color-scheme
FAIL Inserted meta color-scheme applies assert_equals: expected "light" but got "normal"
FAIL Inserted meta color-scheme before existing in head applies assert_equals: expected "dark" but got "normal"

@@ -1,3 +1,3 @@

FAIL Meta color-scheme without content attribute has no effect. assert_equals: expected "normal" but got "auto"
PASS Meta color-scheme without content attribute has no effect.

@@ -1,5 +1,5 @@

FAIL First meta applies. assert_equals: expected "dark" but got "auto"
FAIL Second meta applies after first one is removed. assert_equals: expected "light" but got "auto"
FAIL Initial color-scheme with both meta elements removed. assert_equals: expected "normal" but got "auto"
FAIL First meta applies. assert_equals: expected "dark" but got "normal"
FAIL Second meta applies after first one is removed. assert_equals: expected "light" but got "normal"
PASS Initial color-scheme with both meta elements removed.

@@ -1,4 +1,4 @@

FAIL Meta color-scheme applies. assert_equals: expected "dark" but got "auto"
FAIL Initial value after removing head including meta color-scheme. assert_equals: expected "normal" but got "auto"
FAIL Meta color-scheme applies. assert_equals: expected "dark" but got "normal"
PASS Initial value after removing head including meta color-scheme.

@@ -1,3 +1,3 @@

FAIL Meta color-scheme in body does not apply. assert_equals: expected "normal" but got "auto"
PASS Meta color-scheme in body does not apply.

@@ -1,3 +1,3 @@

FAIL Meta color-scheme in head applies. assert_equals: expected "dark" but got "auto"
FAIL Meta color-scheme in head applies. assert_equals: expected "dark" but got "normal"

@@ -1,3 +1,3 @@

FAIL Meta color-scheme in shadow tree does not apply. assert_equals: expected "normal" but got "auto"
PASS Meta color-scheme in shadow tree does not apply.

@@ -1,15 +1,15 @@

FAIL Property color-scheme value 'normal' assert_equals: expected "normal" but got "auto"
PASS Property color-scheme value 'normal'
PASS Property color-scheme value 'light dark'
FAIL Property color-scheme value 'dark light' assert_equals: expected "dark light" but got "light dark"
FAIL Property color-scheme value 'light unknown' assert_equals: expected "light unknown" but got "light"
PASS Property color-scheme value 'only light'
PASS Property color-scheme value 'only light dark'
FAIL Property color-scheme value 'light light' assert_true: 'light light' is a supported value for color-scheme. expected true got false
PASS Property color-scheme value 'light only'
FAIL Property color-scheme value 'none' assert_equals: expected "none" but got "auto"
FAIL Property color-scheme value 'initial' assert_equals: expected "normal" but got "auto"
FAIL Property color-scheme value 'inherit' assert_equals: expected "normal" but got "auto"
FAIL Property color-scheme value 'unset' assert_equals: expected "normal" but got "auto"
FAIL Property color-scheme value 'revert' assert_equals: expected "normal" but got "auto"
FAIL Property color-scheme value 'none' assert_equals: expected "none" but got "normal"
PASS Property color-scheme value 'initial'
PASS Property color-scheme value 'inherit'
PASS Property color-scheme value 'unset'
PASS Property color-scheme value 'revert'

@@ -1,8 +1,8 @@

FAIL e.style['color-scheme'] = "only normal" should not set the property value assert_equals: expected "" but got "only"
FAIL e.style['color-scheme'] = "normal dark" should not set the property value assert_equals: expected "" but got "dark"
PASS e.style['color-scheme'] = "only normal" should not set the property value
PASS e.style['color-scheme'] = "normal dark" should not set the property value
PASS e.style['color-scheme'] = "normal purple" should not set the property value
FAIL e.style['color-scheme'] = "light normal" should not set the property value assert_equals: expected "" but got "light"
PASS e.style['color-scheme'] = "light normal" should not set the property value
PASS e.style['color-scheme'] = "light, dark" should not set the property value
FAIL e.style['color-scheme'] = "light inherit" should not set the property value assert_equals: expected "" but got "light"
FAIL e.style['color-scheme'] = "light initial" should not set the property value assert_equals: expected "" but got "light"
@@ -1,5 +1,5 @@

FAIL e.style['color-scheme'] = "normal" should set the property value assert_not_equals: property should be set got disallowed value ""
PASS e.style['color-scheme'] = "normal" should set the property value
PASS e.style['color-scheme'] = "light" should set the property value
PASS e.style['color-scheme'] = "dark" should set the property value
PASS e.style['color-scheme'] = "light dark" should set the property value
@@ -1,10 +1,10 @@

FAIL Meta color-scheme initially 'dark'. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
PASS Meta color-scheme initially 'dark'.
FAIL Removed name attribute from meta color-scheme. assert_equals: expected "light" but got "dark"
FAIL Set meta name to color-scheme. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
FAIL Set content attribute of meta color-scheme to empty string. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
FAIL Set content attribute of meta color-scheme to an invalid value. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
FAIL Set content attribute of meta color-scheme to 'light'. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
FAIL Set content attribute of meta color-scheme to 'dark'. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
PASS Set meta name to color-scheme.
PASS Set content attribute of meta color-scheme to empty string.
PASS Set content attribute of meta color-scheme to an invalid value.
PASS Set content attribute of meta color-scheme to 'light'.
PASS Set content attribute of meta color-scheme to 'dark'.
FAIL Removed the content attribute of meta color-scheme. assert_equals: expected "light" but got "dark"

@@ -1,3 +1,3 @@

FAIL Meta color-scheme with empty content attribute has no effect. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
PASS Meta color-scheme with empty content attribute has no effect.

@@ -1,5 +1,5 @@

FAIL Initial color-scheme assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
FAIL Inserted meta color-scheme applies assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
FAIL Inserted meta color-scheme before existing in head applies assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
PASS Initial color-scheme
PASS Inserted meta color-scheme applies
PASS Inserted meta color-scheme before existing in head applies

@@ -1,3 +1,3 @@

FAIL Meta color-scheme without content attribute has no effect. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
PASS Meta color-scheme without content attribute has no effect.

@@ -1,5 +1,5 @@

FAIL First meta applies. assert_equals: expected "dark" but got "light"
FAIL Second meta applies after first one is removed. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
FAIL Initial color-scheme with both meta elements removed. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
PASS Second meta applies after first one is removed.
PASS Initial color-scheme with both meta elements removed.

@@ -1,4 +1,4 @@

FAIL Meta color-scheme applies. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
PASS Meta color-scheme applies.
FAIL Initial value after removing head including meta color-scheme. assert_equals: expected "light" but got "dark"

@@ -1,3 +1,3 @@

FAIL Meta color-scheme in body should apply. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
PASS Meta color-scheme in body should apply.

@@ -1,3 +1,3 @@

FAIL Meta color-scheme in head applies. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
PASS Meta color-scheme in head applies.

@@ -1,3 +1,3 @@

FAIL Meta color-scheme in shadow tree does not apply. assert_equals: Root element's color-scheme should be 'normal' expected "normal" but got "auto"
PASS Meta color-scheme in shadow tree does not apply.

@@ -4146,8 +4146,8 @@ RefPtr<CSSValue> ComputedStyleExtractor::valueForPropertyInStyle(const RenderSty
#if ENABLE(DARK_MODE_CSS)
case CSSPropertyColorScheme: {
auto colorScheme = style.colorScheme();
if (colorScheme.isAuto())
return cssValuePool.createIdentifierValue(CSSValueAuto);
if (colorScheme.isNormal())
return cssValuePool.createIdentifierValue(CSSValueNormal);

auto list = CSSValueList::createSpaceSeparated();
if (colorScheme.contains(ColorScheme::Light))
@@ -6631,7 +6631,7 @@
"color-scheme": {
"inherited": true,
"values": [
"auto",
"normal",
"light",
"dark",
"only"
@@ -1514,6 +1514,7 @@ dark

#if defined(ENABLE_DARK_MODE_CSS) && ENABLE_DARK_MODE_CSS
// color-scheme
// normal
only
// light
// dark
@@ -4229,7 +4229,7 @@ static RefPtr<CSSValue> consumeTextEmphasisPosition(CSSParserTokenRange& range)

static RefPtr<CSSValue> consumeColorScheme(CSSParserTokenRange& range)
{
if (isAuto(range.peek().id()))
if (range.peek().id() == CSSValueNormal)
return consumeIdent(range);

Vector<CSSValueID, 3> identifiers;
@@ -4241,8 +4241,8 @@ static RefPtr<CSSValue> consumeColorScheme(CSSParserTokenRange& range)
CSSValueID id = range.peek().id();

switch (id) {
case CSSValueAuto:
// Auto is only allowed as a single value, and was handled earlier.
case CSSValueNormal:
// `normal` is only allowed as a single value, and was handled earlier.
// Don't allow it in the list.
return nullptr;

@@ -48,7 +48,7 @@ class StyleColorScheme {

bool operator!=(const StyleColorScheme& other) const { return !(*this == other); }

bool isAuto() const { return m_colorScheme.isEmpty() && m_allowsTransformations; }
bool isNormal() const { return m_colorScheme.isEmpty() && m_allowsTransformations; }
bool isOnly() const { return m_colorScheme.isEmpty() && !m_allowsTransformations; }

OptionSet<ColorScheme> colorScheme() const { return m_colorScheme; }

0 comments on commit 1ec4bb7

Please sign in to comment.