[CSS Container Queries] container-type property should establish containment for 'size' and 'inline-size' values
https://bugs.webkit.org/show_bug.cgi?id=235638
Reviewed by Dean Jackson.
LayoutTests/imported/w3c:
* web-platform-tests/css/css-contain/container-queries/container-type-containment-expected.txt:
* web-platform-tests/css/css-contain/container-queries/container-type-layout-invalidation-expected.txt:
Source/WebCore:
https://drafts.csswg.org/css-contain-3/#container-type
* layout/layouttree/LayoutBox.cpp:
(WebCore::Layout::Box::isLayoutContainmentBox const):
(WebCore::Layout::Box::isSizeContainmentBox const):
* rendering/RenderObject.cpp:
(WebCore::shouldApplyAnyContainment):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::effectiveContainment const):
Add effectiveContaiment function add use it in most places instead of accessing contain()
property value directly.
Apply appropriate containment for container-type. Note that 'inline-size' containment is not
supported yet.
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::containsLayout const):
(WebCore::RenderStyle::containsSize const):
(WebCore::RenderStyle::containsStyle const):
(WebCore::RenderStyle::containsPaint const):
LayoutTests:
* TestExpectations:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@288627 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog
index 8bf660c..3d5dee1 100644
--- a/LayoutTests/ChangeLog
+++ b/LayoutTests/ChangeLog
@@ -1,3 +1,12 @@
+2022-01-26 Antti Koivisto <antti@apple.com>
+
+ [CSS Container Queries] container-type property should establish containment for 'size' and 'inline-size' values
+ https://bugs.webkit.org/show_bug.cgi?id=235638
+
+ Reviewed by Dean Jackson.
+
+ * TestExpectations:
+
2022-01-26 Antoine Quint <graouts@webkit.org>
[Web Inspector] Graphics tab should display pseudo-elements for more than ::before and ::after
diff --git a/LayoutTests/TestExpectations b/LayoutTests/TestExpectations
index eda57a7..be463d3 100644
--- a/LayoutTests/TestExpectations
+++ b/LayoutTests/TestExpectations
@@ -4808,7 +4808,6 @@
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/counters-in-container.html [ ImageOnlyFailure ]
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/display-in-container.html [ ImageOnlyFailure ]
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/fieldset-legend-change.html [ ImageOnlyFailure ]
-webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/inline-size-bfc-floats.html [ ImageOnlyFailure ]
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/multicol-inside-container.html [ ImageOnlyFailure ]
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/pseudo-elements-002.tentative.html [ ImageOnlyFailure ]
webkit.org/b/229659 imported/w3c/web-platform-tests/css/css-contain/container-queries/resize-while-content-visibility-hidden.html [ ImageOnlyFailure ]
diff --git a/LayoutTests/imported/w3c/ChangeLog b/LayoutTests/imported/w3c/ChangeLog
index 05529ed..b171727 100644
--- a/LayoutTests/imported/w3c/ChangeLog
+++ b/LayoutTests/imported/w3c/ChangeLog
@@ -1,3 +1,13 @@
+2022-01-26 Antti Koivisto <antti@apple.com>
+
+ [CSS Container Queries] container-type property should establish containment for 'size' and 'inline-size' values
+ https://bugs.webkit.org/show_bug.cgi?id=235638
+
+ Reviewed by Dean Jackson.
+
+ * web-platform-tests/css/css-contain/container-queries/container-type-containment-expected.txt:
+ * web-platform-tests/css/css-contain/container-queries/container-type-layout-invalidation-expected.txt:
+
2022-01-26 Youenn Fablet <youenn@apple.com>
Rebase WPT streams tests up to 8d1dc42
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-containment-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-containment-expected.txt
index 4869ea5..ea80c7f 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-containment-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-containment-expected.txt
@@ -1,8 +1,8 @@
AA
A
-FAIL container-type:inline-size turns on layout containment assert_equals: expected 33 but got 8
+PASS container-type:inline-size turns on layout containment
FAIL container-type:inline-size turns on inline-size containment assert_equals: expected 0 but got 12
-FAIL container-type:size turns on full size containment assert_equals: expected 0 but got 18
+PASS container-type:size turns on full size containment
PASS container-type:inline/size turns on style containment
diff --git a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-layout-invalidation-expected.txt b/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-layout-invalidation-expected.txt
index 3b774e7..cc8c454 100644
--- a/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-layout-invalidation-expected.txt
+++ b/LayoutTests/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-layout-invalidation-expected.txt
@@ -1,4 +1,4 @@
content
-FAIL Changing container-type invalidates layout assert_equals: expected 0 but got 47
+PASS Changing container-type invalidates layout
diff --git a/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-containment-expected.txt b/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-containment-expected.txt
deleted file mode 100644
index 09be5da..0000000
--- a/LayoutTests/platform/ios/imported/w3c/web-platform-tests/css/css-contain/container-queries/container-type-containment-expected.txt
+++ /dev/null
@@ -1,8 +0,0 @@
-AA
-A
-
-FAIL container-type:inline-size turns on layout containment assert_equals: expected 33 but got 8
-FAIL container-type:inline-size turns on inline-size containment assert_equals: expected 0 but got 12
-FAIL container-type:size turns on full size containment assert_equals: expected 0 but got 20
-PASS container-type:inline/size turns on style containment
-
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index d1c441c..ffc3c83 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,32 @@
+2022-01-26 Antti Koivisto <antti@apple.com>
+
+ [CSS Container Queries] container-type property should establish containment for 'size' and 'inline-size' values
+ https://bugs.webkit.org/show_bug.cgi?id=235638
+
+ Reviewed by Dean Jackson.
+
+ https://drafts.csswg.org/css-contain-3/#container-type
+
+ * layout/layouttree/LayoutBox.cpp:
+ (WebCore::Layout::Box::isLayoutContainmentBox const):
+ (WebCore::Layout::Box::isSizeContainmentBox const):
+ * rendering/RenderObject.cpp:
+ (WebCore::shouldApplyAnyContainment):
+ * rendering/style/RenderStyle.cpp:
+ (WebCore::RenderStyle::effectiveContainment const):
+
+ Add effectiveContaiment function add use it in most places instead of accessing contain()
+ property value directly.
+
+ Apply appropriate containment for container-type. Note that 'inline-size' containment is not
+ supported yet.
+
+ * rendering/style/RenderStyle.h:
+ (WebCore::RenderStyle::containsLayout const):
+ (WebCore::RenderStyle::containsSize const):
+ (WebCore::RenderStyle::containsStyle const):
+ (WebCore::RenderStyle::containsPaint const):
+
2022-01-26 Antoine Quint <graouts@webkit.org>
[Web Inspector] Graphics tab should display pseudo-elements for more than ::before and ::after
diff --git a/Source/WebCore/layout/layouttree/LayoutBox.cpp b/Source/WebCore/layout/layouttree/LayoutBox.cpp
index 5de1bff..35a5ce4 100644
--- a/Source/WebCore/layout/layouttree/LayoutBox.cpp
+++ b/Source/WebCore/layout/layouttree/LayoutBox.cpp
@@ -389,7 +389,7 @@
return isAtomicInlineLevelBox();
return true;
};
- return m_style.contain().contains(Containment::Layout) && supportsLayoutContainment();
+ return m_style.effectiveContainment().contains(Containment::Layout) && supportsLayoutContainment();
}
bool Box::isSizeContainmentBox() const
@@ -406,7 +406,7 @@
return isAtomicInlineLevelBox();
return true;
};
- return m_style.contain().contains(Containment::Size) && supportsSizeContainment();
+ return m_style.effectiveContainment().contains(Containment::Size) && supportsSizeContainment();
}
bool Box::isInternalTableBox() const
diff --git a/Source/WebCore/rendering/RenderObject.cpp b/Source/WebCore/rendering/RenderObject.cpp
index 72a6667..b4b6710 100644
--- a/Source/WebCore/rendering/RenderObject.cpp
+++ b/Source/WebCore/rendering/RenderObject.cpp
@@ -2622,7 +2622,7 @@
bool WebCore::shouldApplyAnyContainment(const WebCore::RenderObject& renderer)
{
- if (renderer.style().contain().isEmpty())
+ if (renderer.style().effectiveContainment().isEmpty())
return false;
if ((renderer.style().containsLayout() || renderer.style().containsPaint()) && (!renderer.isInline() || renderer.isAtomicInlineLevelBox()) && !renderer.isRubyText() && (!renderer.isTablePart() || renderer.isRenderBlockFlow()))
return true;
diff --git a/Source/WebCore/rendering/style/RenderStyle.cpp b/Source/WebCore/rendering/style/RenderStyle.cpp
index ad5abad..35a26ac 100644
--- a/Source/WebCore/rendering/style/RenderStyle.cpp
+++ b/Source/WebCore/rendering/style/RenderStyle.cpp
@@ -2818,4 +2818,25 @@
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:
+ // FIXME: Support inline-size containment.
+ containment.add({ Containment::Layout, Containment::Style });
+ break;
+ };
+
+ return containment;
+}
+
+
} // namespace WebCore
diff --git a/Source/WebCore/rendering/style/RenderStyle.h b/Source/WebCore/rendering/style/RenderStyle.h
index 7324469..4887517 100644
--- a/Source/WebCore/rendering/style/RenderStyle.h
+++ b/Source/WebCore/rendering/style/RenderStyle.h
@@ -528,10 +528,11 @@
}
bool hasAspectRatio() const { return aspectRatioType() == AspectRatioType::Ratio || aspectRatioType() == AspectRatioType::AutoAndRatio; }
OptionSet<Containment> contain() const { return m_rareNonInheritedData->contain; }
- bool containsLayout() const { return m_rareNonInheritedData->contain.contains(Containment::Layout); }
- bool containsSize() const { return m_rareNonInheritedData->contain.contains(Containment::Size); }
- bool containsStyle() const { return m_rareNonInheritedData->contain.contains(Containment::Style); }
- bool containsPaint() const { return m_rareNonInheritedData->contain.contains(Containment::Paint); }
+ OptionSet<Containment> effectiveContainment() const;
+ bool containsLayout() const { return effectiveContainment().contains(Containment::Layout); }
+ bool containsSize() const { return effectiveContainment().contains(Containment::Size); }
+ bool containsStyle() const { return effectiveContainment().contains(Containment::Style); }
+ bool containsPaint() const { return effectiveContainment().contains(Containment::Paint); }
ContainerType containerType() const { return static_cast<ContainerType>(m_rareNonInheritedData->containerType); }
const Vector<AtomString>& containerNames() const { return m_rareNonInheritedData->containerNames; }
BoxAlignment boxAlign() const { return static_cast<BoxAlignment>(m_rareNonInheritedData->deprecatedFlexibleBox->align); }