/src/serenity/Userland/Libraries/LibWeb/HTML/HTMLObjectElement.h
Line | Count | Source (jump to first uncovered line) |
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/FormAssociatedElement.h> |
12 | | #include <LibWeb/HTML/HTMLElement.h> |
13 | | #include <LibWeb/HTML/NavigableContainer.h> |
14 | | #include <LibWeb/Layout/ImageProvider.h> |
15 | | #include <LibWeb/Loader/Resource.h> |
16 | | |
17 | | namespace Web::HTML { |
18 | | |
19 | | class HTMLObjectElement final |
20 | | : public NavigableContainer |
21 | | , public FormAssociatedElement |
22 | | , public ResourceClient |
23 | | , public Layout::ImageProvider { |
24 | | WEB_PLATFORM_OBJECT(HTMLObjectElement, NavigableContainer) |
25 | | JS_DECLARE_ALLOCATOR(HTMLObjectElement); |
26 | | FORM_ASSOCIATED_ELEMENT(NavigableContainer, HTMLObjectElement) |
27 | | |
28 | | enum class Representation { |
29 | | Unknown, |
30 | | Image, |
31 | | NestedBrowsingContext, |
32 | | Children, |
33 | | }; |
34 | | |
35 | | public: |
36 | | virtual ~HTMLObjectElement() override; |
37 | | |
38 | | virtual void form_associated_element_attribute_changed(FlyString const& name, Optional<String> const& value) override; |
39 | | virtual void form_associated_element_was_removed(DOM::Node*) override; |
40 | | |
41 | | String data() const; |
42 | 0 | void set_data(String const& data) { MUST(set_attribute(HTML::AttributeNames::data, data)); } |
43 | | |
44 | 0 | String type() const { return get_attribute_value(HTML::AttributeNames::type); } |
45 | | |
46 | | // ^FormAssociatedElement |
47 | | // https://html.spec.whatwg.org/multipage/forms.html#category-listed |
48 | 0 | virtual bool is_listed() const override { return true; } |
49 | | |
50 | | virtual void visit_edges(Cell::Visitor&) override; |
51 | | |
52 | | private: |
53 | | HTMLObjectElement(DOM::Document&, DOM::QualifiedName); |
54 | | |
55 | 0 | virtual bool is_html_object_element() const override { return true; } |
56 | | |
57 | | virtual void initialize(JS::Realm&) override; |
58 | | |
59 | | virtual void apply_presentational_hints(CSS::StyleProperties&) const override; |
60 | | |
61 | | virtual JS::GCPtr<Layout::Node> create_layout_node(NonnullRefPtr<CSS::StyleProperties>) override; |
62 | | |
63 | | bool has_ancestor_media_element_or_object_element_not_showing_fallback_content() const; |
64 | | |
65 | | void queue_element_task_to_run_object_representation_steps(); |
66 | | void run_object_representation_handler_steps(Optional<ByteString> resource_type); |
67 | | void run_object_representation_completed_steps(Representation); |
68 | | void run_object_representation_fallback_steps(); |
69 | | |
70 | | void load_image(); |
71 | | void update_layout_and_child_objects(Representation); |
72 | | |
73 | | // ^ResourceClient |
74 | | virtual void resource_did_load() override; |
75 | | virtual void resource_did_fail() override; |
76 | | |
77 | | // ^DOM::Element |
78 | | virtual i32 default_tab_index_value() const override; |
79 | | |
80 | | // ^Layout::ImageProvider |
81 | | virtual bool is_image_available() const override; |
82 | | virtual Optional<CSSPixels> intrinsic_width() const override; |
83 | | virtual Optional<CSSPixels> intrinsic_height() const override; |
84 | | virtual Optional<CSSPixelFraction> intrinsic_aspect_ratio() const override; |
85 | | virtual RefPtr<Gfx::ImmutableBitmap> current_image_bitmap(Gfx::IntSize = {}) const override; |
86 | | virtual void set_visible_in_viewport(bool) override; |
87 | 0 | virtual JS::NonnullGCPtr<DOM::Element const> to_html_element() const override { return *this; } |
88 | | |
89 | | Representation m_representation { Representation::Unknown }; |
90 | | |
91 | | JS::GCPtr<DecodedImageData> image_data() const; |
92 | | |
93 | | JS::GCPtr<SharedResourceRequest> m_resource_request; |
94 | | }; |
95 | | |
96 | | } |
97 | | |
98 | | namespace Web::DOM { |
99 | | template<> |
100 | 0 | inline bool Node::fast_is<HTML::HTMLObjectElement>() const { return is_html_object_element(); } |
101 | | } |