Skip to content

Commit af28538

Browse files
committed
[css-cascade-4] wip first version of fetching steps for @import w3c#4838
1 parent 90bb4b8 commit af28538

1 file changed

Lines changed: 107 additions & 3 deletions

File tree

css-cascade-4/Overview.bs

Lines changed: 107 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,19 +27,42 @@ Informative Classes: ex
2727

2828
<pre class=link-defaults>
2929
spec:css-values-3; type: value; text:ex
30+
spec:css-color-4; type:property; text:color
3031
spec:css-conditional-3; type:at-rule; text:@media
31-
spec:mediaqueries-4; type:type; for:@media; text:all
32-
spec:mediaqueries-4; type:type; text:<media-query>
32+
spec:css-fonts-4; type:property;
33+
text:font-family
34+
text:font-style
35+
spec:mediaqueries-4;
36+
type:type; text:<media-query>
37+
type:value; text:all; for:@media
3338
spec:css2; type:property; text:display
3439
spec:css2; type:value; text:red
40+
spec:html; type:element; text:style
3541
</pre>
3642

3743
<pre class=ignored-specs>
3844
spec:mediaqueries-5
3945
spec:css-values-4
40-
spec:css-fonts-4
4146
</pre>
4247

48+
<style>
49+
/* Put nice boxes around each algorithm. */
50+
[data-algorithm]:not(.heading) {
51+
padding: .5em;
52+
border: thin solid #ddd; border-radius: .5em;
53+
margin: .5em calc(-0.5em - 1px);
54+
}
55+
[data-algorithm]:not(.heading) > :first-child {
56+
margin-top: 0;
57+
}
58+
[data-algorithm]:not(.heading) > :last-child {
59+
margin-bottom: 0;
60+
}
61+
[data-algorithm] [data-algorithm] {
62+
margin: 1em 0;
63+
}
64+
</style>
65+
4366
<h2 id="intro">
4467
Introduction</h2>
4568

@@ -239,6 +262,87 @@ Processing Stylesheet Imports</h3>
239262

240263
The <a>environment encoding</a> of an imported style sheet is the encoding of the style sheet that imported it. [[css-syntax-3]]
241264

265+
<div algorithm>
266+
To <dfn export>fetch an @import</dfn>, given an ''@import'' rule |rule|:
267+
268+
1. If |rule| has a <<supports-condition>>,
269+
and that condition is not true,
270+
return nothing.
271+
272+
1. [=Parse a URL=] given |rule|'s URL,
273+
relative to |rule|'s [=CSSRule/parent CSS style sheet's=] [=CSSStyleSheet/location=].
274+
275+
Issue: Make sure this is defined correctly,
276+
drawing from the document when it's a <{style}> element, etc.
277+
278+
If that fails, then return nothing. Otherwise, let |url| be the [=resulting URL record=].
279+
280+
2. Let |request| be a new [=/request=]
281+
whose [=request/URL=] is |url|,
282+
[=request/destination=] is <code>"style"</code>,
283+
[=request/mode=] is <code>"no-cors"</code>,
284+
[=request/credentials mode=] is <code>"include"</code>,
285+
and whose [=request/use-URL-credentials flag=] is set.
286+
287+
3. Set |request|'s client to ????
288+
289+
Issue: The Fetch spec doesn't provide any information about what a client is
290+
or what it does,
291+
so I have no idea of what to provide here.
292+
293+
4. Run the following steps [=in parallel=]:
294+
295+
1. Let |response| be the result of [=/fetching=] |request|.
296+
297+
2. Let |success| initially be true.
298+
299+
3. If |response| is a [=network error=]
300+
or its [=response/status=] is not an [=ok status=],
301+
set |success| to false.
302+
303+
4. If |rule|'s [=CSSRule/parent style sheet=] is in [=quirks mode=]
304+
and |response| is [=CORS-same-origin=],
305+
let |content type| be <code>"text/css"</code>.
306+
Otherwise, let |content type| be the Content Type metadata of |response|.
307+
308+
5. If |content type| is not <code>"text/css"</code>,
309+
return.
310+
311+
6. Issue: Do we wait for sub-imports to run now?
312+
Need to explore this.
313+
314+
7. Let |global| be the result of [=finding the relevant global object for a stylesheet=]
315+
given |rule|'s [=CSSRule/parent CSS style sheet=].
316+
317+
8. [=Queue a global task=],
318+
given the [=networking task source=]
319+
and |global|,
320+
to [=process an imported stylesheet=]
321+
given |rule|,
322+
|success|,
323+
and |response|.
324+
</div>
325+
326+
<div algorithm>
327+
To <dfn export>find the relevant global object for a stylesheet</dfn> given a CSS style sheet |stylesheet|:
328+
329+
1. If |stylesheet| has a [=CSSStyleSheet/parent CSS style sheet=],
330+
return the result of [=finding the relevant global object for a stylesheet=]
331+
given the [=CSSStyleSheet/parent CSS style sheet=].
332+
333+
2. If |stylesheet| has an [=CSSStyleSheet/owner node=],
334+
return the [=CSSStyleSheet/owner node's=] [=relevant global object=].
335+
</div>
336+
337+
<div algorithm>
338+
To <dfn export>process an imported stylesheet</dfn>
339+
given a parent rule |rule|,
340+
a success flag |success|,
341+
and a response |response|:
342+
343+
Issue: Create a stylesheet, assign it to the parent rule.
344+
</div>
345+
242346
<h3 id='content-type'>
243347
Content-Type of CSS Style Sheets</h3>
244348

0 commit comments

Comments
 (0)