Commit 95d05625 authored by Rune Lillesveen's avatar Rune Lillesveen Committed by Commit Bot

[css-color-adjust] color-scheme 'auto' -> 'normal'.

Modified implementation and tests based on CSSWG resolution[1] and spec
change.

[1] https://github.com/w3c/csswg-drafts/issues/3849

Bug: 939811
Change-Id: Ia09af8926fa9cd0f00b36f4c20d6857a254bf009
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1640539Reviewed-by: default avatarAnders Hartvoll Ruud <andruud@chromium.org>
Commit-Queue: Rune Lillesveen <futhark@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665505}
parent f56044bc
...@@ -1924,7 +1924,7 @@ const CSSValue* ColorScheme::ParseSingleValue( ...@@ -1924,7 +1924,7 @@ const CSSValue* ColorScheme::ParseSingleValue(
CSSParserTokenRange& range, CSSParserTokenRange& range,
const CSSParserContext& context, const CSSParserContext& context,
const CSSParserLocalContext&) const { const CSSParserLocalContext&) const {
if (range.Peek().Id() == CSSValueID::kAuto) if (range.Peek().Id() == CSSValueID::kNormal)
return css_property_parser_helpers::ConsumeIdent(range); return css_property_parser_helpers::ConsumeIdent(range);
if (range.Peek().Id() == CSSValueID::kOnly) { if (range.Peek().Id() == CSSValueID::kOnly) {
// Handle 'only light' // Handle 'only light'
...@@ -1939,10 +1939,10 @@ const CSSValue* ColorScheme::ParseSingleValue( ...@@ -1939,10 +1939,10 @@ const CSSValue* ColorScheme::ParseSingleValue(
CSSValueList* values = CSSValueList::CreateSpaceSeparated(); CSSValueList* values = CSSValueList::CreateSpaceSeparated();
do { do {
CSSValueID id = range.Peek().Id(); CSSValueID id = range.Peek().Id();
// 'auto' is handled above, and 'none' is reserved for future use. 'revert' // 'normal' is handled above, and 'none' is reserved for future use.
// is not yet implemented as a keyword, but still skip it for compat and // 'revert' is not yet implemented as a keyword, but still skip it for
// interop. // compat and interop.
if (id == CSSValueID::kAuto || id == CSSValueID::kNone || if (id == CSSValueID::kNormal || id == CSSValueID::kNone ||
id == CSSValueID::kRevert || id == CSSValueID::kDefault) { id == CSSValueID::kRevert || id == CSSValueID::kDefault) {
return nullptr; return nullptr;
} }
...@@ -1975,7 +1975,7 @@ const CSSValue* ColorScheme::CSSValueFromComputedStyleInternal( ...@@ -1975,7 +1975,7 @@ const CSSValue* ColorScheme::CSSValueFromComputedStyleInternal(
Node*, Node*,
bool allow_visited_style) const { bool allow_visited_style) const {
if (style.ColorScheme().IsEmpty()) if (style.ColorScheme().IsEmpty())
return CSSIdentifierValue::Create(CSSValueID::kAuto); return CSSIdentifierValue::Create(CSSValueID::kNormal);
CSSValueList* list = CSSValueList::CreateSpaceSeparated(); CSSValueList* list = CSSValueList::CreateSpaceSeparated();
for (auto ident : style.ColorScheme()) { for (auto ident : style.ColorScheme()) {
list->Append(*MakeGarbageCollected<CSSCustomIdentValue>(ident)); list->Append(*MakeGarbageCollected<CSSCustomIdentValue>(ident));
...@@ -1984,7 +1984,7 @@ const CSSValue* ColorScheme::CSSValueFromComputedStyleInternal( ...@@ -1984,7 +1984,7 @@ const CSSValue* ColorScheme::CSSValueFromComputedStyleInternal(
} }
const CSSValue* ColorScheme::InitialValue() const { const CSSValue* ColorScheme::InitialValue() const {
return CSSIdentifierValue::Create(CSSValueID::kAuto); return CSSIdentifierValue::Create(CSSValueID::kNormal);
} }
void ColorScheme::ApplyInitial(StyleResolverState& state) const { void ColorScheme::ApplyInitial(StyleResolverState& state) const {
...@@ -2000,7 +2000,7 @@ void ColorScheme::ApplyInherit(StyleResolverState& state) const { ...@@ -2000,7 +2000,7 @@ void ColorScheme::ApplyInherit(StyleResolverState& state) const {
void ColorScheme::ApplyValue(StyleResolverState& state, void ColorScheme::ApplyValue(StyleResolverState& state,
const CSSValue& value) const { const CSSValue& value) const {
if (const auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) { if (const auto* identifier_value = DynamicTo<CSSIdentifierValue>(value)) {
DCHECK(identifier_value->GetValueID() == CSSValueID::kAuto); DCHECK(identifier_value->GetValueID() == CSSValueID::kNormal);
state.Style()->SetColorScheme(Vector<AtomicString>()); state.Style()->SetColorScheme(Vector<AtomicString>());
state.Style()->SetDarkColorScheme(false); state.Style()->SetDarkColorScheme(false);
} else if (const auto* scheme_list = DynamicTo<CSSValueList>(value)) { } else if (const auto* scheme_list = DynamicTo<CSSValueList>(value)) {
......
...@@ -164,7 +164,7 @@ TEST_F(HTMLMetaElementTest, ColorSchemeProcessing_RemoveContentAttribute) { ...@@ -164,7 +164,7 @@ TEST_F(HTMLMetaElementTest, ColorSchemeProcessing_RemoveContentAttribute) {
GetDocument().getElementById("meta")->removeAttribute( GetDocument().getElementById("meta")->removeAttribute(
html_names::kContentAttr); html_names::kContentAttr);
ExpectComputedColorScheme("auto"); ExpectComputedColorScheme("normal");
} }
TEST_F(HTMLMetaElementTest, ColorSchemeProcessing_RemoveNameAttribute) { TEST_F(HTMLMetaElementTest, ColorSchemeProcessing_RemoveNameAttribute) {
...@@ -176,17 +176,17 @@ TEST_F(HTMLMetaElementTest, ColorSchemeProcessing_RemoveNameAttribute) { ...@@ -176,17 +176,17 @@ TEST_F(HTMLMetaElementTest, ColorSchemeProcessing_RemoveNameAttribute) {
GetDocument().getElementById("meta")->removeAttribute(html_names::kNameAttr); GetDocument().getElementById("meta")->removeAttribute(html_names::kNameAttr);
ExpectComputedColorScheme("auto"); ExpectComputedColorScheme("normal");
} }
TEST_F(HTMLMetaElementTest, ColorSchemeParsing) { TEST_F(HTMLMetaElementTest, ColorSchemeParsing) {
GetDocument().head()->AppendChild(CreateColorSchemeMeta("")); GetDocument().head()->AppendChild(CreateColorSchemeMeta(""));
SetColorScheme(""); SetColorScheme("");
ExpectComputedColorScheme("auto"); ExpectComputedColorScheme("normal");
SetColorScheme("auto"); SetColorScheme("normal");
ExpectComputedColorScheme("auto"); ExpectComputedColorScheme("normal");
SetColorScheme("light"); SetColorScheme("light");
ExpectComputedColorScheme("light"); ExpectComputedColorScheme("light");
...@@ -201,19 +201,19 @@ TEST_F(HTMLMetaElementTest, ColorSchemeParsing) { ...@@ -201,19 +201,19 @@ TEST_F(HTMLMetaElementTest, ColorSchemeParsing) {
ExpectComputedColorScheme("BLUE light"); ExpectComputedColorScheme("BLUE light");
SetColorScheme("light,dark"); SetColorScheme("light,dark");
ExpectComputedColorScheme("auto"); ExpectComputedColorScheme("normal");
SetColorScheme("light,"); SetColorScheme("light,");
ExpectComputedColorScheme("auto"); ExpectComputedColorScheme("normal");
SetColorScheme(",light"); SetColorScheme(",light");
ExpectComputedColorScheme("auto"); ExpectComputedColorScheme("normal");
SetColorScheme(", light"); SetColorScheme(", light");
ExpectComputedColorScheme("auto"); ExpectComputedColorScheme("normal");
SetColorScheme("light, dark"); SetColorScheme("light, dark");
ExpectComputedColorScheme("auto"); ExpectComputedColorScheme("normal");
} }
TEST_F(HTMLMetaElementTest, ColorSchemeForcedDarkeningAndMQ) { TEST_F(HTMLMetaElementTest, ColorSchemeForcedDarkeningAndMQ) {
......
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL Property color-scheme has initial value auto assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme has initial value normal assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme inherits assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme inherits assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -9,5 +9,5 @@ ...@@ -9,5 +9,5 @@
<div id="target"></div> <div id="target"></div>
</div> </div>
<script> <script>
assert_inherited('color-scheme', 'auto', 'light dark'); assert_inherited('color-scheme', 'normal', 'light dark');
</script> </script>
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL Property color-scheme value '' computes to 'auto' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value '' computes to 'normal' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'auto' computes to 'auto' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'normal' computes to 'normal' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'light dark' computes to 'light dark' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'light dark' computes to 'light dark' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'dark light' computes to 'dark light' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'dark light' computes to 'dark light' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'light unknown' computes to 'light unknown' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'light unknown' computes to 'light unknown' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'only light' computes to 'only light' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'only light' computes to 'only light' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'light light' computes to 'light light' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'light light' computes to 'light light' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'light only' computes to 'light only' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'light only' computes to 'light only' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'initial' computes to 'auto' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'initial' computes to 'normal' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'inherit' computes to 'auto' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'inherit' computes to 'normal' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'unset' computes to 'auto' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'unset' computes to 'normal' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'revert' computes to 'auto' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'revert' computes to 'normal' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'default' computes to 'auto' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'default' computes to 'normal' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
FAIL Property color-scheme value 'none' computes to 'auto' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false FAIL Property color-scheme value 'none' computes to 'normal' assert_true: color-scheme doesn't seem to be supported in the computed style expected true got false
Harness: the test ran to completion. Harness: the test ran to completion.
...@@ -6,8 +6,8 @@ ...@@ -6,8 +6,8 @@
<script src="/css/support/computed-testcommon.js"></script> <script src="/css/support/computed-testcommon.js"></script>
<div id="target"></div> <div id="target"></div>
<script> <script>
test_computed_value("color-scheme", "", "auto"); test_computed_value("color-scheme", "", "normal");
test_computed_value("color-scheme", "auto"); test_computed_value("color-scheme", "normal");
test_computed_value("color-scheme", "light dark"); test_computed_value("color-scheme", "light dark");
test_computed_value("color-scheme", "dark light"); test_computed_value("color-scheme", "dark light");
test_computed_value("color-scheme", "light unknown"); test_computed_value("color-scheme", "light unknown");
...@@ -15,10 +15,10 @@ ...@@ -15,10 +15,10 @@
test_computed_value("color-scheme", "light light"); test_computed_value("color-scheme", "light light");
test_computed_value("color-scheme", "light only"); test_computed_value("color-scheme", "light only");
// reserved and css-wide keywords. // reserved and css-wide keywords.
test_computed_value("color-scheme", "initial", "auto"); test_computed_value("color-scheme", "initial", "normal");
test_computed_value("color-scheme", "inherit", "auto"); test_computed_value("color-scheme", "inherit", "normal");
test_computed_value("color-scheme", "unset", "auto"); test_computed_value("color-scheme", "unset", "normal");
test_computed_value("color-scheme", "revert", "auto"); test_computed_value("color-scheme", "revert", "normal");
test_computed_value("color-scheme", "default", "auto"); test_computed_value("color-scheme", "default", "normal");
test_computed_value("color-scheme", "none", "auto"); test_computed_value("color-scheme", "none", "normal");
</script> </script>
...@@ -8,13 +8,13 @@ ...@@ -8,13 +8,13 @@
test_invalid_value("color-scheme", "none"); test_invalid_value("color-scheme", "none");
test_invalid_value("color-scheme", "only"); test_invalid_value("color-scheme", "only");
test_invalid_value("color-scheme", "only only"); test_invalid_value("color-scheme", "only only");
test_invalid_value("color-scheme", "only auto"); test_invalid_value("color-scheme", "only normal");
test_invalid_value("color-scheme", "only light dark"); test_invalid_value("color-scheme", "only light dark");
test_invalid_value("color-scheme", "only light light"); test_invalid_value("color-scheme", "only light light");
test_invalid_value("color-scheme", "only light purple"); test_invalid_value("color-scheme", "only light purple");
test_invalid_value("color-scheme", "auto dark"); test_invalid_value("color-scheme", "normal dark");
test_invalid_value("color-scheme", "auto purple"); test_invalid_value("color-scheme", "normal purple");
test_invalid_value("color-scheme", "light auto"); test_invalid_value("color-scheme", "light normal");
test_invalid_value("color-scheme", "light none"); test_invalid_value("color-scheme", "light none");
test_invalid_value("color-scheme", "light, dark"); test_invalid_value("color-scheme", "light, dark");
test_invalid_value("color-scheme", "light inherit"); test_invalid_value("color-scheme", "light inherit");
......
This is a testharness.js-based test. This is a testharness.js-based test.
FAIL e.style['color-scheme'] = "auto" should set the property value assert_not_equals: property should be set got disallowed value "" FAIL e.style['color-scheme'] = "normal" should set the property value assert_not_equals: property should be set got disallowed value ""
FAIL e.style['color-scheme'] = "light" should set the property value assert_not_equals: property should be set got disallowed value "" FAIL e.style['color-scheme'] = "light" should set the property value assert_not_equals: property should be set got disallowed value ""
FAIL e.style['color-scheme'] = "dark" should set the property value assert_not_equals: property should be set got disallowed value "" FAIL e.style['color-scheme'] = "dark" should set the property value assert_not_equals: property should be set got disallowed value ""
FAIL e.style['color-scheme'] = "light dark" should set the property value assert_not_equals: property should be set got disallowed value "" FAIL e.style['color-scheme'] = "light dark" should set the property value assert_not_equals: property should be set got disallowed value ""
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<script src="/css/support/parsing-testcommon.js"></script> <script src="/css/support/parsing-testcommon.js"></script>
<script> <script>
test_valid_value("color-scheme", "auto"); test_valid_value("color-scheme", "normal");
test_valid_value("color-scheme", "light"); test_valid_value("color-scheme", "light");
test_valid_value("color-scheme", "dark"); test_valid_value("color-scheme", "dark");
test_valid_value("color-scheme", "light dark"); test_valid_value("color-scheme", "light dark");
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment