mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 02:17:35 +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
|
@ -28,10 +28,13 @@
|
|||
|
||||
#include <LibWeb/HTML/HTMLImageElement.h>
|
||||
#include <LibWeb/Layout/ReplacedBox.h>
|
||||
#include <LibWeb/Page/Frame.h>
|
||||
|
||||
namespace Web::Layout {
|
||||
|
||||
class ImageBox : public ReplacedBox {
|
||||
class ImageBox
|
||||
: public ReplacedBox
|
||||
, public Frame::ViewportClient {
|
||||
public:
|
||||
ImageBox(DOM::Document&, DOM::Element&, NonnullRefPtr<CSS::StyleProperties>, const ImageLoader&);
|
||||
virtual ~ImageBox() override;
|
||||
|
@ -43,9 +46,9 @@ public:
|
|||
|
||||
bool renders_as_alt_text() const;
|
||||
|
||||
void set_visible_in_viewport(Badge<InitialContainingBlockBox>, bool);
|
||||
|
||||
private:
|
||||
virtual void frame_did_set_viewport_rect(const Gfx::IntRect&) final;
|
||||
|
||||
int preferred_width() const;
|
||||
int preferred_height() const;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue