Bug 967364: Rename already_AddRefed::get to take. r=bsmedberg
authorKyle Huey <khuey@kylehuey.com>
Sat, 15 Mar 2014 12:00:15 -0700
changeset 173771 32f48d6d3389ea5db45cfc6e452ec52595c11a43
parent 173758 3917d9bfb8fe76dc0b800311622229938f1fd68c
child 173772 4d78ec7d6f0d6ecbde1d85f6e81e619ae7286971
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbsmedberg
bugs967364
milestone30.0a1
Bug 967364: Rename already_AddRefed::get to take. r=bsmedberg
content/base/public/Element.h
content/base/public/nsINode.h
content/base/src/DOMImplementation.cpp
content/base/src/DocumentType.cpp
content/base/src/Element.cpp
content/base/src/NodeIterator.cpp
content/base/src/NodeIterator.h
content/base/src/TreeWalker.cpp
content/base/src/TreeWalker.h
content/base/src/WebSocket.cpp
content/base/src/nsAttrValue.cpp
content/base/src/nsContentUtils.cpp
content/base/src/nsDOMAttributeMap.cpp
content/base/src/nsDOMFile.cpp
content/base/src/nsDOMMutationObserver.h
content/base/src/nsDocument.cpp
content/base/src/nsDocumentEncoder.cpp
content/base/src/nsINode.cpp
content/base/src/nsImageLoadingContent.cpp
content/base/src/nsNameSpaceManager.cpp
content/base/src/nsRange.cpp
content/base/src/nsXMLHttpRequest.cpp
content/html/content/src/HTMLCanvasElement.cpp
content/html/content/src/HTMLInputElement.cpp
content/html/content/src/HTMLMediaElement.cpp
content/html/content/src/nsFormSubmission.cpp
content/html/content/src/nsGenericHTMLElement.cpp
content/html/document/src/ImageDocument.cpp
content/html/document/src/nsHTMLContentSink.cpp
content/html/document/src/nsHTMLDocument.cpp
content/mathml/content/src/nsMathMLElementFactory.cpp
content/media/gstreamer/GStreamerReader-0.10.cpp
content/media/webspeech/recognition/SpeechRecognition.cpp
content/svg/content/src/SVGElementFactory.cpp
content/svg/content/src/nsSVGElement.cpp
content/xul/content/src/nsXULElement.cpp
content/xul/document/src/XULDocument.cpp
content/xul/templates/src/nsXULTemplateBuilder.cpp
dom/base/nsDOMClassInfo.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsLocation.cpp
dom/camera/GonkCameraControl.cpp
dom/events/DataTransfer.cpp
dom/events/MouseEvent.cpp
dom/events/NotifyPaintEvent.cpp
dom/events/XULCommandEvent.cpp
dom/fmradio/ipc/FMRadioParent.cpp
dom/ipc/ContentChild.cpp
dom/ipc/ContentParent.cpp
dom/ipc/TabChild.cpp
dom/ipc/TabParent.cpp
dom/plugins/base/nsNPAPIPlugin.cpp
dom/plugins/base/nsPluginHost.cpp
dom/plugins/ipc/PluginInstanceParent.cpp
dom/smil/nsSMILMappedAttribute.cpp
dom/src/notification/DesktopNotification.cpp
dom/src/offline/nsDOMOfflineResourceList.cpp
dom/workers/WorkerPrivate.cpp
dom/xbl/nsXBLService.cpp
dom/xslt/xml/txXMLUtils.cpp
dom/xslt/xpath/XPathEvaluator.h
dom/xslt/xpath/txExprParser.cpp
dom/xslt/xslt/txStylesheetCompileHandlers.cpp
editor/libeditor/html/nsHTMLCSSUtils.cpp
editor/txmgr/src/nsTransactionList.cpp
editor/txmgr/src/nsTransactionManager.cpp
embedding/browser/webBrowser/nsWebBrowser.cpp
embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
extensions/spellcheck/src/mozInlineSpellChecker.cpp
gfx/layers/basic/BasicImageLayer.cpp
gfx/layers/d3d10/LayerManagerD3D10.cpp
gfx/layers/ipc/CompositorChild.cpp
gfx/layers/ipc/ShadowLayers.cpp
image/src/RasterImage.cpp
image/src/SurfaceCache.cpp
intl/icu/source/io/ufile.c
intl/uconv/src/nsCharsetConverterManager.cpp
ipc/glue/BackgroundImpl.cpp
js/jsd/jsd_xpc.cpp
js/src/jsatom.cpp
js/xpconnect/src/Sandbox.cpp
js/xpconnect/src/XPCConvert.cpp
js/xpconnect/src/XPCJSContextStack.cpp
js/xpconnect/src/XPCWrappedJS.cpp
js/xpconnect/src/XPCWrappedNative.cpp
layout/generic/nsBulletFrame.cpp
layout/generic/nsCanvasFrame.cpp
layout/generic/nsImageFrame.cpp
layout/generic/nsSelection.cpp
layout/style/ErrorReporter.cpp
layout/style/Loader.cpp
layout/style/StyleRule.cpp
layout/style/nsCSSValue.cpp
layout/style/nsStyleAnimation.cpp
layout/style/nsStyleContext.h
layout/xul/tree/nsTreeBoxObject.cpp
layout/xul/tree/nsTreeStyleCache.cpp
media/mtransport/nriceresolver.cpp
media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
media/webrtc/trunk/build/android/gtest_filter/net_unittests_disabled
modules/libjar/nsZipArchive.cpp
netwerk/base/public/nsNetUtil.h
netwerk/base/src/EventTokenBucket.cpp
netwerk/base/src/nsPACMan.cpp
netwerk/cache/nsCacheEntryDescriptor.cpp
netwerk/cache2/CacheFile.cpp
netwerk/cache2/CacheFileInputStream.cpp
netwerk/cache2/CacheFileOutputStream.cpp
netwerk/protocol/about/nsAboutCacheEntry.cpp
netwerk/protocol/http/NullHttpTransaction.cpp
netwerk/protocol/http/nsHttpConnectionMgr.cpp
netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
rdf/base/src/nsRDFContentSink.cpp
security/manager/ssl/src/nsCertTree.cpp
security/manager/ssl/src/nsNSSCertHelper.cpp
security/sandbox/chromium/base/basictypes.h
toolkit/components/finalizationwitness/FinalizationWitnessService.cpp
toolkit/xre/nsEmbedFunctions.cpp
uriloader/exthandler/nsExternalHelperAppService.cpp
view/src/nsView.cpp
widget/windows/KeyboardLayout.cpp
widget/xpwidgets/GfxInfoBase.cpp
widget/xpwidgets/nsBaseWidget.cpp
xpcom/build/Services.cpp
xpcom/components/ModuleUtils.h
xpcom/ds/nsAtomService.cpp
xpcom/glue/nsCOMPtr.h
xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp
xpcom/string/src/nsTSubstring.cpp
--- a/content/base/public/Element.h
+++ b/content/base/public/Element.h
@@ -1372,44 +1372,44 @@ NS_IMETHOD GetAttributeNode(const nsAStr
 NS_IMETHOD SetAttributeNode(nsIDOMAttr* newAttr,                              \
                             nsIDOMAttr** _retval) MOZ_FINAL                   \
 {                                                                             \
   if (!newAttr) {                                                             \
     return NS_ERROR_INVALID_POINTER;                                          \
   }                                                                           \
   mozilla::ErrorResult rv;                                                    \
   mozilla::dom::Attr* attr = static_cast<mozilla::dom::Attr*>(newAttr);       \
-  *_retval = Element::SetAttributeNode(*attr, rv).get();                      \
+  *_retval = Element::SetAttributeNode(*attr, rv).take();                     \
   return rv.ErrorCode();                                                      \
 }                                                                             \
 NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* oldAttr,                           \
                                nsIDOMAttr** _retval) MOZ_FINAL                \
 {                                                                             \
   if (!oldAttr) {                                                             \
     return NS_ERROR_INVALID_POINTER;                                          \
   }                                                                           \
   mozilla::ErrorResult rv;                                                    \
   mozilla::dom::Attr* attr = static_cast<mozilla::dom::Attr*>(oldAttr);       \
-  *_retval = Element::RemoveAttributeNode(*attr, rv).get();                   \
+  *_retval = Element::RemoveAttributeNode(*attr, rv).take();                  \
   return rv.ErrorCode();                                                      \
 }                                                                             \
 NS_IMETHOD GetAttributeNodeNS(const nsAString& namespaceURI,                  \
                               const nsAString& localName,                     \
                               nsIDOMAttr** _retval) MOZ_FINAL                 \
 {                                                                             \
   NS_IF_ADDREF(*_retval = Element::GetAttributeNodeNS(namespaceURI,           \
                                                       localName));            \
   return NS_OK;                                                               \
 }                                                                             \
 NS_IMETHOD SetAttributeNodeNS(nsIDOMAttr* newAttr,                            \
                               nsIDOMAttr** _retval) MOZ_FINAL                 \
 {                                                                             \
   mozilla::ErrorResult rv;                                                    \
   mozilla::dom::Attr* attr = static_cast<mozilla::dom::Attr*>(newAttr);       \
-  *_retval = Element::SetAttributeNodeNS(*attr, rv).get();                    \
+  *_retval = Element::SetAttributeNodeNS(*attr, rv).take();                   \
   return rv.ErrorCode();                                                      \
 }                                                                             \
 NS_IMETHOD GetElementsByTagName(const nsAString& name,                        \
                                 nsIDOMHTMLCollection** _retval) MOZ_FINAL     \
 {                                                                             \
   Element::GetElementsByTagName(name, _retval);                               \
   return NS_OK;                                                               \
 }                                                                             \
@@ -1475,22 +1475,22 @@ NS_IMETHOD GetChildElementCount(uint32_t
 }                                                                             \
 NS_IMETHOD MozRemove() MOZ_FINAL                                              \
 {                                                                             \
   nsINode::Remove();                                                          \
   return NS_OK;                                                               \
 }                                                                             \
 NS_IMETHOD GetClientRects(nsIDOMClientRectList** _retval) MOZ_FINAL           \
 {                                                                             \
-  *_retval = Element::GetClientRects().get();                                 \
+  *_retval = Element::GetClientRects().take();                                \
   return NS_OK;                                                               \
 }                                                                             \
 NS_IMETHOD GetBoundingClientRect(nsIDOMClientRect** _retval) MOZ_FINAL        \
 {                                                                             \
-  *_retval = Element::GetBoundingClientRect().get();                          \
+  *_retval = Element::GetBoundingClientRect().take();                         \
   return NS_OK;                                                               \
 }                                                                             \
 NS_IMETHOD GetScrollTop(int32_t* aScrollTop) MOZ_FINAL                        \
 {                                                                             \
   *aScrollTop = Element::ScrollTop();                                         \
   return NS_OK;                                                               \
 }                                                                             \
 NS_IMETHOD SetScrollTop(int32_t aScrollTop) MOZ_FINAL                         \
--- a/content/base/public/nsINode.h
+++ b/content/base/public/nsINode.h
@@ -1877,17 +1877,17 @@ ToCanonicalSupports(nsINode* aPointer)
     if (aArgc == 0) { \
       aDeep = true; \
     } \
     mozilla::ErrorResult rv; \
     nsCOMPtr<nsINode> clone = nsINode::CloneNode(aDeep, rv); \
     if (rv.Failed()) { \
       return rv.ErrorCode(); \
     } \
-    *aResult = clone.forget().get()->AsDOMNode(); \
+    *aResult = clone.forget().take()->AsDOMNode(); \
     return NS_OK; \
   } \
   NS_IMETHOD Normalize() __VA_ARGS__ \
   { \
     nsINode::Normalize(); \
     return NS_OK; \
   } \
   NS_IMETHOD GetNamespaceURI(nsAString& aNamespaceURI) __VA_ARGS__ \
--- a/content/base/src/DOMImplementation.cpp
+++ b/content/base/src/DOMImplementation.cpp
@@ -83,17 +83,18 @@ DOMImplementation::CreateDocumentType(co
 
 NS_IMETHODIMP
 DOMImplementation::CreateDocumentType(const nsAString& aQualifiedName,
                                       const nsAString& aPublicId,
                                       const nsAString& aSystemId,
                                       nsIDOMDocumentType** aReturn)
 {
   ErrorResult rv;
-  *aReturn = CreateDocumentType(aQualifiedName, aPublicId, aSystemId, rv).get();
+  *aReturn =
+    CreateDocumentType(aQualifiedName, aPublicId, aSystemId, rv).take();
   return rv.ErrorCode();
 }
 
 nsresult
 DOMImplementation::CreateDocument(const nsAString& aNamespaceURI,
                                   const nsAString& aQualifiedName,
                                   nsIDOMDocumentType* aDoctype,
                                   nsIDocument** aDocument,
--- a/content/base/src/DocumentType.cpp
+++ b/content/base/src/DocumentType.cpp
@@ -23,17 +23,17 @@ NS_NewDOMDocumentType(nsIDOMDocumentType
                       nsIAtom *aName,
                       const nsAString& aPublicId,
                       const nsAString& aSystemId,
                       const nsAString& aInternalSubset)
 {
   NS_ENSURE_ARG_POINTER(aDocType);
   mozilla::ErrorResult rv;
   *aDocType = NS_NewDOMDocumentType(aNodeInfoManager, aName, aPublicId,
-                                    aSystemId, aInternalSubset, rv).get();
+                                    aSystemId, aInternalSubset, rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<mozilla::dom::DocumentType>
 NS_NewDOMDocumentType(nsNodeInfoManager* aNodeInfoManager,
                       nsIAtom *aName,
                       const nsAString& aPublicId,
                       const nsAString& aSystemId,
--- a/content/base/src/Element.cpp
+++ b/content/base/src/Element.cpp
@@ -473,17 +473,17 @@ Element::GetElementsByTagName(const nsAS
 {
   return NS_GetContentList(this, kNameSpaceID_Unknown, aLocalName);
 }
 
 void
 Element::GetElementsByTagName(const nsAString& aLocalName,
                               nsIDOMHTMLCollection** aResult)
 {
-  *aResult = GetElementsByTagName(aLocalName).get();
+  *aResult = GetElementsByTagName(aLocalName).take();
 }
 
 nsIFrame*
 Element::GetStyledFrame()
 {
   nsIFrame *frame = GetPrimaryFrame(Flush_Layout);
   return frame ? nsLayoutUtils::GetStyleFrame(frame) : nullptr;
 }
@@ -1047,17 +1047,18 @@ Element::GetElementsByClassName(const ns
 {
   return nsContentUtils::GetElementsByClassName(this, aClassNames);
 }
 
 nsresult
 Element::GetElementsByClassName(const nsAString& aClassNames,
                                 nsIDOMHTMLCollection** aResult)
 {
-  *aResult = nsContentUtils::GetElementsByClassName(this, aClassNames).get();
+  *aResult =
+    nsContentUtils::GetElementsByClassName(this, aClassNames).take();
   return NS_OK;
 }
 
 nsresult
 Element::BindToTree(nsIDocument* aDocument, nsIContent* aParent,
                     nsIContent* aBindingParent,
                     bool aCompileEventHandlers)
 {
--- a/content/base/src/NodeIterator.cpp
+++ b/content/base/src/NodeIterator.cpp
@@ -193,17 +193,17 @@ NS_IMETHODIMP NodeIterator::GetWhatToSho
     return NS_OK;
 }
 
 /* readonly attribute nsIDOMNodeFilter filter; */
 NS_IMETHODIMP NodeIterator::GetFilter(nsIDOMNodeFilter **aFilter)
 {
     NS_ENSURE_ARG_POINTER(aFilter);
 
-    *aFilter = mFilter.ToXPCOMCallback().get();
+    *aFilter = mFilter.ToXPCOMCallback().take();
 
     return NS_OK;
 }
 
 /* nsIDOMNode nextNode ()  raises (DOMException); */
 NS_IMETHODIMP NodeIterator::NextNode(nsIDOMNode **_retval)
 {
     return ImplNodeGetter(&NodeIterator::NextNode, _retval);
--- a/content/base/src/NodeIterator.h
+++ b/content/base/src/NodeIterator.h
@@ -96,17 +96,17 @@ private:
     typedef already_AddRefed<nsINode> (NodeIterator::*NodeGetter)(ErrorResult&);
     inline nsresult ImplNodeGetter(NodeGetter aGetter, nsIDOMNode** aRetval)
     {
         mozilla::ErrorResult rv;
         nsCOMPtr<nsINode> node = (this->*aGetter)(rv);
         if (rv.Failed()) {
             return rv.ErrorCode();
         }
-        *aRetval = node ? node.forget().get()->AsDOMNode() : nullptr;
+        *aRetval = node ? node.forget().take()->AsDOMNode() : nullptr;
         return NS_OK;
     }
 
     // Have to return a strong ref, because the act of testing the node can
     // remove it from the DOM so we're holding the only ref to it.
     already_AddRefed<nsINode>
     NextOrPrevNode(NodePointer::MoveToMethodType aMove, ErrorResult& aResult);
 
--- a/content/base/src/TreeWalker.cpp
+++ b/content/base/src/TreeWalker.cpp
@@ -75,17 +75,17 @@ NS_IMETHODIMP TreeWalker::GetWhatToShow(
     return NS_OK;
 }
 
 /* readonly attribute nsIDOMNodeFilter filter; */
 NS_IMETHODIMP TreeWalker::GetFilter(nsIDOMNodeFilter * *aFilter)
 {
     NS_ENSURE_ARG_POINTER(aFilter);
 
-    *aFilter = mFilter.ToXPCOMCallback().get();
+    *aFilter = mFilter.ToXPCOMCallback().take();
 
     return NS_OK;
 }
 
 /* attribute nsIDOMNode currentNode; */
 NS_IMETHODIMP TreeWalker::GetCurrentNode(nsIDOMNode * *aCurrentNode)
 {
     if (mCurrentNode) {
--- a/content/base/src/TreeWalker.h
+++ b/content/base/src/TreeWalker.h
@@ -93,17 +93,17 @@ private:
     typedef already_AddRefed<nsINode> (TreeWalker::*NodeGetter)(ErrorResult&);
     inline nsresult ImplNodeGetter(NodeGetter aGetter, nsIDOMNode** aRetval)
     {
         mozilla::ErrorResult rv;
         nsCOMPtr<nsINode> node = (this->*aGetter)(rv);
         if (rv.Failed()) {
             return rv.ErrorCode();
         }
-        *aRetval = node ? node.forget().get()->AsDOMNode() : nullptr;
+        *aRetval = node ? node.forget().take()->AsDOMNode() : nullptr;
         return NS_OK;
     }
 };
 
 } // namespace dom
 } // namespace mozilla
 
 #endif // mozilla_dom_TreeWalker_h
--- a/content/base/src/WebSocket.cpp
+++ b/content/base/src/WebSocket.cpp
@@ -1407,17 +1407,17 @@ WebSocket::GetLoadGroup(nsILoadGroup** a
   *aLoadGroup = nullptr;
 
   nsresult rv;
   nsIScriptContext* sc = GetContextForEventHandlers(&rv);
   nsCOMPtr<nsIDocument> doc =
     nsContentUtils::GetDocumentFromScriptContext(sc);
 
   if (doc) {
-    *aLoadGroup = doc->GetDocumentLoadGroup().get();  // already_AddRefed
+    *aLoadGroup = doc->GetDocumentLoadGroup().take();
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 WebSocket::SetLoadGroup(nsILoadGroup* aLoadGroup)
 {
--- a/content/base/src/nsAttrValue.cpp
+++ b/content/base/src/nsAttrValue.cpp
@@ -370,17 +370,17 @@ nsAttrValue::SetTo(const nsAttrValue& aO
   // work correctly.
   cont->mType = otherCont->mType;
 }
 
 void
 nsAttrValue::SetTo(const nsAString& aValue)
 {
   ResetIfSet();
-  nsStringBuffer* buf = GetStringBuffer(aValue).get();
+  nsStringBuffer* buf = GetStringBuffer(aValue).take();
   if (buf) {
     SetPtrValueAndType(buf, eStringBase);
   }
 }
 
 void
 nsAttrValue::SetTo(nsIAtom* aValue)
 {
@@ -1227,17 +1227,17 @@ nsAttrValue::Contains(const nsAString& a
 
 void
 nsAttrValue::ParseAtom(const nsAString& aValue)
 {
   ResetIfSet();
 
   nsCOMPtr<nsIAtom> atom = NS_NewAtom(aValue);
   if (atom) {
-    SetPtrValueAndType(atom.forget().get(), eAtomBase);
+    SetPtrValueAndType(atom.forget().take(), eAtomBase);
   }
 }
 
 void
 nsAttrValue::ParseAtomArray(const nsAString& aValue)
 {
   nsAString::const_iterator iter, end;
   aValue.BeginReading(iter);
@@ -1523,17 +1523,17 @@ nsAttrValue::ParsePositiveIntValue(const
   SetIntValueAndType(originalVal, eInteger, strict ? nullptr : &aString);
 
   return true;
 }
 
 void
 nsAttrValue::SetColorValue(nscolor aColor, const nsAString& aString)
 {
-  nsStringBuffer* buf = GetStringBuffer(aString).get();
+  nsStringBuffer* buf = GetStringBuffer(aString).take();
   if (!buf) {
     return;
   }
 
   MiscContainer* cont = EnsureEmptyMiscContainer();
   cont->mValue.mColor = aColor;
   cont->mType = eColor;
 
@@ -1711,20 +1711,20 @@ nsAttrValue::SetMiscAtomOrString(const n
     // Add other types as needed.
     NS_ASSERTION(len || Type() == eCSSStyleRule || Type() == eEnum,
                  "Empty string?");
     MiscContainer* cont = GetMiscContainer();
     if (len <= NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM) {
       nsCOMPtr<nsIAtom> atom = NS_NewAtom(*aValue);
       if (atom) {
         cont->mStringBits =
-          reinterpret_cast<uintptr_t>(atom.forget().get()) | eAtomBase;
+          reinterpret_cast<uintptr_t>(atom.forget().take()) | eAtomBase;
       }
     } else {
-      nsStringBuffer* buf = GetStringBuffer(*aValue).get();
+      nsStringBuffer* buf = GetStringBuffer(*aValue).take();
       if (buf) {
         cont->mStringBits = reinterpret_cast<uintptr_t>(buf) | eStringBase;
       }
     }
   }
 }
 
 void
--- a/content/base/src/nsContentUtils.cpp
+++ b/content/base/src/nsContentUtils.cpp
@@ -2497,21 +2497,21 @@ nsContentUtils::SplitQName(const nsICont
                                                                   colon),
                                                         nameSpace);
     NS_ENSURE_SUCCESS(rv, rv);
 
     *aNamespace = NameSpaceManager()->GetNameSpaceID(nameSpace);
     if (*aNamespace == kNameSpaceID_Unknown)
       return NS_ERROR_FAILURE;
 
-    *aLocalName = NS_NewAtom(Substring(colon + 1, end)).get();
+    *aLocalName = NS_NewAtom(Substring(colon + 1, end)).take();
   }
   else {
     *aNamespace = kNameSpaceID_None;
-    *aLocalName = NS_NewAtom(aQName).get();
+    *aLocalName = NS_NewAtom(aQName).take();
   }
   NS_ENSURE_TRUE(aLocalName, NS_ERROR_OUT_OF_MEMORY);
   return NS_OK;
 }
 
 // static
 nsresult
 nsContentUtils::GetNodeInfoFromQName(const nsAString& aNamespaceURI,
@@ -2586,30 +2586,30 @@ nsContentUtils::SplitExpatName(const cha
     }
     else {
       *aNameSpaceID = kNameSpaceID_Unknown;
     }
 
     nameStart = (uriEnd + 1);
     if (nameEnd)  {
       const char16_t *prefixStart = nameEnd + 1;
-      *aPrefix = NS_NewAtom(Substring(prefixStart, pos)).get();
+      *aPrefix = NS_NewAtom(Substring(prefixStart, pos)).take();
     }
     else {
       nameEnd = pos;
       *aPrefix = nullptr;
     }
   }
   else {
     *aNameSpaceID = kNameSpaceID_None;
     nameStart = aExpatName;
     nameEnd = pos;
     *aPrefix = nullptr;
   }
-  *aLocalName = NS_NewAtom(Substring(nameStart, nameEnd)).get();
+  *aLocalName = NS_NewAtom(Substring(nameStart, nameEnd)).take();
 }
 
 // static
 nsPresContext*
 nsContentUtils::GetContextForContent(const nsIContent* aContent)
 {
   nsIDocument* doc = aContent->GetCurrentDoc();
   if (doc) {
@@ -2890,17 +2890,17 @@ nsresult
 nsContentUtils::NameChanged(nsINodeInfo* aNodeInfo, nsIAtom* aName,
                             nsINodeInfo** aResult)
 {
   nsNodeInfoManager *niMgr = aNodeInfo->NodeInfoManager();
 
   *aResult = niMgr->GetNodeInfo(aName, aNodeInfo->GetPrefixAtom(),
                                 aNodeInfo->NamespaceID(),
                                 aNodeInfo->NodeType(),
-                                aNodeInfo->GetExtraName()).get();
+                                aNodeInfo->GetExtraName()).take();
   return NS_OK;
 }
 
 
 static bool
 TestSitePerm(nsIPrincipal* aPrincipal, const char* aType, uint32_t aPerm, bool aExactHostMatch)
 {
   if (!aPrincipal) {
@@ -3824,17 +3824,17 @@ nsContentUtils::IsValidNodeName(nsIAtom 
 nsresult
 nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
                                          const nsAString& aFragment,
                                          bool aPreventScriptExecution,
                                          nsIDOMDocumentFragment** aReturn)
 {
   ErrorResult rv;
   *aReturn = CreateContextualFragment(aContextNode, aFragment,
-                                      aPreventScriptExecution, rv).get();
+                                      aPreventScriptExecution, rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<DocumentFragment>
 nsContentUtils::CreateContextualFragment(nsINode* aContextNode,
                                          const nsAString& aFragment,
                                          bool aPreventScriptExecution,
                                          ErrorResult& aRv)
--- a/content/base/src/nsDOMAttributeMap.cpp
+++ b/content/base/src/nsDOMAttributeMap.cpp
@@ -237,28 +237,28 @@ nsDOMAttributeMap::GetNamedItem(const ns
 
 NS_IMETHODIMP
 nsDOMAttributeMap::SetNamedItem(nsIDOMAttr* aAttr, nsIDOMAttr** aReturn)
 {
   Attr* attribute = static_cast<Attr*>(aAttr);
   NS_ENSURE_ARG(attribute);
 
   ErrorResult rv;
-  *aReturn = SetNamedItem(*attribute, rv).get();
+  *aReturn = SetNamedItem(*attribute, rv).take();
   return rv.ErrorCode();
 }
 
 NS_IMETHODIMP
 nsDOMAttributeMap::SetNamedItemNS(nsIDOMAttr* aAttr, nsIDOMAttr** aReturn)
 {
   Attr* attribute = static_cast<Attr*>(aAttr);
   NS_ENSURE_ARG(attribute);
 
   ErrorResult rv;
-  *aReturn = SetNamedItemNS(*attribute, rv).get();
+  *aReturn = SetNamedItemNS(*attribute, rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<Attr>
 nsDOMAttributeMap::SetNamedItemInternal(Attr& aAttr,
                                         bool aWithNS,
                                         ErrorResult& aError)
 {
@@ -351,17 +351,17 @@ nsDOMAttributeMap::SetNamedItemInternal(
 
 NS_IMETHODIMP
 nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName,
                                    nsIDOMAttr** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
 
   ErrorResult rv;
-  *aReturn = RemoveNamedItem(aName, rv).get();
+  *aReturn = RemoveNamedItem(aName, rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<Attr>
 nsDOMAttributeMap::RemoveNamedItem(const nsAString& aName, ErrorResult& aError)
 {
   if (!mContent) {
     aError.Throw(NS_ERROR_DOM_NOT_FOUND_ERR);
@@ -492,17 +492,17 @@ nsDOMAttributeMap::GetAttrNodeInfo(const
 
 NS_IMETHODIMP
 nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
                                      const nsAString& aLocalName,
                                      nsIDOMAttr** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
   ErrorResult rv;
-  *aReturn = RemoveNamedItemNS(aNamespaceURI, aLocalName, rv).get();
+  *aReturn = RemoveNamedItemNS(aNamespaceURI, aLocalName, rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<Attr>
 nsDOMAttributeMap::RemoveNamedItemNS(const nsAString& aNamespaceURI,
                                      const nsAString& aLocalName,
                                      ErrorResult& aError)
 {
--- a/content/base/src/nsDOMFile.cpp
+++ b/content/base/src/nsDOMFile.cpp
@@ -251,17 +251,17 @@ nsDOMFileBase::Slice(int64_t aStart, int
   if (optional_argc < 2) {
     aEnd = (int64_t)thisLength;
   }
 
   ParseSize((int64_t)thisLength, aStart, aEnd);
   
   // Create the new file
   *aBlob = CreateSlice((uint64_t)aStart, (uint64_t)(aEnd - aStart),
-                       aContentType).get();
+                       aContentType).take();
 
   return *aBlob ? NS_OK : NS_ERROR_UNEXPECTED;
 }
 
 NS_IMETHODIMP
 nsDOMFileBase::GetInternalStream(nsIInputStream **aStream)
 {
   // Must be overridden
--- a/content/base/src/nsDOMMutationObserver.h
+++ b/content/base/src/nsDOMMutationObserver.h
@@ -382,24 +382,25 @@ public:
   void HandleMutation();
 
   void GetObservingInfo(nsTArray<Nullable<MutationObservingInfo> >& aResult);
 
   mozilla::dom::MutationCallback* MutationCallback() { return mCallback; }
 
   void AppendMutationRecord(already_AddRefed<nsDOMMutationRecord> aRecord)
   {
-    MOZ_ASSERT(aRecord.get());
+    nsRefPtr<nsDOMMutationRecord> record = aRecord;
+    MOZ_ASSERT(record);
     if (!mLastPendingMutation) {
       MOZ_ASSERT(!mFirstPendingMutation);
-      mFirstPendingMutation = aRecord;
+      mFirstPendingMutation = record.forget();
       mLastPendingMutation = mFirstPendingMutation;
     } else {
       MOZ_ASSERT(mFirstPendingMutation);
-      mLastPendingMutation->mNext = aRecord;
+      mLastPendingMutation->mNext = record.forget();
       mLastPendingMutation = mLastPendingMutation->mNext;
     }
     ++mPendingMutationCount;
   }
 
   void ClearPendingRecords()
   {
     mFirstPendingMutation = nullptr;
--- a/content/base/src/nsDocument.cpp
+++ b/content/base/src/nsDocument.cpp
@@ -1260,17 +1260,17 @@ IMPL_SHIM(nsIApplicationCacheContainer)
       nsCOMPtr<_i> real = do_GetInterface(mCallbacks);                     \
       if (!real) {                                                         \
         return NS_NOINTERFACE;                                             \
       }                                                                    \
       nsCOMPtr<_i> shim = new _i##Shim(this, real);                        \
       if (!shim) {                                                         \
         return NS_ERROR_OUT_OF_MEMORY;                                     \
       }                                                                    \
-      *aSink = shim.forget().get();                                        \
+      shim.forget(aSink);                                                  \
       return NS_OK;                                                        \
     }                                                                      \
   PR_END_MACRO
 
 NS_IMETHODIMP
 nsExternalResourceMap::LoadgroupCallbacks::GetInterface(const nsIID & aIID,
                                                         void **aSink)
 {
@@ -3363,17 +3363,17 @@ nsDocument::NodesFromRectHelper(float aX
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::GetElementsByClassName(const nsAString& aClasses,
                                    nsIDOMNodeList** aReturn)
 {
-  *aReturn = nsIDocument::GetElementsByClassName(aClasses).get();
+  *aReturn = nsIDocument::GetElementsByClassName(aClasses).take();
   return NS_OK;
 }
 
 already_AddRefed<nsContentList>
 nsIDocument::GetElementsByClassName(const nsAString& aClasses)
 {
   return nsContentUtils::GetElementsByClassName(this, aClasses);
 }
@@ -5101,17 +5101,17 @@ nsIDocument::CreateElement(const nsAStri
   }
 
   nsCOMPtr<nsIContent> content;
   rv = CreateElem(needsLowercase ? lcTagName : aTagName,
                   nullptr, mDefaultElementType, getter_AddRefs(content));
   if (rv.Failed()) {
     return nullptr;
   }
-  return dont_AddRef(content.forget().get()->AsElement());
+  return dont_AddRef(content.forget().take()->AsElement());
 }
 
 void
 nsDocument::SwizzleCustomElement(Element* aElement,
                                  const nsAString& aTypeExtension,
                                  uint32_t aNamespaceID,
                                  ErrorResult& rv)
 {
@@ -5232,47 +5232,47 @@ nsDocument::CreateElementNS(const nsAStr
   }
 
   return elem.forget();
 }
 
 NS_IMETHODIMP
 nsDocument::CreateTextNode(const nsAString& aData, nsIDOMText** aReturn)
 {
-  *aReturn = nsIDocument::CreateTextNode(aData).get();
+  *aReturn = nsIDocument::CreateTextNode(aData).take();
   return NS_OK;
 }
 
 already_AddRefed<nsTextNode>
 nsIDocument::CreateTextNode(const nsAString& aData) const
 {
   nsRefPtr<nsTextNode> text = new nsTextNode(mNodeInfoManager);
   // Don't notify; this node is still being created.
   text->SetText(aData, false);
   return text.forget();
 }
 
 NS_IMETHODIMP
 nsDocument::CreateDocumentFragment(nsIDOMDocumentFragment** aReturn)
 {
-  *aReturn = nsIDocument::CreateDocumentFragment().get();
+  *aReturn = nsIDocument::CreateDocumentFragment().take();
   return NS_OK;
 }
 
 already_AddRefed<DocumentFragment>
 nsIDocument::CreateDocumentFragment() const
 {
   nsRefPtr<DocumentFragment> frag = new DocumentFragment(mNodeInfoManager);
   return frag.forget();
 }
 
 NS_IMETHODIMP
 nsDocument::CreateComment(const nsAString& aData, nsIDOMComment** aReturn)
 {
-  *aReturn = nsIDocument::CreateComment(aData).get();
+  *aReturn = nsIDocument::CreateComment(aData).take();
   return NS_OK;
 }
 
 // Unfortunately, bareword "Comment" is ambiguous with some Mac system headers.
 already_AddRefed<dom::Comment>
 nsIDocument::CreateComment(const nsAString& aData) const
 {
   nsRefPtr<dom::Comment> comment = new dom::Comment(mNodeInfoManager);
@@ -5283,17 +5283,17 @@ nsIDocument::CreateComment(const nsAStri
 }
 
 NS_IMETHODIMP
 nsDocument::CreateCDATASection(const nsAString& aData,
                                nsIDOMCDATASection** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
   ErrorResult rv;
-  *aReturn = nsIDocument::CreateCDATASection(aData, rv).get();
+  *aReturn = nsIDocument::CreateCDATASection(aData, rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<CDATASection>
 nsIDocument::CreateCDATASection(const nsAString& aData,
                                 ErrorResult& rv)
 {
   if (IsHTML()) {
@@ -5315,17 +5315,18 @@ nsIDocument::CreateCDATASection(const ns
 }
 
 NS_IMETHODIMP
 nsDocument::CreateProcessingInstruction(const nsAString& aTarget,
                                         const nsAString& aData,
                                         nsIDOMProcessingInstruction** aReturn)
 {
   ErrorResult rv;
-  *aReturn = nsIDocument::CreateProcessingInstruction(aTarget, aData, rv).get();
+  *aReturn =
+    nsIDocument::CreateProcessingInstruction(aTarget, aData, rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<ProcessingInstruction>
 nsIDocument::CreateProcessingInstruction(const nsAString& aTarget,
                                          const nsAString& aData,
                                          ErrorResult& rv) const
 {
@@ -5346,17 +5347,17 @@ nsIDocument::CreateProcessingInstruction
   return pi.forget();
 }
 
 NS_IMETHODIMP
 nsDocument::CreateAttribute(const nsAString& aName,
                             nsIDOMAttr** aReturn)
 {
   ErrorResult rv;
-  *aReturn = nsIDocument::CreateAttribute(aName, rv).get();
+  *aReturn = nsIDocument::CreateAttribute(aName, rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<Attr>
 nsIDocument::CreateAttribute(const nsAString& aName, ErrorResult& rv)
 {
   WarnOnceAbout(eCreateAttribute);
 
@@ -5387,17 +5388,17 @@ nsIDocument::CreateAttribute(const nsASt
 
 NS_IMETHODIMP
 nsDocument::CreateAttributeNS(const nsAString & aNamespaceURI,
                               const nsAString & aQualifiedName,
                               nsIDOMAttr **aResult)
 {
   ErrorResult rv;
   *aResult =
-    nsIDocument::CreateAttributeNS(aNamespaceURI, aQualifiedName, rv).get();
+    nsIDocument::CreateAttributeNS(aNamespaceURI, aQualifiedName, rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<Attr>
 nsIDocument::CreateAttributeNS(const nsAString& aNamespaceURI,
                                const nsAString& aQualifiedName,
                                ErrorResult& rv)
 {
@@ -5951,17 +5952,17 @@ nsDocument::RegisterElement(JSContext* a
 NS_IMETHODIMP
 nsDocument::GetElementsByTagName(const nsAString& aTagname,
                                  nsIDOMNodeList** aReturn)
 {
   nsRefPtr<nsContentList> list = GetElementsByTagName(aTagname);
   NS_ENSURE_TRUE(list, NS_ERROR_OUT_OF_MEMORY);
 
   // transfer ref to aReturn
-  *aReturn = list.forget().get();
+  list.forget(aReturn);
   return NS_OK;
 }
 
 already_AddRefed<nsContentList>
 nsIDocument::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
                                     const nsAString& aLocalName,
                                     ErrorResult& aResult)
 {
@@ -5989,17 +5990,17 @@ nsDocument::GetElementsByTagNameNS(const
   ErrorResult rv;
   nsRefPtr<nsContentList> list =
     nsIDocument::GetElementsByTagNameNS(aNamespaceURI, aLocalName, rv);
   if (rv.Failed()) {
     return rv.ErrorCode();
   }
 
   // transfer ref to aReturn
-  *aReturn = list.forget().get();
+  list.forget(aReturn);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::GetAsync(bool *aAsync)
 {
   NS_ERROR("nsDocument::GetAsync() should be overriden by subclass!");
 
@@ -6417,17 +6418,17 @@ nsIDocument::GetAnonymousNodes(Element& 
 {
   return BindingManager()->GetAnonymousNodesFor(&aElement);
 }
 
 NS_IMETHODIMP
 nsDocument::CreateRange(nsIDOMRange** aReturn)
 {
   ErrorResult rv;
-  *aReturn = nsIDocument::CreateRange(rv).get();
+  *aReturn = nsIDocument::CreateRange(rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<nsRange>
 nsIDocument::CreateRange(ErrorResult& rv)
 {
   nsRefPtr<nsRange> range = new nsRange(this);
   nsresult res = range->Set(this, 0, this, 0);
@@ -6457,17 +6458,17 @@ nsDocument::CreateNodeIterator(nsIDOMNod
   }
 
   nsCOMPtr<nsINode> root = do_QueryInterface(aRoot);
   NS_ENSURE_TRUE(root, NS_ERROR_UNEXPECTED);
 
   ErrorResult rv;
   NodeFilterHolder holder(aFilter);
   *_retval = nsIDocument::CreateNodeIterator(*root, aWhatToShow, holder,
-                                             rv).get();
+                                             rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<NodeIterator>
 nsIDocument::CreateNodeIterator(nsINode& aRoot, uint32_t aWhatToShow,
                                 NodeFilter* aFilter,
                                 ErrorResult& rv) const
 {
@@ -6500,17 +6501,17 @@ nsDocument::CreateTreeWalker(nsIDOMNode 
   }
 
   nsCOMPtr<nsINode> root = do_QueryInterface(aRoot);
   NS_ENSURE_TRUE(root, NS_ERROR_DOM_NOT_SUPPORTED_ERR);
 
   ErrorResult rv;
   NodeFilterHolder holder(aFilter);
   *_retval = nsIDocument::CreateTreeWalker(*root, aWhatToShow, holder,
-                                           rv).get();
+                                           rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<TreeWalker>
 nsIDocument::CreateTreeWalker(nsINode& aRoot, uint32_t aWhatToShow,
                               NodeFilter* aFilter,
                               ErrorResult& rv) const
 {
@@ -6536,17 +6537,17 @@ nsDocument::GetDefaultView(nsIDOMWindow*
   nsCOMPtr<nsPIDOMWindow> win = GetWindow();
   win.forget(aDefaultView);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::GetLocation(nsIDOMLocation **_retval)
 {
-  *_retval = nsIDocument::GetLocation().get();
+  *_retval = nsIDocument::GetLocation().take();
   return NS_OK;
 }
 
 already_AddRefed<nsIDOMLocation>
 nsIDocument::GetLocation() const
 {
   nsCOMPtr<nsIDOMWindow> w = do_QueryInterface(mScriptGlobalObject);
 
@@ -7647,17 +7648,17 @@ nsDocument::PreHandleEvent(nsEventChainP
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocument::CreateEvent(const nsAString& aEventType, nsIDOMEvent** aReturn)
 {
   NS_ENSURE_ARG_POINTER(aReturn);
   ErrorResult rv;
-  *aReturn = nsIDocument::CreateEvent(aEventType, rv).get();
+  *aReturn = nsIDocument::CreateEvent(aEventType, rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<Event>
 nsIDocument::CreateEvent(const nsAString& aEventType, ErrorResult& rv) const
 {
   nsIPresShell *shell = GetShell();
 
@@ -7669,17 +7670,17 @@ nsIDocument::CreateEvent(const nsAString
   }
 
   // Create event even without presContext.
   nsCOMPtr<nsIDOMEvent> ev;
   rv =
     nsEventDispatcher::CreateEvent(const_cast<nsIDocument*>(this),
                                    presContext, nullptr, aEventType,
                                    getter_AddRefs(ev));
-  return ev ? dont_AddRef(ev.forget().get()->InternalDOMEvent()) : nullptr;
+  return ev ? dont_AddRef(ev.forget().take()->InternalDOMEvent()) : nullptr;
 }
 
 void
 nsDocument::FlushPendingNotifications(mozFlushType aType)
 {
   nsDocumentOnStack dos(this);
 
   // We need to flush the sink for non-HTML documents (because the XML
@@ -10129,17 +10130,17 @@ nsIDocument::CaretPositionFromPoint(floa
   }
   return aCaretPos.forget();
 }
 
 NS_IMETHODIMP
 nsDocument::CaretPositionFromPoint(float aX, float aY, nsISupports** aCaretPos)
 {
   NS_ENSURE_ARG_POINTER(aCaretPos);
-  *aCaretPos = nsIDocument::CaretPositionFromPoint(aX, aY).get();
+  *aCaretPos = nsIDocument::CaretPositionFromPoint(aX, aY).take();
   return NS_OK;
 }
 
 void
 nsIDocument::ObsoleteSheet(nsIURI *aSheetURI, ErrorResult& rv)
 {
   nsresult res = CSSLoader()->ObsoleteSheet(aSheetURI);
   if (NS_FAILED(res)) {
--- a/content/base/src/nsDocumentEncoder.cpp
+++ b/content/base/src/nsDocumentEncoder.cpp
@@ -1020,17 +1020,17 @@ nsDocumentEncoder::EncodeToString(nsAStr
   if (!mDocument)
     return NS_ERROR_NOT_INITIALIZED;
 
   aOutputString.Truncate();
 
   nsString output;
   static const size_t bufferSize = 2048;
   if (!mCachedBuffer) {
-    mCachedBuffer = nsStringBuffer::Alloc(bufferSize).get();
+    mCachedBuffer = nsStringBuffer::Alloc(bufferSize).take();
   }
   NS_ASSERTION(!mCachedBuffer->IsReadonly(),
                "DocumentEncoder shouldn't keep reference to non-readonly buffer!");
   static_cast<char16_t*>(mCachedBuffer->Data())[0] = char16_t(0);
   mCachedBuffer->ToString(0, output, true);
   // output owns the buffer now!
   mCachedBuffer = nullptr;
   
--- a/content/base/src/nsINode.cpp
+++ b/content/base/src/nsINode.cpp
@@ -2540,17 +2540,17 @@ nsINode::QuerySelector(const nsAString& 
   elt.forget(aReturn);
   return NS_OK;
 }
 
 nsresult
 nsINode::QuerySelectorAll(const nsAString& aSelector, nsIDOMNodeList **aReturn)
 {
   ErrorResult rv;
-  *aReturn = nsINode::QuerySelectorAll(aSelector, rv).get();
+  *aReturn = nsINode::QuerySelectorAll(aSelector, rv).take();
   return rv.ErrorCode();
 }
 
 Element*
 nsINode::GetElementById(const nsAString& aId)
 {
   MOZ_ASSERT(IsElement() || IsNodeOfType(eDOCUMENT_FRAGMENT),
              "Bogus this object for GetElementById call");
--- a/content/base/src/nsImageLoadingContent.cpp
+++ b/content/base/src/nsImageLoadingContent.cpp
@@ -420,17 +420,17 @@ nsImageLoadingContent::GetRequest(int32_
 
 NS_IMETHODIMP
 nsImageLoadingContent::GetRequest(int32_t aRequestType,
                                   imgIRequest** aRequest)
 {
   NS_ENSURE_ARG_POINTER(aRequest);
 
   ErrorResult result;
-  *aRequest = GetRequest(aRequestType, result).get();
+  *aRequest = GetRequest(aRequestType, result).take();
 
   return result.ErrorCode();
 }
 
 NS_IMETHODIMP_(void)
 nsImageLoadingContent::FrameCreated(nsIFrame* aFrame)
 {
   NS_ASSERTION(aFrame, "aFrame is null");
@@ -534,17 +534,17 @@ nsImageLoadingContent::GetCurrentURI(Err
 }
 
 NS_IMETHODIMP
 nsImageLoadingContent::GetCurrentURI(nsIURI** aURI)
 {
   NS_ENSURE_ARG_POINTER(aURI);
 
   ErrorResult result;
-  *aURI = GetCurrentURI(result).get();
+  *aURI = GetCurrentURI(result).take();
   return result.ErrorCode();
 }
 
 already_AddRefed<nsIStreamListener>
 nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
                                             ErrorResult& aError)
 {
   if (!nsContentUtils::GetImgLoaderForChannel(aChannel)) {
@@ -589,17 +589,17 @@ nsImageLoadingContent::LoadImageWithChan
 
 NS_IMETHODIMP
 nsImageLoadingContent::LoadImageWithChannel(nsIChannel* aChannel,
                                             nsIStreamListener** aListener)
 {
   NS_ENSURE_ARG_POINTER(aListener);
 
   ErrorResult result;
-  *aListener = LoadImageWithChannel(aChannel, result).get();
+  *aListener = LoadImageWithChannel(aChannel, result).take();
   return result.ErrorCode();
 }
 
 void
 nsImageLoadingContent::ForceReload(ErrorResult& aError)
 {
   nsCOMPtr<nsIURI> currentURI;
   GetCurrentURI(getter_AddRefs(currentURI));
--- a/content/base/src/nsNameSpaceManager.cpp
+++ b/content/base/src/nsNameSpaceManager.cpp
@@ -134,37 +134,38 @@ nsNameSpaceManager::GetNameSpaceID(const
 
   return kNameSpaceID_Unknown;
 }
 
 nsresult
 NS_NewElement(Element** aResult,
               already_AddRefed<nsINodeInfo> aNodeInfo, FromParser aFromParser)
 {
-  int32_t ns = aNodeInfo.get()->NamespaceID();
+  nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
+  int32_t ns = ni->NamespaceID();
   if (ns == kNameSpaceID_XHTML) {
-    return NS_NewHTMLElement(aResult, aNodeInfo, aFromParser);
+    return NS_NewHTMLElement(aResult, ni.forget(), aFromParser);
   }
 #ifdef MOZ_XUL
   if (ns == kNameSpaceID_XUL) {
-    return NS_NewXULElement(aResult, aNodeInfo);
+    return NS_NewXULElement(aResult, ni.forget());
   }
 #endif
   if (ns == kNameSpaceID_MathML) {
-    return NS_NewMathMLElement(aResult, aNodeInfo);
+    return NS_NewMathMLElement(aResult, ni.forget());
   }
   if (ns == kNameSpaceID_SVG) {
-    return NS_NewSVGElement(aResult, aNodeInfo, aFromParser);
+    return NS_NewSVGElement(aResult, ni.forget(), aFromParser);
   }
-  if (ns == kNameSpaceID_XBL && aNodeInfo.get()->Equals(nsGkAtoms::children)) {
-    NS_ADDREF(*aResult = new XBLChildrenElement(aNodeInfo));
+  if (ns == kNameSpaceID_XBL && ni->Equals(nsGkAtoms::children)) {
+    NS_ADDREF(*aResult = new XBLChildrenElement(ni.forget()));
     return NS_OK;
   }
 
-  return NS_NewXMLElement(aResult, aNodeInfo);
+  return NS_NewXMLElement(aResult, ni.forget());
 }
 
 bool
 nsNameSpaceManager::HasElementCreator(int32_t aNameSpaceID)
 {
   return aNameSpaceID == kNameSpaceID_XHTML ||
 #ifdef MOZ_XUL
          aNameSpaceID == kNameSpaceID_XUL ||
--- a/content/base/src/nsRange.cpp
+++ b/content/base/src/nsRange.cpp
@@ -2172,17 +2172,17 @@ nsRange::CloneParentsBetween(nsINode *aA
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsRange::CloneContents(nsIDOMDocumentFragment** aReturn)
 {
   ErrorResult rv;
-  *aReturn = CloneContents(rv).get();
+  *aReturn = CloneContents(rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<DocumentFragment>
 nsRange::CloneContents(ErrorResult& aRv)
 {
   nsCOMPtr<nsINode> commonAncestor = GetCommonAncestorContainer(aRv);
   MOZ_ASSERT(!aRv.Failed(), "GetCommonAncestorContainer() shouldn't fail!");
@@ -2395,17 +2395,17 @@ nsRange::CloneRange() const
   range->DoSetRange(mStartParent, mStartOffset, mEndParent, mEndOffset, mRoot);
 
   return range.forget();
 }
 
 NS_IMETHODIMP
 nsRange::CloneRange(nsIDOMRange** aReturn)
 {
-  *aReturn = CloneRange().get();
+  *aReturn = CloneRange().take();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsRange::InsertNode(nsIDOMNode* aNode)
 {
   nsCOMPtr<nsINode> node = do_QueryInterface(aNode);
   if (!node) {
@@ -2872,17 +2872,17 @@ static void CollectClientRects(nsLayoutU
         nsLayoutUtils::GetContainingBlockForClientRect(frame), aCollector);
     }
   } while (!iter.IsDone());
 }
 
 NS_IMETHODIMP
 nsRange::GetBoundingClientRect(nsIDOMClientRect** aResult)
 {
-  *aResult = GetBoundingClientRect().get();
+  *aResult = GetBoundingClientRect().take();
   return NS_OK;
 }
 
 already_AddRefed<DOMRect>
 nsRange::GetBoundingClientRect()
 {
   nsRefPtr<DOMRect> rect = new DOMRect(ToSupports(this));
   if (!mStartParent) {
@@ -2897,17 +2897,17 @@ nsRange::GetBoundingClientRect()
     accumulator.mResultRect;
   rect->SetLayoutRect(r);
   return rect.forget();
 }
 
 NS_IMETHODIMP
 nsRange::GetClientRects(nsIDOMClientRectList** aResult)
 {
-  *aResult = GetClientRects().get();
+  *aResult = GetClientRects().take();
   return NS_OK;
 }
 
 already_AddRefed<DOMRectList>
 nsRange::GetClientRects()
 {
   if (!mStartParent) {
     return nullptr;
--- a/content/base/src/nsXMLHttpRequest.cpp
+++ b/content/base/src/nsXMLHttpRequest.cpp
@@ -3511,21 +3511,21 @@ nsXMLHttpRequest::GetInterface(const nsI
   nsresult rv;
 
   // Make sure to return ourselves for the channel event sink interface and
   // progress event sink interface, no matter what.  We can forward these to
   // mNotificationCallbacks if it wants to get notifications for them.  But we
   // need to see these notifications for proper functioning.
   if (aIID.Equals(NS_GET_IID(nsIChannelEventSink))) {
     mChannelEventSink = do_GetInterface(mNotificationCallbacks);
-    *aResult = static_cast<nsIChannelEventSink*>(EnsureXPCOMifier().get());
+    *aResult = static_cast<nsIChannelEventSink*>(EnsureXPCOMifier().take());
     return NS_OK;
   } else if (aIID.Equals(NS_GET_IID(nsIProgressEventSink))) {
     mProgressEventSink = do_GetInterface(mNotificationCallbacks);
-    *aResult = static_cast<nsIProgressEventSink*>(EnsureXPCOMifier().get());
+    *aResult = static_cast<nsIProgressEventSink*>(EnsureXPCOMifier().take());
     return NS_OK;
   }
 
   // Now give mNotificationCallbacks (if non-null) a chance to return the
   // desired interface.
   if (mNotificationCallbacks) {
     rv = mNotificationCallbacks->GetInterface(aIID, aResult);
     if (NS_SUCCEEDED(rv)) {
@@ -3614,25 +3614,25 @@ nsXMLHttpRequest::GetInterface(const nsI
 
     return wwatch->GetPrompt(window, aIID,
                              reinterpret_cast<void**>(aResult));
   }
   // Now check for the various XHR non-DOM interfaces, except
   // nsIProgressEventSink and nsIChannelEventSink which we already
   // handled above.
   else if (aIID.Equals(NS_GET_IID(nsIStreamListener))) {
-    *aResult = static_cast<nsIStreamListener*>(EnsureXPCOMifier().get());
+    *aResult = static_cast<nsIStreamListener*>(EnsureXPCOMifier().take());
     return NS_OK;
   }
   else if (aIID.Equals(NS_GET_IID(nsIRequestObserver))) {
-    *aResult = static_cast<nsIRequestObserver*>(EnsureXPCOMifier().get());
+    *aResult = static_cast<nsIRequestObserver*>(EnsureXPCOMifier().take());
     return NS_OK;
   }
   else if (aIID.Equals(NS_GET_IID(nsITimerCallback))) {
-    *aResult = static_cast<nsITimerCallback*>(EnsureXPCOMifier().get());
+    *aResult = static_cast<nsITimerCallback*>(EnsureXPCOMifier().take());
     return NS_OK;
   }
 
   return QueryInterface(aIID, aResult);
 }
 
 JS::Value
 nsXMLHttpRequest::GetInterface(JSContext* aCx, nsIJSID* aIID, ErrorResult& aRv)
--- a/content/html/content/src/HTMLCanvasElement.cpp
+++ b/content/html/content/src/HTMLCanvasElement.cpp
@@ -668,17 +668,18 @@ HTMLCanvasElement::GetContextHelper(cons
   return NS_OK;
 }
 
 nsresult
 HTMLCanvasElement::GetContext(const nsAString& aContextId,
                               nsISupports** aContext)
 {
   ErrorResult rv;
-  *aContext = GetContext(nullptr, aContextId, JS::NullHandleValue, rv).get();
+  *aContext =
+    GetContext(nullptr, aContextId, JS::NullHandleValue, rv).take();
   return rv.ErrorCode();
 }
 
 static bool
 IsContextIdWebGL(const nsAString& str)
 {
   return str.EqualsLiteral("webgl") ||
          str.EqualsLiteral("experimental-webgl");
--- a/content/html/content/src/HTMLInputElement.cpp
+++ b/content/html/content/src/HTMLInputElement.cpp
@@ -394,17 +394,17 @@ public:
     mNextFile->GetLeafName(leafName);
     MOZ_ASSERT(leafName.Length() <= path.Length());
     int32_t length = path.Length() - leafName.Length();
     MOZ_ASSERT(length >= 0);
     if (length > 0) {
       // Note that we leave the trailing "/" on the path.
       domFile->SetPath(Substring(path, 0, uint32_t(length)));
     }
-    *aResult = static_cast<nsIDOMFile*>(domFile.forget().get());
+    *aResult = domFile.forget().downcast<nsIDOMFile>().take();
     LookupAndCacheNext();
     return NS_OK;
   }
 
   NS_IMETHOD
   HasMoreElements(bool* aResult)
   {
     *aResult = !!mNextFile;
--- a/content/html/content/src/HTMLMediaElement.cpp
+++ b/content/html/content/src/HTMLMediaElement.cpp
@@ -1824,17 +1824,17 @@ HTMLMediaElement::MozCaptureStream(Error
   }
 
   return stream.forget();
 }
 
 NS_IMETHODIMP HTMLMediaElement::MozCaptureStream(nsIDOMMediaStream** aStream)
 {
   ErrorResult rv;
-  *aStream = MozCaptureStream(rv).get();
+  *aStream = MozCaptureStream(rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<DOMMediaStream>
 HTMLMediaElement::MozCaptureStreamUntilEnded(ErrorResult& aRv)
 {
   nsRefPtr<DOMMediaStream> stream = CaptureStreamInternal(true);
   if (!stream) {
@@ -1843,17 +1843,17 @@ HTMLMediaElement::MozCaptureStreamUntilE
   }
 
   return stream.forget();
 }
 
 NS_IMETHODIMP HTMLMediaElement::MozCaptureStreamUntilEnded(nsIDOMMediaStream** aStream)
 {
   ErrorResult rv;
-  *aStream = MozCaptureStreamUntilEnded(rv).get();
+  *aStream = MozCaptureStreamUntilEnded(rv).take();
   return rv.ErrorCode();
 }
 
 NS_IMETHODIMP HTMLMediaElement::GetMozAudioCaptured(bool* aCaptured)
 {
   *aCaptured = MozAudioCaptured();
   return NS_OK;
 }
--- a/content/html/content/src/nsFormSubmission.cpp
+++ b/content/html/content/src/nsFormSubmission.cpp
@@ -556,17 +556,17 @@ nsFSMultipartFormData::GetEncodedSubmiss
 
   nsAutoCString contentType;
   GetContentType(contentType);
   mimeStream->AddHeader("Content-Type", contentType.get());
   mimeStream->SetAddContentLength(true);
   uint64_t unused;
   mimeStream->SetData(GetSubmissionBody(&unused));
 
-  *aPostDataStream = mimeStream.forget().get();
+  mimeStream.forget(aPostDataStream);
 
   return NS_OK;
 }
 
 nsresult
 nsFSMultipartFormData::AddPostDataStream()
 {
   nsresult rv = NS_OK;
--- a/content/html/content/src/nsGenericHTMLElement.cpp
+++ b/content/html/content/src/nsGenericHTMLElement.cpp
@@ -317,17 +317,17 @@ nsGenericHTMLElement::Dataset()
 
   nsRefPtr<nsDOMStringMap> ret = slots->mDataset;
   return ret.forget();
 }
 
 NS_IMETHODIMP
 nsGenericHTMLElement::GetDataset(nsISupports** aDataset)
 {
-  *aDataset = Dataset().get();
+  *aDataset = Dataset().take();
   return NS_OK;
 }
 
 nsresult
 nsGenericHTMLElement::ClearDataset()
 {
   nsDOMSlots *slots = GetExistingDOMSlots();
 
@@ -740,17 +740,17 @@ nsGenericHTMLElement::PostHandleEventFor
   return PostHandleEventForLinks(aVisitor);
 }
 
 bool
 nsGenericHTMLElement::IsHTMLLink(nsIURI** aURI) const
 {
   NS_PRECONDITION(aURI, "Must provide aURI out param");
 
-  *aURI = GetHrefURIForAnchors().get();
+  *aURI = GetHrefURIForAnchors().take();
   // We promise out param is non-null if we return true, so base rv on it
   return *aURI != nullptr;
 }
 
 already_AddRefed<nsIURI>
 nsGenericHTMLElement::GetHrefURIForAnchors() const
 {
   // This is used by the three Link implementations and
--- a/content/html/document/src/ImageDocument.cpp
+++ b/content/html/document/src/ImageDocument.cpp
@@ -318,17 +318,17 @@ ImageDocument::GetImageRequest(ErrorResu
   }
   return imageRequest.forget();
 }
 
 NS_IMETHODIMP
 ImageDocument::GetImageRequest(imgIRequest** aImageRequest)
 {
   ErrorResult rv;
-  *aImageRequest = GetImageRequest(rv).get();
+  *aImageRequest = GetImageRequest(rv).take();
   return rv.ErrorCode();
 }
 
 void
 ImageDocument::ShrinkToFit()
 {
   if (!mImageContent) {
     return;
--- a/content/html/document/src/nsHTMLContentSink.cpp
+++ b/content/html/document/src/nsHTMLContentSink.cpp
@@ -258,36 +258,36 @@ NS_NewHTMLElement(Element** aResult, alr
   NS_ASSERTION(nodeInfo->NamespaceEquals(kNameSpaceID_XHTML), 
                "Trying to HTML elements that don't have the XHTML namespace");
 
   // Per the Custom Element specification, unknown tags that are valid custom
   // element names should be HTMLElement instead of HTMLUnknownElement.
   int32_t tag = parserService->HTMLCaseSensitiveAtomTagToId(name);
   if (tag == eHTMLTag_userdefined &&
       nsContentUtils::IsCustomElementName(name)) {
+    nsIDocument* doc = nodeInfo->GetDocument();
+
     NS_IF_ADDREF(*aResult = NS_NewHTMLElement(nodeInfo.forget(), aFromParser));
     if (!*aResult) {
       return NS_ERROR_OUT_OF_MEMORY;
     }
 
-    nsIDocument* doc = aNodeInfo.get()->GetDocument();
-
     // Element may be unresolved at this point.
     doc->RegisterUnresolvedElement(*aResult);
 
     // Try to enqueue a created callback. The custom element data will be set
     // and created callback will be enqueued if the custom element type
     // has already been registered.
     doc->EnqueueLifecycleCallback(nsIDocument::eCreated, *aResult);
 
     return NS_OK;
   }
 
   *aResult = CreateHTMLElement(tag,
-                               nodeInfo.forget(), aFromParser).get();
+                               nodeInfo.forget(), aFromParser).take();
   return *aResult ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 already_AddRefed<nsGenericHTMLElement>
 CreateHTMLElement(uint32_t aNodeType, already_AddRefed<nsINodeInfo> aNodeInfo,
                   FromParser aFromParser)
 {
   NS_ASSERTION(aNodeType <= NS_HTML_TAG_MAX ||
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -1315,32 +1315,32 @@ nsHTMLDocument::Open(const nsAString& aC
                      const nsAString& aFeatures,
                      JSContext* cx, uint8_t aOptionalArgCount,
                      nsISupports** aReturn)
 {
   // When called with 3 or more arguments, document.open() calls window.open().
   if (aOptionalArgCount > 2) {
     ErrorResult rv;
     *aReturn = Open(cx, aContentTypeOrUrl, aReplaceOrName, aFeatures,
-                    false, rv).get();
+                    false, rv).take();
     return rv.ErrorCode();
   }
 
   nsString type;
   if (aOptionalArgCount > 0) {
     type = aContentTypeOrUrl;
   } else {
     type.AssignLiteral("text/html");
   }
   nsString replace;
   if (aOptionalArgCount > 1) {
     replace = aReplaceOrName;
   }
   ErrorResult rv;
-  *aReturn = Open(cx, type, replace, rv).get();
+  *aReturn = Open(cx, type, replace, rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<nsIDOMWindow>
 nsHTMLDocument::Open(JSContext* /* unused */,
                      const nsAString& aURL,
                      const nsAString& aName,
                      const nsAString& aFeatures,
@@ -1905,17 +1905,17 @@ nsHTMLDocument::UseExistingNameString(ns
 {
   return const_cast<nsString*>(aName);
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetElementsByName(const nsAString& aElementName,
                                   nsIDOMNodeList** aReturn)
 {
-  *aReturn = GetElementsByName(aElementName).get();
+  *aReturn = GetElementsByName(aElementName).take();
   return NS_OK;
 }
 
 static bool MatchItems(nsIContent* aContent, int32_t aNameSpaceID, 
                        nsIAtom* aAtom, void* aData)
 {
   if (!(aContent->IsElement() && aContent->AsElement()->IsHTML())) {
     return false;
@@ -1978,17 +1978,17 @@ static void* CreateTokens(nsINode* aRoot
     }
   }
   return tokens;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetItems(const nsAString& types, nsIDOMNodeList** aReturn)
 {
-  *aReturn = GetItems(types).get();
+  *aReturn = GetItems(types).take();
   return NS_OK;
 }
 
 already_AddRefed<nsINodeList>
 nsHTMLDocument::GetItems(const nsAString& aTypeNames)
 {
   return NS_GetFuncStringNodeList(this, MatchItems, DestroyTokens, CreateTokens,
                                   aTypeNames);
@@ -2148,17 +2148,17 @@ nsHTMLDocument::Embeds()
   }
   return mEmbeds;
 }
 
 NS_IMETHODIMP
 nsHTMLDocument::GetSelection(nsISelection** aReturn)
 {
   ErrorResult rv;
-  *aReturn = GetSelection(rv).get();
+  *aReturn = GetSelection(rv).take();
   return rv.ErrorCode();
 }
 
 already_AddRefed<Selection>
 nsHTMLDocument::GetSelection(ErrorResult& rv)
 {
   nsCOMPtr<nsIDOMWindow> window = do_QueryInterface(GetScopeObject());
   nsCOMPtr<nsPIDOMWindow> pwin = do_QueryInterface(window);
--- a/content/mathml/content/src/nsMathMLElementFactory.cpp
+++ b/content/mathml/content/src/nsMathMLElementFactory.cpp
@@ -8,15 +8,16 @@
 #include "nsMathMLElement.h"
 
 using namespace mozilla::dom;
 
 // MathML Element Factory (declared in nsContentCreatorFunctions.h)
 nsresult
 NS_NewMathMLElement(Element** aResult, already_AddRefed<nsINodeInfo> aNodeInfo)
 {
-  aNodeInfo.get()->SetIDAttributeAtom(nsGkAtoms::id);
+  nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
+  ni->SetIDAttributeAtom(nsGkAtoms::id);
 
-  nsMathMLElement* it = new nsMathMLElement(aNodeInfo);
+  nsMathMLElement* it = new nsMathMLElement(ni.forget());
 
   NS_ADDREF(*aResult = it);
   return NS_OK;
 }
--- a/content/media/gstreamer/GStreamerReader-0.10.cpp
+++ b/content/media/gstreamer/GStreamerReader-0.10.cpp
@@ -41,18 +41,18 @@ GstFlowReturn GStreamerReader::AllocateV
                                                        GstBuffer** aBuf,
                                                        nsRefPtr<PlanarYCbCrImage>& aImage)
 {
   /* allocate an image using the container */
   ImageContainer* container = mDecoder->GetImageContainer();
   if (container == nullptr) {
     return GST_FLOW_ERROR;
   }
-  PlanarYCbCrImage* img = reinterpret_cast<PlanarYCbCrImage*>(container->CreateImage(ImageFormat::PLANAR_YCBCR).get());
-  nsRefPtr<PlanarYCbCrImage> image = dont_AddRef(img);
+  nsRefPtr<PlanarYCbCrImage> image =
+    container->CreateImage(ImageFormat::PLANAR_YCBCR).downcast<PlanarYCbCrImage>();
 
   /* prepare a GstBuffer pointing to the underlying PlanarYCbCrImage buffer */
   GstBuffer* buf = GST_BUFFER(gst_moz_video_buffer_new());
   GST_BUFFER_SIZE(buf) = aSize;
   /* allocate the actual YUV buffer */
   GST_BUFFER_DATA(buf) = image->AllocateAndGetNewBuffer(aSize);
 
   aImage = image;
--- a/content/media/webspeech/recognition/SpeechRecognition.cpp
+++ b/content/media/webspeech/recognition/SpeechRecognition.cpp
@@ -819,22 +819,22 @@ SpeechRecognition::SplitSamplesBuffer(co
   return chunkStart;
 }
 
 AudioSegment*
 SpeechRecognition::CreateAudioSegment(nsTArray<already_AddRefed<SharedBuffer> >& aChunks)
 {
   AudioSegment* segment = new AudioSegment();
   for (uint32_t i = 0; i < aChunks.Length(); ++i) {
-    const int16_t* chunkData =
-      static_cast<const int16_t*>(aChunks[i].get()->Data());
+    nsRefPtr<SharedBuffer> buffer = aChunks[i];
+    const int16_t* chunkData = static_cast<const int16_t*>(buffer->Data());
 
     nsAutoTArray<const int16_t*, 1> channels;
     channels.AppendElement(chunkData);
-    segment->AppendFrames(aChunks[i], channels, mAudioSamplesPerChunk);
+    segment->AppendFrames(buffer.forget(), channels, mAudioSamplesPerChunk);
   }
 
   return segment;
 }
 
 void
 SpeechRecognition::FeedAudioData(already_AddRefed<SharedBuffer> aSamples,
                                  uint32_t aDuration,
--- a/content/svg/content/src/SVGElementFactory.cpp
+++ b/content/svg/content/src/SVGElementFactory.cpp
@@ -112,32 +112,33 @@ SVGElementFactory::Exists(nsIAtom *aTag)
 }
 
 nsresult
 NS_NewSVGElement(Element** aResult, already_AddRefed<nsINodeInfo> aNodeInfo,
                  FromParser aFromParser)
 {
   NS_ASSERTION(sTagAtomTable, "no lookup table, needs SVGElementFactory::Init");
 
-  nsIAtom* name = aNodeInfo.get()->NameAtom();
+  nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
+  nsIAtom* name = ni->NameAtom();
 
-  NS_ASSERTION(aNodeInfo.get()->NamespaceEquals(kNameSpaceID_SVG), 
+  NS_ASSERTION(ni->NamespaceEquals(kNameSpaceID_SVG),
                "Trying to create SVG elements that aren't in the SVG namespace");
 
   void* tag = PL_HashTableLookupConst(sTagAtomTable, name);
   if (tag) {
     int32_t index = NS_PTR_TO_INT32(tag) - TABLE_VALUE_OFFSET;
     if (index < 0 || index >= eSVGTag_Count) {
       NS_WARNING("About to index out of array bounds - crashing instead");
       MOZ_CRASH();
     }
 
     contentCreatorCallback cb = sContentCreatorCallbacks[index];
 
     nsCOMPtr<nsIContent> content;
-    nsresult rv = cb(getter_AddRefs(content), aNodeInfo, aFromParser);
-    *aResult = content.forget().get()->AsElement();
+    nsresult rv = cb(getter_AddRefs(content), ni.forget(), aFromParser);
+    *aResult = content.forget().take()->AsElement();
     return rv;
   }
 
   // if we don't know what to create, just create a standard svg element:
-  return NS_NewSVGElement(aResult, aNodeInfo);
+  return NS_NewSVGElement(aResult, ni.forget());
 }
--- a/content/svg/content/src/nsSVGElement.cpp
+++ b/content/svg/content/src/nsSVGElement.cpp
@@ -94,17 +94,17 @@ nsSVGElement::WrapNode(JSContext *aCx, J
 }
 
 //----------------------------------------------------------------------
 
 /* readonly attribute SVGAnimatedString className; */
 NS_IMETHODIMP
 nsSVGElement::GetClassName(nsISupports** aClassName)
 {
-  *aClassName = ClassName().get();
+  *aClassName = ClassName().take();
   return NS_OK;
 }
 
 /* readonly attribute nsIDOMCSSStyleDeclaration style; */
 NS_IMETHODIMP
 nsSVGElement::GetStyle(nsIDOMCSSStyleDeclaration** aStyle)
 {
   NS_ADDREF(*aStyle = Style());
--- a/content/xul/content/src/nsXULElement.cpp
+++ b/content/xul/content/src/nsXULElement.cpp
@@ -290,36 +290,38 @@ nsXULElement::Create(nsXULPrototypeEleme
     element.forget(aResult);
 
     return NS_OK;
 }
 
 nsresult
 NS_NewXULElement(Element** aResult, already_AddRefed<nsINodeInfo> aNodeInfo)
 {
-    NS_PRECONDITION(aNodeInfo.get(), "need nodeinfo for non-proto Create");
+    nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
 
-    nsIDocument* doc = aNodeInfo.get()->GetDocument();
+    NS_PRECONDITION(ni, "need nodeinfo for non-proto Create");
+
+    nsIDocument* doc = ni->GetDocument();
     if (doc && !doc->AllowXULXBL()) {
-        nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
         return NS_ERROR_NOT_AVAILABLE;
     }
 
-    NS_ADDREF(*aResult = new nsXULElement(aNodeInfo));
+    NS_ADDREF(*aResult = new nsXULElement(ni.forget()));
 
     return NS_OK;
 }
 
 void
 NS_TrustedNewXULElement(nsIContent** aResult, already_AddRefed<nsINodeInfo> aNodeInfo)
 {
-    NS_PRECONDITION(aNodeInfo.get(), "need nodeinfo for non-proto Create");
+    nsCOMPtr<nsINodeInfo> ni = aNodeInfo;
+    NS_PRECONDITION(ni, "need nodeinfo for non-proto Create");
 
     // Create an nsXULElement with the specified namespace and tag.
-    NS_ADDREF(*aResult = new nsXULElement(aNodeInfo));
+    NS_ADDREF(*aResult = new nsXULElement(ni.forget()));
 }
 
 //----------------------------------------------------------------------
 // nsISupports interface
 
 NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULElement)
 
 NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(nsXULElement,
@@ -411,17 +413,17 @@ nsXULElement::Clone(nsINodeInfo *aNodeIn
 
 //----------------------------------------------------------------------
 
 NS_IMETHODIMP
 nsXULElement::GetElementsByAttribute(const nsAString& aAttribute,
                                      const nsAString& aValue,
                                      nsIDOMNodeList** aReturn)
 {
-    *aReturn = GetElementsByAttribute(aAttribute, aValue).get();
+    *aReturn = GetElementsByAttribute(aAttribute, aValue).take();
     return NS_OK;
 }
 
 already_AddRefed<nsINodeList>
 nsXULElement::GetElementsByAttribute(const nsAString& aAttribute,
                                      const nsAString& aValue)
 {
     nsCOMPtr<nsIAtom> attrAtom(do_GetAtom(aAttribute));
@@ -440,17 +442,17 @@ nsXULElement::GetElementsByAttribute(con
 NS_IMETHODIMP
 nsXULElement::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
                                        const nsAString& aAttribute,
                                        const nsAString& aValue,
                                        nsIDOMNodeList** aReturn)
 {
     ErrorResult rv;
     *aReturn =
-        GetElementsByAttributeNS(aNamespaceURI, aAttribute, aValue, rv).get();
+        GetElementsByAttributeNS(aNamespaceURI, aAttribute, aValue, rv).take();
     return rv.ErrorCode();
 }
 
 already_AddRefed<nsINodeList>
 nsXULElement::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
                                        const nsAString& aAttribute,
                                        const nsAString& aValue,
                                        ErrorResult& rv)
@@ -1217,17 +1219,17 @@ nsXULElement::PreHandleEvent(nsEventChai
     return nsStyledElement::PreHandleEvent(aVisitor);
 }
 
 // XXX This _should_ be an implementation method, _not_ publicly exposed :-(
 NS_IMETHODIMP
 nsXULElement::GetResource(nsIRDFResource** aResource)
 {
     ErrorResult rv;
-    *aResource = GetResource(rv).get();
+    *aResource = GetResource(rv).take();
     return rv.ErrorCode();
 }
 
 already_AddRefed<nsIRDFResource>
 nsXULElement::GetResource(ErrorResult& rv)
 {
     nsAutoString id;
     GetAttr(kNameSpaceID_None, nsGkAtoms::ref, id);
@@ -1243,17 +1245,17 @@ nsXULElement::GetResource(ErrorResult& r
     rv = nsXULContentUtils::RDFService()->
         GetUnicodeResource(id, getter_AddRefs(resource));
     return resource.forget();
 }
 
 NS_IMETHODIMP
 nsXULElement::GetDatabase(nsIRDFCompositeDataSource** aDatabase)
 {
-    *aDatabase = GetDatabase().get();
+    *aDatabase = GetDatabase().take();
     return NS_OK;
 }
 
 already_AddRefed<nsIRDFCompositeDataSource>
 nsXULElement::GetDatabase()
 {
     nsCOMPtr<nsIXULTemplateBuilder> builder = GetBuilder();
     if (!builder) {
@@ -1264,17 +1266,17 @@ nsXULElement::GetDatabase()
     builder->GetDatabase(getter_AddRefs(database));
     return database.forget();
 }
 
 
 NS_IMETHODIMP
 nsXULElement::GetBuilder(nsIXULTemplateBuilder** aBuilder)
 {
-    *aBuilder = GetBuilder().get();
+    *aBuilder = GetBuilder().take();
     return NS_OK;
 }
 
 already_AddRefed<nsIXULTemplateBuilder>
 nsXULElement::GetBuilder()
 {
     // XXX sXBL/XBL2 issue! Owner or current document?
     nsCOMPtr<nsIXULDocument> xuldoc = do_QueryInterface(GetCurrentDoc());
@@ -1358,17 +1360,17 @@ nsXULElement::GetControllers(ErrorResult
 
     return Controllers();
 }
 
 NS_IMETHODIMP
 nsXULElement::GetBoxObject(nsIBoxObject** aResult)
 {
     ErrorResult rv;
-    *aResult = GetBoxObject(rv).get();
+    *aResult = GetBoxObject(rv).take();
     return rv.ErrorCode();
 }
 
 already_AddRefed<nsIBoxObject>
 nsXULElement::GetBoxObject(ErrorResult& rv)
 {
     // XXX sXBL/XBL2 issue! Owner or current document?
     return OwnerDoc()->GetBoxObjectFor(this, rv);
@@ -1461,17 +1463,17 @@ nsXULElement::LoadSrc()
     }
 
     return slots->mFrameLoader->LoadFrame();
 }
 
 nsresult
 nsXULElement::GetFrameLoader(nsIFrameLoader **aFrameLoader)
 {
-    *aFrameLoader = GetFrameLoader().get();
+    *aFrameLoader = GetFrameLoader().take();
     return NS_OK;
 }
 
 already_AddRefed<nsFrameLoader>
 nsXULElement::GetFrameLoader()
 {
     nsXULSlots* slots = static_cast<nsXULSlots*>(GetExistingSlots());
     if (!slots)
--- a/content/xul/document/src/XULDocument.cpp
+++ b/content/xul/document/src/XULDocument.cpp
@@ -1215,17 +1215,17 @@ XULDocument::ResolveForwardReferences()
 // nsIDOMDocument interface
 //
 
 NS_IMETHODIMP
 XULDocument::GetElementsByAttribute(const nsAString& aAttribute,
                                     const nsAString& aValue,
                                     nsIDOMNodeList** aReturn)
 {
-    *aReturn = GetElementsByAttribute(aAttribute, aValue).get();
+    *aReturn = GetElementsByAttribute(aAttribute, aValue).take();
     return NS_OK;
 }
 
 already_AddRefed<nsINodeList>
 XULDocument::GetElementsByAttribute(const nsAString& aAttribute,
                                     const nsAString& aValue)
 {
     nsCOMPtr<nsIAtom> attrAtom(do_GetAtom(aAttribute));
@@ -1244,17 +1244,17 @@ XULDocument::GetElementsByAttribute(cons
 NS_IMETHODIMP
 XULDocument::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
                                       const nsAString& aAttribute,
                                       const nsAString& aValue,
                                       nsIDOMNodeList** aReturn)
 {
     ErrorResult rv;
     *aReturn = GetElementsByAttributeNS(aNamespaceURI, aAttribute,
-                                        aValue, rv).get();
+                                        aValue, rv).take();
     return rv.ErrorCode();
 }
 
 already_AddRefed<nsINodeList>
 XULDocument::GetElementsByAttributeNS(const nsAString& aNamespaceURI,
                                       const nsAString& aAttribute,
                                       const nsAString& aValue,
                                       ErrorResult& aRv)
@@ -4773,17 +4773,17 @@ XULDocument::GetDocumentLWTheme()
     return mDocLWTheme;
 }
 
 NS_IMETHODIMP
 XULDocument::GetBoxObjectFor(nsIDOMElement* aElement, nsIBoxObject** aResult)
 {
     ErrorResult rv;
     nsCOMPtr<Element> el = do_QueryInterface(aElement);
-    *aResult = GetBoxObjectFor(el, rv).get();
+    *aResult = GetBoxObjectFor(el, rv).take();
     return rv.ErrorCode();
 }
 
 JSObject*
 XULDocument::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aScope)
 {
   return XULDocumentBinding::Wrap(aCx, aScope, this);
 }
--- a/content/xul/templates/src/nsXULTemplateBuilder.cpp
+++ b/content/xul/templates/src/nsXULTemplateBuilder.cpp
@@ -2113,17 +2113,17 @@ nsXULTemplateBuilder::DetermineRDFQueryR
 
         if (!uri.IsEmpty())
             mRefVariable = do_GetAtom(uri);
 
         nsAutoString tag;
         content->GetAttr(kNameSpaceID_None, nsGkAtoms::tag, tag);
 
         if (!tag.IsEmpty())
-            *aTag = NS_NewAtom(tag).get();
+            *aTag = NS_NewAtom(tag).take();
     }
 }
 
 nsresult
 nsXULTemplateBuilder::CompileSimpleQuery(nsIContent* aRuleElement,
                                          nsTemplateQuerySet* aQuerySet,
                                          bool* aCanUseTemplate)
 {
--- a/dom/base/nsDOMClassInfo.cpp
+++ b/dom/base/nsDOMClassInfo.cpp
@@ -3955,17 +3955,17 @@ NS_IMPL_RELEASE(nsEventListenerThisTrans
 NS_IMETHODIMP
 nsEventListenerThisTranslator::TranslateThis(nsISupports *aInitialThis,
                                              nsISupports **_retval)
 {
   nsCOMPtr<nsIDOMEvent> event(do_QueryInterface(aInitialThis));
   NS_ENSURE_TRUE(event, NS_ERROR_UNEXPECTED);
 
   nsCOMPtr<EventTarget> target = event->InternalDOMEvent()->GetCurrentTarget();
-  *_retval = target.forget().get();
+  target.forget(_retval);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMConstructorSH::PreCreate(nsISupports *nativeObj, JSContext *cx,
                               JSObject *aGlobalObj, JSObject **parentObj)
 {
   JS::Rooted<JSObject*> globalObj(cx, aGlobalObj);
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -3937,17 +3937,17 @@ nsGlobalWindow::GetContentInternal(Error
   domWindow = do_GetInterface(primaryContent);
   return domWindow.forget();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetContent(nsIDOMWindow** aContent)
 {
   ErrorResult rv;
-  *aContent = GetContentInternal(rv).get();
+  *aContent = GetContentInternal(rv).take();
 
   return rv.ErrorCode();
 }
 
 NS_IMETHODIMP
 nsGlobalWindow::GetScriptableContent(JSContext* aCx, JS::MutableHandle<JS::Value> aVal)
 {
   ErrorResult rv;
--- a/dom/base/nsLocation.cpp
+++ b/dom/base/nsLocation.cpp
@@ -891,17 +891,17 @@ nsLocation::GetSourceBaseURL(JSContext* 
   if (!sgo && GetDocShell()) {
     sgo = do_GetInterface(GetDocShell());
   }
   NS_ENSURE_TRUE(sgo, NS_OK);
   nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(sgo);
   NS_ENSURE_TRUE(window, NS_ERROR_UNEXPECTED);
   nsIDocument* doc = window->GetDoc();
   NS_ENSURE_TRUE(doc, NS_OK);
-  *sourceURL = doc->GetBaseURI().get();
+  *sourceURL = doc->GetBaseURI().take();
   return NS_OK;
 }
 
 bool
 nsLocation::CallerSubsumes()
 {
   // Get the principal associated with the location object.
   nsCOMPtr<nsIDOMWindow> outer = do_QueryReferent(mOuter);
--- a/dom/camera/GonkCameraControl.cpp
+++ b/dom/camera/GonkCameraControl.cpp
@@ -1062,17 +1062,18 @@ nsresult
 nsGonkCameraControl::SetupVideoMode(const nsAString& aProfile)
 {
   DOM_CAMERA_LOGT("%s:%d\n", __func__, __LINE__);
 
   // read preferences for camcorder
   mMediaProfiles = MediaProfiles::getInstance();
 
   nsAutoCString profile = NS_ConvertUTF16toUTF8(aProfile);
-  mRecorderProfile = GetGonkRecorderProfileManager().get()->Get(profile.get());
+  // XXXkhuey are we leaking?
+  mRecorderProfile = GetGonkRecorderProfileManager().take()->Get(profile.get());
   if (!mRecorderProfile) {
     DOM_CAMERA_LOGE("Recorder profile '%s' is not supported\n", profile.get());
     return NS_ERROR_INVALID_ARG;
   }
 
   const GonkRecorderVideoProfile* video = mRecorderProfile->GetGonkVideoProfile();
   int width = video->GetWidth();
   int height = video->GetHeight();
--- a/dom/events/DataTransfer.cpp
+++ b/dom/events/DataTransfer.cpp
@@ -347,17 +347,18 @@ DataTransfer::Types()
   }
 
   return types.forget();
 }
 
 NS_IMETHODIMP
 DataTransfer::GetTypes(nsISupports** aTypes)
 {
-  *aTypes = Types().get();
+  nsCOMPtr<nsISupports> types = Types();
+  types.forget(aTypes);
 
   return NS_OK;
 }
 
 void
 DataTransfer::GetData(const nsAString& aFormat, nsAString& aData,
                       ErrorResult& aRv)
 {
@@ -547,17 +548,18 @@ DataTransfer::MozTypesAt(uint32_t aIndex
 
   return types.forget();
 }
 
 NS_IMETHODIMP
 DataTransfer::MozTypesAt(uint32_t aIndex, nsISupports** aTypes)
 {
   ErrorResult rv;
-  *aTypes = MozTypesAt(aIndex, rv).get();
+  nsCOMPtr<nsISupports> types = MozTypesAt(aIndex, rv);
+  types.forget(aTypes);
   return rv.ErrorCode();
 }
 
 NS_IMETHODIMP
 DataTransfer::MozGetDataAt(const nsAString& aFormat, uint32_t aIndex,
                            nsIVariant** aData)
 {
   *aData = nullptr;
--- a/dom/events/MouseEvent.cpp
+++ b/dom/events/MouseEvent.cpp
@@ -252,17 +252,17 @@ MouseEvent::Buttons()
       MOZ_CRASH("Tried to get mouse buttons for non-mouse event!");
   }
 }
 
 NS_IMETHODIMP
 MouseEvent::GetRelatedTarget(nsIDOMEventTarget** aRelatedTarget)
 {
   NS_ENSURE_ARG_POINTER(aRelatedTarget);
-  *aRelatedTarget = GetRelatedTarget().get();
+  *aRelatedTarget = GetRelatedTarget().take();
   return NS_OK;
 }
 
 already_AddRefed<EventTarget>
 MouseEvent::GetRelatedTarget()
 {
   nsCOMPtr<EventTarget> relatedTarget;
   switch(mEvent->eventStructType)
--- a/dom/events/NotifyPaintEvent.cpp
+++ b/dom/events/NotifyPaintEvent.cpp
@@ -48,17 +48,17 @@ NotifyPaintEvent::GetRegion()
     r.SimplifyOutward(10);
   }
   return r;
 }
 
 NS_IMETHODIMP
 NotifyPaintEvent::GetBoundingClientRect(nsIDOMClientRect** aResult)
 {
-  *aResult = BoundingClientRect().get();
+  *aResult = BoundingClientRect().take();
   return NS_OK;
 }
 
 already_AddRefed<DOMRect>
 NotifyPaintEvent::BoundingClientRect()
 {
   nsRefPtr<DOMRect> rect = new DOMRect(ToSupports(this));
 
@@ -67,17 +67,17 @@ NotifyPaintEvent::BoundingClientRect()
   }
 
   return rect.forget();
 }
 
 NS_IMETHODIMP
 NotifyPaintEvent::GetClientRects(nsIDOMClientRectList** aResult)
 {
-  *aResult = ClientRects().get();
+  *aResult = ClientRects().take();
   return NS_OK;
 }
 
 already_AddRefed<DOMRectList>
 NotifyPaintEvent::ClientRects()
 {
   nsISupports* parent = ToSupports(this);
   nsRefPtr<DOMRectList> rectList = new DOMRectList(parent);
--- a/dom/events/XULCommandEvent.cpp
+++ b/dom/events/XULCommandEvent.cpp
@@ -90,17 +90,18 @@ XULCommandEvent::GetMetaKey(bool* aIsDow
   *aIsDown = MetaKey();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 XULCommandEvent::GetSourceEvent(nsIDOMEvent** aSourceEvent)
 {
   NS_ENSURE_ARG_POINTER(aSourceEvent);
-  *aSourceEvent = GetSourceEvent().get();
+  nsCOMPtr<nsIDOMEvent> event = GetSourceEvent();
+  event.forget(aSourceEvent);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 XULCommandEvent::InitCommandEvent(const nsAString& aType,
                                   bool aCanBubble,
                                   bool aCancelable,
                                   nsIDOMWindow* aView,
--- a/dom/fmradio/ipc/FMRadioParent.cpp
+++ b/dom/fmradio/ipc/FMRadioParent.cpp
@@ -62,17 +62,18 @@ FMRadioParent::AllocPFMRadioRequestParen
       break;
     case FMRadioRequestArgs::TCancelSeekRequestArgs:
       IFMRadioService::Singleton()->CancelSeek(requestParent);
       break;
     default:
       MOZ_CRASH();
   }
 
-  return requestParent.forget().get();
+  // Balanced in DeallocPFMRadioRequestParent
+  return requestParent.forget().take();
 }
 
 bool
 FMRadioParent::DeallocPFMRadioRequestParent(PFMRadioRequestParent* aActor)
 {
   FMRadioRequestParent* parent = static_cast<FMRadioRequestParent*>(aActor);
   NS_RELEASE(parent);
   return true;
--- a/dom/ipc/ContentChild.cpp
+++ b/dom/ipc/ContentChild.cpp
@@ -763,17 +763,17 @@ ContentChild::AllocPBrowserChild(const I
                                  "the parent process. (%s)  Crashing...",
                                  tc.GetInvalidReason()).get());
         MOZ_CRASH("Invalid TabContext received from the parent process.");
     }
 
     nsRefPtr<TabChild> child = TabChild::Create(this, tc.GetTabContext(), aChromeFlags);
 
     // The ref here is released in DeallocPBrowserChild.
-    return child.forget().get();
+    return child.forget().take();
 }
 
 bool
 ContentChild::RecvPBrowserConstructor(PBrowserChild* actor,
                                       const IPCTabContext& context,
                                       const uint32_t& chromeFlags)
 {
     // This runs after AllocPBrowserChild() returns and the IPC machinery for this
--- a/dom/ipc/ContentParent.cpp
+++ b/dom/ipc/ContentParent.cpp
@@ -655,17 +655,18 @@ ContentParent::CreateBrowserOrApp(const 
             if (affectLifetime) {
                 chromeFlags |= nsIWebBrowserChrome::CHROME_PRIVATE_LIFETIME;
             }
 
             nsRefPtr<TabParent> tp(new TabParent(cp, aContext, chromeFlags));
             tp->SetOwnerElement(aFrameElement);
 
             PBrowserParent* browser = cp->SendPBrowserConstructor(
-                tp.forget().get(), // DeallocPBrowserParent() releases this ref.
+                // DeallocPBrowserParent() releases this ref.
+                tp.forget().take(),
                 aContext.AsIPCTabContext(),
                 chromeFlags);
             return static_cast<TabParent*>(browser);
         }
         return nullptr;
     }
 
     // If we got here, we have an app and we're not a browser element.  ownApp
@@ -719,17 +720,18 @@ ContentParent::CreateBrowserOrApp(const 
         sAppContentParents->Put(manifestURL, p);
     }
 
     uint32_t chromeFlags = 0;
 
     nsRefPtr<TabParent> tp = new TabParent(p, aContext, chromeFlags);
     tp->SetOwnerElement(aFrameElement);
     PBrowserParent* browser = p->SendPBrowserConstructor(
-        nsRefPtr<TabParent>(tp).forget().get(), // DeallocPBrowserParent() releases this ref.
+        // DeallocPBrowserParent() releases this ref.
+        nsRefPtr<TabParent>(tp).forget().take(),
         aContext.AsIPCTabContext(),
         chromeFlags);
 
     p->MaybeTakeCPUWakeLock(aFrameElement);
 
     return static_cast<TabParent*>(browser);
 }
 
@@ -2213,17 +2215,17 @@ ContentParent::DeallocPBrowserParent(PBr
 PDeviceStorageRequestParent*
 ContentParent::AllocPDeviceStorageRequestParent(const DeviceStorageParams& aParams)
 {
   nsRefPtr<DeviceStorageRequestParent> result = new DeviceStorageRequestParent(aParams);
   if (!result->EnsureRequiredPermissions(this)) {
       return nullptr;
   }
   result->Dispatch();
-  return result.forget().get();
+  return result.forget().take();
 }
 
 bool
 ContentParent::DeallocPDeviceStorageRequestParent(PDeviceStorageRequestParent* doomed)
 {
   DeviceStorageRequestParent *parent = static_cast<DeviceStorageRequestParent*>(doomed);
   NS_RELEASE(parent);
   return true;
@@ -2231,17 +2233,17 @@ ContentParent::DeallocPDeviceStorageRequ
 
 PFileSystemRequestParent*
 ContentParent::AllocPFileSystemRequestParent(const FileSystemParams& aParams)
 {
   nsRefPtr<FileSystemRequestParent> result = new FileSystemRequestParent();
   if (!result->Dispatch(this, aParams)) {
     return nullptr;
   }
-  return result.forget().get();
+  return result.forget().take();
 }
 
 bool
 ContentParent::DeallocPFileSystemRequestParent(PFileSystemRequestParent* doomed)
 {
   FileSystemRequestParent* parent = static_cast<FileSystemRequestParent*>(doomed);
   NS_RELEASE(parent);
   return true;
--- a/dom/ipc/TabChild.cpp
+++ b/dom/ipc/TabChild.cpp
@@ -1046,17 +1046,17 @@ TabChild::BrowserFrameProvideWindow(nsID
   // BrowserFrameIPCTabContext or an AppFrameIPCTabContext), for security
   // reasons.
   PopupIPCTabContext context;
   context.openerChild() = this;
   context.isBrowserElement() = IsBrowserElement();
 
   unused << Manager()->SendPBrowserConstructor(
       // We release this ref in DeallocPBrowserChild
-      nsRefPtr<TabChild>(newChild).forget().get(),
+      nsRefPtr<TabChild>(newChild).forget().take(),
       IPCTabContext(context, mScrolling), /* chromeFlags */ 0);
 
   nsAutoCString spec;
   if (aURI) {
     aURI->GetSpec(spec);
   }
 
   NS_ConvertUTF8toUTF16 url(spec);
--- a/dom/ipc/TabParent.cpp
+++ b/dom/ipc/TabParent.cpp
@@ -1689,17 +1689,17 @@ mozilla::docshell::POfflineCacheUpdatePa
 TabParent::AllocPOfflineCacheUpdateParent(const URIParams& aManifestURI,
                                           const URIParams& aDocumentURI,
                                           const bool& aStickDocument)
 {
   nsRefPtr<mozilla::docshell::OfflineCacheUpdateParent> update =
     new mozilla::docshell::OfflineCacheUpdateParent(OwnOrContainingAppId(),
                                                     IsBrowserElement());
   // Use this reference as the IPDL reference.
-  return update.forget().get();
+  return update.forget().take();
 }
 
 bool
 TabParent::RecvPOfflineCacheUpdateConstructor(POfflineCacheUpdateParent* aActor,
                                               const URIParams& aManifestURI,
                                               const URIParams& aDocumentURI,
                                               const bool& aStickDocument)
 {
--- a/dom/plugins/base/nsNPAPIPlugin.cpp
+++ b/dom/plugins/base/nsNPAPIPlugin.cpp
@@ -452,17 +452,17 @@ nsNPAPIPlugin::CreatePlugin(nsPluginTag 
 #elif defined(MOZ_WIDGET_GONK)
 #else
   rv = pluginLib->NP_Initialize(&sBrowserFuncs, &plugin->mPluginFuncs, &pluginCallError);
   if (rv != NS_OK || pluginCallError != NPERR_NO_ERROR) {
     return NS_ERROR_FAILURE;
   }
 #endif
 
-  *aResult = plugin.forget().get();
+  plugin.forget(aResult);
   return NS_OK;
 }
 
 PluginLibrary*
 nsNPAPIPlugin::GetLibrary()
 {
   return mLibrary;
 }
--- a/dom/plugins/base/nsPluginHost.cpp
+++ b/dom/plugins/base/nsPluginHost.cpp
@@ -3295,17 +3295,17 @@ nsPluginHost::CreateTempFileToPost(const
       rv = outStream->Write(buf, bw, &br);
       if (NS_FAILED(rv) || (bw != br))
         break;
     }
 
     inStream->Close();
     outStream->Close();
     if (NS_SUCCEEDED(rv))
-      *aTmpFile = tempFile.forget().get();
+      tempFile.forget(aTmpFile);
   }
   return rv;
 }
 
 nsresult
 nsPluginHost::NewPluginNativeWindow(nsPluginNativeWindow ** aPluginNativeWindow)
 {
   return PLUG_NewPluginNativeWindow(aPluginNativeWindow);
--- a/dom/plugins/ipc/PluginInstanceParent.cpp
+++ b/dom/plugins/ipc/PluginInstanceParent.cpp
@@ -818,17 +818,17 @@ PluginInstanceParent::BeginUpdateBackgro
 #ifdef DEBUG
     NS_ABORT_IF_FALSE(nsIntRect(0, 0, sz.width, sz.height).Contains(aRect),
                       "Update outside of background area");
 #endif
 
     RefPtr<gfx::DrawTarget> dt = gfxPlatform::GetPlatform()->
       CreateDrawTargetForSurface(mBackground, gfx::IntSize(sz.width, sz.height));
     nsRefPtr<gfxContext> ctx = new gfxContext(dt);
-    *aCtx = ctx.forget().get();
+    ctx.forget(aCtx);
 
     return NS_OK;
 }
 
 nsresult
 PluginInstanceParent::EndUpdateBackground(gfxContext* aCtx,
                                           const nsIntRect& aRect)
 {
--- a/dom/smil/nsSMILMappedAttribute.cpp
+++ b/dom/smil/nsSMILMappedAttribute.cpp
@@ -100,17 +100,17 @@ nsSMILMappedAttribute::SetAnimValue(cons
     if (valStr.Equals(oldValStr)) {
       // New animated value is the same as the old; nothing to do.
       return NS_OK;
     }
   }
 
   // Set the string as this mapped attribute's animated value.
   nsStringBuffer* valStrBuf =
-    nsCSSValue::BufferFromString(nsString(valStr)).get();
+    nsCSSValue::BufferFromString(nsString(valStr)).take();
   nsresult rv = mElement->SetProperty(SMIL_MAPPED_ATTR_ANIMVAL,
                                       attrName, valStrBuf,
                                       ReleaseStringBufferPropertyValue);
   if (rv == NS_PROPTABLE_PROP_OVERWRITTEN) {
     rv = NS_OK;
   }
   FlushChangesToTargetAttr();
 
--- a/dom/src/notification/DesktopNotification.cpp
+++ b/dom/src/notification/DesktopNotification.cpp
@@ -181,17 +181,17 @@ DesktopNotification::Init()
     nsRefPtr<DesktopNotificationRequest> copy = request;
 
     nsTArray<PermissionRequest> permArray;
     nsTArray<nsString> emptyOptions;
     permArray.AppendElement(PermissionRequest(
                             NS_LITERAL_CSTRING("desktop-notification"),
                             NS_LITERAL_CSTRING("unused"),
                             emptyOptions));
-    child->SendPContentPermissionRequestConstructor(copy.forget().get(),
+    child->SendPContentPermissionRequestConstructor(copy.forget().take(),
                                                     permArray,
                                                     IPC::Principal(mPrincipal));
 
     request->Sendprompt();
     return;
   }
 
   // otherwise, dispatch it
--- a/dom/src/offline/nsDOMOfflineResourceList.cpp
+++ b/dom/src/offline/nsDOMOfflineResourceList.cpp
@@ -220,17 +220,18 @@ nsDOMOfflineResourceList::GetMozItems(Er
 
   return items.forget();
 }
 
 NS_IMETHODIMP
 nsDOMOfflineResourceList::GetMozItems(nsISupports** aItems)
 {
   ErrorResult rv;
-  *aItems = GetMozItems(rv).get();
+  nsCOMPtr<nsISupports> items = GetMozItems(rv);
+  items.forget(aItems);
   return rv.ErrorCode();
 }
 
 NS_IMETHODIMP
 nsDOMOfflineResourceList::MozHasItem(const nsAString& aURI, bool* aExists)
 {
   if (IS_CHILD_PROCESS()) 
     return NS_ERROR_NOT_IMPLEMENTED;
--- a/dom/workers/WorkerPrivate.cpp
+++ b/dom/workers/WorkerPrivate.cpp
@@ -2229,17 +2229,17 @@ WorkerPrivateParent<Derived>::DispatchCo
 
     if (self->mStatus == Dead) {
       NS_WARNING("A control runnable was posted to a worker that is already "
                  "shutting down!");
       return NS_ERROR_UNEXPECTED;
     }
 
     // Transfer ownership to the control queue.
-    self->mControlQueue.Push(runnable.forget().get());
+    self->mControlQueue.Push(runnable.forget().take());
 
     if (JSContext* cx = self->mJSContext) {
       MOZ_ASSERT(self->mThread);
 
       JSRuntime* rt = JS_GetRuntime(cx);
       MOZ_ASSERT(rt);
 
       JS_RequestInterruptCallback(rt);
--- a/dom/xbl/nsXBLService.cpp
+++ b/dom/xbl/nsXBLService.cpp
@@ -581,17 +581,18 @@ nsXBLService::AttachGlobalKeyHandler(Eve
   manager->AddEventListenerByType(handler, NS_LITERAL_STRING("keydown"),
                                   dom::TrustedEventsAtSystemGroupBubble());
   manager->AddEventListenerByType(handler, NS_LITERAL_STRING("keyup"),
                                   dom::TrustedEventsAtSystemGroupBubble());
   manager->AddEventListenerByType(handler, NS_LITERAL_STRING("keypress"),
                                   dom::TrustedEventsAtSystemGroupBubble());
 
   if (contentNode)
-    return contentNode->SetProperty(nsGkAtoms::listener, handler.forget().get(),
+    return contentNode->SetProperty(nsGkAtoms::listener,
+                                    handler.forget().take(),
                                     nsPropertyTable::SupportsDtorFunc, true);
 
   // The reference to the handler will be maintained by the event target,
   // and, if there is a content node, the property.
   return NS_OK;
 }
 
 //
--- a/dom/xslt/xml/txXMLUtils.cpp
+++ b/dom/xslt/xml/txXMLUtils.cpp
@@ -83,34 +83,34 @@ XMLUtils::splitExpatName(const char16_t 
                                                                     uriEnd));
         if (*aNameSpaceID == kNameSpaceID_Unknown) {
             return NS_ERROR_FAILURE;
         }
 
         nameStart = (uriEnd + 1);
         if (nameEnd)  {
             const char16_t *prefixStart = nameEnd + 1;
-            *aPrefix = NS_NewAtom(Substring(prefixStart, pos)).get();
+            *aPrefix = NS_NewAtom(Substring(prefixStart, pos)).take();
             if (!*aPrefix) {
                 return NS_ERROR_OUT_OF_MEMORY;
             }
         }
         else {
             nameEnd = pos;
             *aPrefix = nullptr;
         }
     }
     else {
         *aNameSpaceID = kNameSpaceID_None;
         nameStart = aExpatName;
         nameEnd = pos;
         *aPrefix = nullptr;
     }
 
-    *aLocalName = NS_NewAtom(Substring(nameStart, nameEnd)).get();
+    *aLocalName = NS_NewAtom(Substring(nameStart, nameEnd)).take();
 
     return *aLocalName ? NS_OK : NS_ERROR_OUT_OF_MEMORY;
 }
 
 nsresult
 XMLUtils::splitQName(const nsAString& aName, nsIAtom** aPrefix,
                      nsIAtom** aLocalName)
 {
@@ -120,22 +120,22 @@ XMLUtils::splitQName(const nsAString& aN
     if (!valid) {
         return NS_ERROR_FAILURE;
     }
 
     if (colon) {
         const char16_t *end;
         qName.EndReading(end);
 
-        *aPrefix = NS_NewAtom(Substring(qName.get(), colon)).get();
-        *aLocalName = NS_NewAtom(Substring(colon + 1, end)).get();
+        *aPrefix = NS_NewAtom(Substring(qName.get(), colon)).take();
+        *aLocalName = NS_NewAtom(Substring(colon + 1, end)).take();
     }
     else {
         *aPrefix = nullptr;
-        *aLocalName = NS_NewAtom(aName).get();
+        *aLocalName = NS_NewAtom(aName).take();
     }
 
     return NS_OK;
 }
 
 /**
  * Returns true if the given string has only whitespace characters
  */
--- a/dom/xslt/xpath/XPathEvaluator.h
+++ b/dom/xslt/xpath/XPathEvaluator.h
@@ -32,20 +32,20 @@ public:
 
     NS_DECL_ISUPPORTS
 
     // nsIDOMXPathEvaluator interface
     NS_DECL_NSIDOMXPATHEVALUATOR
 
     // WebIDL API
     JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aScope);
-    already_AddRefed<nsIDocument> GetParentObject()
+    nsIDocument* GetParentObject()
     {
         nsCOMPtr<nsIDocument> doc = do_QueryReferent(mDocument);
-        return doc.forget();
+        return doc;
     }
     static already_AddRefed<XPathEvaluator>
         Constructor(const GlobalObject& aGlobal, ErrorResult& rv);
     already_AddRefed<nsIDOMXPathExpression>
         CreateExpression(const nsAString& aExpression,
                          nsIDOMXPathNSResolver* aResolver,
                          ErrorResult& rv);
     already_AddRefed<nsIDOMXPathNSResolver>
--- a/dom/xslt/xpath/txExprParser.cpp
+++ b/dom/xslt/xpath/txExprParser.cpp
@@ -888,35 +888,35 @@ nsresult
 txExprParser::resolveQName(const nsAString& aQName,
                            nsIAtom** aPrefix, txIParseContext* aContext,
                            nsIAtom** aLocalName, int32_t& aNamespace,
                            bool aIsNameTest)
 {
     aNamespace = kNameSpaceID_None;
     int32_t idx = aQName.FindChar(':');
     if (idx > 0) {
-        *aPrefix = NS_NewAtom(StringHead(aQName, (uint32_t)idx)).get();
+        *aPrefix = NS_NewAtom(StringHead(aQName, (uint32_t)idx)).take();
         if (!*aPrefix) {
             return NS_ERROR_OUT_OF_MEMORY;
         }
         *aLocalName = NS_NewAtom(Substring(aQName, (uint32_t)idx + 1,
-                                           aQName.Length() - (idx + 1))).get();
+                                           aQName.Length() - (idx + 1))).take();
         if (!*aLocalName) {
             NS_RELEASE(*aPrefix);
             return NS_ERROR_OUT_OF_MEMORY;
         }
         return aContext->resolveNamespacePrefix(*aPrefix, aNamespace);
     }
     // the lexer dealt with idx == 0
     *aPrefix = 0;
     if (aIsNameTest && aContext->caseInsensitiveNameTests()) {
         nsAutoString lcname;
         nsContentUtils::ASCIIToLower(aQName, lcname);
-        *aLocalName = NS_NewAtom(lcname).get();
+        *aLocalName = NS_NewAtom(lcname).take();
     }
     else {
-        *aLocalName = NS_NewAtom(aQName).get();
+        *aLocalName = NS_NewAtom(aQName).take();
     }
     if (!*aLocalName) {
         return NS_ERROR_OUT_OF_MEMORY;
     }
     return NS_OK;
 }
--- a/dom/xslt/xslt/txStylesheetCompileHandlers.cpp
+++ b/dom/xslt/xslt/txStylesheetCompileHandlers.cpp
@@ -299,17 +299,17 @@ getAtomAttr(txStylesheetAttr* aAttribute
     *aAtom = nullptr;
     txStylesheetAttr* attr = nullptr;
     nsresult rv = getStyleAttr(aAttributes, aAttrCount, kNameSpaceID_None,
                                aName, aRequired, &attr);
     if (!attr) {
         return rv;
     }
 
-    *aAtom = NS_NewAtom(attr->mValue).get();
+    *aAtom = NS_NewAtom(attr->mValue).take();
     NS_ENSURE_TRUE(*aAtom, NS_ERROR_OUT_OF_MEMORY);
 
     return NS_OK;
 }
 
 static nsresult
 getYesNoAttr(txStylesheetAttr* aAttributes,
              int32_t aAttrCount,
--- a/editor/libeditor/html/nsHTMLCSSUtils.cpp
+++ b/editor/libeditor/html/nsHTMLCSSUtils.cpp
@@ -699,17 +699,17 @@ nsHTMLCSSUtils::ParseLength(const nsAStr
       floatingPointFound = true;
       a = 1.0f; b = 0.1f;
     }
     else break;
     iter++;
     i++;
   }
   *aValue = value * sign;
-  *aUnit = NS_NewAtom(StringTail(aString, j-i)).get();
+  *aUnit = NS_NewAtom(StringTail(aString, j-i)).take();
 }
 
 void
 nsHTMLCSSUtils::GetCSSPropertyAtom(nsCSSEditableProperty aProperty, nsIAtom ** aAtom)
 {
   *aAtom = nullptr;
   switch (aProperty) {
     case eCSSEditableProperty_background_color:
--- a/editor/txmgr/src/nsTransactionList.cpp
+++ b/editor/txmgr/src/nsTransactionList.cpp
@@ -142,17 +142,17 @@ NS_IMETHODIMP nsTransactionList::GetItem
     item = mTxnStack->GetItem(aIndex);
   else if (mTxnItem)
     result = mTxnItem->GetChild(aIndex, getter_AddRefs(item));
 
   NS_ENSURE_SUCCESS(result, result);
 
   NS_ENSURE_TRUE(item, NS_ERROR_FAILURE);
 
-  *aItem = item->GetTransaction().get();
+  *aItem = item->GetTransaction().take();
 
   return NS_OK;
 }
 
 /* long getNumChildrenForItem (in long aIndex); */
 NS_IMETHODIMP nsTransactionList::GetNumChildrenForItem(int32_t aIndex, int32_t *aNumChildren)
 {
   NS_ENSURE_TRUE(aNumChildren, NS_ERROR_NULL_POINTER);
--- a/editor/txmgr/src/nsTransactionManager.cpp
+++ b/editor/txmgr/src/nsTransactionManager.cpp
@@ -390,17 +390,17 @@ nsTransactionManager::SetMaxTransactionC
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsTransactionManager::PeekUndoStack(nsITransaction **aTransaction)
 {
   MOZ_ASSERT(aTransaction);
-  *aTransaction = PeekUndoStack().get();
+  *aTransaction = PeekUndoStack().take();
   return NS_OK;
 }
 
 already_AddRefed<nsITransaction>
 nsTransactionManager::PeekUndoStack()
 {
   nsRefPtr<nsTransactionItem> tx = mUndoStack.Peek();
 
@@ -410,17 +410,17 @@ nsTransactionManager::PeekUndoStack()
 
   return tx->GetTransaction();
 }
 
 NS_IMETHODIMP
 nsTransactionManager::PeekRedoStack(nsITransaction** aTransaction)
 {
   MOZ_ASSERT(aTransaction);
-  *aTransaction = PeekRedoStack().get();
+  *aTransaction = PeekRedoStack().take();
   return NS_OK;
 }
 
 already_AddRefed<nsITransaction>
 nsTransactionManager::PeekRedoStack()
 {
   nsRefPtr<nsTransactionItem> tx = mRedoStack.Peek();
 
--- a/embedding/browser/webBrowser/nsWebBrowser.cpp
+++ b/embedding/browser/webBrowser/nsWebBrowser.cpp
@@ -316,17 +316,17 @@ NS_IMETHODIMP nsWebBrowser::EnableGlobal
     return mDocShell->SetUseGlobalHistory(aEnable);
 }
 
 NS_IMETHODIMP nsWebBrowser::GetContainerWindow(nsIWebBrowserChrome** aTopWindow)
 {
    NS_ENSURE_ARG_POINTER(aTopWindow);
 
    if(mDocShellTreeOwner) {
-      *aTopWindow = mDocShellTreeOwner->GetWebBrowserChrome().get();
+      *aTopWindow = mDocShellTreeOwner->GetWebBrowserChrome().take();
    } else {
       *aTopWindow = nullptr;
    }
 
    return NS_OK;
 }
 
 NS_IMETHODIMP nsWebBrowser::SetContainerWindow(nsIWebBrowserChrome* aTopWindow)
--- a/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
+++ b/embedding/components/webbrowserpersist/src/nsWebBrowserPersist.cpp
@@ -2264,17 +2264,17 @@ nsWebBrowserPersist::MakeOutputStreamFro
     // XXX brade:  get the right flags here!
     int32_t ioFlags = -1;
     if (mPersistFlags & nsIWebBrowserPersist::PERSIST_FLAGS_APPEND_TO_FILE)
       ioFlags = PR_APPEND | PR_CREATE_FILE | PR_WRONLY; 
     rv = fileOutputStream->Init(aFile, ioFlags, -1, 0);
     NS_ENSURE_SUCCESS(rv, rv);
 
     *aOutputStream = NS_BufferOutputStream(fileOutputStream,
-                                           BUFFERED_OUTPUT_SIZE).get();
+                                           BUFFERED_OUTPUT_SIZE).take();
 
     if (mPersistFlags & PERSIST_FLAGS_CLEANUP_ON_FAILURE)
     {
         // Add to cleanup list in event of failure
         CleanupData *cleanupData = new CleanupData;
         if (!cleanupData) {
           NS_RELEASE(*aOutputStream);
           return NS_ERROR_OUT_OF_MEMORY;
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -1177,17 +1177,17 @@ mozInlineSpellChecker::MakeSpellCheckRan
   rv = range->SetStart(aStartNode, aStartOffset);
   NS_ENSURE_SUCCESS(rv, rv);
   if (aEndOffset)
     rv = range->SetEnd(aEndNode, aEndOffset);
   else
     rv = range->SetEndAfter(aEndNode);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  *aRange = static_cast<nsRange*>(range.forget().get());
+  *aRange = static_cast<nsRange*>(range.forget().take());
   return NS_OK;
 }
 
 nsresult
 mozInlineSpellChecker::SpellCheckBetweenNodes(nsIDOMNode *aStartNode,
                                               int32_t aStartOffset,
                                               nsIDOMNode *aEndNode,
                                               int32_t aEndOffset)
--- a/gfx/layers/basic/BasicImageLayer.cpp
+++ b/gfx/layers/basic/BasicImageLayer.cpp
@@ -222,17 +222,17 @@ BasicImageLayer::GetAsSurface(gfxASurfac
                               SurfaceDescriptor* aDescriptor)
 {
   if (!mContainer) {
     return false;
   }
 
   gfx::IntSize dontCare;
   nsRefPtr<gfxASurface> surface = mContainer->DeprecatedGetCurrentAsSurface(&dontCare);
-  *aSurface = surface.forget().get();
+  surface.forget(aSurface);
   return true;
 }
 
 already_AddRefed<ImageLayer>
 BasicLayerManager::CreateImageLayer()
 {
   NS_ASSERTION(InConstruction(), "Only allowed in construction phase");
   nsRefPtr<ImageLayer> layer = new BasicImageLayer(this);
--- a/gfx/layers/d3d10/LayerManagerD3D10.cpp
+++ b/gfx/layers/d3d10/LayerManagerD3D10.cpp
@@ -468,17 +468,17 @@ LayerManagerD3D10::CreateOptimalSurface(
     new gfxD2DSurface(texture, aFormat == gfxImageFormat::RGB24 ?
       gfxContentType::COLOR : gfxContentType::COLOR_ALPHA);
 
   if (!surface || surface->CairoStatus()) {
     return LayerManager::CreateOptimalSurface(aSize, aFormat);
   }
 
   surface->SetData(&gKeyD3D10Texture,
-                   texture.forget().get(),
+                   texture.forget().take(),
                    ReleaseTexture);
 
   return surface.forget();
 }
 
 
 already_AddRefed<gfxASurface>
 LayerManagerD3D10::CreateOptimalMaskSurface(const IntSize &aSize)
--- a/gfx/layers/ipc/CompositorChild.cpp
+++ b/gfx/layers/ipc/CompositorChild.cpp
@@ -79,17 +79,17 @@ CompositorChild::Create(Transport* aTran
     NS_RUNTIMEABORT("Couldn't OpenProcessHandle() to parent process.");
     return nullptr;
   }
   if (!child->Open(aTransport, handle, XRE_GetIOMessageLoop(), ipc::ChildSide)) {
     NS_RUNTIMEABORT("Couldn't Open() Compositor channel.");
     return nullptr;
   }
   // We release this ref in ActorDestroy().
-  return sCompositor = child.forget().get();
+  return sCompositor = child.forget().take();
 }
 
 /*static*/ CompositorChild*
 CompositorChild::Get()
 {
   // This is only expected to be used in child processes.
   MOZ_ASSERT(XRE_GetProcessType() != GeckoProcessType_Default);
   return sCompositor;
--- a/gfx/layers/ipc/ShadowLayers.cpp
+++ b/gfx/layers/ipc/ShadowLayers.cpp
@@ -677,17 +677,17 @@ ShadowLayerForwarder::GetDescriptorSurfa
   gfxContentType content;
   if (PlatformGetDescriptorSurfaceContentType(aDescriptor, aMode,
                                               &content, aSurface)) {
     return content;
   }
 
   nsRefPtr<gfxASurface> surface = OpenDescriptor(aMode, aDescriptor);
   content = surface->GetContentType();
-  *aSurface = surface.forget().get();
+  surface.forget(aSurface);
   return content;
 }
 
 /*static*/ gfx::IntSize
 ShadowLayerForwarder::GetDescriptorSurfaceSize(
   const SurfaceDescriptor& aDescriptor, OpenMode aMode,
   gfxASurface** aSurface)
 {
@@ -717,17 +717,17 @@ ShadowLayerForwarder::GetDescriptorSurfa
 
   nsRefPtr<gfxImageSurface> img = surface->GetAsImageSurface();
   NS_ENSURE_TRUE(img, gfxImageFormat::Unknown);
 
   format = img->Format();
   NS_ASSERTION(format != gfxImageFormat::Unknown,
                "ImageSurface RGB format should be known");
 
-  *aSurface = surface.forget().get();
+  surface.forget(aSurface);
   return format;
 }
 
 /*static*/ void
 ShadowLayerForwarder::CloseDescriptor(const SurfaceDescriptor& aDescriptor)
 {
   PlatformCloseDescriptor(aDescriptor);
   // There's no "close" needed for Shmem surfaces.
--- a/image/src/RasterImage.cpp
+++ b/image/src/RasterImage.cpp
@@ -870,17 +870,17 @@ RasterImage::CopyFrame(uint32_t aWhichFr
                                                              gfxImageFormat::ARGB32);
   gfxContext ctx(imgsurface);
   ctx.SetOperator(gfxContext::OPERATOR_SOURCE);
   ctx.Rectangle(framerect);
   ctx.Translate(framerect.TopLeft());
   ctx.SetPattern(pattern);
   ctx.Fill();
 
-  *_retval = imgsurface.forget().get();
+  imgsurface.forget(_retval);
   return NS_OK;
 }
 
 //******************************************************************************
 /* [noscript] gfxASurface getFrame(in uint32_t aWhichFrame,
  *                                 in uint32_t aFlags); */
 NS_IMETHODIMP_(already_AddRefed<gfxASurface>)
 RasterImage::GetFrame(uint32_t aWhichFrame,
--- a/image/src/SurfaceCache.cpp
+++ b/image/src/SurfaceCache.cpp
@@ -234,17 +234,17 @@ public:
   }
 
   void Insert(DrawTarget*       aTarget,
               IntSize           aTargetSize,
               const Cost        aCost,
               const ImageKey    aImageKey,
               const SurfaceKey& aSurfaceKey)
   {
-    MOZ_ASSERT(!Lookup(aImageKey, aSurfaceKey).get(),
+    MOZ_ASSERT(!Lookup(aImageKey, aSurfaceKey).take(),
                "Inserting a duplicate drawable into the SurfaceCache");
 
     // If this is bigger than the maximum cache size, refuse to cache it.
     if (!CanHold(aCost))
       return;
 
     nsRefPtr<CachedSurface> surface =
       new CachedSurface(aTarget, aTargetSize, aCost, aImageKey, aSurfaceKey);
--- a/intl/icu/source/io/ufile.c
+++ b/intl/icu/source/io/ufile.c
@@ -38,17 +38,17 @@
 /* Windows likes to rename Unix-like functions */
 #define fileno _fileno
 #endif
 
 static UFILE*
 finit_owner(FILE         *f,
               const char *locale,
               const char *codepage,
-              UBool       takeOwnership
+              UBool       take
               )
 {
     UErrorCode status = U_ZERO_ERROR;
     UFILE     *result;
     if(f == NULL) {
         return 0;
     }
     result = (UFILE*) uprv_malloc(sizeof(UFILE));
@@ -89,17 +89,17 @@ finit_owner(FILE         *f,
 
     /* If the codepage is not "" use the ucnv_open default behavior */
     if(codepage == NULL || *codepage != '\0') {
         result->fConverter = ucnv_open(codepage, &status);
     }
     /* else result->fConverter is already memset'd to NULL. */
 
     if(U_SUCCESS(status)) {
-        result->fOwnFile = takeOwnership;
+        result->fOwnFile = take;
     }
     else {
 #if !UCONFIG_NO_FORMATTING
         u_locbund_close(&result->str.fBundle);
 #endif
         /* DO NOT fclose here!!!!!! */
         uprv_free(result);
         result = NULL;
--- a/intl/uconv/src/nsCharsetConverterManager.cpp
+++ b/intl/uconv/src/nsCharsetConverterManager.cpp
@@ -344,13 +344,13 @@ nsCharsetConverterManager::GetCharsetLan
   *aResult = nullptr;
   nsAutoString langGroup;
   // fully qualify to possibly avoid vtable call
   nsresult rv = nsCharsetConverterManager::GetCharsetData(
       aCharset, MOZ_UTF16(".LangGroup"), langGroup);
 
   if (NS_SUCCEEDED(rv)) {
     ToLowerCase(langGroup); // use lowercase for all language atoms
-    *aResult = NS_NewAtom(langGroup).get();
+    *aResult = NS_NewAtom(langGroup).take();
   }
 
   return rv;
 }
--- a/ipc/glue/BackgroundImpl.cpp
+++ b/ipc/glue/BackgroundImpl.cpp
@@ -629,17 +629,17 @@ protected:
   nsRefPtr<ChildImpl> mActor;
 
 public:
   CreateCallbackRunnable(already_AddRefed<ChildImpl> aActor)
   : mActor(aActor)
   {
     // May be created on any thread!
 
-    MOZ_ASSERT(aActor.get());
+    MOZ_ASSERT(mActor);
   }
 
   CreateCallbackRunnable()
   {
     // May be created on any thread!
   }
 
   NS_DECL_ISUPPORTS_INHERITED
@@ -693,17 +693,17 @@ class ChildImpl::OpenMainProcessActorRun
 public:
   OpenMainProcessActorRunnable(already_AddRefed<ChildImpl> aChildActor,
                                already_AddRefed<ParentImpl> aParentActor,
                                MessageLoop* aParentMessageLoop)
   : CreateCallbackRunnable(aChildActor), mParentActor(aParentActor),
     mParentMessageLoop(aParentMessageLoop)
   {
     AssertIsOnMainThread();
-    MOZ_ASSERT(aParentActor.get());
+    MOZ_ASSERT(mParentActor);
     MOZ_ASSERT(aParentMessageLoop);
   }
 
   NS_DECL_ISUPPORTS_INHERITED
 
 private:
   ~OpenMainProcessActorRunnable()
   { }
@@ -1714,27 +1714,29 @@ ChildImpl::CreateActorRunnable::Run()
 
 void
 ChildImpl::ParentCreateCallback::Success(
                                       already_AddRefed<ParentImpl> aParentActor,
                                       MessageLoop* aParentMessageLoop)
 {
   AssertIsInMainProcess();
   AssertIsOnMainThread();
-  MOZ_ASSERT(aParentActor.get());
+
+  nsRefPtr<ParentImpl> parentActor = aParentActor;
+  MOZ_ASSERT(parentActor);
   MOZ_ASSERT(aParentMessageLoop);
   MOZ_ASSERT(mEventTarget);
 
   nsRefPtr<ChildImpl> childActor = new ChildImpl();
 
   nsCOMPtr<nsIEventTarget> target;
   mEventTarget.swap(target);
 
   nsCOMPtr<nsIRunnable> openRunnable =
-    new OpenMainProcessActorRunnable(childActor.forget(), aParentActor,
+    new OpenMainProcessActorRunnable(childActor.forget(), parentActor.forget(),
                                      aParentMessageLoop);
   if (NS_FAILED(target->Dispatch(openRunnable, NS_DISPATCH_NORMAL))) {
     NS_WARNING("Failed to dispatch open runnable!");
   }
 }
 
 void
 ChildImpl::ParentCreateCallback::Failure()
--- a/js/jsd/jsd_xpc.cpp
+++ b/js/jsd/jsd_xpc.cpp
@@ -3417,17 +3417,17 @@ CreateJSDGlobal(JSContext *aCx, const JS
     JSPrincipals *jsPrin = nsJSPrincipals::get(nullPrin);
     JS::RootedObject global(aCx, JS_NewGlobalObject(aCx, aClasp, jsPrin, JS::DontFireOnNewGlobalHook));
     NS_ENSURE_TRUE(global, nullptr);
 
     // We have created a new global let's attach a private to it
     // that implements nsIGlobalObject.
     nsCOMPtr<nsIScriptObjectPrincipal> sbp =
         new SandboxPrivate(nullPrin, global);
-    JS_SetPrivate(global, sbp.forget().get());
+    JS_SetPrivate(global, sbp.forget().take());
 
     JS_FireOnNewGlobalObject(aCx, global);
 
     return global;
 }
 
 /********************************************************************************
  ********************************************************************************
--- a/js/src/jsatom.cpp
+++ b/js/src/jsatom.cpp
@@ -293,17 +293,17 @@ AtomIsInterned(JSContext *cx, JSAtom *at
 
 /*
  * When the jschars reside in a freshly allocated buffer the memory can be used
  * as a new JSAtom's storage without copying. The contract is that the caller no
  * longer owns the memory and this method is responsible for freeing the memory.
  */
 MOZ_ALWAYS_INLINE
 static JSAtom *
-AtomizeAndTakeOwnership(ExclusiveContext *cx, jschar *tbchars, size_t length, InternBehavior ib)
+AtomizeAndtake(ExclusiveContext *cx, jschar *tbchars, size_t length, InternBehavior ib)
 {
     JS_ASSERT(tbchars[length] == 0);
 
     if (JSAtom *s = cx->staticStrings().lookup(tbchars, length)) {
         js_free(tbchars);
         return s;
     }
 
@@ -456,17 +456,17 @@ js::Atomize(ExclusiveContext *cx, const 
         jschar inflated[ATOMIZE_BUF_MAX];
         InflateStringToBuffer(bytes, length, inflated);
         return AtomizeAndCopyChars(cx, inflated, length, ib);
     }
 
     jschar *tbcharsZ = InflateString(cx, bytes, &length);
     if (!tbcharsZ)
         return nullptr;
-    return AtomizeAndTakeOwnership(cx, tbcharsZ, length, ib);
+    return AtomizeAndtake(cx, tbcharsZ, length, ib);
 }
 
 JSAtom *
 js::AtomizeChars(ExclusiveContext *cx, const jschar *chars, size_t length, InternBehavior ib)
 {
     CHECK_REQUEST(cx);
 
     if (!JSString::validateLength(cx, length))
--- a/js/xpconnect/src/Sandbox.cpp
+++ b/js/xpconnect/src/Sandbox.cpp
@@ -1108,17 +1108,17 @@ xpc::CreateSandboxObject(JSContext *cx, 
             if (!ok)
                 return NS_ERROR_XPC_UNEXPECTED;
         }
 
         nsCOMPtr<nsIScriptObjectPrincipal> sbp =
             new SandboxPrivate(principal, sandbox);
 
         // Pass on ownership of sbp to |sandbox|.
-        JS_SetPrivate(sandbox, sbp.forget().get());
+        JS_SetPrivate(sandbox, sbp.forget().take());
 
         bool allowComponents = nsContentUtils::IsSystemPrincipal(principal) ||
                                nsContentUtils::IsExpandedPrincipal(principal);
         if (options.wantComponents && allowComponents &&
             !GetObjectScope(sandbox)->AttachComponentsObject(cx))
             return NS_ERROR_XPC_UNEXPECTED;
 
         if (!XPCNativeWrapper::AttachNewConstructorObject(cx, sandbox))
--- a/js/xpconnect/src/XPCConvert.cpp
+++ b/js/xpconnect/src/XPCConvert.cpp
@@ -906,41 +906,41 @@ XPCConvert::NativeInterface2JSObject(Mut
 
     // If we're not creating security wrappers, we can return the
     // XPCWrappedNative as-is here.
     flat = wrapper->GetFlatJSObject();
     jsval v = OBJECT_TO_JSVAL(flat);
     if (!allowNativeWrapper) {
         d.set(v);
         if (dest)
-            *dest = strongWrapper.forget().get();
+            strongWrapper.forget(dest);
         if (pErr)
             *pErr = NS_OK;
         return true;
     }
 
     // The call to wrap here handles both cross-compartment and same-compartment
     // security wrappers.
     RootedObject original(cx, flat);
     if (!JS_WrapObject(cx, &flat))
         return false;
 
     d.setObjectOrNull(flat);
 
     if (dest) {
         // The strongWrapper still holds the original flat object.
         if (flat == original) {
-            *dest = strongWrapper.forget().get();
+            strongWrapper.forget(dest);
         } else {
             nsRefPtr<XPCJSObjectHolder> objHolder =
                 XPCJSObjectHolder::newHolder(flat);
             if (!objHolder)
                 return false;
 
-            *dest = objHolder.forget().get();
+            objHolder.forget(dest);
         }
     }
 
     if (pErr)
         *pErr = NS_OK;
 
     return true;
 }
--- a/js/xpconnect/src/XPCJSContextStack.cpp
+++ b/js/xpconnect/src/XPCJSContextStack.cpp
@@ -175,17 +175,17 @@ XPCJSContextStack::InitSafeJSContext()
 
     // Make sure the context is associated with a proper compartment
     // and not the default compartment.
     js::SetDefaultObjectForContext(mSafeJSContext, glob);
 
     // Note: make sure to set the private before calling
     // InitClasses
     nsRefPtr<SandboxPrivate> sp = new SandboxPrivate(principal, glob);
-    JS_SetPrivate(glob, sp.forget().get());
+    JS_SetPrivate(glob, sp.forget().take());
 
     // After this point either glob is null and the
     // nsIScriptObjectPrincipal ownership is either handled by the
     // nsCOMPtr or dealt with, or we'll release in the finalize
     // hook.
     if (NS_FAILED(xpc->InitClasses(mSafeJSContext, glob)))
         MOZ_CRASH();
 
--- a/js/xpconnect/src/XPCWrappedJS.cpp
+++ b/js/xpconnect/src/XPCWrappedJS.cpp
@@ -445,17 +445,17 @@ nsXPCWrappedJS::Unlink()
         // let the root go
         NS_RELEASE(mRoot);
     }
 
     mClass = nullptr;
     if (mOuter) {
         XPCJSRuntime* rt = nsXPConnect::GetRuntimeInstance();
         if (rt->GCIsRunning()) {
-            nsContentUtils::DeferredFinalize(mOuter.forget().get());
+            nsContentUtils::DeferredFinalize(mOuter.forget().take());
         } else {
             mOuter = nullptr;
         }
     }
 }
 
 nsXPCWrappedJS*
 nsXPCWrappedJS::Find(REFNSIID aIID)
--- a/js/xpconnect/src/XPCWrappedNative.cpp
+++ b/js/xpconnect/src/XPCWrappedNative.cpp
@@ -308,17 +308,17 @@ XPCWrappedNative::GetNewOrUsed(xpcObject
     // wrapper: we might have an XPCWrappedNative anyway.
     wrapper = map->Find(identity);
 
     if (wrapper) {
         if (!wrapper->FindTearOff(Interface, false, &rv)) {
             MOZ_ASSERT(NS_FAILED(rv), "returning NS_OK on failure");
             return rv;
         }
-        *resultWrapper = wrapper.forget().get();
+        wrapper.forget(resultWrapper);
         return NS_OK;
     }
 
     // There is a chance that the object wants to have the self-same JSObject
     // reflection regardless of the scope into which we are reflecting it.
     // Many DOM objects require this. The scriptable helper specifies this
     // in preCreate by indicating a 'parent' of a particular scope.
     //
@@ -408,17 +408,17 @@ XPCWrappedNative::GetNewOrUsed(xpcObject
             wrapper = map->Find(identity);
         }
 
         if (wrapper) {
             if (wrapper->FindTearOff(Interface, false, &rv)) {
                 MOZ_ASSERT(NS_FAILED(rv), "returning NS_OK on failure");
                 return rv;
             }
-            *resultWrapper = wrapper.forget().get();
+            wrapper.forget(resultWrapper);
             return NS_OK;
         }
     } else {
         ac.construct(static_cast<JSContext*>(cx), parent);
     }
 
     AutoMarkingWrappedNativeProtoPtr proto(cx);
 
@@ -528,17 +528,17 @@ FinishCreate(XPCWrappedNativeScope* Scop
                     cache->ClearWrapper();
                 wrapper->Release();
                 return rv;
             }
         }
     }
 
     DEBUG_CheckClassInfoClaims(wrapper);
-    *resultWrapper = wrapper.forget().get();
+    wrapper.forget(resultWrapper);
     return NS_OK;
 }
 
 // static
 nsresult
 XPCWrappedNative::GetUsedOnly(nsISupports* Object,
                               XPCWrappedNativeScope* Scope,
                               XPCNativeInterface* Interface,
@@ -589,17 +589,17 @@ XPCWrappedNative::GetUsedOnly(nsISupport
 XPCWrappedNative::XPCWrappedNative(already_AddRefed<nsISupports> aIdentity,
                                    XPCWrappedNativeProto* aProto)
     : mMaybeProto(aProto),
       mSet(aProto->GetSet()),
       mScriptableInfo(nullptr)
 {
     MOZ_ASSERT(NS_IsMainThread());
 
-    mIdentity = aIdentity.get();
+    mIdentity = aIdentity.take();
     mFlatJSObject.setFlags(FLAT_JS_OBJECT_VALID);
 
     MOZ_ASSERT(mMaybeProto, "bad ctor param");
     MOZ_ASSERT(mSet, "bad ctor param");
 }
 
 // This ctor is used if this object will NOT have a proto.
 XPCWrappedNative::XPCWrappedNative(already_AddRefed<nsISupports> aIdentity,
@@ -607,17 +607,17 @@ XPCWrappedNative::XPCWrappedNative(alrea
                                    XPCNativeSet* aSet)
 
     : mMaybeScope(TagScope(aScope)),
       mSet(aSet),
       mScriptableInfo(nullptr)
 {
     MOZ_ASSERT(NS_IsMainThread());
 
-    mIdentity = aIdentity.get();
+    mIdentity = aIdentity.take();
     mFlatJSObject.setFlags(FLAT_JS_OBJECT_VALID);
 
     MOZ_ASSERT(aScope, "bad ctor param");
     MOZ_ASSERT(aSet, "bad ctor param");
 }
 
 XPCWrappedNative::~XPCWrappedNative()
 {
--- a/layout/generic/nsBulletFrame.cpp
+++ b/layout/generic/nsBulletFrame.cpp
@@ -1798,17 +1798,17 @@ nsBulletFrame::GetLoadGroup(nsPresContex
 
   if (!shell)
     return;
 
   nsIDocument *doc = shell->GetDocument();
   if (!doc)
     return;
 
-  *aLoadGroup = doc->GetDocumentLoadGroup().get();  // already_AddRefed
+  *aLoadGroup = doc->GetDocumentLoadGroup().take();
 }
 
 union VoidPtrOrFloat {
   VoidPtrOrFloat() : p(nullptr) {}
 
   void *p;
   float f;
 };
--- a/layout/generic/nsCanvasFrame.cpp
+++ b/layout/generic/nsCanvasFrame.cpp
@@ -261,17 +261,18 @@ nsDisplayCanvasBackgroundImage::Paint(ns
 
   PaintInternal(aBuilder,
                 (surf || dt) ? &context : aCtx,
                 (surf || dt) ? bgClipRect: mVisibleRect,
                 &bgClipRect);
 
   if (surf) {
     BlitSurface(dest, destRect, surf);
-    frame->Properties().Set(nsIFrame::CachedBackgroundImage(), surf.forget().get());
+    frame->Properties().Set(nsIFrame::CachedBackgroundImage(),
+                            surf.forget().take());
   }
   if (dt) {
     BlitSurface(dest->GetDrawTarget(), destRect, dt);
     frame->Properties().Set(nsIFrame::CachedBackgroundImageDT(), dt.forget().drop());
   }
 }
 
 void
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -1882,17 +1882,17 @@ nsImageFrame::GetLoadGroup(nsPresContext
 
   if (!shell)
     return;
 
   nsIDocument *doc = shell->GetDocument();
   if (!doc)
     return;
 
-  *aLoadGroup = doc->GetDocumentLoadGroup().get();  // already_AddRefed
+  *aLoadGroup = doc->GetDocumentLoadGroup().take();
 }
 
 nsresult nsImageFrame::LoadIcons(nsPresContext *aPresContext)
 {
   NS_ASSERTION(!gIconLoad, "called LoadIcons twice");
 
   NS_NAMED_LITERAL_STRING(loadingSrc,"resource://gre-resources/loading-image.png");
   NS_NAMED_LITERAL_STRING(brokenSrc,"resource://gre-resources/broken-image.png");
--- a/layout/generic/nsSelection.cpp
+++ b/layout/generic/nsSelection.cpp
@@ -3633,17 +3633,17 @@ Selection::GetRangesForInterval(nsIDOMNo
     return NS_OK;
   }
 
   *aResults = static_cast<nsIDOMRange**>
                          (nsMemory::Alloc(sizeof(nsIDOMRange*) * *aResultCount));
   NS_ENSURE_TRUE(*aResults, NS_ERROR_OUT_OF_MEMORY);
 
   for (uint32_t i = 0; i < *aResultCount; i++) {
-    (*aResults)[i] = results[i].forget().get(); // Already AddRefed
+    (*aResults)[i] = results[i].forget().take();
   }
   return NS_OK;
 }
 
 
 void
 Selection::GetRangesForInterval(nsINode& aBeginNode, int32_t aBeginOffset,
                                 nsINode& aEndNode, int32_t aEndOffset,
--- a/layout/style/ErrorReporter.cpp
+++ b/layout/style/ErrorReporter.cpp
@@ -96,19 +96,19 @@ InitGlobals()
 
   nsCOMPtr<nsIStringBundle> sb;
   nsresult rv = sbs->CreateBundle("chrome://global/locale/css.properties",
                                   getter_AddRefs(sb));
   if (NS_FAILED(rv) || !sb) {
     return false;
   }
 
-  sConsoleService = cs.forget().get();
-  sScriptErrorFactory = sf.forget().get();
-  sStringBundle = sb.forget().get();
+  cs.forget(&sConsoleService);
+  sf.forget(&sScriptErrorFactory);
+  sb.forget(&sStringBundle);
 
   return true;
 }
 
 static inline bool
 ShouldReportErrors()
 {
   if (!sConsoleService) {
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -1172,17 +1172,17 @@ Loader::CreateSheet(nsIURI* aURI,
 
     if (sheet) {
       // The sheet we have now should be either incomplete or unmodified
       NS_ASSERTION(!sheet->IsModified() || !sheet->IsComplete(),
                    "Unexpected modified complete sheet");
       NS_ASSERTION(sheet->IsComplete() || aSheetState != eSheetComplete,
                    "Sheet thinks it's not complete while we think it is");
 
-      *aSheet = sheet->Clone(nullptr, nullptr, nullptr, nullptr).get();
+      *aSheet = sheet->Clone(nullptr, nullptr, nullptr, nullptr).take();
       if (*aSheet && fromCompleteSheets &&
           !sheet->GetOwnerNode() && !sheet->GetParentSheet()) {
         // The sheet we're cloning isn't actually referenced by
         // anyone.  Replace it in the cache, so that if our CSSOM is
         // later modified we don't end up with two copies of our inner
         // hanging around.
         URIPrincipalAndCORSModeHashKey key(aURI, aLoaderPrincipal, aCORSMode);
         NS_ASSERTION((*aSheet)->IsComplete(),
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -1115,17 +1115,17 @@ DOMCSSDeclarationImpl::SetCSSDeclaration
   nsCOMPtr<nsIStyleSheet> sheet = mRule->GetStyleSheet();
   if (sheet) {
     owningDoc = sheet->GetOwningDocument();
   }
 
   mozAutoDocUpdate updateBatch(owningDoc, UPDATE_STYLE, true);
 
   nsRefPtr<css::StyleRule> oldRule = mRule;
-  mRule = oldRule->DeclarationChanged(aDecl, true).get();
+  mRule = oldRule->DeclarationChanged(aDecl, true).take();
   if (!mRule)
     return NS_ERROR_OUT_OF_MEMORY;
   nsrefcnt cnt = mRule->Release();
   if (cnt == 0) {
     NS_NOTREACHED("container didn't take ownership");
     mRule = nullptr;
     return NS_ERROR_UNEXPECTED;
   }
--- a/layout/style/nsCSSValue.cpp
+++ b/layout/style/nsCSSValue.cpp
@@ -55,17 +55,17 @@ nsCSSValue::nsCSSValue(float aValue, nsC
   }
 }
 
 nsCSSValue::nsCSSValue(const nsString& aValue, nsCSSUnit aUnit)
   : mUnit(aUnit)
 {
   NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string value");
   if (UnitHasStringValue()) {
-    mValue.mString = BufferFromString(aValue).get();
+    mValue.mString = BufferFromString(aValue).take();
   }
   else {
     mUnit = eCSSUnit_Null;
     mValue.mInt = 0;
   }
 }
 
 nsCSSValue::nsCSSValue(nsCSSValue::Array* aValue, nsCSSUnit aUnit)
@@ -382,17 +382,17 @@ void nsCSSValue::SetFloatValue(float aVa
 
 void nsCSSValue::SetStringValue(const nsString& aValue,
                                 nsCSSUnit aUnit)
 {
   Reset();
   mUnit = aUnit;
   NS_ABORT_IF_FALSE(UnitHasStringValue(), "not a string unit");
   if (UnitHasStringValue()) {
-    mValue.mString = BufferFromString(aValue).get();
+    mValue.mString = BufferFromString(aValue).take();
   } else
     mUnit = eCSSUnit_Null;
 }
 
 void nsCSSValue::SetColorValue(nscolor aValue)
 {
   SetIntegerColorValue(aValue, eCSSUnit_RGBAColor);
 }
--- a/layout/style/nsStyleAnimation.cpp
+++ b/layout/style/nsStyleAnimation.cpp
@@ -3674,17 +3674,17 @@ nsStyleAnimation::Value::SetColorValue(n
   mValue.mColor = aColor;
 }
 
 void
 nsStyleAnimation::Value::SetUnparsedStringValue(const nsString& aString)
 {
   FreeValue();
   mUnit = eUnit_UnparsedString;
-  mValue.mString = nsCSSValue::BufferFromString(aString).get();
+  mValue.mString = nsCSSValue::BufferFromString(aString).take();
 }
 
 void
 nsStyleAnimation::Value::SetAndAdoptCSSValueValue(nsCSSValue *aValue,
                                                   Unit aUnit)
 {
   FreeValue();
   NS_ABORT_IF_FALSE(IsCSSValueUnit(aUnit), "bad unit");
--- a/layout/style/nsStyleContext.h
+++ b/layout/style/nsStyleContext.h
@@ -166,23 +166,24 @@ public:
   // related to the Peek code in nsStyleContext::CalcStyleDifference.
   nsStyleContext* GetStyleIfVisited() const
     { return mStyleIfVisited; }
 
   // To be called only from nsStyleSet.
   void SetStyleIfVisited(already_AddRefed<nsStyleContext> aStyleIfVisited)
   {
     NS_ABORT_IF_FALSE(!IsStyleIfVisited(), "this context is not visited data");
-    NS_ABORT_IF_FALSE(aStyleIfVisited.get()->IsStyleIfVisited(),
-                      "other context is visited data");
-    NS_ABORT_IF_FALSE(!aStyleIfVisited.get()->GetStyleIfVisited(),
-                      "other context does not have visited data");
     NS_ASSERTION(!mStyleIfVisited, "should only be set once");
+
     mStyleIfVisited = aStyleIfVisited;
 
+    NS_ABORT_IF_FALSE(mStyleIfVisited->IsStyleIfVisited(),
+                      "other context is visited data");
+    NS_ABORT_IF_FALSE(!mStyleIfVisited->GetStyleIfVisited(),
+                      "other context does not have visited data");
     NS_ASSERTION(GetStyleIfVisited()->GetPseudo() == GetPseudo(),
                  "pseudo tag mismatch");
     if (GetParent() && GetParent()->GetStyleIfVisited()) {
       NS_ASSERTION(GetStyleIfVisited()->GetParent() ==
                      GetParent()->GetStyleIfVisited() ||
                    GetStyleIfVisited()->GetParent() == GetParent(),
                    "parent mismatch");
     } else {
--- a/layout/xul/tree/nsTreeBoxObject.cpp
+++ b/layout/xul/tree/nsTreeBoxObject.cpp
@@ -206,17 +206,17 @@ NS_IMETHODIMP nsTreeBoxObject::GetTreeBo
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeBoxObject::GetColumns(nsITreeColumns** aColumns)
 {
   *aColumns = nullptr;
   nsTreeBodyFrame* body = GetTreeBody();
   if (body) 
-    *aColumns = body->Columns().get();
+    *aColumns = body->Columns().take();
   return NS_OK;
 }
 
 NS_IMETHODIMP nsTreeBoxObject::GetRowHeight(int32_t* aRowHeight)
 {
   *aRowHeight = 0;
   nsTreeBodyFrame* body = GetTreeBody();
   if (body) 
--- a/layout/xul/tree/nsTreeStyleCache.cpp
+++ b/layout/xul/tree/nsTreeStyleCache.cpp
@@ -54,17 +54,17 @@ nsTreeStyleCache::GetStyleContext(nsICSS
   // Look up our style context for this state.
   nsStyleContext* result = nullptr;
   if (mCache)
     result = static_cast<nsStyleContext*>(mCache->Get(currState));
   if (!result) {
     // We missed the cache. Resolve this pseudo-style.
     result = aPresContext->StyleSet()->
       ResolveXULTreePseudoStyle(aContent->AsElement(), aPseudoElement,
-                                aContext, aComparator).get();
+                                aContext, aComparator).take();
 
     // Put the style context in our table, transferring the owning reference to the table.
     if (!mCache) {
       mCache = new nsObjectHashtable(nullptr, nullptr, ReleaseStyleContext, nullptr);
     }
     mCache->Put(currState, result);
   }
 
--- a/media/mtransport/nriceresolver.cpp
+++ b/media/mtransport/nriceresolver.cpp
@@ -169,17 +169,17 @@ int NrIceResolver::resolve(nr_resolver_r
     ABORT(R_NOT_FOUND);
   }
   // Because the C API offers no "finished" method to release the handle we
   // return, we cannot return the request we got from AsyncResolve directly.
   //
   // Instead, we return an addref'ed reference to PendingResolution itself,
   // which in turn holds the request and coordinates between cancel and
   // OnLookupComplete to release it only once.
-  *handle = pr.forget().get();
+  pr.forget(handle);
 
   _status=0;
 abort:
   return _status;
 }
 
 nsresult NrIceResolver::PendingResolution::OnLookupComplete(
     nsICancelable *request, nsIDNSRecord *record, nsresult status) {
--- a/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
+++ b/media/webrtc/signaling/src/peerconnection/PeerConnectionImpl.cpp
@@ -938,17 +938,17 @@ PeerConnectionImpl::CreateFakeMediaStrea
       new Fake_AudioGenerator(stream);
     } else {
 #ifdef MOZILLA_INTERNAL_API
     new Fake_VideoGenerator(stream);
 #endif
     }
   }
 
-  *aRetval = stream.forget().get();
+  stream.forget(aRetval);
   return NS_OK;
 }
 
 // Stubbing this call out for now.
 // We can remove it when we are confident of datachannels being started
 // correctly on SDP negotiation (bug 852908)
 NS_IMETHODIMP
 PeerConnectionImpl::ConnectDataConnection(uint16_t aLocalport,
@@ -1162,24 +1162,31 @@ static void NotifyDataChannel_m(nsRefPtr
   NS_DataChannelAppReady(aChannel);
 }
 #endif
 
 void
 PeerConnectionImpl::NotifyDataChannel(already_AddRefed<DataChannel> aChannel)
 {
   PC_AUTO_ENTER_API_CALL_NO_CHECK();
-  MOZ_ASSERT(aChannel.get());
 
-  CSFLogDebug(logTag, "%s: channel: %p", __FUNCTION__, aChannel.get());
+  // XXXkhuey this is completely fucked up.  We can't use nsRefPtr<DataChannel>
+  // here because DataChannel's AddRef/Release are non-virtual and not visible
+  // if !MOZILLA_INTERNAL_API, but this function leaks the DataChannel if
+  // !MOZILLA_INTERNAL_API because it never transfers the ref to
+  // NS_NewDOMDataChannel.
+  DataChannel* channel = aChannel.take();
+  MOZ_ASSERT(channel);
+
+  CSFLogDebug(logTag, "%s: channel: %p", __FUNCTION__, channel);
 
 #ifdef MOZILLA_INTERNAL_API
   nsCOMPtr<nsIDOMDataChannel> domchannel;
-  nsresult rv = NS_NewDOMDataChannel(aChannel, mWindow,
-                                     getter_AddRefs(domchannel));
+  nsresult rv = NS_NewDOMDataChannel(already_AddRefed<DataChannel>(channel),
+                                     mWindow, getter_AddRefs(domchannel));
   NS_ENSURE_SUCCESS_VOID(rv);
 
   nsRefPtr<PeerConnectionObserver> pco = do_QueryObjectReferent(mPCObserver);
   if (!pco) {
     return;
   }
 
   RUN_ON_THREAD(mThread,
@@ -1637,17 +1644,17 @@ PeerConnectionImpl::ShutdownMedia()
   if (!mStartTime.IsNull()){
     TimeDuration timeDelta = TimeStamp::Now() - mStartTime;
     Telemetry::Accumulate(Telemetry::WEBRTC_CALL_DURATION, timeDelta.ToSeconds());
   }
 #endif
 
   // Forget the reference so that we can transfer it to
   // SelfDestruct().
-  mMedia.forget().get()->SelfDestruct();
+  mMedia.forget().take()->SelfDestruct();
 }
 
 #ifdef MOZILLA_INTERNAL_API
 // If NSS is shutting down, then we need to get rid of the DTLS
 // identity right now; otherwise, we'll cause wreckage when we do
 // finally deallocate it in our destructor.
 void
 PeerConnectionImpl::virtualDestroyNSSReference()
--- a/media/webrtc/trunk/build/android/gtest_filter/net_unittests_disabled
+++ b/media/webrtc/trunk/build/android/gtest_filter/net_unittests_disabled
@@ -78,22 +78,22 @@ URLFetcherProtectTest.Overload
 URLFetcherProtectTest.ServerUnavailable
 URLFetcherProtectTestPassedThrough.ServerUnavailablePropagateResponse
 URLFetcherBadHTTPSTest.BadHTTPSTest
 URLFetcherCancelTest.ReleasesContext
 URLFetcherCancelTest.CancelWhileDelayedStartTaskPending
 URLFetcherMultipleAttemptTest.SameData
 URLFetcherFileTest.SmallGet
 URLFetcherFileTest.LargeGet
-URLFetcherFileTest.CanTakeOwnershipOfFile
+URLFetcherFileTest.CantakeOfFile
 URLFetcherFileTest.OverwriteExistingFile
 URLFetcherFileTest.TryToOverwriteDirectory
 URLFetcherFileTest.SmallGetToTempFile
 URLFetcherFileTest.LargeGetToTempFile
-URLFetcherFileTest.CanTakeOwnershipOfTempFile
+URLFetcherFileTest.CantakeOfTempFile
 URLFetcherEmptyPostTest.Basic
 # TODO(jrg): Fails on bots.  Works locally.  Figure out why.  2/6/12
 HttpCache.TypicalGET_ConditionalRequest
 HttpCache.RangeGET_OK
 HttpCache.RangeGET_SyncOK
 HttpCache.RangeGET_Revalidate2
 HttpCache.RangeGET_Previous200
 HttpCache.RangeGET_Cancel2
--- a/modules/libjar/nsZipArchive.cpp
+++ b/modules/libjar/nsZipArchive.cpp
@@ -208,17 +208,17 @@ nsresult nsZipHandle::Init(nsIFile *file
   if (aFd) {
     *aFd = fd.forget();
   }
 #endif
   handle->mMap = map;
   handle->mFile.Init(file);
   handle->mLen = (uint32_t) size;
   handle->mFileData = buf;
-  *ret = handle.forget().get();
+  handle.forget(ret);
   return NS_OK;
 }
 
 nsresult nsZipHandle::Init(nsZipArchive *zip, const char *entry,
                            nsZipHandle **ret)
 {
   nsRefPtr<nsZipHandle> handle = new nsZipHandle();
   if (!handle)
@@ -230,17 +230,17 @@ nsresult nsZipHandle::Init(nsZipArchive 
 
   if (!handle->mBuf->Buffer())
     return NS_ERROR_UNEXPECTED;
 
   handle->mMap = nullptr;
   handle->mFile.Init(zip, entry);
   handle->mLen = handle->mBuf->Length();
   handle->mFileData = handle->mBuf->Buffer();
-  *ret = handle.forget().get();
+  handle.forget(ret);
   return NS_OK;
 }
 
 int64_t nsZipHandle::SizeOfMapping()
 {
     return mLen;
 }
 
--- a/netwerk/base/public/nsNetUtil.h
+++ b/netwerk/base/public/nsNetUtil.h
@@ -93,33 +93,33 @@
 
 #ifdef MOZILLA_INTERNAL_API
 
 #include "nsReadableUtils.h"
 
 inline already_AddRefed<nsIIOService>
 do_GetIOService(nsresult* error = 0)
 {
-    already_AddRefed<nsIIOService> ret = mozilla::services::GetIOService();
+    nsCOMPtr<nsIIOService> io = mozilla::services::GetIOService();
     if (error)
-        *error = ret.get() ? NS_OK : NS_ERROR_FAILURE;
-    return ret;
+        *error = io ? NS_OK : NS_ERROR_FAILURE;
+    return io.forget();
 }
 
 inline already_AddRefed<nsINetUtil>
 do_GetNetUtil(nsresult *error = 0) 
 {
     nsCOMPtr<nsIIOService> io = mozilla::services::GetIOService();
-    already_AddRefed<nsINetUtil> ret = nullptr;
+    nsCOMPtr<nsINetUtil> util;
     if (io)
-        CallQueryInterface(io, &ret.mRawPtr);
+        util = do_QueryInterface(io);
 
     if (error)
-        *error = ret.get() ? NS_OK : NS_ERROR_FAILURE;
-    return ret;
+        *error = !!util ? NS_OK : NS_ERROR_FAILURE;
+    return util.forget();
 }
 #else
 // Helper, to simplify getting the I/O service.
 inline const nsGetServiceByContractIDWithError
 do_GetIOService(nsresult* error = 0)
 {
     return nsGetServiceByContractIDWithError(NS_IOSERVICE_CONTRACTID, error);
 }
--- a/netwerk/base/src/EventTokenBucket.cpp
+++ b/netwerk/base/src/EventTokenBucket.cpp
@@ -223,17 +223,17 @@ EventTokenBucket::SubmitEvent(ATokenBuck
   // When this function exits the cancelEvent needs 2 references, one for the
   // mEvents queue and one for the caller of SubmitEvent()
 
   NS_ADDREF(*cancelable = cancelEvent.get());
 
   if (mPaused || !TryImmediateDispatch(cancelEvent.get())) {
     // queue it
     SOCKET_LOG(("   queued\n"));
-    mEvents.Push(cancelEvent.forget().get());
+    mEvents.Push(cancelEvent.forget().take());
     UpdateTimer();
   }
   else {
     SOCKET_LOG(("   dispatched synchronously\n"));
   }
 
   return NS_OK;
 }
--- a/netwerk/base/src/nsPACMan.cpp
+++ b/netwerk/base/src/nsPACMan.cpp
@@ -321,17 +321,17 @@ nsPACMan::PostQuery(PendingPACQuery *que
 
   if (mShutdown) {
     query->Complete(NS_ERROR_NOT_AVAILABLE, EmptyCString());
     return NS_OK;
   }
 
   // add a reference to the query while it is in the pending list
   nsRefPtr<PendingPACQuery> addref(query);
-  mPendingQ.insertBack(addref.forget().get());
+  mPendingQ.insertBack(addref.forget().take());
   ProcessPendingQ();
   return NS_OK;
 }
 
 nsresult
 nsPACMan::LoadPACFromURI(const nsCString &spec)
 {
   NS_ENSURE_STATE(!mShutdown);
--- a/netwerk/cache/nsCacheEntryDescriptor.cpp
+++ b/netwerk/cache/nsCacheEntryDescriptor.cpp
@@ -1118,17 +1118,17 @@ nsOutputStreamWrapper::LazyInit()
             cacheEntry->SetDataSize(mStartOffset);
     } else {
         rv = NS_ERROR_NOT_AVAILABLE;
     }
 
     // If anything above failed, clean up internal state and get out of here
     // (see bug #654926)...
     if (NS_FAILED(rv)) {
-        nsCacheService::ReleaseObject_Locked(stream.forget().get());
+        nsCacheService::ReleaseObject_Locked(stream.forget().take());
         mDescriptor->mOutputWrapper = nullptr;
         nsCacheService::ReleaseObject_Locked(mDescriptor);
         mDescriptor = nullptr;
         mInitialized = false;
         return rv;
     }
 
     mOutput = stream;
--- a/netwerk/cache2/CacheFile.cpp
+++ b/netwerk/cache2/CacheFile.cpp
@@ -363,17 +363,17 @@ CacheFile::OnChunkWritten(nsresult aResu
     return NS_OK;
   }
 
   LOG(("CacheFile::OnChunkWritten() - Caching unused chunk [this=%p, chunk=%p]",
        this, aChunk));
 
   aChunk->mRemovingChunk = true;
   ReleaseOutsideLock(static_cast<CacheFileChunkListener *>(
-                       aChunk->mFile.forget().get()));
+                       aChunk->mFile.forget().take()));
   mCachedChunks.Put(aChunk->Index(), aChunk);
   mChunks.Remove(aChunk->Index());
   WriteMetadataIfNeededLocked();
 
   return NS_OK;
 }
 
 nsresult
@@ -1024,17 +1024,17 @@ CacheFile::GetChunkLocked(uint32_t aInde
 
     // Read the chunk from the disk
     rv = chunk->Read(mHandle, std::min(static_cast<uint32_t>(mDataSize - off),
                      static_cast<uint32_t>(kChunkSize)),
                      mMetadata->GetHash(aIndex), this);
     if (NS_FAILED(rv)) {
       chunk->mRemovingChunk = true;
       ReleaseOutsideLock(static_cast<CacheFileChunkListener *>(
-                           chunk->mFile.forget().get()));
+                           chunk->mFile.forget().take()));
       mChunks.Remove(aIndex);
       NS_ENSURE_SUCCESS(rv, rv);
     }
 
     if (aWriter) {
       chunk.swap(*_retval);
     }
     else {
@@ -1195,17 +1195,17 @@ CacheFile::RemoveChunk(CacheFileChunk *a
       }
     }
 
     LOG(("CacheFile::RemoveChunk() - Caching unused chunk [this=%p, chunk=%p]",
          this, chunk.get()));
 
     chunk->mRemovingChunk = true;
     ReleaseOutsideLock(static_cast<CacheFileChunkListener *>(
-                         chunk->mFile.forget().get()));
+                         chunk->mFile.forget().take()));
     mCachedChunks.Put(chunk->Index(), chunk);
     mChunks.Remove(chunk->Index());
     if (!mMemoryOnly)
       WriteMetadataIfNeededLocked();
   }
 
   return NS_OK;
 }
@@ -1540,17 +1540,17 @@ CacheFile::PadChunkWithZeroes(uint32_t a
        " [this=%p]", aChunkIdx, chunk->DataSize(), kChunkSize - 1, this));
 
   chunk->EnsureBufSize(kChunkSize);
   memset(chunk->BufForWriting() + chunk->DataSize(), 0, kChunkSize - chunk->DataSize());
 
   chunk->UpdateDataSize(chunk->DataSize(), kChunkSize - chunk->DataSize(),
                         false);
 
-  ReleaseOutsideLock(chunk.forget().get());
+  ReleaseOutsideLock(chunk.forget().take());
 
   return NS_OK;
 }
 
 nsresult
 CacheFile::InitIndexEntry()
 {
   MOZ_ASSERT(mHandle);
--- a/netwerk/cache2/CacheFileInputStream.cpp
+++ b/netwerk/cache2/CacheFileInputStream.cpp
@@ -478,17 +478,17 @@ CacheFileInputStream::ReleaseChunk()
   if (mWaitingForUpdate) {
     LOG(("CacheFileInputStream::ReleaseChunk() - Canceling waiting for update. "
          "[this=%p]", this));
 
     mChunk->CancelWait(this);
     mWaitingForUpdate = false;
   }
 
-  mFile->ReleaseOutsideLock(mChunk.forget().get());
+  mFile->ReleaseOutsideLock(mChunk.forget().take());
 }
 
 void
 CacheFileInputStream::EnsureCorrectChunk(bool aReleaseOnly)
 {
   mFile->AssertOwnsLock();
 
   LOG(("CacheFileInputStream::EnsureCorrectChunk() [this=%p, releaseOnly=%d]",
--- a/netwerk/cache2/CacheFileOutputStream.cpp
+++ b/netwerk/cache2/CacheFileOutputStream.cpp
@@ -308,17 +308,17 @@ void CacheFileOutputStream::NotifyCloseL
 }
 
 void
 CacheFileOutputStream::ReleaseChunk()
 {
   LOG(("CacheFileOutputStream::ReleaseChunk() [this=%p, idx=%d]",
        this, mChunk->Index()));
 
-  mFile->ReleaseOutsideLock(mChunk.forget().get());
+  mFile->ReleaseOutsideLock(mChunk.forget().take());
 }
 
 void
 CacheFileOutputStream::EnsureCorrectChunk(bool aReleaseOnly)
 {
   mFile->AssertOwnsLock();
 
   LOG(("CacheFileOutputStream::EnsureCorrectChunk() [this=%p, releaseOnly=%d]",
--- a/netwerk/protocol/about/nsAboutCacheEntry.cpp
+++ b/netwerk/protocol/about/nsAboutCacheEntry.cpp
@@ -133,17 +133,17 @@ nsAboutCacheEntry::GetContentStream(nsIU
     uint32_t n;
     rv = mOutputStream->Write(buffer.get(), buffer.Length(), &n);
     if (NS_FAILED(rv)) return rv;
     if (n != buffer.Length()) return NS_ERROR_UNEXPECTED;
 
     rv = OpenCacheEntry(uri);
     if (NS_FAILED(rv)) return rv;
 
-    *result = inputStream.forget().get();
+    inputStream.forget(result);
     return NS_OK;
 }
 
 nsresult
 nsAboutCacheEntry::OpenCacheEntry(nsIURI *uri)
 {
     nsresult rv;
     nsAutoCString clientID, key;
--- a/netwerk/protocol/http/NullHttpTransaction.cpp
+++ b/netwerk/protocol/http/NullHttpTransaction.cpp
@@ -47,18 +47,17 @@ NullHttpTransaction::Connection()
 {
   return mConnection.get();
 }
 
 void
 NullHttpTransaction::GetSecurityCallbacks(nsIInterfaceRequestor **outCB)
 {
   nsCOMPtr<nsIInterfaceRequestor> copyCB(mCallbacks);
-  *outCB = copyCB;
-  copyCB.forget();
+  *outCB = copyCB.forget().take();
 }
 
 void
 NullHttpTransaction::OnTransportStatus(nsITransport* transport,
                                        nsresult status, uint64_t progress)
 {
 }
 
--- a/netwerk/protocol/http/nsHttpConnectionMgr.cpp
+++ b/netwerk/protocol/http/nsHttpConnectionMgr.cpp
@@ -498,17 +498,17 @@ nsHttpConnectionMgr::OnMsgUpdateRequestT
 nsresult
 nsHttpConnectionMgr::UpdateRequestTokenBucket(EventTokenBucket *aBucket)
 {
     nsRefPtr<EventTokenBucket> bucket(aBucket);
 
     // Call From main thread when a new EventTokenBucket has been made in order
     // to post the new value to the socket thread.
     nsresult rv = PostEvent(&nsHttpConnectionMgr::OnMsgUpdateRequestTokenBucket,
-                            0, bucket.get());
+                            0, bucket);
     if (NS_SUCCEEDED(rv))
         bucket.forget();
     return rv;
 }
 
 // Given a nsHttpConnectionInfo find the connection entry object that
 // contains either the nshttpconnection or nshttptransaction parameter.
 // Normally this is done by the hashkey lookup of connectioninfo,
@@ -3100,17 +3100,17 @@ nsHalfOpenSocket::OnOutputStreamReady(ns
         }
         else {
             // otherwise just put this in the persistent connection pool
             LOG(("nsHalfOpenSocket::OnOutputStreamReady no transaction match "
                  "returning conn %p to pool\n", conn.get()));
             nsRefPtr<nsHttpConnection> copy(conn);
             // forget() to effectively addref because onmsg*() will drop a ref
             gHttpHandler->ConnMgr()->OnMsgReclaimConnection(
-                0, conn.forget().get());
+                0, conn.forget().take());
         }
     }
 
     return rv;
 }
 
 // method for nsITransportEventSink
 NS_IMETHODIMP
--- a/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
+++ b/netwerk/protocol/wyciwyg/nsWyciwygProtocolHandler.cpp
@@ -124,17 +124,17 @@ nsWyciwygProtocolHandler::NewChannel(nsI
     nsWyciwygChannel *wc = new nsWyciwygChannel();
     channel = wc;
     rv = wc->Init(url);
   }
 
   if (NS_FAILED(rv))
     return rv;
 
-  *result = channel.forget().get();
+  channel.forget(result);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWyciwygProtocolHandler::GetProtocolFlags(uint32_t *result) 
 {
   // Should this be an an nsINestedURI?  We don't really want random webpages
   // loading these URIs...
--- a/rdf/base/src/nsRDFContentSink.cpp
+++ b/rdf/base/src/nsRDFContentSink.cpp
@@ -1335,17 +1335,17 @@ RDFContentSinkImpl::SplitExpatName(const
             }
 
             uriEnd = pos;
             nameStart = pos + 1;
         }
     }
 
     const nsDependentSubstring& nameSpaceURI = Substring(aExpatName, uriEnd);
-    *aLocalName = NS_NewAtom(Substring(nameStart, pos)).get();
+    *aLocalName = NS_NewAtom(Substring(nameStart, pos)).take();
     return nameSpaceURI;
 }
 
 nsresult
 RDFContentSinkImpl::InitContainer(nsIRDFResource* aContainerType, nsIRDFResource* aContainer)
 {
     // Do the right kind of initialization based on the container
     // 'type' resource, and the state of the container (i.e., 'make' a
--- a/security/manager/ssl/src/nsCertTree.cpp
+++ b/security/manager/ssl/src/nsCertTree.cpp
@@ -859,17 +859,17 @@ nsCertTree::DeleteEntryObject(uint32_t i
 //
 /////////////////////////////////////////////////////////////////////////////
 
 /* nsIX509Cert getCert(in unsigned long index); */
 NS_IMETHODIMP
 nsCertTree::GetCert(uint32_t aIndex, nsIX509Cert **_cert)
 {
   NS_ENSURE_ARG(_cert);
-  *_cert = GetCertAtIndex(aIndex).get();
+  *_cert = GetCertAtIndex(aIndex).take();
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsCertTree::GetTreeItem(uint32_t aIndex, nsICertTreeItem **_treeitem)
 {
   NS_ENSURE_ARG(_treeitem);
 
--- a/security/manager/ssl/src/nsNSSCertHelper.cpp
+++ b/security/manager/ssl/src/nsNSSCertHelper.cpp
@@ -2119,17 +2119,17 @@ nsNSSCertificate::CreateASN1Struct(nsIAS
   nsCOMPtr<nsIASN1Sequence> sequence = new nsNSSASN1Sequence();
 
   nsCOMPtr<nsIMutableArray> asn1Objects;
   sequence->GetASN1Objects(getter_AddRefs(asn1Objects));
   nsXPIDLCString title;
   GetWindowTitle(getter_Copies(title));
   
   sequence->SetDisplayName(NS_ConvertUTF8toUTF16(title));
-  *aRetVal = sequence.forget().get();
+  sequence.forget(aRetVal);
 
   // This sequence will be contain the tbsCertificate, signatureAlgorithm,
   // and signatureValue.
   nsresult rv;
   nsCOMPtr<nsINSSComponent> nssComponent(do_GetService(kNSSComponentCID, &rv));
   if (NS_FAILED(rv))
     return rv;
 
--- a/security/sandbox/chromium/base/basictypes.h
+++ b/security/sandbox/chromium/base/basictypes.h
@@ -330,17 +330,17 @@ inline Dest bit_cast(const Source& sourc
   return dest;
 }
 
 // Used to explicitly mark the return value of a function as unused. If you are
 // really sure you don't want to do anything with the return value of a function
 // that has been marked WARN_UNUSED_RESULT, wrap it with this. Example:
 //
 //   scoped_ptr<MyType> my_var = ...;
-//   if (TakeOwnership(my_var.get()) == SUCCESS)
+//   if (take(my_var.get()) == SUCCESS)
 //     ignore_result(my_var.release());
 //
 template<typename T>
 inline void ignore_result(const T&) {
 }
 
 // The following enum should be used only as a constructor argument to indicate
 // that the variable has static storage class, and that the constructor should
--- a/toolkit/components/finalizationwitness/FinalizationWitnessService.cpp
+++ b/toolkit/components/finalizationwitness/FinalizationWitnessService.cpp
@@ -199,15 +199,15 @@ FinalizationWitnessService::Make(const c
   if (!JS_DefineFunctions(aCx, objResult, sWitnessClassFunctions)) {
     return NS_ERROR_FAILURE;
   }
 
   nsRefPtr<FinalizationEvent> event = new FinalizationEvent(aTopic, aValue);
 
   // Transfer ownership of the addrefed |event| to |objResult|.
   JS_SetReservedSlot(objResult, WITNESS_SLOT_EVENT,
-                     JS::PrivateValue(event.forget().get()));
+                     JS::PrivateValue(event.forget().take()));
 
   aRetval.setObject(*objResult);
   return NS_OK;
 }
 
 } // namespace mozilla
--- a/toolkit/xre/nsEmbedFunctions.cpp
+++ b/toolkit/xre/nsEmbedFunctions.cpp
@@ -713,17 +713,17 @@ XRE_ShutdownChildProcess()
 #endif // XP_MACOSX
 }
 
 namespace {
 ContentParent* gContentParent; //long-lived, manually refcounted
 TestShellParent* GetOrCreateTestShellParent()
 {
     if (!gContentParent) {
-        nsRefPtr<ContentParent> parent = ContentParent::GetNewOrUsed().get();
+        nsRefPtr<ContentParent> parent = ContentParent::GetNewOrUsed();
         parent.forget(&gContentParent);
     } else if (!gContentParent->IsAlive()) {
         return nullptr;
     }
     TestShellParent* tsp = gContentParent->GetTestShellSingleton();
     if (!tsp) {
         tsp = gContentParent->CreateTestShell();
     }
--- a/uriloader/exthandler/nsExternalHelperAppService.cpp
+++ b/uriloader/exthandler/nsExternalHelperAppService.cpp
@@ -2510,17 +2510,17 @@ NS_IMETHODIMP nsExternalHelperAppService
       return NS_ERROR_NOT_AVAILABLE;
   }
 
   // We promise to only send lower case mime types to the OS
   ToLowerCase(typeToUse);
 
   // (1) Ask the OS for a mime info
   bool found;
-  *_retval = GetMIMEInfoFromOS(typeToUse, aFileExt, &found).get();
+  *_retval = GetMIMEInfoFromOS(typeToUse, aFileExt, &found).take();
   LOG(("OS gave back 0x%p - found: %i\n", *_retval, found));
   // If we got no mimeinfo, something went wrong. Probably lack of memory.
   if (!*_retval)
     return NS_ERROR_OUT_OF_MEMORY;
 
   // (2) Now, let's see if we can find something in our datastore
   // This will not overwrite the OS information that interests us
   // (i.e. default application, default app. description)
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -574,17 +574,17 @@ nsresult nsView::CreateWidget(nsWidgetIn
   if (!parentWidget) {
     NS_ERROR("nsView::CreateWidget without suitable parent widget??");
     return NS_ERROR_FAILURE;
   }
 
   // XXX: using aForceUseIWidgetParent=true to preserve previous
   // semantics.  It's not clear that it's actually needed.
   mWindow = parentWidget->CreateChild(trect, dx, aWidgetInitData,
-                                      true).get();
+                                      true).take();
   if (!mWindow) {
     return NS_ERROR_FAILURE;
   }
  
   InitializeWindow(aEnableDragDrop, aResetVisibility);
 
   return NS_OK;
 }
@@ -603,17 +603,17 @@ nsresult nsView::CreateWidgetForParent(n
   DefaultWidgetInitData defaultInitData;
   aWidgetInitData = aWidgetInitData ? aWidgetInitData : &defaultInitData;
 
   nsIntRect trect = CalcWidgetBounds(aWidgetInitData->mWindowType);
 
   nsRefPtr<nsDeviceContext> dx = mViewManager->GetDeviceContext();
 
   mWindow =
-    aParentWidget->CreateChild(trect, dx, aWidgetInitData).get();
+    aParentWidget->CreateChild(trect, dx, aWidgetInitData).take();
   if (!mWindow) {
     return NS_ERROR_FAILURE;
   }
 
   InitializeWindow(aEnableDragDrop, aResetVisibility);
 
   return NS_OK;
 }
@@ -635,29 +635,29 @@ nsresult nsView::CreateWidgetForPopup(ns
   // XXX/cjones: having these two separate creation cases seems ... um
   // ... unnecessary, but it's the way the old code did it.  Please
   // unify them by first finding a suitable parent nsIWidget, then
   // getting rid of aForceUseIWidgetParent.
   if (aParentWidget) {
     // XXX: using aForceUseIWidgetParent=true to preserve previous
     // semantics.  It's not clear that it's actually needed.
     mWindow = aParentWidget->CreateChild(trect, dx, aWidgetInitData,
-                                         true).get();
+                                         true).take();
   }
   else {
     nsIWidget* nearestParent = GetParent() ? GetParent()->GetNearestWidget(nullptr)
                                            : nullptr;
     if (!nearestParent) {
       // Without a parent, we can't make a popup.  This can happen
       // when printing
       return NS_ERROR_FAILURE;
     }
 
     mWindow =
-      nearestParent->CreateChild(trect, dx, aWidgetInitData).get();
+      nearestParent->CreateChild(trect, dx, aWidgetInitData).take();
   }
   if (!mWindow) {
     return NS_ERROR_FAILURE;
   }
 
   InitializeWindow(aEnableDragDrop, aResetVisibility);
 
   return NS_OK;
--- a/widget/windows/KeyboardLayout.cpp
+++ b/widget/windows/KeyboardLayout.cpp
@@ -1805,18 +1805,18 @@ nsIIdleServiceInternal* KeyboardLayout::
 // static
 KeyboardLayout*
 KeyboardLayout::GetInstance()
 {
   if (!sInstance) {
     sInstance = new KeyboardLayout();
     nsCOMPtr<nsIIdleServiceInternal> idleService =
       do_GetService("@mozilla.org/widget/idleservice;1");
-    // The refcount will be decreased at shutting down.
-    sIdleService = idleService.forget().get();
+    // The refcount will be decreased at shut down.
+    sIdleService = idleService.forget().take();
   }
   return sInstance;
 }
 
 // static
 void
 KeyboardLayout::Shutdown()
 {
--- a/widget/xpwidgets/GfxInfoBase.cpp
+++ b/widget/xpwidgets/GfxInfoBase.cpp
@@ -339,17 +339,17 @@ BlacklistNodeGetChildByName(nsIDOMElemen
       !nodelist) {
     return false;
   }
 
   nsCOMPtr<nsIDOMNode> node;
   if (NS_FAILED(nodelist->Item(0, getter_AddRefs(node))) || !node)
     return false;
 
-  *firstchild = node.forget().get();
+  node.forget(firstchild);
   return true;
 }
 
 /*
 
 <gfxBlacklistEntry>
   <os>WINNT 6.0</os>
   <vendor>0x8086</vendor>
--- a/widget/xpwidgets/nsBaseWidget.cpp
+++ b/widget/xpwidgets/nsBaseWidget.cpp
@@ -1607,17 +1607,17 @@ nsIWidget::SynthesizeNativeTouchTap(nsIn
                                        TimeDuration::FromMilliseconds(elapse));
   return NS_OK;
 }
 
 // static
 void
 nsIWidget::OnLongTapTimerCallback(nsITimer* aTimer, void* aClosure)
 {
-  nsIWidget *self = static_cast<nsIWidget *>(aClosure);
+  nsIWidget *self = static_cast<nsIWidget *>(aClosure);
 
   if ((self->mLongTapTouchPoint->mStamp + self->mLongTapTouchPoint->mDuration) >
       TimeStamp::Now()) {
 #ifdef XP_WIN
     // Windows needs us to keep pumping feedback to the digitizer, so update
     // the pointer id with the same position.
     self->SynthesizeNativeTouchPoint(self->mLongTapTouchPoint->mPointerId,
                                      TOUCH_CONTACT,
--- a/xpcom/build/Services.cpp
+++ b/xpcom/build/Services.cpp
@@ -24,24 +24,24 @@
 using namespace mozilla;
 using namespace mozilla::services;
 
 /*
  * Define a global variable and a getter for every service in ServiceList.
  * eg. gIOService and GetIOService()
  */
 #define MOZ_SERVICE(NAME, TYPE, CONTRACT_ID)                            \
-  static TYPE* g##NAME = nullptr;                                        \
+  static TYPE* g##NAME = nullptr;                                       \
                                                                         \
   already_AddRefed<TYPE>                                                \
   mozilla::services::Get##NAME()                                        \
   {                                                                     \
     if (!g##NAME) {                                                     \
       nsCOMPtr<TYPE> os = do_GetService(CONTRACT_ID);                   \
-      g##NAME = os.forget().get();                                      \
+      g##NAME = os.forget().take();                            \
     }                                                                   \
     nsRefPtr<TYPE> ret = g##NAME;                                       \
     return ret.forget();                                                \
   }                                                                     \
   NS_EXPORT_(already_AddRefed<TYPE>)                                    \
   mozilla::services::_external_Get##NAME()                              \
   {                                                                     \
     return Get##NAME();                                                 \
--- a/xpcom/components/ModuleUtils.h
+++ b/xpcom/components/ModuleUtils.h
@@ -78,17 +78,17 @@ static nsresult                         
     _InstanceClass * inst;                                                    \
                                                                               \
     *aResult = nullptr;                                                       \
     if (nullptr != aOuter) {                                                  \
         rv = NS_ERROR_NO_AGGREGATION;                                         \
         return rv;                                                            \
     }                                                                         \
                                                                               \
-    inst = already_AddRefed<_InstanceClass>(_GetterProc()).get();             \
+    inst = already_AddRefed<_InstanceClass>(_GetterProc()).take();   \
     if (nullptr == inst) {                                                    \
         rv = NS_ERROR_OUT_OF_MEMORY;                                          \
         return rv;                                                            \
     }                                                                         \
     /* NS_ADDREF(inst); */                                                    \
     rv = inst->QueryInterface(aIID, aResult);                                 \
     NS_RELEASE(inst);                                                         \
                                                                               \
--- a/xpcom/ds/nsAtomService.cpp
+++ b/xpcom/ds/nsAtomService.cpp
@@ -10,17 +10,17 @@ NS_IMPL_ISUPPORTS1(nsAtomService, nsIAto
 
 nsAtomService::nsAtomService()
 {
 }
 
 nsresult
 nsAtomService::GetAtom(const nsAString& aString, nsIAtom ** aResult)
 {
-  *aResult = NS_NewAtom(aString).get();
+  *aResult = NS_NewAtom(aString).take();
 
   if (!*aResult)
     return NS_ERROR_OUT_OF_MEMORY;
   
   return NS_OK;
 }
 
 nsresult
@@ -32,17 +32,17 @@ nsAtomService::GetPermanentAtom(const ns
     return NS_ERROR_OUT_OF_MEMORY;
   
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsAtomService::GetAtomUTF8(const char *aValue, nsIAtom* *aResult)
 {
-    *aResult = NS_NewAtom(aValue).get();
+    *aResult = NS_NewAtom(aValue).take();
 
     if (!*aResult)
         return NS_ERROR_OUT_OF_MEMORY;
 
     return NS_OK;
 }
 
 NS_IMETHODIMP
--- a/xpcom/glue/nsCOMPtr.h
+++ b/xpcom/glue/nsCOMPtr.h
@@ -151,17 +151,17 @@ struct already_AddRefed
     }
 
     already_AddRefed( T* aRawPtr )
       : mRawPtr(aRawPtr)
     {
       // nothing else to do here
     }
 
-    T* get() const { return mRawPtr; }
+    T* take() const { return mRawPtr; }
 
     /**
      * This helper is useful in cases like
      *
      *  already_AddRefed<BaseClass>
      *  Foo()
      *  {
      *    nsRefPtr<SubClass> x = ...;
--- a/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp
+++ b/xpcom/reflect/xptinfo/src/xptiInterfaceInfo.cpp
@@ -309,17 +309,17 @@ xptiInterfaceEntry::GetInfoForParam(uint
                                     const nsXPTParamInfo *param,
                                     nsIInterfaceInfo** info)
 {
     xptiInterfaceEntry* entry;
     nsresult rv = GetEntryForParam(methodIndex, param, &entry);
     if(NS_FAILED(rv))
         return rv;
 
-    *info = entry->InterfaceInfo().get();
+    *info = entry->InterfaceInfo().take();
 
     return NS_OK;
 }
 
 nsresult
 xptiInterfaceEntry::GetIIDForParam(uint16_t methodIndex,
                                    const nsXPTParamInfo* param, nsIID** iid)
 {
@@ -565,17 +565,17 @@ xptiInterfaceInfo::BuildParent()
 {
     mozilla::ReentrantMonitorAutoEnter monitor(XPTInterfaceInfoManager::GetSingleton()->
                                     mWorkingSet.mTableReentrantMonitor);
     NS_ASSERTION(mEntry && 
                  mEntry->IsFullyResolved() && 
                  !mParent &&
                  mEntry->Parent(),
                 "bad BuildParent call");
-    mParent = mEntry->Parent()->InterfaceInfo().get();
+    mParent = mEntry->Parent()->InterfaceInfo().take();
     return true;
 }
 
 /***************************************************************************/
 
 NS_IMPL_QUERY_INTERFACE1(xptiInterfaceInfo, nsIInterfaceInfo)
 
 xptiInterfaceInfo::xptiInterfaceInfo(xptiInterfaceEntry* entry)
--- a/xpcom/string/src/nsTSubstring.cpp
+++ b/xpcom/string/src/nsTSubstring.cpp
@@ -125,17 +125,18 @@ nsTSubstring_CharT::MutatePrep( size_typ
         newDataFlags = F_TERMINATED | F_FIXED;
       }
     else
       {
         // if we reach here then, we must allocate a new buffer.  we cannot
         // make use of our F_OWNED or F_FIXED buffers because they are not
         // large enough.
 
-        nsStringBuffer* newHdr = nsStringBuffer::Alloc(storageSize).get();
+        nsStringBuffer* newHdr =
+          nsStringBuffer::Alloc(storageSize).take();
         if (!newHdr)
           return false; // we are still in a consistent state
 
         newData = (char_type*) newHdr->Data();
         newDataFlags = F_TERMINATED | F_SHARED;
       }
 
     // save old data and flags