Title: [293288] trunk
Revision
293288
Author
[email protected]
Date
2022-04-22 23:44:03 -0700 (Fri, 22 Apr 2022)

Log Message

The layout is not updated when style.contain is changed from "size"/"inline-size" to empty string
https://bugs.webkit.org/show_bug.cgi?id=239489

Reviewed by Rob Buis.

LayoutTests/imported/w3c:

* web-platform-tests/css/css-contain/contain-inline-size-removed-expected.html: Added.
* web-platform-tests/css/css-contain/contain-inline-size-removed.html: Added.
* web-platform-tests/css/css-contain/contain-size-removed-expected.html: Added.
* web-platform-tests/css/css-contain/contain-size-removed.html: Added.
* web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-004-expected.txt:
* web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-005-expected.txt:

Source/WebCore:

Unlike "layout", "paint" and "style" containment, being a "size" and "inline-size" containment or not affects the layout size of the element.
So it should require layout when a normal element becomes a "size"/"inline-size" containment, vice versa.

Tests: imported/w3c/web-platform-tests/css/css-contain/contain-inline-size-removed.html
       imported/w3c/web-platform-tests/css/css-contain/contain-size-removed.html

* rendering/style/RenderStyle.cpp:
(WebCore::rareNonInheritedDataChangeRequiresLayout):
(WebCore::RenderStyle::effectiveContainment const): Deleted. Moved to StyleRareNonInheritedData.
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::effectiveContainment const):
* rendering/style/StyleRareNonInheritedData.cpp:
(WebCore::StyleRareNonInheritedData::effectiveContainment const):
* rendering/style/StyleRareNonInheritedData.h:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (293287 => 293288)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-23 06:27:11 UTC (rev 293287)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2022-04-23 06:44:03 UTC (rev 293288)
@@ -1,3 +1,17 @@
+2022-04-22  Cathie Chen  <[email protected]>
+
+        The layout is not updated when style.contain is changed from "size"/"inline-size" to empty string
+        https://bugs.webkit.org/show_bug.cgi?id=239489
+
+        Reviewed by Rob Buis.
+
+        * web-platform-tests/css/css-contain/contain-inline-size-removed-expected.html: Added.
+        * web-platform-tests/css/css-contain/contain-inline-size-removed.html: Added.
+        * web-platform-tests/css/css-contain/contain-size-removed-expected.html: Added.
+        * web-platform-tests/css/css-contain/contain-size-removed.html: Added.
+        * web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-004-expected.txt:
+        * web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-005-expected.txt:
+
 2022-04-21  Rob Buis  <[email protected]>
 
         `contain: layout` on the html element should change position:fixed behavior

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-inline-size-removed-expected.html (0 => 293288)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-inline-size-removed-expected.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-inline-size-removed-expected.html	2022-04-23 06:44:03 UTC (rev 293288)
@@ -0,0 +1,13 @@
+<!doctype html>
+<html>
+<head>
+   <title>Reference rendering - passes if there is the word "PASS" below</title>
+<style>
+div { overflow: hidden; }
+</style>
+</head>
+<body>
+   <p>Test passes if there is the word "PASS" below.</p>
+   <div>PASS</div>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-inline-size-removed.html (0 => 293288)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-inline-size-removed.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-inline-size-removed.html	2022-04-23 06:44:03 UTC (rev 293288)
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<meta charset="utf-8">
+<title>CSS Containment Test: Remove inline-size from style.contain</title>
+<link rel="help" href=""
+<link rel="help" href=""
+<meta name="assert" content="After removing inline-size from style.contain, the element should trigger layout">
+<link rel="match" href=""
+<style>
+
+</style>
+<p>Test passes if there is the word "PASS" below.</p>
+<div id="container" style="contain: inline-size; width:fit-content; overflow: hidden;"><span>PASS</span></div>
+
+<script>
+    window.requestAnimationFrame(() => {
+        document.getElementById("container").style.contain = "";
+    });
+</script>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-size-removed-expected.html (0 => 293288)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-size-removed-expected.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-size-removed-expected.html	2022-04-23 06:44:03 UTC (rev 293288)
@@ -0,0 +1,13 @@
+<!doctype html>
+<html>
+<head>
+   <title>Reference rendering - passes if there is the word "PASS" below</title>
+<style>
+div { overflow: hidden; }
+</style>
+</head>
+<body>
+   <p>Test passes if there is the word "PASS" below.</p>
+   <div>PASS</div>
+</body>
+</html>

Added: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-size-removed.html (0 => 293288)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-size-removed.html	                        (rev 0)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/contain-size-removed.html	2022-04-23 06:44:03 UTC (rev 293288)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<meta charset="utf-8">
+<title>CSS Containment Test: Remove size from style.contain</title>
+<link rel="help" href=""
+<meta name="assert" content="After removing size from style.contain, the element should trigger layout">
+<link rel="match" href=""
+<style>
+
+</style>
+<p>Test passes if there is the word "PASS" below.</p>
+<div id="container" style="contain: size; overflow: hidden;"><span>PASS</span></div>
+
+<script>
+window.requestAnimationFrame(() => {
+    document.getElementById("container").style.contain = "";
+});
+</script>

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-004-expected.txt (293287 => 293288)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-004-expected.txt	2022-04-23 06:27:11 UTC (rev 293287)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-004-expected.txt	2022-04-23 06:44:03 UTC (rev 293288)
@@ -1,4 +1,4 @@
-50
+0
 
-FAIL contain-intrinsic-size: auto assert_equals: expected 1 but got 50
+FAIL contain-intrinsic-size: auto assert_equals: expected 1 but got 0
 

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-005-expected.txt (293287 => 293288)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-005-expected.txt	2022-04-23 06:27:11 UTC (rev 293287)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/css/css-sizing/contain-intrinsic-size/auto-005-expected.txt	2022-04-23 06:44:03 UTC (rev 293288)
@@ -1,4 +1,4 @@
-50
+0
 
-FAIL contain-intrinsic-size: auto assert_equals: expected 1 but got 50
+FAIL contain-intrinsic-size: auto assert_equals: expected 1 but got 0
 

Modified: trunk/Source/WebCore/ChangeLog (293287 => 293288)


--- trunk/Source/WebCore/ChangeLog	2022-04-23 06:27:11 UTC (rev 293287)
+++ trunk/Source/WebCore/ChangeLog	2022-04-23 06:44:03 UTC (rev 293288)
@@ -1,3 +1,25 @@
+2022-04-22  Cathie Chen  <[email protected]>
+
+        The layout is not updated when style.contain is changed from "size"/"inline-size" to empty string
+        https://bugs.webkit.org/show_bug.cgi?id=239489
+
+        Reviewed by Rob Buis.
+
+        Unlike "layout", "paint" and "style" containment, being a "size" and "inline-size" containment or not affects the layout size of the element.
+        So it should require layout when a normal element becomes a "size"/"inline-size" containment, vice versa.
+
+        Tests: imported/w3c/web-platform-tests/css/css-contain/contain-inline-size-removed.html
+               imported/w3c/web-platform-tests/css/css-contain/contain-size-removed.html
+
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::rareNonInheritedDataChangeRequiresLayout):
+        (WebCore::RenderStyle::effectiveContainment const): Deleted. Moved to StyleRareNonInheritedData.
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::effectiveContainment const):
+        * rendering/style/StyleRareNonInheritedData.cpp:
+        (WebCore::StyleRareNonInheritedData::effectiveContainment const):
+        * rendering/style/StyleRareNonInheritedData.h:
+
 2022-04-22  Rob Buis  <[email protected]>
 
         Should never be reached failure in WebCore::RenderElement::visibleInViewportStateChanged

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.cpp (293287 => 293288)


--- trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2022-04-23 06:27:11 UTC (rev 293287)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.cpp	2022-04-23 06:44:03 UTC (rev 293288)
@@ -776,6 +776,10 @@
     if (first.inputSecurity != second.inputSecurity)
         return true;
 
+    if (first.effectiveContainment().contains(Containment::Size) != second.effectiveContainment().contains(Containment::Size)
+        || first.effectiveContainment().contains(Containment::InlineSize) != second.effectiveContainment().contains(Containment::InlineSize))
+        return true;
+
     return false;
 }
 
@@ -2894,24 +2898,6 @@
     RELEASE_ASSERT_NOT_REACHED();
 }
 
-OptionSet<Containment> RenderStyle::effectiveContainment() const
-{
-    auto containment = contain();
-
-    switch (containerType()) {
-    case ContainerType::None:
-        break;
-    case ContainerType::Size:
-        containment.add({ Containment::Layout, Containment::Style, Containment::Size });
-        break;
-    case ContainerType::InlineSize:
-        containment.add({ Containment::Layout, Containment::Style, Containment::InlineSize });
-        break;
-    };
-
-    return containment;
-}
-
 UserSelect RenderStyle::effectiveUserSelect() const
 {
     if (effectiveInert())

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (293287 => 293288)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2022-04-23 06:27:11 UTC (rev 293287)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2022-04-23 06:44:03 UTC (rev 293288)
@@ -536,7 +536,7 @@
     }
     bool hasAspectRatio() const { return aspectRatioType() == AspectRatioType::Ratio || aspectRatioType() == AspectRatioType::AutoAndRatio; }
     OptionSet<Containment> contain() const { return m_rareNonInheritedData->contain; }
-    OptionSet<Containment> effectiveContainment() const;
+    OptionSet<Containment> effectiveContainment() const { return m_rareNonInheritedData->effectiveContainment(); }
     bool containsLayout() const { return effectiveContainment().contains(Containment::Layout); }
     bool containsSize() const { return effectiveContainment().contains(Containment::Size); }
     bool containsStyle() const { return effectiveContainment().contains(Containment::Style); }

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp (293287 => 293288)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2022-04-23 06:27:11 UTC (rev 293287)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp	2022-04-23 06:44:03 UTC (rev 293288)
@@ -366,6 +366,24 @@
     return !filter->operations.isEmpty();
 }
 
+OptionSet<Containment> StyleRareNonInheritedData::effectiveContainment() const
+{
+    auto containment = contain;
+
+    switch (static_cast<ContainerType>(containerType)) {
+    case ContainerType::None:
+        break;
+    case ContainerType::Size:
+        containment.add({ Containment::Layout, Containment::Style, Containment::Size });
+        break;
+    case ContainerType::InlineSize:
+        containment.add({ Containment::Layout, Containment::Style, Containment::InlineSize });
+        break;
+    };
+
+    return containment;
+}
+
 #if ENABLE(FILTERS_LEVEL_2)
 
 bool StyleRareNonInheritedData::hasBackdropFilters() const

Modified: trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h (293287 => 293288)


--- trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2022-04-23 06:27:11 UTC (rev 293287)
+++ trunk/Source/WebCore/rendering/style/StyleRareNonInheritedData.h	2022-04-23 06:44:03 UTC (rev 293288)
@@ -104,6 +104,8 @@
 
     bool hasOpacity() const { return opacity < 1; }
 
+    OptionSet<Containment> effectiveContainment() const;
+
     float opacity;
 
     double aspectRatioWidth;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to