mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-07 00:08:39 +09:00
Rewrite IntersectionObserver list handling to be more robust.
Tag #935.
This commit is contained in:
parent
9222116f26
commit
dc2cf8544d
3 changed files with 40 additions and 8 deletions
|
|
@ -12313,6 +12313,10 @@ nsDocument::RemoveIntersectionObserver(DOMIntersectionObserver* aObserver)
|
|||
void
|
||||
nsDocument::UpdateIntersectionObservations()
|
||||
{
|
||||
if (mIntersectionObservers.IsEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
DOMHighResTimeStamp time = 0;
|
||||
if (nsPIDOMWindowInner* window = GetInnerWindow()) {
|
||||
Performance* perf = window->GetPerformance();
|
||||
|
|
@ -12320,9 +12324,15 @@ nsDocument::UpdateIntersectionObservations()
|
|||
time = perf->Now();
|
||||
}
|
||||
}
|
||||
nsTArray<RefPtr<DOMIntersectionObserver>> observers(mIntersectionObservers.Count());
|
||||
for (auto iter = mIntersectionObservers.Iter(); !iter.Done(); iter.Next()) {
|
||||
DOMIntersectionObserver* observer = iter.Get()->GetKey();
|
||||
observer->Update(this, time);
|
||||
observers.AppendElement(observer);
|
||||
}
|
||||
for (const auto& observer : observers) {
|
||||
if (observer) {
|
||||
observer->Update(this, time);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -12335,7 +12345,7 @@ nsDocument::ScheduleIntersectionObserverNotification()
|
|||
|
||||
nsCOMPtr<nsIRunnable> notification = NewRunnableMethod(this,
|
||||
&nsDocument::NotifyIntersectionObservers);
|
||||
NS_DispatchToCurrentThread(notification);
|
||||
NS_DispatchToCurrentThread(notification.forget());
|
||||
}
|
||||
|
||||
void
|
||||
|
|
@ -12347,7 +12357,9 @@ nsDocument::NotifyIntersectionObservers()
|
|||
observers.AppendElement(observer);
|
||||
}
|
||||
for (const auto& observer : observers) {
|
||||
observer->Notify();
|
||||
if (observer) {
|
||||
observer->Notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue