diff options
Diffstat (limited to 'Libraries/LibWeb')
-rw-r--r-- | Libraries/LibWeb/InProcessWebView.cpp | 3 | ||||
-rw-r--r-- | Libraries/LibWeb/Layout/LayoutDocument.cpp | 12 | ||||
-rw-r--r-- | Libraries/LibWeb/Layout/LayoutDocument.h | 3 | ||||
-rw-r--r-- | Libraries/LibWeb/Page/EventHandler.cpp | 8 |
4 files changed, 18 insertions, 8 deletions
diff --git a/Libraries/LibWeb/InProcessWebView.cpp b/Libraries/LibWeb/InProcessWebView.cpp index 96f2fa2c4e..175abb5b6a 100644 --- a/Libraries/LibWeb/InProcessWebView.cpp +++ b/Libraries/LibWeb/InProcessWebView.cpp @@ -109,8 +109,7 @@ void InProcessWebView::select_all() if (is<LayoutText>(*last_layout_node)) last_layout_node_index_in_node = downcast<LayoutText>(*last_layout_node).text_for_rendering().length() - 1; - layout_root->selection().set({ first_layout_node, 0 }, { last_layout_node, last_layout_node_index_in_node }); - layout_root->recompute_selection_states(); + layout_root->set_selection({ { first_layout_node, 0 }, { last_layout_node, last_layout_node_index_in_node } }); update(); } diff --git a/Libraries/LibWeb/Layout/LayoutDocument.cpp b/Libraries/LibWeb/Layout/LayoutDocument.cpp index b891874887..c93792b7f9 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.cpp +++ b/Libraries/LibWeb/Layout/LayoutDocument.cpp @@ -146,4 +146,16 @@ void LayoutDocument::recompute_selection_states() }); } +void LayoutDocument::set_selection(const LayoutRange & selection) +{ + m_selection = selection; + recompute_selection_states(); +} + +void LayoutDocument::set_selection_end(const LayoutPosition& position) +{ + m_selection.set_end(position); + recompute_selection_states(); +} + } diff --git a/Libraries/LibWeb/Layout/LayoutDocument.h b/Libraries/LibWeb/Layout/LayoutDocument.h index 2f18e90f44..0e5d39aebe 100644 --- a/Libraries/LibWeb/Layout/LayoutDocument.h +++ b/Libraries/LibWeb/Layout/LayoutDocument.h @@ -46,7 +46,8 @@ public: virtual HitTestResult hit_test(const Gfx::IntPoint&, HitTestType) const override; const LayoutRange& selection() const { return m_selection; } - LayoutRange& selection() { return m_selection; } + void set_selection(const LayoutRange&); + void set_selection_end(const LayoutPosition&); void did_set_viewport_rect(Badge<Frame>, const Gfx::IntRect&); 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(); |