mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 05:37:43 +00:00
LibWeb: Move image viewport awareness from ImageBox to ImagePaintable
Images being aware of being visible inside the viewport is a painting concern, not a layout concern.
This commit is contained in:
parent
8da9ff24e4
commit
dbe961ca02
4 changed files with 26 additions and 26 deletions
|
@ -15,20 +15,10 @@ ImageBox::ImageBox(DOM::Document& document, DOM::Element& element, NonnullRefPtr
|
|||
: ReplacedBox(document, element, move(style))
|
||||
, m_image_loader(image_loader)
|
||||
{
|
||||
browsing_context().register_viewport_client(*this);
|
||||
}
|
||||
|
||||
ImageBox::~ImageBox() = default;
|
||||
|
||||
void ImageBox::finalize()
|
||||
{
|
||||
Base::finalize();
|
||||
|
||||
// NOTE: We unregister from the browsing context in finalize() to avoid trouble
|
||||
// in the scenario where our BrowsingContext has already been swept by GC.
|
||||
browsing_context().unregister_viewport_client(*this);
|
||||
}
|
||||
|
||||
int ImageBox::preferred_width() const
|
||||
{
|
||||
return dom_node().attribute(HTML::AttributeNames::width).to_int().value_or(m_image_loader.width());
|
||||
|
@ -90,11 +80,6 @@ bool ImageBox::renders_as_alt_text() const
|
|||
return false;
|
||||
}
|
||||
|
||||
void ImageBox::browsing_context_did_set_viewport_rect(CSSPixelRect const& viewport_rect)
|
||||
{
|
||||
m_image_loader.set_visible_in_viewport(paintable_box() && viewport_rect.intersects(paintable_box()->absolute_rect()));
|
||||
}
|
||||
|
||||
JS::GCPtr<Painting::Paintable> ImageBox::create_paintable() const
|
||||
{
|
||||
return Painting::ImagePaintable::create(*this);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue