diff options
author | Andreas Kling <kling@serenityos.org> | 2020-08-21 17:54:44 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-21 17:57:24 +0200 |
commit | 684fa0f99b12e79eb95907b53498d09c95f1f1d9 (patch) | |
tree | 35b63657908fea70ede90d48b918d0115fbf7a42 /Libraries/LibWeb/Page/EventHandler.cpp | |
parent | d47f77169f8c3bdb6675a67a736b5591a752b52c (diff) | |
download | serenity-684fa0f99b12e79eb95907b53498d09c95f1f1d9.zip |
LibWeb: Make selection state recomputation implicit
Add a LayoutDocument API for modifying the selection and make clients
call that so we can recompute selection states automatically.
Diffstat (limited to 'Libraries/LibWeb/Page/EventHandler.cpp')
-rw-r--r-- | Libraries/LibWeb/Page/EventHandler.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Libraries/LibWeb/Page/EventHandler.cpp b/Libraries/LibWeb/Page/EventHandler.cpp index cba26e89ba..d9623b8105 100644 --- a/Libraries/LibWeb/Page/EventHandler.cpp +++ b/Libraries/LibWeb/Page/EventHandler.cpp @@ -31,10 +31,10 @@ #include <LibWeb/DOM/Text.h> #include <LibWeb/HTML/HTMLAnchorElement.h> #include <LibWeb/HTML/HTMLIFrameElement.h> +#include <LibWeb/InProcessWebView.h> #include <LibWeb/Layout/LayoutDocument.h> #include <LibWeb/Page/EventHandler.h> #include <LibWeb/Page/Frame.h> -#include <LibWeb/InProcessWebView.h> #include <LibWeb/UIEvents/MouseEvent.h> namespace Web { @@ -156,8 +156,7 @@ bool EventHandler::handle_mousedown(const Gfx::IntPoint& position, unsigned butt auto result = layout_root()->hit_test(position, HitTestType::TextCursor); 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(); + layout_root()->set_selection({ { result.layout_node, result.index_in_node }, {} }); dump_selection("MouseDown"); m_in_mouse_selection = true; } @@ -209,8 +208,7 @@ bool EventHandler::handle_mousemove(const Gfx::IntPoint& position, unsigned butt if (m_in_mouse_selection) { 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(); + layout_root()->set_selection_end({ hit.layout_node, hit.index_in_node }); } dump_selection("MouseMove"); page_client.page_did_change_selection(); |