mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 06:57:46 +00:00
LibWeb: Remove unecessary dependence on Window from DOM and WebIDL
These classes only needed Window to get at its realm. Pass a realm directly to construct DOM and WebIDL classes. This change importantly removes the guarantee that a Document will always have a non-null Window object. Only Documents created by a BrowsingContext will have a non-null Window object. Documents created by for example, DocumentFragment, will not have a Window (soon). This incremental commit leaves some workarounds in place to keep other parts of the code building.
This commit is contained in:
parent
8407bf60c5
commit
8de7e49a56
56 changed files with 364 additions and 326 deletions
|
@ -7,6 +7,7 @@
|
|||
*/
|
||||
|
||||
#include <AK/TypeCasts.h>
|
||||
#include <LibWeb/Bindings/Intrinsics.h>
|
||||
#include <LibWeb/DOM/Event.h>
|
||||
#include <LibWeb/DOM/Node.h>
|
||||
#include <LibWeb/DOM/ShadowRoot.h>
|
||||
|
@ -14,25 +15,30 @@
|
|||
|
||||
namespace Web::DOM {
|
||||
|
||||
JS::NonnullGCPtr<Event> Event::create(HTML::Window& window_object, FlyString const& event_name, EventInit const& event_init)
|
||||
JS::NonnullGCPtr<Event> Event::create(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
|
||||
{
|
||||
return *window_object.heap().allocate<Event>(window_object.realm(), window_object, event_name, event_init);
|
||||
return *realm.heap().allocate<Event>(realm, realm, event_name, event_init);
|
||||
}
|
||||
|
||||
JS::NonnullGCPtr<Event> Event::create_with_global_object(HTML::Window& window_object, FlyString const& event_name, EventInit const& event_init)
|
||||
JS::NonnullGCPtr<Event> Event::create(HTML::Window& window, FlyString const& event_name, EventInit const& event_init)
|
||||
{
|
||||
return create(window_object, event_name, event_init);
|
||||
return create(window.realm(), event_name, event_init);
|
||||
}
|
||||
|
||||
Event::Event(HTML::Window& window, FlyString const& type)
|
||||
: PlatformObject(window.cached_web_prototype("Event"))
|
||||
JS::NonnullGCPtr<Event> Event::construct_impl(JS::Realm& realm, FlyString const& event_name, EventInit const& event_init)
|
||||
{
|
||||
return create(realm, event_name, event_init);
|
||||
}
|
||||
|
||||
Event::Event(JS::Realm& realm, FlyString const& type)
|
||||
: PlatformObject(Bindings::cached_web_prototype(realm, "Event"))
|
||||
, m_type(type)
|
||||
, m_initialized(true)
|
||||
{
|
||||
}
|
||||
|
||||
Event::Event(HTML::Window& window, FlyString const& type, EventInit const& event_init)
|
||||
: PlatformObject(window.cached_web_prototype("Event"))
|
||||
Event::Event(JS::Realm& realm, FlyString const& type, EventInit const& event_init)
|
||||
: PlatformObject(Bindings::cached_web_prototype(realm, "Event"))
|
||||
, m_type(type)
|
||||
, m_bubbles(event_init.bubbles)
|
||||
, m_cancelable(event_init.cancelable)
|
||||
|
@ -41,6 +47,16 @@ Event::Event(HTML::Window& window, FlyString const& type, EventInit const& event
|
|||
{
|
||||
}
|
||||
|
||||
Event::Event(HTML::Window& window, FlyString const& type, EventInit const& event_init)
|
||||
: Event(window.realm(), type, event_init)
|
||||
{
|
||||
}
|
||||
|
||||
Event::Event(HTML::Window& window, FlyString const& type)
|
||||
: Event(window.realm(), type)
|
||||
{
|
||||
}
|
||||
|
||||
void Event::visit_edges(Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue