HTMLImageElement.h 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLImageElement)
  18. public:
  19. using WrapperType = Bindings::HTMLImageElementWrapper;
  20. HTMLImageElement(DOM::Document&, DOM::QualifiedName);
  21. virtual ~HTMLImageElement() override;
  22. virtual void parse_attribute(FlyString const& name, String const& value) override;
  23. String alt() const { return attribute(HTML::AttributeNames::alt); }
  24. String src() const { return attribute(HTML::AttributeNames::src); }
  25. Gfx::Bitmap const* bitmap() const;
  26. unsigned width() const;
  27. void set_width(unsigned);
  28. unsigned height() const;
  29. void set_height(unsigned);
  30. unsigned natural_width() const;
  31. unsigned natural_height() const;
  32. private:
  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. }