mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 06:27:35 +00:00
LibWeb: Move has_a_rendering_opportunity() to Navigable
This commit is contained in:
parent
a02d42dea2
commit
93e4a0de16
5 changed files with 24 additions and 14 deletions
|
@ -466,16 +466,6 @@ bool BrowsingContext::decrement_cursor_position_offset()
|
||||||
return true;
|
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
|
// https://html.spec.whatwg.org/multipage/interaction.html#currently-focused-area-of-a-top-level-browsing-context
|
||||||
JS::GCPtr<DOM::Node> BrowsingContext::currently_focused_area()
|
JS::GCPtr<DOM::Node> BrowsingContext::currently_focused_area()
|
||||||
{
|
{
|
||||||
|
|
|
@ -170,8 +170,6 @@ public:
|
||||||
|
|
||||||
void did_edit(Badge<EditEventHandler>);
|
void did_edit(Badge<EditEventHandler>);
|
||||||
|
|
||||||
bool has_a_rendering_opportunity() const;
|
|
||||||
|
|
||||||
JS::GCPtr<DOM::Node> currently_focused_area();
|
JS::GCPtr<DOM::Node> currently_focused_area();
|
||||||
|
|
||||||
Vector<JS::NonnullGCPtr<SessionHistoryEntry>>& session_history() { return m_session_history; }
|
Vector<JS::NonnullGCPtr<SessionHistoryEntry>>& session_history() { return m_session_history; }
|
||||||
|
|
|
@ -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) {
|
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
|
// 3. If docs is not empty, then set hasARenderingOpportunity to true
|
||||||
|
|
|
@ -1652,4 +1652,23 @@ void Navigable::set_needs_display(CSSPixelRect const& rect)
|
||||||
container()->layout_node()->set_needs_display();
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -151,6 +151,9 @@ public:
|
||||||
|
|
||||||
void set_is_popup(TokenizedFeature::Popup is_popup) { m_is_popup = is_popup; }
|
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:
|
protected:
|
||||||
Navigable();
|
Navigable();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue