summaryrefslogtreecommitdiffstats
path: root/dom/base/DOMIntersectionObserver.cpp
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-12-22 02:15:50 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-12-22 02:15:50 +0100
commitc9d920e9c630fd8b99b863e034742fd3b38e12d3 (patch)
treea2f3f8a11aa10bca612c9648b9219abc89d73e5a /dom/base/DOMIntersectionObserver.cpp
parentba81aaf073bbf9b2e832324d1710faa4c61799ba (diff)
downloadUXP-c9d920e9c630fd8b99b863e034742fd3b38e12d3.tar
UXP-c9d920e9c630fd8b99b863e034742fd3b38e12d3.tar.gz
UXP-c9d920e9c630fd8b99b863e034742fd3b38e12d3.tar.lz
UXP-c9d920e9c630fd8b99b863e034742fd3b38e12d3.tar.xz
UXP-c9d920e9c630fd8b99b863e034742fd3b38e12d3.zip
Revise lifetime management of IntersectionObservers.
Tag #249
Diffstat (limited to 'dom/base/DOMIntersectionObserver.cpp')
-rw-r--r--dom/base/DOMIntersectionObserver.cpp18
1 files changed, 9 insertions, 9 deletions
diff --git a/dom/base/DOMIntersectionObserver.cpp b/dom/base/DOMIntersectionObserver.cpp
index e39abf1a6..cb624fb17 100644
--- a/dom/base/DOMIntersectionObserver.cpp
+++ b/dom/base/DOMIntersectionObserver.cpp
@@ -43,16 +43,18 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(DOMIntersectionObserver)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
+ tmp->Disconnect();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner)
+ NS_IMPL_CYCLE_COLLECTION_UNLINK(mDocument)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mCallback)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRoot)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mQueuedEntries)
- tmp->Disconnect();
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(DOMIntersectionObserver)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
+ NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mDocument)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mCallback)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRoot)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mQueuedEntries)
@@ -185,10 +187,11 @@ DOMIntersectionObserver::Connect()
if (mConnected) {
return;
}
+
mConnected = true;
-
- nsIDocument* document = mOwner->GetExtantDoc();
- document->AddIntersectionObserver(this);
+ if(mDocument) {
+ mDocument->AddIntersectionObserver(this);
+ }
}
void
@@ -202,11 +205,8 @@ DOMIntersectionObserver::Disconnect()
target->UnregisterIntersectionObserver(this);
}
mObservationTargets.Clear();
- if (mOwner) {
- nsIDocument* document = mOwner->GetExtantDoc();
- if (document) {
- document->RemoveIntersectionObserver(this);
- }
+ if (mDocument) {
+ mDocument->RemoveIntersectionObserver(this);
}
mConnected = false;
}