Skip to content

Commit 4b91304

Browse files
alanbaradlayDan Robson
authored and
Dan Robson
committed
Cherry-pick 8b4bbd2. rdar://138343843
[text-box] Make `text-box-edge` inherited per spec update https://bugs.webkit.org/show_bug.cgi?id=281590 rdar://138049359 Reviewed by Antti Koivisto. See w3c/csswg-drafts#10904 1. Make text-box-edge inherited (credit goes to Tim Nguyen) 2. Remove text-box-edge value propagation where we ignore text-box-edge at the trimming site if said trimming is initiated by an ancestors. (test case credit goes to fantasai) * LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/parsing/inheritance-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/parsing/inheritance.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/text-box-trim-accumulation-001-expected.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/text-box-trim-accumulation-001.html: * LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/text-box-trim-not-ignore-nested-text-box-edge-expected.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/text-box-trim-ignore-nested-text-box-edge-expected.html. * LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/text-box-trim-not-ignore-nested-text-box-edge-ref.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/text-box-trim-ignore-nested-text-box-edge-ref.html. * LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/text-box-trim-not-ignore-nested-text-box-edge.html: Renamed from LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/text-box-trim-ignore-nested-text-box-edge.html. * Source/WebCore/css/CSSProperties.json: * Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp: (WebCore::LayoutIntegration::LineLayout::layout): (WebCore::LayoutIntegration::textBoxEdge): Deleted. * Source/WebCore/rendering/RenderLayoutState.h: * Source/WebCore/rendering/TextBoxTrimmer.cpp: (WebCore::TextBoxTrimmer::adjustTextBoxTrimStatusBeforeLayout): * Source/WebCore/rendering/style/RenderStyle.cpp: (WebCore::rareDataChangeRequiresLayout): (WebCore::rareInheritedDataChangeRequiresLayout): (WebCore::RenderStyle::conservativelyCollectChangedAnimatableProperties const): (WebCore::RenderStyle::textBoxEdge const): (WebCore::RenderStyle::setTextBoxEdge): (WebCore::RenderStyle::setLineFitEdge): * Source/WebCore/rendering/style/StyleRareInheritedData.cpp: (WebCore::StyleRareInheritedData::StyleRareInheritedData): (WebCore::StyleRareInheritedData::operator== const): * Source/WebCore/rendering/style/StyleRareInheritedData.h: * Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp: (WebCore::StyleRareNonInheritedData::StyleRareNonInheritedData): (WebCore::StyleRareNonInheritedData::operator== const): * Source/WebCore/rendering/style/StyleRareNonInheritedData.h: Canonical link: https://commits.webkit.org/285489@main Canonical link: https://commits.webkit.org/283286.337@safari-7620-branch
1 parent 9bf1971 commit 4b91304

16 files changed

+55
-66
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
PASS Property text-box-edge has initial value auto
3-
PASS Property text-box-edge does not inherit
3+
PASS Property text-box-edge inherits
44
PASS Property text-box-trim has initial value none
55
PASS Property text-box-trim does not inherit
66

LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/parsing/inheritance.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,6 @@
99
<div id="target">div>
1010
div>
1111
<script>
12-
assert_not_inherited('text-box-edge', 'auto', 'cap');
12+
assert_inherited('text-box-edge', 'auto', 'cap');
1313
assert_not_inherited('text-box-trim', 'none', 'trim-start');
1414
script>
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,23 @@
11
>
2-
<script src="support/variant-class.js">script>
32
<style>
43
@import "support/TestMetricsFont.css";
54

5+
body {
6+
font: 100px/1 MetricsTestFont;
7+
}
68
.spacer {
79
background: lightgray;
810
block-size: 100px;
911
}
10-
.target {
11-
font: 100px/2 MetricsTestFont;
12+
.target-first {
13+
margin-block: -60px 50px;
1214
}
13-
.offset {
14-
position: relative;
15+
.target-second {
16+
margin-block: 50px 0px;
1517
}
16-
.vrl { writing-mode: vertical-rl; }
17-
.vlr { writing-mode: vertical-lr; }
18-
.auto .target, .text .target { line-height: 150px; }
19-
.auto .offset, .text .offset { inset-block-start: -25px; }
20-
.cap .target { line-height: 130px; }
21-
.cap .offset { inset-block-start: -35px; }
22-
.ex .target { line-height: 90px; }
23-
.ex .offset { inset-block-start: -55px; }
24-
.vlr.alphabetic .target { line-height: 130px; }
25-
.vlr.alphabetic .offset { inset-block-start: -35px;}
2618
style>
27-
<div class="text">
2819
<div class="spacer">div>
29-
<div class="target">
30-
<span class="offset">ApÉxspan>
31-
div>
20+
<div class="target-first">ApÉxdiv>
21+
<div class="spacer">div>
22+
<div class="target-second">ApÉx</div>
3223
<div class="spacer">div>
33-
div>

LayoutTests/imported/w3c/web-platform-tests/css/css-inline/text-box-trim/text-box-trim-accumulation-001.html

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
>
2-
<title>Test choosing the innermost for `text-box-trim` for requested trim metrictitle>
2+
<title>Test choosing the correct text-box-edge value for requested trim metrictitle>
33
<link rel="help" href="https://drafts.csswg.org/css-inline-3/#text-box-edge">
44
<link rel="help" href="https://drafts.csswg.org/css-inline-3/#text-box-trim">
55
<meta name="assert"
6-
content="If multiple ancestors specify trimming on the same line box,
7-
the text-box-edge value used is that of the innermost block container
8-
that requests trimming on that side of the line box."
9-
>
6+
content="text-box-edge is an inherited property and trim metric should be used accordingly."
7+
>
108
<link rel="match" href="text-box-trim-start-001-ref.html?class=text">
119
<style>
1210
@import "support/TestMetricsFont.css";
@@ -15,19 +13,33 @@
1513
block-size: 100px;
1614
background: lightgray;
1715
}
18-
.target {
16+
17+
.inner {
1918
font: 100px/2 MetricsTestFont;
2019
}
21-
.target, .outer {
20+
.outer {
2221
text-box-trim: trim-start;
22+
text-box-edge: auto;
23+
}
24+
25+
.middle {
26+
text-box-trim: trim-end;
27+
text-box-edge: text alphabetic;
2328
}
24-
.outer, .inner {
25-
text-box-edge: ex;
29+
30+
.inner:first-child {
31+
text-box-edge: ex alphabetic;
32+
}
33+
34+
.inner:last-child {
35+
text-box-edge: text;
2636
}
2737
style>
2838
<div class="spacer">div>
2939
<div class="outer">
30-
<div class="target">
40+
<div class="middle">
41+
<div class="inner">ApÉxdiv>
42+
<div class="spacer">div>
3143
<div class="inner">ApÉxdiv>
3244
div>
3345
div>
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
>
2-
<title>Consult the block container requesting the trim for text-box-edgetitle>
2+
<title>No need to consult the block container requesting the trim for text-box-edgetitle>
33
<link rel="help" href="https://drafts.csswg.org/css-inline-3/#text-box-trim">
44
<link rel="help" href="https://drafts.csswg.org/css-inline-3/#text-box-edge">
5-
<link rel="match" href="text-box-trim-end-empty-line-001-ref.html">
5+
<link rel="match" href="text-box-trim-not-ignore-nested-text-box-edge-ref.html">
66
<link rel="stylesheet" type="text/css" href="/fonts/ahem.css" />
7+
78
<style>
89
.spacer {
910
background: lightgray;
@@ -12,13 +13,13 @@
1213
.target {
1314
font: 50px/2 Ahem;
1415
text-box-trim: trim-both;
16+
text-box-edge: ex alphabetic;
17+
}
18+
.inner {
1519
text-box-edge: auto;
1620
/* auto keyword uses the value of line-fit-edge on the root inline box of the the affected line box,
1721
interpreting leading (the initial value) as text. */
1822
}
19-
.inner {
20-
text-box-edge: ex alphabetic;
21-
}
2223
style>
2324
<div class="spacer">div>
2425
<div class="target">

Source/WebCore/css/CSSProperties.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -684,7 +684,7 @@
684684
}
685685
},
686686
"text-box-edge": {
687-
"inherited": false,
687+
"inherited": true,
688688
"values": [
689689
"auto",
690690
"text",

Source/WebCore/layout/integration/inline/LayoutIntegrationLineLayout.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -325,16 +325,6 @@ static inline Layout::BlockLayoutState::TextBoxTrim textBoxTrim(const RenderBloc
325325
return textBoxTrimForIFC;
326326
}
327327

328-
static inline TextEdge textBoxEdge(const RenderBlockFlow& rootRenderer)
329-
{
330-
auto* layoutState = rootRenderer.view().frameView().layoutContext().layoutState();
331-
if (!layoutState)
332-
return { };
333-
if (auto textBoxTrim = layoutState->textBoxTrim())
334-
return textBoxTrim->propagatedTextBoxEdge;
335-
return { };
336-
}
337-
338328
static inline std::optional lineGrid(const RenderBlockFlow& rootRenderer)
339329
{
340330
auto& layoutState = *rootRenderer.view().frameView().layoutContext().layoutState();
@@ -402,7 +392,7 @@ std::optional LineLayout::layout()
402392
m_blockFormattingState.placedFloats(),
403393
lineClamp(flow()),
404394
textBoxTrim(flow()),
405-
textBoxEdge(flow()),
395+
flow().style().textBoxEdge(),
406396
intrusiveInitialLetterBottom(),
407397
lineGrid(flow())
408398
};

Source/WebCore/rendering/RenderLayoutState.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ class RenderLayoutState {
4848
public:
4949
struct TextBoxTrim {
5050
bool trimFirstFormattedLine { false };
51-
TextEdge propagatedTextBoxEdge { };
5251
SingleThreadWeakPtr<const RenderBlockFlow> lastFormattedLineRoot;
5352
};
5453

Source/WebCore/rendering/TextBoxTrimmer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ void TextBoxTrimmer::adjustTextBoxTrimStatusBeforeLayout(const RenderBlockFlow*
147147
if (!lastFormattedLineRoot && m_previousTextBoxTrimStatus)
148148
lastFormattedLineRoot = m_previousTextBoxTrimStatus->lastFormattedLineRoot.get();
149149

150-
layoutState.setTextBoxTrim(RenderLayoutState::TextBoxTrim { shouldTrimFirstFormattedLineStart, m_blockContainer->style().textBoxEdge(), lastFormattedLineRoot });
150+
layoutState.setTextBoxTrim(RenderLayoutState::TextBoxTrim { shouldTrimFirstFormattedLineStart, lastFormattedLineRoot });
151151
}
152152

153153
void TextBoxTrimmer::adjustTextBoxTrimStatusAfterLayout()

Source/WebCore/rendering/style/RenderStyle.cpp

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -878,9 +878,6 @@ static bool rareDataChangeRequiresLayout(const StyleRareNonInheritedData& first,
878878
if (first.textBoxTrim != second.textBoxTrim)
879879
return true;
880880

881-
if (first.textBoxEdge != second.textBoxEdge)
882-
return true;
883-
884881
if (first.maxLines != second.maxLines)
885882
return true;
886883

@@ -898,6 +895,7 @@ static bool rareInheritedDataChangeRequiresLayout(const StyleRareInheritedData&
898895
|| first.textAlignLast != second.textAlignLast
899896
|| first.textJustify != second.textJustify
900897
|| first.textIndentLine != second.textIndentLine
898+
|| first.textBoxEdge != second.textBoxEdge
901899
|| first.lineFitEdge != second.lineFitEdge
902900
|| first.usedZoom != second.usedZoom
903901
|| first.textZoom != second.textZoom
@@ -1946,8 +1944,6 @@ void RenderStyle::conservativelyCollectChangedAnimatableProperties(const RenderS
19461944
changingProperties.m_properties.set(CSSPropertyScrollSnapStop);
19471945
if (first.scrollSnapType != second.scrollSnapType)
19481946
changingProperties.m_properties.set(CSSPropertyScrollSnapType);
1949-
if (first.textBoxEdge != second.textBoxEdge)
1950-
changingProperties.m_properties.set(CSSPropertyTextBoxEdge);
19511947
if (first.maxLines != second.maxLines)
19521948
changingProperties.m_properties.set(CSSPropertyMaxLines);
19531949
if (first.overflowContinue != second.overflowContinue)
@@ -2081,6 +2077,8 @@ void RenderStyle::conservativelyCollectChangedAnimatableProperties(const RenderS
20812077
changingProperties.m_properties.set(CSSPropertyImageRendering);
20822078
if (first.textAlignLast != second.textAlignLast)
20832079
changingProperties.m_properties.set(CSSPropertyTextAlignLast);
2080+
if (first.textBoxEdge != second.textBoxEdge)
2081+
changingProperties.m_properties.set(CSSPropertyTextBoxEdge);
20842082
if (first.lineFitEdge != second.lineFitEdge)
20852083
changingProperties.m_properties.set(CSSPropertyLineFitEdge);
20862084
if (first.textJustify != second.textJustify)
@@ -3766,12 +3764,12 @@ bool RenderStyle::hasSnapPosition() const
37663764

37673765
TextEdge RenderStyle::textBoxEdge() const
37683766
{
3769-
return m_nonInheritedData->rareData->textBoxEdge;
3767+
return m_rareInheritedData->textBoxEdge;
37703768
}
37713769

3772-
void RenderStyle::setTextBoxEdge(TextEdge textBoxEdgeValue)
3770+
void RenderStyle::setTextBoxEdge(TextEdge value)
37733771
{
3774-
SET_NESTED_VAR(m_nonInheritedData, rareData, textBoxEdge, textBoxEdgeValue);
3772+
SET_VAR(m_rareInheritedData, textBoxEdge, value);
37753773
}
37763774

37773775
TextEdge RenderStyle::initialTextBoxEdge()
@@ -3784,9 +3782,9 @@ TextEdge RenderStyle::lineFitEdge() const
37843782
return m_rareInheritedData->lineFitEdge;
37853783
}
37863784

3787-
void RenderStyle::setLineFitEdge(TextEdge lineFitEdgeValue)
3785+
void RenderStyle::setLineFitEdge(TextEdge value)
37883786
{
3789-
SET_VAR(m_rareInheritedData, lineFitEdge, lineFitEdgeValue);
3787+
SET_VAR(m_rareInheritedData, lineFitEdge, value);
37903788
}
37913789

37923790
TextEdge RenderStyle::initialLineFitEdge()

Source/WebCore/rendering/style/StyleRareInheritedData.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ StyleRareInheritedData::StyleRareInheritedData()
8787
, indent(RenderStyle::initialTextIndent())
8888
, usedZoom(RenderStyle::initialZoom())
8989
, textUnderlineOffset(RenderStyle::initialTextUnderlineOffset())
90+
, textBoxEdge(RenderStyle::initialTextBoxEdge())
9091
, lineFitEdge(RenderStyle::initialLineFitEdge())
9192
, miterLimit(RenderStyle::initialStrokeMiterLimit())
9293
, customProperties(StyleCustomPropertyData::create())
@@ -182,6 +183,7 @@ inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedDa
182183
, indent(o.indent)
183184
, usedZoom(o.usedZoom)
184185
, textUnderlineOffset(o.textUnderlineOffset)
186+
, textBoxEdge(o.textBoxEdge)
185187
, lineFitEdge(o.lineFitEdge)
186188
, miterLimit(o.miterLimit)
187189
, customProperties(o.customProperties)
@@ -295,6 +297,7 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
295297
&& indent == o.indent
296298
&& usedZoom == o.usedZoom
297299
&& textUnderlineOffset == o.textUnderlineOffset
300+
&& textBoxEdge == o.textBoxEdge
298301
&& lineFitEdge == o.lineFitEdge
299302
&& wordSpacing == o.wordSpacing
300303
&& miterLimit == o.miterLimit

Source/WebCore/rendering/style/StyleRareInheritedData.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ class StyleRareInheritedData : public RefCounted {
9696

9797
TextUnderlineOffset textUnderlineOffset;
9898

99+
TextEdge textBoxEdge;
99100
TextEdge lineFitEdge;
100101

101102
Length wordSpacing;

Source/WebCore/rendering/style/StyleRareNonInheritedData.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ StyleRareNonInheritedData::StyleRareNonInheritedData()
9898
, pseudoElementNameArgument(nullAtom())
9999
, anchorNames(RenderStyle::initialAnchorNames())
100100
, positionAnchor(RenderStyle::initialPositionAnchor())
101-
, textBoxEdge(RenderStyle::initialTextBoxEdge())
102101
, blockStepSize(RenderStyle::initialBlockStepSize())
103102
, blockStepInsert(static_cast<unsigned>(RenderStyle::initialBlockStepInsert()))
104103
, overscrollBehaviorX(static_cast<unsigned>(RenderStyle::initialOverscrollBehaviorX()))
@@ -194,7 +193,6 @@ inline StyleRareNonInheritedData::StyleRareNonInheritedData(const StyleRareNonIn
194193
, pseudoElementNameArgument(o.pseudoElementNameArgument)
195194
, anchorNames(o.anchorNames)
196195
, positionAnchor(o.positionAnchor)
197-
, textBoxEdge(o.textBoxEdge)
198196
, blockStepSize(o.blockStepSize)
199197
, blockStepInsert(o.blockStepInsert)
200198
, overscrollBehaviorX(o.overscrollBehaviorX)
@@ -321,7 +319,6 @@ bool StyleRareNonInheritedData::operator==(const StyleRareNonInheritedData& o) c
321319
&& containIntrinsicHeightType == o.containIntrinsicHeightType
322320
&& containerType == o.containerType
323321
&& textBoxTrim == o.textBoxTrim
324-
&& textBoxEdge == o.textBoxEdge
325322
&& overflowAnchor == o.overflowAnchor
326323
&& viewTransitionClasses == o.viewTransitionClasses
327324
&& viewTransitionName == o.viewTransitionName

Source/WebCore/rendering/style/StyleRareNonInheritedData.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,6 @@ class StyleRareNonInheritedData : public RefCounted {
199199
Vector anchorNames;
200200
AtomString positionAnchor;
201201

202-
TextEdge textBoxEdge;
203-
204202
std::optional blockStepSize;
205203
unsigned blockStepInsert : 1; // BlockStepInsert
206204

0 commit comments

Comments
 (0)