From 64becb59fe678760608a6f2a8d6bfb3a334500c9 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 5 Oct 2021 11:08:49 +0300 Subject: [PATCH 01/14] Formalize fetching and resource timing reporting Add a generic method to fetch style resources, and make use of it in fonts & imports. [css-syntax-3]: Make sure we have a location when parsing a stylesheet. [css-values-3]: Add a reusable method to fetch a style-originated resource. [css-cascade-4]: Formalize the import algorithm to use the new fetch method. [css=fonts-4]: Formalize font loading to use the new fetch method. --- css-cascade-4/Overview.bs | 82 ++++++++++----------------------------- css-fonts-4/Overview.bs | 15 +++++-- css-syntax-3/Overview.bs | 5 ++- css-values-4/Overview.bs | 44 +++++++++++++++++++++ 4 files changed, 80 insertions(+), 66 deletions(-) diff --git a/css-cascade-4/Overview.bs b/css-cascade-4/Overview.bs index 844f9fa8b18..0c9b48c3814 100644 --- a/css-cascade-4/Overview.bs +++ b/css-cascade-4/Overview.bs @@ -265,82 +265,42 @@ Processing Stylesheet Imports
To fetch an @import, given an ''@import'' rule |rule|: + 1. Let |parentStylesheet| be |rule|'s parent CSS style sheet. + [[CSSOM]] + 1. If |rule| has a <>, and that condition is not true, - return nothing. - - 1. [=Parse a URL=] given |rule|'s URL, - relative to |rule|'s [=CSSRule/parent CSS style sheet's=] [=CSSStyleSheet/location=]. - - Issue: Make sure this is defined correctly, - drawing from the document when it's a <{style}> element, etc. - - If that fails, then return nothing. Otherwise, let |url| be the [=resulting URL record=]. - - 2. Let |request| be a new [=/request=] - whose [=request/URL=] is |url|, - [=request/destination=] is "style", - [=request/mode=] is "no-cors", - [=request/credentials mode=] is "include", - and whose [=request/use-URL-credentials flag=] is set. - - 3. Set |request|'s client to ???? - - Issue: The Fetch spec doesn't provide any information about what a client is - or what it does, - so I have no idea of what to provide here. - - 4. Run the following steps [=in parallel=]: + return. - 1. Let |response| be the result of [=/fetching=] |request|. + 1. Let |parsedUrl| be the result of the [=URL parser=] steps with |relativeUrl| and + |parentStylesheet|'s location. If the algorithm returns an error, + return. [[CSSOM]] - 2. Let |success| initially be true. + 1. [=Fetch a style resource=] |parsedUrl|, with |parentStylesheet|, "style", "no-cors", + and the following steps given [=/response=] |response|: - 3. If |response| is a [=network error=] - or its [=response/status=] is not an [=ok status=], - set |success| to false. + 1. If |response| is a [=network error=] or its [=response/status=] is not an + [=ok status=], return. - 4. If |rule|'s [=CSSRule/parent style sheet=] is in [=quirks mode=] + 1. If |parentStylesheet| is in [=quirks mode=] and |response| is [=CORS-same-origin=], let |content type| be "text/css". Otherwise, let |content type| be the Content Type metadata of |response|. - 5. If |content type| is not "text/css", + 1. If |content type| is not "text/css", return. - 6. Issue: Do we wait for sub-imports to run now? - Need to explore this. + 1. Let |importedStylesheet| be the result of [=Parse a stylesheet|parsing=] |response|'s + [=response/body=]'s [=body/stream=] given |parsedUrl|. - 7. Let |global| be the result of [=finding the relevant global object for a stylesheet=] - given |rule|'s [=CSSRule/parent CSS style sheet=]. + 1. Set |importedStylesheet|'s origin-clean flag to + |parentStylesheet|'s origin-clean flag. - 8. [=Queue a global task=], - given the [=networking task source=] - and |global|, - to [=process an imported stylesheet=] - given |rule|, - |success|, - and |response|. -
- -
- To find the relevant global object for a stylesheet given a CSS style sheet |stylesheet|: - - 1. If |stylesheet| has a [=CSSStyleSheet/parent CSS style sheet=], - return the result of [=finding the relevant global object for a stylesheet=] - given the [=CSSStyleSheet/parent CSS style sheet=]. - - 2. If |stylesheet| has an [=CSSStyleSheet/owner node=], - return the [=CSSStyleSheet/owner node's=] [=relevant global object=]. -
- -
- To process an imported stylesheet - given a parent rule |rule|, - a success flag |success|, - and a response |response|: + 1. If |response|'s [=response/url=]'s [=url/origin=] is not the [=same origin=] as + |rule|'s [=relevant settings object=]'s [=environment settings object/origin=], + unset |importedStylesheet|'s origin-clean flag. - Issue: Create a stylesheet, assign it to the parent rule. + 1. Set |rule|'s {{CSSImportRule/styleSheet}} to |importedStylesheet|.

diff --git a/css-fonts-4/Overview.bs b/css-fonts-4/Overview.bs index 86c3a96e889..1fe88a1ff83 100644 --- a/css-fonts-4/Overview.bs +++ b/css-fonts-4/Overview.bs @@ -2944,9 +2944,18 @@ downloadable fonts to avoid large page reflows where possible.

Font fetching requirements

-For font loads from @font-face rules, user agents must create a request -whose url is the URL given by the @font-face rule, whose referrer -is the stylesheet's URL, and whose origin is the URL of the containing document. +
+ To fetch a font given a selected [=/url=] |url| for ''@font-face'' |rule|, + [=fetch a style resource|fetch=] |url|, with |rule|'s + parent CSS style sheet, "font", "cors" and the following steps + given [=/response=] |res|: + + 1. Let |body| be |res|'s [=response/body=]. + + 1. If |body| is null, return. + + 1. ISSUE: Load a font from |body| according to its type. +
Note: The implications of this for authors are that fonts will typically not be loaded cross-origin unless authors specifically diff --git a/css-syntax-3/Overview.bs b/css-syntax-3/Overview.bs index f61283fb3b8..086d7dd8010 100644 --- a/css-syntax-3/Overview.bs +++ b/css-syntax-3/Overview.bs @@ -2121,7 +2121,8 @@ Parse A Comma-Separated List According To A CSS Grammar Parse a stylesheet
- To parse a stylesheet from an |input|: + To parse a stylesheet from an |input| given [=/url=] or Null |location| + (default null):
  1. @@ -2134,7 +2135,7 @@ Parse a stylesheet and set |input| to the result.
  2. - Create a new stylesheet. + Create a new stylesheet, with its location set to |location|.
  3. Consume a list of rules from |input|, diff --git a/css-values-4/Overview.bs b/css-values-4/Overview.bs index b5d8e56afba..e1c93a04c56 100644 --- a/css-values-4/Overview.bs +++ b/css-values-4/Overview.bs @@ -989,6 +989,50 @@ URL Modifiers Note: A <> that is either unquoted or not wrapped in ''url()'' notation cannot accept any <>s. +

    +URL processing model

    + +
    + To fetch a style resource [=/url=] |url|, given a {{CSSStyleSheet}} + |sheet|, a string |destination|, a "no-cors" or "cors" |corsMode|, and an algorithm + |processResponse| accepting a [=/response=]: + + 1. Let |environmentSettings| be |sheet|'s [=relevant settings object=]. + + 1. Let |global| be |environmentSettings|'s [=environment settings object/global object=]. + + 1. Let |documentBase| be |environmentSettings|'s [=API base URL=]. + + 1. Let |base| be |sheet|'s stylesheet base URL. [[CSSOM]] + + 1. Let |referrer| be |documentBase|. + + 1. Let |handleResourceFetchDone| be to do nothing. + + 1. If |base| is null, set |base| to |documentBase|. + + 1. Let |parsedUrl| be the result of the [=URL parser=] steps with |url| and |base|. + If the algorithm returns an error, return. + + 1. If |corsMode| is not "cors", or |url| is the [=same origin=] as |environmentSettings|'s + [=environment settings object/origin=], set |referrer| to |sheet|'s + location. [[CSSOM]] + + 1. 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|. + + 1. If |sheet|'s origin-clean flag is set, set |handleResourceFetchDone| + given [=/response=] |res| to [=finalize and report timing=] with |res|, |global|, and + "css". [[CSSOM]] + + 1. [=/Fetch=] |req|, with |processResponseDone| set to |handleResourceFetchDone|, + |taskDestination| set to |global|, and |processResponse| set to |processResponse|. +
    +

    Numeric Data Types

    From 6865584ca83166e9f74294004eaf82a89e32bc4c Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 5 Oct 2021 13:27:33 +0300 Subject: [PATCH 02/14] Use more precise terms for same-origin --- css-cascade-4/Overview.bs | 5 ++--- css-values-4/Overview.bs | 3 +-- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/css-cascade-4/Overview.bs b/css-cascade-4/Overview.bs index 0c9b48c3814..b3a2cec7bf1 100644 --- a/css-cascade-4/Overview.bs +++ b/css-cascade-4/Overview.bs @@ -296,9 +296,8 @@ Processing Stylesheet Imports 1. Set |importedStylesheet|'s origin-clean flag to |parentStylesheet|'s origin-clean flag. - 1. If |response|'s [=response/url=]'s [=url/origin=] is not the [=same origin=] as - |rule|'s [=relevant settings object=]'s [=environment settings object/origin=], - unset |importedStylesheet|'s origin-clean flag. + 1. If |response| is not [=CORS-same-origin=], unset |importedStylesheet|'s + origin-clean flag. 1. Set |rule|'s {{CSSImportRule/styleSheet}} to |importedStylesheet|.
diff --git a/css-values-4/Overview.bs b/css-values-4/Overview.bs index e1c93a04c56..2412224f42d 100644 --- a/css-values-4/Overview.bs +++ b/css-values-4/Overview.bs @@ -1014,8 +1014,7 @@ URL processing model 1. Let |parsedUrl| be the result of the [=URL parser=] steps with |url| and |base|. If the algorithm returns an error, return. - 1. If |corsMode| is not "cors", or |url| is the [=same origin=] as |environmentSettings|'s - [=environment settings object/origin=], set |referrer| to |sheet|'s + 1. If |corsMode| is "cors", set |referrer| to |sheet|'s location. [[CSSOM]] 1. Let |req| be a new [=/request=] whose [=request/url=] is |parsedUrl|, whose From e47f6feb9af36c49e22e79ececc437f319f8fdd1 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 6 Oct 2021 12:06:51 +0300 Subject: [PATCH 03/14] Update css-fonts-4/Overview.bs Co-authored-by: Tab Atkins Jr. --- css-fonts-4/Overview.bs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/css-fonts-4/Overview.bs b/css-fonts-4/Overview.bs index 1fe88a1ff83..53c23b19890 100644 --- a/css-fonts-4/Overview.bs +++ b/css-fonts-4/Overview.bs @@ -2946,9 +2946,11 @@ Font fetching requirements
To fetch a font given a selected [=/url=] |url| for ''@font-face'' |rule|, - [=fetch a style resource|fetch=] |url|, with |rule|'s - parent CSS style sheet, "font", "cors" and the following steps - given [=/response=] |res|: + [=fetch a style resource|fetch=] |url|, + with stylesheet being |rule|'s parent CSS style sheet, + destination "font", + CORS mode "cors", + and processResponse being the following steps given [=/response=] |res|: 1. Let |body| be |res|'s [=response/body=]. From 05e285eb91d7050ff1ab5795754563e4803f7a8c Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 6 Oct 2021 12:06:57 +0300 Subject: [PATCH 04/14] Update css-cascade-4/Overview.bs Co-authored-by: Tab Atkins Jr. --- css-cascade-4/Overview.bs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/css-cascade-4/Overview.bs b/css-cascade-4/Overview.bs index b3a2cec7bf1..08cd6af9d8f 100644 --- a/css-cascade-4/Overview.bs +++ b/css-cascade-4/Overview.bs @@ -276,8 +276,11 @@ Processing Stylesheet Imports |parentStylesheet|'s location. If the algorithm returns an error, return. [[CSSOM]] - 1. [=Fetch a style resource=] |parsedUrl|, with |parentStylesheet|, "style", "no-cors", - and the following steps given [=/response=] |response|: + 1. [=Fetch a style resource=] from |parsedUrl|, + with stylesheet |parentStylesheet|, + destination "style", + CORS mode "no-cors", + and processResponse being the following steps given [=/response=] |response|: 1. If |response| is a [=network error=] or its [=response/status=] is not an [=ok status=], return. From 99b8996d190f3e2472422e027779371b498201d6 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 6 Oct 2021 12:07:04 +0300 Subject: [PATCH 05/14] Update css-values-4/Overview.bs Co-authored-by: Tab Atkins Jr. --- css-values-4/Overview.bs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/css-values-4/Overview.bs b/css-values-4/Overview.bs index 2412224f42d..756d5c4bd34 100644 --- a/css-values-4/Overview.bs +++ b/css-values-4/Overview.bs @@ -993,9 +993,11 @@ URL Modifiers URL processing model
- To fetch a style resource [=/url=] |url|, given a {{CSSStyleSheet}} - |sheet|, a string |destination|, a "no-cors" or "cors" |corsMode|, and an algorithm - |processResponse| accepting a [=/response=]: + To fetch a style resource from [=/url=] |url|, + given a {{CSSStyleSheet}} |sheet|, + a string |destination| matching a {{RequestDestination}}, + a "no-cors" or "cors" |corsMode|, + and an algorithm |processResponse| accepting a [=/response=]: 1. Let |environmentSettings| be |sheet|'s [=relevant settings object=]. From ab66419e10e48a3303b4583b44b83f219701100e Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 6 Oct 2021 12:07:39 +0300 Subject: [PATCH 06/14] Apply suggestions from code review Co-authored-by: Tab Atkins Jr. --- css-syntax-3/Overview.bs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/css-syntax-3/Overview.bs b/css-syntax-3/Overview.bs index 086d7dd8010..13f5b9ac656 100644 --- a/css-syntax-3/Overview.bs +++ b/css-syntax-3/Overview.bs @@ -2121,8 +2121,8 @@ Parse A Comma-Separated List According To A CSS Grammar Parse a stylesheet
- To parse a stylesheet from an |input| given [=/url=] or Null |location| - (default null): + To parse a stylesheet from an |input| + given an optional [=/url=] |location|:
  1. @@ -2135,7 +2135,7 @@ Parse a stylesheet and set |input| to the result.
  2. - Create a new stylesheet, with its location set to |location|. + Create a new stylesheet, with its location set to |location| (or null, if |location| was not passed).
  3. Consume a list of rules from |input|, From 34002f2c23a8a08200c35a8abd2df151954aa4c7 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Wed, 6 Oct 2021 12:46:40 +0300 Subject: [PATCH 07/14] Nits --- css-cascade-4/Overview.bs | 21 +++++++++++---------- css-values-4/Overview.bs | 22 +++++++++++----------- 2 files changed, 22 insertions(+), 21 deletions(-) diff --git a/css-cascade-4/Overview.bs b/css-cascade-4/Overview.bs index 08cd6af9d8f..cdc0512676a 100644 --- a/css-cascade-4/Overview.bs +++ b/css-cascade-4/Overview.bs @@ -268,15 +268,16 @@ Processing Stylesheet Imports 1. Let |parentStylesheet| be |rule|'s parent CSS style sheet. [[CSSOM]] - 1. If |rule| has a <>, + 2. If |rule| has a <>, and that condition is not true, return. - 1. Let |parsedUrl| be the result of the [=URL parser=] steps with |relativeUrl| and - |parentStylesheet|'s location. If the algorithm returns an error, + 3. Let |parsedUrl| be the result of the [=URL parser=] steps with |rule|'s URL and + |parentStylesheet|'s location. + If the algorithm returns an error, return. [[CSSOM]] - 1. [=Fetch a style resource=] from |parsedUrl|, + 4. [=Fetch a style resource=] from |parsedUrl|, with stylesheet |parentStylesheet|, destination "style", CORS mode "no-cors", @@ -285,24 +286,24 @@ Processing Stylesheet Imports 1. If |response| is a [=network error=] or its [=response/status=] is not an [=ok status=], return. - 1. If |parentStylesheet| is in [=quirks mode=] + 2. If |parentStylesheet| is in [=quirks mode=] and |response| is [=CORS-same-origin=], let |content type| be "text/css". Otherwise, let |content type| be the Content Type metadata of |response|. - 1. If |content type| is not "text/css", + 3. If |content type| is not "text/css", return. - 1. Let |importedStylesheet| be the result of [=Parse a stylesheet|parsing=] |response|'s + 4. Let |importedStylesheet| be the result of [=Parse a stylesheet|parsing=] |response|'s [=response/body=]'s [=body/stream=] given |parsedUrl|. - 1. Set |importedStylesheet|'s origin-clean flag to + 5. Set |importedStylesheet|'s origin-clean flag to |parentStylesheet|'s origin-clean flag. - 1. If |response| is not [=CORS-same-origin=], unset |importedStylesheet|'s + 6. If |response| is not [=CORS-same-origin=], unset |importedStylesheet|'s origin-clean flag. - 1. Set |rule|'s {{CSSImportRule/styleSheet}} to |importedStylesheet|. + 7. Set |rule|'s {{CSSImportRule/styleSheet}} to |importedStylesheet|.

diff --git a/css-values-4/Overview.bs b/css-values-4/Overview.bs index 756d5c4bd34..79f80152733 100644 --- a/css-values-4/Overview.bs +++ b/css-values-4/Overview.bs @@ -1001,36 +1001,36 @@ URL processing model

1. Let |environmentSettings| be |sheet|'s [=relevant settings object=]. - 1. Let |global| be |environmentSettings|'s [=environment settings object/global object=]. + 2. Let |global| be |environmentSettings|'s [=environment settings object/global object=]. - 1. Let |documentBase| be |environmentSettings|'s [=API base URL=]. + 3. Let |documentBase| be |environmentSettings|'s [=API base URL=]. - 1. Let |base| be |sheet|'s stylesheet base URL. [[CSSOM]] + 4. Let |base| be |sheet|'s stylesheet base URL. [[CSSOM]] - 1. Let |referrer| be |documentBase|. + 5. Let |referrer| be |documentBase|. - 1. Let |handleResourceFetchDone| be to do nothing. + 6. Let |handleResourceFetchDone| be to do nothing. - 1. If |base| is null, set |base| to |documentBase|. + 7. If |base| is null, set |base| to |documentBase|. - 1. Let |parsedUrl| be the result of the [=URL parser=] steps with |url| and |base|. + 8. Let |parsedUrl| be the result of the [=URL parser=] steps with |url| and |base|. If the algorithm returns an error, return. - 1. If |corsMode| is "cors", set |referrer| to |sheet|'s + 9. If |corsMode| is "cors", set |referrer| to |sheet|'s location. [[CSSOM]] - 1. 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|. - 1. If |sheet|'s origin-clean flag is set, set |handleResourceFetchDone| + 11. If |sheet|'s origin-clean flag is set, set |handleResourceFetchDone| given [=/response=] |res| to [=finalize and report timing=] with |res|, |global|, and "css". [[CSSOM]] - 1. [=/Fetch=] |req|, with |processResponseDone| set to |handleResourceFetchDone|, + 12. [=/Fetch=] |req|, with |processResponseDone| set to |handleResourceFetchDone|, |taskDestination| set to |global|, and |processResponse| set to |processResponse|.
From ffc8bf7550261efef26ebc395e0563ddcb484027 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 11 Oct 2021 10:09:25 +0300 Subject: [PATCH 08/14] Numbering --- css-values-4/Overview.bs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/css-values-4/Overview.bs b/css-values-4/Overview.bs index 79f80152733..7ad168da86f 100644 --- a/css-values-4/Overview.bs +++ b/css-values-4/Overview.bs @@ -1009,29 +1009,29 @@ URL processing model 5. Let |referrer| be |documentBase|. - 6. Let |handleResourceFetchDone| be to do nothing. + 6. If |base| is null, set |base| to |documentBase|. - 7. If |base| is null, set |base| to |documentBase|. - - 8. Let |parsedUrl| be the result of the [=URL parser=] steps with |url| and |base|. + 7. Let |parsedUrl| be the result of the [=URL parser=] steps with |url| and |base|. If the algorithm returns an error, return. - 9. If |corsMode| is "cors", set |referrer| to |sheet|'s + 8. If |corsMode| is "cors", set |referrer| to |sheet|'s location. [[CSSOM]] - 10. Let |req| be a new [=/request=] whose [=request/url=] is |parsedUrl|, whose + 9. 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|. - 11. If |sheet|'s origin-clean flag is set, set |handleResourceFetchDone| - given [=/response=] |res| to [=finalize and report timing=] with |res|, |global|, and - "css". [[CSSOM]] + 10. [=/Fetch=] |req|, with |taskDestination| set to |global|, and |processResponse| set to + the following steps given [=/response=] |res|: + + 1. If |sheet|'s origin-clean flag is set, set |handleResourceFetchDone| + given [=/response=] |res| to [=finalize and report timing=] with |res|, |global|, and + "css". [[CSSOM]] - 12. [=/Fetch=] |req|, with |processResponseDone| set to |handleResourceFetchDone|, - |taskDestination| set to |global|, and |processResponse| set to |processResponse|. + 2. Call |processResponseDone| with |res|.

From 69379fb02650162271e2d4e6bd8c0c8f6bb27903 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Mon, 11 Oct 2021 10:58:15 +0300 Subject: [PATCH 09/14] Tighten fetch integration, add shape support --- css-cascade-4/Overview.bs | 10 +++++----- css-fonts-4/Overview.bs | 9 ++++----- css-shapes-2/Overview.bs | 21 +++++++++++++++++++++ css-values-4/Overview.bs | 26 +++++++++++++++----------- 4 files changed, 45 insertions(+), 21 deletions(-) diff --git a/css-cascade-4/Overview.bs b/css-cascade-4/Overview.bs index cdc0512676a..5991b8fbd83 100644 --- a/css-cascade-4/Overview.bs +++ b/css-cascade-4/Overview.bs @@ -281,10 +281,10 @@ Processing Stylesheet Imports

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=], @@ -294,8 +294,8 @@ Processing Stylesheet Imports 3. If |content type| is not "text/css", 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 origin-clean flag to |parentStylesheet|'s origin-clean flag. diff --git a/css-fonts-4/Overview.bs b/css-fonts-4/Overview.bs index 53c23b19890..a1e077a4d31 100644 --- a/css-fonts-4/Overview.bs +++ b/css-fonts-4/Overview.bs @@ -2950,13 +2950,12 @@ Font fetching requirements with stylesheet being |rule|'s parent CSS style sheet, 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. Note: The implications of this for authors are that fonts diff --git a/css-shapes-2/Overview.bs b/css-shapes-2/Overview.bs index 1b46434182e..3404c94d204 100644 --- a/css-shapes-2/Overview.bs +++ b/css-shapes-2/Overview.bs @@ -423,6 +423,27 @@ Shapes from Image that determines the relevant pixels to use (both for defining a shape and for display). +

+Fetching external shapes

+ + To fetch an external resource for a shape, 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 location. + If the algorithm returns an error, + return. [[CSSOM]] + + 2. [=Fetch a style resource=] given |parsedUrl|, + with stylesheet being |rule|'s parent CSS style sheet, + 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. +

Shapes from Box Values

diff --git a/css-values-4/Overview.bs b/css-values-4/Overview.bs index 7ad168da86f..41191e4cfb1 100644 --- a/css-values-4/Overview.bs +++ b/css-values-4/Overview.bs @@ -997,7 +997,8 @@ URL processing model 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=]. @@ -1009,29 +1010,32 @@ URL processing model 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 location. [[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|. - 10. [=/Fetch=] |req|, with |taskDestination| set to |global|, and |processResponse| set to - the following steps given [=/response=] |res|: - - 1. If |sheet|'s origin-clean flag 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 origin-clean flag is set, + [=finalize and report timing=] with |res|, |global|, and "css". [[CSSOM]] - 2. Call |processResponseDone| with |res|. + 2. Call |processResponse| with |res| and |byteStream|. +

From 6dc96e01c6bf5dacc278453c0e5369b28bf6b706 Mon Sep 17 00:00:00 2001 From: Noam Rosenthal Date: Tue, 12 Oct 2021 15:17:22 +0300 Subject: [PATCH 10/14] Shapes, images, colors --- css-color-4/Overview.bs | 11 +++++++++++ css-images-4/Overview.bs | 14 +++++++++++++- css-shapes-2/Overview.bs | 9 ++------- css-values-4/Overview.bs | 4 ++-- 4 files changed, 28 insertions(+), 10 deletions(-) diff --git a/css-color-4/Overview.bs b/css-color-4/Overview.bs index 56400f0f2dd..57bdedf5975 100644 --- a/css-color-4/Overview.bs +++ b/css-color-4/Overview.bs @@ -3992,6 +3992,17 @@ Specifying a color profile: the ''@color-profile'' at-rule

which reference this profile are invalid colors. + To fetch an external color profile, given a + ''@color-profile'' rule |rule|, + [=fetch a style resource=] given |rule|'s URL, + with stylesheet being |rule|'s parent CSS style sheet, + destination "color-profile", + CORS mode "no-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 color profile as parsed from |byteStream. + Note: The Internet Media Type ("MIME type") for ICC profiles is application/vnd.iccprofile. diff --git a/css-images-4/Overview.bs b/css-images-4/Overview.bs index 630add9cf9c..fbd62965ad2 100644 --- a/css-images-4/Overview.bs +++ b/css-images-4/Overview.bs @@ -1,4 +1,4 @@ -