This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse the repository at this point in the history
[margin-trim] block-start margins for grid items in horizontal writin…
…g-mode should be reflected in computed style. https://bugs.webkit.org/show_bug.cgi?id=253716 rdar://106559103 Reviewed by Alan Baradlay. When the block-start margins for grid items that are adjacent to the block-start edge of the grid, We need to set the rare data bits for the item to indicate that the margin has been trimmed. We can then check if this bit is set within ComputedStyleExtractor to get the trimmed value for this margin by directly querying the renderer's m_marginBox. In a horizontal writing mode this bit would correspond to the "top," margin value. For block-start margins, the trimming occurs when a renderer goes through layout and calls RenderBox::constrainBlockMarginInAvailableSpaceOrTrim, which is called from RenderBox::computeBlockDirectionMargins. This function consults the layout system, which is grid in this case, via shouldTrimChildMargin to see if it should trim its margin. If this returns true, then the renderer will not compute the margin and will return 0_lu. We can use this opportunity to set the rare data for the renderer to indicate that this margin has been trimmed. Inside of ComputedStyleExtractor, we need to update rendererCanHaveTrimmedMargin so that this returns true for grid items. This will allow us to do 2 things: 1.) Have isLayoutDependent return true for grid items with margin-trim set on the grid so that layout is forced when checking the "top," margin for grid items 2.) Allow us to call box->hasTrimmedMargin when computing the margin value (since that call is guarded by a call to rendererCanHaveTrimmedMargin) Similarly, there are a couple of other extra pieces of code in RenderBox (particularly in physicalToFlowRelativeDirectionMapping and hasTrimmedMargin) that should now be used with grid items. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/grid-block-start-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/grid-block-start.html: Added. * Source/WebCore/css/ComputedStyleExtractor.cpp: (WebCore::rendererCanHaveTrimmedMargin): (WebCore::isLayoutDependent): * Source/WebCore/rendering/RenderBox.cpp: (WebCore::RenderBox::physicalToFlowRelativeDirectionMapping const): (WebCore::RenderBox::hasTrimmedMargin const): (WebCore::RenderBox::constrainBlockMarginInAvailableSpaceOrTrim const): Canonical link: https://commits.webkit.org/262967@main
- Loading branch information
Showing 4 changed files with 76 additions and 5 deletions.