mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:37:44 +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:
parent
c45615128b
commit
73c9f7ebf4
7 changed files with 12 additions and 13 deletions
|
@ -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;
|
||||
});
|
||||
}
|
||||
|
|
|
@ -108,4 +108,9 @@ bool LayoutImage::renders_as_alt_text() const
|
|||
return false;
|
||||
}
|
||||
|
||||
void LayoutImage::set_visible_in_viewport(Badge<LayoutDocument>, bool visible_in_viewport)
|
||||
{
|
||||
m_image_loader.set_visible_in_viewport(visible_in_viewport);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -45,6 +45,8 @@ public:
|
|||
|
||||
bool renders_as_alt_text() const;
|
||||
|
||||
void set_visible_in_viewport(Badge<LayoutDocument>, bool);
|
||||
|
||||
private:
|
||||
virtual const char* class_name() const override { return "LayoutImage"; }
|
||||
virtual bool is_image() const override { return true; }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue