From 58bb5e1f7a34d361fbe07cfb06e66a2d5951e68e Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Tue, 21 May 2024 13:42:31 +0100 Subject: [PATCH] LibWeb: Use `[Reflect]` to implement `HTMLPreElement.width` --- .../Libraries/LibWeb/HTML/HTMLPreElement.cpp | 16 ---------------- Userland/Libraries/LibWeb/HTML/HTMLPreElement.h | 3 --- .../Libraries/LibWeb/HTML/HTMLPreElement.idl | 2 +- 3 files changed, 1 insertion(+), 20 deletions(-) diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp index 5bfbb0691b..bb5e369671 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp @@ -38,20 +38,4 @@ void HTMLPreElement::apply_presentational_hints(CSS::StyleProperties& style) con }); } -// https://html.spec.whatwg.org/multipage/obsolete.html#dom-pre-width -WebIDL::Long HTMLPreElement::width() const -{ - // The width IDL attribute of the pre element must reflect the content attribute of the same name. - if (auto width_string = get_attribute(HTML::AttributeNames::width); width_string.has_value()) { - if (auto width = parse_integer(*width_string); width.has_value()) - return *width; - } - return 0; -} - -WebIDL::ExceptionOr HTMLPreElement::set_width(WebIDL::Long width) -{ - return set_attribute(HTML::AttributeNames::width, MUST(String::number(width))); -} - } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h index 8d07a56b89..17b3162707 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.h @@ -22,9 +22,6 @@ public: // https://www.w3.org/TR/html-aria/#el-pre virtual Optional default_role() const override { return ARIA::Role::generic; } - WebIDL::Long width() const; - WebIDL::ExceptionOr set_width(WebIDL::Long); - private: HTMLPreElement(DOM::Document&, DOM::QualifiedName); diff --git a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.idl b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.idl index 774c6362e9..edec24a199 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLPreElement.idl +++ b/Userland/Libraries/LibWeb/HTML/HTMLPreElement.idl @@ -7,6 +7,6 @@ interface HTMLPreElement : HTMLElement { [HTMLConstructor] constructor(); // Obsolete - [CEReactions] attribute long width; + [CEReactions, Reflect] attribute long width; };