From 8315ad67595e98bacc81a0100bf9e239e9cef7cf Mon Sep 17 00:00:00 2001 From: Jamie Mansfield Date: Mon, 27 May 2024 09:46:36 +0100 Subject: [PATCH] LibWeb: Implement HTMLImageElement.fetchPriority --- .../HTML/img-element-fetch-priority.txt | 5 +++++ .../input/HTML/img-element-fetch-priority.html | 18 ++++++++++++++++++ .../Libraries/LibWeb/HTML/HTMLImageElement.cpp | 3 ++- .../Libraries/LibWeb/HTML/HTMLImageElement.idl | 2 +- 4 files changed, 26 insertions(+), 2 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/HTML/img-element-fetch-priority.txt create mode 100644 Tests/LibWeb/Text/input/HTML/img-element-fetch-priority.html diff --git a/Tests/LibWeb/Text/expected/HTML/img-element-fetch-priority.txt b/Tests/LibWeb/Text/expected/HTML/img-element-fetch-priority.txt new file mode 100644 index 00000000000..c3a1c4708bd --- /dev/null +++ b/Tests/LibWeb/Text/expected/HTML/img-element-fetch-priority.txt @@ -0,0 +1,5 @@ + fetchPriority = auto + +fetchPriority = high + +fetchPriority = auto diff --git a/Tests/LibWeb/Text/input/HTML/img-element-fetch-priority.html b/Tests/LibWeb/Text/input/HTML/img-element-fetch-priority.html new file mode 100644 index 00000000000..ae41552d589 --- /dev/null +++ b/Tests/LibWeb/Text/input/HTML/img-element-fetch-priority.html @@ -0,0 +1,18 @@ + + + diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp index 7ae044cc51d..88375b0e012 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.cpp @@ -563,7 +563,8 @@ after_step_7: // 21. Set request's referrer policy to the current state of the element's referrerpolicy attribute. request->set_referrer_policy(ReferrerPolicy::from_string(get_attribute_value(HTML::AttributeNames::referrerpolicy)).value_or(ReferrerPolicy::ReferrerPolicy::EmptyString)); - // FIXME: 22. Set request's priority to the current state of the element's fetchpriority attribute. + // 22. Set request's priority to the current state of the element's fetchpriority attribute. + request->set_priority(Fetch::Infrastructure::request_priority_from_string(get_attribute_value(HTML::AttributeNames::fetchpriority)).value_or(Fetch::Infrastructure::Request::Priority::Auto)); // 24. If the will lazy load element steps given the img return true, then: if (will_lazy_load_element()) { diff --git a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.idl index 6b80732bc91..cab5f7845d0 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLImageElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLImageElement.idl @@ -23,7 +23,7 @@ interface HTMLImageElement : HTMLElement { [FIXME, CEReactions] attribute DOMString referrerPolicy; [FIXME, CEReactions] attribute DOMString decoding; [CEReactions, Enumerated=LazyLoadingAttribute, Reflect] attribute DOMString loading; - [FIXME, CEReactions] attribute DOMString fetchPriority; + [CEReactions, Enumerated=FetchPriorityAttribute, Reflect=fetchpriority] attribute DOMString fetchPriority; [FIXME] Promise decode();