mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-21 03:55:24 +00:00
LibWeb: Ensure global objects are an event target
All global objects current need to be event targets so that they can have events dispatched to them. This allows for removing of verify_cast for these global objects.
This commit is contained in:
parent
6a85677f70
commit
05b4676917
Notes:
github-actions[bot]
2024-12-02 23:20:48 +00:00
Author: https://github.com/shannonbooth Commit: https://github.com/LadybirdBrowser/ladybird/commit/05b46769174 Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2702 Reviewed-by: https://github.com/gmta ✅
6 changed files with 11 additions and 12 deletions
|
@ -26,8 +26,8 @@ public:
|
|||
|
||||
static GC::Ref<ShadowRealmGlobalScope> create(JS::Realm&);
|
||||
|
||||
virtual Bindings::PlatformObject& this_impl() override { return *this; }
|
||||
virtual Bindings::PlatformObject const& this_impl() const override { return *this; }
|
||||
virtual DOM::EventTarget& this_impl() override { return *this; }
|
||||
virtual DOM::EventTarget const& this_impl() const override { return *this; }
|
||||
|
||||
// https://whatpr.org/html/9893/webappapis.html#dom-shadowrealmglobalscope-self
|
||||
GC::Ref<ShadowRealmGlobalScope> self()
|
||||
|
|
|
@ -198,8 +198,7 @@ void UniversalGlobalScopeMixin::notify_about_rejected_promises(Badge<EventLoop>)
|
|||
m_about_to_be_notified_rejected_promises_list.clear();
|
||||
|
||||
// 4. Let global be settings object's global object.
|
||||
// We need this as an event target for the unhandledrejection event below
|
||||
auto& global = verify_cast<DOM::EventTarget>(this_impl());
|
||||
auto& global = this_impl();
|
||||
|
||||
// 5. Queue a global task on the DOM manipulation task source given global to run the following substep:
|
||||
queue_global_task(Task::Source::DOMManipulation, global, GC::create_function(realm.heap(), [this, &global, list = move(list)] {
|
||||
|
|
|
@ -21,8 +21,8 @@ class UniversalGlobalScopeMixin {
|
|||
public:
|
||||
virtual ~UniversalGlobalScopeMixin();
|
||||
|
||||
virtual Bindings::PlatformObject& this_impl() = 0;
|
||||
virtual Bindings::PlatformObject const& this_impl() const = 0;
|
||||
virtual DOM::EventTarget& this_impl() = 0;
|
||||
virtual DOM::EventTarget const& this_impl() const = 0;
|
||||
|
||||
WebIDL::ExceptionOr<String> btoa(String const& data) const;
|
||||
WebIDL::ExceptionOr<String> atob(String const& data) const;
|
||||
|
|
|
@ -76,8 +76,8 @@ public:
|
|||
virtual bool dispatch_event(DOM::Event&) override;
|
||||
|
||||
// ^WindowOrWorkerGlobalScopeMixin
|
||||
virtual Bindings::PlatformObject& this_impl() override { return *this; }
|
||||
virtual Bindings::PlatformObject const& this_impl() const override { return *this; }
|
||||
virtual DOM::EventTarget& this_impl() override { return *this; }
|
||||
virtual DOM::EventTarget const& this_impl() const override { return *this; }
|
||||
|
||||
// ^JS::Object
|
||||
virtual JS::ThrowCompletionOr<bool> internal_set_prototype_of(JS::Object* prototype) override;
|
||||
|
|
|
@ -29,8 +29,8 @@ class WindowOrWorkerGlobalScopeMixin {
|
|||
public:
|
||||
virtual ~WindowOrWorkerGlobalScopeMixin();
|
||||
|
||||
virtual Bindings::PlatformObject& this_impl() = 0;
|
||||
virtual Bindings::PlatformObject const& this_impl() const = 0;
|
||||
virtual DOM::EventTarget& this_impl() = 0;
|
||||
virtual DOM::EventTarget const& this_impl() const = 0;
|
||||
|
||||
// JS API functions
|
||||
String origin() const;
|
||||
|
|
|
@ -43,8 +43,8 @@ public:
|
|||
virtual ~WorkerGlobalScope() override;
|
||||
|
||||
// ^WindowOrWorkerGlobalScopeMixin
|
||||
virtual Bindings::PlatformObject& this_impl() override { return *this; }
|
||||
virtual Bindings::PlatformObject const& this_impl() const override { return *this; }
|
||||
virtual DOM::EventTarget& this_impl() override { return *this; }
|
||||
virtual DOM::EventTarget const& this_impl() const override { return *this; }
|
||||
|
||||
using UniversalGlobalScopeMixin::atob;
|
||||
using UniversalGlobalScopeMixin::btoa;
|
||||
|
|
Loading…
Add table
Reference in a new issue