Skip to content

Commit e96f861

Browse files
committed
[field-sizing] Larger placeholder font-size should expand the field
https://bugs.webkit.org/show_bug.cgi?id=269127 Reviewed by Antti Koivisto. RenderTextControl::computeLogicalHeight is supposed to return a hugging size when field-sizing is on. It essentially means stretching the height to the size of its content. Normally (bfc) computeLogicalHeight happens on the "way back", meaning that the renderer's subtree is laid out by then and we could just consult the placeholder's content height. While placeholder is part of the text control's subtree, it is an excluded renderer (not taking in-flow space, positioned by hand) and we don't lay it out until after we start positioning the inner renderer(s) for the input _after_ layout (still in RenderTextControlSingleLine::layout though) This fix initiates layout on this excluded placeholder in ::layoutExcludedChildren (duh), and includes its height when computing the input box's final height. * LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-number-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-text-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-placeholder-stretch-expected.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-placeholder-stretch-ref.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-placeholder-stretch.html: Added. * LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea-expected.txt: * LayoutTests/platform/ios-18/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea-expected.txt: * LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-number-expected.txt: * LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-text-expected.txt: * LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea-expected.txt: * LayoutTests/platform/mac-sequoia-wk2/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-number-expected.txt: * LayoutTests/platform/mac-wk2/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-number-expected.txt: * Source/WebCore/rendering/RenderTextControl.cpp: (WebCore::RenderTextControl::computeLogicalHeight const): (WebCore::RenderTextControl::layoutExcludedChildren): Canonical link: https://commits.webkit.org/299672@main
1 parent 36a28ec commit e96f861

File tree

13 files changed

+93
-25
lines changed

13 files changed

+93
-25
lines changed

LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-number-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ PASS number: Explicit width and height
66
PASS number: Explicit width and auto height
77
PASS number: Explicit height and auto width
88
PASS number: Text caret is taller than the placeholder
9-
FAIL number: Text caret is shorter than the placeholder assert_less_than: expected a number less than 36 but got 36
9+
PASS number: Text caret is shorter than the placeholder
1010
PASS number: Update field-sizing property dynamically
1111

LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-text-expected.txt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PASS text: Explicit width and heigth
77
PASS text: Explicit width and auto height
88
PASS text: Explicit height and auto width
99
PASS text: Text caret is taller than the placeholder
10-
FAIL text: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
10+
PASS text: Text caret is shorter than the placeholder
1111
PASS text: Update field-sizing property dynamically
1212
PASS search: Empty value
1313
PASS search: Empty value with a size atttribute
@@ -25,7 +25,7 @@ PASS tel: Explicit width and heigth
2525
PASS tel: Explicit width and auto height
2626
PASS tel: Explicit height and auto width
2727
PASS tel: Text caret is taller than the placeholder
28-
FAIL tel: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
28+
PASS tel: Text caret is shorter than the placeholder
2929
PASS tel: Update field-sizing property dynamically
3030
PASS url: Empty value
3131
PASS url: Empty value with a size atttribute
@@ -34,7 +34,7 @@ PASS url: Explicit width and heigth
3434
PASS url: Explicit width and auto height
3535
PASS url: Explicit height and auto width
3636
PASS url: Text caret is taller than the placeholder
37-
FAIL url: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
37+
PASS url: Text caret is shorter than the placeholder
3838
PASS url: Update field-sizing property dynamically
3939
PASS email: Empty value
4040
PASS email: Empty value with a size atttribute
@@ -43,7 +43,7 @@ PASS email: Explicit width and heigth
4343
PASS email: Explicit width and auto height
4444
PASS email: Explicit height and auto width
4545
PASS email: Text caret is taller than the placeholder
46-
FAIL email: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
46+
PASS email: Text caret is shorter than the placeholder
4747
PASS email: Update field-sizing property dynamically
4848
PASS password: Empty value
4949
PASS password: Empty value with a size atttribute
@@ -52,6 +52,6 @@ PASS password: Explicit width and heigth
5252
PASS password: Explicit width and auto height
5353
PASS password: Explicit height and auto width
5454
PASS password: Text caret is taller than the placeholder
55-
FAIL password: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
55+
PASS password: Text caret is shorter than the placeholder
5656
PASS password: Update field-sizing property dynamically
5757

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<style>
3+
input {
4+
padding: 0px;
5+
border: none;
6+
font-size: 30px;
7+
color: green;
8+
font-family: Ahem;
9+
}
10+
</style>
11+
<input value="PASS if not clipped">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<!DOCTYPE html>
2+
<style>
3+
input {
4+
padding: 0px;
5+
border: none;
6+
font-size: 30px;
7+
color: green;
8+
font-family: Ahem;
9+
}
10+
</style>
11+
<input value="PASS if not clipped">
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<!DOCTYPE html>
2+
<title>Placeholder should stretch input when field-sizing is applied.</title>
3+
<link rel="help" href="https://drafts.csswg.org/css-ui-4/#field-sizing">
4+
<link rel=match href="field-sizing-placeholder-stretch-ref.html">
5+
<link rel="stylesheet" href="/fonts/ahem.css">
6+
7+
<style>
8+
::placeholder {
9+
font-size: 30px;
10+
color: green;
11+
font-family: Ahem;
12+
}
13+
input {
14+
field-sizing: content;
15+
padding: 0px;
16+
border: none;
17+
}
18+
</style>
19+
<input placeholder="PASS if not clipped">
20+
<input style="height: 0px;" placeholder="PASS fully clipped">

LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea-expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ PASS Empty value
44
PASS Empty value with cols/rows
55
PASS Auto width and auto height with a long text
66
PASS Explicit width and heigth
7-
FAIL Explicit width and auto height assert_greater_than: expected a number greater than 32 but got 19
7+
PASS Explicit width and auto height
88
PASS Explicit height and auto width
99
PASS Text caret is taller than the placeholder
10-
FAIL Text caret is shorter than the placeholder assert_less_than: height expected a number less than 29 but got 29
10+
PASS Text caret is shorter than the placeholder
1111
PASS Update field-sizing property dynamically
1212

LayoutTests/platform/ios-18/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea-expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ PASS Empty value
44
PASS Empty value with cols/rows
55
PASS Auto width and auto height with a long text
66
PASS Explicit width and heigth
7-
FAIL Explicit width and auto height assert_greater_than: expected a number greater than 30 but got 18
7+
PASS Explicit width and auto height
88
PASS Explicit height and auto width
99
PASS Text caret is taller than the placeholder
10-
FAIL Text caret is shorter than the placeholder assert_less_than: height expected a number less than 27 but got 27
10+
PASS Text caret is shorter than the placeholder
1111
PASS Update field-sizing property dynamically
1212

LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-number-expected.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ PASS number: Explicit width and height
66
PASS number: Explicit width and auto height
77
PASS number: Explicit height and auto width
88
PASS number: Text caret is taller than the placeholder
9-
FAIL number: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
9+
PASS number: Text caret is shorter than the placeholder
1010
PASS number: Update field-sizing property dynamically
1111

LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-text-expected.txt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ PASS text: Explicit width and heigth
77
PASS text: Explicit width and auto height
88
PASS text: Explicit height and auto width
99
PASS text: Text caret is taller than the placeholder
10-
FAIL text: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
10+
PASS text: Text caret is shorter than the placeholder
1111
PASS text: Update field-sizing property dynamically
1212
PASS search: Empty value
1313
PASS search: Empty value with a size atttribute
@@ -16,7 +16,7 @@ PASS search: Explicit width and heigth
1616
PASS search: Explicit width and auto height
1717
PASS search: Explicit height and auto width
1818
PASS search: Text caret is taller than the placeholder
19-
FAIL search: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
19+
PASS search: Text caret is shorter than the placeholder
2020
PASS search: Update field-sizing property dynamically
2121
PASS tel: Empty value
2222
PASS tel: Empty value with a size atttribute
@@ -25,7 +25,7 @@ PASS tel: Explicit width and heigth
2525
PASS tel: Explicit width and auto height
2626
PASS tel: Explicit height and auto width
2727
PASS tel: Text caret is taller than the placeholder
28-
FAIL tel: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
28+
PASS tel: Text caret is shorter than the placeholder
2929
PASS tel: Update field-sizing property dynamically
3030
PASS url: Empty value
3131
PASS url: Empty value with a size atttribute
@@ -34,7 +34,7 @@ PASS url: Explicit width and heigth
3434
PASS url: Explicit width and auto height
3535
PASS url: Explicit height and auto width
3636
PASS url: Text caret is taller than the placeholder
37-
FAIL url: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
37+
PASS url: Text caret is shorter than the placeholder
3838
PASS url: Update field-sizing property dynamically
3939
PASS email: Empty value
4040
PASS email: Empty value with a size atttribute
@@ -43,7 +43,7 @@ PASS email: Explicit width and heigth
4343
PASS email: Explicit width and auto height
4444
PASS email: Explicit height and auto width
4545
PASS email: Text caret is taller than the placeholder
46-
FAIL email: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
46+
PASS email: Text caret is shorter than the placeholder
4747
PASS email: Update field-sizing property dynamically
4848
PASS password: Empty value
4949
PASS password: Empty value with a size atttribute
@@ -52,6 +52,6 @@ PASS password: Explicit width and heigth
5252
PASS password: Explicit width and auto height
5353
PASS password: Explicit height and auto width
5454
PASS password: Text caret is taller than the placeholder
55-
FAIL password: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
55+
PASS password: Text caret is shorter than the placeholder
5656
PASS password: Update field-sizing property dynamically
5757

LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea-expected.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ PASS Empty value
44
PASS Empty value with cols/rows
55
PASS Auto width and auto height with a long text
66
PASS Explicit width and heigth
7-
FAIL Explicit width and auto height assert_greater_than: expected a number greater than 30 but got 18
7+
PASS Explicit width and auto height
88
PASS Explicit height and auto width
99
PASS Text caret is taller than the placeholder
10-
FAIL Text caret is shorter than the placeholder assert_less_than: height expected a number less than 33 but got 33
10+
PASS Text caret is shorter than the placeholder
1111
PASS Update field-sizing property dynamically
1212

0 commit comments

Comments
 (0)