diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
index 90f9e1b514..75b5f4d759 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.cpp
@@ -466,16 +466,6 @@ bool BrowsingContext::decrement_cursor_position_offset()
return true;
}
-// https://html.spec.whatwg.org/#rendering-opportunity
-bool BrowsingContext::has_a_rendering_opportunity() const
-{
- // A browsing context has a rendering opportunity if the user agent is currently able to present the contents of the browsing context to the user,
- // accounting for hardware refresh rate constraints and user agent throttling for performance reasons, but considering content presentable even if it's outside the viewport.
-
- // FIXME: We should at the very least say `false` here if we're an inactive browser tab.
- return true;
-}
-
// https://html.spec.whatwg.org/multipage/interaction.html#currently-focused-area-of-a-top-level-browsing-context
JS::GCPtr BrowsingContext::currently_focused_area()
{
diff --git a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
index 2f2fa59f78..a2ffbebd6c 100644
--- a/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
+++ b/Userland/Libraries/LibWeb/HTML/BrowsingContext.h
@@ -170,8 +170,6 @@ public:
void did_edit(Badge);
- bool has_a_rendering_opportunity() const;
-
JS::GCPtr currently_focused_area();
Vector>& session_history() { return m_session_history; }
diff --git a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
index 6d4c0f031a..cfe60dfc01 100644
--- a/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
+++ b/Userland/Libraries/LibWeb/HTML/EventLoop/EventLoop.cpp
@@ -145,9 +145,9 @@ void EventLoop::process()
}
};
- // 2. Rendering opportunities: Remove from docs all Document objects whose browsing context do not have a rendering opportunity.
+ // 2. Rendering opportunities: Remove from docs all Document objects whose node navigables do not have a rendering opportunity.
docs.remove_all_matching([&](auto& document) {
- return document->browsing_context() && !document->browsing_context()->has_a_rendering_opportunity();
+ return document->navigable() && !document->navigable()->has_a_rendering_opportunity();
});
// 3. If docs is not empty, then set hasARenderingOpportunity to true
diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.cpp b/Userland/Libraries/LibWeb/HTML/Navigable.cpp
index a1bf8e8a84..08cd9eef3a 100644
--- a/Userland/Libraries/LibWeb/HTML/Navigable.cpp
+++ b/Userland/Libraries/LibWeb/HTML/Navigable.cpp
@@ -1652,4 +1652,23 @@ void Navigable::set_needs_display(CSSPixelRect const& rect)
container()->layout_node()->set_needs_display();
}
+// https://html.spec.whatwg.org/#rendering-opportunity
+bool Navigable::has_a_rendering_opportunity() const
+{
+ // A navigable has a rendering opportunity if the user agent is currently able to present
+ // the contents of the navigable to the user,
+ // accounting for hardware refresh rate constraints and user agent throttling for performance reasons,
+ // but considering content presentable even if it's outside the viewport.
+
+ // A navigable has no rendering opportunities if its active document is render-blocked
+ // or if it is suppressed for view transitions;
+ // otherwise, rendering opportunities are determined based on hardware constraints
+ // such as display refresh rates and other factors such as page performance
+ // or whether the document's visibility state is "visible".
+ // Rendering opportunities typically occur at regular intervals.
+
+ // FIXME: We should at the very least say `false` here if we're an inactive browser tab.
+ return true;
+}
+
}
diff --git a/Userland/Libraries/LibWeb/HTML/Navigable.h b/Userland/Libraries/LibWeb/HTML/Navigable.h
index 032273e66d..12712b7408 100644
--- a/Userland/Libraries/LibWeb/HTML/Navigable.h
+++ b/Userland/Libraries/LibWeb/HTML/Navigable.h
@@ -151,6 +151,9 @@ public:
void set_is_popup(TokenizedFeature::Popup is_popup) { m_is_popup = is_popup; }
+ // https://html.spec.whatwg.org/#rendering-opportunity
+ [[nodiscard]] bool has_a_rendering_opportunity() const;
+
protected:
Navigable();