-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
LibWeb: Store CSS color name in CSSRGB
When serializing an sRGB color value that originated from a named color, it should return the color name converted to ASCII lowercase. This requires storing the color name (if it has one). This change also requires explicitly removing the color names when computing style, because computed color values do not retain their name. It also requires removing a caching optimization in create_from_color(), because adding the name means that the cached value might be wrong. This fixes some WPT subtests, and also required updating some of our own tests.
- Loading branch information
Showing
16 changed files
with
133 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...bWeb/Text/expected/css/PropertyOwningCSSStyleDeclaration-serialized-custom-properties.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
test { --color: red; color: rgb(255, 0, 0); } | ||
test { --color: red; color: red; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
fooRule: [object CSSKeyframesRule] ~ @keyframes "foo" { 0% { color: rgb(0, 0, 0); } 100% { color: rgb(255, 255, 255); } } | ||
fooRule: [object CSSKeyframesRule] ~ @keyframes "foo" { 0% { color: black; } 100% { color: white; } } | ||
fooRule.cssRules: [object CSSRuleList] | ||
fooRule.cssRules[0]: [object CSSKeyframeRule] ~ 0% { color: rgb(0, 0, 0); } | ||
fooRule.cssRules[0]: [object CSSKeyframeRule] ~ 0% { color: black; } | ||
fooRule.cssRules[0].parentRule: [object CSSKeyframesRule] | ||
fooRule.cssRules[0].parentRule: [object CSSKeyframesRule] ~ @keyframes "foo" { 0% { color: rgb(0, 0, 0); } 100% { color: rgb(255, 255, 255); } } | ||
fooRule.cssRules[0].style.parentRule: [object CSSKeyframeRule] ~ 0% { color: rgb(0, 0, 0); } | ||
fooRule.cssRules[0].parentRule: [object CSSKeyframesRule] ~ @keyframes "foo" { 0% { color: black; } 100% { color: white; } } | ||
fooRule.cssRules[0].style.parentRule: [object CSSKeyframeRule] ~ 0% { color: black; } | ||
fooRule.cssRules[0].style.parentRule === fooRule.cssRules[0]: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
Tests/LibWeb/Text/expected/css/style-declaration-parent-rule.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
spanRule: [object CSSStyleRule] ~ span { color: rgb(128, 0, 128); } | ||
spanRule.style: [object CSSStyleDeclaration] ~ span { color: rgb(128, 0, 128); } | ||
spanRule.style.parentRule: [object CSSStyleRule] ~ span { color: rgb(128, 0, 128); } | ||
spanRule: [object CSSStyleRule] ~ span { color: purple; } | ||
spanRule.style: [object CSSStyleDeclaration] ~ span { color: purple; } | ||
spanRule.style.parentRule: [object CSSStyleRule] ~ span { color: purple; } | ||
spanRule.style.parentRule === spanRule: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
Tests/LibWeb/Text/expected/wpt-import/domparsing/style_attribute_html.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
Summary | ||
|
||
Harness status: OK | ||
|
||
Rerun | ||
|
||
Found 4 tests | ||
|
||
2 Pass | ||
2 Fail | ||
Details | ||
Result Test Name MessagePass Parsing of initial style attribute | ||
Fail Parsing of invalid style attribute | ||
Fail Parsing of style attribute | ||
Pass Update style.backgroundColor |
52 changes: 52 additions & 0 deletions
52
Tests/LibWeb/Text/input/wpt-import/domparsing/style_attribute_html.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<!doctype html> | ||
<meta charset=utf-8> | ||
<title>Style attribute in HTML</title> | ||
<script src=../resources/testharness.js></script> | ||
<script src=../resources/testharnessreport.js></script> | ||
<script> | ||
|
||
var div; | ||
setup(function() { | ||
var input = '<div style="color: red">Foo</div>'; | ||
var doc = (new DOMParser()).parseFromString(input, 'text/html'); | ||
div = doc.querySelector('div'); | ||
}); | ||
|
||
test(function() { | ||
var style = div.style; | ||
assert_equals(style.cssText, 'color: red;'); | ||
assert_equals(style.color, 'red'); | ||
assert_equals(div.getAttribute("style"), 'color: red', | ||
'Value of style attribute should match the string value that was set'); | ||
}, 'Parsing of initial style attribute'); | ||
|
||
test(function() { | ||
var style = div.style; | ||
div.setAttribute('style', 'color:: invalid'); | ||
assert_equals(style.cssText, ''); | ||
assert_equals(style.color, ''); | ||
assert_equals(div.getAttribute('style'), 'color:: invalid', | ||
'Value of style attribute should match the string value that was set'); | ||
}, 'Parsing of invalid style attribute'); | ||
|
||
test(function() { | ||
var style = div.style; | ||
div.setAttribute('style', 'color: green'); | ||
assert_equals(style.cssText, 'color: green;'); | ||
assert_equals(style.color, 'green'); | ||
assert_equals(div.getAttribute('style'), 'color: green', | ||
'Value of style attribute should match the string value that was set'); | ||
}, 'Parsing of style attribute'); | ||
|
||
test(function() { | ||
var style = div.style; | ||
style.backgroundColor = 'blue'; | ||
assert_equals(style.cssText, 'color: green; background-color: blue;', | ||
'Should not drop the existing style'); | ||
assert_equals(style.color, 'green', | ||
'Should not drop the existing style'); | ||
assert_equals(div.getAttribute('style'), 'color: green; background-color: blue;', | ||
'Should update style attribute'); | ||
}, 'Update style.backgroundColor'); | ||
|
||
</script> |