Title: [295385] trunk
Revision
295385
Author
[email protected]
Date
2022-06-08 10:23:41 -0700 (Wed, 08 Jun 2022)

Log Message

REGRESSION(r295200): Avoid style update when resolving container queries in other frames
https://bugs.webkit.org/show_bug.cgi?id=241409
<rdar://94536162>

Reviewed by Alan Bujtas.

* LayoutTests/fast/css/container-query-style-recursion-expected.txt: Added.
* LayoutTests/fast/css/container-query-style-recursion.html: Added.
* Source/WebCore/dom/Document.cpp:
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::isResolvingContainerQueriesForSelfOrAncestor const):

Also check ancestors.

* Source/WebCore/dom/Document.h:
* Source/WebCore/page/FrameViewLayoutContext.cpp:
(WebCore::FrameViewLayoutContext::performLayout):

Canonical link: https://commits.webkit.org/251392@main

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/fast/css/container-query-style-recursion-expected.txt (0 => 295385)


--- trunk/LayoutTests/fast/css/container-query-style-recursion-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/css/container-query-style-recursion-expected.txt	2022-06-08 17:23:41 UTC (rev 295385)
@@ -0,0 +1 @@
+ This test passes if it doesn't crash.

Added: trunk/LayoutTests/fast/css/container-query-style-recursion.html (0 => 295385)


--- trunk/LayoutTests/fast/css/container-query-style-recursion.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css/container-query-style-recursion.html	2022-06-08 17:23:41 UTC (rev 295385)
@@ -0,0 +1,20 @@
+<style>
+  #x {
+    container-type: inline-size;
+    position: sticky;
+    width: 10%;
+  }
+  :read-only {
+    border-width: 250px;
+  }
+</style>
+<script>
+  if (window.testRunner)
+    testRunner.dumpAsText();
+  _onload_ = () => {
+    location.hash = 'x';
+    document.designMode = 'on';
+  };
+</script>
+<iframe id="x"></iframe>
+This test passes if it doesn't crash.

Modified: trunk/Source/WebCore/dom/Document.cpp (295384 => 295385)


--- trunk/Source/WebCore/dom/Document.cpp	2022-06-08 17:22:34 UTC (rev 295384)
+++ trunk/Source/WebCore/dom/Document.cpp	2022-06-08 17:23:41 UTC (rev 295385)
@@ -2207,7 +2207,7 @@
 
 bool Document::updateStyleIfNeeded()
 {
-    if (isResolvingContainerQueries())
+    if (isResolvingContainerQueriesForSelfOrAncestor())
         return false;
 
     RefPtr<FrameView> frameView = view();
@@ -2477,6 +2477,15 @@
     m_isResolvingTreeStyle = value;
 }
 
+bool Document::isResolvingContainerQueriesForSelfOrAncestor() const
+{
+    if (m_isResolvingContainerQueries)
+        return true;
+    if (auto* owner = ownerElement())
+        return owner->document().isResolvingContainerQueriesForSelfOrAncestor();
+    return false;
+}
+
 void Document::createRenderTree()
 {
     ASSERT(!renderView());

Modified: trunk/Source/WebCore/dom/Document.h (295384 => 295385)


--- trunk/Source/WebCore/dom/Document.h	2022-06-08 17:22:34 UTC (rev 295384)
+++ trunk/Source/WebCore/dom/Document.h	2022-06-08 17:23:41 UTC (rev 295385)
@@ -1348,6 +1348,7 @@
     bool inStyleRecalc() const { return m_inStyleRecalc; }
     bool inRenderTreeUpdate() const { return m_inRenderTreeUpdate; }
     bool isResolvingContainerQueries() const { return m_isResolvingContainerQueries; }
+    bool isResolvingContainerQueriesForSelfOrAncestor() const;
     bool isResolvingTreeStyle() const { return m_isResolvingTreeStyle; }
     void setIsResolvingTreeStyle(bool);
 

Modified: trunk/Source/WebCore/page/FrameViewLayoutContext.cpp (295384 => 295385)


--- trunk/Source/WebCore/page/FrameViewLayoutContext.cpp	2022-06-08 17:22:34 UTC (rev 295384)
+++ trunk/Source/WebCore/page/FrameViewLayoutContext.cpp	2022-06-08 17:23:41 UTC (rev 295385)
@@ -219,7 +219,7 @@
     {
         SetForScope layoutPhase(m_layoutPhase, LayoutPhase::InPreLayout);
 
-        if (!frame().document()->isResolvingContainerQueries()) {
+        if (!frame().document()->isResolvingContainerQueriesForSelfOrAncestor()) {
             // If this is a new top-level layout and there are any remaining tasks from the previous layout, finish them now.
             if (!isLayoutNested() && m_asynchronousTasksTimer.isActive() && !view().isInChildFrameWithFrameFlattening())
                 runAsynchronousTasks();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to