mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 17:07:34 +00:00
LibWeb: Make hit testing return a { paintable, offset }
Everything related to hit testing is better off using the painting tree. The thing being mousemoved over is a paintable, so let's hand that out directly instead of the corresponding layout node.
This commit is contained in:
parent
cb0c5390ff
commit
f017c1c064
5 changed files with 46 additions and 49 deletions
|
@ -42,16 +42,16 @@ HitTestResult BlockContainer::hit_test(const Gfx::IntPoint& position, HitTestTyp
|
|||
if (enclosing_int_rect(fragment.absolute_rect()).contains(position)) {
|
||||
if (is<BlockContainer>(fragment.layout_node()))
|
||||
return verify_cast<BlockContainer>(fragment.layout_node()).hit_test(position, type);
|
||||
return { fragment.layout_node(), fragment.text_index_at(position.x()) };
|
||||
return { fragment.layout_node().paintable(), fragment.text_index_at(position.x()) };
|
||||
}
|
||||
if (fragment.absolute_rect().top() <= position.y())
|
||||
last_good_candidate = { fragment.layout_node(), fragment.text_index_at(position.x()) };
|
||||
last_good_candidate = { fragment.layout_node().paintable(), fragment.text_index_at(position.x()) };
|
||||
}
|
||||
}
|
||||
|
||||
if (type == HitTestType::TextCursor && last_good_candidate.layout_node)
|
||||
if (type == HitTestType::TextCursor && last_good_candidate.paintable)
|
||||
return last_good_candidate;
|
||||
return { paint_box()->absolute_border_box_rect().contains(position.x(), position.y()) ? this : nullptr };
|
||||
return { paint_box()->absolute_border_box_rect().contains(position.x(), position.y()) ? paintable() : nullptr };
|
||||
}
|
||||
|
||||
bool BlockContainer::is_scrollable() const
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue