Title: [290644] trunk
Revision
290644
Author
[email protected]
Date
2022-03-01 06:42:27 -0800 (Tue, 01 Mar 2022)

Log Message

[web-animations] web-animations/interfaces/Animatable/getAnimations-iframe.html is a unique failure
https://bugs.webkit.org/show_bug.cgi?id=237314

Reviewed by Antti Koivisto.

LayoutTests/imported/w3c:

Add a new test to check that both Document.getAnimations() and Element.getAnimations() correctly
update layout on the owner document.

* web-platform-tests/web-animations/interfaces/Animatable/getAnimations-iframe-expected.txt:
* web-platform-tests/web-animations/interfaces/Animatable/getAnimations-iframe.html:

Source/WebCore:

We need to update the layout of a potential owner document in case some layout-dependent media queries
trigger declarative animations.

* dom/Document.cpp:
(WebCore::Document::matchingAnimations):
* dom/Element.cpp:
(WebCore::Element::getAnimations):

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (290643 => 290644)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-01 14:32:12 UTC (rev 290643)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-01 14:42:27 UTC (rev 290644)
@@ -1,3 +1,16 @@
+2022-03-01  Antoine Quint  <[email protected]>
+
+        [web-animations] web-animations/interfaces/Animatable/getAnimations-iframe.html is a unique failure
+        https://bugs.webkit.org/show_bug.cgi?id=237314
+
+        Reviewed by Antti Koivisto.
+
+        Add a new test to check that both Document.getAnimations() and Element.getAnimations() correctly
+        update layout on the owner document.
+
+        * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-iframe-expected.txt:
+        * web-platform-tests/web-animations/interfaces/Animatable/getAnimations-iframe.html:
+
 2022-03-01  Ziran Sun  <[email protected]>
 
         [Selection] Selection Range should be clamped by the current value length

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/getAnimations-iframe-expected.txt (290643 => 290644)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/getAnimations-iframe-expected.txt	2022-03-01 14:32:12 UTC (rev 290643)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/getAnimations-iframe-expected.txt	2022-03-01 14:42:27 UTC (rev 290644)
@@ -1,4 +1,4 @@
 
+PASS Calling Element.getAnimations updates layout of parent frame if needed
+PASS Calling Document.getAnimations updates layout of parent frame if needed
 
-FAIL Calling getAnimations updates layout of parent frame if needed assert_equals: expected 1 but got 0
-

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/getAnimations-iframe.html (290643 => 290644)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/getAnimations-iframe.html	2022-03-01 14:32:12 UTC (rev 290643)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/web-animations/interfaces/Animatable/getAnimations-iframe.html	2022-03-01 14:42:27 UTC (rev 290644)
@@ -2,6 +2,7 @@
 <title>getAnimations in dirty iframe</title>
 <script src=""
 <script src=""
+<script src=""
 <style>
   iframe {
     width: 200px;
@@ -8,32 +9,43 @@
     height: 40px;
   }
 </style>
-<iframe id=iframe srcdoc="
-  <style>
-    div { color: red; }
-    @keyframes test {
-      from { color: green; }
-      to { color: green; }
-    }
-    @media (min-width: 300px) {
-      div { animation: test 1s linear forwards; }
-    }
-  </style>
-  <div id=div>Green</div>
-"></iframe>
+<body>
 <script>
 
-  function waitForLoad(w) {
-    return new Promise(resolve => w.addEventListener('load', resolve));
+  const createFrame = async test => {
+      const iframe = createElement(test, "iframe");
+      const contents = "" +
+        "<style>" +
+        "  div { color: red; }" +
+        "  @keyframes test {" +
+        "    from { color: green; }" +
+        "    to { color: green; }" +
+        "  }" +
+        "  @media (min-width: 300px) {" +
+        "    div { animation: test 1s linear forwards; }" +
+        "  }" +
+        "</style>" +
+        "<div id=div>Green</div>";
+      iframe.setAttribute("srcdoc", contents);
+      await new Promise(resolve => iframe.addEventListener("load", resolve));
+      return iframe;
+  };
+
+  const iframeTest = (getAnimations, interfaceName) => {
+      promise_test(async test => {
+        const frame = await createFrame(test);
+        const inner_div = frame.contentDocument.getElementById('div');
+        assert_equals(getComputedStyle(inner_div).color, 'rgb(255, 0, 0)');
+
+        frame.style.width = '400px';
+        const animations = getAnimations(inner_div);
+        assert_equals(animations.length, 1);
+        assert_equals(getComputedStyle(inner_div).color, 'rgb(0, 128, 0)');
+      }, `Calling ${interfaceName}.getAnimations updates layout of parent frame if needed`);
   }
 
-  promise_test(async () => {
-    await waitForLoad(window);
-    let inner_div = iframe.contentDocument.getElementById('div');
-    assert_equals(getComputedStyle(inner_div).color, 'rgb(255, 0, 0)');
+  iframeTest(element => element.getAnimations(), 'Element');
+  iframeTest(element => element.ownerDocument.getAnimations(), 'Document');
 
-    iframe.style.width = '400px';
-    assert_equals(inner_div.getAnimations().length, 1);
-    assert_equals(getComputedStyle(inner_div).color, 'rgb(0, 128, 0)');
-  }, 'Calling getAnimations updates layout of parent frame if needed');
 </script>
+</body>

Modified: trunk/Source/WebCore/ChangeLog (290643 => 290644)


--- trunk/Source/WebCore/ChangeLog	2022-03-01 14:32:12 UTC (rev 290643)
+++ trunk/Source/WebCore/ChangeLog	2022-03-01 14:42:27 UTC (rev 290644)
@@ -1,3 +1,18 @@
+2022-03-01  Antoine Quint  <[email protected]>
+
+        [web-animations] web-animations/interfaces/Animatable/getAnimations-iframe.html is a unique failure
+        https://bugs.webkit.org/show_bug.cgi?id=237314
+
+        Reviewed by Antti Koivisto.
+
+        We need to update the layout of a potential owner document in case some layout-dependent media queries
+        trigger declarative animations.
+
+        * dom/Document.cpp:
+        (WebCore::Document::matchingAnimations):
+        * dom/Element.cpp:
+        (WebCore::Element::getAnimations):
+
 2022-03-01  Kimmo Kinnunen  <[email protected]>
 
         WebGL GPUP OpenGL context is not used even if WebGL via Metal is deselected

Modified: trunk/Source/WebCore/dom/Document.cpp (290643 => 290644)


--- trunk/Source/WebCore/dom/Document.cpp	2022-03-01 14:32:12 UTC (rev 290643)
+++ trunk/Source/WebCore/dom/Document.cpp	2022-03-01 14:42:27 UTC (rev 290644)
@@ -8527,7 +8527,10 @@
 Vector<RefPtr<WebAnimation>> Document::matchingAnimations(const Function<bool(Element&)>& function)
 {
     // For the list of animations to be current, we need to account for any pending CSS changes,
-    // such as updates to CSS Animations and CSS Transitions.
+    // such as updates to CSS Animations and CSS Transitions. This requires updating layout as
+    // well since resolving layout-dependent media queries could yield animations.
+    if (RefPtr owner = ownerElement())
+        owner->document().updateLayout();
     updateStyleIfNeeded();
 
     Vector<RefPtr<WebAnimation>> animations;

Modified: trunk/Source/WebCore/dom/Element.cpp (290643 => 290644)


--- trunk/Source/WebCore/dom/Element.cpp	2022-03-01 14:32:12 UTC (rev 290643)
+++ trunk/Source/WebCore/dom/Element.cpp	2022-03-01 14:42:27 UTC (rev 290644)
@@ -4728,8 +4728,11 @@
     }
 
     // For the list of animations to be current, we need to account for any pending CSS changes,
-    // such as updates to CSS Animations and CSS Transitions.
+    // such as updates to CSS Animations and CSS Transitions. This requires updating layout as
+    // well since resolving layout-dependent media queries could yield animations.
     // FIXME: We might be able to use ComputedStyleExtractor which is more optimized.
+    if (RefPtr owner = document().ownerElement())
+        owner->document().updateLayout();
     document().updateStyleIfNeeded();
 
     Vector<RefPtr<WebAnimation>> animations;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to