mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 15:47:44 +00:00
LibWeb: Only allocate EventTarget listener/handler storage on demand
This shaves 40 bytes off of all EventTargets that don't actually get listeners or handlers attached (which is most of them).
This commit is contained in:
parent
a71eaefdf6
commit
c1fd55ce94
2 changed files with 54 additions and 27 deletions
|
@ -68,11 +68,16 @@ protected:
|
|||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
private:
|
||||
Vector<JS::NonnullGCPtr<DOMEventListener>> m_event_listener_list;
|
||||
struct Data {
|
||||
Vector<JS::NonnullGCPtr<DOMEventListener>> event_listener_list;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-map
|
||||
// Spec Note: The order of the entries of event handler map could be arbitrary. It is not observable through any algorithms that operate on the map.
|
||||
HashMap<FlyString, JS::GCPtr<HTML::EventHandler>> m_event_handler_map;
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#event-handler-map
|
||||
// Spec Note: The order of the entries of event handler map could be arbitrary. It is not observable through any algorithms that operate on the map.
|
||||
HashMap<FlyString, JS::GCPtr<HTML::EventHandler>> event_handler_map;
|
||||
};
|
||||
|
||||
Data& ensure_data();
|
||||
OwnPtr<Data> m_data;
|
||||
|
||||
WebIDL::CallbackType* get_current_value_of_event_handler(FlyString const& name);
|
||||
void activate_event_handler(FlyString const& name, HTML::EventHandler& event_handler);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue