mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2026-04-19 02:10:26 +00:00
When constructing MouseEvent, PointerEvent, DragEvent, or WheelEvent from JavaScript, pageX/pageY and offsetX/offsetY were left at 0 instead of being initialized from clientX/clientY. Per the CSSOM View spec, pageX should be clientX + scrollX (which is 0 for a newly constructed event with no associated window), and offsetX should be clientX minus the target's bounding rect origin (which is 0 for an event with no target). So both should default to clientX.
45 lines
1.4 KiB
C++
45 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2024, Maciej <sppmacd@pm.me>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/Bindings/DragEventPrototype.h>
|
|
#include <LibWeb/Bindings/Intrinsics.h>
|
|
#include <LibWeb/HTML/DragEvent.h>
|
|
|
|
namespace Web::HTML {
|
|
|
|
GC_DEFINE_ALLOCATOR(DragEvent);
|
|
|
|
GC::Ref<DragEvent> DragEvent::create(JS::Realm& realm, FlyString const& event_name, DragEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y)
|
|
{
|
|
return realm.create<DragEvent>(realm, event_name, event_init, page_x, page_y, offset_x, offset_y);
|
|
}
|
|
|
|
WebIDL::ExceptionOr<GC::Ref<DragEvent>> DragEvent::construct_impl(JS::Realm& realm, FlyString const& event_name, DragEventInit const& event_init)
|
|
{
|
|
return create(realm, event_name, event_init, event_init.client_x, event_init.client_y, event_init.client_x, event_init.client_y);
|
|
}
|
|
|
|
DragEvent::DragEvent(JS::Realm& realm, FlyString const& event_name, DragEventInit const& event_init, double page_x, double page_y, double offset_x, double offset_y)
|
|
: MouseEvent(realm, event_name, event_init, page_x, page_y, offset_x, offset_y)
|
|
, m_data_transfer(event_init.data_transfer)
|
|
{
|
|
}
|
|
|
|
DragEvent::~DragEvent() = default;
|
|
|
|
void DragEvent::initialize(JS::Realm& realm)
|
|
{
|
|
WEB_SET_PROTOTYPE_FOR_INTERFACE(DragEvent);
|
|
Base::initialize(realm);
|
|
}
|
|
|
|
void DragEvent::visit_edges(JS::Cell::Visitor& visitor)
|
|
{
|
|
Base::visit_edges(visitor);
|
|
visitor.visit(m_data_transfer);
|
|
}
|
|
|
|
}
|