From 07e06f5635b95b90144caa198a941fc024f606b7 Mon Sep 17 00:00:00 2001 From: Stephen Muss Date: Wed, 19 Mar 2025 18:57:43 +1100 Subject: [PATCH] Support align attribute on HTMLParagraphElement interface (#36054) Signed-off-by: Stephen Muss --- components/script/dom/htmlparagraphelement.rs | 10 ++ .../webidls/HTMLParagraphElement.webidl | 3 +- .../meta/html/dom/idlharness.https.html.ini | 6 - .../html/dom/reflection-grouping.html.ini | 114 ------------------ 4 files changed, 11 insertions(+), 122 deletions(-) diff --git a/components/script/dom/htmlparagraphelement.rs b/components/script/dom/htmlparagraphelement.rs index bf910d56263..8cc16c6ba58 100644 --- a/components/script/dom/htmlparagraphelement.rs +++ b/components/script/dom/htmlparagraphelement.rs @@ -6,7 +6,9 @@ use dom_struct::dom_struct; use html5ever::{LocalName, Prefix}; use js::rust::HandleObject; +use crate::dom::bindings::codegen::Bindings::HTMLParagraphElementBinding::HTMLParagraphElementMethods; use crate::dom::bindings::root::DomRoot; +use crate::dom::bindings::str::DOMString; use crate::dom::document::Document; use crate::dom::htmlelement::HTMLElement; use crate::dom::node::Node; @@ -46,3 +48,11 @@ impl HTMLParagraphElement { ) } } + +impl HTMLParagraphElementMethods for HTMLParagraphElement { + // https://html.spec.whatwg.org/multipage/#dom-p-align + make_getter!(Align, "align"); + + // https://html.spec.whatwg.org/multipage/#dom-p-align + make_setter!(SetAlign, "align"); +} diff --git a/components/script_bindings/webidls/HTMLParagraphElement.webidl b/components/script_bindings/webidls/HTMLParagraphElement.webidl index d42533b9ef9..296bed6a938 100644 --- a/components/script_bindings/webidls/HTMLParagraphElement.webidl +++ b/components/script_bindings/webidls/HTMLParagraphElement.webidl @@ -12,6 +12,5 @@ interface HTMLParagraphElement : HTMLElement { // https://html.spec.whatwg.org/multipage/#HTMLParagraphElement-partial partial interface HTMLParagraphElement { - // [CEReactions] - // attribute DOMString align; + [CEReactions] attribute DOMString align; }; diff --git a/tests/wpt/meta/html/dom/idlharness.https.html.ini b/tests/wpt/meta/html/dom/idlharness.https.html.ini index e30c6e3ca8c..4f695f94a80 100644 --- a/tests/wpt/meta/html/dom/idlharness.https.html.ini +++ b/tests/wpt/meta/html/dom/idlharness.https.html.ini @@ -6292,12 +6292,6 @@ [HTMLHeadingElement interface: document.createElement("h1") must inherit property "align" with the proper type] expected: FAIL - [HTMLParagraphElement interface: attribute align] - expected: FAIL - - [HTMLParagraphElement interface: document.createElement("p") must inherit property "align" with the proper type] - expected: FAIL - [HTMLHRElement interface: attribute noShade] expected: FAIL diff --git a/tests/wpt/meta/html/dom/reflection-grouping.html.ini b/tests/wpt/meta/html/dom/reflection-grouping.html.ini index 41b71e15802..556eea039e9 100644 --- a/tests/wpt/meta/html/dom/reflection-grouping.html.ini +++ b/tests/wpt/meta/html/dom/reflection-grouping.html.ini @@ -191,120 +191,6 @@ [p.tabIndex: IDL set to -2147483648] expected: FAIL - [p.align: typeof IDL attribute] - expected: FAIL - - [p.align: IDL get with DOM attribute unset] - expected: FAIL - - [p.align: setAttribute() to ""] - expected: FAIL - - [p.align: setAttribute() to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo "] - expected: FAIL - - [p.align: setAttribute() to undefined] - expected: FAIL - - [p.align: setAttribute() to 7] - expected: FAIL - - [p.align: setAttribute() to 1.5] - expected: FAIL - - [p.align: setAttribute() to "5%"] - expected: FAIL - - [p.align: setAttribute() to "+100"] - expected: FAIL - - [p.align: setAttribute() to ".5"] - expected: FAIL - - [p.align: setAttribute() to true] - expected: FAIL - - [p.align: setAttribute() to false] - expected: FAIL - - [p.align: setAttribute() to object "[object Object\]"] - expected: FAIL - - [p.align: setAttribute() to NaN] - expected: FAIL - - [p.align: setAttribute() to Infinity] - expected: FAIL - - [p.align: setAttribute() to -Infinity] - expected: FAIL - - [p.align: setAttribute() to "\\0"] - expected: FAIL - - [p.align: setAttribute() to null] - expected: FAIL - - [p.align: setAttribute() to object "test-toString"] - expected: FAIL - - [p.align: setAttribute() to object "test-valueOf"] - expected: FAIL - - [p.align: IDL set to ""] - expected: FAIL - - [p.align: IDL set to " \\0\\x01\\x02\\x03\\x04\\x05\\x06\\x07 \\b\\t\\n\\v\\f\\r\\x0e\\x0f \\x10\\x11\\x12\\x13\\x14\\x15\\x16\\x17 \\x18\\x19\\x1a\\x1b\\x1c\\x1d\\x1e\\x1f foo "] - expected: FAIL - - [p.align: IDL set to undefined] - expected: FAIL - - [p.align: IDL set to 7] - expected: FAIL - - [p.align: IDL set to 1.5] - expected: FAIL - - [p.align: IDL set to "5%"] - expected: FAIL - - [p.align: IDL set to "+100"] - expected: FAIL - - [p.align: IDL set to ".5"] - expected: FAIL - - [p.align: IDL set to true] - expected: FAIL - - [p.align: IDL set to false] - expected: FAIL - - [p.align: IDL set to object "[object Object\]"] - expected: FAIL - - [p.align: IDL set to NaN] - expected: FAIL - - [p.align: IDL set to Infinity] - expected: FAIL - - [p.align: IDL set to -Infinity] - expected: FAIL - - [p.align: IDL set to "\\0"] - expected: FAIL - - [p.align: IDL set to null] - expected: FAIL - - [p.align: IDL set to object "test-toString"] - expected: FAIL - - [p.align: IDL set to object "test-valueOf"] - expected: FAIL - [hr.accessKey: typeof IDL attribute] expected: FAIL