Skip to content

Commit ba9aa74

Browse files
committed
Rendering: field-sizing support for some elements
This covers: - input element as a text entry widget size attribute is ignored if field-sizing:content - input element as domain-specific widgets (optional) - input element as a file upload control (optional) - select element size attribute is used only for dropdown/listbox switching if field-sizing:content - textarea element cols/rows are ignored if field-sizing:content Issue: whatwg#6807 Issue: w3c/csswg-drafts#7542
1 parent 37659e9 commit ba9aa74

File tree

1 file changed

+133
-35
lines changed

1 file changed

+133
-35
lines changed

source

+133-35
Original file line numberDiff line numberDiff line change
@@ -3916,9 +3916,12 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
39163916
<dfn data-x-href="https://drafts.csswg.org/css-ui/#typedef-appearance-compat-auto">&lt;compat-auto></dfn> non-terminal value type, its
39173917
<dfn data-x-href="https://drafts.csswg.org/css-ui/#valdef-appearance-textfield">'textfield'</dfn> value, and its
39183918
<dfn data-x-href="https://drafts.csswg.org/css-ui/#valdef-appearance-menulist-button">'menulist-button'</dfn> value.</li>
3919+
<li>The <dfn data-x-href="https://drafts.csswg.org/css-ui/#field-sizing">'field-sizing'</dfn> property, and its
3920+
<dfn data-x-href="https://drafts.csswg.org/css-ui/#valdef-field-sizing-content" data-x="field-sizing-content">'content'</dfn> value.</li>
39193921
<li>The concept <dfn data-x-href="https://drafts.csswg.org/css-ui/#widget">widget</dfn></li>
39203922
<li>The concept <dfn data-x-href="https://drafts.csswg.org/css-ui/#native-appearance">native appearance</dfn></li>
39213923
<li>The concept <dfn data-x-href="https://drafts.csswg.org/css-ui/#primitive-appearance">primitive appearance</dfn></li>
3924+
<li>The concept <dfn data-x-href="https://drafts.csswg.org/css-ui/#element-with-default-preferred-size">element with default preferred size</dfn></li>
39223925
<li>The <dfn data-x-href="https://drafts.csswg.org/css-ui/#non-devolvable">non-devolvable widget</dfn> and
39233926
<dfn data-x-href="https://drafts.csswg.org/css-ui/#devolvable">devolvable widget</dfn> classification, and the related
39243927
<dfn data-x-href="https://drafts.csswg.org/css-ui/#devolved">devolved widget</dfn> state.</li>
@@ -131907,19 +131910,38 @@ details[open] > summary:first-of-type {
131907131910
at the element, with the <code data-x="dom-Event-bubbles">bubbles</code> attribute initialized to
131908131911
true.</p>
131909131912

131910-
<p>If an <code>input</code> element whose <code data-x="attr-input-type">type</code> attribute is
131911-
in one of the above states has a <code data-x="attr-input-size">size</code> attribute, and parsing
131912-
that attribute's value using the <span>rules for parsing non-negative integers</span> doesn't
131913-
generate an error, then the user agent is expected to use the attribute as a <span
131914-
data-x="presentational hints">presentational hint</span> for the <span>'width'</span> property on
131915-
the element, with the value obtained from applying the <span>converting a character width to
131916-
pixels</span> algorithm to the value of the attribute.</p>
131913+
<p>The <code>input</code> element whose <code data-x="attr-input-type">type</code> attribute is
131914+
in one of the above states is an <span>element with default preferred size</span>, and
131915+
user agents are expected to apply the <span>'field-sizing'</span> CSS property to
131916+
the elements.</p>
131917131917

131918-
<p>If an <code>input</code> element whose <code data-x="attr-input-type">type</code> attribute is
131919-
in one of the above states does <em>not</em> have a <code data-x="attr-input-size">size</code>
131920-
attribute, then the user agent is expected to act as if it had a user-agent-level style sheet rule
131921-
setting the <span>'width'</span> property on the element to the value obtained from applying the
131922-
<span>converting a character width to pixels</span> algorithm to the number 20.</p>
131918+
<p>The <span>inline size</span> of the default preferred size is determined by the following
131919+
steps:<p>
131920+
131921+
<ol>
131922+
<li>
131923+
<p>If the <span>'field-sizing'</span> property on the element has a <span>computed value</span>
131924+
of <span data-x="field-sizing-content">'content'</span>,
131925+
The <span>inline size</span> of the default preferred size is determined by the text which the
131926+
element shows. The text is either a <span data-x="concept-fe-value">value</span> or a short hint
131927+
specified by the <code data-x="attr-input-placeholder">placeholder</code> attribute. If the text
131928+
is editable by the user, user agents may secure space for the text caret.</p>
131929+
</li>
131930+
131931+
<li>
131932+
<p>If the element has a <code data-x="attr-input-size">size</code> attribute, and parsing that
131933+
attribute's value using the <span>rules for parsing non-negative integers</span> doesn't
131934+
generate an error, the <span>inline size</span> of the default preferred size is the value
131935+
obtained from applying the <span>converting a character width to pixels</span> algorithm to the
131936+
value of the attribute.</p>
131937+
</li>
131938+
131939+
<li>
131940+
<p>Otherwise, the <span>inline size</span> of the default preferred size is the value obtained
131941+
from applying the <span>converting a character width to pixels</span> algorithm to the number
131942+
20.</p>
131943+
</li>
131944+
</ol>
131923131945

131924131946
<p>The <dfn>converting a character width to pixels</dfn> algorithm returns <span data-x="">(<var>size</var>-1)&times;<var>avg</var>&nbsp;+&nbsp;<var>max</var></span>,
131925131947
where <var>size</var> is the character width to convert, <var>avg</var> is the
@@ -131966,8 +131988,23 @@ details[open] > summary:first-of-type {
131966131988
the <span data-x="attr-input-type-number">Number</span> state is a <span>devolvable widget</span>
131967131989
expected to render as an <span>'inline-block'</span> box depicting a number control.</p>
131968131990

131969-
<p>These controls are all expected to be about one line high, and about as wide as necessary to
131970-
show the widest possible value.</p>
131991+
<p>An <code>input</code> element whose <code data-x="attr-input-type">type</code> attribute is in
131992+
the <span data-x="attr-input-type-number">Number</span> state is an
131993+
<span>element with default preferred size</span>, and user agents are expected to apply the
131994+
<span>'field-sizing'</span> CSS property to the element. The <span>block size</span> of the
131995+
default preferred size is about one line high. If the <span>'field-sizing'</span> property on the
131996+
control has a <span>computed value</span> of <span data-x="field-sizing-content">'content'</span>,
131997+
the <span>inline size</span> of the default preferred size is expected to be about as wide as the
131998+
necessary to show the current <span data-x="concept-fe-value">value</span>. Otherwise, the
131999+
<span>inline size</span> is expected to be about as wide as necessary to show the widest possible
132000+
value.</p>
132001+
132002+
<p>An <code>input</code> element whose <span data-x="attr-input-type">type</code> attribute is in
132003+
the <span data-x="attr-input-type-date">Date</span>,
132004+
<span data-x="attr-input-type-month">Month</span>,
132005+
<span data-x="attr-input-type-week">Week</span>, <span data-x="attr-input-type-time">Time</span>,
132006+
or <span data-x="attr-input-type-datetime-local">Local Date and Time</span> state, is expected to
132007+
be about one line high, and about as wide as necessary to show the widest possible value.</p>
131971132008

131972132009
<p class="XXX">Need to detail the expected <span>native appearance</span> and <span>primitive
131973132010
appearance</span>.</p>
@@ -132065,6 +132102,18 @@ details[open] > summary:first-of-type {
132065132102
<span>implementation-defined</span> (and possibly locale-specific) text, for example "Choose
132066132103
file".</p>
132067132104

132105+
<p>User agents may handle an <code>input</code> element whose
132106+
<code data-x="attr-input-type">type</code> attribute is in the
132107+
<span data-x="attr-input-type-file">File Upload</span> state as an
132108+
<span>element with default preferred size</span>, and user agents may apply the
132109+
<span>'field-sizing'</span> CSS property to the element.</p>
132110+
132111+
<p>If the user agent applies <span>'field-sizing'</span> CSS property to the element and the
132112+
<span>'field-sizing'</span> property on the control has a <span>computed value</span> of
132113+
<span data-x="field-sizing-content">'content'</span>, the default preferred size of the element
132114+
is expected to depend on its content such as the <span>'::file-selector-button'</span>
132115+
pseudo-element and chosen file names.</p>
132116+
132068132117
</div>
132069132118

132070132119

@@ -132317,6 +132366,10 @@ progress { appearance: auto; }</code></pre>
132317132366

132318132367
<h4>The <code>select</code> element</h4>
132319132368

132369+
<p>The <code>select</code> element is an <span>element with default preferred size</span>, and
132370+
user agents are expected to apply the <span>'field-sizing'</span> CSS property to
132371+
<code>select</code> elements.
132372+
132320132373
<p>A <code>select</code> element is either a <dfn export for="select">list box</dfn> or a <dfn
132321132374
export for="select">drop-down box</dfn>, depending on its attributes.</p>
132322132375

@@ -132328,16 +132381,37 @@ progress { appearance: auto; }</code></pre>
132328132381
than 1, is expected to render as a single-select <span>list box</span>.</p>
132329132382

132330132383
<p>When the element renders as a <span>list box</span>, it is a <span>devolvable widget</span>
132331-
expected to render as an <span>'inline-block'</span> box whose <span>'height'</span> is the height
132332-
necessary to contain as many rows for items as given by the element's <span
132333-
data-x="concept-select-size">display size</span>, or four rows if the attribute is absent, and
132334-
whose <span>'width'</span> is the <span>width of the <code>select</code>'s labels</span> plus the
132335-
width of a scrollbar.</p>
132384+
expected to render as an <span>'inline-block'</span> box. Its <span>inline size</span> of the
132385+
default preferred size is the <span>width of the <code>select</code>'s labels</span> plus the
132386+
width of a scrollbar. Its <span>block size</span> is determined by the following steps:</p>
132387+
132388+
<ol>
132389+
<li>
132390+
<p>If the <span>'field-sizing'</span> property on the element has a <span>computed value</span>
132391+
of <span data-x="field-sizing-content">'content'</span>, return the height necessary to contain
132392+
all rows for items.</p>
132393+
</li>
132394+
132395+
<li>
132396+
<p>If <code data-x="attr-select-size">size</code> attribute is absent or it has no valid value,
132397+
return the height necessary to contain four rows.</p>
132398+
</li>
132399+
132400+
<li>
132401+
<p>Otherwise, return the height necessary to contain as many rows for items as given by the
132402+
element's <span data-x="concept-select-size">display size</span>.</p>
132403+
</li>
132404+
</ol>
132336132405

132337132406
<p>A <code>select</code> element whose <code data-x="attr-select-multiple">multiple</code>
132338132407
attribute is absent, and whose <span data-x="concept-select-size">display size</span> is 1, is
132339-
expected to render as an <span>'inline-block'</span> one-line <span>drop-down box</span> whose
132340-
width is the <span>width of the <code>select</code>'s labels</span>.</p>
132408+
expected to render as an <span>'inline-block'</span> one-line <span>drop-down box</span>.
132409+
The <span>inline size</span> of its default preferred size depends on the shown text if the
132410+
<span>'field-sizing'</span> property on the element has a <span>computed value</span> of
132411+
<span data-x="field-sizing-content">'content'</span>. The text is typically the label of an
132412+
<code>option</code> of which <span data-x="concept-option-selectedness">selectedness</span> is
132413+
set to true. Otherwise, the <span>inline size</span> is the
132414+
<span>width of the <code>select</code>'s labels</span>.</p>
132341132415

132342132416
<p>When the element renders as a <span>drop-down box</span>, it is a <span>devolvable
132343132417
widget</span>. Its appearance in the devolved state, as well as its appearance when the
@@ -132398,13 +132472,27 @@ progress { appearance: auto; }</code></pre>
132398132472
named <code data-x="event-select">select</code> at the element, with the <code
132399132473
data-x="dom-Event-bubbles">bubbles</code> attribute initialized to true.</p>
132400132474

132401-
<p>If the element has a <code data-x="attr-textarea-cols">cols</code> attribute, and parsing that
132402-
attribute's value using the <span>rules for parsing non-negative integers</span> doesn't generate
132403-
an error, then the user agent is expected to use the attribute as a <span data-x="presentational
132404-
hints">presentational hint</span> for the <span>'width'</span> property on the element, with the
132405-
value being the <span>textarea effective width</span> (as defined below). Otherwise, the user
132406-
agent is expected to act as if it had a user-agent-level style sheet rule setting the
132407-
<span>'width'</span> property on the element to the <span>textarea effective width</span>.</p>
132475+
<p>The <code>textarea</code> element is an <span>element with default preferred size</span>, and
132476+
user agents are expected to apply the <span>'field-sizing'</span> CSS property to
132477+
<code>textarea</code> elements.
132478+
132479+
<p>The <span>inline size</span> of the default preferred size is determined by the following
132480+
steps:</p>
132481+
132482+
<ol>
132483+
<li>
132484+
<p>If the <span>'field-sizing'</span> property on the element has a <span>computed value</span>
132485+
of <span data-x="field-sizing-content">'content'</span>, return the size determined by the text
132486+
which the element shows. The text is either a
132487+
<span data-x="concept-textarea-raw-value">raw value</span> or a short hint specified by the
132488+
<code data-x="attr-textarea-placeholder">placeholder</code> attribute. If the text is editable
132489+
by the user, the <span>inline size</span> of text caret may be included.</p>
132490+
</li>
132491+
132492+
<li>
132493+
<p>Otherwise, return the <span>textarea effective width</span> (as defined below)</p>
132494+
</li>
132495+
</ol>
132408132496

132409132497
<p>The <dfn>textarea effective width</dfn> of a <code>textarea</code> element is <span
132410132498
data-x=""><var>size</var>&times;<var>avg</var>&nbsp;+&nbsp;<var>sbw</var></span>, where
@@ -132414,13 +132502,23 @@ progress { appearance: auto; }</code></pre>
132414132502
data-x="'px'">CSS pixels</span>. (The element's <span>'letter-spacing'</span> property does not
132415132503
affect the result.)</p>
132416132504

132417-
<p>If the element has a <code data-x="attr-textarea-rows">rows</code> attribute, and parsing that
132418-
attribute's value using the <span>rules for parsing non-negative integers</span> doesn't generate
132419-
an error, then the user agent is expected to use the attribute as a <span data-x="presentational
132420-
hints">presentational hint</span> for the <span>'height'</span> property on the element, with the
132421-
value being the <span>textarea effective height</span> (as defined below). Otherwise, the user
132422-
agent is expected to act as if it had a user-agent-level style sheet rule setting the
132423-
<span>'height'</span> property on the element to the <span>textarea effective height</span>.</p>
132505+
<p>The <span>block size</span> of the default preferred size is determined by the following
132506+
steps:</p>
132507+
132508+
<ol>
132509+
<li>
132510+
<p>If the <span>'field-sizing'</span> property on the element has a <span>computed value</span>
132511+
of <span data-x="field-sizing-content">'content'</span>, return the size determined by the text
132512+
which the element shows. The text is either a
132513+
<span data-x="concept-textarea-raw-value">raw value</span> or a short hint specified by the
132514+
<code data-x="attr-textarea-placeholder">placeholder</code> attribute. If the text is editable
132515+
by the user, the <span>block size</span> of text caret may be included.</p>
132516+
</li>
132517+
132518+
<li>
132519+
<p>Otherwise, return the <span>textarea effective height</span> (as defined below)</p>
132520+
</li>
132521+
</ol>
132424132522

132425132523
<p>The <dfn>textarea effective height</dfn> of a <code>textarea</code> element is the height in
132426132524
<span data-x="'px'">CSS pixels</span> of the number of lines specified the element's <span

0 commit comments

Comments
 (0)