Skip to content

Commit

Permalink
LibWeb: Use [Reflect] to implement HTMLPreElement.width
Browse files Browse the repository at this point in the history
  • Loading branch information
tcl3 committed May 21, 2024
1 parent baf8284 commit b401fc0
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 20 deletions.
16 changes: 0 additions & 16 deletions Userland/Libraries/LibWeb/HTML/HTMLPreElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
}

}
3 changes: 0 additions & 3 deletions Userland/Libraries/LibWeb/HTML/HTMLPreElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ class HTMLPreElement final : public HTMLElement {
// 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);

Expand Down
2 changes: 1 addition & 1 deletion Userland/Libraries/LibWeb/HTML/HTMLPreElement.idl
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ interface HTMLPreElement : HTMLElement {
[HTMLConstructor] constructor();

// Obsolete
[CEReactions] attribute long width;
[CEReactions, Reflect] attribute long width;

};

0 comments on commit b401fc0

Please sign in to comment.