Skip to content

Commit 53ead22

Browse files
authored
Merge pull request #6715 from noamr/resource-load
[css-syntax-3][css-values-3][css-cascade-4][css-fonts-4] Formalize fetching and resource timing reporting
2 parents 5f878c0 + 45e648d commit 53ead22

File tree

7 files changed

+129
-68
lines changed

7 files changed

+129
-68
lines changed

css-cascade-4/Overview.bs

Lines changed: 25 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -267,82 +267,45 @@ Processing Stylesheet Imports</h3>
267267
<div algorithm>
268268
To <dfn export>fetch an @import</dfn>, given an ''@import'' rule |rule|:
269269

270-
1. If |rule| has a <<supports-condition>>,
271-
and that condition is not true,
272-
return nothing.
273-
274-
1. [=Parse a URL=] given |rule|'s URL,
275-
relative to |rule|'s [=CSSRule/parent CSS style sheet's=] [=CSSStyleSheet/location=].
276-
277-
Issue: Make sure this is defined correctly,
278-
drawing from the document when it's a <{style}> element, etc.
279-
280-
If that fails, then return nothing. Otherwise, let |url| be the [=resulting URL record=].
270+
1. Let |parentStylesheet| be |rule|'s <a spec=cssom for=CSSRule>parent CSS style sheet</a>.
271+
[[CSSOM]]
281272

282-
2. Let |request| be a new [=/request=]
283-
whose [=request/URL=] is |url|,
284-
[=request/destination=] is <code>"style"</code>,
285-
[=request/mode=] is <code>"no-cors"</code>,
286-
[=request/credentials mode=] is <code>"include"</code>,
287-
and whose [=request/use-URL-credentials flag=] is set.
288-
289-
3. Set |request|'s client to ????
290-
291-
Issue: The Fetch spec doesn't provide any information about what a client is
292-
or what it does,
293-
so I have no idea of what to provide here.
294-
295-
4. Run the following steps [=in parallel=]:
273+
2. If |rule| has a <<supports-condition>>,
274+
and that condition is not true,
275+
return.
296276

297-
1. Let |response| be the result of [=/fetching=] |request|.
277+
3. Let |parsedUrl| be the result of the [=URL parser=] steps with |rule|'s URL and
278+
|parentStylesheet|'s <a spec=cssom>location</a>.
279+
If the algorithm returns an error,
280+
return. [[CSSOM]]
298281

299-
2. Let |success| initially be true.
282+
4. [=Fetch a style resource=] from |parsedUrl|,
283+
with stylesheet |parentStylesheet|,
284+
destination "style",
285+
CORS mode "no-cors",
286+
and processResponse being the following steps given [=/response=] |response| and
287+
byte stream, null or failure |byteStream|:
300288

301-
3. If |response| is a [=network error=]
302-
or its [=response/status=] is not an [=ok status=],
303-
set |success| to false.
289+
1. If |maybeByteStream| is not a byte stream, return.
304290

305-
4. If |rule|'s [=CSSRule/parent style sheet=] is in [=quirks mode=]
291+
2. If |parentStylesheet| is in [=quirks mode=]
306292
and |response| is [=CORS-same-origin=],
307293
let |content type| be <code>"text/css"</code>.
308294
Otherwise, let |content type| be the Content Type metadata of |response|.
309295

310-
5. If |content type| is not <code>"text/css"</code>,
296+
3. If |content type| is not <code>"text/css"</code>,
311297
return.
312298

313-
6. Issue: Do we wait for sub-imports to run now?
314-
Need to explore this.
299+
4. Let |importedStylesheet| be the result of [=Parse a stylesheet|parsing=] |byteStram|
300+
given |parsedUrl|.
315301

316-
7. Let |global| be the result of [=finding the relevant global object for a stylesheet=]
317-
given |rule|'s [=CSSRule/parent CSS style sheet=].
302+
5. Set |importedStylesheet|'s <a spec=cssom>origin-clean flag</a> to
303+
|parentStylesheet|'s <a spec=cssom>origin-clean flag</a>.
318304

319-
8. [=Queue a global task=],
320-
given the [=networking task source=]
321-
and |global|,
322-
to [=process an imported stylesheet=]
323-
given |rule|,
324-
|success|,
325-
and |response|.
326-
</div>
327-
328-
<div algorithm>
329-
To <dfn export>find the relevant global object for a stylesheet</dfn> given a CSS style sheet |stylesheet|:
330-
331-
1. If |stylesheet| has a [=CSSStyleSheet/parent CSS style sheet=],
332-
return the result of [=finding the relevant global object for a stylesheet=]
333-
given the [=CSSStyleSheet/parent CSS style sheet=].
334-
335-
2. If |stylesheet| has an [=CSSStyleSheet/owner node=],
336-
return the [=CSSStyleSheet/owner node's=] [=relevant global object=].
337-
</div>
338-
339-
<div algorithm>
340-
To <dfn export>process an imported stylesheet</dfn>
341-
given a parent rule |rule|,
342-
a success flag |success|,
343-
and a response |response|:
305+
6. If |response| is not [=CORS-same-origin=], unset |importedStylesheet|'s
306+
<a spec=cssom>origin-clean flag</a>.
344307

345-
Issue: Create a stylesheet, assign it to the parent rule.
308+
7. Set |rule|'s {{CSSImportRule/styleSheet}} to |importedStylesheet|.
346309
</div>
347310

348311
<h3 id='content-type'>

css-color-4/Overview.bs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4211,6 +4211,17 @@ Specifying a color profile: the ''@color-profile'' at-rule</h3>
42114211
which reference this profile
42124212
are <a>invalid color</a>s.
42134213

4214+
To <dfn>fetch an external color profile</dfn>, given a
4215+
''@color-profile'' rule |rule|,
4216+
[=fetch a style resource=] given |rule|'s URL,
4217+
with stylesheet being |rule|'s <a spec=cssom for=CSSRule>parent CSS style sheet</a>,
4218+
destination "color-profile",
4219+
CORS mode "cors",
4220+
and processResponse being the following steps given [=/response=] |res| and null, failure or
4221+
a byte stream |byteStream|:
4222+
If |byteStream| is a byte stream,
4223+
apply the color profile as parsed from |byteStream.
4224+
42144225
Note: The Internet Media Type ("MIME type")
42154226
for ICC profiles is
42164227
<a href="https://www.iana.org/assignments/media-types/application/vnd.iccprofile">application/vnd.iccprofile</a>.

css-fonts-4/Overview.bs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2853,9 +2853,19 @@ downloadable fonts to avoid large page reflows where possible.
28532853
<h4 id="font-fetching-requirements" oldids="same-origin-restriction,allowing-cross-origin-font-loading">
28542854
Font fetching requirements</h4>
28552855

2856-
For font loads from @font-face rules, user agents must create a <a>request</a>
2857-
whose <var>url</var> is the URL given by the @font-face rule, whose <var>referrer</var>
2858-
is the stylesheet's URL, and whose <var>origin</var> is the URL of the containing document.
2856+
<div algorithm>
2857+
To <dfn>fetch a font</dfn> given a selected [=/url=] |url| for ''@font-face'' |rule|,
2858+
[=fetch a style resource|fetch=] |url|,
2859+
with stylesheet being |rule|'s <a spec=cssom for=CSSRule>parent CSS style sheet</a>,
2860+
destination "font",
2861+
CORS mode "cors",
2862+
and processResponse being the following steps given [=/response=] |res| and null, failure or a
2863+
byte stream |stream|:
2864+
2865+
1. If |stream| is null, return.
2866+
2867+
2. ISSUE: Load a font from |stream| according to its type.
2868+
</div>
28592869

28602870
Note: The implications of this for authors are that fonts
28612871
will typically not be loaded cross-origin unless authors specifically

css-images-4/Overview.bs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<pre class='metadata'>
1+
uel<pre class='metadata'>
22
Title: CSS Images Module Level 4
33
Status: ED
44
Work Status: Exploring
@@ -140,6 +140,18 @@ Image References: the ''url()'' notation {#url-notation}
140140
Note: No change from [[css3-images]].
141141

142142

143+
Fetching External Images
144+
------------------------------------------------------------------------------------------
145+
To <dfn>fetch an external image for a stylesheet</dfn>,
146+
given a [=/url=] |url| and {{CSSStyleSheet}} sheet,
147+
[=fetch a style resource=] given |url|,
148+
with stylesheet {{CSSStyleSheet}},
149+
destination "image",
150+
CORS mode "no-cors",
151+
and processResponse being the following steps given [=/response=] |res| and null, failure or
152+
a byte stream |byteStream|:
153+
If |byteStream| is a byte stream, load the image from the byte stream.
154+
143155

144156
<!--
145157
████ ██ ██ ███ ██████ ████████ ██████ ████████ ████████ ███ ███

css-shapes-2/Overview.bs

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -423,6 +423,22 @@ Shapes from Image</h3>
423423
that determines the relevant pixels to use
424424
(both for defining a shape and for display).
425425

426+
<h2 id="fetching-external-shapes">
427+
Fetching external shapes</h2>
428+
429+
To <dfn>fetch an external resource for a shape</dfn>, either an SVG or an image, given a
430+
{{CSSStyleRule}} |rule|,
431+
[=fetch a style resource=] given |rule|'s URL,
432+
with stylesheet being |rule|'s <a spec=cssom for=CSSRule>parent CSS style sheet</a>,
433+
destination "image",
434+
CORS mode "cors",
435+
and processResponse being the following steps given [=/response=] |res| and null, failure or
436+
a byte stream |byteStream|:
437+
If |byteStream| is a byte stream,
438+
apply the image or SVG to the appropriate shape-accepting property.
439+
440+
Note: shapes require CORS mode as their effect is detected by the document.
441+
426442

427443
<h2 id="shapes-from-box-values">
428444
Shapes from Box Values</h2>

css-syntax-3/Overview.bs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,8 @@ Parse A Comma-Separated List According To A CSS Grammar</h4>
21212121
Parse a stylesheet</h4>
21222122

21232123
<div algorithm>
2124-
To <dfn export>parse a stylesheet</dfn> from an |input|:
2124+
To <dfn export>parse a stylesheet</dfn> from an |input|
2125+
given an optional [=/url=] |location|:
21252126

21262127
<ol>
21272128
<li>
@@ -2134,7 +2135,7 @@ Parse a stylesheet</h4>
21342135
and set |input| to the result.
21352136

21362137
<li>
2137-
Create a new stylesheet.
2138+
Create a new stylesheet, with its <a spec=cssom>location</a> set to |location| (or null, if |location| was not passed).
21382139

21392140
<li>
21402141
<a>Consume a list of rules</a> from |input|,

css-values-4/Overview.bs

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,54 @@ URL Modifiers</h4>
999999
Note: A <<url>> that is either unquoted or not wrapped in ''url()'' notation
10001000
cannot accept any <<url-modifier>>s.
10011001

1002+
<h4 id='prcoessing-model'>
1003+
URL processing model</h4>
1004+
1005+
<div algorithm>
1006+
To <dfn export>fetch a style resource</dfn> from [=/url=] |url|,
1007+
given a {{CSSStyleSheet}} |sheet|,
1008+
a string |destination| matching a {{RequestDestination}},
1009+
a "no-cors" or "cors" |corsMode|,
1010+
and an algorithm |processResponse| accepting a [=/response=] and a null, failure or byte
1011+
stream:
1012+
1013+
1. Let |environmentSettings| be |sheet|'s [=relevant settings object=].
1014+
1015+
2. Let |global| be |environmentSettings|'s [=environment settings object/global object=].
1016+
1017+
3. Let |documentBase| be |environmentSettings|'s [=API base URL=].
1018+
1019+
4. Let |base| be |sheet|'s <a spec=cssom>stylesheet base URL</a>. [[CSSOM]]
1020+
1021+
5. Let |referrer| be |documentBase|.
1022+
1023+
6. Let |handleResourceFetchDone| be to do nothing.
1024+
1025+
7. If |base| is null, set |base| to |documentBase|.
1026+
1027+
8. Let |parsedUrl| be the result of the [=URL parser=] steps with |url| and |base|.
1028+
If the algorithm returns an error, return.
1029+
1030+
9. If |corsMode| is "cors", set |referrer| to |sheet|'s
1031+
<a spec=cssom>location</a>. [[CSSOM]]
1032+
1033+
10. Let |req| be a new [=/request=] whose [=request/url=] is |parsedUrl|, whose
1034+
[=request/destination=] is |destination|, [=request/mode=] is |corsMode|,
1035+
[=request/origin=] is |environmentSettings|'s [=environment settings object/origin=],
1036+
[=request/credentials mode=] is "same-origin", [=request/use-url-credentials flag=] is
1037+
set, and whose [=request/referrer=] is |referrer|.
1038+
1039+
11. [=/Fetch=] |req|, with |taskDestination| set to |global|, and |processResponseEndOfBody|
1040+
set to the following steps given [=/response=] |res| and Null, failure or byte stream
1041+
|byteStream|:
1042+
1. If |sheet|'s <a spec=cssom>origin-clean flag</a> is set,
1043+
[=finalize and report timing=] with |res|, |global|, and
1044+
<code>"css"</code>. [[CSSOM]]
1045+
1046+
2. Call |processResponse| with |res| and |byteStream|.
1047+
1048+
</div>
1049+
10021050
<h2 id="numeric-types">
10031051
Numeric Data Types</h2>
10041052

0 commit comments

Comments
 (0)