mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-06 19:22:53 +00:00
LibHTML: Implement naive hit testing
We don't have proper line boxes yet, so we can't easily hit test inline text.
This commit is contained in:
parent
3ed41abba4
commit
3de4b99dc3
Notes:
sideshowbarker
2024-07-19 11:54:11 +09:00
Author: https://github.com/awesomekling
Commit: 3de4b99dc3
4 changed files with 38 additions and 0 deletions
|
@ -1,5 +1,6 @@
|
|||
#include <LibGUI/GPainter.h>
|
||||
#include <LibGUI/GScrollBar.h>
|
||||
#include <LibHTML/DOM/Element.h>
|
||||
#include <LibHTML/Dump.h>
|
||||
#include <LibHTML/HtmlView.h>
|
||||
#include <LibHTML/Layout/LayoutNode.h>
|
||||
|
@ -78,3 +79,17 @@ void HtmlView::paint_event(GPaintEvent& event)
|
|||
RenderingContext context { painter };
|
||||
m_layout_root->render(context);
|
||||
}
|
||||
|
||||
void HtmlView::mousemove_event(GMouseEvent& event)
|
||||
{
|
||||
if (!m_layout_root)
|
||||
return GScrollableWidget::mousemove_event(event);
|
||||
|
||||
auto result = m_layout_root->hit_test(event.position());
|
||||
if (result.layout_node) {
|
||||
if (auto* node = result.layout_node->node()) {
|
||||
dbg() << "HtmlView: mousemove: " << node->tag_name() << "{" << node << "}";
|
||||
}
|
||||
}
|
||||
event.accept();
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue