mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 21:57:43 +00:00
LibWeb: Remove unecessary dependence on Window from WebGL and WebSocket
These classes only needed Window to get at its realm. Pass a realm directly to construct WebGL and WebSocket classes.
This commit is contained in:
parent
4bb6345b2f
commit
beb3519a49
9 changed files with 42 additions and 42 deletions
|
@ -97,7 +97,7 @@ JS::ThrowCompletionOr<HTMLCanvasElement::HasOrCreatedContext> HTMLCanvasElement:
|
||||||
if (!m_context.has<Empty>())
|
if (!m_context.has<Empty>())
|
||||||
return m_context.has<JS::NonnullGCPtr<WebGL::WebGLRenderingContext>>() ? HasOrCreatedContext::Yes : HasOrCreatedContext::No;
|
return m_context.has<JS::NonnullGCPtr<WebGL::WebGLRenderingContext>>() ? 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)
|
if (!maybe_context)
|
||||||
return HasOrCreatedContext::No;
|
return HasOrCreatedContext::No;
|
||||||
|
|
||||||
|
|
|
@ -4,26 +4,26 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <LibWeb/HTML/Window.h>
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/WebGL/WebGLContextEvent.h>
|
#include <LibWeb/WebGL/WebGLContextEvent.h>
|
||||||
|
|
||||||
namespace Web::WebGL {
|
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)
|
WebGLContextEvent::WebGLContextEvent(JS::Realm& realm, FlyString const& type, WebGLContextEventInit const& event_init)
|
||||||
: DOM::Event(window_object, type, event_init)
|
: DOM::Event(realm, type, event_init)
|
||||||
, m_status_message(event_init.status_message)
|
, 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;
|
WebGLContextEvent::~WebGLContextEvent() = default;
|
||||||
|
|
|
@ -19,16 +19,16 @@ class WebGLContextEvent final : public DOM::Event {
|
||||||
WEB_PLATFORM_OBJECT(WebGLContextEvent, DOM::Event);
|
WEB_PLATFORM_OBJECT(WebGLContextEvent, DOM::Event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static WebGLContextEvent* create(HTML::Window&, FlyString const& type, WebGLContextEventInit const& event_init);
|
static WebGLContextEvent* create(JS::Realm&, FlyString const& type, WebGLContextEventInit const& event_init);
|
||||||
static WebGLContextEvent* create_with_global_object(HTML::Window&, FlyString const& type, WebGLContextEventInit const& event_init);
|
static WebGLContextEvent* construct_impl(JS::Realm&, FlyString const& type, WebGLContextEventInit const& event_init);
|
||||||
|
|
||||||
WebGLContextEvent(HTML::Window&, FlyString const& type, WebGLContextEventInit const& event_init);
|
|
||||||
|
|
||||||
virtual ~WebGLContextEvent() override;
|
virtual ~WebGLContextEvent() override;
|
||||||
|
|
||||||
String const& status_message() const { return m_status_message; }
|
String const& status_message() const { return m_status_message; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
WebGLContextEvent(JS::Realm&, FlyString const& type, WebGLContextEventInit const& event_init);
|
||||||
|
|
||||||
String m_status_message { String::empty() };
|
String m_status_message { String::empty() };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
* SPDX-License-Identifier: BSD-2-Clause
|
* SPDX-License-Identifier: BSD-2-Clause
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#include <LibWeb/Bindings/Intrinsics.h>
|
||||||
#include <LibWeb/DOM/Document.h>
|
#include <LibWeb/DOM/Document.h>
|
||||||
#include <LibWeb/HTML/HTMLCanvasElement.h>
|
#include <LibWeb/HTML/HTMLCanvasElement.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
#include <LibWeb/WebGL/WebGLContextEvent.h>
|
#include <LibWeb/WebGL/WebGLContextEvent.h>
|
||||||
#include <LibWeb/WebGL/WebGLRenderingContext.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.
|
// 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.
|
// 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_is_trusted(true);
|
||||||
event->set_cancelable(true);
|
event->set_cancelable(true);
|
||||||
canvas_element.dispatch_event(*event);
|
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);
|
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.
|
// 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));
|
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);
|
fire_webgl_context_creation_error(canvas_element);
|
||||||
return JS::GCPtr<WebGLRenderingContext> { nullptr };
|
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)
|
WebGLRenderingContext::WebGLRenderingContext(JS::Realm& realm, 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))
|
: 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;
|
WebGLRenderingContext::~WebGLRenderingContext() = default;
|
||||||
|
|
|
@ -16,12 +16,12 @@ class WebGLRenderingContext final : public WebGLRenderingContextBase {
|
||||||
WEB_PLATFORM_OBJECT(WebGLRenderingContext, WebGLRenderingContextBase);
|
WEB_PLATFORM_OBJECT(WebGLRenderingContext, WebGLRenderingContextBase);
|
||||||
|
|
||||||
public:
|
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;
|
virtual ~WebGLRenderingContext() override;
|
||||||
|
|
||||||
private:
|
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);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,13 +7,12 @@
|
||||||
#include <AK/Debug.h>
|
#include <AK/Debug.h>
|
||||||
#include <LibGL/GLContext.h>
|
#include <LibGL/GLContext.h>
|
||||||
#include <LibWeb/HTML/HTMLCanvasElement.h>
|
#include <LibWeb/HTML/HTMLCanvasElement.h>
|
||||||
#include <LibWeb/HTML/Window.h>
|
|
||||||
#include <LibWeb/WebGL/WebGLRenderingContextBase.h>
|
#include <LibWeb/WebGL/WebGLRenderingContextBase.h>
|
||||||
|
|
||||||
namespace Web::WebGL {
|
namespace Web::WebGL {
|
||||||
|
|
||||||
WebGLRenderingContextBase::WebGLRenderingContextBase(HTML::Window& window, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)
|
WebGLRenderingContextBase::WebGLRenderingContextBase(JS::Realm& realm, HTML::HTMLCanvasElement& canvas_element, NonnullOwnPtr<GL::GLContext> context, WebGLContextAttributes context_creation_parameters, WebGLContextAttributes actual_context_parameters)
|
||||||
: PlatformObject(window.realm())
|
: PlatformObject(realm)
|
||||||
, m_canvas_element(canvas_element)
|
, m_canvas_element(canvas_element)
|
||||||
, m_context(move(context))
|
, m_context(move(context))
|
||||||
, m_context_creation_parameters(move(context_creation_parameters))
|
, m_context_creation_parameters(move(context_creation_parameters))
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
void viewport(GLint x, GLint y, GLsizei width, GLsizei height);
|
||||||
|
|
||||||
protected:
|
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:
|
private:
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
|
@ -47,25 +47,26 @@ WebSocketClientSocket::~WebSocketClientSocket() = default;
|
||||||
WebSocketClientManager::WebSocketClientManager() = default;
|
WebSocketClientManager::WebSocketClientManager() = default;
|
||||||
|
|
||||||
// https://websockets.spec.whatwg.org/#dom-websocket-websocket
|
// https://websockets.spec.whatwg.org/#dom-websocket-websocket
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebSocket>> WebSocket::create_with_global_object(HTML::Window& window, String const& url)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<WebSocket>> WebSocket::construct_impl(JS::Realm& realm, String const& url)
|
||||||
{
|
{
|
||||||
|
auto& window = verify_cast<HTML::Window>(realm.global_object());
|
||||||
AK::URL url_record(url);
|
AK::URL url_record(url);
|
||||||
if (!url_record.is_valid())
|
if (!url_record.is_valid())
|
||||||
return WebIDL::SyntaxError::create(window, "Invalid URL");
|
return WebIDL::SyntaxError::create(realm, "Invalid URL");
|
||||||
if (!url_record.scheme().is_one_of("ws", "wss"))
|
if (!url_record.scheme().is_one_of("ws", "wss"))
|
||||||
return WebIDL::SyntaxError::create(window, "Invalid protocol");
|
return WebIDL::SyntaxError::create(realm, "Invalid protocol");
|
||||||
if (!url_record.fragment().is_empty())
|
if (!url_record.fragment().is_empty())
|
||||||
return WebIDL::SyntaxError::create(window, "Presence of URL fragment is invalid");
|
return WebIDL::SyntaxError::create(realm, "Presence of URL fragment is invalid");
|
||||||
// 5. If `protocols` is a string, set `protocols` to a sequence consisting of just that string
|
// 5. If `protocols` is a string, set `protocols` to a sequence consisting of just that string
|
||||||
// 6. If any of the values in `protocols` occur more than once or otherwise fail to match the requirements, throw SyntaxError
|
// 6. If any of the values in `protocols` occur more than once or otherwise fail to match the requirements, throw SyntaxError
|
||||||
return JS::NonnullGCPtr(*window.heap().allocate<WebSocket>(window.realm(), window, url_record));
|
return JS::NonnullGCPtr(*realm.heap().allocate<WebSocket>(realm, window, url_record));
|
||||||
}
|
}
|
||||||
|
|
||||||
WebSocket::WebSocket(HTML::Window& window, AK::URL& url)
|
WebSocket::WebSocket(HTML::Window& window, AK::URL& url)
|
||||||
: EventTarget(window.realm())
|
: EventTarget(window.realm())
|
||||||
, m_window(window)
|
, m_window(window)
|
||||||
{
|
{
|
||||||
set_prototype(&window.cached_web_prototype("WebSocket"));
|
set_prototype(&Bindings::cached_web_prototype(window.realm(), "WebSocket"));
|
||||||
|
|
||||||
// FIXME: Integrate properly with FETCH as per https://fetch.spec.whatwg.org/#websocket-opening-handshake
|
// FIXME: Integrate properly with FETCH as per https://fetch.spec.whatwg.org/#websocket-opening-handshake
|
||||||
auto origin_string = m_window->associated_document().origin().serialize();
|
auto origin_string = m_window->associated_document().origin().serialize();
|
||||||
|
@ -137,13 +138,13 @@ WebIDL::ExceptionOr<void> WebSocket::close(Optional<u16> code, Optional<String>
|
||||||
{
|
{
|
||||||
// 1. If code is present, but is neither an integer equal to 1000 nor an integer in the range 3000 to 4999, inclusive, throw an "InvalidAccessError" DOMException.
|
// 1. If code is present, but is neither an integer equal to 1000 nor an integer in the range 3000 to 4999, inclusive, throw an "InvalidAccessError" DOMException.
|
||||||
if (code.has_value() && *code != 1000 && (*code < 3000 || *code > 4099))
|
if (code.has_value() && *code != 1000 && (*code < 3000 || *code > 4099))
|
||||||
return WebIDL::InvalidAccessError::create(global_object(), "The close error code is invalid");
|
return WebIDL::InvalidAccessError::create(realm(), "The close error code is invalid");
|
||||||
// 2. If reason is present, then run these substeps:
|
// 2. If reason is present, then run these substeps:
|
||||||
if (reason.has_value()) {
|
if (reason.has_value()) {
|
||||||
// 1. Let reasonBytes be the result of encoding reason.
|
// 1. Let reasonBytes be the result of encoding reason.
|
||||||
// 2. If reasonBytes is longer than 123 bytes, then throw a "SyntaxError" DOMException.
|
// 2. If reasonBytes is longer than 123 bytes, then throw a "SyntaxError" DOMException.
|
||||||
if (reason->bytes().size() > 123)
|
if (reason->bytes().size() > 123)
|
||||||
return WebIDL::SyntaxError::create(global_object(), "The close reason is longer than 123 bytes");
|
return WebIDL::SyntaxError::create(realm(), "The close reason is longer than 123 bytes");
|
||||||
}
|
}
|
||||||
// 3. Run the first matching steps from the following list:
|
// 3. Run the first matching steps from the following list:
|
||||||
auto state = ready_state();
|
auto state = ready_state();
|
||||||
|
@ -164,7 +165,7 @@ WebIDL::ExceptionOr<void> WebSocket::send(String const& data)
|
||||||
{
|
{
|
||||||
auto state = ready_state();
|
auto state = ready_state();
|
||||||
if (state == WebSocket::ReadyState::Connecting)
|
if (state == WebSocket::ReadyState::Connecting)
|
||||||
return WebIDL::InvalidStateError::create(global_object(), "Websocket is still CONNECTING");
|
return WebIDL::InvalidStateError::create(realm(), "Websocket is still CONNECTING");
|
||||||
if (state == WebSocket::ReadyState::Open) {
|
if (state == WebSocket::ReadyState::Open) {
|
||||||
m_websocket->send(data);
|
m_websocket->send(data);
|
||||||
// TODO : If the data cannot be sent, e.g. because it would need to be buffered but the buffer is full, the user agent must flag the WebSocket as full and then close the WebSocket connection.
|
// TODO : If the data cannot be sent, e.g. because it would need to be buffered but the buffer is full, the user agent must flag the WebSocket as full and then close the WebSocket connection.
|
||||||
|
@ -179,13 +180,13 @@ void WebSocket::on_open()
|
||||||
// 1. Change the readyState attribute's value to OPEN (1).
|
// 1. Change the readyState attribute's value to OPEN (1).
|
||||||
// 2. Change the extensions attribute's value to the extensions in use, if it is not the null value. [WSP]
|
// 2. Change the extensions attribute's value to the extensions in use, if it is not the null value. [WSP]
|
||||||
// 3. Change the protocol attribute's value to the subprotocol in use, if it is not the null value. [WSP]
|
// 3. Change the protocol attribute's value to the subprotocol in use, if it is not the null value. [WSP]
|
||||||
dispatch_event(*DOM::Event::create(*m_window, HTML::EventNames::open));
|
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::open));
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
||||||
void WebSocket::on_error()
|
void WebSocket::on_error()
|
||||||
{
|
{
|
||||||
dispatch_event(*DOM::Event::create(*m_window, HTML::EventNames::error));
|
dispatch_event(*DOM::Event::create(realm(), HTML::EventNames::error));
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
||||||
|
@ -197,7 +198,7 @@ void WebSocket::on_close(u16 code, String reason, bool was_clean)
|
||||||
event_init.was_clean = was_clean;
|
event_init.was_clean = was_clean;
|
||||||
event_init.code = code;
|
event_init.code = code;
|
||||||
event_init.reason = move(reason);
|
event_init.reason = move(reason);
|
||||||
dispatch_event(*HTML::CloseEvent::create(*m_window, HTML::EventNames::close, event_init));
|
dispatch_event(*HTML::CloseEvent::create(realm(), HTML::EventNames::close, event_init));
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
// https://websockets.spec.whatwg.org/#feedback-from-the-protocol
|
||||||
|
@ -210,7 +211,7 @@ void WebSocket::on_message(ByteBuffer message, bool is_text)
|
||||||
HTML::MessageEventInit event_init;
|
HTML::MessageEventInit event_init;
|
||||||
event_init.data = JS::js_string(vm(), text_message);
|
event_init.data = JS::js_string(vm(), text_message);
|
||||||
event_init.origin = url();
|
event_init.origin = url();
|
||||||
dispatch_event(*HTML::MessageEvent::create(*m_window, HTML::EventNames::message, event_init));
|
dispatch_event(*HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +223,7 @@ void WebSocket::on_message(ByteBuffer message, bool is_text)
|
||||||
HTML::MessageEventInit event_init;
|
HTML::MessageEventInit event_init;
|
||||||
event_init.data = JS::ArrayBuffer::create(realm(), message);
|
event_init.data = JS::ArrayBuffer::create(realm(), message);
|
||||||
event_init.origin = url();
|
event_init.origin = url();
|
||||||
dispatch_event(*HTML::MessageEvent::create(*m_window, HTML::EventNames::message, event_init));
|
dispatch_event(*HTML::MessageEvent::create(realm(), HTML::EventNames::message, event_init));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,7 +37,7 @@ public:
|
||||||
Closed = 3,
|
Closed = 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<WebSocket>> create_with_global_object(HTML::Window&, String const& url);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<WebSocket>> construct_impl(JS::Realm&, String const& url);
|
||||||
|
|
||||||
virtual ~WebSocket() override;
|
virtual ~WebSocket() override;
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ private:
|
||||||
void on_error();
|
void on_error();
|
||||||
void on_close(u16 code, String reason, bool was_clean);
|
void on_close(u16 code, String reason, bool was_clean);
|
||||||
|
|
||||||
explicit WebSocket(HTML::Window&, AK::URL&);
|
WebSocket(HTML::Window&, AK::URL&);
|
||||||
|
|
||||||
virtual void visit_edges(Cell::Visitor&) override;
|
virtual void visit_edges(Cell::Visitor&) override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue