2020-01-18 09:38:21 +01:00
|
|
|
/*
|
2024-10-04 13:19:50 +02:00
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
|
2020-01-18 09:38:21 +01:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
2019-10-05 22:07:45 +02:00
|
|
|
#pragma once
|
|
|
|
|
2020-07-26 15:08:16 +02:00
|
|
|
#include <LibWeb/HTML/HTMLImageElement.h>
|
2020-11-22 15:53:01 +01:00
|
|
|
#include <LibWeb/Layout/ReplacedBox.h>
|
2019-10-05 22:07:45 +02:00
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
namespace Web::Layout {
|
2020-03-07 10:27:02 +01:00
|
|
|
|
2023-05-09 07:02:28 +02:00
|
|
|
class ImageBox final : public ReplacedBox {
|
2024-11-15 04:01:23 +13:00
|
|
|
GC_CELL(ImageBox, ReplacedBox);
|
|
|
|
GC_DECLARE_ALLOCATOR(ImageBox);
|
2022-10-17 14:41:50 +02:00
|
|
|
|
2019-10-05 22:07:45 +02:00
|
|
|
public:
|
2024-12-20 16:35:12 +01:00
|
|
|
ImageBox(DOM::Document&, DOM::Element&, GC::Ref<CSS::ComputedProperties>, ImageProvider const&);
|
2020-11-22 15:53:01 +01:00
|
|
|
virtual ~ImageBox() override;
|
2019-10-05 22:07:45 +02:00
|
|
|
|
2020-11-22 13:38:18 +01:00
|
|
|
virtual void prepare_for_replaced_layout() override;
|
2019-10-05 22:07:45 +02:00
|
|
|
|
2020-11-22 15:53:01 +01:00
|
|
|
const DOM::Element& dom_node() const { return static_cast<const DOM::Element&>(ReplacedBox::dom_node()); }
|
2019-10-05 23:20:35 +02:00
|
|
|
|
|
|
|
bool renders_as_alt_text() const;
|
|
|
|
|
2024-11-15 04:01:23 +13:00
|
|
|
virtual GC::Ptr<Painting::Paintable> create_paintable() const override;
|
2022-03-10 14:02:25 +01:00
|
|
|
|
2023-05-12 07:17:01 +02:00
|
|
|
auto const& image_provider() const { return m_image_provider; }
|
|
|
|
auto& image_provider() { return m_image_provider; }
|
2022-03-10 14:02:25 +01:00
|
|
|
|
2024-02-18 20:10:37 -05:00
|
|
|
void dom_node_did_update_alt_text(Badge<ImageProvider>);
|
2022-09-07 16:46:05 +02:00
|
|
|
|
2019-10-05 22:07:45 +02:00
|
|
|
private:
|
2024-02-26 17:36:48 +01:00
|
|
|
virtual void visit_edges(Visitor&) override;
|
|
|
|
|
2023-05-12 07:17:01 +02:00
|
|
|
ImageProvider const& m_image_provider;
|
2022-09-07 16:46:05 +02:00
|
|
|
|
2022-11-04 20:54:05 +00:00
|
|
|
Optional<CSSPixels> m_cached_alt_text_width;
|
2019-10-05 22:07:45 +02:00
|
|
|
};
|
2019-12-18 20:52:36 +01:00
|
|
|
|
|
|
|
}
|