mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-04-27 14:58:46 +00:00
LibWeb: Add a DOM Event class (instead of events being simple strings)
This patch adds the Event base class, along with a MouseEvent subclass. We now dispatch MouseEvent objects for mousedown, mouseup and mousemove and these objects have the .offsetX and .offsetY properties. Both of those properties are hard-coded at the moment. This will be fixed in the next patch. :^)
This commit is contained in:
parent
b196665131
commit
4dde36844b
Notes:
sideshowbarker
2024-07-19 08:11:59 +09:00
Author: https://github.com/awesomekling
Commit: 4dde36844b
15 changed files with 311 additions and 10 deletions
|
@ -36,6 +36,7 @@
|
|||
#include <LibWeb/DOM/ElementFactory.h>
|
||||
#include <LibWeb/DOM/HTMLAnchorElement.h>
|
||||
#include <LibWeb/DOM/HTMLImageElement.h>
|
||||
#include <LibWeb/DOM/MouseEvent.h>
|
||||
#include <LibWeb/DOM/Text.h>
|
||||
#include <LibWeb/Dump.h>
|
||||
#include <LibWeb/Frame.h>
|
||||
|
@ -184,7 +185,7 @@ void HtmlView::mousemove_event(GUI::MouseEvent& event)
|
|||
#endif
|
||||
is_hovering_link = true;
|
||||
}
|
||||
const_cast<Node*>(node)->dispatch_event("mousemove");
|
||||
const_cast<Node*>(node)->dispatch_event(MouseEvent::create("mousemove", 2, 3));
|
||||
}
|
||||
if (m_in_mouse_selection) {
|
||||
layout_root()->selection().set_end({ result.layout_node, result.index_in_node });
|
||||
|
@ -235,7 +236,7 @@ void HtmlView::mousedown_event(GUI::MouseEvent& event)
|
|||
m_in_mouse_selection = true;
|
||||
}
|
||||
}
|
||||
const_cast<Node*>(node)->dispatch_event("mousedown");
|
||||
const_cast<Node*>(node)->dispatch_event(MouseEvent::create("mousedown", 2, 3));
|
||||
}
|
||||
}
|
||||
if (hovered_node_changed)
|
||||
|
@ -251,7 +252,7 @@ void HtmlView::mouseup_event(GUI::MouseEvent& event)
|
|||
auto result = layout_root()->hit_test(to_content_position(event.position()));
|
||||
if (result.layout_node) {
|
||||
if (auto* node = result.layout_node->node())
|
||||
const_cast<Node*>(node)->dispatch_event("mouseup");
|
||||
const_cast<Node*>(node)->dispatch_event(MouseEvent::create("mouseup", 2, 3));
|
||||
}
|
||||
|
||||
if (event.button() == GUI::MouseButton::Left) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue