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:
Andreas Kling 2020-08-21 17:54:44 +02:00
commit 684fa0f99b
Notes: sideshowbarker 2024-07-19 03:21:01 +09:00
4 changed files with 18 additions and 8 deletions

View file

@ -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();
}
}

View file

@ -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&);