summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke <luke.wilde@live.co.uk>2021-05-07 00:53:22 +0100
committerAndreas Kling <kling@serenityos.org>2021-05-07 08:53:37 +0200
commitb6004a4ce1af1b03718ce836df75e529f86de9c8 (patch)
tree5ed40a6b628ce8ae558a5ae6f943e9241a18e11d
parent46f2c278b02adc99833c089f0d639fcbe8a50bc4 (diff)
downloadserenity-b6004a4ce1af1b03718ce836df75e529f86de9c8.zip
LibWeb: Add non-const variants of Document::{html_element,body,head}()
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp6
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.h22
2 files changed, 22 insertions, 6 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index 67066f2729..0f652e69a3 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -184,7 +184,7 @@ const Element* Document::document_element() const
return first_child_of_type<Element>();
}
-const HTML::HTMLHtmlElement* Document::html_element() const
+HTML::HTMLHtmlElement* Document::html_element()
{
auto* html = document_element();
if (is<HTML::HTMLHtmlElement>(html))
@@ -192,7 +192,7 @@ const HTML::HTMLHtmlElement* Document::html_element() const
return nullptr;
}
-const HTML::HTMLHeadElement* Document::head() const
+HTML::HTMLHeadElement* Document::head()
{
auto* html = html_element();
if (!html)
@@ -200,7 +200,7 @@ const HTML::HTMLHeadElement* Document::head() const
return html->first_child_of_type<HTML::HTMLHeadElement>();
}
-const HTML::HTMLElement* Document::body() const
+HTML::HTMLElement* Document::body()
{
auto* html = html_element();
if (!html)
diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h
index d31c43a036..43195032d7 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.h
+++ b/Userland/Libraries/LibWeb/DOM/Document.h
@@ -91,9 +91,25 @@ public:
Element* document_element();
const Element* document_element() const;
- const HTML::HTMLHtmlElement* html_element() const;
- const HTML::HTMLHeadElement* head() const;
- const HTML::HTMLElement* body() const;
+ HTML::HTMLHtmlElement* html_element();
+ HTML::HTMLHeadElement* head();
+ HTML::HTMLElement* body();
+
+ const HTML::HTMLHtmlElement* html_element() const
+ {
+ return const_cast<Document*>(this)->html_element();
+ }
+
+ const HTML::HTMLHeadElement* head() const
+ {
+ return const_cast<Document*>(this)->head();
+ }
+
+ const HTML::HTMLElement* body() const
+ {
+ return const_cast<Document*>(this)->body();
+ }
+
ExceptionOr<void> set_body(HTML::HTMLElement& new_body);
String title() const;