From f91dc3335032a9544116a098a552ce2a8ecc3be1 Mon Sep 17 00:00:00 2001 From: Andrei Volykhin Date: Wed, 24 Sep 2025 12:29:44 +0300 Subject: [PATCH] html: Add the reflected 'sizes' IDL attribute for (#39466) Add the reflected 'sizes' IDL attribute for element's DOM interface which defines image sizes for different page layouts. See https://html.spec.whatwg.org/multipage/#dom-img-sizes Testing: Improvements in the following tests - custom-elements/reactions/customized-builtins/HTMLImageElement.html - html/dom/idlharness.https.html - html/semantics/embedded-content/the-img-element/relevant-mutations.html Signed-off-by: Andrei Volykhin --- components/script/dom/html/htmlimageelement.rs | 6 ++++++ .../script_bindings/webidls/HTMLImageElement.webidl | 1 + .../customized-builtins/HTMLImageElement.html.ini | 6 ------ tests/wpt/meta/html/dom/idlharness.https.html.ini | 9 --------- .../the-img-element/relevant-mutations.html.ini | 3 --- 5 files changed, 7 insertions(+), 18 deletions(-) diff --git a/components/script/dom/html/htmlimageelement.rs b/components/script/dom/html/htmlimageelement.rs index d56145219e0..2f8275b8734 100644 --- a/components/script/dom/html/htmlimageelement.rs +++ b/components/script/dom/html/htmlimageelement.rs @@ -1670,6 +1670,12 @@ impl HTMLImageElementMethods for HTMLImageElement { // https://html.spec.whatwg.org/multipage/#dom-img-src make_url_setter!(SetSrcset, "srcset"); + // + make_getter!(Sizes, "sizes"); + + // + make_setter!(SetSizes, "sizes"); + // https://html.spec.whatwg.org/multipage/#dom-img-crossOrigin fn GetCrossOrigin(&self) -> Option { reflect_cross_origin_attribute(self.upcast::()) diff --git a/components/script_bindings/webidls/HTMLImageElement.webidl b/components/script_bindings/webidls/HTMLImageElement.webidl index faae1c8992b..0c4f8dce430 100644 --- a/components/script_bindings/webidls/HTMLImageElement.webidl +++ b/components/script_bindings/webidls/HTMLImageElement.webidl @@ -13,6 +13,7 @@ interface HTMLImageElement : HTMLElement { attribute USVString src; [CEReactions] attribute USVString srcset; + [CEReactions] attribute DOMString sizes; [CEReactions] attribute DOMString? crossOrigin; [CEReactions] diff --git a/tests/wpt/meta/custom-elements/reactions/customized-builtins/HTMLImageElement.html.ini b/tests/wpt/meta/custom-elements/reactions/customized-builtins/HTMLImageElement.html.ini index e06ae4f37f9..d39f5b305e0 100644 --- a/tests/wpt/meta/custom-elements/reactions/customized-builtins/HTMLImageElement.html.ini +++ b/tests/wpt/meta/custom-elements/reactions/customized-builtins/HTMLImageElement.html.ini @@ -1,10 +1,4 @@ [HTMLImageElement.html] - [sizes on HTMLImageElement must enqueue an attributeChanged reaction when adding a new attribute] - expected: FAIL - - [sizes on HTMLImageElement must enqueue an attributeChanged reaction when replacing an existing attribute] - expected: FAIL - [decoding on HTMLImageElement must enqueue an attributeChanged reaction when adding a new attribute] expected: FAIL diff --git a/tests/wpt/meta/html/dom/idlharness.https.html.ini b/tests/wpt/meta/html/dom/idlharness.https.html.ini index 524d8e737d3..32a83999bcc 100644 --- a/tests/wpt/meta/html/dom/idlharness.https.html.ini +++ b/tests/wpt/meta/html/dom/idlharness.https.html.ini @@ -5473,9 +5473,6 @@ [HTMLSourceElement interface: document.createElement("source") must inherit property "height" with the proper type] expected: FAIL - [HTMLImageElement interface: attribute sizes] - expected: FAIL - [HTMLImageElement interface: attribute decoding] expected: FAIL @@ -5488,9 +5485,6 @@ [HTMLImageElement interface: attribute lowsrc] expected: FAIL - [HTMLImageElement interface: document.createElement("img") must inherit property "sizes" with the proper type] - expected: FAIL - [HTMLImageElement interface: document.createElement("img") must inherit property "decoding" with the proper type] expected: FAIL @@ -5503,9 +5497,6 @@ [HTMLImageElement interface: document.createElement("img") must inherit property "lowsrc" with the proper type] expected: FAIL - [HTMLImageElement interface: new Image() must inherit property "sizes" with the proper type] - expected: FAIL - [HTMLImageElement interface: new Image() must inherit property "decoding" with the proper type] expected: FAIL diff --git a/tests/wpt/meta/html/semantics/embedded-content/the-img-element/relevant-mutations.html.ini b/tests/wpt/meta/html/semantics/embedded-content/the-img-element/relevant-mutations.html.ini index 33b778fb584..089c3ea5915 100644 --- a/tests/wpt/meta/html/semantics/embedded-content/the-img-element/relevant-mutations.html.ini +++ b/tests/wpt/meta/html/semantics/embedded-content/the-img-element/relevant-mutations.html.ini @@ -7,6 +7,3 @@ [crossorigin state not changed: anonymous to foobar] expected: FAIL - - [sizes is set to same value] - expected: FAIL