summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/HTML/HTMLBaseElement.h
blob: f32b9f5b6b3013c450e24f577df9c75200879f9b (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
/*
 * Copyright (c) 2020, the SerenityOS developers.
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include <LibWeb/HTML/HTMLElement.h>

namespace Web::HTML {

class HTMLBaseElement final : public HTMLElement {
    WEB_PLATFORM_OBJECT(HTMLBaseElement, HTMLElement);

public:
    virtual ~HTMLBaseElement() override;

    String href() const;
    void set_href(String const& href);

    AK::URL const& frozen_base_url() const { return m_frozen_base_url; }

    virtual void inserted() override;
    virtual void parse_attribute(FlyString const& name, String const& value) override;

private:
    HTMLBaseElement(DOM::Document&, DOM::QualifiedName);

    virtual bool is_html_base_element() const override { return true; }

    // https://html.spec.whatwg.org/multipage/semantics.html#frozen-base-url
    // A base element that is the first base element with an href content attribute in a document tree has a frozen base URL.
    AK::URL m_frozen_base_url;

    void set_the_frozen_base_url();
};

}

namespace Web::DOM {
template<>
inline bool Node::fast_is<HTML::HTMLBaseElement>() const { return is_html_base_element(); }
}

WRAPPER_HACK(HTMLBaseElement, Web::HTML)