Bug 1018486 - Part 1: Changes in dom/, r=baku
authorMichael Layzell <michael@thelayzells.com>
Wed, 24 Aug 2016 14:12:09 -0400
changeset 313015 5399738f71c074589c8d6d52f4a62c1e87cfe8dc
parent 313014 5db21f7f4efa2eb6d8e59beef7f97f64001b2b6f
child 313016 9a9dbfdcdb15c3b530f5b92ff43b1bd1b102d8e9
push id20479
push userkwierso@gmail.com
push dateThu, 08 Sep 2016 01:08:46 +0000
treeherderfx-team@fb7c6b034329 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbaku
bugs1018486
milestone51.0a1
Bug 1018486 - Part 1: Changes in dom/, r=baku MozReview-Commit-ID: 4tCUM4KRe81
dom/animation/Animation.cpp
dom/base/NodeInfo.cpp
dom/base/TextInputProcessor.cpp
dom/base/WebSocket.cpp
dom/base/nsDocument.cpp
dom/base/nsFrameLoader.cpp
dom/base/nsFrameMessageManager.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsObjectLoadingContent.cpp
dom/events/IMEStateManager.cpp
dom/fetch/Fetch.cpp
dom/html/HTMLButtonElement.cpp
dom/html/HTMLInputElement.cpp
dom/html/HTMLMediaElement.cpp
dom/html/ImageDocument.cpp
dom/html/nsTextEditorState.cpp
dom/indexedDB/ActorsChild.cpp
dom/ipc/Blob.cpp
dom/ipc/ContentParent.cpp
dom/media/gmp/GMPServiceParent.cpp
dom/messagechannel/MessagePortParent.cpp
dom/notification/Notification.cpp
dom/plugins/base/nsNPAPIPluginInstance.cpp
dom/smil/nsSMILAnimationController.cpp
dom/workers/WorkerPrivate.cpp
--- a/dom/animation/Animation.cpp
+++ b/dom/animation/Animation.cpp
@@ -221,23 +221,23 @@ Animation::SetTimeline(AnimationTimeline
   SetTimelineNoUpdate(aTimeline);
   PostUpdate();
 }
 
 // https://w3c.github.io/web-animations/#setting-the-timeline
 void
 Animation::SetTimelineNoUpdate(AnimationTimeline* aTimeline)
 {
-  RefPtr<AnimationTimeline> oldTimeline = mTimeline;
   if (mTimeline == aTimeline) {
     return;
   }
 
-  if (mTimeline) {
-    mTimeline->RemoveAnimation(this);
+  RefPtr<AnimationTimeline> oldTimeline = mTimeline;
+  if (oldTimeline) {
+    oldTimeline->RemoveAnimation(this);
   }
 
   mTimeline = aTimeline;
   if (!mStartTime.IsNull()) {
     mHoldTime.SetNull();
   }
 
   UpdateTiming(SeekFlag::NoSeek, SyncNotifyFlag::Async);
--- a/dom/base/NodeInfo.cpp
+++ b/dom/base/NodeInfo.cpp
@@ -202,16 +202,17 @@ NodeInfo::NamespaceEquals(const nsAStrin
 
   return mozilla::dom::NodeInfo::NamespaceEquals(nsid);
 }
 
 void
 NodeInfo::DeleteCycleCollectable()
 {
   RefPtr<nsNodeInfoManager> kungFuDeathGrip = mOwnerManager;
+  mozilla::Unused << kungFuDeathGrip; // Just keeping value alive for longer than this
   delete this;
 }
 
 bool
 NodeInfo::CanSkip()
 {
   return mDocument &&
     nsCCUncollectableMarker::InGeneration(mDocument->GetMarkedCCGeneration());
--- a/dom/base/TextInputProcessor.cpp
+++ b/dom/base/TextInputProcessor.cpp
@@ -72,17 +72,17 @@ TextInputProcessor::~TextInputProcessor(
 {
   if (mDispatcher && mDispatcher->IsComposing()) {
     // If this is composing and not canceling the composition, nobody can steal
     // the rights of TextEventDispatcher from this instance.  Therefore, this
     // needs to cancel the composition here.
     if (NS_SUCCEEDED(IsValidStateForComposition())) {
       RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
       nsEventStatus status = nsEventStatus_eIgnore;
-      mDispatcher->CommitComposition(status, &EmptyString());
+      kungFuDeathGrip->CommitComposition(status, &EmptyString());
     }
   }
 }
 
 bool
 TextInputProcessor::IsComposing() const
 {
   return mDispatcher && mDispatcher->IsComposing();
@@ -369,17 +369,17 @@ TextInputProcessor::StartComposition(nsI
                                      uint32_t aKeyFlags,
                                      uint8_t aOptionalArgc,
                                      bool* aSucceeded)
 {
   MOZ_RELEASE_ASSERT(aSucceeded, "aSucceeded must not be nullptr");
   MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
   *aSucceeded = false;
 
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
 
   WidgetKeyboardEvent* keyboardEvent;
   nsresult rv =
     PrepareKeyboardEventForComposition(aDOMKeyEvent, aKeyFlags, aOptionalArgc,
                                        keyboardEvent);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -388,92 +388,92 @@ TextInputProcessor::StartComposition(nsI
     MaybeDispatchKeydownForComposition(keyboardEvent, aKeyFlags);
   if (NS_WARN_IF(NS_FAILED(dispatcherResult.mResult)) ||
       !dispatcherResult.mCanContinue) {
     return dispatcherResult.mResult;
   }
 
   if (dispatcherResult.mDoDefault) {
     nsEventStatus status = nsEventStatus_eIgnore;
-    rv = mDispatcher->StartComposition(status);
+    rv = kungFuDeathGrip->StartComposition(status);
     *aSucceeded = status != nsEventStatus_eConsumeNoDefault &&
-                    mDispatcher && mDispatcher->IsComposing();
+                    kungFuDeathGrip && kungFuDeathGrip->IsComposing();
   }
 
   MaybeDispatchKeyupForComposition(keyboardEvent, aKeyFlags);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TextInputProcessor::SetPendingCompositionString(const nsAString& aString)
 {
   MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   nsresult rv = IsValidStateForComposition();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
-  return mDispatcher->SetPendingCompositionString(aString);
+  return kungFuDeathGrip->SetPendingCompositionString(aString);
 }
 
 NS_IMETHODIMP
 TextInputProcessor::AppendClauseToPendingComposition(uint32_t aLength,
                                                      uint32_t aAttribute)
 {
   MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   TextRangeType textRangeType;
   switch (aAttribute) {
     case ATTR_RAW_CLAUSE:
     case ATTR_SELECTED_RAW_CLAUSE:
     case ATTR_CONVERTED_CLAUSE:
     case ATTR_SELECTED_CLAUSE:
       textRangeType = ToTextRangeType(aAttribute);
       break;
     default:
       return NS_ERROR_INVALID_ARG;
   }
   nsresult rv = IsValidStateForComposition();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
-  return mDispatcher->AppendClauseToPendingComposition(aLength, textRangeType);
+  return kungFuDeathGrip->AppendClauseToPendingComposition(aLength, textRangeType);
 }
 
 NS_IMETHODIMP
 TextInputProcessor::SetCaretInPendingComposition(uint32_t aOffset)
 {
   MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   nsresult rv = IsValidStateForComposition();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
-  return mDispatcher->SetCaretInPendingComposition(aOffset, 0);
+  return kungFuDeathGrip->SetCaretInPendingComposition(aOffset, 0);
 }
 
 NS_IMETHODIMP
 TextInputProcessor::FlushPendingComposition(nsIDOMKeyEvent* aDOMKeyEvent,
                                             uint32_t aKeyFlags,
                                             uint8_t aOptionalArgc,
                                             bool* aSucceeded)
 {
   MOZ_RELEASE_ASSERT(aSucceeded, "aSucceeded must not be nullptr");
   MOZ_RELEASE_ASSERT(nsContentUtils::IsCallerChrome());
 
   // Even if this doesn't flush pending composition actually, we need to reset
   // pending composition for starting next composition with new user input.
   AutoPendingCompositionResetter resetter(this);
 
   *aSucceeded = false;
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   bool wasComposing = IsComposing();
 
   WidgetKeyboardEvent* keyboardEvent;
   nsresult rv =
     PrepareKeyboardEventForComposition(aDOMKeyEvent, aKeyFlags, aOptionalArgc,
                                        keyboardEvent);
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
@@ -489,17 +489,17 @@ TextInputProcessor::FlushPendingComposit
   // Even if the preceding keydown event was consumed, if the composition
   // was already started, we shouldn't prevent the change of composition.
   if (dispatcherResult.mDoDefault || wasComposing) {
     // Preceding keydown event may cause destroying the widget.
     if (NS_FAILED(IsValidStateForComposition())) {
       return NS_OK;
     }
     nsEventStatus status = nsEventStatus_eIgnore;
-    rv = mDispatcher->FlushPendingComposition(status);
+    rv = kungFuDeathGrip->FlushPendingComposition(status);
     *aSucceeded = status != nsEventStatus_eConsumeNoDefault;
   }
 
   MaybeDispatchKeyupForComposition(keyboardEvent, aKeyFlags);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
@@ -551,17 +551,17 @@ TextInputProcessor::CommitCompositionInt
                       const WidgetKeyboardEvent* aKeyboardEvent,
                       uint32_t aKeyFlags,
                       const nsAString* aCommitString,
                       bool* aSucceeded)
 {
   if (aSucceeded) {
     *aSucceeded = false;
   }
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   bool wasComposing = IsComposing();
 
   EventDispatcherResult dispatcherResult =
     MaybeDispatchKeydownForComposition(aKeyboardEvent, aKeyFlags);
   if (NS_WARN_IF(NS_FAILED(dispatcherResult.mResult)) ||
       !dispatcherResult.mCanContinue) {
     return dispatcherResult.mResult;
   }
@@ -570,17 +570,17 @@ TextInputProcessor::CommitCompositionInt
   // was already started, we shouldn't prevent the commit of composition.
   nsresult rv = NS_OK;
   if (dispatcherResult.mDoDefault || wasComposing) {
     // Preceding keydown event may cause destroying the widget.
     if (NS_FAILED(IsValidStateForComposition())) {
       return NS_OK;
     }
     nsEventStatus status = nsEventStatus_eIgnore;
-    rv = mDispatcher->CommitComposition(status, aCommitString);
+    rv = kungFuDeathGrip->CommitComposition(status, aCommitString);
     if (aSucceeded) {
       *aSucceeded = status != nsEventStatus_eConsumeNoDefault;
     }
   }
 
   MaybeDispatchKeyupForComposition(aKeyboardEvent, aKeyFlags);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -607,27 +607,27 @@ TextInputProcessor::CancelComposition(ns
   return CancelCompositionInternal(keyboardEvent, aKeyFlags);
 }
 
 nsresult
 TextInputProcessor::CancelCompositionInternal(
                       const WidgetKeyboardEvent* aKeyboardEvent,
                       uint32_t aKeyFlags)
 {
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
 
   EventDispatcherResult dispatcherResult =
     MaybeDispatchKeydownForComposition(aKeyboardEvent, aKeyFlags);
   if (NS_WARN_IF(NS_FAILED(dispatcherResult.mResult)) ||
       !dispatcherResult.mCanContinue) {
     return dispatcherResult.mResult;
   }
 
   nsEventStatus status = nsEventStatus_eIgnore;
-  nsresult rv = mDispatcher->CommitComposition(status, &EmptyString());
+  nsresult rv = kungFuDeathGrip->CommitComposition(status, &EmptyString());
 
   MaybeDispatchKeyupForComposition(aKeyboardEvent, aKeyFlags);
 
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
   return NS_OK;
 }
@@ -830,36 +830,36 @@ TextInputProcessor::KeydownInternal(cons
     if (aKeyFlags & KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT) {
       return NS_OK;
     }
   } else if (NS_WARN_IF(aKeyFlags & KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT)) {
     return NS_ERROR_INVALID_ARG;
   }
   keyEvent.mModifiers = GetActiveModifiers();
 
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   rv = IsValidStateForComposition();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   nsEventStatus status = aConsumedFlags ? nsEventStatus_eConsumeNoDefault :
                                           nsEventStatus_eIgnore;
-  if (!mDispatcher->DispatchKeyboardEvent(eKeyDown, keyEvent, status)) {
+  if (!kungFuDeathGrip->DispatchKeyboardEvent(eKeyDown, keyEvent, status)) {
     // If keydown event isn't dispatched, we don't need to dispatch keypress
     // events.
     return NS_OK;
   }
 
   aConsumedFlags |=
     (status == nsEventStatus_eConsumeNoDefault) ? KEYDOWN_IS_CONSUMED :
                                                   KEYEVENT_NOT_CONSUMED;
 
   if (aAllowToDispatchKeypress &&
-      mDispatcher->MaybeDispatchKeypressEvents(keyEvent, status)) {
+      kungFuDeathGrip->MaybeDispatchKeypressEvents(keyEvent, status)) {
     aConsumedFlags |=
       (status == nsEventStatus_eConsumeNoDefault) ? KEYPRESS_IS_CONSUMED :
                                                     KEYEVENT_NOT_CONSUMED;
   }
 
   return NS_OK;
 }
 
@@ -910,25 +910,25 @@ TextInputProcessor::KeyupInternal(const 
     if (aKeyFlags & KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT) {
       return NS_OK;
     }
   } else if (NS_WARN_IF(aKeyFlags & KEY_DONT_DISPATCH_MODIFIER_KEY_EVENT)) {
     return NS_ERROR_INVALID_ARG;
   }
   keyEvent.mModifiers = GetActiveModifiers();
 
-  RefPtr<TextEventDispatcher> kungfuDeathGrip(mDispatcher);
+  RefPtr<TextEventDispatcher> kungFuDeathGrip(mDispatcher);
   rv = IsValidStateForComposition();
   if (NS_WARN_IF(NS_FAILED(rv))) {
     return rv;
   }
 
   nsEventStatus status = aDoDefault ? nsEventStatus_eIgnore :
                                       nsEventStatus_eConsumeNoDefault;
-  mDispatcher->DispatchKeyboardEvent(eKeyUp, keyEvent, status);
+  kungFuDeathGrip->DispatchKeyboardEvent(eKeyUp, keyEvent, status);
   aDoDefault = (status != nsEventStatus_eConsumeNoDefault);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 TextInputProcessor::GetModifierState(const nsAString& aModifierKeyName,
                                      bool* aActive)
 {
--- a/dom/base/WebSocket.cpp
+++ b/dom/base/WebSocket.cpp
@@ -1260,41 +1260,41 @@ WebSocket::ConstructorCommon(const Globa
       aRv.Throw(NS_ERROR_DOM_SYNTAX_ERR);
       return nullptr;
     }
 
     protocolArray.AppendElement(protocolElement);
   }
 
   RefPtr<WebSocket> webSocket = new WebSocket(ownerWindow);
-  RefPtr<WebSocketImpl> kungfuDeathGrip = webSocket->mImpl;
+  RefPtr<WebSocketImpl> webSocketImpl = webSocket->mImpl;
 
   bool connectionFailed = true;
 
   if (NS_IsMainThread()) {
-    webSocket->mImpl->Init(aGlobal.Context(), principal, !!aTransportProvider,
-                           aUrl, protocolArray, EmptyCString(),
-                           0, 0, aRv, &connectionFailed);
+    webSocketImpl->Init(aGlobal.Context(), principal, !!aTransportProvider,
+                        aUrl, protocolArray, EmptyCString(),
+                        0, 0, aRv, &connectionFailed);
   } else {
     // In workers we have to keep the worker alive using a workerHolder in order
     // to dispatch messages correctly.
-    if (!webSocket->mImpl->RegisterWorkerHolder()) {
+    if (!webSocketImpl->RegisterWorkerHolder()) {
       aRv.Throw(NS_ERROR_FAILURE);
       return nullptr;
     }
 
     unsigned lineno, column;
     JS::AutoFilename file;
     if (!JS::DescribeScriptedCaller(aGlobal.Context(), &file, &lineno,
                                     &column)) {
       NS_WARNING("Failed to get line number and filename in workers.");
     }
 
     RefPtr<InitRunnable> runnable =
-      new InitRunnable(webSocket->mImpl, !!aTransportProvider, aUrl,
+      new InitRunnable(webSocketImpl, !!aTransportProvider, aUrl,
                        protocolArray, nsDependentCString(file.get()), lineno,
                        column, aRv, &connectionFailed);
     runnable->Dispatch(aRv);
   }
 
   if (NS_WARN_IF(aRv.Failed())) {
     return nullptr;
   }
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -4708,19 +4708,19 @@ nsPIDOMWindowOuter*
 nsDocument::GetWindowInternal() const
 {
   MOZ_ASSERT(!mWindow, "This should not be called when mWindow is not null!");
   // Let's use mScriptGlobalObject. Even if the document is already removed from
   // the docshell, the outer window might be still obtainable from the it.
   nsCOMPtr<nsPIDOMWindowOuter> win;
   if (mRemovedFromDocShell) {
     // The docshell returns the outer window we are done.
-    nsCOMPtr<nsIDocShell> kungfuDeathGrip(mDocumentContainer);
-    if (mDocumentContainer) {
-      win = mDocumentContainer->GetWindow();
+    nsCOMPtr<nsIDocShell> kungFuDeathGrip(mDocumentContainer);
+    if (kungFuDeathGrip) {
+      win = kungFuDeathGrip->GetWindow();
     }
   } else {
     if (nsCOMPtr<nsPIDOMWindowInner> inner = do_QueryInterface(mScriptGlobalObject)) {
       // mScriptGlobalObject is always the inner window, let's get the outer.
       win = inner->GetOuterWindow();
     }
   }
 
--- a/dom/base/nsFrameLoader.cpp
+++ b/dom/base/nsFrameLoader.cpp
@@ -1055,21 +1055,21 @@ nsFrameLoader::SwapWithOtherRemoteLoader
   aOther->mRemoteBrowser->SetOwnerElement(ourContent);
 
   MaybeUpdatePrimaryTabParent(eTabParentChanged);
   aOther->MaybeUpdatePrimaryTabParent(eTabParentChanged);
 
   RefPtr<nsFrameMessageManager> ourMessageManager = mMessageManager;
   RefPtr<nsFrameMessageManager> otherMessageManager = aOther->mMessageManager;
   // Swap and setup things in parent message managers.
-  if (mMessageManager) {
-    mMessageManager->SetCallback(aOther);
+  if (ourMessageManager) {
+    ourMessageManager->SetCallback(aOther);
   }
-  if (aOther->mMessageManager) {
-    aOther->mMessageManager->SetCallback(this);
+  if (otherMessageManager) {
+    otherMessageManager->SetCallback(this);
   }
   mMessageManager.swap(aOther->mMessageManager);
 
   aFirstToSwap.swap(aSecondToSwap);
 
   ourFrameFrame->EndSwapDocShells(otherFrame);
 
   ourShell->BackingScaleFactorChanged();
@@ -2754,17 +2754,19 @@ nsFrameLoader::SendCrossProcessKeyEvent(
 
 nsresult
 nsFrameLoader::CreateStaticClone(nsIFrameLoader* aDest)
 {
   nsFrameLoader* dest = static_cast<nsFrameLoader*>(aDest);
   dest->MaybeCreateDocShell();
   NS_ENSURE_STATE(dest->mDocShell);
 
-  nsCOMPtr<nsIDocument> dummy = dest->mDocShell->GetDocument();
+  nsCOMPtr<nsIDocument> kungFuDeathGrip = dest->mDocShell->GetDocument();
+  Unused << kungFuDeathGrip;
+
   nsCOMPtr<nsIContentViewer> viewer;
   dest->mDocShell->GetContentViewer(getter_AddRefs(viewer));
   NS_ENSURE_STATE(viewer);
 
   nsCOMPtr<nsIDocShell> origDocShell;
   GetDocShell(getter_AddRefs(origDocShell));
   NS_ENSURE_STATE(origDocShell);
 
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -1308,22 +1308,26 @@ nsFrameMessageManager::ReceiveMessage(ns
 
             JS_ClearPendingException(cx);
             continue;
           }
         }
       }
     }
   }
-  RefPtr<nsFrameMessageManager> kungfuDeathGrip = mParentManager;
-  return mParentManager ? mParentManager->ReceiveMessage(aTarget, aTargetFrameLoader,
-                                                         aTargetClosed, aMessage,
-                                                         aIsSync, aCloneData,
-                                                         aCpows, aPrincipal,
-                                                         aRetVal) : NS_OK;
+
+  RefPtr<nsFrameMessageManager> kungFuDeathGrip = mParentManager;
+  if (kungFuDeathGrip) {
+    return kungFuDeathGrip->ReceiveMessage(aTarget, aTargetFrameLoader,
+                                           aTargetClosed, aMessage,
+                                           aIsSync, aCloneData,
+                                           aCpows, aPrincipal,
+                                           aRetVal);
+  }
+  return NS_OK;
 }
 
 void
 nsFrameMessageManager::AddChildManager(nsFrameMessageManager* aManager)
 {
   mChildManagers.AppendObject(aManager);
 
   RefPtr<nsFrameMessageManager> kungfuDeathGrip = this;
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -444,17 +444,18 @@ nsGlobalWindow::DOMMinTimeoutValue() con
 // inner doesn't already exists.
 #define FORWARD_TO_INNER_CREATE(method, args, err_rval)                       \
   PR_BEGIN_MACRO                                                              \
   if (IsOuterWindow()) {                                                      \
     if (!mInnerWindow) {                                                      \
       if (mIsClosed) {                                                        \
         return err_rval;                                                      \
       }                                                                       \
-      nsCOMPtr<nsIDocument> doc = GetDoc();                                   \
+      nsCOMPtr<nsIDocument> kungFuDeathGrip = GetDoc();                       \
+      ::mozilla::Unused << kungFuDeathGrip;                                   \
       if (!mInnerWindow) {                                                    \
         return err_rval;                                                      \
       }                                                                       \
     }                                                                         \
     return GetCurrentInnerWindowInternal()->method args;                      \
   }                                                                           \
   PR_END_MACRO
 
@@ -2863,17 +2864,17 @@ nsGlobalWindow::SetNewDocument(nsIDocume
 
         newInnerWindow->ClearDocumentDependentSlots(cx);
       }
     } else {
       newInnerWindow->InnerSetNewDocument(cx, aDocument);
 
       // Initialize DOM classes etc on the inner window.
       JS::Rooted<JSObject*> obj(cx, newInnerGlobal);
-      rv = mContext->InitClasses(obj);
+      rv = kungFuDeathGrip->InitClasses(obj);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     // If the document comes from a JAR, check if the channel was determined
     // to be unsafe. If so, permanently disable script on the compartment by
     // calling Block() and throwing away the key.
     nsCOMPtr<nsIJARChannel> jarChannel = do_QueryInterface(aDocument->GetChannel());
     if (jarChannel && jarChannel->GetIsUnsafe()) {
@@ -2886,17 +2887,17 @@ nsGlobalWindow::SetNewDocument(nsIDocume
     }
 
     // Give the new inner window our chrome event handler (since it
     // doesn't have one).
     newInnerWindow->mChromeEventHandler = mChromeEventHandler;
   }
 
   nsJSContext::PokeGC(JS::gcreason::SET_NEW_DOCUMENT);
-  mContext->DidInitializeContext();
+  kungFuDeathGrip->DidInitializeContext();
 
   // We wait to fire the debugger hook until the window is all set up and hooked
   // up with the outer. See bug 969156.
   if (createdInnerWindow) {
     nsContentUtils::AddScriptRunner(
       NewRunnableMethod(newInnerWindow,
                         &nsGlobalWindow::FireOnNewGlobalObject));
   }
@@ -3429,17 +3430,20 @@ nsGlobalWindow::PostHandleEvent(EventCha
     default:
       return NS_OK;
   }
 
   /* mChromeEventHandler and mContext go dangling in the middle of this
    function under some circumstances (events that destroy the window)
    without this addref. */
   nsCOMPtr<nsIDOMEventTarget> kungFuDeathGrip1(mChromeEventHandler);
+  mozilla::Unused << kungFuDeathGrip1; // These aren't referred to through the function
   nsCOMPtr<nsIScriptContext> kungFuDeathGrip2(GetContextInternal());
+  mozilla::Unused << kungFuDeathGrip2; // These aren't referred to through the function
+
 
   if (aVisitor.mEvent->mMessage == eResize) {
     mIsHandlingResizeEvent = false;
   } else if (aVisitor.mEvent->mMessage == eUnload &&
              aVisitor.mEvent->IsTrusted()) {
     // Execute bindingdetached handlers before we tear ourselves
     // down.
     if (mDoc) {
@@ -3599,16 +3603,17 @@ void
 nsPIDOMWindow<T>::MaybeCreateDoc()
 {
   MOZ_ASSERT(!mDoc);
   if (nsIDocShell* docShell = GetDocShell()) {
     // Note that |document| here is the same thing as our mDoc, but we
     // don't have to explicitly set the member variable because the docshell
     // has already called SetNewDocument().
     nsCOMPtr<nsIDocument> document = docShell->GetDocument();
+    Unused << document;
   }
 }
 
 void
 nsPIDOMWindowOuter::SetInitialKeyboardIndicators(
   UIStateChangeType aShowAccelerators, UIStateChangeType aShowFocusRings)
 {
   MOZ_ASSERT(IsOuterWindow());
@@ -11861,16 +11866,17 @@ nsGlobalWindow::OpenInternal(const nsASt
       // window.open() from JavaScript, make sure there's a document in
       // the new window. We do this by simply asking the new window for
       // its document, this will synchronously create an empty document
       // if there is no document in the window.
       // XXXbz should this just use EnsureInnerWindow()?
 
       // Force document creation.
       nsCOMPtr<nsIDocument> doc = (*aReturn)->GetDoc();
+      Unused << doc;
     }
   }
 
   if (checkForPopup) {
     MOZ_ASSERT(abuseLevel < openAbused, "Why didn't we take the early return?");
 
     if (abuseLevel >= openControlled) {
       nsGlobalWindow *opened = nsGlobalWindow::Cast(*aReturn);
--- a/dom/base/nsObjectLoadingContent.cpp
+++ b/dom/base/nsObjectLoadingContent.cpp
@@ -3033,16 +3033,17 @@ nsObjectLoadingContent::SyncStartPluginI
   // the document and active
   nsCOMPtr<nsIContent> thisContent =
     do_QueryInterface(static_cast<nsIImageLoadingContent*>(this));
   if (!InActiveDocument(thisContent)) {
     return NS_ERROR_FAILURE;
   }
 
   nsCOMPtr<nsIURI> kungFuURIGrip(mURI);
+  mozilla::Unused << kungFuURIGrip; // This URI is not referred to within this function
   nsCString contentType(mContentType);
   return InstantiatePluginInstance();
 }
 
 NS_IMETHODIMP
 nsObjectLoadingContent::AsyncStartPluginInstance()
 {
   // OK to have an instance already or a pending spawn.
--- a/dom/events/IMEStateManager.cpp
+++ b/dom/events/IMEStateManager.cpp
@@ -1596,18 +1596,18 @@ IMEStateManager::CreateIMEContentObserve
   MOZ_LOG(sISMLog, LogLevel::Debug,
     ("  CreateIMEContentObserver() is creating an "
      "IMEContentObserver instance..."));
   sActiveIMEContentObserver = new IMEContentObserver();
 
   // IMEContentObserver::Init() might create another IMEContentObserver
   // instance.  So, sActiveIMEContentObserver would be replaced with new one.
   // We should hold the current instance here.
-  RefPtr<IMEContentObserver> kungFuDeathGrip(sActiveIMEContentObserver);
-  sActiveIMEContentObserver->Init(widget, sPresContext, sContent, aEditor);
+  RefPtr<IMEContentObserver> activeIMEContentObserver(sActiveIMEContentObserver);
+  activeIMEContentObserver->Init(widget, sPresContext, sContent, aEditor);
 }
 
 // static
 nsresult
 IMEStateManager::GetFocusSelectionAndRoot(nsISelection** aSelection,
                                           nsIContent** aRootContent)
 {
   if (!sActiveIMEContentObserver) {
--- a/dom/fetch/Fetch.cpp
+++ b/dom/fetch/Fetch.cpp
@@ -1044,17 +1044,17 @@ FetchBody<Derived>::ContinueConsumeBody(
   mReadDone = true;
 #endif
 
   AutoFreeBuffer autoFree(aResult);
 
   MOZ_ASSERT(mConsumePromise);
   RefPtr<Promise> localPromise = mConsumePromise.forget();
 
-  RefPtr<Derived> kungfuDeathGrip = DerivedClass();
+  RefPtr<Derived> derivedClass = DerivedClass();
   ReleaseObject();
 
   if (NS_WARN_IF(NS_FAILED(aStatus))) {
     localPromise->MaybeReject(NS_ERROR_DOM_ABORT_ERR);
 
     // If binding aborted, cancel the pump. We can't assert mConsumeBodyPump.
     // In the (admittedly rare) situation that BeginConsumeBodyMainThread()
     // context switches out, and the worker thread gets canceled before the
@@ -1093,17 +1093,17 @@ FetchBody<Derived>::ContinueConsumeBody(
   if (NS_FAILED(aStatus)) {
     return;
   }
 
   // Finish successfully consuming body according to type.
   MOZ_ASSERT(aResult);
 
   AutoJSAPI jsapi;
-  if (!jsapi.Init(DerivedClass()->GetParentObject())) {
+  if (!jsapi.Init(derivedClass->GetParentObject())) {
     localPromise->MaybeReject(NS_ERROR_UNEXPECTED);
     return;
   }
 
   JSContext* cx = jsapi.cx();
   ErrorResult error;
 
   switch (mConsumeType) {
@@ -1119,32 +1119,32 @@ FetchBody<Derived>::ContinueConsumeBody(
         localPromise->MaybeResolve(cx, val);
         // ArrayBuffer takes over ownership.
         autoFree.Reset();
       }
       break;
     }
     case CONSUME_BLOB: {
       RefPtr<dom::Blob> blob = BodyUtil::ConsumeBlob(
-        DerivedClass()->GetParentObject(), NS_ConvertUTF8toUTF16(mMimeType),
+        derivedClass->GetParentObject(), NS_ConvertUTF8toUTF16(mMimeType),
         aResultLength, aResult, error);
       if (!error.Failed()) {
         localPromise->MaybeResolve(blob);
         // File takes over ownership.
         autoFree.Reset();
       }
       break;
     }
     case CONSUME_FORMDATA: {
       nsCString data;
       data.Adopt(reinterpret_cast<char*>(aResult), aResultLength);
       autoFree.Reset();
 
       RefPtr<dom::FormData> fd = BodyUtil::ConsumeFormData(
-        DerivedClass()->GetParentObject(),
+        derivedClass->GetParentObject(),
         mMimeType, data, error);
       if (!error.Failed()) {
         localPromise->MaybeResolve(fd);
       }
       break;
     }
     case CONSUME_TEXT:
       // fall through handles early exit.
--- a/dom/html/HTMLButtonElement.cpp
+++ b/dom/html/HTMLButtonElement.cpp
@@ -381,17 +381,17 @@ HTMLButtonElement::PostHandleEvent(Event
         // Using presShell to dispatch the event. It makes sure that
         // event is not handled if the window is being destroyed.
         if (presShell && (event.mMessage != eFormSubmit ||
                           mForm->SubmissionCanProceed(this))) {
           // TODO: removing this code and have the submit event sent by the form
           // see bug 592124.
           // Hold a strong ref while dispatching
           RefPtr<HTMLFormElement> form(mForm);
-          presShell->HandleDOMEventWithTarget(mForm, &event, &status);
+          presShell->HandleDOMEventWithTarget(form, &event, &status);
           aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
         }
       }
     }
   } else if ((aVisitor.mItemFlags & NS_IN_SUBMIT_CLICK) && mForm) {
     // Tell the form to flush a possible pending submission.
     // the reason is that the script returned false (the event was
     // not ignored) so if there is a stored submission, it needs to
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -3339,17 +3339,17 @@ HTMLInputElement::MaybeSubmitForm(nsPres
              mForm->SubmissionCanProceed(nullptr)) {
     // TODO: removing this code and have the submit event sent by the form,
     // bug 592124.
     // If there's only one text control, just submit the form
     // Hold strong ref across the event
     RefPtr<mozilla::dom::HTMLFormElement> form = mForm;
     InternalFormEvent event(true, eFormSubmit);
     nsEventStatus status = nsEventStatus_eIgnore;
-    shell->HandleDOMEventWithTarget(mForm, &event, &status);
+    shell->HandleDOMEventWithTarget(form, &event, &status);
   }
 
   return NS_OK;
 }
 
 void
 HTMLInputElement::SetCheckedInternal(bool aChecked, bool aNotify)
 {
@@ -4598,17 +4598,17 @@ HTMLInputElement::PostHandleEvent(EventC
             // handling the event the pres context will return a null
             // pres shell.  See bug 125624.
             // TODO: removing this code and have the submit event sent by the
             // form, see bug 592124.
             if (presShell && (event.mMessage != eFormSubmit ||
                               mForm->SubmissionCanProceed(this))) {
               // Hold a strong ref while dispatching
               RefPtr<mozilla::dom::HTMLFormElement> form(mForm);
-              presShell->HandleDOMEventWithTarget(mForm, &event, &status);
+              presShell->HandleDOMEventWithTarget(form, &event, &status);
               aVisitor.mEventStatus = nsEventStatus_eConsumeNoDefault;
             }
           }
           break;
 
         default:
           break;
         } //switch
--- a/dom/html/HTMLMediaElement.cpp
+++ b/dom/html/HTMLMediaElement.cpp
@@ -294,17 +294,17 @@ public:
   {
     MOZ_ASSERT(NS_IsMainThread());
 
     if (!mElement) {
       return;
     }
 
     RefPtr<HTMLMediaElement> deathGrip = mElement;
-    mElement->UpdateInitialMediaSize(aSize);
+    deathGrip->UpdateInitialMediaSize(aSize);
   }
 
   void NotifyRealtimeTrackData(MediaStreamGraph* aGraph,
                                StreamTime aTrackOffset,
                                const MediaSegment& aMedia) override
   {
     if (mInitialSizeFound) {
       return;
@@ -3937,26 +3937,26 @@ public:
   }
   void DoNotifyOutput()
   {
     {
       MutexAutoLock lock(mMutex);
       mPendingNotifyOutput = false;
     }
     if (mElement && mHaveCurrentData) {
-      RefPtr<HTMLMediaElement> deathGrip = mElement;
-      mElement->FireTimeUpdate(true);
+      RefPtr<HTMLMediaElement> kungFuDeathGrip = mElement;
+      kungFuDeathGrip->FireTimeUpdate(true);
     }
   }
   void DoNotifyHaveCurrentData()
   {
     mHaveCurrentData = true;
     if (mElement) {
-      RefPtr<HTMLMediaElement> deathGrip = mElement;
-      mElement->FirstFrameLoaded();
+      RefPtr<HTMLMediaElement> kungFuDeathGrip = mElement;
+      kungFuDeathGrip->FirstFrameLoaded();
     }
     NotifyWatchers();
     DoNotifyOutput();
   }
 
   // These notifications run on the media graph thread so we need to
   // dispatch events to the main thread.
   virtual void NotifyBlockingChanged(MediaStreamGraph* aGraph, Blocking aBlocked) override
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -356,17 +356,17 @@ ImageDocument::ShrinkToFit()
       classList->Remove(NS_LITERAL_STRING("overflowingVertical"), ignored);
     }
     ignored.SuppressException();
     return;
   }
 
   // Keep image content alive while changing the attributes.
   nsCOMPtr<Element> imageContent = mImageContent;
-  nsCOMPtr<nsIDOMHTMLImageElement> image = do_QueryInterface(mImageContent);
+  nsCOMPtr<nsIDOMHTMLImageElement> image = do_QueryInterface(imageContent);
   image->SetWidth(std::max(1, NSToCoordFloor(GetRatio() * mImageWidth)));
   image->SetHeight(std::max(1, NSToCoordFloor(GetRatio() * mImageHeight)));
   
   // The view might have been scrolled when zooming in, scroll back to the
   // origin now that we're showing a shrunk-to-window version.
   ScrollImageTo(0, 0, false);
 
   if (!mImageContent) {
--- a/dom/html/nsTextEditorState.cpp
+++ b/dom/html/nsTextEditorState.cpp
@@ -2101,17 +2101,17 @@ nsTextEditorState::SetValue(const nsAStr
 
         nsCOMPtr<nsISelectionController> kungFuDeathGrip = mSelCon.get();
         uint32_t currentLength = currentValue.Length();
         uint32_t newlength = newValue.Length();
         if (!currentLength ||
             !StringBeginsWith(newValue, currentValue)) {
           // Replace the whole text.
           currentLength = 0;
-          mSelCon->SelectAll();
+          kungFuDeathGrip->SelectAll();
         } else {
           // Collapse selection to the end so that we can append data.
           mBoundFrame->SelectAllOrCollapseToEndOfText(false);
         }
         const nsAString& insertValue =
           StringTail(newValue, newlength - currentLength);
         nsCOMPtr<nsIPlaintextEditor> plaintextEditor = do_QueryInterface(mEditor);
         if (!plaintextEditor || !weakFrame.IsAlive()) {
--- a/dom/indexedDB/ActorsChild.cpp
+++ b/dom/indexedDB/ActorsChild.cpp
@@ -1495,20 +1495,20 @@ BackgroundFactoryRequestChild::RecvBlock
     MOZ_ASSERT(blockedEvent);
   }
 
   RefPtr<IDBRequest> kungFuDeathGrip = mRequest;
 
   IDB_LOG_MARK("IndexedDB %s: Child  Request[%llu]: Firing \"blocked\" event",
                "IndexedDB %s: C R[%llu]: \"blocked\"",
                IDB_LOG_ID_STRING(),
-               mRequest->LoggingSerialNumber());
+               kungFuDeathGrip->LoggingSerialNumber());
 
   bool dummy;
-  if (NS_FAILED(mRequest->DispatchEvent(blockedEvent, &dummy))) {
+  if (NS_FAILED(kungFuDeathGrip->DispatchEvent(blockedEvent, &dummy))) {
     NS_WARNING("Failed to dispatch event!");
   }
 
   return true;
 }
 
 /*******************************************************************************
  * BackgroundDatabaseChild
@@ -1788,73 +1788,73 @@ BackgroundDatabaseChild::RecvVersionChan
 
   if (!mDatabase || mDatabase->IsClosed()) {
     return true;
   }
 
   RefPtr<IDBDatabase> kungFuDeathGrip = mDatabase;
 
   // Handle bfcache'd windows.
-  if (nsPIDOMWindowInner* owner = mDatabase->GetOwner()) {
+  if (nsPIDOMWindowInner* owner = kungFuDeathGrip->GetOwner()) {
     // The database must be closed if the window is already frozen.
     bool shouldAbortAndClose = owner->IsFrozen();
 
     // Anything in the bfcache has to be evicted and then we have to close the
     // database also.
     if (nsCOMPtr<nsIDocument> doc = owner->GetExtantDoc()) {
       if (nsCOMPtr<nsIBFCacheEntry> bfCacheEntry = doc->GetBFCacheEntry()) {
         bfCacheEntry->RemoveFromBFCacheSync();
         shouldAbortAndClose = true;
       }
     }
 
     if (shouldAbortAndClose) {
       // Invalidate() doesn't close the database in the parent, so we have
       // to call Close() and AbortTransactions() manually.
-      mDatabase->AbortTransactions(/* aShouldWarn */ false);
-      mDatabase->Close();
+      kungFuDeathGrip->AbortTransactions(/* aShouldWarn */ false);
+      kungFuDeathGrip->Close();
       return true;
     }
   }
 
   // Otherwise fire a versionchange event.
   const nsDependentString type(kVersionChangeEventType);
 
   nsCOMPtr<nsIDOMEvent> versionChangeEvent;
 
   switch (aNewVersion.type()) {
     case NullableVersion::Tnull_t:
       versionChangeEvent =
-        IDBVersionChangeEvent::Create(mDatabase, type, aOldVersion);
+        IDBVersionChangeEvent::Create(kungFuDeathGrip, type, aOldVersion);
       MOZ_ASSERT(versionChangeEvent);
       break;
 
     case NullableVersion::Tuint64_t:
       versionChangeEvent =
-        IDBVersionChangeEvent::Create(mDatabase,
+        IDBVersionChangeEvent::Create(kungFuDeathGrip,
                                       type,
                                       aOldVersion,
                                       aNewVersion.get_uint64_t());
       MOZ_ASSERT(versionChangeEvent);
       break;
 
     default:
       MOZ_CRASH("Should never get here!");
   }
 
   IDB_LOG_MARK("IndexedDB %s: Child : Firing \"versionchange\" event",
                "IndexedDB %s: C: IDBDatabase \"versionchange\" event",
                IDB_LOG_ID_STRING());
 
   bool dummy;
-  if (NS_FAILED(mDatabase->DispatchEvent(versionChangeEvent, &dummy))) {
+  if (NS_FAILED(kungFuDeathGrip->DispatchEvent(versionChangeEvent, &dummy))) {
     NS_WARNING("Failed to dispatch event!");
   }
 
-  if (!mDatabase->IsClosed()) {
+  if (!kungFuDeathGrip->IsClosed()) {
     SendBlocked();
   }
 
   return true;
 }
 
 bool
 BackgroundDatabaseChild::RecvInvalidate()
--- a/dom/ipc/Blob.cpp
+++ b/dom/ipc/Blob.cpp
@@ -1660,17 +1660,17 @@ private:
 
     // If our luck is *really* bad then it is possible for the CloseStream() and
     // nsIThread::Shutdown() functions to run before the Dispatch() call here
     // finishes... Keep the thread alive until this method returns.
     nsCOMPtr<nsIThread> kungFuDeathGrip = mIOTarget;
 
     mClosing = true;
 
-    nsresult rv = mIOTarget->Dispatch(this, NS_DISPATCH_NORMAL);
+    nsresult rv = kungFuDeathGrip->Dispatch(this, NS_DISPATCH_NORMAL);
     NS_ENSURE_SUCCESS(rv, rv);
 
     return NS_OK;
   }
 
   NS_IMETHOD
   Run() override
   {
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -4998,17 +4998,16 @@ ContentParent::RecvCreateWindow(PBrowser
     if (!newTab->SetRenderFrame(rfp) ||
         !newTab->GetRenderFrameInfo(aTextureFactoryIdentifier, aLayersId)) {
       *aResult = NS_ERROR_FAILURE;
     }
 
     return true;
   }
 
-  nsCOMPtr<mozIDOMWindowProxy> window;
   TabParent::AutoUseNewTab aunt(newTab, aWindowIsNew, aURLToLoad);
 
   nsCOMPtr<nsPIWindowWatcher> pwwatch =
     do_GetService(NS_WINDOWWATCHER_CONTRACTID, aResult);
 
   if (NS_WARN_IF(NS_FAILED(*aResult))) {
     return true;
   }
--- a/dom/media/gmp/GMPServiceParent.cpp
+++ b/dom/media/gmp/GMPServiceParent.cpp
@@ -876,16 +876,17 @@ GeckoMediaPluginServiceParent::AsyncAddP
     ->CompletionPromise();
 }
 
 NS_IMETHODIMP
 GeckoMediaPluginServiceParent::AddPluginDirectory(const nsAString& aDirectory)
 {
   MOZ_ASSERT(NS_IsMainThread());
   RefPtr<GenericPromise> p = AsyncAddPluginDirectory(aDirectory);
+  Unused << p;
   return NS_OK;
 }
 
 NS_IMETHODIMP
 GeckoMediaPluginServiceParent::RemovePluginDirectory(const nsAString& aDirectory)
 {
   MOZ_ASSERT(NS_IsMainThread());
   return GMPDispatch(new PathRunnable(this, aDirectory,
--- a/dom/messagechannel/MessagePortParent.cpp
+++ b/dom/messagechannel/MessagePortParent.cpp
@@ -128,17 +128,17 @@ MessagePortParent::RecvClose()
 
 void
 MessagePortParent::ActorDestroy(ActorDestroyReason aWhy)
 {
   if (mService && mEntangled) {
     // When the last parent is deleted, this service is freed but this cannot
     // be done when the hashtables are written by CloseAll.
     RefPtr<MessagePortService> kungFuDeathGrip = mService;
-    mService->ParentDestroy(this);
+    kungFuDeathGrip->ParentDestroy(this);
   }
 }
 
 bool
 MessagePortParent::Entangled(const nsTArray<MessagePortMessage>& aMessages)
 {
   MOZ_ASSERT(!mEntangled);
   mEntangled = true;
--- a/dom/notification/Notification.cpp
+++ b/dom/notification/Notification.cpp
@@ -2523,29 +2523,29 @@ NotificationWorkerHolder::Notify(Status 
     // closed, but there is no permission to show it so that the main thread
     // immediately drops the NotificationRef. In this case, this function blocks
     // on the main thread, but the main thread dispatches the control runnable,
     // invalidating mNotification.
     RefPtr<Notification> kungFuDeathGrip = mNotification;
 
     // Dispatched to main thread, blocks on closing the Notification.
     RefPtr<CloseNotificationRunnable> r =
-      new CloseNotificationRunnable(mNotification);
+      new CloseNotificationRunnable(kungFuDeathGrip);
     ErrorResult rv;
     r->Dispatch(rv);
     // XXXbz I'm told throwing and returning false from here is pointless (and
     // also that doing sync stuff from here is really weird), so I guess we just
     // suppress the exception on rv, if any.
     rv.SuppressException();
 
     // Only call ReleaseObject() to match the observer's NotificationRef
     // ownership (since CloseNotificationRunnable asked the observer to drop the
     // reference to the notification).
     if (r->HadObserver()) {
-      mNotification->ReleaseObject();
+      kungFuDeathGrip->ReleaseObject();
     }
 
     // From this point we cannot touch properties of this feature because
     // ReleaseObject() may have led to the notification going away and the
     // notification owns this feature!
   }
   return true;
 }
--- a/dom/plugins/base/nsNPAPIPluginInstance.cpp
+++ b/dom/plugins/base/nsNPAPIPluginInstance.cpp
@@ -313,20 +313,20 @@ nsresult nsNPAPIPluginInstance::Stop()
 }
 
 already_AddRefed<nsPIDOMWindowOuter>
 nsNPAPIPluginInstance::GetDOMWindow()
 {
   if (!mOwner)
     return nullptr;
 
-  RefPtr<nsPluginInstanceOwner> deathGrip(mOwner);
+  RefPtr<nsPluginInstanceOwner> kungFuDeathGrip(mOwner);
 
   nsCOMPtr<nsIDocument> doc;
-  mOwner->GetDocument(getter_AddRefs(doc));
+  kungFuDeathGrip->GetDocument(getter_AddRefs(doc));
   if (!doc)
     return nullptr;
 
   RefPtr<nsPIDOMWindowOuter> window = doc->GetWindow();
 
   return window.forget();
 }
 
--- a/dom/smil/nsSMILAnimationController.cpp
+++ b/dom/smil/nsSMILAnimationController.cpp
@@ -419,19 +419,19 @@ nsSMILAnimationController::DoSample(bool
   }
 
   // return early if there are no active animations to avoid a style flush
   if (currentCompositorTable->Count() == 0) {
     mLastCompositorTable = nullptr;
     return;
   }
 
-  nsCOMPtr<nsIDocument> kungFuDeathGrip(mDocument);  // keeps 'this' alive too
+  nsCOMPtr<nsIDocument> document(mDocument);  // keeps 'this' alive too
   if (isStyleFlushNeeded) {
-    mDocument->FlushPendingNotifications(Flush_Style);
+    document->FlushPendingNotifications(Flush_Style);
   }
 
   // WARNING:
   // WARNING: the above flush may have destroyed the pres shell and/or
   // WARNING: frames and other layout related objects.
   // WARNING:
 
   // STEP 5: Compose currently-animated attributes.
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -2535,17 +2535,17 @@ WorkerPrivateParent<Derived>::Freeze(nsP
     bool allFrozen = false;
 
     for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
       if (aWindow && mSharedWorkers[i]->GetOwner() == aWindow) {
         // Calling Freeze() may change the refcount, ensure that the worker
         // outlives this call.
         RefPtr<SharedWorker> kungFuDeathGrip = mSharedWorkers[i];
 
-        mSharedWorkers[i]->Freeze();
+        kungFuDeathGrip->Freeze();
       } else {
         MOZ_ASSERT_IF(mSharedWorkers[i]->GetOwner() && aWindow,
                       !SameCOMIdentity(mSharedWorkers[i]->GetOwner(),
                                        aWindow));
         if (!mSharedWorkers[i]->IsFrozen()) {
           allFrozen = false;
         }
       }
@@ -2599,17 +2599,17 @@ WorkerPrivateParent<Derived>::Thaw(nsPID
     bool anyRunning = false;
 
     for (uint32_t i = 0; i < mSharedWorkers.Length(); ++i) {
       if (aWindow && mSharedWorkers[i]->GetOwner() == aWindow) {
         // Calling Thaw() may change the refcount, ensure that the worker
         // outlives this call.
         RefPtr<SharedWorker> kungFuDeathGrip = mSharedWorkers[i];
 
-        mSharedWorkers[i]->Thaw();
+        kungFuDeathGrip->Thaw();
         anyRunning = true;
       } else {
         MOZ_ASSERT_IF(mSharedWorkers[i]->GetOwner() && aWindow,
                       !SameCOMIdentity(mSharedWorkers[i]->GetOwner(),
                                        aWindow));
         if (!mSharedWorkers[i]->IsFrozen()) {
           anyRunning = true;
         }