mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-06-02 00:13:02 +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,3 +1,4 @@
|
|||
#include <LibHTML/DOM/Element.h>
|
||||
#include <LibHTML/Layout/LayoutBlock.h>
|
||||
#include <LibHTML/Layout/LayoutNode.h>
|
||||
|
||||
|
@ -34,3 +35,16 @@ void LayoutNode::render(RenderingContext& context)
|
|||
child.render(context);
|
||||
});
|
||||
}
|
||||
|
||||
HitTestResult LayoutNode::hit_test(const Point& position) const
|
||||
{
|
||||
if (!m_rect.contains(position))
|
||||
return {};
|
||||
HitTestResult result { this };
|
||||
for_each_child([&](auto& child) {
|
||||
auto child_result = child.hit_test(position);
|
||||
if (child_result.layout_node)
|
||||
result = child_result;
|
||||
});
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue