mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 07:17:34 +00:00
LibWeb: Move hit testing to the painting tree
This commit is contained in:
parent
ba606d9057
commit
5779a910e5
18 changed files with 196 additions and 172 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue