summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibWeb/Layout/Node.cpp
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2023-03-18 12:09:22 +0100
committerAndreas Kling <kling@serenityos.org>2023-03-18 16:34:41 +0100
commit8b177a6da5b96b051ee65a264207cf9e8479e264 (patch)
tree33150d177e82a57068fc2a510cd4cb4188001661 /Userland/Libraries/LibWeb/Layout/Node.cpp
parent8169b878f839a2745ffd938945065ef7f30b1291 (diff)
downloadserenity-8b177a6da5b96b051ee65a264207cf9e8479e264.zip
LibWeb: Clarify stacking context creation for viewport box
Explicitly check is_viewport() instead of looking at the corresponding DOM node. (The viewport has the DOM document as its DOM node, but that's not obvious from context here.)
Diffstat (limited to 'Userland/Libraries/LibWeb/Layout/Node.cpp')
-rw-r--r--Userland/Libraries/LibWeb/Layout/Node.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp
index ca474c7441..317281516e 100644
--- a/Userland/Libraries/LibWeb/Layout/Node.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Node.cpp
@@ -117,8 +117,15 @@ bool Node::establishes_stacking_context() const
if (!has_style())
return false;
- if (is_root_element() || dom_node() == &document().root())
+
+ // We make a stacking context for the viewport. Painting and hit testing starts from here.
+ if (is_viewport())
+ return true;
+
+ // Root element of the document (<html>).
+ if (is_root_element())
return true;
+
auto position = computed_values().position();
// Element with a position value absolute or relative and z-index value other than auto.