1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-28 03:07:35 +00:00

LibWeb: Move hit testing to the painting tree

This commit is contained in:
Andreas Kling 2022-03-11 00:03:28 +01:00
parent ba606d9057
commit 5779a910e5
18 changed files with 196 additions and 172 deletions

View file

@ -10,10 +10,35 @@
#include <LibWeb/Layout/Box.h>
#include <LibWeb/Layout/LineBox.h>
#include <LibWeb/Layout/TextNode.h>
#include <LibWeb/Painting/StackingContext.h>
namespace Web::Painting {
enum class PaintPhase {
Background,
Border,
Foreground,
FocusOutline,
Overlay,
};
struct HitTestResult {
RefPtr<Painting::Paintable> paintable;
int index_in_node { 0 };
enum InternalPosition {
None,
Before,
Inside,
After,
};
InternalPosition internal_position { None };
};
enum class HitTestType {
Exact, // Exact matches only
TextCursor, // Clicking past the right/bottom edge of text will still hit the text
};
class Paintable : public RefCounted<Paintable> {
AK_MAKE_NONMOVABLE(Paintable);
AK_MAKE_NONCOPYABLE(Paintable);
@ -25,6 +50,8 @@ public:
virtual void before_children_paint(PaintContext&, PaintPhase) const { }
virtual void after_children_paint(PaintContext&, PaintPhase) const { }
virtual HitTestResult hit_test(Gfx::IntPoint const&, HitTestType) const;
virtual bool wants_mouse_events() const { return false; }
virtual void handle_mousedown(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers);
virtual void handle_mouseup(Badge<EventHandler>, const Gfx::IntPoint&, unsigned button, unsigned modifiers);