Skip to content

Commit 7702ece

Browse files
committed
[cssom-1] Light rewrite of the fetching algos to use the new Fetch algo style of algorithm-passing.
1 parent d0b9780 commit 7702ece

File tree

1 file changed

+147
-128
lines changed

1 file changed

+147
-128
lines changed

cssom-1/Overview.bs

Lines changed: 147 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -1320,33 +1320,42 @@ relation type is an
13201320

13211321
### Fetching CSS style sheets ### {#fetching-css-style-sheets}
13221322

1323-
To <dfn export>fetch a CSS style sheet</dfn> with parsed URL <var>parsed URL</var>, referrer <var>referrer</var>, document
1324-
<var>document</var>, optionally a set of parameters <var>parameters</var> (used as input to creating a
1325-
<a>request</a>), follow these steps:
1323+
<div algorithm>
1324+
To <dfn export>fetch a CSS style sheet</dfn>
1325+
with parsed URL <var>parsed URL</var>,
1326+
referrer <var>referrer</var>,
1327+
document <var>document</var>,
1328+
optionally a set of parameters <var>parameters</var>
1329+
(used as input to creating a <a>request</a>),
1330+
and an algorithm for handling the response result <var>processTheResponse</var> that takes a response,
1331+
follow these steps:
13261332

1327-
<ol>
1328-
<li>Let <var>origin</var> be <var>document</var>'s <a for=/>origin</a>.
1329-
1330-
<li>Let <var>request</var> be a new <a>request</a>, with the
1331-
<a for=request>url</a> <var>parsed URL</var>,
1332-
<a for=request>origin</a> <var>origin</var>,
1333-
<a for=request>referrer</a> <var>referrer</var>, and if specified the set of parameters <var>parameters</var>.
1333+
<ol>
1334+
<li>Let <var>origin</var> be <var>document</var>'s <a for=/>origin</a>.
13341335

1335-
<li>Let <var>response</var> be the result of <a>fetching</a> <var>request</var>.
1336+
<li>Let <var>request</var> be a new <a>request</a>, with the
1337+
<a for=request>url</a> <var>parsed URL</var>,
1338+
<a for=request>origin</a> <var>origin</var>,
1339+
<a for=request>referrer</a> <var>referrer</var>, and if specified the set of parameters <var>parameters</var>.
13361340

1337-
<li>Wait until <var>response</var> is available.
1341+
<li><a>Fetch</a> <var>request</var>,
1342+
with <var>processResponseDone</var>, given <var>response</var>,
1343+
being the following steps:
13381344

1339-
<li>If <var>response</var> is a <a>network error</a>, return an error.
1345+
<ol>
1346+
<li>If <var>response</var> is a <a>network error</a>, return.
13401347

1341-
<li>If <var>document</var> is in <a>quirks mode</a>, <var>response</var> is
1342-
<a>CORS-same-origin</a> and the <a>Content-Type metadata</a> of <var>response</var> is not a
1343-
<a>supported styling language</a> change the <a>Content-Type metadata</a> of <var>response</var> to
1344-
<code>text/css</code>.
1348+
<li>If <var>document</var> is in <a>quirks mode</a>, <var>response</var> is
1349+
<a>CORS-same-origin</a> and the <a>Content-Type metadata</a> of <var>response</var> is not a
1350+
<a>supported styling language</a> change the <a>Content-Type metadata</a> of <var>response</var> to
1351+
<code>text/css</code>.
13451352

1346-
<li>If <var>response</var> is not in a <a>supported styling language</a> return an error.
1353+
<li>If <var>response</var> is not in a <a>supported styling language</a>, return.
13471354

1348-
<li>Return <var>response</var>.
1349-
</ol>
1355+
<li>Execute <var>processTheResponse</var> given <var>response</var>
1356+
</ol>
1357+
</ol>
1358+
</div>
13501359

13511360
### The {{LinkStyle}} Interface ### {#the-linkstyle-interface}
13521361

@@ -1410,93 +1419,97 @@ When a <code>ProcessingInstruction</code> <a>node</a> <var>node</var> becomes pa
14101419
<a>prolog</a>, is no longer part of the <a>prolog</a>, or has its <a>data</a> changed, these steps
14111420
must be run:
14121421

1413-
<ol>
1414-
<li>If an instance of this algorithm is currently running for <var>node</var>, abort that instance, and stop the associated
1415-
<a>fetching</a> if applicable.
1416-
1417-
<li>If <var>node</var> has an <a>associated CSS style sheet</a>, <a lt="remove a CSS style sheet">remove</a> it.
1422+
<div algorithm="handle a PI stylesheet">
1423+
<ol>
1424+
<li>If an instance of this algorithm is currently running for <var>node</var>, abort that instance, and stop the associated
1425+
<a>fetching</a> if applicable.
14181426

1419-
<li>If <var>node</var> is not an <a>xml-stylesheet processing instruction</a>, then return.
1427+
<li>If <var>node</var> has an <a>associated CSS style sheet</a>, <a lt="remove a CSS style sheet">remove</a> it.
14201428

1421-
<li>If <var>node</var> does not have an <code>href</code> <a>pseudo-attribute</a>, then return.
1429+
<li>If <var>node</var> is not an <a>xml-stylesheet processing instruction</a>, then return.
14221430

1423-
<li>Let <var>title</var> be the value of the
1424-
<code>title</code> <a>pseudo-attribute</a> or the empty string if the
1425-
<code>title</code> <a>pseudo-attribute</a> is not specified.
1431+
<li>If <var>node</var> does not have an <code>href</code> <a>pseudo-attribute</a>, then return.
14261432

1427-
<li>If there is an <code>alternate</code> <a>pseudo-attribute</a>
1428-
whose value is a <a>case-sensitive</a> match
1429-
for "<code>yes</code>" and <var>title</var> is the
1430-
empty string, then return.
1433+
<li>Let <var>title</var> be the value of the
1434+
<code>title</code> <a>pseudo-attribute</a> or the empty string if the
1435+
<code>title</code> <a>pseudo-attribute</a> is not specified.
14311436

1432-
<li>If there is a <code>type</code> <a>pseudo-attribute</a> whose
1433-
value is not a <a>supported styling language</a> the user agent
1434-
may return.
1437+
<li>If there is an <code>alternate</code> <a>pseudo-attribute</a>
1438+
whose value is a <a>case-sensitive</a> match
1439+
for "<code>yes</code>" and <var>title</var> is the
1440+
empty string, then return.
14351441

1436-
<li>Let <var>input URL</var> be the value specified by the
1437-
<code>href</code> <a>pseudo-attribute</a>.
1442+
<li>If there is a <code>type</code> <a>pseudo-attribute</a> whose
1443+
value is not a <a>supported styling language</a> the user agent
1444+
may return.
14381445

1439-
<li>Let <var>document</var> be <var>node</var>'s <a>node document</a>
1446+
<li>Let <var>input URL</var> be the value specified by the
1447+
<code>href</code> <a>pseudo-attribute</a>.
14401448

1441-
<li>Let <var>base URL</var> be <var>document</var>'s <a>document base URL</a>.
1449+
<li>Let <var>document</var> be <var>node</var>'s <a>node document</a>
14421450

1443-
<li>Let <var>referrer</var> be <var>document</var>'s <a lt="document URL">address</a>.
1451+
<li>Let <var>base URL</var> be <var>document</var>'s <a>document base URL</a>.
14441452

1445-
<li>Let <var>parsed URL</var> be the return value of invoking the <a>URL parser</a> with the
1446-
string <var>input URL</var> and the base URL <var>base URL</var>.
1453+
<li>Let <var>referrer</var> be <var>document</var>'s <a lt="document URL">address</a>.
14471454

1448-
<li>If <var>parsed URL</var> is failure, then return.
1455+
<li>Let <var>parsed URL</var> be the return value of invoking the <a>URL parser</a> with the
1456+
string <var>input URL</var> and the base URL <var>base URL</var>.
14491457

1450-
<li>Let <var>response</var> be the result of <a lt="fetch a CSS style sheet">fetching a CSS style sheet</a> with parsed URL <var>parsed URL</var>,
1451-
referrer <var>referrer</var> and document <var>document</var>.
1458+
<li>If <var>parsed URL</var> is failure, then return.
14521459

1453-
<li>If <var>response</var> is an error, then return.
1460+
<li>[=Fetch a CSS style sheet=]
1461+
with parsed URL <var>parsed URL</var>,
1462+
referrer <var>referrer</var>,
1463+
document <var>document</var>,
1464+
and <var>processTheResponse</var> given |response| being the following steps:
14541465

1455-
<li>
1456-
<a>Create a CSS style sheet</a> with the following properties:
1457-
1458-
<dl>
1459-
<dt><a>location</a>
1460-
<dd>The result of invoking the <a>URL serializer</a> with <var>parsed URL</var>.
1466+
<ol>
1467+
<li>
1468+
<a>Create a CSS style sheet</a> with the following properties:
14611469

1462-
<dt><a for=CSSStyleSheet>parent CSS style sheet</a>
1463-
<dd>null.
1470+
<dl>
1471+
<dt><a>location</a>
1472+
<dd>The result of invoking the <a>URL serializer</a> with <var>parsed URL</var>.
14641473

1465-
<dt><a for=CSSStyleSheet>owner node</a>
1466-
<dd><var>node</var>.
1474+
<dt><a for=CSSStyleSheet>parent CSS style sheet</a>
1475+
<dd>null.
14671476

1468-
<dt><a for=CSSStyleSheet>owner CSS rule</a>
1469-
<dd>null.
1477+
<dt><a for=CSSStyleSheet>owner node</a>
1478+
<dd><var>node</var>.
14701479

1471-
<dt><a>media</a>
1472-
<dd>The value of the <code>media</code> <a>pseudo-attribute</a>
1473-
if any, or the empty string otherwise.
1480+
<dt><a for=CSSStyleSheet>owner CSS rule</a>
1481+
<dd>null.
14741482

1475-
<dt><a>title</a>
1476-
<dd><var>title</var>.
1483+
<dt><a>media</a>
1484+
<dd>The value of the <code>media</code> <a>pseudo-attribute</a>
1485+
if any, or the empty string otherwise.
14771486

1478-
<dt><a>alternate flag</a>
1479-
<dd>Set if the <code>alternate</code> <a>pseudo-attribute</a>
1480-
value is a <a>case-sensitive</a> match for
1481-
"<code>yes</code>", or unset otherwise.
1487+
<dt><a>title</a>
1488+
<dd><var>title</var>.
14821489

1483-
<dt><a>origin-clean flag</a>
1484-
<dd>Set if <var>response</var> is <a>CORS-same-origin</a>, or unset otherwise.
1485-
</dl>
1490+
<dt><a>alternate flag</a>
1491+
<dd>Set if the <code>alternate</code> <a>pseudo-attribute</a>
1492+
value is a <a>case-sensitive</a> match for
1493+
"<code>yes</code>", or unset otherwise.
14861494

1487-
The CSS <a>environment encoding</a> is the result of running the following steps:
1495+
<dt><a>origin-clean flag</a>
1496+
<dd>Set if <var>response</var> is <a>CORS-same-origin</a>, or unset otherwise.
1497+
</dl>
14881498

1489-
<ol>
1490-
<li>If the element has a <code>charset</code>
1491-
<a>pseudo-attribute</a>,
1492-
<a>get an encoding</a> from that pseudo-attribute's value.
1493-
If that succeeds, return the resulting encoding and abort these steps.
1499+
The CSS <a>environment encoding</a> is the result of running the following steps:
14941500

1495-
<li>Otherwise, return the <a lt="encoding" for="Document">document's character encoding</a>.
1496-
[[!DOM]]
1497-
</ol>
1501+
<ol>
1502+
<li>If the element has a <code>charset</code>
1503+
<a>pseudo-attribute</a>,
1504+
<a>get an encoding</a> from that pseudo-attribute's value.
1505+
If that succeeds, return the resulting encoding and abort these steps.
14981506

1499-
</ol>
1507+
<li>Otherwise, return the <a lt="encoding" for="Document">document's character encoding</a>.
1508+
[[!DOM]]
1509+
</ol>
1510+
</ol>
1511+
</ol>
1512+
</div>
15001513

15011514
A style sheet referenced by an <a>xml-stylesheet processing instruction</a> using the rules in this section, in the context of
15021515
the {{Document}} of an <a>XML parser</a> is said to be
@@ -1519,72 +1532,78 @@ of the link relation types is an
15191532
for "<code>stylesheet</code>" these steps
15201533
must be run:
15211534

1522-
<ol>
1523-
<li>Let <var>title</var> be the value of the first of all the
1524-
<code>title</code> parameters.
1525-
If there are no such parameters it is the empty string.
1535+
<div algorithm="fetch a Link header stylesheet">
1536+
<ol>
1537+
<li>Let <var>title</var> be the value of the first of all the
1538+
<code>title</code> parameters.
1539+
If there are no such parameters it is the empty string.
15261540

1527-
<li>If one of the (other) link relation types is an
1528-
<a>ASCII case-insensitive</a> match for
1529-
"<code>alternate</code>" and <var>title</var> is the
1530-
empty string, then return.
1541+
<li>If one of the (other) link relation types is an
1542+
<a>ASCII case-insensitive</a> match for
1543+
"<code>alternate</code>" and <var>title</var> is the
1544+
empty string, then return.
15311545

1532-
<li>Let <var>input URL</var> be the value specified.
1546+
<li>Let <var>input URL</var> be the value specified.
15331547

1534-
Issue: Be more specific
1548+
Issue: Be more specific
15351549

1536-
<li>Let <var>base URL</var> be the document's <a>document base URL</a>.
1550+
<li>Let <var>base URL</var> be the document's <a>document base URL</a>.
15371551

1538-
Issue: Is there a document at this point?
1552+
Issue: Is there a document at this point?
15391553

1540-
<li>Let <var>referrer</var> be the document's <a lt="document URL">address</a>.
1554+
<li>Let <var>referrer</var> be the document's <a lt="document URL">address</a>.
15411555

1542-
<li>Let <var>origin</var> be the document's <a for=/>origin</a>.
1556+
<li>Let <var>origin</var> be the document's <a for=/>origin</a>.
15431557

1544-
<li>Let <var>parsed URL</var> be the return value of invoking the <a>URL parser</a> with the
1545-
string <var>input URL</var> and the base URL <var>base URL</var>.
1558+
<li>Let <var>parsed URL</var> be the return value of invoking the <a>URL parser</a> with the
1559+
string <var>input URL</var> and the base URL <var>base URL</var>.
15461560

1547-
<li>If <var>parsed URL</var> is failure, then return.
1561+
<li>If <var>parsed URL</var> is failure, then return.
15481562

1549-
<li>Let <var>response</var> be the result of <a lt="fetch a CSS style sheet">fetching a CSS style sheet</a> with parsed URL <var>parsed URL</var>,
1550-
referrer <var>referrer</var> and document being the document.
1563+
<li>[=Fetch a CSS style sheet=]
1564+
with parsed URL <var>parsed URL</var>,
1565+
referrer <var>referrer</var>,
1566+
document being the document,
1567+
and <var>processTheResponse</var>, given |response|, being the following steps:
15511568

1552-
Issue: What if the HTML parser hasn't decided on quirks/non-quirks yet?
1569+
Issue: What if the HTML parser hasn't decided on quirks/non-quirks yet?
15531570

1554-
<li>
1555-
<a>Create a CSS style sheet</a> with the following properties:
1556-
1557-
<dl>
1558-
<dt><a>location</a>
1559-
<dd>The result of invoking the <a>URL serializer</a> with <var>parsed URL</var>.
1571+
<ol>
1572+
<li>
1573+
<a>Create a CSS style sheet</a> with the following properties:
15601574

1561-
<dt><a for=CSSStyleSheet>owner node</a>
1562-
<dd>null.
1575+
<dl>
1576+
<dt><a>location</a>
1577+
<dd>The result of invoking the <a>URL serializer</a> with <var>parsed URL</var>.
15631578

1564-
<dt><a for=CSSStyleSheet>parent CSS style sheet</a>
1565-
<dd>null.
1579+
<dt><a for=CSSStyleSheet>owner node</a>
1580+
<dd>null.
15661581

1567-
<dt><a for=CSSStyleSheet>owner CSS rule</a>
1568-
<dd>null.
1582+
<dt><a for=CSSStyleSheet>parent CSS style sheet</a>
1583+
<dd>null.
15691584

1570-
<dt><a>media</a>
1571-
<dd>The value of the first <code>media</code> parameter.
1572-
<!-- XXX register media parameter? bah -->
1585+
<dt><a for=CSSStyleSheet>owner CSS rule</a>
1586+
<dd>null.
15731587

1574-
<dt><a>title</a>
1575-
<dd><var>title</var>.
1588+
<dt><a>media</a>
1589+
<dd>The value of the first <code>media</code> parameter.
1590+
<!-- XXX register media parameter? bah -->
15761591

1577-
<dt><a>alternate flag</a>
1578-
<dd>Set if one of the specified link relation type for this HTTP
1579-
<code>Link</code> header is an
1580-
<a>ASCII case-insensitive</a> match for
1581-
"<code>alternate</code>", or false otherwise.
1592+
<dt><a>title</a>
1593+
<dd><var>title</var>.
15821594

1583-
<dt><a>origin-clean flag</a>
1584-
<dd>Set if <var>response</var> is <a>CORS-same-origin</a>, or unset otherwise.
1585-
</dl>
1595+
<dt><a>alternate flag</a>
1596+
<dd>Set if one of the specified link relation type for this HTTP
1597+
<code>Link</code> header is an
1598+
<a>ASCII case-insensitive</a> match for
1599+
"<code>alternate</code>", or false otherwise.
15861600

1587-
</ol>
1601+
<dt><a>origin-clean flag</a>
1602+
<dd>Set if <var>response</var> is <a>CORS-same-origin</a>, or unset otherwise.
1603+
</dl>
1604+
</ol>
1605+
</ol>
1606+
</div>
15881607

15891608
A style sheet referenced by a HTTP <code>Link</code> header using the rules in this section is said to be <a>a style sheet
15901609
that is blocking scripts</a> if the style sheet was enabled when created,

0 commit comments

Comments
 (0)