10BC0 [css-values-4][css-images-4][css-fonts-4] URL request modifiers by noamr · Pull Request #8222 · w3c/csswg-drafts · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion css-fonts-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3208,7 +3208,7 @@ downloadable fonts to avoid large page reflows where possible.
Font fetching requirements</h4>

<div algorithm>
To <dfn>fetch a font</dfn> given a selected [=/url=] |url| for ''@font-face'' |rule|,
To <dfn>fetch a font</dfn> given a selected <<url>> |url| for ''@font-face'' |rule|,
[=fetch a style resource|fetch=] |url|,
with stylesheet being |rule|'s <a spec=cssom for=CSSRule>parent CSS style sheet</a>,
destination "font",
Expand Down
2 changes: 1 addition & 1 deletion css-images-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ Fetching External Images {#fetching-images}
-------------------------------------------

To <dfn>fetch an external image for a stylesheet</dfn>,
given a [=/url=] |url| and {{CSSStyleSheet}} sheet,
given a <<url>> |url| and {{CSSStyleSheet}} sheet,
[=fetch a style resource=] given |url|,
with stylesheet {{CSSStyleSheet}},
destination "image",
Expand Down
74 changes: 52 additions & 22 deletions css-values-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,46 +1050,76 @@ URL Modifiers</h4>
URL Processing Model</h4>

<div algorithm>
To <dfn export>fetch a style resource</dfn> from [=/url=] |url|,
given a {{CSSStyleSheet}} |sheet|,
To <dfn export>fetch a style resource</dfn> from [=/url=] or
<<url>> |urlValue|, given a {{CSSStyleSheet}} |sheet|,
a string |destination| matching a {{RequestDestination}},
a "no-cors" or "cors" |corsMode|,
and an algorithm |processResponse| accepting a [=/response=] and a null, failure or byte
stream:

1. Let |environmentSettings| be |sheet|'s [=relevant settings object=].

3. Let |documentBase| be |environmentSettings|'s [=API base URL=].
2. Let |base| be |sheet|'s <a spec=cssom>stylesheet base URL</a> if it is not null, otherwise
|environmentSettings|'s [=API base URL=]. [[CSSOM]]

4. Let |base| be |sheet|'s <a spec=cssom>stylesheet base URL</a>. [[CSSOM]]

5. Let |referrer| be |documentBase|.

6. If |base| is null, set |base| to |documentBase|.

7. Let |parsedUrl| be the result of the [=URL parser=] steps with |url| and |base|.
3. Let |parsedUrl| be the result of the [=URL parser=] steps with |urlValue|'s [=/url=] and |base|.
If the algorithm returns an error, return.

8. If |corsMode| is "cors", set |referrer| to |sheet|'s
<a spec=cssom>location</a>. [[CSSOM]]

9. Let |req| be a new [=/request=] whose [=request/url=] is |parsedUrl|, whose
4. Let |req| be a new [=/request=] whose [=request/url=] is |parsedUrl|, whose
[=request/destination=] is |destination|, [=request/mode=] is |corsMode|,
[=request/origin=] is |environmentSettings|'s [=environment settings object/origin=],
[=request/credentials mode=] is "same-origin", [=request/use-url-credentials flag=] is
set, [=request/client=] is |environmentSettings|, and whose [=request/referrer=] is
|referrer|.
|environmentSettings|'s [=API base URL=].

5. [=Apply request modifiers from URL value=] given |req| and |urlValue|.

10. If |sheet|'s <a spec=cssom>origin-clean flag</a> is set, set |req|'s
[=request/initiator type=] to "css". [[CSSOM]]
6. If |req|'s [=request/mode=] is "cors",
set |req|'s [=request/referrer=] to |sheet|'s <a spec=cssom>location</a>. [[CSSOM]]

11. [=/Fetch|fetching=] |req|, with [=fetch/processresponseconsumebody=] set to
|processResponse|.
7. If |sheet|'s <a spec=cssom>origin-clean flag</a> is set,
set |req|'s [=request/initiator type=] to "css". [[CSSOM]]

8. [=/Fetch=] |req|,
with [=fetch/processresponseconsumebody=] set to |processResponse|.
</div>

Note: Resources loaded through CSS style sheets
are cached and cleared the same as any other resources
linked from the document.
<h4 id='request-url-modifiers'>
Request URL Modifiers</h4>

The <dfn><<request-url-modifier>></dfn>s represent <<url-modifier>>s that affect the resource's
[=/request=]. Each <<request-url-modifier>> has a <dfn>request modifier steps</dfn> which accepts
a [=/request=].

<pre class=prod>
<<request-url-modifier>> = <<crossorigin-modifier>> | <<integrity-modifier>> | <<referrerpolicy-modifier>>
<<crossorigin-modifier>> = crossorigin(anonymous | use-credentials)
<<integrity-modifier>> = integrity(<<string>>)
<<referrerpolicy-modifier>> = referrerpolicy(no-referrer | no-referrer-when-downgrade | same-origin | origin | strict-origin | origin-when-cross-origin | strict-origin-when-cross-origin | unsafe-url)
</pre>

<dl dfn-for="<<request-url-modifier>>">
<dt><dfn><<crossorigin-modifier>></dfn> = <dfn function lt="crossorigin()">crossorigin</dfn>(<dfn value>anonymous</dfn> | <dfn value>use-credentials</dfn>)
<dd>The [=request modifier steps=] for this modifier given [=/request=] |req| are:
1. Set [=/request=]'s [=request/mode=] to "cors".

2. If the given value is ''use-credentials'', set [=/request=]'s
[=request/credentials mode=] to "include".

<dt><dfn><<integrity-modifier>></dfn> = <dfn function lt="integrity()">integrity</dfn>(<<string>>)
<dd>The [=request modifier steps=] for this modifier given [=/request=] |req| are to set
[=/request=]'s [=request/integrity metadata=] to the given <<string>>.

<dt><dfn><<referrerpolicy-modifier>></dfn> = <dfn function lt="referrerpolicy()">referrerpolicy</dfn>(<dfn value>no-referrer</dfn> | <dfn value>no-referrer-when-downgrade</dfn> | <dfn value>same-origin</dfn> | <dfn value>origin</dfn> | <dfn value>strict-origin</dfn> | <dfn value>origin-when-cross-origin</dfn> | <dfn value>strict-origin-when-cross-origin</dfn> | <dfn value>unsafe-url</dfn>)
<dd>The [=request modifier steps=] for this modifier given [=/request=] |req| are to set
[=/request=]'s [=request/referrer policy=] to the {{ReferrerPolicy}} that matches the given value.
</dl>

<div algorithm>
To <dfn>apply request modifiers from URL value</dfn> given a [=/request=] |req| and a <<url>>
|url|, call the [=request modifier steps=] for |url|'s <<request-url-modifier>>s in sequence
given |req|.
</div>

<h2 id="numeric-types">
Numeric Data Types</h2>
Expand Down
0