Skip to content

Commit

Permalink
Implement field-sizing support for input and textarea
Browse files Browse the repository at this point in the history
https://bugs.webkit.org/show_bug.cgi?id=269125

Reviewed by Aditya Keerthi.

Inputs and textareas with field-sizing: content now size based on their content size not intrinsic.

This patch does not include the handling for caret width, autofill, or placeholders.

* LayoutTests/TestExpectations:
* 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-textarea-expected.txt:
* LayoutTests/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea.html:
* LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-number-expected.txt: Added.
* LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-text-expected.txt: Added.
* LayoutTests/platform/gtk/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea-expected.txt: Added.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-number-expected.txt: Added.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-text-expected.txt: Added.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-select-expected.txt: Added.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-select.tentative-expected.txt: Removed.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea-expected.txt: Added.
* LayoutTests/platform/ios/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea.tentative-expected.txt: Removed.
* LayoutTests/platform/mac-monterey/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-text-expected.txt: Added.
* LayoutTests/platform/wpe/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-number-expected.txt: Added.
* LayoutTests/platform/wpe/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-text-expected.txt: Added.
* LayoutTests/platform/wpe/imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea-expected.txt: Added.
* Source/WebCore/rendering/RenderTextControl.cpp:
(WebCore::RenderTextControl::computeLogicalHeight const):
(WebCore::RenderTextControl::computeIntrinsicLogicalWidths const):
(WebCore::RenderTextControl::computePreferredLogicalWidths):

Canonical link: https://commits.webkit.org/275649@main
  • Loading branch information
lukewarlow committed Mar 4, 2024
1 parent c87270c commit bcca5fc
Show file tree
Hide file tree
Showing 19 changed files with 368 additions and 72 deletions.
5 changes: 0 additions & 5 deletions LayoutTests/TestExpectations
Original file line number Diff line number Diff line change
Expand Up @@ -1072,11 +1072,6 @@ imported/w3c/web-platform-tests/css/css-ui/caret-color-020.html [ Skip ]
# Dump console messages to stderr for all the imported Content Security Policy tests to avoid flakiness.
imported/w3c/web-platform-tests/content-security-policy [ DumpJSConsoleLogInStdErr ]

# field-sizing is not supported
imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-number.html [ Skip ]
imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-input-text.html [ Skip ]
imported/w3c/web-platform-tests/html/rendering/widgets/field-sizing-textarea.html [ Skip ]

# FIXME: Skip Content Security Policy tests that are dumping the render tree instead of text:
imported/w3c/web-platform-tests/content-security-policy/svg/scripted.svg [ Skip ]
imported/w3c/web-platform-tests/content-security-policy/svg/including.sub.svg [ Skip ]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@


FAIL number: Empty value assert_less_than: expected a number less than 148 but got 148
FAIL number: Auto width and auto height with a long text assert_greater_than: expected a number greater than 148 but got 148
FAIL number: Empty value assert_equals: expected 19 but got 23
PASS number: Auto width and auto height with a long text
PASS number: Explicit width and heigth
PASS number: Explicit width and auto height
FAIL number: Explicit height and auto width assert_less_than: expected a number less than 148 but got 148
FAIL number: Text caret is taller than the placeholder assert_less_than: expected a number less than 404 but got 404
FAIL number: Text caret is shorter than the placeholder assert_less_than: expected a number less than 249 but got 249
FAIL number: Update field-sizing property dynamically assert_less_than: expected a number less than 148 but got 148
FAIL number: Explicit width and auto height assert_equals: expected 19 but got 23
PASS number: Explicit height and auto width
PASS number: Text caret is taller than the placeholder
FAIL number: Text caret is shorter than the placeholder assert_less_than: expected a number less than 36 but got 36
FAIL number: Update field-sizing property dynamically assert_equals: expected 19 but got 23

Original file line number Diff line number Diff line change
@@ -1,57 +1,57 @@


FAIL text: Empty value assert_less_than: expected a number less than 148 but got 148
FAIL text: Empty value with a size atttribute assert_less_than: expected a number less than 78 but got 78
FAIL text: Auto width and auto height with a long text assert_greater_than: expected a number greater than 148 but got 148
PASS text: Empty value
PASS text: Empty value with a size atttribute
PASS text: Auto width and auto height with a long text
PASS text: Explicit width and heigth
PASS text: Explicit width and auto height
FAIL text: Explicit height and auto width assert_less_than: expected a number less than 148 but got 148
FAIL text: Text caret is taller than the placeholder assert_less_than: expected a number less than 404 but got 404
FAIL text: Text caret is shorter than the placeholder assert_less_than: expected a number less than 249 but got 249
PASS text: Explicit height and auto width
PASS text: Text caret is taller than the placeholder
FAIL text: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL text: Update field-sizing property dynamically assert_less_than: expected a number less than 148 but got 148
FAIL search: Empty value assert_less_than: expected a number less than 148 but got 148
FAIL search: Empty value with a size atttribute assert_less_than: expected a number less than 105 but got 105
FAIL search: Auto width and auto height with a long text assert_greater_than: expected a number greater than 148 but got 148
PASS search: Empty value
PASS search: Empty value with a size atttribute
PASS search: Auto width and auto height with a long text
PASS search: Explicit width and heigth
PASS search: Explicit width and auto height
FAIL search: Explicit height and auto width assert_less_than: expected a number less than 148 but got 148
FAIL search: Text caret is taller than the placeholder assert_less_than: expected a number less than 170 but got 170
FAIL search: Text caret is shorter than the placeholder assert_less_than: expected a number less than 170 but got 170
PASS search: Explicit height and auto width
PASS search: Text caret is taller than the placeholder
FAIL search: Text caret is shorter than the placeholder assert_less_than: expected a number less than 19 but got 19
FAIL search: Update field-sizing property dynamically assert_less_than: expected a number less than 148 but got 148
FAIL tel: Empty value assert_less_than: expected a number less than 148 but got 148
FAIL tel: Empty value with a size atttribute assert_less_than: expected a number less than 78 but got 78
FAIL tel: Auto width and auto height with a long text assert_greater_than: expected a number greater than 148 but got 148
PASS tel: Empty value
PASS tel: Empty value with a size atttribute
PASS tel: Auto width and auto height with a long text
PASS tel: Explicit width and heigth
PASS tel: Explicit width and auto height
FAIL tel: Explicit height and auto width assert_less_than: expected a number less than 148 but got 148
FAIL tel: Text caret is taller than the placeholder assert_less_than: expected a number less than 404 but got 404
FAIL tel: Text caret is shorter than the placeholder assert_less_than: expected a number less than 249 but got 249
PASS tel: Explicit height and auto width
PASS tel: Text caret is taller than the placeholder
FAIL tel: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL tel: Update field-sizing property dynamically assert_less_than: expected a number less than 148 but got 148
FAIL url: Empty value assert_less_than: expected a number less than 148 but got 148
FAIL url: Empty value with a size atttribute assert_less_than: expected a number less than 78 but got 78
FAIL url: Auto width and auto height with a long text assert_greater_than: expected a number greater than 148 but got 148
PASS url: Empty value
PASS url: Empty value with a size atttribute
PASS url: Auto width and auto height with a long text
PASS url: Explicit width and heigth
PASS url: Explicit width and auto height
FAIL url: Explicit height and auto width assert_less_than: expected a number less than 148 but got 148
FAIL url: Text caret is taller than the placeholder assert_less_than: expected a number less than 404 but got 404
FAIL url: Text caret is shorter than the placeholder assert_less_than: expected a number less than 249 but got 249
PASS url: Explicit height and auto width
PASS url: Text caret is taller than the placeholder
FAIL url: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL url: Update field-sizing property dynamically assert_less_than: expected a number less than 148 but got 148
FAIL email: Empty value assert_less_than: expected a number less than 148 but got 148
FAIL email: Empty value with a size atttribute assert_less_than: expected a number less than 78 but got 78
FAIL email: Auto width and auto height with a long text assert_greater_than: expected a number greater than 148 but got 148
PASS email: Empty value
PASS email: Empty value with a size atttribute
PASS email: Auto width and auto height with a long text
PASS email: Explicit width and heigth
PASS email: Explicit width and auto height
FAIL email: Explicit height and auto width assert_less_than: expected a number less than 148 but got 148
FAIL email: Text caret is taller than the placeholder assert_less_than: expected a number less than 404 but got 404
FAIL email: Text caret is shorter than the placeholder assert_less_than: expected a number less than 249 but got 249
PASS email: Explicit height and auto width
PASS email: Text caret is taller than the placeholder
FAIL email: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL email: Update field-sizing property dynamically assert_less_than: expected a number less than 148 but got 148
FAIL password: Empty value assert_less_than: expected a number less than 148 but got 148
FAIL password: Empty value with a size atttribute assert_less_than: expected a number less than 78 but got 78
FAIL password: Auto width and auto height with a long text assert_greater_than: expected a number greater than 148 but got 148
PASS password: Empty value
PASS password: Empty value with a size atttribute
PASS password: Auto width and auto height with a long text
PASS password: Explicit width and heigth
PASS password: Explicit width and auto height
FAIL password: Explicit height and auto width assert_less_than: expected a number less than 148 but got 148
FAIL password: Text caret is taller than the placeholder assert_less_than: expected a number less than 404 but got 404
FAIL password: Text caret is shorter than the placeholder assert_less_than: expected a number less than 249 but got 249
PASS password: Explicit height and auto width
PASS password: Text caret is taller than the placeholder
FAIL password: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL password: Update field-sizing property dynamically assert_less_than: expected a number less than 148 but got 148

Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@


FAIL Empty value assert_less_than: expected a number less than 161 but got 161
FAIL Empty value with cols/rows assert_less_than: expected a number less than 91 but got 91
FAIL Auto width and auto height with a long text assert_greater_than: expected a number greater than 161 but got 161
PASS Empty value
PASS Empty value with cols/rows
PASS Auto width and auto height with a long text
PASS Explicit width and heigth
FAIL Explicit width and auto height assert_less_than: expected a number less than 32 but got 32
FAIL Explicit height and auto width assert_less_than: expected a number less than 161 but got 161
FAIL Text caret is taller than the placeholder assert_less_than: expected a number less than 418 but got 418
FAIL Text caret is shorter than the placeholder assert_less_than: width expected a number less than 262 but got 262
FAIL Explicit width and auto height assert_greater_than: expected a number greater than 32 but got 19
PASS Explicit height and auto width
PASS Text caret is taller than the placeholder
FAIL Text caret is shorter than the placeholder assert_less_than: height expected a number less than 29 but got 29
FAIL Update field-sizing property dynamically assert_less_than: expected a number less than 161 but got 161

Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<style>
textarea {
font-family: monospace;
}

.disable-default {
field-sizing: content;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


FAIL number: Empty value assert_equals: expected 24 but got 30
PASS number: Auto width and auto height with a long text
PASS number: Explicit width and heigth
FAIL number: Explicit width and auto height assert_equals: expected 24 but got 30
PASS number: Explicit height and auto width
PASS number: Text caret is taller than the placeholder
FAIL number: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL number: Update field-sizing property dynamically assert_equals: expected 24 but got 30

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@


PASS text: Empty value
PASS text: Empty value with a size atttribute
PASS text: Auto width and auto height with a long text
PASS text: Explicit width and heigth
PASS text: Explicit width and auto height
PASS text: Explicit height and auto width
PASS text: Text caret is taller than the placeholder
FAIL text: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL text: Update field-sizing property dynamically assert_less_than: expected a number less than 192 but got 192
PASS search: Empty value
PASS search: Empty value with a size atttribute
PASS search: Auto width and auto height with a long text
PASS search: Explicit width and heigth
PASS search: Explicit width and auto height
PASS search: Explicit height and auto width
PASS search: Text caret is taller than the placeholder
FAIL search: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL search: Update field-sizing property dynamically assert_less_than: expected a number less than 192 but got 192
PASS tel: Empty value
PASS tel: Empty value with a size atttribute
PASS tel: Auto width and auto height with a long text
PASS tel: Explicit width and heigth
PASS tel: Explicit width and auto height
PASS tel: Explicit height and auto width
PASS tel: Text caret is taller than the placeholder
FAIL tel: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL tel: Update field-sizing property dynamically assert_less_than: expected a number less than 192 but got 192
PASS url: Empty value
PASS url: Empty value with a size atttribute
PASS url: Auto width and auto height with a long text
PASS url: Explicit width and heigth
PASS url: Explicit width and auto height
PASS url: Explicit height and auto width
PASS url: Text caret is taller than the placeholder
FAIL url: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL url: Update field-sizing property dynamically assert_less_than: expected a number less than 192 but got 192
PASS email: Empty value
PASS email: Empty value with a size atttribute
PASS email: Auto width and auto height with a long text
PASS email: Explicit width and heigth
PASS email: Explicit width and auto height
PASS email: Explicit height and auto width
PASS email: Text caret is taller than the placeholder
FAIL email: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL email: Update field-sizing property dynamically assert_less_than: expected a number less than 192 but got 192
PASS password: Empty value
PASS password: Empty value with a size atttribute
PASS password: Auto width and auto height with a long text
PASS password: Explicit width and heigth
PASS password: Explicit width and auto height
PASS password: Explicit height and auto width
PASS password: Text caret is taller than the placeholder
FAIL password: Text caret is shorter than the placeholder assert_less_than: expected a number less than 29 but got 29
FAIL password: Update field-sizing property dynamically assert_less_than: expected a number less than 192 but got 192

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


PASS Empty value
PASS Empty value with cols/rows
PASS Auto width and auto height with a long text
PASS Explicit width and heigth
FAIL Explicit width and auto height assert_greater_than: expected a number greater than 42 but got 24
PASS Explicit height and auto width
PASS Text caret is taller than the placeholder
FAIL Text caret is shorter than the placeholder assert_less_than: height expected a number less than 29 but got 29
FAIL Update field-sizing property dynamically assert_less_than: expected a number less than 221 but got 221

Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@


PASS number: Empty value
PASS number: Auto width and auto height with a long text
PASS number: Explicit width and heigth
PASS number: Explicit width and auto height
PASS number: Explicit height and auto width
PASS number: Text caret is taller than the placeholder
FAIL number: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
PASS number: Update field-sizing property dynamically

Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@


PASS text: Empty value
PASS text: Empty value with a size atttribute
PASS text: Auto width and auto height with a long text
PASS text: Explicit width and heigth
PASS text: Explicit width and auto height
PASS text: Explicit height and auto width
PASS text: Text caret is taller than the placeholder
FAIL text: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
FAIL text: Update field-sizing property dynamically assert_less_than: expected a number less than 155 but got 155
PASS search: Empty value
PASS search: Empty value with a size atttribute
PASS search: Auto width and auto height with a long text
PASS search: Explicit width and heigth
PASS search: Explicit width and auto height
PASS search: Explicit height and auto width
PASS search: Text caret is taller than the placeholder
FAIL search: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
FAIL search: Update field-sizing property dynamically assert_less_than: expected a number less than 155 but got 155
PASS tel: Empty value
PASS tel: Empty value with a size atttribute
PASS tel: Auto width and auto height with a long text
PASS tel: Explicit width and heigth
PASS tel: Explicit width and auto height
PASS tel: Explicit height and auto width
PASS tel: Text caret is taller than the placeholder
FAIL tel: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
FAIL tel: Update field-sizing property dynamically assert_less_than: expected a number less than 155 but got 155
PASS url: Empty value
PASS url: Empty value with a size atttribute
PASS url: Auto width and auto height with a long text
PASS url: Explicit width and heigth
PASS url: Explicit width and auto height
PASS url: Explicit height and auto width
PASS url: Text caret is taller than the placeholder
FAIL url: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
FAIL url: Update field-sizing property dynamically assert_less_than: expected a number less than 155 but got 155
PASS email: Empty value
PASS email: Empty value with a size atttribute
PASS email: Auto width and auto height with a long text
PASS email: Explicit width and heigth
PASS email: Explicit width and auto height
PASS email: Explicit height and auto width
PASS email: Text caret is taller than the placeholder
FAIL email: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
FAIL email: Update field-sizing property dynamically assert_less_than: expected a number less than 155 but got 155
PASS password: Empty value
PASS password: Empty value with a size atttribute
PASS password: Auto width and auto height with a long text
PASS password: Explicit width and heigth
PASS password: Explicit width and auto height
PASS password: Explicit height and auto width
PASS password: Text caret is taller than the placeholder
FAIL password: Text caret is shorter than the placeholder assert_less_than: expected a number less than 37 but got 37
FAIL password: Update field-sizing property dynamically assert_less_than: expected a number less than 155 but got 155

Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@


PASS dropdown: The width should depend on the selected OPTION
PASS dropdown: Change the field-sizing value dynamically

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@


PASS Empty value
PASS Empty value with cols/rows
PASS Auto width and auto height with a long text
PASS Explicit width and heigth
FAIL Explicit width and auto height assert_greater_than: expected a number greater than 30 but got 18
PASS Explicit height and auto width
PASS Text caret is taller than the placeholder
FAIL Text caret is shorter than the placeholder assert_less_than: height expected a number less than 27 but got 27
FAIL Update field-sizing property dynamically assert_less_than: expected a number less than 168 but got 168

0 comments on commit bcca5fc

Please sign in to comment.