/src/serenity/Userland/Libraries/LibWeb/HTML/HTMLTitleElement.cpp
Line | Count | Source |
1 | | /* |
2 | | * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org> |
3 | | * |
4 | | * SPDX-License-Identifier: BSD-2-Clause |
5 | | */ |
6 | | |
7 | | #include <LibWeb/Bindings/HTMLTitleElementPrototype.h> |
8 | | #include <LibWeb/DOM/Document.h> |
9 | | #include <LibWeb/HTML/HTMLTitleElement.h> |
10 | | #include <LibWeb/HTML/TraversableNavigable.h> |
11 | | #include <LibWeb/Page/Page.h> |
12 | | |
13 | | namespace Web::HTML { |
14 | | |
15 | | JS_DEFINE_ALLOCATOR(HTMLTitleElement); |
16 | | |
17 | | HTMLTitleElement::HTMLTitleElement(DOM::Document& document, DOM::QualifiedName qualified_name) |
18 | 0 | : HTMLElement(document, move(qualified_name)) |
19 | 0 | { |
20 | 0 | } |
21 | | |
22 | 0 | HTMLTitleElement::~HTMLTitleElement() = default; |
23 | | |
24 | | void HTMLTitleElement::initialize(JS::Realm& realm) |
25 | 0 | { |
26 | 0 | Base::initialize(realm); |
27 | 0 | WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLTitleElement); |
28 | 0 | } |
29 | | |
30 | | void HTMLTitleElement::children_changed() |
31 | 0 | { |
32 | 0 | HTMLElement::children_changed(); |
33 | 0 | auto navigable = this->navigable(); |
34 | 0 | if (navigable && navigable->is_traversable()) { |
35 | 0 | navigable->traversable_navigable()->page().client().page_did_change_title(document().title().to_byte_string()); |
36 | 0 | } |
37 | 0 | } |
38 | | |
39 | | // https://html.spec.whatwg.org/multipage/semantics.html#dom-title-text |
40 | | String HTMLTitleElement::text() const |
41 | 0 | { |
42 | | // The text attribute's getter must return this title element's child text content. |
43 | 0 | return child_text_content(); |
44 | 0 | } |
45 | | |
46 | | // https://html.spec.whatwg.org/multipage/semantics.html#dom-title-text |
47 | | void HTMLTitleElement::set_text(String const& value) |
48 | 0 | { |
49 | | // The text attribute's setter must string replace all with the given value within this title element. |
50 | 0 | string_replace_all(value); |
51 | 0 | } |
52 | | |
53 | | } |