Skip to content

Commit

Permalink
Fix bugs in source parser
Browse files Browse the repository at this point in the history
Fixes #9648, fixes #9649
  • Loading branch information
zcorpan committed Sep 5, 2023
1 parent e90b823 commit 1b6f84a
Showing 1 changed file with 28 additions and 20 deletions.
48 changes: 28 additions & 20 deletions source
Expand Up @@ -29769,9 +29769,8 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
<p>This example is the same as the previous example, but the image is <span
data-x="attr-loading-lazy-state">lazy-loaded</span>. In this case, the <code
data-x="attr-img-sizes">sizes</code> attribute can use the <code
data-x="valdef-sizes-auto">auto</code> keyword (or the <code
data-x="attr-img-sizes">sizes</code> attribute can be omitted), and the user agent will use the
<code data-x="attr-dim-width">width</code> attribute (or the width specified in CSS) for the
data-x="valdef-sizes-auto">auto</code> keyword, and the user agent will use the <code
data-x="attr-dim-width">width</code> attribute (or the width specified in CSS) for the
<span>source size</span>.</p>

<pre><code class="html">&lt;img <strong>loading="lazy" width="200" height="200" sizes="auto"</strong>
Expand Down Expand Up @@ -30068,7 +30067,8 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
<span>update the image data</span> or <span data-x="img-environment-changes">react to environment
changes</span> algorithms) <span>allows auto-sizes</span> and is <span>being rendered</span>,
then <code data-x="valdef-sizes-auto">auto</code> is the <span>concrete object size</span> width.
Otherwise, <code data-x="valdef-sizes-auto">auto</code> is <code data-x="">100vw</code>.</p>
Otherwise, the <code data-x="valdef-sizes-auto">auto</code> value is ignored and the next
<span>source size</span> is used instead, if any.</p>

<p>The <code data-x="valdef-sizes-auto">auto</code> keyword may be specified in the <code
data-x="attr-source-sizes">sizes</code> attribute of <code>source</code> elements and <code
Expand Down Expand Up @@ -31406,13 +31406,28 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
Otherwise, there is a <span data-x="concept-microsyntax-parse-error">parse error</span>;
<span>continue</span>.</p></li>

<li><p>Remove all consecutive <span>&lt;whitespace-token></span>s
from the end of <var>unparsed size</var>.
If <var>unparsed size</var> is now empty,
then return <var>size</var>.
If this was not the keyword <code data-x="valdef-sizes-auto">auto</code> and
it was not the last item in <var>unparsed sizes list</var>,
that is a <span data-x="concept-microsyntax-parse-error">parse error</span>.</p></li>
<li>
<p>If <var>size</var> is <code data-x="valdef-sizes-auto">auto</code>, and <var>img</var>
is not null, and <var>img</var> is <span>being rendered</span>, and <var>img</var>
<span>allows auto-sizes</span>, then set <var>size</var> to the <span>concrete object
size</span> width of <var>img</var>, in <span data-x="'px'">CSS pixels</span>.</p>

<p class="note">If <var>size</var> is still <code data-x="valdef-sizes-auto">auto</code>,
then it will be ignored.</p>
</li>

<li>
<p>Remove all consecutive <span>&lt;whitespace-token></span>s from the end of <var>unparsed
size</var>. If <var>unparsed size</var> is now empty:</p>

<ol>
<li><p>If this was not the last item in <var>unparsed sizes list</var>, that is a <span
data-x="concept-microsyntax-parse-error">parse error</span>.</p></li>

<li><p>If <var>size</var> is not <code data-x="valdef-sizes-auto">auto</code>, then return
<var>size</var>. Otherwise, continue.</p></li>
</ol>
</li>

<li><p>Parse the remaining <span data-x="component value">component values</span> in <var>unparsed size</var>
as a <span>&lt;media-condition></span>.
Expand All @@ -31421,18 +31436,11 @@ was an English &lt;a href="/wiki/Music_hall">music hall&lt;/a> singer, ...</code
<span>continue</span>. <ref>MQ</ref></p></li>

<li><p>If <var>size</var> is not <code data-x="valdef-sizes-auto">auto</code>, then return
<var>size</var>.</p></li>
<var>size</var>. Otherwise, continue.</p></li>
</ol>
</li>

<li><p>Assert: <var>size</var> is null or <code data-x="valdef-sizes-auto">auto</code>.</p></li>

<li><p>If <var>img</var> is null, or <var>img</var> is not <span>being rendered</span>, or
<var>img</var> does not <span data-x="allows auto-sizes">allow auto-sizes</span>, then return
<code data-x="">100vw</code>.</p></li>

<li><p>Return the <span>concrete object size</span> width of <var>img</var>, in <span
data-x="'px'">CSS pixels</span>.</p></li>
<li><p>Return <code data-x="">100vw</code>.</p></li>
</ol>

<p class="note">It is invalid to use a bare <span>&lt;source-size-value></span> that is a <span>&lt;length></span>
Expand Down

0 comments on commit 1b6f84a

Please sign in to comment.