mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 20:07:36 +00:00
LibWeb: Make factory methods of UIEvents::WheelEvent fallible
This commit is contained in:
parent
587cf355ed
commit
e57461b89e
3 changed files with 7 additions and 6 deletions
|
@ -185,7 +185,7 @@ bool EventHandler::handle_mousewheel(CSSPixelPoint position, unsigned button, un
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
auto offset = compute_mouse_event_offset(position, *layout_node);
|
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()) {
|
if (auto* page = m_browsing_context.page()) {
|
||||||
page->client().page_did_request_scroll(wheel_delta_x * 20, wheel_delta_y * 20);
|
page->client().page_did_request_scroll(wheel_delta_x * 20, wheel_delta_y * 20);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
#include <LibWeb/HTML/EventNames.h>
|
#include <LibWeb/HTML/EventNames.h>
|
||||||
#include <LibWeb/UIEvents/EventNames.h>
|
#include <LibWeb/UIEvents/EventNames.h>
|
||||||
#include <LibWeb/UIEvents/WheelEvent.h>
|
#include <LibWeb/UIEvents/WheelEvent.h>
|
||||||
|
#include <LibWeb/WebIDL/ExceptionOr.h>
|
||||||
|
|
||||||
namespace Web::UIEvents {
|
namespace Web::UIEvents {
|
||||||
|
|
||||||
|
@ -30,12 +31,12 @@ JS::ThrowCompletionOr<void> WheelEvent::initialize(JS::Realm& realm)
|
||||||
return {};
|
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 {};
|
WheelEventInit event_init {};
|
||||||
event_init.offset_x = static_cast<double>(offset_x.value());
|
event_init.offset_x = static_cast<double>(offset_x.value());
|
||||||
|
|
|
@ -29,8 +29,8 @@ class WheelEvent final : public MouseEvent {
|
||||||
WEB_PLATFORM_OBJECT(WheelEvent, MouseEvent);
|
WEB_PLATFORM_OBJECT(WheelEvent, MouseEvent);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
static WheelEvent* create(JS::Realm&, DeprecatedFlyString const& event_name, WheelEventInit const& event_init = {});
|
static WebIDL::ExceptionOr<JS::NonnullGCPtr<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_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;
|
virtual ~WheelEvent() override;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue