summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/HTMLHyperlinkElementUtils.h
blob: f11098c2797e9c8d0c6942a056b45d415c82a4f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*
 * Copyright (c) 2021, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <AK/URL.h>
#include <LibWeb/Forward.h>
#include <LibWeb/HTML/EventLoop/Task.h>

namespace Web::HTML {

class HTMLHyperlinkElementUtils {
public:
    virtual ~HTMLHyperlinkElementUtils();

    DeprecatedString origin() const;

    DeprecatedString href() const;
    void set_href(DeprecatedString);

    DeprecatedString protocol() const;
    void set_protocol(DeprecatedString);

    DeprecatedString username() const;
    void set_username(DeprecatedString);

    DeprecatedString password() const;
    void set_password(DeprecatedString);

    DeprecatedString host() const;
    void set_host(DeprecatedString);

    DeprecatedString hostname() const;
    void set_hostname(DeprecatedString);

    DeprecatedString port() const;
    void set_port(DeprecatedString);

    DeprecatedString pathname() const;
    void set_pathname(DeprecatedString);

    DeprecatedString search() const;
    void set_search(DeprecatedString);

    DeprecatedString hash() const;
    void set_hash(DeprecatedString);

protected:
    virtual DOM::Document& hyperlink_element_utils_document() = 0;
    virtual DeprecatedString hyperlink_element_utils_href() const = 0;
    virtual void set_hyperlink_element_utils_href(DeprecatedString) = 0;
    virtual bool hyperlink_element_utils_is_html_anchor_element() const = 0;
    virtual bool hyperlink_element_utils_is_connected() const = 0;
    virtual DeprecatedString hyperlink_element_utils_target() const = 0;
    virtual DeprecatedString hyperlink_element_utils_rel() const = 0;
    virtual void hyperlink_element_utils_queue_an_element_task(HTML::Task::Source source, Function<void()> steps) = 0;

    void set_the_url();
    void follow_the_hyperlink(Optional<DeprecatedString> hyperlink_suffix);

private:
    void reinitialize_url() const;
    void update_href();
    bool cannot_navigate() const;
    DeprecatedString get_an_elements_target() const;
    bool get_an_elements_noopener(StringView target) const;

    Optional<AK::URL> m_url;
};

}