/src/serenity/Userland/Libraries/LibWeb/HTML/NavigationDestination.h
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Copyright (c) 2023, Andrew Kaster <akaster@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #pragma once |
8 | | |
9 | | #include <LibURL/URL.h> |
10 | | #include <LibWeb/Bindings/PlatformObject.h> |
11 | | #include <LibWeb/HTML/StructuredSerialize.h> |
12 | | |
13 | | namespace Web::HTML { |
14 | | |
15 | | // https://html.spec.whatwg.org/multipage/nav-history-apis.html#navigationdestination |
16 | | class NavigationDestination : public Bindings::PlatformObject { |
17 | | WEB_PLATFORM_OBJECT(NavigationDestination, Bindings::PlatformObject); |
18 | | JS_DECLARE_ALLOCATOR(NavigationDestination); |
19 | | |
20 | | public: |
21 | | [[nodiscard]] static JS::NonnullGCPtr<NavigationDestination> create(JS::Realm&); |
22 | | |
23 | | WebIDL::ExceptionOr<String> url() const; |
24 | | String key() const; |
25 | | String id() const; |
26 | | i64 index() const; |
27 | | bool same_document() const; |
28 | | WebIDL::ExceptionOr<JS::Value> get_state(); |
29 | | |
30 | | // Non-spec'd getter, not exposed to JS |
31 | 0 | JS::GCPtr<NavigationHistoryEntry> navigation_history_entry() const { return m_entry; } |
32 | | |
33 | | // Setters are not available to JS, but expected in many spec algorithms |
34 | 0 | void set_url(URL::URL const& url) { m_url = url; } |
35 | 0 | void set_entry(JS::GCPtr<NavigationHistoryEntry> entry) { m_entry = entry; } |
36 | 0 | void set_state(SerializationRecord state) { m_state = move(state); } |
37 | 0 | void set_is_same_document(bool b) { m_is_same_document = b; } |
38 | | |
39 | | virtual ~NavigationDestination() override; |
40 | | |
41 | 0 | URL::URL const& raw_url() const { return m_url; } |
42 | | |
43 | | private: |
44 | | NavigationDestination(JS::Realm&); |
45 | | |
46 | | virtual void initialize(JS::Realm&) override; |
47 | | virtual void visit_edges(JS::Cell::Visitor&) override; |
48 | | |
49 | | // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationdestination-url |
50 | | URL::URL m_url; |
51 | | |
52 | | // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationdestination-url |
53 | | JS::GCPtr<NavigationHistoryEntry> m_entry; |
54 | | |
55 | | // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationdestination-state |
56 | | SerializationRecord m_state; |
57 | | |
58 | | // https://html.spec.whatwg.org/multipage/nav-history-apis.html#concept-navigationdestination-samedocument |
59 | | bool m_is_same_document { false }; |
60 | | }; |
61 | | |
62 | | } |