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

LibWeb: Move painting logic from Layout::Viewport to ViewportPaintable

This commit is contained in:
Andreas Kling 2023-08-19 08:38:51 +02:00
parent c01c4b41e2
commit 8bb275f2ea
9 changed files with 54 additions and 48 deletions

View file

@ -25,42 +25,6 @@ JS::GCPtr<Selection::Selection> Viewport::selection() const
return const_cast<DOM::Document&>(document()).get_selection();
}
void Viewport::build_stacking_context_tree_if_needed()
{
if (paintable_box()->stacking_context())
return;
build_stacking_context_tree();
}
void Viewport::build_stacking_context_tree()
{
paintable_box()->set_stacking_context(make<Painting::StackingContext>(*this, nullptr, 0));
size_t index_in_tree_order = 1;
for_each_in_subtree_of_type<Box>([&](Box& box) {
if (!box.paintable_box())
return IterationDecision::Continue;
box.paintable_box()->invalidate_stacking_context();
if (!box.establishes_stacking_context()) {
VERIFY(!box.paintable_box()->stacking_context());
return IterationDecision::Continue;
}
auto* parent_context = box.paintable_box()->enclosing_stacking_context();
VERIFY(parent_context);
box.paintable_box()->set_stacking_context(make<Painting::StackingContext>(box, parent_context, index_in_tree_order++));
return IterationDecision::Continue;
});
paintable_box()->stacking_context()->sort();
}
void Viewport::paint_all_phases(PaintContext& context)
{
build_stacking_context_tree_if_needed();
context.painter().translate(-context.device_viewport_rect().location().to_type<int>());
paintable_box()->stacking_context()->paint(context);
}
void Viewport::recompute_selection_states()
{
// 1. Start by resetting the selection state of all layout nodes to None.