ladybird/Libraries/LibWeb/Painting/ChromeWidget.h
Andreas Kling 7445cff5e8 LibWeb: Use retained data for hit testing
Build a hit-test display list while recording paint output. Use it as
source of truth for point hit testing instead of recursively walking the
paintable tree in reverse paint order.

The retained list records target paintables, visual context indices,
border radii, caret rects, and line metadata needed by hit testing. It
also keeps a spatial index so point queries inspect nearby items before
checking containment in paint order.

Refresh scroll state before hit testing so visual context transforms use
current scroll offsets. Add text tests for rounded hit regions and
selection across non-text content.
2026-05-30 13:50:48 +02:00

47 lines
1 KiB
C++

/*
* Copyright (c) 2026, the Ladybird developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/EnumBits.h>
#include <AK/RefCounted.h>
#include <AK/Weakable.h>
#include <LibGC/Cell.h>
#include <LibWeb/CSS/ComputedValues.h>
#include <LibWeb/Forward.h>
#include <LibWeb/PixelUnits.h>
namespace Web {
struct ChromeMetrics;
}
namespace Web::Painting {
enum class MouseAction : u8 {
None = 0,
CaptureInput = 1 << 0,
SwallowEvent = 1 << 1,
};
AK_ENUM_BITWISE_OPERATORS(MouseAction);
class ChromeWidget
: public RefCounted<ChromeWidget>
, public Weakable<ChromeWidget> {
public:
virtual ~ChromeWidget() = default;
virtual bool contains(CSSPixelPoint, ChromeMetrics const&) const = 0;
virtual MouseAction handle_pointer_event(FlyString const& type, unsigned button, CSSPixelPoint visual_viewport_position) = 0;
virtual void mouse_enter() = 0;
virtual void mouse_leave() = 0;
virtual Optional<CSS::CursorPredefined> cursor() const { return {}; }
};
}