LibWeb: Make factory methods of UIEvents::WheelEvent fallible

This commit is contained in:
Kenneth Myhra 2023-02-19 10:48:02 +01:00 committed by Andreas Kling
parent 587cf355ed
commit e57461b89e
Notes: sideshowbarker 2024-07-17 08:38:37 +09:00
3 changed files with 7 additions and 6 deletions

View File

@ -185,7 +185,7 @@ bool EventHandler::handle_mousewheel(CSSPixelPoint position, unsigned button, un
return false;
auto offset = compute_mouse_event_offset(position, *layout_node);
if (node->dispatch_event(*UIEvents::WheelEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::wheel, offset.x(), offset.y(), position.x(), position.y(), wheel_delta_x, wheel_delta_y, buttons, button))) {
if (node->dispatch_event(UIEvents::WheelEvent::create_from_platform_event(node->realm(), UIEvents::EventNames::wheel, offset.x(), offset.y(), position.x(), position.y(), wheel_delta_x, wheel_delta_y, buttons, button).release_value_but_fixme_should_propagate_errors())) {
if (auto* page = m_browsing_context.page()) {
page->client().page_did_request_scroll(wheel_delta_x * 20, wheel_delta_y * 20);
}

View File

@ -8,6 +8,7 @@
#include <LibWeb/HTML/EventNames.h>
#include <LibWeb/UIEvents/EventNames.h>
#include <LibWeb/UIEvents/WheelEvent.h>
#include <LibWeb/WebIDL/ExceptionOr.h>
namespace Web::UIEvents {
@ -30,12 +31,12 @@ JS::ThrowCompletionOr<void> WheelEvent::initialize(JS::Realm& realm)
return {};
}
WheelEvent* WheelEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, WheelEventInit const& event_init)
WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> WheelEvent::create(JS::Realm& realm, DeprecatedFlyString const& event_name, WheelEventInit const& event_init)
{
return realm.heap().allocate<WheelEvent>(realm, realm, event_name, event_init).release_allocated_value_but_fixme_should_propagate_errors();
return MUST_OR_THROW_OOM(realm.heap().allocate<WheelEvent>(realm, realm, event_name, event_init));
}
WheelEvent* WheelEvent::create_from_platform_event(JS::Realm& realm, DeprecatedFlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, double delta_x, double delta_y, unsigned buttons, unsigned button)
WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> WheelEvent::create_from_platform_event(JS::Realm& realm, DeprecatedFlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, double delta_x, double delta_y, unsigned buttons, unsigned button)
{
WheelEventInit event_init {};
event_init.offset_x = static_cast<double>(offset_x.value());

View File

@ -29,8 +29,8 @@ class WheelEvent final : public MouseEvent {
WEB_PLATFORM_OBJECT(WheelEvent, MouseEvent);
public:
static WheelEvent* create(JS::Realm&, DeprecatedFlyString const& event_name, WheelEventInit const& event_init = {});
static WheelEvent* create_from_platform_event(JS::Realm&, DeprecatedFlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, double delta_x, double delta_y, unsigned buttons, unsigned button);
static WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> create(JS::Realm&, DeprecatedFlyString const& event_name, WheelEventInit const& event_init = {});
static WebIDL::ExceptionOr<JS::NonnullGCPtr<WheelEvent>> create_from_platform_event(JS::Realm&, DeprecatedFlyString const& event_name, CSSPixels offset_x, CSSPixels offset_y, CSSPixels client_x, CSSPixels client_y, double delta_x, double delta_y, unsigned buttons, unsigned button);
virtual ~WheelEvent() override;