Title: [291500] trunk
Revision
291500
Author
[email protected]
Date
2022-03-18 15:47:34 -0700 (Fri, 18 Mar 2022)

Log Message

[CSS Container Queries] Ensure container style changes are propagated to descendants
https://bugs.webkit.org/show_bug.cgi?id=238072

Reviewed by Alan Bujtas.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-contain/container-queries/container-name-invalidation-expected.txt:
* web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt:
* web-platform-tests/css/css-contain/container-queries/container-units-selection-expected.txt:

Source/WebCore:

* style/StyleChange.cpp:
(WebCore::Style::determineChange):

Ensure we recompute the descendants when container properties change.

* style/StyleTreeResolver.cpp:
(WebCore::Style::TreeResolver::resolveComposedTree):
(WebCore::Style::TreeResolver::updateQueryContainer):

We need to ensure layout is up-to-date also when a query container stops being one.
Remove the unused m_resolvedQueryContainers maps.

* style/StyleTreeResolver.h:

Modified Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (291499 => 291500)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-18 22:12:12 UTC (rev 291499)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-03-18 22:47:34 UTC (rev 291500)
@@ -1,5 +1,16 @@
 2022-03-18  Antti Koivisto  <[email protected]>
 
+        [CSS Container Queries] Ensure container style changes are propagated to descendants
+        https://bugs.webkit.org/show_bug.cgi?id=238072
+
+        Reviewed by Alan Bujtas.
+
+        * web-platform-tests/css/css-contain/container-queries/container-name-invalidation-expected.txt:
+        * web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt:
+        * web-platform-tests/css/css-contain/container-queries/container-units-selection-expected.txt:
+
+2022-03-18  Antti Koivisto  <[email protected]>
+
         [CSS Container Queries] Basic support for container units
         https://bugs.webkit.org/show_bug.cgi?id=238021
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-name-invalidation-expected.txt (291499 => 291500)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-name-invalidation-expected.txt	2022-03-18 22:12:12 UTC (rev 291499)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-name-invalidation-expected.txt	2022-03-18 22:47:34 UTC (rev 291500)
@@ -1,5 +1,5 @@
 Test
 
 PASS Changing a named container invalidates relevant descendants
-FAIL Changing container-name invalidates relevant descendants assert_equals: expected "rgb(0, 0, 0)" but got "rgb(0, 128, 0)"
+PASS Changing container-name invalidates relevant descendants
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt (291499 => 291500)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt	2022-03-18 22:12:12 UTC (rev 291499)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-invalidation-expected.txt	2022-03-18 22:47:34 UTC (rev 291500)
@@ -1,4 +1,4 @@
 Test
 
-FAIL Changing the container type invalidates relevant descendants assert_equals: expected "rgb(0, 0, 0)" but got "rgb(0, 128, 0)"
+PASS Changing the container type invalidates relevant descendants
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-units-selection-expected.txt (291499 => 291500)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-units-selection-expected.txt	2022-03-18 22:12:12 UTC (rev 291499)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-units-selection-expected.txt	2022-03-18 22:47:34 UTC (rev 291500)
@@ -1,5 +1,5 @@
 Test
 
-FAIL Container units select the proper container assert_equals: expected "30px" but got "10px"
+PASS Container units select the proper container
 FAIL Units respond to the writing-mode of the element assert_equals: expected "40px" but got "30px"
 

Modified: trunk/Source/WebCore/ChangeLog (291499 => 291500)


--- trunk/Source/WebCore/ChangeLog	2022-03-18 22:12:12 UTC (rev 291499)
+++ trunk/Source/WebCore/ChangeLog	2022-03-18 22:47:34 UTC (rev 291500)
@@ -1,3 +1,24 @@
+2022-03-18  Antti Koivisto  <[email protected]>
+
+        [CSS Container Queries] Ensure container style changes are propagated to descendants
+        https://bugs.webkit.org/show_bug.cgi?id=238072
+
+        Reviewed by Alan Bujtas.
+
+        * style/StyleChange.cpp:
+        (WebCore::Style::determineChange):
+
+        Ensure we recompute the descendants when container properties change.
+
+        * style/StyleTreeResolver.cpp:
+        (WebCore::Style::TreeResolver::resolveComposedTree):
+        (WebCore::Style::TreeResolver::updateQueryContainer):
+
+        We need to ensure layout is up-to-date also when a query container stops being one.
+        Remove the unused m_resolvedQueryContainers maps.
+
+        * style/StyleTreeResolver.h:
+
 2022-03-18  Per Arne Vollan  <[email protected]>
 
         Fix test failures when enabling content filtering in the Network process

Modified: trunk/Source/WebCore/style/StyleChange.cpp (291499 => 291500)


--- trunk/Source/WebCore/style/StyleChange.cpp	2022-03-18 22:12:12 UTC (rev 291499)
+++ trunk/Source/WebCore/style/StyleChange.cpp	2022-03-18 22:47:34 UTC (rev 291500)
@@ -63,6 +63,10 @@
     if (!s1.descendantAffectingNonInheritedPropertiesEqual(s2))
         return Change::Inherited;
 
+    // Query container changes affect descendant style.
+    if (s1.containerType() != s2.containerType() || s1.containerNames() != s2.containerNames())
+        return Change::Inherited;
+
     if (s1 != s2)
         return Change::NonInherited;
 

Modified: trunk/Source/WebCore/style/StyleTreeResolver.cpp (291499 => 291500)


--- trunk/Source/WebCore/style/StyleTreeResolver.cpp	2022-03-18 22:12:12 UTC (rev 291499)
+++ trunk/Source/WebCore/style/StyleTreeResolver.cpp	2022-03-18 22:47:34 UTC (rev 291500)
@@ -706,6 +706,7 @@
         auto* style = element.renderOrDisplayContentsStyle();
         auto change = Change::None;
         auto descendantsToResolve = DescendantsToResolve::None;
+        auto previousContainerType = style ? style->containerType() : ContainerType::None;
 
         bool shouldResolve = shouldResolveElement(element, parent.descendantsToResolve);
         if (shouldResolve) {
@@ -737,7 +738,7 @@
         bool shouldIterateChildren = style && (element.childNeedsStyleRecalc() || descendantsToResolve != DescendantsToResolve::None);
 
         if (shouldIterateChildren) {
-            if (updateQueryContainer(element, *style) == QueryContainerAction::Layout)
+            if (updateQueryContainer(element, *style, previousContainerType) == QueryContainerAction::Layout)
                 shouldIterateChildren = false;
         }
 
@@ -762,25 +763,24 @@
     popParentsToDepth(1);
 }
 
-auto TreeResolver::updateQueryContainer(Element& element, const RenderStyle& style) -> QueryContainerAction
+auto TreeResolver::updateQueryContainer(Element& element, const RenderStyle& style, ContainerType previousContainerType) -> QueryContainerAction
 {
-    if (style.containerType() == ContainerType::None)
-        return QueryContainerAction::None;
+    if (style.containerType() != ContainerType::None)
+        scope().selectorMatchingState.queryContainers.append(element);
 
-    scope().selectorMatchingState.queryContainers.append(element);
-
-    if (m_unresolvedQueryContainers.remove(&element)) {
-        m_resolvedQueryContainers.add(&element);
+    if (m_unresolvedQueryContainers.remove(&element))
         return QueryContainerAction::Continue;
-    }
 
-    if (m_update->isEmpty()) {
-        m_resolvedQueryContainers.add(&element);
+    // Render tree needs to be updated before proceeding to children also if we have a former query container
+    // because container query resolution for descendants relies on it being up-to-date.
+    if (style.containerType() == ContainerType::None && previousContainerType == ContainerType::None)
+        return QueryContainerAction::None;
+
+    if (m_update->isEmpty())
         return QueryContainerAction::Continue;
-    }
 
+    // Bail out from TreeResolver to build a render tree and do a layout. Resolution continues after.
     m_unresolvedQueryContainers.add(&element);
-
     return QueryContainerAction::Layout;
 }
 

Modified: trunk/Source/WebCore/style/StyleTreeResolver.h (291499 => 291500)


--- trunk/Source/WebCore/style/StyleTreeResolver.h	2022-03-18 22:12:12 UTC (rev 291499)
+++ trunk/Source/WebCore/style/StyleTreeResolver.h	2022-03-18 22:47:34 UTC (rev 291500)
@@ -63,7 +63,7 @@
     void resolveComposedTree();
 
     enum class QueryContainerAction : uint8_t { None, Continue, Layout };
-    QueryContainerAction updateQueryContainer(Element&, const RenderStyle&);
+    QueryContainerAction updateQueryContainer(Element&, const RenderStyle&, ContainerType previousContainerType);
 
     enum class DescendantsToResolve : uint8_t { None, ChildrenWithExplicitInherit, Children, All };
     std::pair<ElementUpdate, DescendantsToResolve> resolveElement(Element&);
@@ -127,7 +127,6 @@
     bool m_didSeePendingStylesheet { false };
 
     HashSet<RefPtr<Element>> m_unresolvedQueryContainers;
-    HashSet<RefPtr<Element>> m_resolvedQueryContainers;
 
     std::unique_ptr<Update> m_update;
 };
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to