summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2022-03-01 21:17:53 +0000
committerLinus Groh <mail@linusgroh.de>2022-03-01 21:21:42 +0000
commit0f660760edf8dce27e13c271a4f4abde9ffc5c1c (patch)
tree7ec07843ae6015d620d02e75138c360268b1b4d1 /Userland/Libraries/LibWeb
parentf0ac1bcaf80394e0fe6b7ab7a5e36ec8ed955018 (diff)
downloadserenity-0f660760edf8dce27e13c271a4f4abde9ffc5c1c.zip
LibWeb: Fix incorrect check in BrowsingContext::is_top_level
A top level browsing context is a browsing context with no parent browsing context. However, we considered a top level browsing context to be a browsing context with no associated browsing context container.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp7
-rw-r--r--Userland/Libraries/LibWeb/HTML/BrowsingContext.h2
2 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
index 668a0b1868..1d0ca9d25f 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
@@ -57,6 +57,13 @@ void BrowsingContext::reset_cursor_blink_cycle()
m_cursor_position.node()->layout_node()->set_needs_display();
}
+// https://html.spec.whatwg.org/multipage/browsers.html#top-level-browsing-context
+bool BrowsingContext::is_top_level() const
+{
+ // A browsing context that has no parent browsing context is the top-level browsing context for itself and all of the browsing contexts for which it is an ancestor browsing context.
+ return !parent();
+}
+
bool BrowsingContext::is_focused_context() const
{
return m_page && &m_page->focused_context() == this;
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
index bcb621a3a1..067303e2be 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
@@ -36,7 +36,7 @@ public:
void register_viewport_client(ViewportClient&);
void unregister_viewport_client(ViewportClient&);
- bool is_top_level() const { return !container(); }
+ bool is_top_level() const;
bool is_focused_context() const;
DOM::Document const* active_document() const { return m_active_document; }