mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-24 18:02:20 +00:00
LibWeb: Avoid dynamic_cast in EventTarget initialization
Let's use a virtual to tell if something uses the WindowOrWorkerGlobalScope mixin instead.
This commit is contained in:
parent
84626c7db2
commit
e7b6b84648
Notes:
github-actions[bot]
2025-04-18 12:47:57 +00:00
Author: https://github.com/awesomekling
Commit: e7b6b84648
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4395
4 changed files with 7 additions and 1 deletions
|
@ -67,7 +67,7 @@ void EventTarget::initialize(JS::Realm& realm)
|
||||||
|
|
||||||
// FIXME: We can't do this for HTML::Window or HTML::WorkerGlobalScope, as this will run when creating the initial global object.
|
// FIXME: We can't do this for HTML::Window or HTML::WorkerGlobalScope, as this will run when creating the initial global object.
|
||||||
// During this time, the ESO is not setup, so it will cause a nullptr dereference in host_defined_intrinsics.
|
// During this time, the ESO is not setup, so it will cause a nullptr dereference in host_defined_intrinsics.
|
||||||
if (!is<HTML::WindowOrWorkerGlobalScopeMixin>(this))
|
if (!is_window_or_worker_global_scope_mixin())
|
||||||
WEB_SET_PROTOTYPE_FOR_INTERFACE(EventTarget);
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(EventTarget);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,6 +59,8 @@ public:
|
||||||
bool has_event_listener(FlyString const& type) const;
|
bool has_event_listener(FlyString const& type) const;
|
||||||
bool has_event_listeners() const;
|
bool has_event_listeners() const;
|
||||||
|
|
||||||
|
virtual bool is_window_or_worker_global_scope_mixin() const { return false; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
explicit EventTarget(JS::Realm&, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
|
explicit EventTarget(JS::Realm&, MayInterfereWithIndexedPropertyAccess = MayInterfereWithIndexedPropertyAccess::No);
|
||||||
|
|
||||||
|
|
|
@ -269,6 +269,8 @@ public:
|
||||||
private:
|
private:
|
||||||
explicit Window(JS::Realm&);
|
explicit Window(JS::Realm&);
|
||||||
|
|
||||||
|
virtual bool is_window_or_worker_global_scope_mixin() const final { return true; }
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
virtual void finalize() override;
|
virtual void finalize() override;
|
||||||
|
|
||||||
|
|
|
@ -112,6 +112,8 @@ protected:
|
||||||
GC::Ptr<MessagePort> m_internal_port;
|
GC::Ptr<MessagePort> m_internal_port;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
virtual bool is_window_or_worker_global_scope_mixin() const final { return true; }
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
GC::Ptr<WorkerLocation> m_location;
|
GC::Ptr<WorkerLocation> m_location;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue