mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 16:35:08 +00:00
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.
This commit is contained in:
parent
d47f77169f
commit
684fa0f99b
4 changed files with 18 additions and 8 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue