diff options
author | Andreas Kling <kling@serenityos.org> | 2020-08-05 16:55:56 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2020-08-05 16:57:51 +0200 |
commit | e2b4fef6c75070febdc689d7fadc21eb28c2315d (patch) | |
tree | 981ef1f04549f0d07f29e6cb8e5c369ebe1b85ea /Libraries/LibWeb/Painting | |
parent | 5cee150a91b6c3fab02240ebc3d7a48e5bbad56e (diff) | |
download | serenity-e2b4fef6c75070febdc689d7fadc21eb28c2315d.zip |
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.
Diffstat (limited to 'Libraries/LibWeb/Painting')
-rw-r--r-- | Libraries/LibWeb/Painting/StackingContext.cpp | 8 | ||||
-rw-r--r-- | Libraries/LibWeb/Painting/StackingContext.h | 2 |
2 files changed, 5 insertions, 5 deletions
diff --git a/Libraries/LibWeb/Painting/StackingContext.cpp b/Libraries/LibWeb/Painting/StackingContext.cpp index ed66da46a6..f55cfe355d 100644 --- a/Libraries/LibWeb/Painting/StackingContext.cpp +++ b/Libraries/LibWeb/Painting/StackingContext.cpp @@ -61,19 +61,19 @@ void StackingContext::paint(PaintContext& context, LayoutNode::PaintPhase phase) } } -HitTestResult StackingContext::hit_test(const Gfx::IntPoint& position) const +HitTestResult StackingContext::hit_test(const Gfx::IntPoint& position, HitTestType type) const { HitTestResult result; if (!m_box.is_root()) { - result = m_box.hit_test(position); + result = m_box.hit_test(position, type); } else { // NOTE: LayoutDocument::hit_test() merely calls StackingContext::hit_test() // so we call its base class instead. - result = downcast<LayoutDocument>(m_box).LayoutBlock::hit_test(position); + result = downcast<LayoutDocument>(m_box).LayoutBlock::hit_test(position, type); } for (auto* child : m_children) { - auto result_here = child->hit_test(position); + auto result_here = child->hit_test(position, type); if (result_here.layout_node) result = result_here; } diff --git a/Libraries/LibWeb/Painting/StackingContext.h b/Libraries/LibWeb/Painting/StackingContext.h index f817a5ff67..d7621c3829 100644 --- a/Libraries/LibWeb/Painting/StackingContext.h +++ b/Libraries/LibWeb/Painting/StackingContext.h @@ -41,7 +41,7 @@ public: const StackingContext* parent() const { return m_parent; } void paint(PaintContext&, LayoutNode::PaintPhase); - HitTestResult hit_test(const Gfx::IntPoint&) const; + HitTestResult hit_test(const Gfx::IntPoint&, HitTestType) const; void dump(int indent = 0) const; |