HTMLImageElement.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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(DeprecatedFlyString const& name, DeprecatedString const& value) override;
  22. DeprecatedString alt() const { return attribute(HTML::AttributeNames::alt); }
  23. DeprecatedString 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. // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-complete
  32. bool complete() const;
  33. virtual Optional<ARIA::Role> default_role() const override;
  34. private:
  35. HTMLImageElement(DOM::Document&, DOM::QualifiedName);
  36. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  37. virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
  38. virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  39. ImageLoader m_image_loader;
  40. };
  41. }