Skip to content

Commit

Permalink
Update inverted-colors UA styles to match spec
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=259416

Reviewed by Tim Nguyen.

Updated the style for the inverted-colors media query in html.css
the new styles are taken directly from the spec.

Spec: https://drafts.csswg.org/mediaqueries-5/#inverted

* LayoutTests/fast/media/mq-inverted-colors-ua-styles-expected.txt: Added.
* LayoutTests/fast/media/mq-inverted-colors-ua-styles-img-expected.html: Added.
* LayoutTests/fast/media/mq-inverted-colors-ua-styles-img.html: Added.
* LayoutTests/fast/media/mq-inverted-colors-ua-styles.html: Added.
* Source/WebCore/css/html.css:
(@media (inverted-colors) img:not(picture>img), picture, video):
(@media (inverted-colors) img, picture, video): Deleted.

Canonical link: https://commits.webkit.org/266234@main
  • Loading branch information
lukewarlow authored and Ahmad Saleem committed Jul 23, 2023
1 parent e31512b commit 87011db
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 2 deletions.
13 changes: 13 additions & 0 deletions LayoutTests/fast/media/mq-inverted-colors-ua-styles-expected.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
inverted-colors ua style test

On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".


PASS getComputedStyle(document.querySelector('img')).filter is 'invert(1)'
PASS getComputedStyle(document.querySelector('picture')).filter is 'invert(1)'
PASS getComputedStyle(document.querySelector('picture>img')).filter is 'none'
PASS getComputedStyle(document.querySelector('video')).filter is 'invert(1)'
PASS successfullyParsed is true

TEST COMPLETE

Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!DOCTYPE html>
<html>
<body>

<img src="resources/apple_logo_big.jpg">

<script>
if (window.internals) {
window.internals.settings.forcedColorsAreInvertedAccessibilityValue = "on";
}
</script>
</body>
</html>
14 changes: 14 additions & 0 deletions LayoutTests/fast/media/mq-inverted-colors-ua-styles-img.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html>
<body>

<picture>
<img src="resources/apple_logo_big.jpg">
</picture>
<script>
if (window.internals) {
window.internals.settings.forcedColorsAreInvertedAccessibilityValue = "on";
}
</script>
</body>
</html>
24 changes: 24 additions & 0 deletions LayoutTests/fast/media/mq-inverted-colors-ua-styles.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test.js"></script>

<img>
<picture>
<img>
</picture>
<video></video>

<script>
if (window.testRunner && window.internals) {
window.testRunner.dumpAsText();
window.internals.settings.forcedColorsAreInvertedAccessibilityValue = "on";
description("inverted-colors ua style test");
shouldEvaluateTo("getComputedStyle(document.querySelector('img')).filter", "'invert(1)'");
shouldEvaluateTo("getComputedStyle(document.querySelector('picture')).filter", "'invert(1)'");
shouldEvaluateTo("getComputedStyle(document.querySelector('picture>img')).filter", "'none'");
shouldEvaluateTo("getComputedStyle(document.querySelector('video')).filter", "'invert(1)'");
}
</script>
</body>
</html>
5 changes: 3 additions & 2 deletions Source/WebCore/css/html.css
Original file line number Diff line number Diff line change
Expand Up @@ -1426,9 +1426,10 @@ applet, embed, object, img {
}
}

/* Default support for "Smart Invert" where all content color except media is inverted. */
/* Default support for "Smart Invert" where all content color except media is inverted. */
/* https://drafts.csswg.org/mediaqueries-5/#inverted */
@media (inverted-colors) {
img, picture, video { filter: invert(100%); } /* Images and videos double-inverted. */
img:not(picture>img), picture, video { filter: invert(100%); } /* Images and videos double-inverted. */
}

/* https://drafts.csswg.org/css-text-decor-4/#text-decoration-skipping */
Expand Down

0 comments on commit 87011db

Please sign in to comment.