mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-20 01:37:39 +03:00
LibWeb: Make factory methods of UIEvents::UIEvent fallible
This affects calls to FocusEvent::create() since FocusEvent does not implement its own create() method.
This commit is contained in:
parent
a401cff4e2
commit
587cf355ed
Notes:
sideshowbarker
2024-07-17 07:38:17 +09:00
Author: https://github.com/kennethmyhra Commit: https://github.com/SerenityOS/serenity/commit/587cf355ed Pull-request: https://github.com/SerenityOS/serenity/pull/17542
@ -1290,7 +1290,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(DeprecatedSt
|
||||
|| Infra::is_ascii_case_insensitive_match(interface, "events"sv)) {
|
||||
event = TRY(Event::create(realm, ""));
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "focusevent"sv)) {
|
||||
event = UIEvents::FocusEvent::create(realm, "");
|
||||
event = TRY(UIEvents::FocusEvent::create(realm, ""));
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "hashchangeevent"sv)) {
|
||||
event = TRY(Event::create(realm, "")); // FIXME: Create HashChangeEvent
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "htmlevents"sv)) {
|
||||
@ -1312,7 +1312,7 @@ WebIDL::ExceptionOr<JS::NonnullGCPtr<Event>> Document::create_event(DeprecatedSt
|
||||
event = TRY(Event::create(realm, "")); // FIXME: Create TouchEvent
|
||||
} else if (Infra::is_ascii_case_insensitive_match(interface, "uievent"sv)
|
||||
|| Infra::is_ascii_case_insensitive_match(interface, "uievents"sv)) {
|
||||
event = UIEvents::UIEvent::create(realm, "");
|
||||
event = TRY(UIEvents::UIEvent::create(realm, ""));
|
||||
}
|
||||
|
||||
// 3. If constructor is null, then throw a "NotSupportedError" DOMException.
|
||||
|
@ -65,9 +65,9 @@ static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vect
|
||||
// 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(blur_event_target->realm(), HTML::EventNames::blur);
|
||||
auto blur_event = UIEvents::FocusEvent::create(blur_event_target->realm(), HTML::EventNames::blur).release_value_but_fixme_should_propagate_errors();
|
||||
blur_event->set_related_target(related_blur_target);
|
||||
blur_event_target->dispatch_event(*blur_event);
|
||||
blur_event_target->dispatch_event(blur_event);
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,9 +108,9 @@ static void run_focus_update_steps(Vector<JS::Handle<DOM::Node>> old_chain, Vect
|
||||
// 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(focus_event_target->realm(), HTML::EventNames::focus);
|
||||
auto focus_event = UIEvents::FocusEvent::create(focus_event_target->realm(), HTML::EventNames::focus).release_value_but_fixme_should_propagate_errors();
|
||||
focus_event->set_related_target(related_focus_target);
|
||||
focus_event_target->dispatch_event(*focus_event);
|
||||
focus_event_target->dispatch_event(focus_event);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,14 +9,14 @@
|
||||
|
||||
namespace Web::UIEvents {
|
||||
|
||||
UIEvent* UIEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name)
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> UIEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name)
|
||||
{
|
||||
return realm.heap().allocate<UIEvent>(realm, realm, event_name).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<UIEvent>(realm, realm, event_name));
|
||||
}
|
||||
|
||||
UIEvent* UIEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, UIEventInit const& event_init)
|
||||
WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> UIEvent::construct_impl(JS::Realm& realm, DeprecatedFlyString const& event_name, UIEventInit const& event_init)
|
||||
{
|
||||
return realm.heap().allocate<UIEvent>(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors();
|
||||
return MUST_OR_THROW_OOM(realm.heap().allocate<UIEvent>(realm, realm, event_name, event_init));
|
||||
}
|
||||
|
||||
UIEvent::UIEvent(JS::Realm& realm, DeprecatedFlyString const& event_name)
|
||||
|
@ -21,8 +21,8 @@ class UIEvent : public DOM::Event {
|
||||
WEB_PLATFORM_OBJECT(UIEvent, DOM::Event);
|
||||
|
||||
public:
|
||||
static UIEvent* create(JS::Realm&, DeprecatedFlyString const& type);
|
||||
static UIEvent* construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, UIEventInit const& event_init);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> create(JS::Realm&, DeprecatedFlyString const& type);
|
||||
static WebIDL::ExceptionOr<JS::NonnullGCPtr<UIEvent>> construct_impl(JS::Realm&, DeprecatedFlyString const& event_name, UIEventInit const& event_init);
|
||||
|
||||
virtual ~UIEvent() override;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user