Title: [288882] trunk
Revision
288882
Author
[email protected]
Date
2022-02-01 08:53:24 -0800 (Tue, 01 Feb 2022)

Log Message

Redefining @keyframes does not work
https://bugs.webkit.org/show_bug.cgi?id=229437
<rdar://problem/82563372>

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Add a new test that reproduces the test content submitted with the bug report where
a <style> element containing a @keyframes rule with a given name is replaced with
another <style> element containing another @keyframes rule with the same name
but different keyframes. The test checks that the animation correctly uses the new
keyframes when querying the computed style.

We also get a fair few new PASS results on a ::marker animation test since that test
sets the `textContent` for a shared `<style>` element with generated @keyframes rules.

* web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name-expected.txt: Added.
* web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name.html: Added.
* web-platform-tests/css/css-pseudo/parsing/marker-supported-properties-in-animation-expected.txt:

Source/WebCore:

Notify the document upon insertion of a new @keyframes rule such that any running CSS Animation
using that rule name may update its computed keyframes.

Test: imported/w3c/web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name.html

* style/StyleResolver.cpp:
(WebCore::Style::Resolver::addKeyframeStyle):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (288881 => 288882)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-02-01 16:51:44 UTC (rev 288881)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-02-01 16:53:24 UTC (rev 288882)
@@ -1,3 +1,24 @@
+2022-02-01  Antoine Quint  <[email protected]>
+
+        Redefining @keyframes does not work
+        https://bugs.webkit.org/show_bug.cgi?id=229437
+        <rdar://problem/82563372>
+
+        Reviewed by Antti Koivisto.
+
+        Add a new test that reproduces the test content submitted with the bug report where
+        a <style> element containing a @keyframes rule with a given name is replaced with
+        another <style> element containing another @keyframes rule with the same name
+        but different keyframes. The test checks that the animation correctly uses the new
+        keyframes when querying the computed style.
+
+        We also get a fair few new PASS results on a ::marker animation test since that test
+        sets the `textContent` for a shared `<style>` element with generated @keyframes rules.
+
+        * web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name-expected.txt: Added.
+        * web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name.html: Added.
+        * web-platform-tests/css/css-pseudo/parsing/marker-supported-properties-in-animation-expected.txt:
+
 2022-02-01  Oriol Brufau  <[email protected]>
 
         [css-cascade] Fix removal of not yet loaded CSS @import

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name-expected.txt (0 => 288882)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name-expected.txt	2022-02-01 16:53:24 UTC (rev 288882)
@@ -0,0 +1,3 @@
+
+PASS Replacing a <style> element with a new <style> element while both containing the different @keyframes rule with the same name dynamically updates running animations.
+

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name.html (0 => 288882)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name.html	2022-02-01 16:53:24 UTC (rev 288882)
@@ -0,0 +1,36 @@
+<!doctype html>
+<meta charset=utf-8>
+<title>Changes to @keyframes rules</title>
+<link rel="help" href=""
+<script src=""
+<script src=""
+<script src=""
+<div id="log"></div>
+<script>
+'use strict';
+
+test(t => {
+  const div = addDiv(t);
+
+  const originalStyleElement = document.createElement("style");
+  originalStyleElement.textContent = '@keyframes anim-custom { from, to { left: 100px } }';
+  document.head.appendChild(originalStyleElement);
+
+  t.add_cleanup(() => originalStyleElement.remove());
+
+  div.style.animation = 'anim-custom 100s';
+
+  const computedStyle = getComputedStyle(div);
+  assert_equals(computedStyle.left, "100px", "The initial @keyframes rule is applied");
+
+  // Remove the original style element and add a new one with an animation with the same name.
+  const newStyleElement = document.createElement("style");
+  newStyleElement.textContent = '@keyframes anim-custom { from, to { left: 200px } }';
+  originalStyleElement.replaceWith(newStyleElement);
+
+  t.add_cleanup(() => newStyleElement.remove());
+
+  assert_equals(computedStyle.left, "200px", "The new @keyframes rule is applied");
+}, 'Replacing a <style> element with a new <style> element while both containing the different @keyframes rule with the same name dynamically updates running animations.');
+
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/parsing/marker-supported-properties-in-animation-expected.txt (288881 => 288882)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/parsing/marker-supported-properties-in-animation-expected.txt	2022-02-01 16:51:44 UTC (rev 288881)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-pseudo/parsing/marker-supported-properties-in-animation-expected.txt	2022-02-01 16:53:24 UTC (rev 288882)
@@ -19,26 +19,26 @@
 FAIL Animation of font-variant-position in ::marker assert_equals: expected "sub" but got "normal"
 PASS Animation of font-weight in ::marker
 PASS Animation of line-height in ::marker
-FAIL Animation of white-space in ::marker assert_equals: expected "nowrap" but got "pre"
-FAIL Animation of color in ::marker assert_equals: expected "rgb(50, 150, 100)" but got "rgb(0, 0, 0)"
+PASS Animation of white-space in ::marker
+PASS Animation of color in ::marker
 PASS Animation of text-combine-upright in ::marker
 PASS Animation of unicode-bidi in ::marker
 PASS Animation of direction in ::marker
-FAIL Animation of content in ::marker assert_equals: expected "\"bar\"" but got "normal"
+PASS Animation of content in ::marker
 FAIL Animation of hyphens in ::marker assert_true: hyphens doesn't seem to be supported in the computed style expected true got false
-FAIL Animation of letter-spacing in ::marker assert_equals: expected "10px" but got "normal"
+PASS Animation of letter-spacing in ::marker
 FAIL Animation of line-break in ::marker assert_equals: expected "anywhere" but got "auto"
-FAIL Animation of overflow-wrap in ::marker assert_equals: expected "anywhere" but got "normal"
-FAIL Animation of tab-size in ::marker assert_equals: expected "10px" but got "8"
-FAIL Animation of text-transform in ::marker assert_equals: expected "uppercase" but got "none"
-FAIL Animation of word-break in ::marker assert_equals: expected "break-word" but got "normal"
-FAIL Animation of word-spacing in ::marker assert_equals: expected "10px" but got "0px"
+PASS Animation of overflow-wrap in ::marker
+PASS Animation of tab-size in ::marker
+PASS Animation of text-transform in ::marker
+PASS Animation of word-break in ::marker
+PASS Animation of word-spacing in ::marker
 FAIL Animation of text-decoration-skip-ink in ::marker assert_equals: expected "none" but got "auto"
 FAIL Animation of text-emphasis in ::marker assert_equals: expected "triangle rgb(50, 100, 100)" but got ""
-FAIL Animation of text-emphasis-color in ::marker assert_equals: expected "rgb(50, 100, 100)" but got "rgb(0, 0, 0)"
-FAIL Animation of text-emphasis-position in ::marker assert_equals: expected "under left" but got "over right"
+FAIL Animation of text-emphasis-color in ::marker assert_equals: expected "rgb(50, 100, 100)" but got "rgb(100, 0, 200)"
+PASS Animation of text-emphasis-position in ::marker
 FAIL Animation of text-emphasis-style in ::marker assert_equals: expected "triangle" but got "none"
-FAIL Animation of text-shadow in ::marker assert_equals: expected "rgb(50, 100, 100) 2px 2px 2px" but got "none"
+PASS Animation of text-shadow in ::marker
 PASS Animation of display in ::marker
 PASS Animation of position in ::marker
 PASS Animation of float in ::marker

Modified: trunk/Source/WebCore/ChangeLog (288881 => 288882)


--- trunk/Source/WebCore/ChangeLog	2022-02-01 16:51:44 UTC (rev 288881)
+++ trunk/Source/WebCore/ChangeLog	2022-02-01 16:53:24 UTC (rev 288882)
@@ -1,5 +1,21 @@
 2022-02-01  Antoine Quint  <[email protected]>
 
+        Redefining @keyframes does not work
+        https://bugs.webkit.org/show_bug.cgi?id=229437
+        <rdar://problem/82563372>
+
+        Reviewed by Antti Koivisto.
+
+        Notify the document upon insertion of a new @keyframes rule such that any running CSS Animation
+        using that rule name may update its computed keyframes.
+
+        Test: imported/w3c/web-platform-tests/css/css-animations/animation-style-element-replaced-with-keyframes-rule-of-same-name.html
+
+        * style/StyleResolver.cpp:
+        (WebCore::Style::Resolver::addKeyframeStyle):
+
+2022-02-01  Antoine Quint  <[email protected]>
+
         Animation from scale(0) has missing backing store
         https://bugs.webkit.org/show_bug.cgi?id=227733
         <rdar://problem/80246192>

Modified: trunk/Source/WebCore/style/StyleResolver.cpp (288881 => 288882)


--- trunk/Source/WebCore/style/StyleResolver.cpp	2022-02-01 16:51:44 UTC (rev 288881)
+++ trunk/Source/WebCore/style/StyleResolver.cpp	2022-02-01 16:53:24 UTC (rev 288882)
@@ -195,8 +195,9 @@
 // This is a simplified style setting function for keyframe styles
 void Resolver::addKeyframeStyle(Ref<StyleRuleKeyframes>&& rule)
 {
-    AtomString s(rule->name());
-    m_keyframesRuleMap.set(s.impl(), WTFMove(rule));
+    AtomString animationName(rule->name());
+    m_keyframesRuleMap.set(animationName.impl(), WTFMove(rule));
+    m_document.keyframesRuleDidChange(animationName);
 }
 
 Resolver::~Resolver()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to