summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/WebGL
diff options
context:
space:
mode:
Diffstat (limited to 'Userland/Libraries/LibWeb/WebGL')
-rw-r--r--Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.cpp16
-rw-r--r--Userland/Libraries/LibWeb/WebGL/WebGLContextEvent.h8
-rw-r--r--Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.cpp14
-rw-r--r--Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h4
-rw-r--r--Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp5
-rw-r--r--Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h2
6 files changed, 24 insertions, 25 deletions
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 <LibWeb/HTML/Window.h>
+#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/WebGL/WebGLContextEvent.h>
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<WebGLContextEvent>(window_object.realm(), window_object, event_name, event_init);
+ return realm.heap().allocate<WebGLContextEvent>(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 <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/DOM/Document.h>
#include <LibWeb/HTML/HTMLCanvasElement.h>
-#include <LibWeb/HTML/Window.h>
#include <LibWeb/WebGL/WebGLContextEvent.h>
#include <LibWeb/WebGL/WebGLRenderingContext.h>
@@ -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<JS::GCPtr<WebGLRenderingContext>> WebGLRenderingContext::create(HTML::Window& window, HTML::HTMLCanvasElement& canvas_element, JS::Value options)
+JS::ThrowCompletionOr<JS::GCPtr<WebGLRenderingContext>> WebGLRenderingContext::create(JS::Realm& realm, HTML::HTMLCanvasElement& canvas_element, JS::Value options)
{
// We should be coming here from getContext being called on a wrapped <canvas> element.
auto context_attributes = TRY(convert_value_to_context_attributes_dictionary(canvas_element.vm(), options));
@@ -46,13 +46,13 @@ JS::ThrowCompletionOr<JS::GCPtr<WebGLRenderingContext>> WebGLRenderingContext::c
fire_webgl_context_creation_error(canvas_element);
return JS::GCPtr<WebGLRenderingContext> { nullptr };
}
- return window.heap().allocate<WebGLRenderingContext>(window.realm(), window, canvas_element, context_or_error.release_value(), context_attributes, context_attributes);
+ return realm.heap().allocate<WebGLRenderingContext>(realm, realm, canvas_element, context_or_error.release_value(), context_attributes, context_attributes);
}
-WebGLRenderingContext::WebGLRenderingContext(HTML::Window& window, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)
- : WebGLRenderingContextBase(window, canvas_element, move(context), move(context_creation_parameters), move(actual_context_parameters))
+WebGLRenderingContext::WebGLRenderingContext(JS::Realm& realm, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)
+ : WebGLRenderingContextBase(realm, canvas_element, move(context), move(context_creation_parameters), move(actual_context_parameters))
{
- set_prototype(&window.cached_web_prototype("WebGLRenderingContext"));
+ set_prototype(&Bindings::cached_web_prototype(realm, "WebGLRenderingContext"));
}
WebGLRenderingContext::~WebGLRenderingContext() = default;
diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h
index f1255c20e2..d864e5dc00 100644
--- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h
+++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContext.h
@@ -16,12 +16,12 @@ class WebGLRenderingContext final : public WebGLRenderingContextBase {
WEB_PLATFORM_OBJECT(WebGLRenderingContext, WebGLRenderingContextBase);
public:
- static JS::ThrowCompletionOr<JS::GCPtr<WebGLRenderingContext>> create(HTML::Window&, HTML::HTMLCanvasElement& canvas_element, JS::Value options);
+ static JS::ThrowCompletionOr<JS::GCPtr<WebGLRenderingContext>> create(JS::Realm&, HTML::HTMLCanvasElement& canvas_element, JS::Value options);
virtual ~WebGLRenderingContext() override;
private:
- WebGLRenderingContext(HTML::Window&, HTML::HTMLCanvasElement&, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters);
+ WebGLRenderingContext(JS::Realm&, HTML::HTMLCanvasElement&, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters);
};
}
diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp
index f6d4c37890..5b424c6784 100644
--- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp
+++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.cpp
@@ -7,13 +7,12 @@
#include <AK/Debug.h>
#include <LibGL/GLContext.h>
#include <LibWeb/HTML/HTMLCanvasElement.h>
-#include <LibWeb/HTML/Window.h>
#include <LibWeb/WebGL/WebGLRenderingContextBase.h>
namespace Web::WebGL {
-WebGLRenderingContextBase::WebGLRenderingContextBase(HTML::Window& window, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)
- : PlatformObject(window.realm())
+WebGLRenderingContextBase::WebGLRenderingContextBase(JS::Realm& realm, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)
+ : PlatformObject(realm)
, m_canvas_element(canvas_element)
, m_context(move(context))
, m_context_creation_parameters(move(context_creation_parameters))
diff --git a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h
index d31992d0c3..1027923fd4 100644
--- a/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h
+++ b/Userland/Libraries/LibWeb/WebGL/WebGLRenderingContextBase.h
@@ -64,7 +64,7 @@ public:
void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
protected:
- WebGLRenderingContextBase(HTML::Window&, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters);
+ WebGLRenderingContextBase(JS::Realm&, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters);
private:
virtual void visit_edges(Cell::Visitor&) override;