mirror of
https://github.com/RGBCube/serenity
synced 2025-06-01 07:18:13 +00:00
LibWeb: Specialize hit testing for text cursor purposes
The text cursor follows slightly different "intuitive" rules than the regular hit testing. Clicking past the right edge of a text box should still "hit" the text box, and place the cursor at its end, for example. We solve this by adding a HitTestType enum that is passed to hit_test() and determines whether past-the-edge candidates are considered.
This commit is contained in:
parent
5cee150a91
commit
e2b4fef6c7
11 changed files with 38 additions and 27 deletions
|
@ -45,11 +45,16 @@ struct HitTestResult {
|
|||
int index_in_node { 0 };
|
||||
};
|
||||
|
||||
enum class HitTestType {
|
||||
Exact, // Exact matches only
|
||||
TextCursor, // Clicking past the right/bottom edge of text will still hit the text
|
||||
};
|
||||
|
||||
class LayoutNode : public TreeNode<LayoutNode> {
|
||||
public:
|
||||
virtual ~LayoutNode();
|
||||
|
||||
virtual HitTestResult hit_test(const Gfx::IntPoint&) const;
|
||||
virtual HitTestResult hit_test(const Gfx::IntPoint&, HitTestType) const;
|
||||
|
||||
bool is_anonymous() const { return !m_node; }
|
||||
const DOM::Node* node() const { return m_node; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue