From 73c9f7ebf4ae07492367c1c39f940603046b780e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 14 Jun 2020 19:32:23 +0200 Subject: LibWeb: Move "visible in viewport" state tracking to ImageLoader This should technically apply to any LayoutImage, so let's just move it to ImageLoader. --- Libraries/LibWeb/Loader/ImageLoader.cpp | 4 ++-- Libraries/LibWeb/Loader/ImageLoader.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'Libraries/LibWeb/Loader') diff --git a/Libraries/LibWeb/Loader/ImageLoader.cpp b/Libraries/LibWeb/Loader/ImageLoader.cpp index e3e3502805..a6b3ecae58 100644 --- a/Libraries/LibWeb/Loader/ImageLoader.cpp +++ b/Libraries/LibWeb/Loader/ImageLoader.cpp @@ -44,7 +44,7 @@ void ImageLoader::load(const URL& url) set_resource(ResourceLoader::the().load_resource(Resource::Type::Image, request)); } -void ImageLoader::set_visible_in_viewport(bool visible_in_viewport) +void ImageLoader::set_visible_in_viewport(bool visible_in_viewport) const { if (m_visible_in_viewport == visible_in_viewport) return; @@ -54,7 +54,7 @@ void ImageLoader::set_visible_in_viewport(bool visible_in_viewport) // the whole document, updating "is visible in viewport" flags, and this could lead // to the same bitmap being marked volatile back and forth unnecessarily. if (resource()) - resource()->update_volatility(); + const_cast(resource())->update_volatility(); } void ImageLoader::resource_did_load() diff --git a/Libraries/LibWeb/Loader/ImageLoader.h b/Libraries/LibWeb/Loader/ImageLoader.h index 14c8cd3288..71cd48ff64 100644 --- a/Libraries/LibWeb/Loader/ImageLoader.h +++ b/Libraries/LibWeb/Loader/ImageLoader.h @@ -41,7 +41,7 @@ public: const Gfx::Bitmap* bitmap() const; const Gfx::ImageDecoder* image_decoder() const; - void set_visible_in_viewport(bool); + void set_visible_in_viewport(bool) const; Function on_load; Function on_fail; @@ -57,7 +57,7 @@ private: void animate(); RefPtr m_decoder; - bool m_visible_in_viewport { false }; + mutable bool m_visible_in_viewport { false }; size_t m_current_frame_index { 0 }; size_t m_loops_completed { 0 }; -- cgit v1.2.3