Skip to content

Commit

Permalink
LibWeb: Shrink DOM::EventTarget by 80 bytes
Browse files Browse the repository at this point in the history
Do this by converting two Function members into virtual functions:
- legacy_pre_activation_behavior
- legacy_cancelled_activation_behavior
  • Loading branch information
awesomekling committed Feb 19, 2022
1 parent bfe69e9 commit a97586c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions Userland/Libraries/LibWeb/DOM/EventDispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr<
}
}

if (activation_target && activation_target->legacy_pre_activation_behavior)
if (activation_target)
activation_target->legacy_pre_activation_behavior();

for (ssize_t i = event->path().size() - 1; i >= 0; --i) {
Expand Down Expand Up @@ -329,8 +329,7 @@ bool EventDispatcher::dispatch(NonnullRefPtr<EventTarget> target, NonnullRefPtr<
// NOTE: Since activation_target is set, it will have activation behavior.
activation_target->activation_behavior(event);
} else {
if (activation_target->legacy_cancelled_activation_behavior)
activation_target->legacy_cancelled_activation_behavior();
activation_target->legacy_cancelled_activation_behavior();
}
}

Expand Down
5 changes: 2 additions & 3 deletions Userland/Libraries/LibWeb/DOM/EventTarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
#pragma once

#include <AK/FlyString.h>
#include <AK/Function.h>
#include <AK/Noncopyable.h>
#include <AK/Vector.h>
#include <LibJS/Forward.h>
Expand Down Expand Up @@ -50,8 +49,8 @@ class EventTarget {
Function<void(const Event&)> activation_behavior;

// NOTE: These only exist for checkbox and radio input elements.
Function<void()> legacy_pre_activation_behavior;
Function<void()> legacy_cancelled_activation_behavior;
virtual void legacy_pre_activation_behavior() { }
virtual void legacy_cancelled_activation_behavior() { }

Bindings::CallbackType* event_handler_attribute(FlyString const& name);
void set_event_handler_attribute(FlyString const& name, Optional<Bindings::CallbackType>);
Expand Down

0 comments on commit a97586c

Please sign in to comment.