ImageBox.h 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <andreas@ladybird.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <LibWeb/HTML/HTMLImageElement.h>
  8. #include <LibWeb/Layout/ReplacedBox.h>
  9. namespace Web::Layout {
  10. class ImageBox final : public ReplacedBox {
  11. JS_CELL(ImageBox, ReplacedBox);
  12. JS_DECLARE_ALLOCATOR(ImageBox);
  13. public:
  14. ImageBox(DOM::Document&, DOM::Element&, CSS::StyleProperties, ImageProvider const&);
  15. virtual ~ImageBox() override;
  16. virtual void prepare_for_replaced_layout() override;
  17. const DOM::Element& dom_node() const { return static_cast<const DOM::Element&>(ReplacedBox::dom_node()); }
  18. bool renders_as_alt_text() const;
  19. virtual JS::GCPtr<Painting::Paintable> create_paintable() const override;
  20. auto const& image_provider() const { return m_image_provider; }
  21. auto& image_provider() { return m_image_provider; }
  22. void dom_node_did_update_alt_text(Badge<ImageProvider>);
  23. private:
  24. virtual void visit_edges(Visitor&) override;
  25. ImageProvider const& m_image_provider;
  26. Optional<CSSPixels> m_cached_alt_text_width;
  27. };
  28. }