Skip to content

Commit c2d1a36

Browse files
authored
Add width and height attributes to source elements
Closes #4968.
1 parent 0560fb0 commit c2d1a36

File tree

1 file changed

+60
-26
lines changed

1 file changed

+60
-26
lines changed

source

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -26034,6 +26034,8 @@ interface <dfn>HTMLPictureElement</dfn> : <span>HTMLElement</span> {
2603426034
<dd><code data-x="attr-source-srcset">srcset</code></dd>
2603526035
<dd><code data-x="attr-source-sizes">sizes</code></dd>
2603626036
<dd><code data-x="attr-source-media">media</code></dd>
26037+
<dd><code data-x="attr-dim-width">width</code></dd>
26038+
<dd><code data-x="attr-dim-height">height</code></dd>
2603726039
<dt><span
2603826040
data-x="concept-element-accessibility-considerations">Accessibility considerations</span>:</dt>
2603926041
<dd><a href="https://w3c.github.io/html-aria/#el-source">For authors</a>.</dd>
@@ -26049,6 +26051,8 @@ interface <dfn>HTMLSourceElement</dfn> : <span>HTMLElement</span> {
2604926051
[<span>CEReactions</span>] attribute USVString <span data-x="dom-source-srcset">srcset</span>;
2605026052
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-source-sizes">sizes</span>;
2605126053
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-source-media">media</span>;
26054+
[<span>CEReactions</span>] attribute unsigned long <span data-x="dom-dim-width">width</span>;
26055+
[<span>CEReactions</span>] attribute unsigned long <span data-x="dom-dim-height">height</span>;
2605226056
};</code></pre>
2605326057
</dd>
2605426058
<dd w-dev>Uses <code>HTMLSourceElement</code>.</dd>
@@ -26088,6 +26092,13 @@ interface <dfn>HTMLSourceElement</dfn> : <span>HTMLElement</span> {
2608826092
skip to the next <code>source</code> element if the value does not <span data-x="matches the
2608926093
environment">match the environment</span>.</p>
2609026094

26095+
<p>The <span>source</span> element supports <span>dimension attributes</span>. These attributes
26096+
can <span>map to the aspect-ratio property</span> as well as the rendered dimensions of
26097+
sibling <span>img</span> element, if <span>source</span> element's parent is a
26098+
<span>picture</span> element and <span>source</span> element's <span>source set</span> is
26099+
returned as a result of <span>update the source set</span> for that sibling
26100+
<span>img</span>.</p>
26101+
2609126102
<p>The <code data-x="attr-source-type">type</code> attribute gives the type of the images in the
2609226103
<span>source set</span>, to allow the user agent to skip to the next <code>source</code> element
2609326104
if it does not support the given type.</p>
@@ -26341,6 +26352,9 @@ interface <dfn>HTMLImageElement</dfn> : <span>HTMLElement</span> {
2634126352

2634226353
<p>An <code>img</code> element represents an image.</p>
2634326354

26355+
<p>An <code>img</code> element has a <dfn data-x="concept-img-dimension-attribute-source">dimension
26356+
attribute source</dfn>, initially set to the element itself.</p>
26357+
2634426358
<!-- v2 ideas for <img>:
2634526359

2634626360
* Maps sites would like to know which images are already cached, so that they can use images
@@ -27879,8 +27893,9 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
2787927893

2788027894
<li><p>The element's parent is a <code>picture</code> element and a <code>source</code> element
2788127895
that is a previous sibling has its <code data-x="attr-source-srcset">srcset</code>, <code
27882-
data-x="attr-source-sizes">sizes</code>, <code data-x="attr-source-media">media</code>, or <code
27883-
data-x="attr-source-type">type</code> attributes set, changed, or removed.</p></li>
27896+
data-x="attr-source-sizes">sizes</code>, <code data-x="attr-source-media">media</code>, <code
27897+
data-x="attr-source-type">type</code>, <code data-x="attr-dim-width">width</code> or <code
27898+
data-x="attr-dim-height">height</code> attributes set, changed, or removed.</p></li>
2788427899

2788527900
<li><p>The element's <span data-x="concept-node-adopt-ext">adopting steps</span> are run.</p></li>
2788627901

@@ -28525,6 +28540,13 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
2852528540
<li><p>If <var>child</var> has a <code data-x="attr-source-type">type</code> attribute, and its
2852628541
value is an unknown or unsupported <span>MIME type</span>, continue to the next child.</p></li>
2852728542

28543+
<li><p>If <var>child</var> has <code data-x="attr-dim-width">width</code> or <code
28544+
data-x="attr-dim-height">height</code> attributes, set <var>el</var>'s <span
28545+
data-x="concept-img-dimension-attribute-source">dimension attribute source</span> to
28546+
<var>child</var>. Otherwise, set <var>el</var>'s <span
28547+
data-x="concept-img-dimension-attribute-source">dimension attribute source</span> to
28548+
<var>el</var>.</p></li>
28549+
2852828550
<li><p><span>Normalize the source densities</span> of <var>source set</var>.</p></li>
2852928551

2853028552
<li><p>Let <var>el</var>'s <span>source set</span> be <var>source set</var>.</p></li>
@@ -39397,16 +39419,16 @@ interface <dfn>HTMLAreaElement</dfn> : <span>HTMLElement</span> {
3939739419
<h4><dfn>Dimension attributes</dfn></h4>
3939839420

3939939421
<p><span w-nodev><strong>Author requirements</strong>:</span> The <dfn element-attr
39400-
for="img,iframe,embed,object,video"><code data-x="attr-dim-width">width</code></dfn> and <dfn
39401-
element-attr for="img,iframe,embed,object,video"><code
39422+
for="img,iframe,embed,object,source,video"><code data-x="attr-dim-width">width</code></dfn> and
39423+
<dfn element-attr for="img,iframe,embed,object,source,video"><code
3940239424
data-x="attr-dim-height">height</code></dfn> attributes on <code>img</code>, <code>iframe</code>,
39403-
<code>embed</code>, <code>object</code>, <code>video</code>, and, when their <code
39404-
data-x="attr-input-type">type</code> attribute is in the <span
39405-
data-x="attr-input-type-image">Image Button</span> state, <code>input</code> elements may be
39406-
specified to give the dimensions of the visual content of the element (the width and height
39407-
respectively, relative to the nominal direction of the output medium), in <span data-x="'px'">CSS
39408-
pixels</span>. The attributes, if specified, must have values that are <span data-x="valid
39409-
non-negative integer">valid non-negative integers</span>.</p>
39425+
<code>embed</code>, <code>object</code>, <code>video</code>, <code>source</code> when the parent
39426+
is a <code>picture</code> element and, when their <code data-x="attr-input-type">type</code>
39427+
attribute is in the <span data-x="attr-input-type-image">Image Button</span> state,
39428+
<code>input</code> elements may be specified to give the dimensions of the visual content of the
39429+
element (the width and height respectively, relative to the nominal direction of the output
39430+
medium), in <span data-x="'px'">CSS pixels</span>. The attributes, if specified, must have values
39431+
that are <span data-x="valid non-negative integer">valid non-negative integers</span>.</p>
3941039432

3941139433
<p>The specified dimensions given may differ from the dimensions specified in the resource itself,
3941239434
since the resource may have a resolution that differs from the CSS pixel resolution. (On screens,
@@ -39446,17 +39468,19 @@ interface <dfn>HTMLAreaElement</dfn> : <span>HTMLElement</span> {
3944639468
<p><strong>User agent requirements</strong>: User agents are expected to use these attributes <a
3944739469
href="#dimRendering">as hints for the rendering</a>.</p>
3944839470

39471+
3944939472
<p>The <dfn attribute
39450-
for="HTMLImageElement,HTMLIFrameElement,HTMLEmbedElement,HTMLObjectElement,HTMLVideoElement"><code
39473+
for="HTMLImageElement,HTMLIFrameElement,HTMLEmbedElement,HTMLObjectElement,HTMLSourceElement,HTMLVideoElement"><code
3945139474
data-x="dom-dim-width">width</code></dfn> and <dfn attribute
39452-
for="HTMLImageElement,HTMLIFrameElement,HTMLEmbedElement,HTMLObjectElement,HTMLVideoElement"><code
39475+
for="HTMLImageElement,HTMLIFrameElement,HTMLEmbedElement,HTMLObjectElement,HTMLSourceElement,HTMLVideoElement"><code
3945339476
data-x="dom-dim-height">height</code></dfn> IDL attributes on the <code>iframe</code>,
39454-
<code>embed</code>, <code>object</code>, and <code>video</code> elements must <span>reflect</span>
39455-
the respective content attributes of the same name.</p>
39477+
<code>embed</code>, <code>object</code>, <code>source</code>, and <code>video</code> elements must
39478+
<span>reflect</span> the respective content attributes of the same name.</p>
3945639479

39457-
<p class="note">For <code>iframe</code>, <code>embed</code>, and <code>object</code> the IDL
39458-
attributes are <code data-x="idl-DOMString">DOMString</code>; for <code>video</code> the IDL attributes are <code
39459-
data-x="idl-unsigned-long">unsigned long</code>.</p>
39480+
<p class="note">For <code>iframe</code>, <code>embed</code> and <code>object</code> the IDL
39481+
attributes are <code data-x="idl-DOMString">DOMString</code>; for <code>video</code> and
39482+
<code>source</code> the IDL attributes are <code data-x="idl-unsigned-long">unsigned
39483+
long</code>.</p>
3946039484

3946139485
<p class="note">The corresponding IDL attributes for <code data-x="dom-img-height">img</code> and
3946239486
<code data-x="dom-input-height">input</code> elements are defined in those respective elements'
@@ -114341,13 +114365,19 @@ input[type=image i][align=bottom i], object[align=bottom i] {
114341114365
'solid'.</p>
114342114366

114343114367
<p id="dimRendering">The <code data-x="attr-dim-width">width</code> and <code
114344-
data-x="attr-dim-height">height</code> attributes on <code>embed</code>, <code>iframe</code>,
114345-
<code>img</code>, <code>object</code> or <code>video</code> elements, and <code>input</code>
114346-
elements with a <code data-x="attr-input-type">type</code> attribute in the <span
114347-
data-x="attr-input-type-image">Image Button</span> state and that either represents an image or
114348-
that the user expects will eventually represent an image, <span data-x="maps to the dimension
114349-
property">map to the dimension properties</span> <span>'width'</span> and <span>'height'</span> on
114350-
the element respectively.</p>
114368+
data-x="attr-dim-height">height</code> attributes on an <code>img</code> element's <span
114369+
data-x="concept-img-dimension-attribute-source">dimension attribute source</span> <span
114370+
data-x="maps to the dimension property">map to the dimension properties</span>
114371+
<span>'width'</span> and <span>'height'</span> on the <code>img</code> element respectively. They
114372+
similarly <span>map to the aspect-ratio property</span> of the <code>img</code> element.</p>
114373+
114374+
<p>The <code data-x="attr-dim-width">width</code> and <code data-x="attr-dim-height">height</code>
114375+
attributes on <code>embed</code>, <code>iframe</code>, <code>object</code> or <code>video</code>
114376+
elements, and <code>input</code> elements with a <code data-x="attr-input-type">type</code>
114377+
attribute in the <span data-x="attr-input-type-image">Image Button</span> state and that either
114378+
represents an image or that the user expects will eventually represent an image, <span
114379+
data-x="maps to the dimension property">map to the dimension properties</span>
114380+
<span>'width'</span> and <span>'height'</span> on the element respectively.</p>
114351114381

114352114382
<p>The <code data-x="attr-dim-width">width</code> and <code data-x="attr-dim-height">height</code>
114353114383
attributes <span>map to the aspect-ratio property</span> on <code>img</code>, <code>canvas</code>,
@@ -119277,7 +119307,9 @@ interface <dfn>MimeType</dfn> {
119277119307
<code data-x="attr-source-type">type</code>;
119278119308
<code data-x="attr-source-srcset">srcset</code>;
119279119309
<code data-x="attr-source-sizes">sizes</code>;
119280-
<code data-x="attr-source-media">media</code></td>
119310+
<code data-x="attr-source-media">media</code>;
119311+
<code data-x="attr-dim-width">width</code>;
119312+
<code data-x="attr-dim-height">height</code></td>
119281119313
<td><code>HTMLSourceElement</code></td>
119282119314
</tr>
119283119315

@@ -120408,6 +120440,7 @@ interface <dfn>MimeType</dfn> {
120408120440
<code data-x="attr-dim-height">img</code>;
120409120441
<code data-x="attr-dim-height">input</code>;
120410120442
<code data-x="attr-dim-height">object</code>;
120443+
<code data-x="attr-dim-width">source</code>;
120411120444
<code data-x="attr-dim-height">video</code>
120412120445
<td> Vertical dimension
120413120446
<td> <span>Valid non-negative integer</span>
@@ -121037,6 +121070,7 @@ interface <dfn>MimeType</dfn> {
121037121070
<code data-x="attr-dim-width">img</code>;
121038121071
<code data-x="attr-dim-width">input</code>;
121039121072
<code data-x="attr-dim-width">object</code>;
121073+
<code data-x="attr-dim-width">source</code>;
121040121074
<code data-x="attr-dim-width">video</code>
121041121075
<td> Horizontal dimension
121042121076
<td> <span>Valid non-negative integer</span>

0 commit comments

Comments
 (0)