Serenity Operating System
1/*
2 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
3 *
4 * SPDX-License-Identifier: BSD-2-Clause
5 */
6
7#pragma once
8
9#include <AK/URL.h>
10#include <LibWeb/Forward.h>
11#include <LibWeb/HTML/EventLoop/Task.h>
12
13namespace Web::HTML {
14
15class HTMLHyperlinkElementUtils {
16public:
17 virtual ~HTMLHyperlinkElementUtils();
18
19 DeprecatedString origin() const;
20
21 DeprecatedString href() const;
22 void set_href(DeprecatedString);
23
24 DeprecatedString protocol() const;
25 void set_protocol(DeprecatedString);
26
27 DeprecatedString username() const;
28 void set_username(DeprecatedString);
29
30 DeprecatedString password() const;
31 void set_password(DeprecatedString);
32
33 DeprecatedString host() const;
34 void set_host(DeprecatedString);
35
36 DeprecatedString hostname() const;
37 void set_hostname(DeprecatedString);
38
39 DeprecatedString port() const;
40 void set_port(DeprecatedString);
41
42 DeprecatedString pathname() const;
43 void set_pathname(DeprecatedString);
44
45 DeprecatedString search() const;
46 void set_search(DeprecatedString);
47
48 DeprecatedString hash() const;
49 void set_hash(DeprecatedString);
50
51protected:
52 virtual DOM::Document& hyperlink_element_utils_document() = 0;
53 virtual DeprecatedString hyperlink_element_utils_href() const = 0;
54 virtual void set_hyperlink_element_utils_href(DeprecatedString) = 0;
55 virtual bool hyperlink_element_utils_is_html_anchor_element() const = 0;
56 virtual bool hyperlink_element_utils_is_connected() const = 0;
57 virtual DeprecatedString hyperlink_element_utils_target() const = 0;
58 virtual DeprecatedString hyperlink_element_utils_rel() const = 0;
59 virtual void hyperlink_element_utils_queue_an_element_task(HTML::Task::Source source, Function<void()> steps) = 0;
60
61 void set_the_url();
62 void follow_the_hyperlink(Optional<DeprecatedString> hyperlink_suffix);
63
64private:
65 void reinitialize_url() const;
66 void update_href();
67 bool cannot_navigate() const;
68 DeprecatedString get_an_elements_target() const;
69 bool get_an_elements_noopener(StringView target) const;
70
71 Optional<AK::URL> m_url;
72};
73
74}