diff --git a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp
index 2d836095fd..54217cf542 100644
--- a/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp
+++ b/Userland/Libraries/LibWeb/HTML/HTMLCanvasElement.cpp
@@ -97,7 +97,7 @@ JS::ThrowCompletionOr HTMLCanvasElement:
if (!m_context.has())
return m_context.has>() ? HasOrCreatedContext::Yes : HasOrCreatedContext::No;
- auto maybe_context = TRY(WebGL::WebGLRenderingContext::create(window(), *this, options));
+ auto maybe_context = TRY(WebGL::WebGLRenderingContext::create(realm(), *this, options));
if (!maybe_context)
return HasOrCreatedContext::No;
diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp
index 363bdeeec5..343a8c2a0b 100644
--- a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp
+++ b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp
@@ -4,26 +4,26 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
-#include
+#include
#include
namespace Web::WebGL {
-WebGLContextEvent* WebGLContextEvent::create(HTML::Window& window_object, FlyString const& event_name, WebGLContextEventInit const& event_init)
+WebGLContextEvent* WebGLContextEvent::create(JS::Realm& realm, FlyString const& event_name, WebGLContextEventInit const& event_init)
{
- return window_object.heap().allocate(window_object.realm(), window_object, event_name, event_init);
+ return realm.heap().allocate(realm, realm, event_name, event_init);
}
-WebGLContextEvent* WebGLContextEvent::create_with_global_object(HTML::Window& window_object, FlyString const& event_name, WebGLContextEventInit const& event_init)
+WebGLContextEvent* WebGLContextEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, WebGLContextEventInit const& event_init)
{
- return create(window_object, event_name, event_init);
+ return create(realm, event_name, event_init);
}
-WebGLContextEvent::WebGLContextEvent(HTML::Window& window_object, FlyString const& type, WebGLContextEventInit const& event_init)
- : DOM::Event(window_object, type, event_init)
+WebGLContextEvent::WebGLContextEvent(JS::Realm& realm, FlyString const& type, WebGLContextEventInit const& event_init)
+ : DOM::Event(realm, type, event_init)
, m_status_message(event_init.status_message)
{
- set_prototype(&window_object.cached_web_prototype("WebGLContextEvent"));
+ set_prototype(&Bindings::cached_web_prototype(realm, "WebGLContextEvent"));
}
WebGLContextEvent::~WebGLContextEvent() = default;
diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h
index 6440e60ea9..2827ecaeb7 100644
--- a/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h
+++ b/Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h
@@ -19,16 +19,16 @@ class WebGLContextEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(WebGLContextEvent, DOM::Event);
public:
- static WebGLContextEvent* create(HTML::Window&, FlyString const& type, WebGLContextEventInit const& event_init);
- static WebGLContextEvent* create_with_global_object(HTML::Window&, FlyString const& type, WebGLContextEventInit const& event_init);
-
- WebGLContextEvent(HTML::Window&, FlyString const& type, WebGLContextEventInit const& event_init);
+ static WebGLContextEvent* create(JS::Realm&, FlyString const& type, WebGLContextEventInit const& event_init);
+ static WebGLContextEvent* construct_impl(JS::Realm&, FlyString const& type, WebGLContextEventInit const& event_init);
virtual ~WebGLContextEvent() override;
String const& status_message() const { return m_status_message; }
private:
+ WebGLContextEvent(JS::Realm&, FlyString const& type, WebGLContextEventInit const& event_init);
+
String m_status_message { String::empty() };
};
diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp
index 824425b668..e540f002f0 100644
--- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp
+++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp
@@ -4,9 +4,9 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
+#include
#include
#include
-#include
#include
#include
@@ -17,7 +17,7 @@ static void fire_webgl_context_event(HTML::HTMLCanvasElement& canvas_element, Fl
{
// To fire a WebGL context event named e means that an event using the WebGLContextEvent interface, with its type attribute [DOM4] initialized to e, its cancelable attribute initialized to true, and its isTrusted attribute [DOM4] initialized to true, is to be dispatched at the given object.
// FIXME: Consider setting a status message.
- auto event = WebGLContextEvent::create(canvas_element.document().window(), type, WebGLContextEventInit {});
+ auto event = WebGLContextEvent::create(canvas_element.realm(), type, WebGLContextEventInit {});
event->set_is_trusted(true);
event->set_cancelable(true);
canvas_element.dispatch_event(*event);
@@ -30,7 +30,7 @@ static void fire_webgl_context_creation_error(HTML::HTMLCanvasElement& canvas_el
fire_webgl_context_event(canvas_element, "webglcontextcreationerror"sv);
}
-JS::ThrowCompletionOr> WebGLRenderingContext::create(HTML::Window& window, HTML::HTMLCanvasElement& canvas_element, JS::Value options)
+JS::ThrowCompletionOr> WebGLRenderingContext::create(JS::Realm& realm, HTML::HTMLCanvasElement& canvas_element, JS::Value options)
{
// We should be coming here from getContext being called on a wrapped