LibWeb: Use [Reflect] to implement HTMLPreElement.width

This commit is contained in:
Tim Ledbetter 2024-05-21 13:42:31 +01:00 committed by Andreas Kling
parent 2a7cf1c588
commit 58bb5e1f7a
3 changed files with 1 additions and 20 deletions

View file

@ -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<void> HTMLPreElement::set_width(WebIDL::Long width)
{
return set_attribute(HTML::AttributeNames::width, MUST(String::number(width)));
}
}

View file

@ -22,9 +22,6 @@ public:
// https://www.w3.org/TR/html-aria/#el-pre
virtual Optional<ARIA::Role> default_role() const override { return ARIA::Role::generic; }
WebIDL::Long width() const;
WebIDL::ExceptionOr<void> set_width(WebIDL::Long);
private:
HTMLPreElement(DOM::Document&, DOM::QualifiedName);

View file

@ -7,6 +7,6 @@ interface HTMLPreElement : HTMLElement {
[HTMLConstructor] constructor();
// Obsolete
[CEReactions] attribute long width;
[CEReactions, Reflect] attribute long width;
};