1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-15 20:34:59 +00:00
serenity/Userland/Libraries/LibWeb/Painting/ImagePaintable.h
Aliaksandr Kalenik 5ff7448fee LibWeb: Move viewport subscriptions from BrowsingContext to Document
With this change, elements that want to receive viewport rect updates
will need to register on document instead of the browsing context.

This change solves the problem where a browsing context for a document
is guaranteed to exist only while the document is active so browsing
context might not exit by the time DOM node that want to register is
constructed.

This is a part of preparation work before switching to navigables where
this issue becomes more visible.
2023-08-23 20:14:20 +02:00

36 lines
793 B
C++

/*
* Copyright (c) 2022, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/Layout/ImageBox.h>
#include <LibWeb/Painting/PaintableBox.h>
namespace Web::Painting {
class ImagePaintable final
: public PaintableBox
, public DOM::Document::ViewportClient {
JS_CELL(ImagePaintable, PaintableBox);
public:
static JS::NonnullGCPtr<ImagePaintable> create(Layout::ImageBox const&);
virtual void paint(PaintContext&, PaintPhase) const override;
Layout::ImageBox const& layout_box() const;
private:
// ^JS::Cell
virtual void finalize() override;
// ^Document::ViewportClient
virtual void did_set_viewport_rect(CSSPixelRect const&) final;
ImagePaintable(Layout::ImageBox const&);
};
}