Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Implement margin-trim for flexbox.
https://bugs.webkit.org/show_bug.cgi?id=249208 rdar://103285847 Reviewed by Alan Baradlay. Adds support for the margin-trim property on flexbox containers. Depending on the values that are set for this property, it will trim the corresponding edges of the flex items that are adjacent to those edges of the container. In order to achieve this, a new data structure, m_marginTrimItems, was added to RenderFlexibleBox. This structure simply holds the items that are trimmed according to their location in the flexbox. The first step of this algorithm is to trim the edges of the first and last child of the flexbox. This is done so that RenderFlexibleBox::computeIntrinsicLogicalWidths does not incorrectly take these margins into consideration when computing the width of the flexbox under a min/max content constraint. In order to figure out which items are actually being trimmed, we cannot perform any trimming until the flex lines are created. As the lines get created in FlexLayoutAlgorithm::computeNextFlexLine, we can trim the main axis margins of the first and last items. This will require not only updating the object's MarginBox but also the main axis sizing information of the flex item itself. In order to do this, we need to make FlexItem's mainAxisMargin mutable. After the line has been constructed, we can trim the cross axis margins of the items if the line is either the first line or last line of the flexbox. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-block-end-trimmed-only-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-block-end-trimmed-only.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-block-start-trimmed-only-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-block-start-trimmed-only.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-block-trimmed-only-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-block-trimmed-only.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-column-block-multiline-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-column-block-multiline.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-column-grow-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-column-grow.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-column-inline-multiline-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-column-inline-multiline.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-column-orthogonal-item-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-column-orthogonal-item.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-column-shrink-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-column-shrink.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-inline-end-trimmed-only-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-inline-end-trimmed-only.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-inline-start-trimmed-only-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-inline-start-trimmed-only.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-inline-trimmed-only-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-inline-trimmed-only.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-row-block-multiline-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-row-block-multiline.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-row-grow-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-row-grow.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-row-inline-multiline-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-row-inline-multiline.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-row-orthogonal-item-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-row-orthogonal-item.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-row-shrink-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-row-shrink.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-trim-all-margins-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-trim-all-margins.html: Added. * LayoutTests/platform/mac/imported/w3c/web-platform-tests/css/css-box/margin-trim/flex-template-expected.txt: Added. * Source/WebCore/rendering/FlexibleBoxAlgorithm.cpp: (WebCore::FlexLayoutAlgorithm::FlexLayoutAlgorithm): (WebCore::FlexLayoutAlgorithm::canFitItemWithTrimmedMarginEnd const): (WebCore::FlexLayoutAlgorithm::removeMarginEndFromFlexSizes const): (WebCore::FlexLayoutAlgorithm::computeNextFlexLine): * Source/WebCore/rendering/FlexibleBoxAlgorithm.h: (WebCore::FlexLayoutAlgorithm::isMultiline const): * Source/WebCore/rendering/RenderBlock.cpp: (WebCore::RenderBlock::marginIntrinsicLogicalWidthForChild const): * Source/WebCore/rendering/RenderBox.cpp: (WebCore::RenderBox::computeLogicalWidthInFragment const): (WebCore::RenderBox::fillAvailableMeasure const): (WebCore::RenderBox::computeOrTrimInlineMargin const): (WebCore::RenderBox::computeInlineDirectionMargins const): * Source/WebCore/rendering/RenderBox.h: * Source/WebCore/rendering/RenderFlexibleBox.cpp: (WebCore::RenderFlexibleBox::layoutBlock): (WebCore::RenderFlexibleBox::initializeMarginTrimState): (WebCore::RenderFlexibleBox::shouldTrimChildMargin const): (WebCore::RenderFlexibleBox::shouldTrimMainAxisMarginStart const): (WebCore::RenderFlexibleBox::shouldTrimMainAxisMarginEnd const): (WebCore::RenderFlexibleBox::shouldTrimCrossAxisMarginStart const): (WebCore::RenderFlexibleBox::shouldTrimCrossAxisMarginEnd const): (WebCore::RenderFlexibleBox::trimMainAxisMarginStart): (WebCore::RenderFlexibleBox::trimMainAxisMarginEnd): (WebCore::RenderFlexibleBox::trimCrossAxisMarginStart): (WebCore::RenderFlexibleBox::trimCrossAxisMarginEnd): (WebCore::RenderFlexibleBox::layoutFlexItems): * Source/WebCore/rendering/RenderFlexibleBox.h: Canonical link: https://commits.webkit.org/258563@main
- Loading branch information