Title: [283082] trunk
Revision
283082
Author
[email protected]
Date
2021-09-25 12:30:00 -0700 (Sat, 25 Sep 2021)

Log Message

Test palette animations
https://bugs.webkit.org/show_bug.cgi?id=230677
<rdar://problem/83437391>

Reviewed by Simon Fraser.

LayoutTests/imported/w3c:

These are being upstreamed at https://github.com/web-platform-tests/wpt/pull/30955.

* web-platform-tests/css/css-fonts/animations/font-palette-animation-2-expected.html: Added.
* web-platform-tests/css/css-fonts/animations/font-palette-animation-2.html: Added.
* web-platform-tests/css/css-fonts/animations/font-palette-animation-3-expected-mismatch.html: Added.
* web-platform-tests/css/css-fonts/animations/font-palette-animation-3.html: Added.
* web-platform-tests/css/css-fonts/animations/font-palette-animation-expected.html: Added.
* web-platform-tests/css/css-fonts/animations/font-palette-animation.html: Added.

Source/WebCore:

Simply hook it up to CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap().

Tests: imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-2.html
       imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-3.html
       imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation.html

* animation/CSSPropertyAnimation.cpp:
(WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
* platform/graphics/FontPalette.h:
(WebCore::operator<<):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::setFontPalette):
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::fontPalette const):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (283081 => 283082)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-25 16:12:26 UTC (rev 283081)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-09-25 19:30:00 UTC (rev 283082)
@@ -1,3 +1,20 @@
+2021-09-25  Myles C. Maxfield  <[email protected]>
+
+        Test palette animations
+        https://bugs.webkit.org/show_bug.cgi?id=230677
+        <rdar://problem/83437391>
+
+        Reviewed by Simon Fraser.
+
+        These are being upstreamed at https://github.com/web-platform-tests/wpt/pull/30955.
+
+        * web-platform-tests/css/css-fonts/animations/font-palette-animation-2-expected.html: Added.
+        * web-platform-tests/css/css-fonts/animations/font-palette-animation-2.html: Added.
+        * web-platform-tests/css/css-fonts/animations/font-palette-animation-3-expected-mismatch.html: Added.
+        * web-platform-tests/css/css-fonts/animations/font-palette-animation-3.html: Added.
+        * web-platform-tests/css/css-fonts/animations/font-palette-animation-expected.html: Added.
+        * web-platform-tests/css/css-fonts/animations/font-palette-animation.html: Added.
+
 2021-09-23  Tim Nguyen  <[email protected]>
 
         Make inert nodes invisible to hit testing

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-2-expected.html (0 => 283082)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-2-expected.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-2-expected.html	2021-09-25 19:30:00 UTC (rev 283082)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Tests that animating font-palette is discrete</title>
+<link rel="help" href=""
+<link rel="author" title="Myles C. Maxfield" href=""
+<style>
+@font-face {
+    font-family: "Ahem-COLR";
+    src: url("../resources/Ahem-COLOR-palettes.ttf") format("truetype");
+}
+
+@font-palette-values Palette0 {
+    font-family: "Ahem-COLR";
+    base-palette: 0;
+}
+
+@font-palette-values Palette1 {
+    font-family: "Ahem-COLR";
+    base-palette: 1;
+}
+
+#target {
+    font-palette: Palette1;
+}
+</style>
+</head>
+<body>
+<div id="target" style="font: 48px 'Ahem-COLR';">A</div>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-2.html (0 => 283082)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-2.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-2.html	2021-09-25 19:30:00 UTC (rev 283082)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+<meta charset="utf-8">
+<title>Tests that animating font-palette is discrete</title>
+<link rel="help" href=""
+<link rel="author" title="Myles C. Maxfield" href=""
+<link rel="match" href=""
+<style>
+@font-face {
+    font-family: "Ahem-COLR";
+    src: url("../resources/Ahem-COLOR-palettes.ttf") format("truetype");
+}
+
+@font-palette-values Palette0 {
+    font-family: "Ahem-COLR";
+    base-palette: 0;
+}
+
+@font-palette-values Palette1 {
+    font-family: "Ahem-COLR";
+    base-palette: 1;
+}
+
+@keyframes TheAnimation {
+    from {
+        font-palette: Palette0;
+    }
+    to {
+        font-palette: Palette1;
+    }
+}
+
+#target {
+    animation: TheAnimation 10s -6s paused linear;
+}
+</style>
+</head>
+<body>
+<div id="target" style="font: 48px 'Ahem-COLR';">A</div>
+<script>
+[...document.fonts][0].load().then(function() {
+    requestAnimationFrame(function() {
+        document.documentElement.classList.remove("reftest-wait");
+    });
+});
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-3-expected-mismatch.html (0 => 283082)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-3-expected-mismatch.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-3-expected-mismatch.html	2021-09-25 19:30:00 UTC (rev 283082)
@@ -0,0 +1,48 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+<meta charset="utf-8">
+<title>Tests that animating font-palette is discrete</title>
+<link rel="help" href=""
+<link rel="author" title="Myles C. Maxfield" href=""
+<style>
+@font-face {
+    font-family: "Ahem-COLR";
+    src: url("../resources/Ahem-COLOR-palettes.ttf") format("truetype");
+}
+
+@font-palette-values Palette0 {
+    font-family: "Ahem-COLR";
+    base-palette: 0;
+}
+
+@font-palette-values Palette1 {
+    font-family: "Ahem-COLR";
+    base-palette: 1;
+}
+
+@keyframes TheAnimation {
+    from {
+        font-palette: Palette0;
+    }
+    to {
+        font-palette: Palette1;
+    }
+}
+
+#target {
+    animation: TheAnimation 10s -6s paused linear;
+}
+</style>
+</head>
+<body>
+<div id="target" style="font: 48px 'Ahem-COLR';">A</div>
+<script>
+[...document.fonts][0].load().then(function() {
+    requestAnimationFrame(function() {
+        document.documentElement.classList.remove("reftest-wait");
+    });
+});
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-3.html (0 => 283082)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-3.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-3.html	2021-09-25 19:30:00 UTC (rev 283082)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+<meta charset="utf-8">
+<title>Tests that animating font-palette is discrete</title>
+<link rel="help" href=""
+<link rel="author" title="Myles C. Maxfield" href=""
+<link rel="mismatch" href=""
+<style>
+@font-face {
+    font-family: "Ahem-COLR";
+    src: url("../resources/Ahem-COLOR-palettes.ttf") format("truetype");
+}
+
+@font-palette-values Palette0 {
+    font-family: "Ahem-COLR";
+    base-palette: 0;
+}
+
+@font-palette-values Palette1 {
+    font-family: "Ahem-COLR";
+    base-palette: 1;
+}
+
+@keyframes TheAnimation {
+    from {
+        font-palette: Palette0;
+    }
+    to {
+        font-palette: Palette1;
+    }
+}
+
+#target {
+    animation: TheAnimation 10s -3s paused linear;
+}
+</style>
+</head>
+<body>
+<div id="target" style="font: 48px 'Ahem-COLR';">A</div>
+<script>
+[...document.fonts][0].load().then(function() {
+    requestAnimationFrame(function() {
+        document.documentElement.classList.remove("reftest-wait");
+    });
+});
+</script>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-expected.html (0 => 283082)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-expected.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-expected.html	2021-09-25 19:30:00 UTC (rev 283082)
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+<html>
+<head>
+<meta charset="utf-8">
+<title>Tests that animating font-palette is discrete</title>
+<link rel="help" href=""
+<link rel="author" title="Myles C. Maxfield" href=""
+<style>
+@font-face {
+    font-family: "Ahem-COLR";
+    src: url("../resources/Ahem-COLOR-palettes.ttf") format("truetype");
+}
+
+@font-palette-values Palette0 {
+    font-family: "Ahem-COLR";
+    base-palette: 0;
+}
+
+@font-palette-values Palette1 {
+    font-family: "Ahem-COLR";
+    base-palette: 1;
+}
+
+#target {
+    font-palette: Palette0;
+}
+</style>
+</head>
+<body>
+<div id="target" style="font: 48px 'Ahem-COLR';">A</div>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation.html (0 => 283082)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation.html	2021-09-25 19:30:00 UTC (rev 283082)
@@ -0,0 +1,49 @@
+<!DOCTYPE html>
+<html class="reftest-wait">
+<head>
+<meta charset="utf-8">
+<title>Tests that animating font-palette is discrete</title>
+<link rel="help" href=""
+<link rel="author" title="Myles C. Maxfield" href=""
+<link rel="match" href=""
+<style>
+@font-face {
+    font-family: "Ahem-COLR";
+    src: url("../resources/Ahem-COLOR-palettes.ttf") format("truetype");
+}
+
+@font-palette-values Palette0 {
+    font-family: "Ahem-COLR";
+    base-palette: 0;
+}
+
+@font-palette-values Palette1 {
+    font-family: "Ahem-COLR";
+    base-palette: 1;
+}
+
+@keyframes TheAnimation {
+    from {
+        font-palette: Palette0;
+    }
+    to {
+        font-palette: Palette1;
+    }
+}
+
+#target {
+    animation: TheAnimation 10s -3s paused linear;
+}
+</style>
+</head>
+<body>
+<div id="target" style="font: 48px 'Ahem-COLR';">A</div>
+<script>
+[...document.fonts][0].load().then(function() {
+    requestAnimationFrame(function() {
+        document.documentElement.classList.remove("reftest-wait");
+    });
+});
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (283081 => 283082)


--- trunk/Source/WebCore/ChangeLog	2021-09-25 16:12:26 UTC (rev 283081)
+++ trunk/Source/WebCore/ChangeLog	2021-09-25 19:30:00 UTC (rev 283082)
@@ -1,3 +1,26 @@
+2021-09-25  Myles C. Maxfield  <[email protected]>
+
+        Test palette animations
+        https://bugs.webkit.org/show_bug.cgi?id=230677
+        <rdar://problem/83437391>
+
+        Reviewed by Simon Fraser.
+
+        Simply hook it up to CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap().
+
+        Tests: imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-2.html
+               imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation-3.html
+               imported/w3c/web-platform-tests/css/css-fonts/animations/font-palette-animation.html
+
+        * animation/CSSPropertyAnimation.cpp:
+        (WebCore::CSSPropertyAnimationWrapperMap::CSSPropertyAnimationWrapperMap):
+        * platform/graphics/FontPalette.h:
+        (WebCore::operator<<):
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::setFontPalette):
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::fontPalette const):
+
 2021-09-25  Alan Bujtas  <[email protected]>
 
         [LFC][IFC] Text measuring is first-line style dependent

Modified: trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp (283081 => 283082)


--- trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp	2021-09-25 16:12:26 UTC (rev 283081)
+++ trunk/Source/WebCore/animation/CSSPropertyAnimation.cpp	2021-09-25 19:30:00 UTC (rev 283082)
@@ -2538,6 +2538,7 @@
         new DiscretePropertyWrapper<BlendMode>(CSSPropertyMixBlendMode, &RenderStyle::blendMode, &RenderStyle::setBlendMode),
 #endif
         new PropertyWrapperAspectRatio,
+        new DiscretePropertyWrapper<FontPalette>(CSSPropertyFontPalette, &RenderStyle::fontPalette, &RenderStyle::setFontPalette),
     };
     const unsigned animatableLonghandPropertiesCount = WTF_ARRAY_LENGTH(animatableLonghandPropertyWrappers);
 

Modified: trunk/Source/WebCore/platform/graphics/FontPalette.h (283081 => 283082)


--- trunk/Source/WebCore/platform/graphics/FontPalette.h	2021-09-25 16:12:26 UTC (rev 283081)
+++ trunk/Source/WebCore/platform/graphics/FontPalette.h	2021-09-25 19:30:00 UTC (rev 283082)
@@ -28,6 +28,7 @@
 #include <wtf/Hasher.h>
 #include <wtf/Variant.h>
 #include <wtf/text/AtomString.h>
+#include <wtf/text/TextStream.h>
 
 namespace WebCore {
 
@@ -62,4 +63,26 @@
         add(hasher, request.identifier);
 }
 
+inline TextStream& operator<<(TextStream& ts, const FontPalette& fontPalette)
+{
+    switch (fontPalette.type) {
+    case FontPalette::Type::None:
+        ts << "none";
+        break;
+    case FontPalette::Type::Normal:
+        ts << "normal";
+        break;
+    case FontPalette::Type::Light:
+        ts << "light";
+        break;
+    case FontPalette::Type::Dark:
+        ts << "dark";
+        break;
+    case FontPalette::Type::Custom:
+        ts << "custom: " << fontPalette.identifier;
+        break;
+    }
+    return ts;
 }
+
+}

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (283081 => 283082)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2021-09-25 16:12:26 UTC (rev 283081)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2021-09-25 19:30:00 UTC (rev 283082)
@@ -1944,6 +1944,16 @@
     fontCascade().update(currentFontSelector);
 }
 
+void RenderStyle::setFontPalette(FontPalette value)
+{
+    FontSelector* currentFontSelector = fontCascade().fontSelector();
+    auto description = fontDescription();
+    description.setFontPalette(value);
+
+    setFontDescription(WTFMove(description));
+    fontCascade().update(currentFontSelector);
+}
+
 LayoutBoxExtent RenderStyle::shadowExtent(const ShadowData* shadow)
 {
     LayoutUnit top;

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (283081 => 283082)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2021-09-25 16:12:26 UTC (rev 283081)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2021-09-25 19:30:00 UTC (rev 283082)
@@ -366,6 +366,7 @@
     FontSelectionValue fontWeight() const { return fontDescription().weight(); }
     FontSelectionValue fontStretch() const { return fontDescription().stretch(); }
     std::optional<FontSelectionValue> fontItalic() const { return fontDescription().italic(); }
+    FontPalette fontPalette() const { return fontDescription().fontPalette(); }
 
     const Length& textIndent() const { return m_rareInheritedData->indent; }
     TextAlignMode textAlign() const { return static_cast<TextAlignMode>(m_inheritedFlags.textAlign); }
@@ -973,6 +974,7 @@
     void setFontWeight(FontSelectionValue);
     void setFontStretch(FontSelectionValue);
     void setFontItalic(std::optional<FontSelectionValue>);
+    void setFontPalette(FontPalette);
 
     void setColor(const Color&);
     void setTextIndent(Length&& length) { SET_VAR(m_rareInheritedData, indent, WTFMove(length)); }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to