HTMLImageElement.h 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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/DOM/DocumentLoadEventDelayer.h>
  11. #include <LibWeb/HTML/FormAssociatedElement.h>
  12. #include <LibWeb/HTML/HTMLElement.h>
  13. #include <LibWeb/Loader/ImageLoader.h>
  14. namespace Web::HTML {
  15. class HTMLImageElement final
  16. : public HTMLElement
  17. , public FormAssociatedElement {
  18. WEB_PLATFORM_OBJECT(HTMLImageElement, HTMLElement);
  19. FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLImageElement)
  20. public:
  21. virtual ~HTMLImageElement() override;
  22. virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override;
  23. DeprecatedString alt() const { return attribute(HTML::AttributeNames::alt); }
  24. DeprecatedString 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. // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-complete
  33. bool complete() const;
  34. virtual Optional<ARIA::Role> default_role() const override;
  35. private:
  36. HTMLImageElement(DOM::Document&, DOM::QualifiedName);
  37. virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override;
  38. virtual void apply_presentational_hints(CSS::StyleProperties&) const override;
  39. virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override;
  40. ImageLoader m_image_loader;
  41. Optional<DOM::DocumentLoadEventDelayer> m_load_event_delayer;
  42. };
  43. }