mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 23:27:43 +00:00
LibWeb: Make DOM::Event and all its subclasses GC-allocated
This commit is contained in:
parent
a4ddb0ef87
commit
7c3db526b0
76 changed files with 892 additions and 565 deletions
34
Userland/Libraries/LibWeb/HTML/CloseEvent.cpp
Normal file
34
Userland/Libraries/LibWeb/HTML/CloseEvent.cpp
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/CloseEventPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/HTML/CloseEvent.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
CloseEvent* CloseEvent::create(Bindings::WindowObject& window_object, FlyString const& event_name, CloseEventInit const& event_init)
|
||||
{
|
||||
return window_object.heap().allocate<CloseEvent>(window_object.realm(), window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
CloseEvent* CloseEvent::create_with_global_object(Bindings::WindowObject& window_object, FlyString const& event_name, CloseEventInit const& event_init)
|
||||
{
|
||||
return create(window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
CloseEvent::CloseEvent(Bindings::WindowObject& window_object, FlyString const& event_name, CloseEventInit const& event_init)
|
||||
: DOM::Event(window_object, event_name, event_init)
|
||||
, m_was_clean(event_init.was_clean)
|
||||
, m_code(event_init.code)
|
||||
, m_reason(event_init.reason)
|
||||
{
|
||||
set_prototype(&window_object.ensure_web_prototype<Bindings::CloseEventPrototype>("CloseEvent"));
|
||||
}
|
||||
|
||||
CloseEvent::~CloseEvent() = default;
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -17,36 +18,31 @@ struct CloseEventInit : public DOM::EventInit {
|
|||
};
|
||||
|
||||
class CloseEvent : public DOM::Event {
|
||||
JS_OBJECT(CloseEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
using WrapperType = Bindings::CloseEventWrapper;
|
||||
static CloseEvent* create(Bindings::WindowObject&, FlyString const& event_name, CloseEventInit const& event_init = {});
|
||||
static CloseEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, CloseEventInit const& event_init);
|
||||
|
||||
static NonnullRefPtr<CloseEvent> create(FlyString const& event_name, CloseEventInit const& event_init = {})
|
||||
{
|
||||
return adopt_ref(*new CloseEvent(event_name, event_init));
|
||||
}
|
||||
static NonnullRefPtr<CloseEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, CloseEventInit const& event_init)
|
||||
{
|
||||
return CloseEvent::create(event_name, event_init);
|
||||
}
|
||||
CloseEvent(Bindings::WindowObject&, FlyString const& event_name, CloseEventInit const& event_init);
|
||||
|
||||
virtual ~CloseEvent() override = default;
|
||||
virtual ~CloseEvent() override;
|
||||
|
||||
CloseEvent& impl() { return *this; }
|
||||
|
||||
bool was_clean() const { return m_was_clean; }
|
||||
u16 code() const { return m_code; }
|
||||
String reason() const { return m_reason; }
|
||||
|
||||
protected:
|
||||
CloseEvent(FlyString const& event_name, CloseEventInit const& event_init)
|
||||
: DOM::Event(event_name, event_init)
|
||||
, m_was_clean(event_init.was_clean)
|
||||
, m_code(event_init.code)
|
||||
, m_reason(event_init.reason)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_was_clean { false };
|
||||
u16 m_code { 0 };
|
||||
String m_reason;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::HTML::CloseEvent& object) { return &object; }
|
||||
using CloseEventWrapper = Web::HTML::CloseEvent;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#import <DOM/Event.idl>
|
||||
|
||||
[NoInstanceWrapper]
|
||||
interface CloseEvent : Event {
|
||||
constructor(DOMString type, optional CloseEventInit eventInitDict = {});
|
||||
|
||||
|
|
42
Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp
Normal file
42
Userland/Libraries/LibWeb/HTML/ErrorEvent.cpp
Normal file
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/ErrorEventPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/HTML/ErrorEvent.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
ErrorEvent* ErrorEvent::create(Bindings::WindowObject& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
|
||||
{
|
||||
return window_object.heap().allocate<ErrorEvent>(window_object.realm(), window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
ErrorEvent* ErrorEvent::create_with_global_object(Bindings::WindowObject& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
|
||||
{
|
||||
return create(window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
ErrorEvent::ErrorEvent(Bindings::WindowObject& window_object, FlyString const& event_name, ErrorEventInit const& event_init)
|
||||
: DOM::Event(window_object, event_name)
|
||||
, m_message(event_init.message)
|
||||
, m_filename(event_init.filename)
|
||||
, m_lineno(event_init.lineno)
|
||||
, m_colno(event_init.colno)
|
||||
, m_error(event_init.error)
|
||||
{
|
||||
set_prototype(&window_object.ensure_web_prototype<Bindings::ErrorEventPrototype>("ErrorEvent"));
|
||||
}
|
||||
|
||||
ErrorEvent::~ErrorEvent() = default;
|
||||
|
||||
void ErrorEvent::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_error);
|
||||
}
|
||||
|
||||
}
|
|
@ -21,20 +21,17 @@ struct ErrorEventInit : public DOM::EventInit {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#errorevent
|
||||
class ErrorEvent final : public DOM::Event {
|
||||
JS_OBJECT(ErrorEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
using WrapperType = Bindings::ErrorEventWrapper;
|
||||
static ErrorEvent* create(Bindings::WindowObject&, FlyString const& event_name, ErrorEventInit const& event_init = {});
|
||||
static ErrorEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, ErrorEventInit const& event_init);
|
||||
|
||||
static NonnullRefPtr<ErrorEvent> create(FlyString const& event_name, ErrorEventInit const& event_init = {})
|
||||
{
|
||||
return adopt_ref(*new ErrorEvent(event_name, event_init));
|
||||
}
|
||||
ErrorEvent(Bindings::WindowObject&, FlyString const& event_name, ErrorEventInit const& event_init);
|
||||
|
||||
static NonnullRefPtr<ErrorEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, ErrorEventInit const& event_init)
|
||||
{
|
||||
return ErrorEvent::create(event_name, event_init);
|
||||
}
|
||||
virtual ~ErrorEvent() override;
|
||||
|
||||
virtual ~ErrorEvent() override = default;
|
||||
ErrorEvent& impl() { return *this; }
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-message
|
||||
String const& message() const { return m_message; }
|
||||
|
@ -49,24 +46,21 @@ public:
|
|||
u32 colno() const { return m_colno; }
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-error
|
||||
JS::Value error() const { return m_error.value(); }
|
||||
JS::Value error() const { return m_error; }
|
||||
|
||||
private:
|
||||
ErrorEvent(FlyString const& event_name, ErrorEventInit const& event_init)
|
||||
: DOM::Event(event_name)
|
||||
, m_message(event_init.message)
|
||||
, m_filename(event_init.filename)
|
||||
, m_lineno(event_init.lineno)
|
||||
, m_colno(event_init.colno)
|
||||
, m_error(JS::make_handle(event_init.error))
|
||||
{
|
||||
}
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
String m_message { "" };
|
||||
String m_filename { "" }; // FIXME: This should be a USVString.
|
||||
u32 m_lineno { 0 };
|
||||
u32 m_colno { 0 };
|
||||
JS::Handle<JS::Value> m_error;
|
||||
JS::Value m_error;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::HTML::ErrorEvent& object) { return &object; }
|
||||
using ErrorEventWrapper = Web::HTML::ErrorEvent;
|
||||
}
|
||||
|
|
|
@ -247,9 +247,9 @@ static void run_focus_update_steps(NonnullRefPtrVector<DOM::Node> old_chain, Non
|
|||
// with related blur target as the related target.
|
||||
if (blur_event_target) {
|
||||
// FIXME: Implement the "fire a focus event" spec operation.
|
||||
auto blur_event = UIEvents::FocusEvent::create(HTML::EventNames::blur);
|
||||
auto blur_event = UIEvents::FocusEvent::create(verify_cast<DOM::Node>(*blur_event_target).document().preferred_window_object(), HTML::EventNames::blur);
|
||||
blur_event->set_related_target(related_blur_target);
|
||||
blur_event_target->dispatch_event(move(blur_event));
|
||||
blur_event_target->dispatch_event(*blur_event);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -290,9 +290,9 @@ static void run_focus_update_steps(NonnullRefPtrVector<DOM::Node> old_chain, Non
|
|||
// with related focus target as the related target.
|
||||
if (focus_event_target) {
|
||||
// FIXME: Implement the "fire a focus event" spec operation.
|
||||
auto focus_event = UIEvents::FocusEvent::create(HTML::EventNames::focus);
|
||||
auto focus_event = UIEvents::FocusEvent::create(verify_cast<DOM::Node>(*focus_event_target).document().preferred_window_object(), HTML::EventNames::focus);
|
||||
focus_event->set_related_target(related_focus_target);
|
||||
focus_event_target->dispatch_event(move(focus_event));
|
||||
focus_event_target->dispatch_event(*focus_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -411,7 +411,7 @@ bool HTMLElement::fire_a_synthetic_pointer_event(FlyString const& type, DOM::Ele
|
|||
// 1. Let event be the result of creating an event using PointerEvent.
|
||||
// 2. Initialize event's type attribute to e.
|
||||
// FIXME: Actually create a PointerEvent!
|
||||
auto event = UIEvents::MouseEvent::create(type);
|
||||
auto event = UIEvents::MouseEvent::create(document().preferred_window_object(), type);
|
||||
|
||||
// 3. Initialize event's bubbles and cancelable attributes to true.
|
||||
event->set_bubbles(true);
|
||||
|
@ -433,7 +433,7 @@ bool HTMLElement::fire_a_synthetic_pointer_event(FlyString const& type, DOM::Ele
|
|||
// FIXME: 8. event's getModifierState() method is to return values appropriately describing the current state of the key input device.
|
||||
|
||||
// 9. Return the result of dispatching event at target.
|
||||
return target.dispatch_event(move(event));
|
||||
return target.dispatch_event(*event);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/interaction.html#dom-click
|
||||
|
|
|
@ -65,10 +65,10 @@ void HTMLFormElement::submit_form(RefPtr<HTMLElement> submitter, bool from_submi
|
|||
|
||||
SubmitEventInit event_init {};
|
||||
event_init.submitter = submitter_button;
|
||||
auto submit_event = SubmitEvent::create(EventNames::submit, event_init);
|
||||
auto submit_event = SubmitEvent::create(document().preferred_window_object(), EventNames::submit, event_init);
|
||||
submit_event->set_bubbles(true);
|
||||
submit_event->set_cancelable(true);
|
||||
bool continue_ = dispatch_event(submit_event);
|
||||
bool continue_ = dispatch_event(*submit_event);
|
||||
|
||||
m_firing_submission_events = false;
|
||||
|
||||
|
|
|
@ -92,7 +92,7 @@ void run_iframe_load_event_steps(HTML::HTMLIFrameElement& element)
|
|||
// FIXME: 4. Set childDocument's iframe load in progress flag.
|
||||
|
||||
// 5. Fire an event named load at element.
|
||||
element.dispatch_event(DOM::Event::create(HTML::EventNames::load));
|
||||
element.dispatch_event(*DOM::Event::create(element.document().preferred_window_object(), HTML::EventNames::load));
|
||||
|
||||
// FIXME: 6. Unset childDocument's iframe load in progress flag.
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, DOM::QualifiedName q
|
|||
set_needs_style_update(true);
|
||||
this->document().set_needs_layout();
|
||||
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
|
||||
dispatch_event(DOM::Event::create(EventNames::load));
|
||||
dispatch_event(*DOM::Event::create(this->document().preferred_window_object(), EventNames::load));
|
||||
});
|
||||
};
|
||||
|
||||
|
@ -35,7 +35,7 @@ HTMLImageElement::HTMLImageElement(DOM::Document& document, DOM::QualifiedName q
|
|||
set_needs_style_update(true);
|
||||
this->document().set_needs_layout();
|
||||
queue_an_element_task(HTML::Task::Source::DOMManipulation, [this] {
|
||||
dispatch_event(DOM::Event::create(EventNames::error));
|
||||
dispatch_event(*DOM::Event::create(this->document().preferred_window_object(), EventNames::error));
|
||||
});
|
||||
};
|
||||
|
||||
|
|
|
@ -90,15 +90,15 @@ void HTMLInputElement::run_input_activation_behavior()
|
|||
return;
|
||||
|
||||
// 2. Fire an event named input at the element with the bubbles and composed attributes initialized to true.
|
||||
auto input_event = DOM::Event::create(HTML::EventNames::input);
|
||||
auto input_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::input);
|
||||
input_event->set_bubbles(true);
|
||||
input_event->set_composed(true);
|
||||
dispatch_event(move(input_event));
|
||||
dispatch_event(*input_event);
|
||||
|
||||
// 3. Fire an event named change at the element with the bubbles attribute initialized to true.
|
||||
auto change_event = DOM::Event::create(HTML::EventNames::change);
|
||||
auto change_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::change);
|
||||
change_event->set_bubbles(true);
|
||||
dispatch_event(move(change_event));
|
||||
dispatch_event(*change_event);
|
||||
} else if (type_state() == TypeAttributeState::SubmitButton) {
|
||||
RefPtr<HTMLFormElement> form;
|
||||
// 1. If the element does not have a form owner, then return.
|
||||
|
@ -112,7 +112,7 @@ void HTMLInputElement::run_input_activation_behavior()
|
|||
// 3. Submit the form owner from the element.
|
||||
form->submit_form(this);
|
||||
} else {
|
||||
dispatch_event(DOM::Event::create(EventNames::change));
|
||||
dispatch_event(*DOM::Event::create(document().preferred_window_object(), EventNames::change));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -125,15 +125,15 @@ void HTMLInputElement::did_edit_text_node(Badge<BrowsingContext>)
|
|||
// NOTE: This is a bit ad-hoc, but basically implements part of "4.10.5.5 Common event behaviors"
|
||||
// https://html.spec.whatwg.org/multipage/input.html#common-input-element-events
|
||||
queue_an_element_task(HTML::Task::Source::UserInteraction, [this] {
|
||||
auto input_event = DOM::Event::create(HTML::EventNames::input);
|
||||
auto input_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::input);
|
||||
input_event->set_bubbles(true);
|
||||
input_event->set_composed(true);
|
||||
dispatch_event(move(input_event));
|
||||
dispatch_event(*input_event);
|
||||
|
||||
// FIXME: This should only fire when the input is "committed", whatever that means.
|
||||
auto change_event = DOM::Event::create(HTML::EventNames::change);
|
||||
auto change_event = DOM::Event::create(document().preferred_window_object(), HTML::EventNames::change);
|
||||
change_event->set_bubbles(true);
|
||||
dispatch_event(move(change_event));
|
||||
dispatch_event(*change_event);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -96,7 +96,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps()
|
|||
|
||||
// 3. If that failed, fire an event named error at the element, then jump to the step below labeled fallback.
|
||||
if (!url.is_valid()) {
|
||||
dispatch_event(DOM::Event::create(HTML::EventNames::error));
|
||||
dispatch_event(*DOM::Event::create(document().preferred_window_object(), HTML::EventNames::error));
|
||||
return run_object_representation_fallback_steps();
|
||||
}
|
||||
|
||||
|
@ -123,7 +123,7 @@ void HTMLObjectElement::queue_element_task_to_run_object_representation_steps()
|
|||
void HTMLObjectElement::resource_did_fail()
|
||||
{
|
||||
// 4.7. If the load failed (e.g. there was an HTTP 404 error, there was a DNS error), fire an event named error at the element, then jump to the step below labeled fallback.
|
||||
dispatch_event(DOM::Event::create(HTML::EventNames::error));
|
||||
dispatch_event(*DOM::Event::create(document().preferred_window_object(), HTML::EventNames::error));
|
||||
run_object_representation_fallback_steps();
|
||||
}
|
||||
|
||||
|
@ -261,7 +261,7 @@ void HTMLObjectElement::run_object_representation_completed_steps(Representation
|
|||
// 4.11. If the object element does not represent its nested browsing context, then once the resource is completely loaded, queue an element task on the DOM manipulation task source given the object element to fire an event named load at the element.
|
||||
if (representation != Representation::NestedBrowsingContext) {
|
||||
queue_an_element_task(HTML::Task::Source::DOMManipulation, [&]() {
|
||||
dispatch_event(DOM::Event::create(HTML::EventNames::load));
|
||||
dispatch_event(*DOM::Event::create(document().preferred_window_object(), HTML::EventNames::load));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ void HTMLScriptElement::execute_script()
|
|||
// 3. If the script's script is null for scriptElement, then fire an event named error at scriptElement, and return.
|
||||
if (!m_script) {
|
||||
dbgln("HTMLScriptElement: Refusing to run script because the script's script is null.");
|
||||
dispatch_event(DOM::Event::create(HTML::EventNames::error));
|
||||
dispatch_event(*DOM::Event::create(document().preferred_window_object(), HTML::EventNames::error));
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -95,7 +95,7 @@ void HTMLScriptElement::execute_script()
|
|||
|
||||
// 7. If scriptElement is from an external file, then fire an event named load at scriptElement.
|
||||
if (m_from_an_external_file)
|
||||
dispatch_event(DOM::Event::create(HTML::EventNames::load));
|
||||
dispatch_event(*DOM::Event::create(document().preferred_window_object(), HTML::EventNames::load));
|
||||
}
|
||||
|
||||
// https://mimesniff.spec.whatwg.org/#javascript-mime-type-essence-match
|
||||
|
@ -259,7 +259,7 @@ void HTMLScriptElement::prepare_script()
|
|||
if (src.is_empty()) {
|
||||
dbgln("HTMLScriptElement: Refusing to run script because the src attribute is empty.");
|
||||
queue_an_element_task(HTML::Task::Source::Unspecified, [this] {
|
||||
dispatch_event(DOM::Event::create(HTML::EventNames::error));
|
||||
dispatch_event(*DOM::Event::create(document().preferred_window_object(), HTML::EventNames::error));
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
@ -272,7 +272,7 @@ void HTMLScriptElement::prepare_script()
|
|||
if (!url.is_valid()) {
|
||||
dbgln("HTMLScriptElement: Refusing to run script because the src URL '{}' is invalid.", url);
|
||||
queue_an_element_task(HTML::Task::Source::Unspecified, [this] {
|
||||
dispatch_event(DOM::Event::create(HTML::EventNames::error));
|
||||
dispatch_event(*DOM::Event::create(document().preferred_window_object(), HTML::EventNames::error));
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
|
40
Userland/Libraries/LibWeb/HTML/MessageEvent.cpp
Normal file
40
Userland/Libraries/LibWeb/HTML/MessageEvent.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/MessageEventPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/HTML/MessageEvent.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
MessageEvent* MessageEvent::create(Bindings::WindowObject& window_object, FlyString const& event_name, MessageEventInit const& event_init)
|
||||
{
|
||||
return window_object.heap().allocate<MessageEvent>(window_object.realm(), window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
MessageEvent* MessageEvent::create_with_global_object(Bindings::WindowObject& window_object, FlyString const& event_name, MessageEventInit const& event_init)
|
||||
{
|
||||
return create(window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
MessageEvent::MessageEvent(Bindings::WindowObject& window_object, FlyString const& event_name, MessageEventInit const& event_init)
|
||||
: DOM::Event(window_object, event_name, event_init)
|
||||
, m_data(event_init.data)
|
||||
, m_origin(event_init.origin)
|
||||
, m_last_event_id(event_init.last_event_id)
|
||||
{
|
||||
set_prototype(&window_object.ensure_web_prototype<Bindings::MessageEventPrototype>("MessageEvent"));
|
||||
}
|
||||
|
||||
MessageEvent::~MessageEvent() = default;
|
||||
|
||||
void MessageEvent::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_data);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Dex♪ <dexes.ttp@gmail.com>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -17,36 +18,32 @@ struct MessageEventInit : public DOM::EventInit {
|
|||
};
|
||||
|
||||
class MessageEvent : public DOM::Event {
|
||||
JS_OBJECT(MessageEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
using WrapperType = Bindings::MessageEventWrapper;
|
||||
static MessageEvent* create(Bindings::WindowObject&, FlyString const& event_name, MessageEventInit const& event_init = {});
|
||||
static MessageEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, MessageEventInit const& event_init);
|
||||
|
||||
static NonnullRefPtr<MessageEvent> create(FlyString const& event_name, MessageEventInit const& event_init = {})
|
||||
{
|
||||
return adopt_ref(*new MessageEvent(event_name, event_init));
|
||||
}
|
||||
static NonnullRefPtr<MessageEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, MessageEventInit const& event_init)
|
||||
{
|
||||
return MessageEvent::create(event_name, event_init);
|
||||
}
|
||||
MessageEvent(Bindings::WindowObject&, FlyString const& event_name, MessageEventInit const& event_init);
|
||||
virtual ~MessageEvent() override;
|
||||
|
||||
virtual ~MessageEvent() override = default;
|
||||
MessageEvent& impl() { return *this; }
|
||||
|
||||
JS::Value data() const { return m_data.value(); }
|
||||
JS::Value data() const { return m_data; }
|
||||
String const& origin() const { return m_origin; }
|
||||
String const& last_event_id() const { return m_last_event_id; }
|
||||
|
||||
protected:
|
||||
MessageEvent(FlyString const& event_name, MessageEventInit const& event_init)
|
||||
: DOM::Event(event_name, event_init)
|
||||
, m_data(JS::make_handle(event_init.data))
|
||||
, m_origin(event_init.origin)
|
||||
, m_last_event_id(event_init.last_event_id)
|
||||
{
|
||||
}
|
||||
private:
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::Handle<JS::Value> m_data;
|
||||
JS::Value m_data;
|
||||
String m_origin;
|
||||
String m_last_event_id;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::HTML::MessageEvent& object) { return &object; }
|
||||
using MessageEventWrapper = Web::HTML::MessageEvent;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#import <DOM/Event.idl>
|
||||
|
||||
[NoInstanceWrapper]
|
||||
interface MessageEvent : Event {
|
||||
constructor(DOMString type, optional MessageEventInit eventInitDict = {});
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ void MessagePort::post_message(JS::Value message)
|
|||
MessageEventInit event_init {};
|
||||
event_init.data = message;
|
||||
event_init.origin = "<origin>";
|
||||
strong_port->dispatch_event(MessageEvent::create(HTML::EventNames::message, event_init));
|
||||
strong_port->dispatch_event(*MessageEvent::create(verify_cast<Bindings::WindowObject>(strong_port->wrapper()->global_object()), HTML::EventNames::message, event_init));
|
||||
}));
|
||||
}
|
||||
|
||||
|
|
32
Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp
Normal file
32
Userland/Libraries/LibWeb/HTML/PageTransitionEvent.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/PageTransitionEventPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/HTML/PageTransitionEvent.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
PageTransitionEvent* PageTransitionEvent::create(Bindings::WindowObject& window_object, FlyString const& event_name, PageTransitionEventInit const& event_init)
|
||||
{
|
||||
return window_object.heap().allocate<PageTransitionEvent>(window_object.realm(), window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
PageTransitionEvent* PageTransitionEvent::create_with_global_object(Bindings::WindowObject& window_object, FlyString const& event_name, PageTransitionEventInit const& event_init)
|
||||
{
|
||||
return create(window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
PageTransitionEvent::PageTransitionEvent(Bindings::WindowObject& window_object, FlyString const& event_name, PageTransitionEventInit const& event_init)
|
||||
: DOM::Event(window_object, event_name, event_init)
|
||||
, m_persisted(event_init.persisted)
|
||||
{
|
||||
set_prototype(&window_object.ensure_web_prototype<Bindings::PageTransitionEventPrototype>("PageTransitionEvent"));
|
||||
}
|
||||
|
||||
PageTransitionEvent::~PageTransitionEvent() = default;
|
||||
|
||||
}
|
|
@ -15,30 +15,27 @@ struct PageTransitionEventInit : public DOM::EventInit {
|
|||
};
|
||||
|
||||
class PageTransitionEvent final : public DOM::Event {
|
||||
JS_OBJECT(PageTransitionEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
using WrapperType = Bindings::PageTransitionEventWrapper;
|
||||
static PageTransitionEvent* create(Bindings::WindowObject&, FlyString const& event_name, PageTransitionEventInit const& event_init);
|
||||
static PageTransitionEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, PageTransitionEventInit const& event_init);
|
||||
|
||||
static NonnullRefPtr<PageTransitionEvent> create(FlyString const& event_name, PageTransitionEventInit const& event_init)
|
||||
{
|
||||
return adopt_ref(*new PageTransitionEvent(event_name, event_init));
|
||||
}
|
||||
static NonnullRefPtr<PageTransitionEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, PageTransitionEventInit const& event_init)
|
||||
{
|
||||
return PageTransitionEvent::create(event_name, event_init);
|
||||
}
|
||||
PageTransitionEvent(Bindings::WindowObject&, FlyString const& event_name, PageTransitionEventInit const& event_init);
|
||||
|
||||
virtual ~PageTransitionEvent() override = default;
|
||||
virtual ~PageTransitionEvent() override;
|
||||
|
||||
PageTransitionEvent& impl() { return *this; }
|
||||
|
||||
bool persisted() const { return m_persisted; }
|
||||
|
||||
protected:
|
||||
PageTransitionEvent(FlyString const& event_name, PageTransitionEventInit const& event_init)
|
||||
: DOM::Event(event_name, event_init)
|
||||
, m_persisted(event_init.persisted)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
bool m_persisted { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::HTML::PageTransitionEvent& object) { return &object; }
|
||||
using PageTransitionEventWrapper = Web::HTML::PageTransitionEvent;
|
||||
}
|
||||
|
|
|
@ -236,9 +236,9 @@ void HTMLParser::the_end()
|
|||
// FIXME: 1. Set the Document's load timing info's DOM content loaded event start time to the current high resolution time given the Document's relevant global object.
|
||||
|
||||
// 2. Fire an event named DOMContentLoaded at the Document object, with its bubbles attribute initialized to true.
|
||||
auto content_loaded_event = DOM::Event::create(HTML::EventNames::DOMContentLoaded);
|
||||
auto content_loaded_event = DOM::Event::create(document->preferred_window_object(), HTML::EventNames::DOMContentLoaded);
|
||||
content_loaded_event->set_bubbles(true);
|
||||
document->dispatch_event(content_loaded_event);
|
||||
document->dispatch_event(*content_loaded_event);
|
||||
|
||||
// FIXME: 3. Set the Document's load timing info's DOM content loaded event end time to the current high resolution time given the Document's relevant global object.
|
||||
|
||||
|
@ -275,7 +275,7 @@ void HTMLParser::the_end()
|
|||
// 5. Fire an event named load at window, with legacy target override flag set.
|
||||
// FIXME: The legacy target override flag is currently set by a virtual override of dispatch_event()
|
||||
// We should reorganize this so that the flag appears explicitly here instead.
|
||||
window->dispatch_event(DOM::Event::create(HTML::EventNames::load));
|
||||
window->dispatch_event(*DOM::Event::create(document->preferred_window_object(), HTML::EventNames::load));
|
||||
|
||||
// FIXME: 6. Invoke WebDriver BiDi load complete with the Document's browsing context, and a new WebDriver BiDi navigation status whose id is the Document object's navigation id, status is "complete", and url is the Document object's URL.
|
||||
|
||||
|
|
40
Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp
Normal file
40
Userland/Libraries/LibWeb/HTML/PromiseRejectionEvent.cpp
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/PromiseRejectionEventPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/HTML/PromiseRejectionEvent.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
PromiseRejectionEvent* PromiseRejectionEvent::create(Bindings::WindowObject& window_object, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
||||
{
|
||||
return window_object.heap().allocate<PromiseRejectionEvent>(window_object.realm(), window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
PromiseRejectionEvent* PromiseRejectionEvent::create_with_global_object(Bindings::WindowObject& window_object, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
||||
{
|
||||
return create(window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
PromiseRejectionEvent::PromiseRejectionEvent(Bindings::WindowObject& window_object, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
||||
: DOM::Event(window_object, event_name, event_init)
|
||||
, m_promise(const_cast<JS::Promise*>(event_init.promise.cell()))
|
||||
, m_reason(event_init.reason)
|
||||
{
|
||||
set_prototype(&window_object.ensure_web_prototype<Bindings::PromiseRejectionEventPrototype>("PromiseRejectionEvent"));
|
||||
}
|
||||
|
||||
PromiseRejectionEvent::~PromiseRejectionEvent() = default;
|
||||
|
||||
void PromiseRejectionEvent::visit_edges(Cell::Visitor& visitor)
|
||||
{
|
||||
Base::visit_edges(visitor);
|
||||
visitor.visit(m_promise);
|
||||
visitor.visit(m_reason);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
/*
|
||||
* Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
@ -17,35 +18,33 @@ struct PromiseRejectionEventInit : public DOM::EventInit {
|
|||
JS::Value reason;
|
||||
};
|
||||
|
||||
class PromiseRejectionEvent : public DOM::Event {
|
||||
class PromiseRejectionEvent final : public DOM::Event {
|
||||
JS_OBJECT(PromiseRejectionEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
using WrapperType = Bindings::PromiseRejectionEventWrapper;
|
||||
static PromiseRejectionEvent* create(Bindings::WindowObject&, FlyString const& event_name, PromiseRejectionEventInit const& event_init = {});
|
||||
static PromiseRejectionEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, PromiseRejectionEventInit const& event_init);
|
||||
|
||||
static NonnullRefPtr<PromiseRejectionEvent> create(FlyString const& event_name, PromiseRejectionEventInit const& event_init = {})
|
||||
{
|
||||
return adopt_ref(*new PromiseRejectionEvent(event_name, event_init));
|
||||
}
|
||||
static NonnullRefPtr<PromiseRejectionEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
||||
{
|
||||
return PromiseRejectionEvent::create(event_name, event_init);
|
||||
}
|
||||
PromiseRejectionEvent(Bindings::WindowObject&, FlyString const& event_name, PromiseRejectionEventInit const& event_init);
|
||||
|
||||
virtual ~PromiseRejectionEvent() override = default;
|
||||
virtual ~PromiseRejectionEvent() override;
|
||||
|
||||
PromiseRejectionEvent& impl() { return *this; }
|
||||
|
||||
// Needs to return a pointer for the generated JS bindings to work.
|
||||
JS::Promise const* promise() const { return m_promise.cell(); }
|
||||
JS::Value reason() const { return m_reason.value(); }
|
||||
JS::Promise const* promise() const { return m_promise; }
|
||||
JS::Value reason() const { return m_reason; }
|
||||
|
||||
protected:
|
||||
PromiseRejectionEvent(FlyString const& event_name, PromiseRejectionEventInit const& event_init)
|
||||
: DOM::Event(event_name, event_init)
|
||||
, m_promise(event_init.promise)
|
||||
, m_reason(JS::make_handle(event_init.reason))
|
||||
{
|
||||
}
|
||||
private:
|
||||
virtual void visit_edges(Cell::Visitor&) override;
|
||||
|
||||
JS::Handle<JS::Promise> m_promise;
|
||||
JS::Handle<JS::Value> m_reason;
|
||||
JS::Promise* m_promise { nullptr };
|
||||
JS::Value m_reason;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
namespace Web::Bindings {
|
||||
inline JS::Object* wrap(JS::Realm&, Web::HTML::PromiseRejectionEvent& object) { return &object; }
|
||||
using PromiseRejectionEventWrapper = Web::HTML::PromiseRejectionEvent;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#import <DOM/Event.idl>
|
||||
|
||||
[Exposed=(Window,Worker)]
|
||||
[Exposed=(Window,Worker), NoInstanceWrapper]
|
||||
interface PromiseRejectionEvent : Event {
|
||||
constructor(DOMString type, PromiseRejectionEventInit eventInitDict);
|
||||
|
||||
|
|
|
@ -217,12 +217,12 @@ void EnvironmentSettingsObject::notify_about_rejected_promises(Badge<EventLoop>)
|
|||
/* .promise = */ promise_handle,
|
||||
/* .reason = */ promise.result(),
|
||||
};
|
||||
auto promise_rejection_event = PromiseRejectionEvent::create(HTML::EventNames::unhandledrejection, event_init);
|
||||
|
||||
// FIXME: This currently assumes that global is a WindowObject.
|
||||
auto& window = verify_cast<Bindings::WindowObject>(*global.cell());
|
||||
|
||||
bool not_handled = window.impl().dispatch_event(move(promise_rejection_event));
|
||||
auto promise_rejection_event = PromiseRejectionEvent::create(window, HTML::EventNames::unhandledrejection, event_init);
|
||||
|
||||
bool not_handled = window.impl().dispatch_event(*promise_rejection_event);
|
||||
|
||||
// 3. If notHandled is false, then the promise rejection is handled. Otherwise, the promise rejection is not handled.
|
||||
|
||||
|
|
32
Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp
Normal file
32
Userland/Libraries/LibWeb/HTML/SubmitEvent.cpp
Normal file
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibWeb/Bindings/SubmitEventPrototype.h>
|
||||
#include <LibWeb/Bindings/WindowObject.h>
|
||||
#include <LibWeb/HTML/SubmitEvent.h>
|
||||
|
||||
namespace Web::HTML {
|
||||
|
||||
SubmitEvent* SubmitEvent::create(Bindings::WindowObject& window_object, FlyString const& event_name, SubmitEventInit const& event_init)
|
||||
{
|
||||
return window_object.heap().allocate<SubmitEvent>(window_object.realm(), window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
SubmitEvent* SubmitEvent::create_with_global_object(Bindings::WindowObject& window_object, FlyString const& event_name, SubmitEventInit const& event_init)
|
||||
{
|
||||
return create(window_object, event_name, event_init);
|
||||
}
|
||||
|
||||
SubmitEvent::SubmitEvent(Bindings::WindowObject& window_object, FlyString const& event_name, SubmitEventInit const& event_init)
|
||||
: DOM::Event(window_object, event_name, event_init)
|
||||
, m_submitter(event_init.submitter)
|
||||
{
|
||||
set_prototype(&window_object.ensure_web_prototype<Bindings::SubmitEventPrototype>("SubmitEvent"));
|
||||
}
|
||||
|
||||
SubmitEvent::~SubmitEvent() = default;
|
||||
|
||||
}
|
|
@ -17,29 +17,21 @@ struct SubmitEventInit : public DOM::EventInit {
|
|||
};
|
||||
|
||||
class SubmitEvent final : public DOM::Event {
|
||||
JS_OBJECT(SubmitEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
using WrapperType = Bindings::SubmitEventWrapper;
|
||||
static SubmitEvent* create(Bindings::WindowObject&, FlyString const& event_name, SubmitEventInit const& event_init);
|
||||
static SubmitEvent* create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, SubmitEventInit const& event_init);
|
||||
|
||||
static NonnullRefPtr<SubmitEvent> create(FlyString const& event_name, SubmitEventInit const& event_init)
|
||||
{
|
||||
return adopt_ref(*new SubmitEvent(event_name, event_init));
|
||||
}
|
||||
static NonnullRefPtr<SubmitEvent> create_with_global_object(Bindings::WindowObject&, FlyString const& event_name, SubmitEventInit const& event_init)
|
||||
{
|
||||
return SubmitEvent::create(event_name, event_init);
|
||||
}
|
||||
virtual ~SubmitEvent() override;
|
||||
|
||||
virtual ~SubmitEvent() override = default;
|
||||
SubmitEvent(Bindings::WindowObject&, FlyString const& event_name, SubmitEventInit const& event_init);
|
||||
|
||||
SubmitEvent& impl() { return *this; }
|
||||
|
||||
RefPtr<HTMLElement> submitter() const { return m_submitter; }
|
||||
|
||||
private:
|
||||
SubmitEvent(FlyString const& event_name, SubmitEventInit const& event_init)
|
||||
: DOM::Event(event_name, event_init)
|
||||
, m_submitter(event_init.submitter)
|
||||
{
|
||||
}
|
||||
|
||||
RefPtr<HTMLElement> m_submitter;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#import <DOM/Event.idl>
|
||||
#import <HTML/HTMLElement.idl>
|
||||
|
||||
[NoInstanceWrapper]
|
||||
interface SubmitEvent : Event {
|
||||
constructor(DOMString type, optional SubmitEventInit eventInitDict = {});
|
||||
|
||||
|
|
|
@ -279,7 +279,7 @@ void Window::did_call_location_replace(Badge<Bindings::LocationObject>, String u
|
|||
browsing_context->loader().load(move(new_url), FrameLoader::Type::Navigation);
|
||||
}
|
||||
|
||||
bool Window::dispatch_event(NonnullRefPtr<DOM::Event> event)
|
||||
bool Window::dispatch_event(DOM::Event& event)
|
||||
{
|
||||
return DOM::EventDispatcher::dispatch(*this, event, true);
|
||||
}
|
||||
|
@ -458,7 +458,7 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers
|
|||
// with the persisted attribute initialized to persisted,
|
||||
HTML::PageTransitionEventInit event_init {};
|
||||
event_init.persisted = persisted;
|
||||
auto event = HTML::PageTransitionEvent::create(event_name, event_init);
|
||||
auto event = HTML::PageTransitionEvent::create(associated_document().preferred_window_object(), event_name, event_init);
|
||||
|
||||
// ...the cancelable attribute initialized to true,
|
||||
event->set_cancelable(true);
|
||||
|
@ -467,7 +467,7 @@ void Window::fire_a_page_transition_event(FlyString const& event_name, bool pers
|
|||
event->set_bubbles(true);
|
||||
|
||||
// and legacy target override flag set.
|
||||
dispatch_event(move(event));
|
||||
dispatch_event(*event);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/#dom-queuemicrotask
|
||||
|
@ -567,7 +567,9 @@ DOM::ExceptionOr<void> Window::post_message(JS::Value message, String const&)
|
|||
HTML::MessageEventInit event_init {};
|
||||
event_init.data = message;
|
||||
event_init.origin = "<origin>";
|
||||
strong_this->dispatch_event(HTML::MessageEvent::create(HTML::EventNames::message, event_init));
|
||||
auto* wrapper = static_cast<Bindings::WindowObject*>(strong_this->wrapper());
|
||||
VERIFY(wrapper);
|
||||
strong_this->dispatch_event(*HTML::MessageEvent::create(*wrapper, HTML::EventNames::message, event_init));
|
||||
});
|
||||
return {};
|
||||
}
|
||||
|
@ -688,4 +690,9 @@ void Window::set_associated_document(DOM::Document& document)
|
|||
m_associated_document = document;
|
||||
}
|
||||
|
||||
void Window::set_current_event(DOM::Event* event)
|
||||
{
|
||||
m_current_event = JS::make_handle(event);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -43,7 +43,7 @@ public:
|
|||
|
||||
virtual void ref_event_target() override { RefCounted::ref(); }
|
||||
virtual void unref_event_target() override { RefCounted::unref(); }
|
||||
virtual bool dispatch_event(NonnullRefPtr<DOM::Event>) override;
|
||||
virtual bool dispatch_event(DOM::Event&) override;
|
||||
virtual JS::Object* create_wrapper(JS::Realm&) override;
|
||||
|
||||
Page* page();
|
||||
|
@ -92,8 +92,9 @@ public:
|
|||
|
||||
CSS::Screen& screen() { return *m_screen; }
|
||||
|
||||
DOM::Event const* current_event() const { return m_current_event; }
|
||||
void set_current_event(DOM::Event* event) { m_current_event = event; }
|
||||
DOM::Event* current_event() { return m_current_event.cell(); }
|
||||
DOM::Event const* current_event() const { return m_current_event.cell(); }
|
||||
void set_current_event(DOM::Event* event);
|
||||
|
||||
CSS::CSSStyleDeclaration* get_computed_style(DOM::Element&) const;
|
||||
NonnullRefPtr<CSS::MediaQueryList> match_media(String);
|
||||
|
@ -157,7 +158,7 @@ private:
|
|||
NonnullOwnPtr<HighResolutionTime::Performance> m_performance;
|
||||
NonnullRefPtr<Crypto::Crypto> m_crypto;
|
||||
NonnullOwnPtr<CSS::Screen> m_screen;
|
||||
RefPtr<DOM::Event> m_current_event;
|
||||
JS::Handle<DOM::Event> m_current_event;
|
||||
|
||||
AnimationFrameCallbackDriver m_animation_frame_callback_driver;
|
||||
|
||||
|
|
|
@ -148,7 +148,8 @@ void Worker::run_a_worker(AK::URL& url, EnvironmentSettingsObject& outside_setti
|
|||
MessageEventInit event_init {};
|
||||
event_init.data = message;
|
||||
event_init.origin = "<origin>";
|
||||
dispatch_event(MessageEvent::create(HTML::EventNames::message, event_init));
|
||||
// FIXME: The cast here is totally bogus, since workers don't have a WindowObject..
|
||||
dispatch_event(*MessageEvent::create(verify_cast<Bindings::WindowObject>(*m_worker_scope), HTML::EventNames::message, event_init));
|
||||
}));
|
||||
|
||||
return JS::js_undefined();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue