summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorLinus Groh <mail@linusgroh.de>2022-03-30 22:28:28 +0100
committerAndreas Kling <kling@serenityos.org>2022-03-31 17:08:38 +0200
commitf60a2a1d8008dfbcdea3ace4978d79b49edf8672 (patch)
tree96618b744896ac9b25fbdf21ef16584d0a016364 /Userland/Libraries/LibWeb
parentc79e4961f6b30ba28d7db4cf189bc1ae1fb12c3d (diff)
downloadserenity-f60a2a1d8008dfbcdea3ace4978d79b49edf8672.zip
LibWeb: Remove Document::is_scripting_enabled() and use Node's
There's no need to have a custom is_scripting_enabled() for the Document class, as it (indirectly) inherits from Node. Also, let's not hardcode false here :^)
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.h2
-rw-r--r--Userland/Libraries/LibWeb/DOM/Node.cpp12
-rw-r--r--Userland/Libraries/LibWeb/DOM/Node.h1
3 files changed, 11 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h
index dc6211beed..341781f95f 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.h
+++ b/Userland/Libraries/LibWeb/DOM/Document.h
@@ -70,8 +70,6 @@ public:
Origin origin() const;
void set_origin(const Origin& origin);
- bool is_scripting_enabled() const { return true; }
-
AK::URL parse_url(String const&) const;
CSS::StyleComputer& style_computer() { return *m_style_computer; }
diff --git a/Userland/Libraries/LibWeb/DOM/Node.cpp b/Userland/Libraries/LibWeb/DOM/Node.cpp
index 891323d018..96af914100 100644
--- a/Userland/Libraries/LibWeb/DOM/Node.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Node.cpp
@@ -843,11 +843,19 @@ void Node::serialize_tree_as_json(JsonObjectSerializer<StringBuilder>& object) c
}
}
+// https://html.spec.whatwg.org/multipage/webappapis.html#concept-n-script
+bool Node::is_scripting_enabled() const
+{
+ // Scripting is enabled for a node node if node's node document's browsing context is non-null, and scripting is enabled for node's relevant settings object.
+ // FIXME: Check if scripting is enabled for the ESO.
+ return document().browsing_context();
+}
+
// https://html.spec.whatwg.org/multipage/webappapis.html#concept-n-noscript
bool Node::is_scripting_disabled() const
{
- // FIXME: or when scripting is disabled for its relevant settings object.
- return !document().browsing_context();
+ // Scripting is disabled for a node when scripting is not enabled, i.e., when its node document's browsing context is null or when scripting is disabled for its relevant settings object.
+ return !is_scripting_enabled();
}
// https://dom.spec.whatwg.org/#dom-node-contains
diff --git a/Userland/Libraries/LibWeb/DOM/Node.h b/Userland/Libraries/LibWeb/DOM/Node.h
index 4af2f3f720..44d63efb96 100644
--- a/Userland/Libraries/LibWeb/DOM/Node.h
+++ b/Userland/Libraries/LibWeb/DOM/Node.h
@@ -188,6 +188,7 @@ public:
bool is_host_including_inclusive_ancestor_of(const Node&) const;
+ bool is_scripting_enabled() const;
bool is_scripting_disabled() const;
bool contains(RefPtr<Node>) const;