diff options
author | Moonchild <moonchild@palemoon.org> | 2020-10-01 11:37:38 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-10-01 11:37:38 +0000 |
commit | 63a0006985036b062eed7e9e83324581d8ab247c (patch) | |
tree | f8a7796c662ac4fce03e94e7aff0d3d9ad768684 /dom/base/ResizeObserverController.cpp | |
parent | af6a8637f56dc2774690a3d92f9df772257ca82d (diff) | |
parent | e50094ab02604892ad619abb0e3d1c7c674e43cf (diff) | |
download | UXP-63a0006985036b062eed7e9e83324581d8ab247c.tar UXP-63a0006985036b062eed7e9e83324581d8ab247c.tar.gz UXP-63a0006985036b062eed7e9e83324581d8ab247c.tar.lz UXP-63a0006985036b062eed7e9e83324581d8ab247c.tar.xz UXP-63a0006985036b062eed7e9e83324581d8ab247c.zip |
Merge branch 'redwood' into releaseRELBASE_20201001
Diffstat (limited to 'dom/base/ResizeObserverController.cpp')
-rw-r--r-- | dom/base/ResizeObserverController.cpp | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/dom/base/ResizeObserverController.cpp b/dom/base/ResizeObserverController.cpp index 349cb66ba..d4166155e 100644 --- a/dom/base/ResizeObserverController.cpp +++ b/dom/base/ResizeObserverController.cpp @@ -119,6 +119,10 @@ ResizeObserverController::Notify() return; } + // Hold a strong reference to the document, because otherwise calling + // all active observers on it might yank it out from under us. + RefPtr<nsIDocument> document(mDocument); + uint32_t shallowestTargetDepth = 0; GatherAllActiveObservations(shallowestTargetDepth); @@ -153,7 +157,7 @@ ResizeObserverController::Notify() nsEventStatus status = nsEventStatus_eIgnore; nsCOMPtr<nsPIDOMWindowInner> window = - mDocument->GetWindow()->GetCurrentInnerWindow(); + document->GetWindow()->GetCurrentInnerWindow(); if (window) { nsCOMPtr<nsIScriptGlobalObject> sgo = do_QueryInterface(window); @@ -185,7 +189,11 @@ ResizeObserverController::BroadcastAllActiveObservations() { uint32_t shallowestTargetDepth = UINT32_MAX; - for (auto observer : mResizeObservers) { + // Use a copy of the observers as this invokes the callbacks of the observers + // which could register/unregister observers at will. + nsTArray<RefPtr<ResizeObserver>> tempObservers(mResizeObservers); + + for (auto observer : tempObservers) { uint32_t targetDepth = observer->BroadcastActiveObservations(); |