summaryrefslogtreecommitdiff
path: root/Userland
diff options
context:
space:
mode:
authorLuke Wilde <lukew@serenityos.org>2021-09-11 23:28:41 +0100
committerAndreas Kling <kling@serenityos.org>2021-09-12 01:41:44 +0200
commit3eca8cb24353604431a1d8bfbb968f5ef218cda3 (patch)
treed40801eb99505ccb651455fbe254557e2dde213e /Userland
parentf5c988b3ce61db21d1fd59338ce5a16081a365f9 (diff)
downloadserenity-3eca8cb24353604431a1d8bfbb968f5ef218cda3.zip
LibWeb: Add Document::is_fully_active
This is used in a bunch of places in the HTML spec. The current use case for this is History.
Diffstat (limited to 'Userland')
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.cpp8
-rw-r--r--Userland/Libraries/LibWeb/DOM/Document.h2
2 files changed, 10 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/DOM/Document.cpp b/Userland/Libraries/LibWeb/DOM/Document.cpp
index 5d6fac43de..4cdc41a2a6 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.cpp
+++ b/Userland/Libraries/LibWeb/DOM/Document.cpp
@@ -970,4 +970,12 @@ String Document::referrer() const
return "";
}
+// https://html.spec.whatwg.org/multipage/browsers.html#fully-active
+bool Document::is_fully_active() const
+{
+ // A Document d is said to be fully active when d's browsing context is non-null, d's browsing context's active document is d,
+ // and either d's browsing context is a top-level browsing context, or d's browsing context's container document is fully active.
+ return browsing_context() && browsing_context()->active_document() == this && (browsing_context()->is_top_level() || browsing_context()->container_document()->is_fully_active());
+}
+
}
diff --git a/Userland/Libraries/LibWeb/DOM/Document.h b/Userland/Libraries/LibWeb/DOM/Document.h
index b9dc5ca93f..ad39329e95 100644
--- a/Userland/Libraries/LibWeb/DOM/Document.h
+++ b/Userland/Libraries/LibWeb/DOM/Document.h
@@ -274,6 +274,8 @@ public:
bool has_a_style_sheet_that_is_blocking_scripts() const;
+ bool is_fully_active() const;
+
private:
explicit Document(const URL&);