New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement margin-trim for flexbox. #8166
Implement margin-trim for flexbox. #8166
Conversation
EWS run on previous version of this PR (hash 82aa6fa) |
82aa6fa
to
4e012cf
Compare
EWS run on previous version of this PR (hash 4e012cf) |
4e012cf
to
42fc1e4
Compare
EWS run on previous version of this PR (hash 42fc1e4) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rs=me
it would be great if someone with more extensive flex + margin knowledge could also take a look at it.
42fc1e4
to
1a9552c
Compare
EWS run on current version of this PR (hash 1a9552c) |
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
1a9552c
to
0efe67f
Compare
Committed 258563@main (0efe67f): https://commits.webkit.org/258563@main Reviewed commits have been landed. Closing PR #8166 and removing active labels. |
0efe67f
1a9552c
π π§ͺ winπ gtkπ wincairoπ§ͺ ios-wk2π§ͺ api-macπ§ͺ gtk-wk2π§ͺ api-iosπ§ͺ mac-wk1π§ͺ api-gtkπ tvπ§ͺ mac-AS-debug-wk2π watch-sim