Serenity Operating System
at master 59 lines 1.7 kB view raw
1/* 2 * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <AK/ByteBuffer.h> 10#include <AK/OwnPtr.h> 11#include <LibGfx/Forward.h> 12#include <LibWeb/HTML/FormAssociatedElement.h> 13#include <LibWeb/HTML/HTMLElement.h> 14#include <LibWeb/Loader/ImageLoader.h> 15 16namespace Web::HTML { 17 18class HTMLImageElement final 19 : public HTMLElement 20 , public FormAssociatedElement { 21 WEB_PLATFORM_OBJECT(HTMLImageElement, HTMLElement); 22 FORM_ASSOCIATED_ELEMENT(HTMLElement, HTMLImageElement) 23 24public: 25 virtual ~HTMLImageElement() override; 26 27 virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; 28 29 DeprecatedString alt() const { return attribute(HTML::AttributeNames::alt); } 30 DeprecatedString src() const { return attribute(HTML::AttributeNames::src); } 31 32 Gfx::Bitmap const* bitmap() const; 33 34 unsigned width() const; 35 void set_width(unsigned); 36 37 unsigned height() const; 38 void set_height(unsigned); 39 40 unsigned natural_width() const; 41 unsigned natural_height() const; 42 43 // https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-complete 44 bool complete() const; 45 46 virtual Optional<ARIA::Role> default_role() const override; 47 48private: 49 HTMLImageElement(DOM::Document&, DOM::QualifiedName); 50 51 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; 52 virtual void apply_presentational_hints(CSS::StyleProperties&) const override; 53 54 virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; 55 56 ImageLoader m_image_loader; 57}; 58 59}