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.
69 lines
2.3 KiB
C++
69 lines
2.3 KiB
C++
/*
|
|
* Copyright (c) 2018-2022, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2022, Sam Atkins <atkinssj@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibWeb/Painting/DisplayListRecordingContext.h>
|
|
|
|
namespace Web {
|
|
|
|
static u64 s_next_paint_generation_id = 0;
|
|
|
|
DisplayListRecordingContext::DisplayListRecordingContext(Painting::DisplayListRecorder& display_list_recorder, Palette const& palette, double device_pixels_per_css_pixel, ChromeMetrics const& chrome_metrics, Painting::HitTestDisplayList* hit_test_display_list)
|
|
: m_display_list_recorder(display_list_recorder)
|
|
, m_hit_test_display_list(hit_test_display_list)
|
|
, m_palette(palette)
|
|
, m_device_pixel_converter(device_pixels_per_css_pixel)
|
|
, m_chrome_metrics(chrome_metrics)
|
|
, m_paint_generation_id(s_next_paint_generation_id++)
|
|
{
|
|
}
|
|
|
|
DevicePixels DisplayListRecordingContext::rounded_device_pixels(CSSPixels css_pixels) const
|
|
{
|
|
return m_device_pixel_converter.rounded_device_pixels(css_pixels);
|
|
}
|
|
|
|
DevicePixels DisplayListRecordingContext::enclosing_device_pixels(CSSPixels css_pixels) const
|
|
{
|
|
return m_device_pixel_converter.enclosing_device_pixels(css_pixels);
|
|
}
|
|
|
|
DevicePixels DisplayListRecordingContext::floored_device_pixels(CSSPixels css_pixels) const
|
|
{
|
|
return m_device_pixel_converter.floored_device_pixels(css_pixels);
|
|
}
|
|
|
|
DevicePixelPoint DisplayListRecordingContext::rounded_device_point(CSSPixelPoint point) const
|
|
{
|
|
return m_device_pixel_converter.rounded_device_point(point);
|
|
}
|
|
|
|
DevicePixelPoint DisplayListRecordingContext::floored_device_point(CSSPixelPoint point) const
|
|
{
|
|
return m_device_pixel_converter.floored_device_point(point);
|
|
}
|
|
|
|
DevicePixelRect DisplayListRecordingContext::enclosing_device_rect(CSSPixelRect rect) const
|
|
{
|
|
return m_device_pixel_converter.enclosing_device_rect(rect);
|
|
}
|
|
|
|
DevicePixelRect DisplayListRecordingContext::rounded_device_rect(CSSPixelRect rect) const
|
|
{
|
|
return m_device_pixel_converter.rounded_device_rect(rect);
|
|
}
|
|
|
|
DevicePixelSize DisplayListRecordingContext::enclosing_device_size(CSSPixelSize size) const
|
|
{
|
|
return m_device_pixel_converter.enclosing_device_size(size);
|
|
}
|
|
|
|
DevicePixelSize DisplayListRecordingContext::rounded_device_size(CSSPixelSize size) const
|
|
{
|
|
return m_device_pixel_converter.rounded_device_size(size);
|
|
}
|
|
|
|
}
|