From a4b43cae9aad53a4b66f4321b1c131171b6ab555 Mon Sep 17 00:00:00 2001 From: Shannon Booth Date: Mon, 18 Nov 2024 07:00:59 +1300 Subject: [PATCH] LibWeb: Implement HTMLLinkElement.sizes --- Libraries/LibWeb/HTML/HTMLLinkElement.cpp | 10 ++++++++++ Libraries/LibWeb/HTML/HTMLLinkElement.h | 2 ++ Libraries/LibWeb/HTML/HTMLLinkElement.idl | 2 +- .../dom/lists/DOMTokenList-coverage-for-attributes.txt | 6 +++--- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp index 79906b42cbf..4c9a38d7584 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.cpp @@ -124,6 +124,15 @@ GC::Ref HTMLLinkElement::rel_list() return *m_rel_list; } +// https://html.spec.whatwg.org/multipage/semantics.html#dom-link-sizes +GC::Ref HTMLLinkElement::sizes() +{ + // The size IDL attribute must reflect the size content attribute. + if (!m_sizes) + m_sizes = DOM::DOMTokenList::create(*this, HTML::AttributeNames::sizes); + return *m_sizes; +} + bool HTMLLinkElement::has_loaded_icon() const { return m_relationship & Relationship::Icon && resource() && resource()->is_loaded() && resource()->has_encoded_data(); @@ -616,6 +625,7 @@ void HTMLLinkElement::visit_edges(Cell::Visitor& visitor) visitor.visit(m_fetch_controller); visitor.visit(m_loaded_style_sheet); visitor.visit(m_rel_list); + visitor.visit(m_sizes); } } diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.h b/Libraries/LibWeb/HTML/HTMLLinkElement.h index 11defb3d60e..09398005c16 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.h +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.h @@ -37,6 +37,7 @@ public: WebIDL::ExceptionOr set_as(String const&); GC::Ref rel_list(); + GC::Ref sizes(); bool has_loaded_icon() const; bool load_favicon_and_use_if_window_is_active(); @@ -146,6 +147,7 @@ private: Optional m_document_load_event_delayer; GC::Ptr m_rel_list; + GC::Ptr m_sizes; unsigned m_relationship { 0 }; // https://html.spec.whatwg.org/multipage/semantics.html#explicitly-enabled bool m_explicitly_enabled { false }; diff --git a/Libraries/LibWeb/HTML/HTMLLinkElement.idl b/Libraries/LibWeb/HTML/HTMLLinkElement.idl index 990ba0de8bd..0fe41bdbd9a 100644 --- a/Libraries/LibWeb/HTML/HTMLLinkElement.idl +++ b/Libraries/LibWeb/HTML/HTMLLinkElement.idl @@ -18,7 +18,7 @@ interface HTMLLinkElement : HTMLElement { [CEReactions, Reflect] attribute DOMString integrity; [CEReactions, Reflect] attribute DOMString hreflang; [CEReactions, Reflect] attribute DOMString type; - [FIXME, SameObject, PutForwards=value] readonly attribute DOMTokenList sizes; + [SameObject, PutForwards=value] readonly attribute DOMTokenList sizes; [CEReactions, Reflect=imagesrcset] attribute USVString imageSrcset; [CEReactions, Reflect=imagesizes] attribute DOMString imageSizes; [CEReactions, Reflect=referrerpolicy, Enumerated=ReferrerPolicy] attribute DOMString referrerPolicy; diff --git a/Tests/LibWeb/Text/expected/wpt-import/dom/lists/DOMTokenList-coverage-for-attributes.txt b/Tests/LibWeb/Text/expected/wpt-import/dom/lists/DOMTokenList-coverage-for-attributes.txt index e71b9bb75c0..9502f336e27 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/dom/lists/DOMTokenList-coverage-for-attributes.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/dom/lists/DOMTokenList-coverage-for-attributes.txt @@ -6,8 +6,8 @@ Rerun Found 175 tests -173 Pass -2 Fail +174 Pass +1 Fail Details Result Test Name MessagePass a.classList in http://www.w3.org/1999/xhtml namespace should be DOMTokenList. Pass area.classList in http://www.w3.org/1999/xhtml namespace should be DOMTokenList. @@ -151,7 +151,7 @@ Pass td.sandbox in null namespace should be undefined. Pass th.sandbox in null namespace should be undefined. Pass a.sizes in http://www.w3.org/1999/xhtml namespace should be undefined. Pass area.sizes in http://www.w3.org/1999/xhtml namespace should be undefined. -Fail link.sizes in http://www.w3.org/1999/xhtml namespace should be DOMTokenList. +Pass link.sizes in http://www.w3.org/1999/xhtml namespace should be DOMTokenList. Pass iframe.sizes in http://www.w3.org/1999/xhtml namespace should be undefined. Pass output.sizes in http://www.w3.org/1999/xhtml namespace should be undefined. Pass td.sizes in http://www.w3.org/1999/xhtml namespace should be undefined.