mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-05-09 20:52:54 +00:00
LibWeb: Remember the selection state of each LayoutNode
Instead of computing it on the fly while painting each layout node, they now remember their selection state. This avoids a whole bunch of tree traversal while painting with anything selected.
This commit is contained in:
parent
cf4870c93e
commit
d47f77169f
Notes:
sideshowbarker
2024-07-19 03:21:04 +09:00
Author: https://github.com/awesomekling
Commit: d47f77169f
6 changed files with 60 additions and 15 deletions
|
@ -157,6 +157,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt
|
|||
if (result.layout_node && result.layout_node->node()) {
|
||||
m_frame.set_cursor_position(DOM::Position(*node, result.index_in_node));
|
||||
layout_root()->selection().set({ result.layout_node, result.index_in_node }, {});
|
||||
layout_root()->recompute_selection_states();
|
||||
dump_selection("MouseDown");
|
||||
m_in_mouse_selection = true;
|
||||
}
|
||||
|
@ -209,6 +210,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt
|
|||
auto hit = layout_root()->hit_test(position, HitTestType::TextCursor);
|
||||
if (hit.layout_node && hit.layout_node->node()) {
|
||||
layout_root()->selection().set_end({ hit.layout_node, hit.index_in_node });
|
||||
layout_root()->recompute_selection_states();
|
||||
}
|
||||
dump_selection("MouseMove");
|
||||
page_client.page_did_change_selection();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue