mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-07-28 11:49:44 +00:00
LibWeb: Begin implementing the drag-and-drop processing model
The drag-and-drop processing model allows for users to drag around either elements within the DOM or objects completely outside the DOM. This drag event can either end without action (via cancellation or user input), or in a drop event, where the dragged object is dropped onto another element within the DOM. The processing model is rather large. This implements enough of it to allow the UI process to specifically handle dragging objects outside of the DOM onto the DOM. For example, dragging an image from the OS file manager onto a file-upload input element. This does not implement the ability to drag DOM elements.
This commit is contained in:
parent
3674e037f3
commit
e8a1b89447
Notes:
github-actions[bot]
2024-08-19 11:30:44 +00:00
Author: https://github.com/trflynn89
Commit: e8a1b89447
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1111
15 changed files with 944 additions and 0 deletions
|
@ -14,6 +14,7 @@
|
|||
#include <LibWeb/HTML/HTMLElement.h>
|
||||
#include <LibWeb/HTML/Window.h>
|
||||
#include <LibWeb/Internals/Internals.h>
|
||||
#include <LibWeb/Page/InputEvent.h>
|
||||
#include <LibWeb/Page/Page.h>
|
||||
#include <LibWeb/Painting/PaintableBox.h>
|
||||
#include <LibWeb/Painting/ViewportPaintable.h>
|
||||
|
@ -117,4 +118,25 @@ JS::NonnullGCPtr<InternalAnimationTimeline> Internals::create_internal_animation
|
|||
return realm.heap().allocate<InternalAnimationTimeline>(realm, realm);
|
||||
}
|
||||
|
||||
void Internals::simulate_drag_start(double x, double y, String const& name, String const& contents)
|
||||
{
|
||||
Vector<HTML::SelectedFile> files;
|
||||
files.empend(name.to_byte_string(), MUST(ByteBuffer::copy(contents.bytes())));
|
||||
|
||||
auto& page = global_object().browsing_context()->page();
|
||||
page.handle_drag_and_drop_event(DragEvent::Type::DragStart, { x, y }, { x, y }, UIEvents::MouseButton::Primary, 0, 0, move(files));
|
||||
}
|
||||
|
||||
void Internals::simulate_drag_move(double x, double y)
|
||||
{
|
||||
auto& page = global_object().browsing_context()->page();
|
||||
page.handle_drag_and_drop_event(DragEvent::Type::DragMove, { x, y }, { x, y }, UIEvents::MouseButton::Primary, 0, 0, {});
|
||||
}
|
||||
|
||||
void Internals::simulate_drop(double x, double y)
|
||||
{
|
||||
auto& page = global_object().browsing_context()->page();
|
||||
page.handle_drag_and_drop_event(DragEvent::Type::Drop, { x, y }, { x, y }, UIEvents::MouseButton::Primary, 0, 0, {});
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue