From 6712444c6515b3072cea17450f1686a749e61252 Mon Sep 17 00:00:00 2001
From: Noam Rosenthal The processing of ` All link types that can be external resource
+ links define a process a link header algorithm, which takes a link
+ processing options. This algorithm defines whether and how they react to appearing in an
+ HTTP ` To extract links from headers given
- header list headers: The processing of ` A link processing options is a struct. It has the following
+ items: A link processing options has a base URL and an href
+ rather than a parsed URL because the URL could be a result of the options's source set. To create link options from element given a Let document be el's node document. Let options be a new link processing options with If el has an If el has an If el has a Assert: options's href is not the empty
+ string, or options's source set is not
+ null. A Return options. To extract links from headers given a header
+ list headers: Let links be a new list. If linkObject[" If linkObject["Processing `
- Link
` headersLink
` headers apart from preload
and preconnect
, in
- particular their influence on a Document
's script-blocking style sheet
- counter, is not defined. See issue
- #4224 for discussion on integrating this into the spec.Link
` response header.Link
` headers is not defined for
+ all link relation types. In particular some implementations might process types that have a no-op
+ process link headers algorithm, and in doing so influence a Document
's
+ script-blocking style sheet counter. See
+ issue #4224 for discussion on
+ integrating this into the spec.
+
+
+ link
")Document
Document
link
element
+ el:
+
+
+
+
+ as
attributecrossorigin
+ content attributehref
attribute, then set
+ options's href to the value of
+ el's href
attribute.integrity
attribute,
+ then set options's integrity to the
+ value of el's integrity
content
+ attribute.type
attribute, then set
+ options's type to the value of
+ el's type
attribute.link
element with neither an href
or an
+ imagesrcset
does not represent a link.
relation_type
"] is not "preload
" or "preconnect
",
- then continue.target_uri
"] does not
exist, then continue.pre-media
" or "media
" phase:
Let links be the result of - extracting links from response's - header list.
Let links be the result of extracting links from response's header list.
For each linkObject in links:
Let attribs be
- linkObject["target_attributes
"].
Let rel be linkObject["relation_type
"].
Let attribs be linkObject["target_attributes
"].
Let expectedPhase be "media
" if either "srcset
", "HTMLLinkElement : HTMLElement {
does not match the environment, then
continue.
Let element be the result of creating an
- element given doc, link
, and the HTML
- namespace.
Let options be a new link processing options with
-Set an attribute value for
- element using "href
" and
- linkObject["target_uri
"].
target_uri
"]Set an attribute value for
- element using "rel
" and
- linkObject["relation_type
"].
For each entry in attribs: if
- entry[0] is "as
", "type
", "crossorigin
", "imagesizes
", "blocking
", "integrity
", "imagesrcset
", or "media
", then set an attribute value for
- element using entry[0] and entry[1].
Fetch and process - el.
Apply link options from parsed header attributes to options + given attribs.
If attribs["imagesrcset
"] exists and attribs["imagesizes
"] exists,
+ then set options's source set to the
+ result of creating a source set given
+ linkObject["target_uri
"], attribs["imagesrcset
"], and attribs["imagesizes
"].
Run the process a link header steps for rel given + options.
To apply link options from parsed header attributes to a link processing + options options given attribs:
+ +If attribs["as
"] exists, then set options's destination to the result of translating attribs["as
"].
If attribs["crossorigin
"] exists and is an ASCII case-insensitive match for one of
+ the CORS settings attribute keywords,
+ then set options's crossorigin to the
+ CORS settings attribute state corresponding to that keyword.
If attribs["integrity
"] exists, then set options's integrity to attribs["integrity
"].
If attribs["type
"] exists, then set options's type to attribs["type
"].
Early hints allow user-agents to perform some operations, such as to speculatively @@ -14537,7 +14690,6 @@ data-x="rel-preload">preload; as=font< the style will not be accessible to the document.
-To process early hint headers given a response response and an environment reservedEnvironment:
@@ -14564,7 +14716,7 @@ data-x="rel-preload">preload; as=font< headers">extracting links from response's header list. -Let uncommittedPreloads be an empty list.
Let earlyHints be an empty list.
For each linkObject in links:
@@ -14579,6 +14731,34 @@ data-x="rel-preload">preload; as=font< committed as soon as it becomes available.Let rel be linkObject["relation_type
"].
Let options be a new link processing options with
+ +target_uri
"]early-hint
"Let attribs be linkObject["target_attributes
"].
Let crossorigin be attribs["crossorigin
"] if attribs["crossorigin
"] exists,
- or the empty string otherwise.
Let url be the result of parsing
- linkObject["target_uri
"] relative to response's
- URL.
If linkObject["relation_type
"] is "preconnect
", then preconnect to url
- given crossorigin and response's url's origin, and
- continue.
Assert: linkObject["relation_type
"] is "preload
".
If attribs["as
"] does not exist, then continue.
Let destination be attribs["as
"].
If destination is not a destination, continue.
Let earlyRequest be the result of creating a potential-CORS request given url, - destination, and crossorigin.
Set earlyRequest's policy - container to earlyPolicyContainer.
Let type be the empty string.
If attribs["type
"] exists, then set type to
- attribs["type
"].
If attribs["integrity
"] exists, then set earlyRequest's integrity metadata to
- attribs["integrity
"].
Apply link options from parsed header attributes to options + given attribs.
Let unsafeEndTime be 0.
Let earlyResponse be null.
Let processResponse given response - res be to set earlyResponse to res.
Append the following steps given Document
- document to uncommittedPreloads:
Let entry be new preload entry whose - integrity metadata is - earlyRequest's integrity metadata.
Let respond be the following steps given response response:
- -Finalize and report timing given response,
- document's relevant global object, "early-hint
", and unsafeEndTime.
If entry's on response - available is null, then set entry's response to response; otherwise call entry's on response available given - response.
Run the process a link header steps for rel given + options.
Let key be the result of creating a - preload key given earlyRequest.
Append options to + earlyHints.
Set document's map of preloaded resources[key] to - entry.
Return the following substeps given Document
doc: for each options in earlyHints:
If earlyResponse is null, then set processResponse to - respond; otherwise call respond with earlyResponse.
If options's on document ready is null, then set + options's document to + docs.
Preload earlyRequest given - type and the following steps given response - res: set unsafeEndTime to the unsafe shared current time and - call processResponse with res.
Otherwise, call options's on document ready with doc.
Return uncommittedPreloads.
Return true.
The process a link header steps for this type of linked resource are to do + nothing.
+In the absence of a link
with the icon
keyword, for
Document
objects whose URL's
scheme is an HTTP(S) scheme, user agents may
@@ -25761,6 +25871,9 @@ document.body.appendChild(wbr);
and response.
The process a link header steps for this type of linked resource are to do + nothing.
+ @@ -25880,6 +25993,9 @@ document.body.appendChild(wbr); data-x="event-load">load at thelink
element.
+ The process a link header steps for this type of linked resource are to do + nothing.
+The fetch and process the linked resource steps for this type of linked resource,
- given a link
element el, are:
link
element el, are to create link options from el and
+ to preconnect given the result.
- Let urlRecord be the result of parsing
- el's href
attribute, relative to el's
- node document.
The process a link header step for this type of linked resource given a link processing options options are to + preconnect given options.
-If urlRecord is not failure, then preconnect to
- urlRecord given the current state of el's crossorigin
attribute and el's node
- document's origin.
To preconnect to a URL urlRecord given a CORS - settings attribute state crossOrigin and an origin - documentOrigin:
+To preconnect given a link processing options options:
If urlRecord's scheme is not an +
If options's + href is an empty string, returns.
If url's scheme is not an HTTP(S) scheme, then return.
Let partitionKey be the result of determining the network partition key given el's node - document's relevant settings object.
Let useCredentials be true.
If crossOrigin is not Anonymous and documentOrigin does not have - the same origin as urlRecord's origin, then set useCredentials to false.
If options's crossorigin is not + Anonymous and options's origin does not + have the same origin as url's + origin, then set useCredentials to + false.
The user agent should obtain a connection given partitionKey, - urlRecord's origin, and + url's origin, and useCredentials.
This connection is obtained but not used directly. It will remain in the @@ -26308,43 +26427,7 @@ document.body.appendChild(wbr);
Return true.
To preload a resource given a request - request, a string type and processResponse, which is an algorithm - accepting a response:
- -If type doesn't match - request's destination, then - return.
Fetch request, with - processResponseConsumeBody - set to the following steps given response - response and null or byte sequence bytesOrNull:
- -If bytesOrNull is a byte sequence, then set response's - body to the first return value of safely extracting bytesOrNull.
- -By using processResponseConsumeBody, - we have extracted the entire body. This is necessary to ensure the preloader loads the - entire body from the network, regardless of whether the preload will be consumed (which is - uncertain at this point). This step then resets the request's body to a new body containing the - same bytes, so that other specifications can read from it at the time of actual consumption, - despite us having already done so once.
-Otherwise, set response to a network error.
Call processResponse with response.
-For the purposes of the above algorithm, a string type +
For the purposes of this section, a string type matches a string destination if the following algorithm returns true:
The fetch and process the linked resource steps for this type of linked resource,
- given a link
element el, are:
To preload given a link processing options options and + an optional processResponse, which is an algorithm accepting a response:
Let as be the current state of el's as
attribute.
If options's destination is not + a destination, then return.
If as does not represent a state, return false.
If options's type doesn't match options's destination, then return.
Let request be the result of creating a link
element request given el and the result
- of translating
- as.
Let href be options's href.
If request is null, then return.
If options's destination is
+ "image
" and options's source set is not null, then set href
+ to the result of selecting an image source from
+ options's source set.
If as is "image
", then:
If href is an empty string, return.
Let selected source and selected pixel density be the URL and - pixel density that results from selecting an image - source given el, respectively.
Parse href relative to + options's base URL. If that fails, then + return. Otherwise let url be the resulting URL record.
If selected source is null, then return false.
Let unsafeEndTime be 0.
Parse selected source, relative to - el's node document. If that fails, then return false. Otherwise, let - url be the resulting URL record.
Let response be "pending
".
Set request's URL to - url.
Let request be the result of creating a potential-CORS request given url, destination, + and options's crossorigin.
Set request's policy + container to options's policy container.
Set request's integrity metadata to options's + integrity.
Let preloadKey be the result of creating a
+ Let entry be a new preload entry whose
+ integrity metadata is options's
+ integrity. Let key be the result of creating a
preload key given request. Let preloadEntry be a new preload entry whose
- integrity metadata is request's integrity metadata. Let finalize be the following step given a Set el's node document's map
- of preloaded resources[preloadKey] to preloadEntry. Fetch request, with processResponseConsumeBody set to the following steps
+ given a response response and null, failure,
+ or a byte sequence bytesOrNull: Let type be the empty string. If bytesOrNull is a byte sequence, then set response's
+ body to the first return value of safely extracting bytesOrNull. By using processResponseConsumeBody,
+ we have extracted the entire body. This is necessary to ensure the preloader loads the
+ entire body from the network, regardless of whether the preload will be consumed (which is
+ uncertain at this point). This step then resets the request's body to a new body containing the
+ same bytes, so that other specifications can read from it at the time of actual consumption,
+ despite us having already done so once. If el has a Otherwise, set response to a network error. Set unsafeEndTime to the unsafe shared current time. If options's document is not
+ null, then call finalize given options's document and response. If entry's on response
+ available is null, then set entry's response to response; otherwise call entry's on response available given
+ response. If processResponse is given, then call processResponse with
+ response.Document
+ document and a response response:
+ finalize and report timing given response,
+ document's relevant global object, options's
+ initiator, and unsafeEndTime.
+
+ type
attribute, then set
- type to the value of el's type
- attribute.
Preload request, given type - and the following steps given response - response:
+Let commit be the following steps given a Document
+ document:
Finalize and report timing with response, given el's
- relevant global object and "link
".
If entry's response is not null, then + call finalize given document and entry's + response.
If preloadEntry's on response - available is null, then set preloadEntry's response to response.
Set document's map of preloaded resources[key] to + entry.
Otherwise, call preloadEntry's on response available with response.
If options's document is null, then set options's on document ready to commit. + Otherwise call commit with options's document.
The fetch and process the linked resource steps for this type of linked resource,
+ given a link
element el, are:
Update the source set for el.
Let options be the result of creating link options from + el.
Preload options, with the following steps given a response response: + +
If response is a network error, fire an event named error
at el. Otherwise, fire an event named load
- at el.
If response is a network error, fire an event named error
at el. Otherwise, fire an event named
+ load
at el.
The actual browsers' behavior is different from the spec here, and the - feasibility of changing the behavior has not yet been investigated. See issue #1142.
+The actual browsers' behavior is different from the spec here, and the + feasibility of changing the behavior has not yet been investigated. See issue #1142.
The process a link header step for this type of link + given a link processing options options + is to preload options.
+ +prerender
"Unblock rendering on el.
The process a link header steps for this type of linked resource are to do + nothing.
+When asked to select an image source for a given img
or
- link
element el, user agents must do the following:
To select an image source given an img
element el:
Update the source set for el.
If el's source set is empty, - return null as the URL and undefined as the pixel density.
If el's source set is empty, return null as the URL and undefined + as the pixel density.
Return the result of selecting an + image from el's source set.
Otherwise, take el's source set - and let it be source set.
To select an image source from a source set given a source set + sourceSet:
-If an entry b in source set has the same associated pixel - density descriptor as an earlier entry a in source set, then remove - entry b. Repeat this step until none of the entries in source set have the +
If an entry b in sourceSet has the same associated pixel + density descriptor as an earlier entry a in sourceSet, then remove + entry b. Repeat this step until none of the entries in sourceSet have the same associated pixel density descriptor as an earlier entry.
In a user agent-specific manner, - choose one image source from source set. - Let this be selected source.
In an implementation-defined manner, choose one image source + from sourceSet. Let this be selectedSource.
Return selected source and its associated pixel density.
Return selectedSource and its associated pixel density.
When asked to create a source set given a string default source, a string + srcset and a string sizes:
+ +Let source set be an empty source set.
If srcset is not an empty string, then set + source set to the result of parsing + srcset.
Let source size be the result of parsing sizes.
If default source is not the empty string and + source set does not contain an image source with a pixel + density descriptor value of 1, and no image source with a width + descriptor, append default source to source set.
Normalize the source densities of source set.
Return source set.
Let source set be an empty source set.
Let srcset be the empty string.
If child has a srcset
or imagesrcset
attribute, parse child's srcset attribute and set
- source set to the returned source set.
Let sizes be the empty string.
Parse child's sizes - attribute, and let source set's source size be the returned - value.
If el has a srcset
or imagesrcset
attribute, set srcset to that
+ attribute.
If child has a src
or href
attribute whose value is not the empty string and
- source set does not contain an image source with a pixel
- density descriptor value of 1, and no image source with a width
- descriptor, append child's src
or href
attribute value to source set.
If el has a sizes
or imagesizes
attribute, set sizes to that
+ attribute.
Normalize the source densities of source set.
If el has a src
or href
attribute, set href to that
+ attribute.
Let el's source set be source set.
Let el's source set be the result of creating a source set given + href, srcset and sizes.
Return.
@@ -88573,9 +88757,8 @@ interface Location { // but see also response -Document
has been createdDocument
, once it has been createdOnce a navigation params struct is created, this standard does not @@ -88870,7 +89053,7 @@ interface Location { // but see also has cross-origin redirects is false, and uncommitted preloads is null.
Run process a navigate response with navigationType, allowedToDownload, hasTransientActivation, and @@ -88931,7 +89114,7 @@ interface Location { // but see also has cross-origin redirects is false, and uncommitted preloads is null.
Run process a navigate response with navigationType, allowedToDownload, hasTransientActivation, and @@ -89046,7 +89229,7 @@ interface Location { // but see also to null.
Set uncommittedPreloads to null.
+Set commitEarlyHints to null.
Preloaded links from early hint headers remain in the preload cache after a same origin redirect, but @@ -89144,7 +89327,7 @@ interface Location { // but see also fetch request, with processEarlyHintsResponse set to the following step given a response earlyResponse: If - uncommittedPreloads is null, then set uncommittedPreloads to the result + commitEarlyHints is null, then set commitEarlyHints to the result of processing early hint headers given earlyResponse and request's reserved client.
Run process a navigate response with navigationType, allowedToDownload, hasTransientActivation, and @@ -89884,11 +90067,11 @@ interface Location { // but see also issue #2900.
If navigationParams's - uncommitted preloads is not null, - then for each commitEarlyPreload in - navigationParams's uncommitted - preloads, call commitEarlyPreload given document.
+If navigationParams's commit early hints is not null, then call + navigationParams's commit early hints with + document.
Process link headers given document, navigationParams's response, and