mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 08:47:34 +00:00
LibWeb: Port CustomEvent to new String
This commit is contained in:
parent
44cf92616e
commit
59a21c6274
4 changed files with 13 additions and 12 deletions
|
@ -11,18 +11,18 @@
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::DOM {
|
||||||
|
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> CustomEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, CustomEventInit const& event_init)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> CustomEvent::create(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init)
|
||||||
{
|
{
|
||||||
return MUST_OR_THROW_OOM(realm.heap().allocate<CustomEvent>(realm, realm, event_name, event_init));
|
return MUST_OR_THROW_OOM(realm.heap().allocate<CustomEvent>(realm, realm, event_name, event_init));
|
||||||
}
|
}
|
||||||
|
|
||||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> CustomEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, CustomEventInit const& event_init)
|
WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> CustomEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init)
|
||||||
{
|
{
|
||||||
return create(realm, event_name, event_init);
|
return create(realm, event_name, event_init);
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomEvent::CustomEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, CustomEventInit const& event_init)
|
CustomEvent::CustomEvent(JS::Realm& realm, FlyString const& event_name, CustomEventInit const& event_init)
|
||||||
: Event(realm, event_name, event_init)
|
: Event(realm, event_name.to_deprecated_fly_string(), event_init)
|
||||||
, m_detail(event_init.detail)
|
, m_detail(event_init.detail)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -44,14 +44,14 @@ void CustomEvent::visit_edges(JS::Cell::Visitor& visitor)
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-customevent-initcustomevent
|
// https://dom.spec.whatwg.org/#dom-customevent-initcustomevent
|
||||||
void CustomEvent::init_custom_event(DeprecatedString const& type, bool bubbles, bool cancelable, JS::Value detail)
|
void CustomEvent::init_custom_event(String const& type, bool bubbles, bool cancelable, JS::Value detail)
|
||||||
{
|
{
|
||||||
// 1. If this’s dispatch flag is set, then return.
|
// 1. If this’s dispatch flag is set, then return.
|
||||||
if (dispatched())
|
if (dispatched())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// 2. Initialize this with type, bubbles, and cancelable.
|
// 2. Initialize this with type, bubbles, and cancelable.
|
||||||
initialize_event(type, bubbles, cancelable);
|
initialize_event(type.to_deprecated_string(), bubbles, cancelable);
|
||||||
|
|
||||||
// 3. Set this’s detail attribute to detail.
|
// 3. Set this’s detail attribute to detail.
|
||||||
m_detail = detail;
|
m_detail = detail;
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <AK/FlyString.h>
|
||||||
#include <LibWeb/DOM/Event.h>
|
#include <LibWeb/DOM/Event.h>
|
||||||
|
|
||||||
namespace Web::DOM {
|
namespace Web::DOM {
|
||||||
|
@ -20,8 +21,8 @@ class CustomEvent : public Event {
|
||||||
WEB_PLATFORM_OBJECT(CustomEvent, Event);
|
WEB_PLATFORM_OBJECT(CustomEvent, Event);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> create(JS::Realm&, DeprecatedFlyString const& event_name, CustomEventInit const& event_init = {});
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> create(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init = {});
|
||||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, CustomEventInit const& event_init);
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<CustomEvent>> construct_impl(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init);
|
||||||
|
|
||||||
virtual ~CustomEvent() override;
|
virtual ~CustomEvent() override;
|
||||||
|
|
||||||
|
@ -31,10 +32,10 @@ public:
|
||||||
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
|
||||||
virtual void visit_edges(JS::Cell::Visitor&) override;
|
virtual void visit_edges(JS::Cell::Visitor&) override;
|
||||||
|
|
||||||
void init_custom_event(DeprecatedString const& type, bool bubbles, bool cancelable, JS::Value detail);
|
void init_custom_event(String const& type, bool bubbles, bool cancelable, JS::Value detail);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CustomEvent(JS::Realm&, DeprecatedFlyString const& event_name, CustomEventInit const& event_init);
|
CustomEvent(JS::Realm&, FlyString const& event_name, CustomEventInit const& event_init);
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-customevent-initcustomevent-type-bubbles-cancelable-detail-detail
|
// https://dom.spec.whatwg.org/#dom-customevent-initcustomevent-type-bubbles-cancelable-detail-detail
|
||||||
JS::Value m_detail { JS::js_null() };
|
JS::Value m_detail { JS::js_null() };
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#import <DOM/Event.idl>
|
#import <DOM/Event.idl>
|
||||||
|
|
||||||
[Exposed=(Window,Worker)]
|
[Exposed=(Window,Worker), UseNewAKString]
|
||||||
interface CustomEvent : Event {
|
interface CustomEvent : Event {
|
||||||
constructor(DOMString type, optional CustomEventInit eventInitDict = {});
|
constructor(DOMString type, optional CustomEventInit eventInitDict = {});
|
||||||
|
|
||||||
|
|
|
@ -1296,7 +1296,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(DeprecatedSt
|
||||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "compositionevent"sv)) {
|
} else if (Infra::is_ascii_case_insensitive_match(interface, "compositionevent"sv)) {
|
||||||
event = TRY(Event::create(realm, "")); // FIXME: Create CompositionEvent
|
event = TRY(Event::create(realm, "")); // FIXME: Create CompositionEvent
|
||||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "customevent"sv)) {
|
} else if (Infra::is_ascii_case_insensitive_match(interface, "customevent"sv)) {
|
||||||
event = TRY(CustomEvent::create(realm, ""));
|
event = TRY(CustomEvent::create(realm, FlyString {}));
|
||||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "devicemotionevent"sv)) {
|
} else if (Infra::is_ascii_case_insensitive_match(interface, "devicemotionevent"sv)) {
|
||||||
event = TRY(Event::create(realm, "")); // FIXME: Create DeviceMotionEvent
|
event = TRY(Event::create(realm, "")); // FIXME: Create DeviceMotionEvent
|
||||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "deviceorientationevent"sv)) {
|
} else if (Infra::is_ascii_case_insensitive_match(interface, "deviceorientationevent"sv)) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue