Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Trimmed inline-end margins for flex items in horizontal writing-mode …
…should be reflected in computed style. https://bugs.webkit.org/show_bug.cgi?id=253715 rdar://106559532 Reviewed by Alan Baradlay. When trimming the inline-end margins in RenderFlexibleBox::trimMainAxisMarginEnd and RenderFlexibleBox::trimCrossAxisMarginEnd, instead of trimming the margins there directly, we can replace the trimming with calls to RenderBlock::setTrimmedMarginForChild with MarginTrimType::InlineEnd as an argument. This will both trim the margins by calling setMarginEndForChild and also set the appropriate rare data bit to indicate that the inline-end margin for this box has been trimmed. In horizonal writing modes this bit that is set should refer to margin-right. This can be used after layout has completed to check if a box has a trimmed margin. When ComputedStyleExtractor tries to obtain the "margin-right," value, it will need to check if this margin has been trimmed. This is done by calling RenderBox::hasTrimmedMargin(PhysicalDirection::Right), which will transform this physical direction into a flow relative direction. In horizontal writing mode with LTR direction, the "right," physical direction should correspond to the "inline-end," FlowRelativeDirection. hasTrimmedMargin should then take this new flow relative direction and check to see if the box has this margin marked as trimmed. If this returns true, then this means that the box must have had its margin-right trimmed during layout and ComputedStyleExtractor should consule the box's m_marinBox for the trimmed value. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-end-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-end.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-end-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-end.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-end-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-end.html: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-end-expected.txt: Added. * LayoutTests/imported/w3c/web-platform-tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-end.html: Added. * Source/WebCore/css/ComputedStyleExtractor.cpp: (WebCore::rendererContainingBlockHasMarginTrim): (WebCore::isLayoutDependent): (WebCore::ComputedStyleExtractor::valueForPropertyInStyle): * Source/WebCore/rendering/RenderBlock.cpp: (WebCore::RenderBlock::setTrimmedMarginForChild): * Source/WebCore/rendering/RenderBox.cpp: (WebCore::RenderBox::physicalToFlowRelativeDirectionMapping const): (WebCore::RenderBox::hasTrimmedMargin const): * Source/WebCore/rendering/RenderFlexibleBox.cpp: (WebCore::RenderFlexibleBox::trimMainAxisMarginEnd): (WebCore::RenderFlexibleBox::trimCrossAxisMarginEnd): Canonical link: https://commits.webkit.org/262663@main
- Loading branch information
Showing
12 changed files
with
217 additions
and
12 deletions.
There are no files selected for viewing
5 changes: 5 additions & 0 deletions
5
...sts/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-end-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
PASS flexbox > item 1 | ||
PASS flexbox > item 2 | ||
PASS flexbox > item 3 | ||
|
43 changes: 43 additions & 0 deletions
43
...tform-tests/css/css-box/margin-trim/computed-margin-values/flexbox-column-inline-end.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="author" href="mailto:sammy.gill@apple.com"> | ||
<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex"> | ||
<meta name="assert" content="trimmed inline-end margins should be reflected in computed style"> | ||
<style> | ||
flexbox { | ||
display: flex; | ||
flex-direction: column; | ||
width: min-content; | ||
margin-trim: inline-end; | ||
} | ||
item { | ||
display: block; | ||
background-color: green; | ||
width: 50px; | ||
height: 50px; | ||
} | ||
item:nth-child(1) { | ||
margin-inline-end: 10px; | ||
} | ||
item:nth-child(2) { | ||
margin-inline-end: -10px; | ||
} | ||
item:nth-child(3) { | ||
margin-inline-end: 30%; | ||
} | ||
</style> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/check-layout-th.js"></script> | ||
</head> | ||
<body onload="checkLayout('flexbox > item')"> | ||
<div id="target"> | ||
<flexbox> | ||
<item data-expected-margin-right="0" data-offset-x="8"></item> | ||
<item data-expected-margin-right="0" data-offset-x="8"></item> | ||
<item data-expected-margin-right="0" data-offset-x="8"></item> | ||
</flexbox> | ||
</div> | ||
</body> | ||
</html> |
6 changes: 6 additions & 0 deletions
6
...-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-end-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
PASS flexbox > item 1 | ||
PASS flexbox > item 2 | ||
PASS flexbox > item 3 | ||
PASS flexbox > item 4 | ||
|
38 changes: 38 additions & 0 deletions
38
.../css/css-box/margin-trim/computed-margin-values/flexbox-column-multi-line-inline-end.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="author" href="mailto:sammy.gill@apple.com"> | ||
<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex"> | ||
<meta name="assert" content="trimmed inline-end margins should be reflected in computed style"> | ||
<style> | ||
flexbox { | ||
display: flex; | ||
flex-direction: column; | ||
flex-wrap: wrap; | ||
width: min-content; | ||
height: 100px; | ||
margin-trim: inline-end; | ||
} | ||
item { | ||
display: block; | ||
background-color: green; | ||
width: 50px; | ||
height: 50px; | ||
margin-inline-end: 10px; | ||
} | ||
</style> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/check-layout-th.js"></script> | ||
</head> | ||
<body onload="checkLayout('flexbox > item')"> | ||
<div id="target"> | ||
<flexbox> | ||
<item data-offset-x="8" data-expected-margin-right="10"></item> | ||
<item data-offset-x="8" data-expected-margin-right="10"></item> | ||
<item data-offset-x="68" data-expected-margin-right="0"></item> | ||
<item data-offset-x="68" data-expected-margin-right="0"></item> | ||
</flexbox> | ||
</div> | ||
</body> | ||
</html> |
5 changes: 5 additions & 0 deletions
5
...-tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-end-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
|
||
PASS flexbox > item 1 | ||
PASS flexbox > item 2 | ||
PASS flexbox > item 3 | ||
|
33 changes: 33 additions & 0 deletions
33
...platform-tests/css/css-box/margin-trim/computed-margin-values/flexbox-row-inline-end.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="author" href="mailto:sammy.gill@apple.com"> | ||
<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex"> | ||
<meta name="assert" content="trimmed inline-end margins should be reflected in computed style"> | ||
<style> | ||
flexbox { | ||
display: flex; | ||
margin-trim: inline-end; | ||
} | ||
item { | ||
display: block; | ||
background-color: green; | ||
width: 50px; | ||
height: 50px; | ||
margin-inline-end: 20px; | ||
} | ||
</style> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/check-layout-th.js"></script> | ||
</head> | ||
<body onload="checkLayout('flexbox > item')"> | ||
<div id="target"> | ||
<flexbox> | ||
<item data-expected-margin-right="20" data-offset-x="8"></item> | ||
<item data-expected-margin-right="20" data-offset-x="78"></item> | ||
<item data-expected-margin-right="0" data-offset-x="148"></item> | ||
</flexbox> | ||
</div> | ||
</body> | ||
</html> |
6 changes: 6 additions & 0 deletions
6
...css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-end-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
|
||
PASS flexbox > item 1 | ||
PASS flexbox > item 2 | ||
PASS flexbox > item 3 | ||
PASS flexbox > item 4 | ||
|
47 changes: 47 additions & 0 deletions
47
...sts/css/css-box/margin-trim/computed-margin-values/flexbox-row-multi-line-inline-end.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<link rel="author" href="mailto:sammy.gill@apple.com"> | ||
<link rel="help" href="https://drafts.csswg.org/css-box-4/#margin-trim-flex"> | ||
<meta name="assert" content="trimmed inline-end margins should be reflected in computed style"> | ||
<style> | ||
flexbox { | ||
display: flex; | ||
width: 110px; | ||
flex-wrap: wrap; | ||
margin-trim: inline-end; | ||
} | ||
item { | ||
display: block; | ||
background-color: green; | ||
width: 50px; | ||
height: 50px; | ||
} | ||
item:nth-child(1) { | ||
margin-inline-end: 10px; | ||
} | ||
item:nth-child(2) { | ||
margin-inline-end: -10px; | ||
} | ||
item:nth-child(3) { | ||
margin-inline-end: 10px; | ||
} | ||
item:nth-child(4) { | ||
margin-inline-end: 50%; | ||
} | ||
</style> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/resources/check-layout-th.js"></script> | ||
</head> | ||
<body onload="checkLayout('flexbox > item')"> | ||
<div id="target"> | ||
<flexbox> | ||
<item data-expected-margin-right="10" data-offset-x="8"></item> | ||
<item data-expected-margin-right="0" data-offset-x="68"></item> | ||
<item data-expected-margin-right="10" data-offset-x="8"></item> | ||
<item data-expected-margin-right="0" data-offset-x="68"></item> | ||
</flexbox> | ||
</div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters