2022-03-10 14:02:25 +01:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2022, Andreas Kling <andreas@ladybird.org>
|
2022-03-10 14:02:25 +01:00
|
|
|
*
|
|
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <LibWeb/Layout/ImageBox.h>
|
2024-08-20 15:12:55 +01:00
|
|
|
#include <LibWeb/Layout/SVGImageBox.h>
|
2022-03-10 23:13:37 +01:00
|
|
|
#include <LibWeb/Painting/PaintableBox.h>
|
2022-03-10 14:02:25 +01:00
|
|
|
|
|
|
|
|
namespace Web::Painting {
|
|
|
|
|
|
2023-05-09 07:02:28 +02:00
|
|
|
class ImagePaintable final
|
|
|
|
|
: public PaintableBox
|
2023-08-23 18:58:42 +02:00
|
|
|
, public DOM::Document::ViewportClient {
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_CELL(ImagePaintable, PaintableBox);
|
|
|
|
|
GC_DECLARE_ALLOCATOR(ImagePaintable);
|
2023-01-11 12:51:49 +01:00
|
|
|
|
2022-03-10 14:02:25 +01:00
|
|
|
public:
|
2024-11-15 04:01:23 +13:00
|
|
|
static GC::Ref<ImagePaintable> create(Layout::ImageBox const& layout_box);
|
|
|
|
|
static GC::Ref<ImagePaintable> create(Layout::SVGImageBox const& layout_box);
|
2022-03-10 14:02:25 +01:00
|
|
|
|
|
|
|
|
virtual void paint(PaintContext&, PaintPhase) const override;
|
|
|
|
|
|
|
|
|
|
private:
|
2023-05-09 07:02:28 +02:00
|
|
|
// ^JS::Cell
|
2024-02-26 09:38:52 +01:00
|
|
|
virtual void visit_edges(Visitor&) override;
|
2023-05-09 07:02:28 +02:00
|
|
|
virtual void finalize() override;
|
|
|
|
|
|
2023-08-23 18:58:42 +02:00
|
|
|
// ^Document::ViewportClient
|
|
|
|
|
virtual void did_set_viewport_rect(CSSPixelRect const&) final;
|
2023-05-09 07:02:28 +02:00
|
|
|
|
2024-08-20 15:12:55 +01:00
|
|
|
ImagePaintable(Layout::Box const& layout_box, Layout::ImageProvider const& image_provider, bool renders_as_alt_text, String alt_text, bool is_svg_image);
|
2024-02-26 09:18:31 +01:00
|
|
|
|
|
|
|
|
bool m_renders_as_alt_text { false };
|
|
|
|
|
String m_alt_text;
|
2024-02-26 09:38:52 +01:00
|
|
|
|
|
|
|
|
Layout::ImageProvider const& m_image_provider;
|
2024-08-20 15:12:55 +01:00
|
|
|
|
|
|
|
|
bool m_is_svg_image { false };
|
2022-03-10 14:02:25 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
}
|