summaryrefslogtreecommitdiff
path: root/dom/base/ResizeObserverController.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'dom/base/ResizeObserverController.cpp')
-rw-r--r--dom/base/ResizeObserverController.cpp22
1 files changed, 13 insertions, 9 deletions
diff --git a/dom/base/ResizeObserverController.cpp b/dom/base/ResizeObserverController.cpp
index acc401a5e2..d2162bb62e 100644
--- a/dom/base/ResizeObserverController.cpp
+++ b/dom/base/ResizeObserverController.cpp
@@ -15,7 +15,7 @@ namespace dom {
void
ResizeObserverNotificationHelper::WillRefresh(TimeStamp aTime)
{
- MOZ_ASSERT(mOwner, "Why is mOwner already dead when this RefreshObserver is still registered?");
+ MOZ_DIAGNOSTIC_ASSERT(mOwner, "RefreshObserver should have been de-registered on time, but isn't.");
if (mOwner) {
mOwner->Notify();
}
@@ -69,10 +69,8 @@ ResizeObserverNotificationHelper::Unregister()
}
nsRefreshDriver* refreshDriver = GetRefreshDriver();
- if (!refreshDriver) {
- // We can't access RefreshDriver now. Just abort the Unregister().
- return;
- }
+ MOZ_RELEASE_ASSERT(refreshDriver,
+ "We should not leave a dangling reference to the observer around");
refreshDriver->RemoveRefreshObserver(this, Flush_Display);
mRegistered = false;
@@ -81,9 +79,8 @@ ResizeObserverNotificationHelper::Unregister()
void
ResizeObserverNotificationHelper::Disconnect()
{
- Unregister();
- // Our owner is dying. Clear our pointer to it, in case we outlive it.
- mOwner = nullptr;
+ MOZ_RELEASE_ASSERT(!mRegistered, "How can we die when registered?");
+ MOZ_RELEASE_ASSERT(!mOwner, "Forgot to clear weak pointer?");
}
ResizeObserverNotificationHelper::~ResizeObserverNotificationHelper()
@@ -111,6 +108,10 @@ ResizeObserverController::AddResizeObserver(ResizeObserver* aObserver)
mResizeObservers.AppendElement(aObserver);
}
+void ResizeObserverController::DetachFromDocument() {
+ mResizeObserverNotificationHelper->Unregister();
+}
+
void
ResizeObserverController::Notify()
{
@@ -240,7 +241,10 @@ ResizeObserverController::GetShell() const
ResizeObserverController::~ResizeObserverController()
{
- mResizeObserverNotificationHelper->Disconnect();
+ MOZ_RELEASE_ASSERT(
+ !mResizeObserverNotificationHelper->IsRegistered(),
+ "Nothing else should keep a reference to our notification helper when we go away");
+ mResizeObserverNotificationHelper->DetachFromOwner();
}
} // namespace dom