HTMLImageElement.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/ByteBuffer.h>
  8. #include <AK/OwnPtr.h>
  9. #include <LibGfx/Forward.h>
  10. #include <LibWeb/HTML/FormAssociatedElement.h>
  11. #include <LibWeb/HTML/HTMLElement.h>
  12. #include <LibWeb/Loader/ImageLoader.h>
  13. namespace Web::HTML {
  14. class HTMLImageElement final
  15. : public HTMLElement
  16. , public FormAssociatedElement {
  17. WEB_PLATFORM_OBJECT(HTMLImageElement, HTMLElement);
  18. FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLImageElement)
  19. public:
  20. virtual ~HTMLImageElement() override;
  21. virtual void parse_attribute(FlyString const& name, String const& value) override;
  22. String alt() const { return attribute(HTML::AttributeNames::alt); }
  23. String src() const { return attribute(HTML::AttributeNames::src); }
  24. Gfx::Bitmap const* bitmap() const;
  25. unsigned width() const;
  26. void set_width(unsigned);
  27. unsigned height() const;
  28. void set_height(unsigned);
  29. unsigned natural_width() const;
  30. unsigned natural_height() const;
  31. private:
  32. HTMLImageElement(DOM::Document&, DOM::QualifiedName);
  33. virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
  34. void animate();
  35. virtual RefPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  36. ImageLoader m_image_loader;
  37. };
  38. }
  39. WRAPPER_HACK(HTMLImageElement, Web::HTML)