LibWeb: Update "create a link request" for spec changes
Fetch priority is added, and one line is split into two :)
This commit is contained in:
parent
21cf2c2981
commit
d1f884533e
Notes:
sideshowbarker
2024-07-17 01:00:06 +09:00
Author: https://github.com/jamierocks Commit: https://github.com/LadybirdBrowser/ladybird/commit/d1f884533e Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/24 Reviewed-by: https://github.com/tcl3 ✅
2 changed files with 19 additions and 9 deletions
|
@ -210,6 +210,7 @@ HTMLLinkElement::LinkProcessingOptions HTMLLinkElement::create_link_options()
|
|||
// document document
|
||||
options.document = &document;
|
||||
// FIXME: cryptographic nonce metadata The current value of el's [[CryptographicNonce]] internal slot
|
||||
// FIXME: fetch priority the state of el's fetchpriority content attribute
|
||||
|
||||
// 3. If el has an href attribute, then set options's href to the value of el's href attribute.
|
||||
if (auto maybe_href = get_attribute(AttributeNames::href); maybe_href.has_value())
|
||||
|
@ -234,33 +235,39 @@ HTMLLinkElement::LinkProcessingOptions HTMLLinkElement::create_link_options()
|
|||
JS::GCPtr<Fetch::Infrastructure::Request> HTMLLinkElement::create_link_request(HTMLLinkElement::LinkProcessingOptions const& options)
|
||||
{
|
||||
// 1. Assert: options's href is not the empty string.
|
||||
VERIFY(!options.href.is_empty());
|
||||
|
||||
// FIXME: 2. If options's destination is not a destination, then return null.
|
||||
// FIXME: 2. If options's destination is null, then return null.
|
||||
|
||||
// 3. Parse a URL given options's href, relative to options's base URL. If that fails, then return null. Otherwise, let url be the resulting URL record.
|
||||
// 3. Let url be the result of encoding-parsing a URL given options's href, relative to options's base URL.
|
||||
auto url = options.base_url.complete_url(options.href);
|
||||
|
||||
// 4. If url is failure, then return null.
|
||||
if (!url.is_valid())
|
||||
return nullptr;
|
||||
|
||||
// 4. Let request be the result of creating a potential-CORS request given url, options's destination, and options's crossorigin.
|
||||
// 5. Let request be the result of creating a potential-CORS request given url, options's destination, and options's crossorigin.
|
||||
auto request = create_potential_CORS_request(vm(), url, options.destination, options.crossorigin);
|
||||
|
||||
// 5. Set request's policy container to options's policy container.
|
||||
// 6. Set request's policy container to options's policy container.
|
||||
request->set_policy_container(options.policy_container);
|
||||
|
||||
// 6. Set request's integrity metadata to options's integrity.
|
||||
// 7. Set request's integrity metadata to options's integrity.
|
||||
request->set_integrity_metadata(options.integrity);
|
||||
|
||||
// 7. Set request's cryptographic nonce metadata to options's cryptographic nonce metadata.
|
||||
// 8. Set request's cryptographic nonce metadata to options's cryptographic nonce metadata.
|
||||
request->set_cryptographic_nonce_metadata(options.cryptographic_nonce_metadata);
|
||||
|
||||
// 8. Set request's referrer policy to options's referrer policy.
|
||||
// 9. Set request's referrer policy to options's referrer policy.
|
||||
request->set_referrer_policy(options.referrer_policy);
|
||||
|
||||
// 9. Set request's client to options's environment.
|
||||
// 10. Set request's client to options's environment.
|
||||
request->set_client(options.environment);
|
||||
|
||||
// 10. Return request.
|
||||
// 11. Set request's priority to options's fetch priority.
|
||||
request->set_priority(options.fetch_priority);
|
||||
|
||||
// 12. Return request.
|
||||
return request;
|
||||
}
|
||||
|
||||
|
|
|
@ -93,6 +93,9 @@ private:
|
|||
JS::GCPtr<Web::DOM::Document> document;
|
||||
// FIXME: on document ready (default null)
|
||||
// Null or an algorithm accepting a Document
|
||||
// fetch priority (default auto)
|
||||
// A fetch priority attribute state
|
||||
Fetch::Infrastructure::Request::Priority fetch_priority { Fetch::Infrastructure::Request::Priority::Auto };
|
||||
};
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/semantics.html#create-link-options-from-element
|
||||
|
|
Loading…
Add table
Reference in a new issue