mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:18:12 +00:00
LibWeb: Add Frame::ViewportClient and use it for Layout::ImageBox
Image boxes want to know whether they are inside the visible viewport. This is used to pause/resume animations, and to update the purgeable memory volatility state. Previously we would traverse the entire layout tree on every resize, calling a helper on each ImageBox. Make those boxes register with the frame they are interested in instead, saving us all that traversal. This also makes it easier for other parts of the code to learn about viewport changes in the future. :^)
This commit is contained in:
parent
1c6f278677
commit
9b0ca75f84
6 changed files with 39 additions and 22 deletions
|
@ -63,15 +63,6 @@ void InitialContainingBlockBox::build_stacking_context_tree()
|
|||
});
|
||||
}
|
||||
|
||||
void InitialContainingBlockBox::did_set_viewport_rect(Badge<Frame>, const Gfx::IntRect& a_viewport_rect)
|
||||
{
|
||||
Gfx::FloatRect viewport_rect(a_viewport_rect.x(), a_viewport_rect.y(), a_viewport_rect.width(), a_viewport_rect.height());
|
||||
for_each_in_subtree_of_type<ImageBox>([&](auto& layout_image) {
|
||||
const_cast<ImageBox&>(layout_image).set_visible_in_viewport({}, viewport_rect.intersects(layout_image.absolute_rect()));
|
||||
return IterationDecision::Continue;
|
||||
});
|
||||
}
|
||||
|
||||
void InitialContainingBlockBox::paint_all_phases(PaintContext& context)
|
||||
{
|
||||
paint(context, PaintPhase::Background);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue