mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 12:07:14 +02:00
With per-paintable display list command caching now in place, the separate paint-only properties resolution phase is no longer needed. Resolution now happens inline during painting and its cost is amortized since it only runs on cache miss. Move all property resolution to point of consumption: - is_visible() and visible_for_hit_testing() compute on the fly - Filter resolution moved to assign_accumulated_visual_contexts() - Border radii, outlines computed on access - Box shadows, backdrop filter resolved inline during painting - Background resolution moved into paint_background() - Mask resolution moved to StackingContext::paint() - Text fragment and SVG stroke properties resolved during painting
66 lines
2.3 KiB
C++
66 lines
2.3 KiB
C++
/*
|
|
* Copyright (c) 2022-2025, Andreas Kling <andreas@ladybird.org>
|
|
* Copyright (c) 2024-2025, Aliaksandr Kalenik <kalenik.aliaksandr@gmail.com>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibWeb/Forward.h>
|
|
#include <LibWeb/Painting/PaintableBox.h>
|
|
#include <LibWeb/Painting/PaintableFragment.h>
|
|
|
|
namespace Web::Painting {
|
|
|
|
class PaintableWithLines : public PaintableBox {
|
|
GC_CELL(PaintableWithLines, PaintableBox);
|
|
GC_DECLARE_ALLOCATOR(PaintableWithLines);
|
|
|
|
public:
|
|
static GC::Ref<PaintableWithLines> create(Layout::BlockContainer const&);
|
|
static GC::Ref<PaintableWithLines> create(Layout::InlineNode const&, size_t line_index);
|
|
virtual ~PaintableWithLines() override;
|
|
|
|
virtual void reset_for_relayout() override;
|
|
|
|
Vector<PaintableFragment> const& fragments() const { return m_fragments; }
|
|
Vector<PaintableFragment>& fragments() { return m_fragments; }
|
|
|
|
void add_fragment(Layout::LineBoxFragment const& fragment)
|
|
{
|
|
m_fragments.append(PaintableFragment { fragment });
|
|
}
|
|
|
|
virtual void paint(DisplayListRecordingContext&, PaintPhase) const override;
|
|
static void paint_text_fragment_debug_highlight(DisplayListRecordingContext&, PaintableFragment const&);
|
|
|
|
[[nodiscard]] virtual TraversalDecision hit_test(CSSPixelPoint position, HitTestType type, Function<TraversalDecision(HitTestResult)> const& callback) const override;
|
|
[[nodiscard]] TraversalDecision hit_test_fragments(CSSPixelPoint position, CSSPixelPoint local_position, HitTestType type, Function<TraversalDecision(HitTestResult)> const& callback) const;
|
|
|
|
virtual void visit_edges(Cell::Visitor& visitor) override
|
|
{
|
|
Base::visit_edges(visitor);
|
|
for (auto& fragment : m_fragments)
|
|
visitor.visit(GC::Ref { fragment.layout_node() });
|
|
}
|
|
|
|
size_t line_index() const { return m_line_index; }
|
|
|
|
protected:
|
|
PaintableWithLines(Layout::BlockContainer const&);
|
|
PaintableWithLines(Layout::InlineNode const&, size_t line_index);
|
|
|
|
private:
|
|
[[nodiscard]] virtual bool is_paintable_with_lines() const final { return true; }
|
|
|
|
Optional<PaintableFragment const&> fragment_at_position(DOM::Position const&) const;
|
|
void paint_cursor(DisplayListRecordingContext&) const;
|
|
|
|
Vector<PaintableFragment> m_fragments;
|
|
|
|
size_t m_line_index { 0 };
|
|
};
|
|
|
|
}
|