mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-09 17:49:40 +00:00
LibWeb: Make Document::m_intersection_observers a weak mapping
These registrations are not meant to keep the observers alive. This fixes a handful of world leaks on Speedometer.
This commit is contained in:
parent
6a6618f5ea
commit
b397a0d535
Notes:
github-actions[bot]
2024-11-11 20:41:59 +00:00
Author: https://github.com/awesomekling
Commit: b397a0d535
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2287
Reviewed-by: https://github.com/ADKaster
2 changed files with 10 additions and 4 deletions
|
@ -505,7 +505,6 @@ void Document::visit_edges(Cell::Visitor& visitor)
|
||||||
visitor.visit(m_document_observers);
|
visitor.visit(m_document_observers);
|
||||||
visitor.visit(m_pending_scroll_event_targets);
|
visitor.visit(m_pending_scroll_event_targets);
|
||||||
visitor.visit(m_pending_scrollend_event_targets);
|
visitor.visit(m_pending_scrollend_event_targets);
|
||||||
visitor.visit(m_intersection_observers);
|
|
||||||
visitor.visit(m_resize_observers);
|
visitor.visit(m_resize_observers);
|
||||||
|
|
||||||
visitor.visit(m_shared_resource_requests);
|
visitor.visit(m_shared_resource_requests);
|
||||||
|
@ -4037,7 +4036,14 @@ void Document::run_the_update_intersection_observations_steps(HighResolutionTime
|
||||||
// 1. Let observer list be a list of all IntersectionObservers whose root is in the DOM tree of document.
|
// 1. Let observer list be a list of all IntersectionObservers whose root is in the DOM tree of document.
|
||||||
// For the top-level browsing context, this includes implicit root observers.
|
// For the top-level browsing context, this includes implicit root observers.
|
||||||
// 2. For each observer in observer list:
|
// 2. For each observer in observer list:
|
||||||
for (auto& observer : m_intersection_observers) {
|
|
||||||
|
// NOTE: We make a copy of the intersection observers list to avoid modifying it while iterating.
|
||||||
|
JS::MarkedVector<JS::NonnullGCPtr<IntersectionObserver::IntersectionObserver>> intersection_observers(heap());
|
||||||
|
intersection_observers.ensure_capacity(m_intersection_observers.size());
|
||||||
|
for (auto& observer : m_intersection_observers)
|
||||||
|
intersection_observers.append(observer);
|
||||||
|
|
||||||
|
for (auto& observer : intersection_observers) {
|
||||||
// 1. Let rootBounds be observer’s root intersection rectangle.
|
// 1. Let rootBounds be observer’s root intersection rectangle.
|
||||||
auto root_bounds = observer->root_intersection_rectangle();
|
auto root_bounds = observer->root_intersection_rectangle();
|
||||||
|
|
||||||
|
|
|
@ -939,8 +939,8 @@ private:
|
||||||
|
|
||||||
JS::GCPtr<CSS::VisualViewport> m_visual_viewport;
|
JS::GCPtr<CSS::VisualViewport> m_visual_viewport;
|
||||||
|
|
||||||
// NOTE: Not in the spec per say, but Document must be able to access all IntersectionObservers whose root is in the document.
|
// NOTE: Not in the spec per se, but Document must be able to access all IntersectionObservers whose root is in the document.
|
||||||
OrderedHashTable<JS::NonnullGCPtr<IntersectionObserver::IntersectionObserver>> m_intersection_observers;
|
IGNORE_GC OrderedHashTable<JS::NonnullGCPtr<IntersectionObserver::IntersectionObserver>> m_intersection_observers;
|
||||||
|
|
||||||
// https://www.w3.org/TR/intersection-observer/#document-intersectionobservertaskqueued
|
// https://www.w3.org/TR/intersection-observer/#document-intersectionobservertaskqueued
|
||||||
// Each document has an IntersectionObserverTaskQueued flag which is initialized to false.
|
// Each document has an IntersectionObserverTaskQueued flag which is initialized to false.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue