Skip to content

Commit fa16e3b

Browse files
committed
Add lazy-loading for <video poster>
Add a new posterloading attribute to the video element which controls lazy-loading of the poster image. Fixes #6636.
1 parent db370e7 commit fa16e3b

File tree

1 file changed

+77
-14
lines changed

1 file changed

+77
-14
lines changed

source

+77-14
Original file line numberDiff line numberDiff line change
@@ -7330,14 +7330,14 @@ a.setAttribute('href', 'https://example.com/'); // change the content attribute
73307330
<li><p>Return false.</p></li>
73317331
</ol>
73327332

7333-
<p>Each <code>img</code> and <code>iframe</code> element has associated <dfn>lazy load resumption
7334-
steps</dfn>, initially null.</p>
7333+
<p>Each <code>img</code>, <code>iframe</code> and <code>video</code> element has associated
7334+
<dfn>lazy load resumption steps</dfn>, initially null.</p>
73357335

7336-
<p class="note">For <code>img</code> and <code>iframe</code> elements that <span data-x="will lazy
7337-
load element steps">will lazy load</span>, these steps are run from the <span>lazy load
7338-
intersection observer</span>'s callback or when their <span>lazy loading attribute</span> is set
7339-
to the <span data-x="attr-loading-eager-state">Eager</span> state. This causes the element to
7340-
continue loading.</p>
7336+
<p class="note">For <code>img</code>, <code>iframe</code> and <code>video</code> elements that
7337+
<span data-x="will lazy load element steps">will lazy load</span>, these steps are run from the
7338+
<span>lazy load intersection observer</span>'s callback or when their <span>lazy loading
7339+
attribute</span> is set to the <span data-x="attr-loading-eager-state">Eager</span> state. This
7340+
causes the element to continue loading.</p>
73417341

73427342
<p>Each <code>Document</code> has a <dfn>lazy load intersection observer</dfn>, initially set to
73437343
null but can be set to an <code>IntersectionObserver</code> instance.</p>
@@ -33271,6 +33271,7 @@ interface <dfn interface>HTMLObjectElement</dfn> : <span>HTMLElement</span> {
3327133271
<dd><code data-x="attr-media-src">src</code></dd>
3327233272
<dd><code data-x="attr-media-crossorigin">crossorigin</code></dd>
3327333273
<dd><code data-x="attr-video-poster">poster</code></dd>
33274+
<dd><code data-x="attr-video-posterloading">posterloading</code></dd>
3327433275
<dd><code data-x="attr-media-preload">preload</code></dd>
3327533276
<dd><code data-x="attr-media-autoplay">autoplay</code></dd>
3327633277
<dd><code data-x="attr-video-playsinline">playsinline</code></dd>
@@ -33294,6 +33295,7 @@ interface <dfn interface>HTMLVideoElement</dfn> : <span>HTMLMediaElement</span>
3329433295
readonly attribute unsigned long <span data-x="dom-video-videoWidth">videoWidth</span>;
3329533296
readonly attribute unsigned long <span data-x="dom-video-videoHeight">videoHeight</span>;
3329633297
[<span>CEReactions</span>] attribute USVString <span data-x="dom-video-poster">poster</span>;
33298+
[<span>CEReactions</span>] attribute DOMString <span data-x="dom-video-posterloading">posterloading</span>;
3329733299
[<span>CEReactions</span>] attribute boolean <span data-x="dom-video-playsInline">playsInline</span>;
3329833300
};</code></pre>
3329933301
</dd>
@@ -33333,8 +33335,29 @@ interface <dfn interface>HTMLVideoElement</dfn> : <span>HTMLMediaElement</span>
3333333335
data is available. The attribute, if present, must contain a <span>valid non-empty URL
3333433336
potentially surrounded by spaces</span>.</p>
3333533337

33338+
<p>The <dfn element-attr for="video"><code
33339+
data-x="attr-video-posterloading">posterloading</code></dfn> attribute is a <span>lazy
33340+
loading attribute</span>. Its purpose is to indicate the policy for loading the image given by the
33341+
<code data-x="attr-video-poster">poster</code> attribute of <code>video</code> elements that are
33342+
outside the viewport.</p>
33343+
3333633344
<div w-nodev>
3333733345

33346+
<p>When the <code data-x="attr-video-posterloading">posterloading</code> attribute's state is
33347+
changed to the <span data-x="attr-loading-eager-state">Eager</span> state, the user agent must run
33348+
these steps:</p>
33349+
33350+
<ol>
33351+
<li><p>Let <var>resumptionSteps</var> be the <code>video</code> element's <span>lazy load
33352+
resumption steps</span>.</p></li>
33353+
33354+
<li><p>If <var>resumptionSteps</var> is null, then return.</p></li>
33355+
33356+
<li><p>Set the <code>video</code>'s <span>lazy load resumption steps</span> to null.</p></li>
33357+
33358+
<li><p>Invoke <var>resumptionSteps</var>.</p></li>
33359+
</ol>
33360+
3333833361
<p>If the specified resource is to be used, then, when the element is created or when the <code
3333933362
data-x="attr-video-poster">poster</code> attribute is set, changed, or removed, the user agent must
3334033363
run the following steps to determine the element's <dfn>poster frame</dfn> (regardless of the
@@ -33361,13 +33384,41 @@ interface <dfn interface>HTMLVideoElement</dfn> : <span>HTMLMediaElement</span>
3336133384
data-x="concept-request-credentials-mode">credentials mode</span> is "<code
3336233385
data-x="">include</code>", and whose <span>use-URL-credentials flag</span> is set.
3336333386

33364-
<!--FETCH--><li><p><span data-x="concept-fetch">Fetch</span> <var>request</var>, with
33365-
<i data-x="processResponseEndOfBody">processResponseEndOfBody</i> given
33366-
<span data-x="concept-response">response</span> <var>res</var> set to
33367-
<span>finalize and report timing</span> with <var>res</var>, the element's
33368-
<span>node document</span>'s <span>relevant global object</span>, and
33369-
"<code data-x="">video</code>". This must <span>delay the load event</span> of the element's
33370-
<span>node document</span>.</p></li>
33387+
<li><p>Let <var>delay load event</var> be true if the <code>video</code>'s <span>lazy loading
33388+
attribute</span> is in the <span data-x="attr-loading-eager-state">Eager</span> state, or if
33389+
<span data-x="concept-n-noscript">scripting is disabled</span> for the <code>video</code>, and
33390+
false otherwise.</p></li>
33391+
33392+
<li>
33393+
<p>If the <span>will lazy load element steps</span> given the <code>video</code> return true,
33394+
then:</p>
33395+
33396+
<ol>
33397+
<li><p>Set the <code>video</code>'s <span>lazy load resumption steps</span> to the rest of this
33398+
algorithm starting with the step labeled <i>fetch the poster image</i>.</p></li>
33399+
33400+
<li><p><span>Start intersection-observing a lazy loading element</span> for the
33401+
<code>video</code> element.</p></li>
33402+
33403+
<li><p>Return.</p></li>
33404+
</ol>
33405+
</li>
33406+
33407+
<li>
33408+
<!--FETCH-->
33409+
<p><i>Fetch the poster image</i>: <span data-x="concept-fetch">Fetch</span>
33410+
<var>request</var>, with <i data-x="processResponseEndOfBody">processResponseEndOfBody</i>
33411+
given <span data-x="concept-response">response</span> <var>res</var> set to
33412+
<span>finalize and report timing</span> with <var>res</var>, the element's
33413+
<span>node document</span>'s <span>relevant global object</span>, and
33414+
"<code data-x="">video</code>".</p>
33415+
33416+
<!-- similar text in <img>, <input type=image> -->
33417+
<p>When <var>delay load event</var> is true, fetching the image must <span>delay the load
33418+
event</span> of the element's <span>node document</span> until the <span
33419+
data-x="concept-task">task</span> that is <span data-x="queue a task">queued</span> by the
33420+
<span>networking task source</span> once the resource has been fetched has been run.
33421+
</li>
3337133422

3337233423
<!-- could define how to sniff for an image here -->
3337333424

@@ -33580,6 +33631,11 @@ interface <dfn interface>HTMLVideoElement</dfn> : <span>HTMLMediaElement</span>
3358033631
IDL attribute must <span>reflect</span> the <code data-x="attr-video-poster">poster</code> content
3358133632
attribute.</p>
3358233633

33634+
<p>The <dfn attribute for="HTMLVideoElement"><code
33635+
data-x="dom-video-posterloading">posterloading</code></dfn> IDL attribute must
33636+
<span>reflect</span> the <code data-x="attr-video-posterloading">posterloading</code> content
33637+
attribute, <span>limited to only known values</span>.</p>
33638+
3358333639
<p>The <dfn attribute for="HTMLVideoElement"><code
3358433640
data-x="dom-video-playsInline">playsInline</code></dfn> IDL attribute must <span>reflect</span>
3358533641
the <code data-x="attr-video-playsinline">playsinline</code> content attribute.</p>
@@ -125318,6 +125374,7 @@ interface <dfn interface>External</dfn> {
125318125374
<code data-x="attr-media-src">src</code>;
125319125375
<code data-x="attr-media-crossorigin">crossorigin</code>;
125320125376
<code data-x="attr-video-poster">poster</code>;
125377+
<code data-x="attr-video-posterloading">posterloading</code>;
125321125378
<code data-x="attr-media-preload">preload</code>;
125322125379
<code data-x="attr-media-autoplay">autoplay</code>;
125323125380
<code data-x="attr-video-playsinline">playsinline</code>;
@@ -126438,6 +126495,12 @@ interface <dfn interface>External</dfn> {
126438126495
<td> <code data-x="attr-video-poster">video</code>
126439126496
<td> Poster frame to show prior to video playback
126440126497
<td> <span>Valid non-empty URL potentially surrounded by spaces</span>
126498+
<tr>
126499+
<th> <code data-x="">posterloading</code>
126500+
<td> <code data-x="attr-video-posterloading">video</code>
126501+
<td> Used when determining loading deferral of the poster frame
126502+
<td> "<code data-x="attr-loading-lazy">lazy</code>";
126503+
"<code data-x="attr-loading-eager">eager</code>"
126441126504
<tr>
126442126505
<th> <code data-x="">preload</code>
126443126506
<td> <code data-x="attr-media-preload">audio</code>;

0 commit comments

Comments
 (0)