summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2020-12-05 20:10:02 +0100
committerAndreas Kling <kling@serenityos.org>2020-12-05 22:51:03 +0100
commit11256de366eb7d882e91ac46bcc535511d54fdde (patch)
tree4ce64700f11f01c4fba3c97782b2d7683f5484cd
parentcc14b5a6d7b68375e9d912c11902d67f16f5efbf (diff)
downloadserenity-11256de366eb7d882e91ac46bcc535511d54fdde.zip
LibWeb: Add Layout::Node::is_root_element()
This returns true if the layout node corresponds to the <html> element.
-rw-r--r--Libraries/LibWeb/Layout/Node.cpp8
-rw-r--r--Libraries/LibWeb/Layout/Node.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/Libraries/LibWeb/Layout/Node.cpp b/Libraries/LibWeb/Layout/Node.cpp
index a5c36137e6..a7eafcef39 100644
--- a/Libraries/LibWeb/Layout/Node.cpp
+++ b/Libraries/LibWeb/Layout/Node.cpp
@@ -28,6 +28,7 @@
#include <LibWeb/DOM/Document.h>
#include <LibWeb/DOM/Element.h>
#include <LibWeb/Dump.h>
+#include <LibWeb/HTML/HTMLHtmlElement.h>
#include <LibWeb/Layout/BlockBox.h>
#include <LibWeb/Layout/InitialContainingBlockBox.h>
#include <LibWeb/Layout/Node.h>
@@ -265,4 +266,11 @@ void Node::handle_mousemove(Badge<EventHandler>, const Gfx::IntPoint&, unsigned,
{
}
+bool Node::is_root_element() const
+{
+ if (is_anonymous())
+ return false;
+ return is<HTML::HTMLHtmlElement>(*dom_node());
+}
+
}
diff --git a/Libraries/LibWeb/Layout/Node.h b/Libraries/LibWeb/Layout/Node.h
index c0244d2316..90121e7621 100644
--- a/Libraries/LibWeb/Layout/Node.h
+++ b/Libraries/LibWeb/Layout/Node.h
@@ -91,6 +91,8 @@ public:
const InitialContainingBlockBox& root() const;
InitialContainingBlockBox& root();
+ bool is_root_element() const;
+
virtual const char* class_name() const = 0;
virtual bool is_initial_containing_block() const { return false; }
virtual bool is_text() const { return false; }