Changeset 276548 in webkit
- Timestamp:
- Apr 24, 2021, 6:10:44 AM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
-
ChangeLog (modified) (1 diff)
-
layout/FormattingContextGeometry.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r276547 r276548 1 2021-04-24 Zalan Bujtas <zalan@apple.com> 2 3 [LFC] Ignore content height and width when 'contain: size' is present 4 https://bugs.webkit.org/show_bug.cgi?id=225013 5 6 Reviewed by Antti Koivisto. 7 8 Enable size containment for "shrink to fit width" and for "height: auto" formatting context roots. 9 https://www.w3.org/TR/css-contain-2/#size-containment. 10 11 * layout/FormattingContextGeometry.cpp: 12 (WebCore::Layout::FormattingContext::Geometry::contentHeightForFormattingContextRoot const): 13 (WebCore::Layout::FormattingContext::Geometry::shrinkToFitWidth): 14 1 15 2021-04-24 Rob Buis <rbuis@igalia.com> 2 16 -
trunk/Source/WebCore/layout/FormattingContextGeometry.cpp
r271085 r276548 176 176 ASSERT(formattingContextRoot.establishesFormattingContext()); 177 177 ASSERT(isHeightAuto(formattingContextRoot) || formattingContextRoot.establishesTableFormattingContext() || formattingContextRoot.isTableCell()); 178 if (!formattingContextRoot.hasInFlowOrFloatingChild()) 179 return { }; 180 return LayoutContext::createFormattingContext(formattingContextRoot, const_cast<LayoutState&>(layoutState()))->usedContentHeight(); 178 auto usedContentHeight = LayoutUnit { }; 179 auto hasContent = formattingContextRoot.hasInFlowOrFloatingChild(); 180 // 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. 181 auto shouldIgnoreContent = formattingContextRoot.isSizeContainmentBox(); 182 if (hasContent && !shouldIgnoreContent) 183 usedContentHeight = LayoutContext::createFormattingContext(formattingContextRoot, const_cast<LayoutState&>(layoutState()))->usedContentHeight(); 184 return usedContentHeight; 181 185 } 182 186 … … 279 283 } 280 284 281 LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(const Box& formatting Root, LayoutUnit availableWidth)282 { 283 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width] -> shrink to fit -> unsupported -> width(" << LayoutUnit { } << "px) layoutBox: " << &formatting Root << ")");284 ASSERT(formatting Root.establishesFormattingContext());285 LayoutUnit FormattingContext::Geometry::shrinkToFitWidth(const Box& formattingContextRoot, LayoutUnit availableWidth) 286 { 287 LOG_WITH_STREAM(FormattingContextLayout, stream << "[Width] -> shrink to fit -> unsupported -> width(" << LayoutUnit { } << "px) layoutBox: " << &formattingContextRoot << ")"); 288 ASSERT(formattingContextRoot.establishesFormattingContext()); 285 289 286 290 // Calculation of the shrink-to-fit width is similar to calculating the width of a table cell using the automatic table layout algorithm. … … 292 296 // Then the shrink-to-fit width is: min(max(preferred minimum width, available width), preferred width). 293 297 auto intrinsicWidthConstraints = IntrinsicWidthConstraints { }; 294 if (is<ContainerBox>(formattingRoot) && downcast<ContainerBox>(formattingRoot).hasInFlowOrFloatingChild()) { 295 auto& root = downcast<ContainerBox>(formattingRoot); 298 auto hasContent = is<ContainerBox>(formattingContextRoot) && downcast<ContainerBox>(formattingContextRoot).hasInFlowOrFloatingChild(); 299 // 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. 300 auto shouldIgnoreContent = formattingContextRoot.isSizeContainmentBox(); 301 if (hasContent && !shouldIgnoreContent) { 302 auto& root = downcast<ContainerBox>(formattingContextRoot); 296 303 auto& formattingStateForRoot = layoutState().ensureFormattingState(root); 297 304 auto precomputedIntrinsicWidthConstraints = formattingStateForRoot.intrinsicWidthConstraints();
Note:
See TracChangeset
for help on using the changeset viewer.