1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 17:17:45 +00:00

LibJS+Everywhere: Allow Cell::initialize overrides to throw OOM errors

Note that as of this commit, there aren't any such throwers, and the
call site in Heap::allocate will drop exceptions on the floor. This
commit only serves to change the declaration of the overrides, make sure
they return an empty value, and to propagate OOM errors frm their base
initialize invocations.
This commit is contained in:
Timothy Flynn 2023-01-28 12:33:35 -05:00 committed by Linus Groh
parent 1c1b902a6a
commit 2692db8699
694 changed files with 1774 additions and 1065 deletions

View file

@ -22,10 +22,12 @@ FocusEvent::FocusEvent(JS::Realm& realm, DeprecatedFlyString const& event_name,
FocusEvent::~FocusEvent() = default;
void FocusEvent::initialize(JS::Realm& realm)
JS::ThrowCompletionOr<void> FocusEvent::initialize(JS::Realm& realm)
{
Base::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
set_prototype(&Bindings::ensure_web_prototype<Bindings::FocusEventPrototype>(realm, "FocusEvent"));
return {};
}
}

View file

@ -25,7 +25,7 @@ public:
private:
FocusEvent(JS::Realm&, DeprecatedFlyString const& event_name, FocusEventInit const&);
virtual void initialize(JS::Realm&) override;
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
};
}

View file

@ -132,10 +132,12 @@ KeyboardEvent::KeyboardEvent(JS::Realm& realm, DeprecatedFlyString const& event_
KeyboardEvent::~KeyboardEvent() = default;
void KeyboardEvent::initialize(JS::Realm& realm)
JS::ThrowCompletionOr<void> KeyboardEvent::initialize(JS::Realm& realm)
{
Base::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
set_prototype(&Bindings::ensure_web_prototype<Bindings::KeyboardEventPrototype>(realm, "KeyboardEvent"));
return {};
}
}

View file

@ -56,7 +56,7 @@ public:
private:
KeyboardEvent(JS::Realm&, DeprecatedFlyString const& event_name, KeyboardEventInit const& event_init);
virtual void initialize(JS::Realm&) override;
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
DeprecatedString m_key;
DeprecatedString m_code;

View file

@ -29,10 +29,12 @@ MouseEvent::MouseEvent(JS::Realm& realm, DeprecatedFlyString const& event_name,
MouseEvent::~MouseEvent() = default;
void MouseEvent::initialize(JS::Realm& realm)
JS::ThrowCompletionOr<void> MouseEvent::initialize(JS::Realm& realm)
{
Base::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
set_prototype(&Bindings::ensure_web_prototype<Bindings::MouseEventPrototype>(realm, "MouseEvent"));
return {};
}
// https://www.w3.org/TR/uievents/#dom-mouseevent-button

View file

@ -58,7 +58,7 @@ public:
protected:
MouseEvent(JS::Realm&, DeprecatedFlyString const& event_name, MouseEventInit const& event_init);
virtual void initialize(JS::Realm&) override;
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
private:
void set_event_characteristics();

View file

@ -33,10 +33,12 @@ UIEvent::UIEvent(JS::Realm& realm, DeprecatedFlyString const& event_name, UIEven
UIEvent::~UIEvent() = default;
void UIEvent::initialize(JS::Realm& realm)
JS::ThrowCompletionOr<void> UIEvent::initialize(JS::Realm& realm)
{
Base::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
set_prototype(&Bindings::ensure_web_prototype<Bindings::UIEventPrototype>(realm, "UIEvent"));
return {};
}
void UIEvent::visit_edges(Cell::Visitor& visitor)

View file

@ -41,7 +41,7 @@ protected:
UIEvent(JS::Realm&, DeprecatedFlyString const& event_name);
UIEvent(JS::Realm&, DeprecatedFlyString const& event_name, UIEventInit const& event_init);
virtual void initialize(JS::Realm&) override;
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
virtual void visit_edges(Cell::Visitor&) override;
JS::GCPtr<HTML::Window> m_view;

View file

@ -22,10 +22,12 @@ WheelEvent::WheelEvent(JS::Realm& realm, DeprecatedFlyString const& event_name,
WheelEvent::~WheelEvent() = default;
void WheelEvent::initialize(JS::Realm& realm)
JS::ThrowCompletionOr<void> WheelEvent::initialize(JS::Realm& realm)
{
Base::initialize(realm);
MUST_OR_THROW_OOM(Base::initialize(realm));
set_prototype(&Bindings::ensure_web_prototype<Bindings::WheelEventPrototype>(realm, "WheelEvent"));
return {};
}
WheelEvent* WheelEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, WheelEventInit const& event_init)

View file

@ -42,7 +42,7 @@ public:
private:
WheelEvent(JS::Realm&, DeprecatedFlyString const& event_name, WheelEventInit const& event_init);
virtual void initialize(JS::Realm&) override;
virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
void set_event_characteristics();