mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-30 08:18:49 +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:
parent
84eecbb10e
commit
a71eaefdf6
Notes:
sideshowbarker
2024-07-18 08:59:31 +09:00
Author: https://github.com/awesomekling
Commit: a71eaefdf6
Pull-request: https://github.com/SerenityOS/serenity/pull/21991
11 changed files with 108 additions and 64 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue