summaryrefslogtreecommitdiff
path: root/Libraries/LibWeb/Page/EventHandler.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-08-21 17:50:41 +0200
committerAndreas Kling <kling@serenityos.org>2020-08-21 17:57:24 +0200
commitd47f77169f8c3bdb6675a67a736b5591a752b52c (patch)
tree4ad2cb19410f7fafd5e17a05548dc18ecd3e6612 /Libraries/LibWeb/Page/EventHandler.cpp
parentcf4870c93e274ad7f0620f86241b85de9a2adc76 (diff)
downloadserenity-d47f77169f8c3bdb6675a67a736b5591a752b52c.zip
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.
Diffstat (limited to 'Libraries/LibWeb/Page/EventHandler.cpp')
-rw-r--r--Libraries/LibWeb/Page/EventHandler.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp
index 38a8bfb8cb..cba26e89ba 100644
--- a/Libraries/LibWeb/Page/EventHandler.cpp
+++ b/Libraries/LibWeb/Page/EventHandler.cpp
@@ -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();