Skip to content

Commit

Permalink
Fix script-blocking style sheet infrastructure
Browse files Browse the repository at this point in the history
In particular, fixes whatwg#4325, which documents a case where <link rel="stylesheet"> would increment, and never decrement, the script-blocking style sheet counter.

To do this without increasing the amount of action-at-a-distance in the spec, we move from a script-blocking style sheet counter to a script-blocking style sheet set. That also matches implementations better, and sets us up for fixing other issues in this area.
  • Loading branch information
domfarolino authored Jan 27, 2023
1 parent a9f103c commit 901c8c5
Showing 1 changed file with 34 additions and 23 deletions.
57 changes: 34 additions & 23 deletions source
Original file line number Diff line number Diff line change
Expand Up @@ -16879,9 +16879,9 @@ console.log(style.disabled); // false</code></pre>
base URL don't affect the CSS -->
</li>

<li><p>If <var>element</var> <span>contributes a script-blocking style sheet</span>, increment
<var>element</var>'s <span>node document</span>'s <span>script-blocking style sheet
counter</span> by 1.</p></li>
<li><p>If <var>element</var> <span>contributes a script-blocking style sheet</span>, <span
data-x="set append">append</span> <var>element</var> to its <span>node document</span>'s
<span>script-blocking style sheet set</span>.</p></li>

<li><p>If <var>element</var>'s <code data-x="attr-style-media">media</code> attribute's value
<span>matches the environment</span> and <var>element</var> is
Expand Down Expand Up @@ -16933,10 +16933,11 @@ console.log(style.disabled); // false</code></pre>

<ol>
<li><p><span>Assert</span>: <var>element</var>'s <span>node document</span>'s
<span>script-blocking style sheet counter</span> is greater than 0.</p></li>
<span>script-blocking style sheet set</span> <span data-x="list contains">contains</span>
<var>element</var>.</p></li>

<li><p>Decrement <var>element</var>'s <span>node document</span>'s <span>script-blocking
style sheet counter</span> by 1.</p></li>
<li><p><span data-x="list remove">Remove</span> <var>element</var> from its <span>node
document</span>'s <span>script-blocking style sheet set</span>.</p></li>
</ol>
</li>

Expand Down Expand Up @@ -17038,23 +17039,24 @@ console.log(style.disabled); // false</code></pre>
<code>&lt;?xml-stylesheet?></code> PIs. However, this has not yet been thoroughly
investigated.</p>

<p>A <code>Document</code> has a <dfn>script-blocking style sheet counter</dfn>, which is a
number, initially 0.</p>
<p>A <code>Document</code> has a <dfn>script-blocking style sheet set</dfn>, which is an <span
data-x="set">ordered set</span>, initially empty.</p>

<p>A <code>Document</code> <var>document</var> <dfn>has a style sheet that is blocking
scripts</dfn> if the following steps return true:</p>

<ol>
<li><p>If <var>document</var>'s <span>script-blocking style sheet counter</span> is greater than
0, then return true.</p></li>
<li><p>If <var>document</var>'s <span>script-blocking style sheet set</span> is not <span
data-x="list empty">empty</span>, then return true.</p></li>

<li><p>If <var>document</var>'s <span>node navigable</span> is null, then return false.</p></li>

<li><p>Let <var>containerDocument</var> be <var>document</var>'s <span>node navigable</span>'s
<span data-x="nav-container">container document</span>.</p></li>

<li><p>If <var>containerDocument</var> is non-null and <var>containerDocument</var>'s
<span>script-blocking style sheet counter</span> is greater than 0, then return true.</p></li>
<span>script-blocking style sheet set</span> is not <span data-x="list empty">empty</span>, then
return true.</p></li>

<li><p>Return false.</p></li>
</ol>
Expand Down Expand Up @@ -26592,9 +26594,9 @@ document.body.appendChild(wbr);</code></pre>
<li><p>If <var>el</var>'s <code data-x="attr-link-disabled">disabled</code> attribute is set,
then return false.</p></li>

<li><p>If <var>el</var> <span>contributes a script-blocking style sheet</span>, increment
<var>el</var>'s <span>node document</span>'s <span>script-blocking style sheet counter</span> by
1.</p></li>
<li><p>If <var>el</var> <span>contributes a script-blocking style sheet</span>, <span data-x="set
append">append</span> <var>el</var> to its <span>node document</span>'s <span>script-blocking
style sheet set</span>.</p></li>

<li><p>If <var>el</var>'s <code data-x="attr-link-media">media</code> attribute's value
<span>matches the environment</span> and <var>el</var> is
Expand Down Expand Up @@ -26629,10 +26631,19 @@ document.body.appendChild(wbr);</code></pre>
<li><p>If the resource's <span data-x="Content-Type">Content-Type metadata</span> is not
<code>text/css</code>, then set <var>success</var> to false.</p></li>

<li><p>If <var>el</var> no longer creates an <span>external resource link</span> that contributes
to the styling processing model, or if, since the resource in question was <span
data-x="fetch and process the linked resource">fetched</span>, it has become appropriate to <span
data-x="fetch and process the linked resource">fetch</span> it again, then return.</p></li>
<li>
<p>If <var>el</var> no longer creates an <span>external resource link</span> that contributes to
the styling processing model, or if, since the resource in question was <span data-x="fetch and
process the linked resource">fetched</span>, it has become appropriate to <span data-x="fetch
and process the linked resource">fetch</span> it again, then:</p>

<ol>
<li><p><span data-x="list remove">Remove</span> <var>el</var> from <var>el</var>'s <span>node
document</span>'s <span>script-blocking style sheet set</span>.</p></li>

<li><p>Return.</p></li>
</ol>
</li>

<li><p>If <var>el</var> has an <span>associated CSS style sheet</span>, <span data-x="remove a
CSS style sheet">remove the CSS style sheet</span>.</p></li>
Expand Down Expand Up @@ -26727,10 +26738,10 @@ document.body.appendChild(wbr);</code></pre>

<ol>
<li><p><span>Assert</span>: <var>el</var>'s <span>node document</span>'s <span>script-blocking
style sheet counter</span> is greater than 0.</p></li>
style sheet set</span> <span data-x="list contains">contains</span> <var>el</var>.</p></li>

<li><p>Decrement <var>el</var>'s <span>node document</span>'s <span>script-blocking style
sheet counter</span> by 1.</p></li>
<li><p><span data-x="list remove">Remove</span> <var>el</var> from its <span>node
document</span>'s <span>script-blocking style sheet set</span>.</p></li>
</ol>
</li>

Expand Down Expand Up @@ -77791,8 +77802,8 @@ partial interface <span id="NavigatorUserActivation-partial">Navigator</span> {
and <span>continue</span>.</p></li>

<li>
<p>If <var>doc</var>'s <span>script-blocking style sheet counter</span> is greater than 0,
then return.</p>
<p>If <var>doc</var>'s <span>script-blocking style sheet set</span> is not <span data-x="list
empty">empty</span>, then return.</p>

<p class="note">In this case, <var>element</var> is the currently-best candidate, but
<var>doc</var> is not ready for autofocusing. We'll try again next time <span>flush
Expand Down

0 comments on commit 901c8c5

Please sign in to comment.