mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-24 02:09:28 +00:00
LibWeb: Make EventTarget::activation_behavior a virtual function
(Instead of using an AK::Function on EventTarget). This shaves 48 bytes off of every EventTarget instance.
This commit is contained in:
@@ -15,22 +15,29 @@ JS_DEFINE_ALLOCATOR(HTMLSummaryElement);
|
||||
HTMLSummaryElement::HTMLSummaryElement(DOM::Document& document, DOM::QualifiedName qualified_name)
|
||||
: HTMLElement(document, move(qualified_name))
|
||||
{
|
||||
activation_behavior = [this](auto&) {
|
||||
// The activation behavior of summary elements is to run the following steps:
|
||||
}
|
||||
|
||||
// 1. If this summary element is not the summary for its parent details, then return.
|
||||
if (!is_summary_for_its_parent_details())
|
||||
return;
|
||||
bool HTMLSummaryElement::has_activation_behavior() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// 2. Let parent be this summary element's parent.
|
||||
auto* parent = this->parent_element();
|
||||
void HTMLSummaryElement::activation_behavior(DOM::Event const&)
|
||||
{
|
||||
// The activation behavior of summary elements is to run the following steps:
|
||||
|
||||
// 3. If the open attribute is present on parent, then remove it. Otherwise, set parent's open attribute to the empty string.
|
||||
if (parent->has_attribute(HTML::AttributeNames::open))
|
||||
parent->remove_attribute(HTML::AttributeNames::open);
|
||||
else
|
||||
parent->set_attribute(HTML::AttributeNames::open, String {}).release_value_but_fixme_should_propagate_errors();
|
||||
};
|
||||
// 1. If this summary element is not the summary for its parent details, then return.
|
||||
if (!is_summary_for_its_parent_details())
|
||||
return;
|
||||
|
||||
// 2. Let parent be this summary element's parent.
|
||||
auto* parent = this->parent_element();
|
||||
|
||||
// 3. If the open attribute is present on parent, then remove it. Otherwise, set parent's open attribute to the empty string.
|
||||
if (parent->has_attribute(HTML::AttributeNames::open))
|
||||
parent->remove_attribute(HTML::AttributeNames::open);
|
||||
else
|
||||
parent->set_attribute(HTML::AttributeNames::open, String {}).release_value_but_fixme_should_propagate_errors();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interactive-elements.html#summary-for-its-parent-details
|
||||
|
||||
Reference in New Issue
Block a user