1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-25 18:55:08 +00:00

LibWeb: Port ErrorEvent to new String

This commit is contained in:
Kenneth Myhra 2023-03-05 10:17:53 +01:00 committed by Linus Groh
parent e661f03ffa
commit 84997ab0ee
3 changed files with 15 additions and 14 deletions

View file

@ -9,18 +9,18 @@
namespace Web::HTML { namespace Web::HTML {
WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> ErrorEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, ErrorEventInit const& event_init) WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> ErrorEvent::create(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
{ {
return MUST_OR_THROW_OOM(realm.heap().allocate<ErrorEvent>(realm, realm, event_name, event_init)); return MUST_OR_THROW_OOM(realm.heap().allocate<ErrorEvent>(realm, realm, event_name, event_init));
} }
WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> ErrorEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, ErrorEventInit const& event_init) WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> ErrorEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
{ {
return create(realm, event_name, event_init); return create(realm, event_name, event_init);
} }
ErrorEvent::ErrorEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, ErrorEventInit const& event_init) ErrorEvent::ErrorEvent(JS::Realm& realm, FlyString const& event_name, ErrorEventInit const& event_init)
: DOM::Event(realm, event_name) : DOM::Event(realm, event_name.to_deprecated_fly_string())
, m_message(event_init.message) , m_message(event_init.message)
, m_filename(event_init.filename) , m_filename(event_init.filename)
, m_lineno(event_init.lineno) , m_lineno(event_init.lineno)

View file

@ -6,14 +6,15 @@
#pragma once #pragma once
#include <AK/FlyString.h>
#include <LibWeb/DOM/Event.h> #include <LibWeb/DOM/Event.h>
namespace Web::HTML { namespace Web::HTML {
// https://html.spec.whatwg.org/multipage/webappapis.html#erroreventinit // https://html.spec.whatwg.org/multipage/webappapis.html#erroreventinit
struct ErrorEventInit : public DOM::EventInit { struct ErrorEventInit : public DOM::EventInit {
DeprecatedString message { "" }; String message;
DeprecatedString filename { "" }; // FIXME: This should be a USVString. String filename; // FIXME: This should be a USVString.
u32 lineno { 0 }; u32 lineno { 0 };
u32 colno { 0 }; u32 colno { 0 };
JS::Value error { JS::js_null() }; JS::Value error { JS::js_null() };
@ -24,16 +25,16 @@ class ErrorEvent final : public DOM::Event {
WEB_PLATFORM_OBJECT(ErrorEvent, DOM::Event); WEB_PLATFORM_OBJECT(ErrorEvent, DOM::Event);
public: public:
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> create(JS::Realm&, DeprecatedFlyString const& event_name, ErrorEventInit const& event_init = {}); static WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> create(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, ErrorEventInit const& event_init); static WebIDL::ExceptionOr<JS::NonnullGCPtr<ErrorEvent>> construct_impl(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init);
virtual ~ErrorEvent() override; virtual ~ErrorEvent() override;
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-message // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-message
DeprecatedString const& message() const { return m_message; } String const& message() const { return m_message; }
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-filename // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-filename
DeprecatedString const& filename() const { return m_filename; } String const& filename() const { return m_filename; }
// https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-lineno // https://html.spec.whatwg.org/multipage/webappapis.html#dom-errorevent-lineno
u32 lineno() const { return m_lineno; } u32 lineno() const { return m_lineno; }
@ -45,13 +46,13 @@ public:
JS::Value error() const { return m_error; } JS::Value error() const { return m_error; }
private: private:
ErrorEvent(JS::Realm&, DeprecatedFlyString const& event_name, ErrorEventInit const& event_init); ErrorEvent(JS::Realm&, FlyString const& event_name, ErrorEventInit const& event_init);
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override; virtual void visit_edges(Cell::Visitor&) override;
DeprecatedString m_message { "" }; String m_message;
DeprecatedString m_filename { "" }; // FIXME: This should be a USVString. String m_filename; // FIXME: This should be a USVString.
u32 m_lineno { 0 }; u32 m_lineno { 0 };
u32 m_colno { 0 }; u32 m_colno { 0 };
JS::Value m_error; JS::Value m_error;

View file

@ -1,6 +1,6 @@
#import <DOM/Event.idl> #import <DOM/Event.idl>
[Exposed=(Window,Worker)] [Exposed=(Window,Worker), UseNewAKString]
interface ErrorEvent : Event { interface ErrorEvent : Event {
constructor(DOMString type, optional ErrorEventInit eventInitDict = {}); constructor(DOMString type, optional ErrorEventInit eventInitDict = {});