Title: [276548] trunk/Source/WebCore
- Revision
- 276548
- Author
- [email protected]
- Date
- 2021-04-24 06:10:44 -0700 (Sat, 24 Apr 2021)
Log Message
[LFC] Ignore content height and width when 'contain: size' is present
https://bugs.webkit.org/show_bug.cgi?id=225013
Reviewed by Antti Koivisto.
Enable size containment for "shrink to fit width" and for "height: auto" formatting context roots.
https://www.w3.org/TR/css-contain-2/#size-containment.
* layout/FormattingContextGeometry.cpp:
(WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const):
(WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (276547 => 276548)
--- trunk/Source/WebCore/ChangeLog 2021-04-24 07:41:54 UTC (rev 276547)
+++ trunk/Source/WebCore/ChangeLog 2021-04-24 13:10:44 UTC (rev 276548)
@@ -1,3 +1,17 @@
+2021-04-24 Zalan Bujtas <[email protected]>
+
+ [LFC] Ignore content height and width when 'contain: size' is present
+ https://bugs.webkit.org/show_bug.cgi?id=225013
+
+ Reviewed by Antti Koivisto.
+
+ Enable size containment for "shrink to fit width" and for "height: auto" formatting context roots.
+ https://www.w3.org/TR/css-contain-2/#size-containment.
+
+ * layout/FormattingContextGeometry.cpp:
+ (WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const):
+ (WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth):
+
2021-04-24 Rob Buis <[email protected]>
Move selectedOptions cache invalidation timing
Modified: trunk/Source/WebCore/layout/FormattingContextGeometry.cpp (276547 => 276548)
--- trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2021-04-24 07:41:54 UTC (rev 276547)
+++ trunk/Source/WebCore/layout/FormattingContextGeometry.cpp 2021-04-24 13:10:44 UTC (rev 276548)
@@ -175,9 +175,13 @@
{
ASSERT(formattingContextRoot.establishesFormattingContext());
ASSERT(isHeightAuto(formattingContextRoot) || formattingContextRoot.establishesTableFormattingContext() || formattingContextRoot.isTableCell());
- if (!formattingContextRoot.hasInFlowOrFloatingChild())
- return { };
- return LayoutContext::createFormattingContext(formattingContextRoot, const_cast<LayoutState&>(layoutState()))->usedContentHeight();
+ auto usedContentHeight = LayoutUnit { };
+ auto hasContent = formattingContextRoot.hasInFlowOrFloatingChild();
+ // The used height of the containment box is determined as if performing a normal layout of the box, except that it is treated as having no content.
+ auto shouldIgnoreContent = formattingContextRoot.isSizeContainmentBox();
+ if (hasContent && !shouldIgnoreContent)
+ usedContentHeight = LayoutContext::createFormattingContext(formattingContextRoot, const_cast<LayoutState&>(layoutState()))->usedContentHeight();
+ return usedContentHeight;
}
Optional<LayoutUnit> FormattingContext::Geometry::computedValue(const Length& geometryProperty, LayoutUnit containingBlockWidth) const
@@ -278,10 +282,10 @@
return left - horizontalConstraints.logicalLeft;
}
-LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(const Box& formattingRoot, LayoutUnit availableWidth)
+LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(const Box& formattingContextRoot, LayoutUnit availableWidth)
{
- LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width] -> shrink to fit -> unsupported -> width(" << LayoutUnit { } << "px) layoutBox: " << &formattingRoot << ")");
- ASSERT(formattingRoot.establishesFormattingContext());
+ LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width] -> shrink to fit -> unsupported -> width(" << LayoutUnit { } << "px) layoutBox: " << &formattingContextRoot << ")");
+ ASSERT(formattingContextRoot.establishesFormattingContext());
// Calculation of the shrink-to-fit width is similar to calculating the width of a table cell using the automatic table layout algorithm.
// Roughly: calculate the preferred width by formatting the content without breaking lines other than where explicit line breaks occur,
@@ -291,8 +295,11 @@
// Then the shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width).
auto intrinsicWidthConstraints = IntrinsicWidthConstraints { };
- if (is<ContainerBox>(formattingRoot) && downcast<ContainerBox>(formattingRoot).hasInFlowOrFloatingChild()) {
- auto& root = downcast<ContainerBox>(formattingRoot);
+ auto hasContent = is<ContainerBox>(formattingContextRoot) && downcast<ContainerBox>(formattingContextRoot).hasInFlowOrFloatingChild();
+ // The used width of the containment box is determined as if performing a normal layout of the box, except that it is treated as having no content.
+ auto shouldIgnoreContent = formattingContextRoot.isSizeContainmentBox();
+ if (hasContent && !shouldIgnoreContent) {
+ auto& root = downcast<ContainerBox>(formattingContextRoot);
auto& formattingStateForRoot = layoutState().ensureFormattingState(root);
auto precomputedIntrinsicWidthConstraints = formattingStateForRoot.intrinsicWidthConstraints();
if (!precomputedIntrinsicWidthConstraints)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes