Title: [282641] releases/WebKitGTK/webkit-2.32
Revision
282641
Author
[email protected]
Date
2021-09-17 01:29:06 -0700 (Fri, 17 Sep 2021)

Log Message

Merge r281128 - REGRESSION (r275756): Accelerated animations freeze when invalidating layout with shadow dom
https://bugs.webkit.org/show_bug.cgi?id=228954
<rdar://problem/81750217>

Reviewed by Ryosuke Niwa.

Source/WebCore:

Test: animations/shadow-host-child-change.html

Tearing down the host renderer after slot assignments change cancels animations on it.

* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::didChangeSlot):
* rendering/updating/RenderTreeUpdater.cpp:
(WebCore::RenderTreeUpdater::tearDownRenderersAfterSlotChange):

Add a version that keeps the animations going on the teardown root.

(WebCore::RenderTreeUpdater::tearDownRenderers):
* rendering/updating/RenderTreeUpdater.h:

LayoutTests:

Original test by Liam DeBeasi

* animations/shadow-host-child-change-expected.html: Added.
* animations/shadow-host-child-change.html: Added.

Modified Paths

Added Paths

Diff

Modified: releases/WebKitGTK/webkit-2.32/LayoutTests/ChangeLog (282640 => 282641)


--- releases/WebKitGTK/webkit-2.32/LayoutTests/ChangeLog	2021-09-17 08:28:59 UTC (rev 282640)
+++ releases/WebKitGTK/webkit-2.32/LayoutTests/ChangeLog	2021-09-17 08:29:06 UTC (rev 282641)
@@ -1,3 +1,16 @@
+2021-08-16  Antti Koivisto  <[email protected]>
+
+        REGRESSION (r275756): Accelerated animations freeze when invalidating layout with shadow dom
+        https://bugs.webkit.org/show_bug.cgi?id=228954
+        <rdar://problem/81750217>
+
+        Reviewed by Ryosuke Niwa.
+
+        Original test by Liam DeBeasi
+
+        * animations/shadow-host-child-change-expected.html: Added.
+        * animations/shadow-host-child-change.html: Added.
+
 2021-07-08  Antti Koivisto  <[email protected]>
 
         Shadow host stops rendering after removing a slot, updating style, then its assigned node

Added: releases/WebKitGTK/webkit-2.32/LayoutTests/animations/shadow-host-child-change-expected.html (0 => 282641)


--- releases/WebKitGTK/webkit-2.32/LayoutTests/animations/shadow-host-child-change-expected.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.32/LayoutTests/animations/shadow-host-child-change-expected.html	2021-09-17 08:29:06 UTC (rev 282641)
@@ -0,0 +1,18 @@
+
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            app-content {
+                display: block;
+                width: 100px;
+                height: 100px;
+                background: green;
+                transform: translateX(100px);
+            }
+        </style>
+    </head>
+    <body>
+        <app-content id=target>new text</app-content>
+    </body>
+</html>

Added: releases/WebKitGTK/webkit-2.32/LayoutTests/animations/shadow-host-child-change.html (0 => 282641)


--- releases/WebKitGTK/webkit-2.32/LayoutTests/animations/shadow-host-child-change.html	                        (rev 0)
+++ releases/WebKitGTK/webkit-2.32/LayoutTests/animations/shadow-host-child-change.html	2021-09-17 08:29:06 UTC (rev 282641)
@@ -0,0 +1,50 @@
+
+<!DOCTYPE html>
+<html>
+    <head>
+        <style>
+            app-content {
+                display: block;
+                width: 100px;
+                height: 100px;
+                background: green;
+                animation: animation 10s linear forwards;
+            }
+            @keyframes animation {
+                from {
+                    transform: translateX(0px);
+                }
+                2% {
+                    transform: translateX(100px);
+                }
+                to {
+                    transform: translateX(100px);
+                }
+            }
+        </style>
+    </head>
+    <body>
+        <app-content id=target>old text</app-content>
+
+        <script>
+            if (window.testRunner)
+                testRunner.waitUntilDone();
+
+            customElements.define('app-content', class extends HTMLElement {
+                constructor() {
+                    super();
+
+                    const root = this.attachShadow({ mode: 'open' });
+                    root.innerHTML = `<slot></slot>`;
+                }
+            });
+
+            setTimeout(() => {
+                target.innerHTML = "new text"
+            }, 100);
+
+            if (window.testRunner)
+                setTimeout(() => testRunner.notifyDone(), 500);
+        </script>
+    </body>
+</html>

Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog (282640 => 282641)


--- releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog	2021-09-17 08:28:59 UTC (rev 282640)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog	2021-09-17 08:29:06 UTC (rev 282641)
@@ -1,3 +1,25 @@
+2021-08-16  Antti Koivisto  <[email protected]>
+
+        REGRESSION (r275756): Accelerated animations freeze when invalidating layout with shadow dom
+        https://bugs.webkit.org/show_bug.cgi?id=228954
+        <rdar://problem/81750217>
+
+        Reviewed by Ryosuke Niwa.
+
+        Test: animations/shadow-host-child-change.html
+
+        Tearing down the host renderer after slot assignments change cancels animations on it.
+
+        * dom/SlotAssignment.cpp:
+        (WebCore::SlotAssignment::didChangeSlot):
+        * rendering/updating/RenderTreeUpdater.cpp:
+        (WebCore::RenderTreeUpdater::tearDownRenderersAfterSlotChange):
+
+        Add a version that keeps the animations going on the teardown root.
+
+        (WebCore::RenderTreeUpdater::tearDownRenderers):
+        * rendering/updating/RenderTreeUpdater.h:
+
 2021-07-08  Antti Koivisto  <[email protected]>
 
         Shadow host stops rendering after removing a slot, updating style, then its assigned node

Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/SlotAssignment.cpp (282640 => 282641)


--- releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/SlotAssignment.cpp	2021-09-17 08:28:59 UTC (rev 282640)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/SlotAssignment.cpp	2021-09-17 08:29:06 UTC (rev 282641)
@@ -307,8 +307,8 @@
     if (!slot)
         return;
 
-    RenderTreeUpdater::tearDownRenderers(*shadowRoot.host());
-    shadowRoot.host()->invalidateStyleAndRenderersForSubtree();
+    RenderTreeUpdater::tearDownRenderersAfterSlotChange(*shadowRoot.host());
+    shadowRoot.host()->invalidateStyleForSubtree();
 
     slot->assignedNodes.clear();
     m_slotAssignmentsIsValid = false;

Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp (282640 => 282641)


--- releases/WebKitGTK/webkit-2.32/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp	2021-09-17 08:28:59 UTC (rev 282640)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/rendering/updating/RenderTreeUpdater.cpp	2021-09-17 08:29:06 UTC (rev 282641)
@@ -536,6 +536,16 @@
     tearDownRenderers(root, TeardownType::Full, builder);
 }
 
+void RenderTreeUpdater::tearDownRenderersAfterSlotChange(Element& host)
+{
+    ASSERT(host.shadowRoot());
+    auto* view = host.document().renderView();
+    if (!view)
+        return;
+    RenderTreeBuilder builder(*view);
+    tearDownRenderers(host, TeardownType::FullAfterSlotChange, builder);
+}
+
 void RenderTreeUpdater::tearDownRenderer(Text& text)
 {
     auto* view = text.document().renderView();
@@ -561,6 +571,7 @@
     auto pop = [&] (unsigned depth) {
         while (teardownStack.size() > depth) {
             auto& element = *teardownStack.takeLast();
+            auto styleable = Styleable::fromElement(element);
 
             // Make sure we don't leave any renderers behind in nodes outside the composed tree.
             if (element.shadowRoot())
@@ -567,15 +578,25 @@
                 tearDownLeftoverShadowHostChildren(element, builder);
 
             switch (teardownType) {
+            case TeardownType::FullAfterSlotChange:
+                if (&element == &root) {
+                    // Keep animations going on the host.
+                    if (timeline)
+                        timeline->willChangeRendererForStyleable(styleable);
+                    break;
+                }
+                FALLTHROUGH;
             case TeardownType::Full:
-            case TeardownType::RendererUpdateCancelingAnimations:
                 if (timeline) {
                     if (document.renderTreeBeingDestroyed())
-                        timeline->cancelDeclarativeAnimationsForStyleable(Styleable::fromElement(element), WebAnimation::Silently::Yes);
-                    else if (teardownType == TeardownType::RendererUpdateCancelingAnimations)
-                        timeline->cancelDeclarativeAnimationsForStyleable(Styleable::fromElement(element), WebAnimation::Silently::No);
+                        timeline->cancelDeclarativeAnimationsForStyleable(styleable, WebAnimation::Silently::Yes);
                 }
+                element.clearHoverAndActiveStatusBeforeDetachingRenderer();
                 break;
+            case TeardownType::RendererUpdateCancelingAnimations:
+                if (timeline)
+                    timeline->cancelDeclarativeAnimationsForStyleable(styleable, WebAnimation::Silently::No);
+                break;
             case TeardownType::RendererUpdate:
                 if (timeline)
                     timeline->willChangeRendererForStyleable(Styleable::fromElement(element));
@@ -582,9 +603,6 @@
                 break;
             }
 
-            if (teardownType == TeardownType::Full)
-                element.clearHoverAndActiveStatusBeforeDetachingRenderer();
-
             GeneratedContent::removeBeforePseudoElement(element, builder);
             GeneratedContent::removeAfterPseudoElement(element, builder);
 

Modified: releases/WebKitGTK/webkit-2.32/Source/WebCore/rendering/updating/RenderTreeUpdater.h (282640 => 282641)


--- releases/WebKitGTK/webkit-2.32/Source/WebCore/rendering/updating/RenderTreeUpdater.h	2021-09-17 08:28:59 UTC (rev 282640)
+++ releases/WebKitGTK/webkit-2.32/Source/WebCore/rendering/updating/RenderTreeUpdater.h	2021-09-17 08:29:06 UTC (rev 282641)
@@ -50,6 +50,7 @@
     void commit(std::unique_ptr<const Style::Update>);
 
     static void tearDownRenderers(Element&);
+    static void tearDownRenderersAfterSlotChange(Element& host);
     static void tearDownRenderer(Text&);
 
 private:
@@ -87,7 +88,8 @@
     void popParent();
     void popParentsToDepth(unsigned depth);
 
-    enum class TeardownType { Full, RendererUpdate, RendererUpdateCancelingAnimations };
+    // FIXME: Use OptionSet.
+    enum class TeardownType { Full, FullAfterSlotChange, RendererUpdate, RendererUpdateCancelingAnimations };
     static void tearDownRenderers(Element&, TeardownType, RenderTreeBuilder&);
     static void tearDownTextRenderer(Text&, RenderTreeBuilder&);
     static void tearDownLeftoverShadowHostChildren(Element&, RenderTreeBuilder&);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to