Skip to content

[css-syntax-3][css-values-3][css-cascade-4][css-fonts-4] Formalize fetching and resource timing reporting #6715

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Nov 3, 2021
Merged
Prev Previous commit
Next Next commit
Tighten fetch integration, add shape support
  • Loading branch information
noamr committed Oct 11, 2021
commit 69379fb02650162271e2d4e6bd8c0c8f6bb27903
10 changes: 5 additions & 5 deletions css-cascade-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -281,10 +281,10 @@ Processing Stylesheet Imports</h3>
with stylesheet |parentStylesheet|,
destination "style",
CORS mode "no-cors",
and processResponse being the following steps given [=/response=] |response|:
and processResponse being the following steps given [=/response=] |response| and
byte stream, null or failure |byteStream|:

1. If |response| is a [=network error=] or its [=response/status=] is not an
[=ok status=], return.
1. If |maybeByteStream| is not a byte stream, return.

2. If |parentStylesheet| is in [=quirks mode=]
and |response| is [=CORS-same-origin=],
Expand All @@ -294,8 +294,8 @@ Processing Stylesheet Imports</h3>
3. If |content type| is not <code>"text/css"</code>,
return.

4. Let |importedStylesheet| be the result of [=Parse a stylesheet|parsing=] |response|'s
[=response/body=]'s [=body/stream=] given |parsedUrl|.
4. Let |importedStylesheet| be the result of [=Parse a stylesheet|parsing=] |byteStram|
given |parsedUrl|.

5. Set |importedStylesheet|'s <a spec=cssom>origin-clean flag</a> to
|parentStylesheet|'s <a spec=cssom>origin-clean flag</a>.
Expand Down
9 changes: 4 additions & 5 deletions css-fonts-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -2950,13 +2950,12 @@ Font fetching requirements</h4>
with stylesheet being |rule|'s <a spec=cssom for=CSSRule>parent CSS style sheet</a>,
destination "font",
CORS mode "cors",
and processResponse being the following steps given [=/response=] |res|:
and processResponse being the following steps given [=/response=] |res| and null, failure or a
byte stream |stream|:

1. Let |body| be |res|'s [=response/body=].
1. If |stream| is null, return.

1. If |body| is null, return.

1. ISSUE: Load a font from |body| according to its type.
2. ISSUE: Load a font from |stream| according to its type.
</div>

Note: The implications of this for authors are that fonts
Expand Down
21 changes: 21 additions & 0 deletions css-shapes-2/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,27 @@ Shapes from Image</h3>
that determines the relevant pixels to use
(both for defining a shape and for display).

<h2 id="fetching-external-shapes">
Fetching external shapes</h2>

To <dfn>fetch an external resource for a shape</dfn>, either an SVG or an image, given a
{{CSSStyleRule}} |rule|:
1. Let |parsedUrl| be the result of the [=URL parser=] steps with |rule|'s URL and |rule|'s
|parentStylesheet|'s <a spec=cssom>location</a>.
If the algorithm returns an error,
return. [[CSSOM]]

2. [=Fetch a style resource=] given |parsedUrl|,
with stylesheet being |rule|'s <a spec=cssom for=CSSRule>parent CSS style sheet</a>,
destination "image",
CORS mode "cors",
and processResponse being the following steps given [=/response=] |res| and null, failure or
a byte stream |byteStream|:
If |byteStream| is a byte stream,
apply the image or SVG to the appropriate shape-accepting property.

Note: shapes require CORS mode as their effect is detected by the document.


<h2 id="shapes-from-box-values">
Shapes from Box Values</h2>
Expand Down
26 changes: 15 additions & 11 deletions css-values-4/Overview.bs
Original file line number Diff line number Diff line change
Expand Up @@ -997,7 +997,8 @@ URL processing model</h4>
given a {{CSSStyleSheet}} |sheet|,
a string |destination| matching a {{RequestDestination}},
a "no-cors" or "cors" |corsMode|,
and an algorithm |processResponse| accepting a [=/response=]:
and an algorithm |processResponse| accepting a [=/response=] and a null, failure or byte
stream:

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

Expand All @@ -1009,29 +1010,32 @@ URL processing model</h4>

5. Let |referrer| be |documentBase|.

6. If |base| is null, set |base| to |documentBase|.
6. Let |handleResourceFetchDone| be to do nothing.

7. Let |parsedUrl| be the result of the [=URL parser=] steps with |url| and |base|.
7. If |base| is null, set |base| to |documentBase|.

8. Let |parsedUrl| be the result of the [=URL parser=] steps with |url| and |base|.
If the algorithm returns an error, return.

8. If |corsMode| is "cors", set |referrer| to |sheet|'s
9. 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
10. Let |req| be a new [=/request=] whose [=request/url=] is |parsedUrl|, whose
[=request/destination=] is |destination|, [=request/mode=] is |mode|, [=request/origin=]
is |environmentSettings|'s [=environment settings object/origin=],
[=request/credentials mode=] is "same-origin", [=request/use-url-credentials flag=] is
set, and whose [=request/header list=] is a [=/header list=] containing a [=header=]
with its [=header/name=] set to "referrer" and its [=header/value=] set to |referrer|.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is somewhat wrong. You want to set the referrer field on the request. That will set the Referer (note, one r less) header. But good that it sets it explicitly though as CSS cannot take it from the global.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, fixed.


10. [=/Fetch=] |req|, with |taskDestination| set to |global|, and |processResponse| set to
the following steps given [=/response=] |res|:

1. If |sheet|'s <a spec=cssom>origin-clean flag</a> is set, set |handleResourceFetchDone|
given [=/response=] |res| to [=finalize and report timing=] with |res|, |global|, and
11. [=/Fetch=] |req|, with |taskDestination| set to |global|, and |processResponseEndOfBody|
set to the following steps given [=/response=] |res| and Null, failure or byte stream
|byteStream|:
1. If |sheet|'s <a spec=cssom>origin-clean flag</a> is set,
[=finalize and report timing=] with |res|, |global|, and
<code>"css"</code>. [[CSSOM]]

2. Call |processResponseDone| with |res|.
2. Call |processResponse| with |res| and |byteStream|.

</div>

<h2 id="numeric-types">
Expand Down