1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 13:47:45 +00:00

LibWeb: Move "visible in viewport" state tracking to ImageLoader

This should technically apply to any LayoutImage, so let's just move
it to ImageLoader.
This commit is contained in:
Andreas Kling 2020-06-14 19:32:23 +02:00
parent c45615128b
commit 73c9f7ebf4
7 changed files with 12 additions and 13 deletions

View file

@ -71,8 +71,7 @@ void LayoutDocument::did_set_viewport_rect(Badge<Frame>, const Gfx::IntRect& a_v
{
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<LayoutImage>([&](auto& layout_image) {
if (is<HTMLImageElement>(layout_image.node()))
const_cast<HTMLImageElement&>(to<HTMLImageElement>(layout_image.node())).set_visible_in_viewport({}, viewport_rect.intersects(layout_image.absolute_rect()));
const_cast<LayoutImage&>(layout_image).set_visible_in_viewport({}, viewport_rect.intersects(layout_image.absolute_rect()));
return IterationDecision::Continue;
});
}