/src/serenity/Userland/Libraries/LibWeb/HTML/NavigableContainer.h
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibWeb/HTML/HTMLElement.h> |
10 | | #include <LibWeb/HTML/Navigable.h> |
11 | | |
12 | | namespace Web::HTML { |
13 | | |
14 | | class NavigableContainer : public HTMLElement { |
15 | | WEB_PLATFORM_OBJECT(NavigableContainer, HTMLElement); |
16 | | |
17 | | public: |
18 | | static JS::GCPtr<NavigableContainer> navigable_container_with_content_navigable(JS::NonnullGCPtr<Navigable> navigable); |
19 | | |
20 | | virtual ~NavigableContainer() override; |
21 | | |
22 | | static HashTable<NavigableContainer*>& all_instances(); |
23 | | |
24 | 0 | JS::GCPtr<Navigable> content_navigable() { return m_content_navigable; } |
25 | 0 | JS::GCPtr<Navigable const> content_navigable() const { return m_content_navigable.ptr(); } |
26 | | |
27 | | BrowsingContext* nested_browsing_context() |
28 | 0 | { |
29 | 0 | if (m_content_navigable) |
30 | 0 | return m_content_navigable->active_browsing_context(); |
31 | 0 | return nullptr; |
32 | 0 | } |
33 | | BrowsingContext const* nested_browsing_context() const |
34 | 0 | { |
35 | 0 | if (m_content_navigable) |
36 | 0 | return m_content_navigable->active_browsing_context(); |
37 | 0 | return nullptr; |
38 | 0 | } |
39 | | |
40 | | const DOM::Document* content_document() const; |
41 | | DOM::Document const* content_document_without_origin_check() const; |
42 | | |
43 | | HTML::WindowProxy* content_window(); |
44 | | |
45 | | DOM::Document const* get_svg_document() const; |
46 | | |
47 | | void destroy_the_child_navigable(); |
48 | | |
49 | | // All elements that extend NavigableContainer "potentially delay the load event". |
50 | | // (embed, frame, iframe, and object) |
51 | | // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#potentially-delays-the-load-event |
52 | | bool currently_delays_the_load_event() const; |
53 | | |
54 | 0 | bool content_navigable_initialized() const { return m_content_navigable_initialized; } |
55 | | |
56 | | protected: |
57 | | NavigableContainer(DOM::Document&, DOM::QualifiedName); |
58 | | |
59 | | virtual void visit_edges(Cell::Visitor&) override; |
60 | | |
61 | | // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#shared-attribute-processing-steps-for-iframe-and-frame-elements |
62 | | Optional<URL::URL> shared_attribute_processing_steps_for_iframe_and_frame(bool initial_insertion); |
63 | | |
64 | | // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#navigate-an-iframe-or-frame |
65 | | void navigate_an_iframe_or_frame(URL::URL url, ReferrerPolicy::ReferrerPolicy referrer_policy, Optional<String> srcdoc_string = {}); |
66 | | |
67 | | WebIDL::ExceptionOr<void> create_new_child_navigable(JS::GCPtr<JS::HeapFunction<void()>> after_session_history_update = {}); |
68 | | |
69 | | // https://html.spec.whatwg.org/multipage/document-sequences.html#content-navigable |
70 | | JS::GCPtr<Navigable> m_content_navigable { nullptr }; |
71 | | |
72 | 0 | void set_potentially_delays_the_load_event(bool value) { m_potentially_delays_the_load_event = value; } |
73 | | |
74 | 0 | void set_content_navigable_initialized() { m_content_navigable_initialized = true; } |
75 | | |
76 | | private: |
77 | 0 | virtual bool is_navigable_container() const override { return true; } |
78 | | bool m_potentially_delays_the_load_event { true }; |
79 | | bool m_content_navigable_initialized { false }; |
80 | | }; |
81 | | |
82 | | } |
83 | | |
84 | | namespace Web::DOM { |
85 | | template<> |
86 | 0 | inline bool Node::fast_is<HTML::NavigableContainer>() const { return is_navigable_container(); } |
87 | | } |