LibWeb: Implement HTMLLinkElement.sizes

This commit is contained in:
Shannon Booth 2024-11-18 07:00:59 +13:00 committed by Andreas Kling
parent 061ac1f8c7
commit a4b43cae9a
Notes: github-actions[bot] 2024-11-17 21:13:53 +00:00
4 changed files with 16 additions and 4 deletions

View file

@ -124,6 +124,15 @@ GC::Ref<DOM::DOMTokenList> HTMLLinkElement::rel_list()
return *m_rel_list;
}
// https://html.spec.whatwg.org/multipage/semantics.html#dom-link-sizes
GC::Ref<DOM::DOMTokenList> 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);
}
}

View file

@ -37,6 +37,7 @@ public:
WebIDL::ExceptionOr<void> set_as(String const&);
GC::Ref<DOM::DOMTokenList> rel_list();
GC::Ref<DOM::DOMTokenList> sizes();
bool has_loaded_icon() const;
bool load_favicon_and_use_if_window_is_active();
@ -146,6 +147,7 @@ private:
Optional<DOM::DocumentLoadEventDelayer> m_document_load_event_delayer;
GC::Ptr<DOM::DOMTokenList> m_rel_list;
GC::Ptr<DOM::DOMTokenList> m_sizes;
unsigned m_relationship { 0 };
// https://html.spec.whatwg.org/multipage/semantics.html#explicitly-enabled
bool m_explicitly_enabled { false };

View file

@ -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;

View file

@ -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.