Serenity Operating System
at master 74 lines 2.4 kB view raw
1/* 2 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org> 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <LibCore/Forward.h> 10#include <LibGfx/Forward.h> 11#include <LibWeb/HTML/BrowsingContextContainer.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 HTMLObjectElement final 19 : public BrowsingContextContainer 20 , public FormAssociatedElement 21 , public ResourceClient { 22 WEB_PLATFORM_OBJECT(HTMLObjectElement, BrowsingContextContainer) 23 FORM_ASSOCIATED_ELEMENT(BrowsingContextContainer, HTMLObjectElement) 24 25 enum class Representation { 26 Unknown, 27 Image, 28 NestedBrowsingContext, 29 Children, 30 }; 31 32public: 33 virtual ~HTMLObjectElement() override; 34 35 virtual void parse_attribute(DeprecatedFlyString const& name, DeprecatedString const& value) override; 36 37 DeprecatedString data() const; 38 void set_data(DeprecatedString const& data) { MUST(set_attribute(HTML::AttributeNames::data, data)); } 39 40 DeprecatedString type() const { return attribute(HTML::AttributeNames::type); } 41 42 // ^FormAssociatedElement 43 // https://html.spec.whatwg.org/multipage/forms.html#category-listed 44 virtual bool is_listed() const override { return true; } 45 46private: 47 HTMLObjectElement(DOM::Document&, DOM::QualifiedName); 48 49 virtual JS::ThrowCompletionOr<void> initialize(JS::Realm&) override; 50 51 virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; 52 53 bool has_ancestor_media_element_or_object_element_not_showing_fallback_content() const; 54 55 void queue_element_task_to_run_object_representation_steps(); 56 void run_object_representation_handler_steps(Optional<DeprecatedString> resource_type); 57 void run_object_representation_completed_steps(Representation); 58 void run_object_representation_fallback_steps(); 59 60 void convert_resource_to_image(); 61 void update_layout_and_child_objects(Representation); 62 63 // ^ResourceClient 64 virtual void resource_did_load() override; 65 virtual void resource_did_fail() override; 66 67 // ^DOM::Element 68 virtual i32 default_tab_index_value() const override; 69 70 Representation m_representation { Representation::Unknown }; 71 Optional<ImageLoader> m_image_loader; 72}; 73 74}