Bug 1494745 part 5 - Don't check the result from ns[Auto]TObserverArray insertions since they're infallible. r=bz
authorMats Palmgren <mats@mozilla.com>
Sun, 14 Oct 2018 18:12:23 +0200
changeset 496912 74198da29da55fc32fb6c7b102bda55d16058ae6
parent 496911 1ec0c8e82a3d11acae7dd7cfbc81fe0a9d1ef024
child 496913 2b7fce8c4f926662732fae0deaf857121810f1ab
push id9984
push userffxbld-merge
push dateMon, 15 Oct 2018 21:07:35 +0000
treeherdermozilla-beta@183d27ea8570 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1494745
milestone64.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1494745 part 5 - Don't check the result from ns[Auto]TObserverArray insertions since they're infallible. r=bz
docshell/base/nsDocShell.cpp
docshell/shistory/nsSHistory.cpp
dom/base/nsDocument.cpp
toolkit/components/places/History.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -1799,27 +1799,29 @@ nsDocShell::GetAffectPrivateSessionLifet
 NS_IMETHODIMP
 nsDocShell::AddWeakPrivacyTransitionObserver(
     nsIPrivacyTransitionObserver* aObserver)
 {
   nsWeakPtr weakObs = do_GetWeakReference(aObserver);
   if (!weakObs) {
     return NS_ERROR_NOT_AVAILABLE;
   }
-  return mPrivacyObservers.AppendElement(weakObs) ? NS_OK : NS_ERROR_FAILURE;
+  mPrivacyObservers.AppendElement(weakObs);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::AddWeakReflowObserver(nsIReflowObserver* aObserver)
 {
   nsWeakPtr weakObs = do_GetWeakReference(aObserver);
   if (!weakObs) {
     return NS_ERROR_FAILURE;
   }
-  return mReflowObservers.AppendElement(weakObs) ? NS_OK : NS_ERROR_FAILURE;
+  mReflowObservers.AppendElement(weakObs);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::RemoveWeakReflowObserver(nsIReflowObserver* aObserver)
 {
   nsWeakPtr obs = do_GetWeakReference(aObserver);
   return mReflowObservers.RemoveElement(obs) ? NS_OK : NS_ERROR_FAILURE;
 }
@@ -2510,17 +2512,18 @@ nsDocShell::GetCurrentDocChannel()
 
 NS_IMETHODIMP
 nsDocShell::AddWeakScrollObserver(nsIScrollObserver* aObserver)
 {
   nsWeakPtr weakObs = do_GetWeakReference(aObserver);
   if (!weakObs) {
     return NS_ERROR_FAILURE;
   }
-  return mScrollObservers.AppendElement(weakObs) ? NS_OK : NS_ERROR_FAILURE;
+  mScrollObservers.AppendElement(weakObs);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDocShell::RemoveWeakScrollObserver(nsIScrollObserver* aObserver)
 {
   nsWeakPtr obs = do_GetWeakReference(aObserver);
   return mScrollObservers.RemoveElement(obs) ? NS_OK : NS_ERROR_FAILURE;
 }
--- a/docshell/shistory/nsSHistory.cpp
+++ b/docshell/shistory/nsSHistory.cpp
@@ -777,18 +777,18 @@ nsSHistory::AddSHistoryListener(nsISHist
   // Check if the listener supports Weak Reference. This is a must.
   // This listener functionality is used by embedders and we want to
   // have the right ownership with who ever listens to SHistory
   nsWeakPtr listener = do_GetWeakReference(aListener);
   if (!listener) {
     return NS_ERROR_FAILURE;
   }
 
-  return mListeners.AppendElementUnlessExists(listener) ?
-    NS_OK : NS_ERROR_OUT_OF_MEMORY;
+  mListeners.AppendElementUnlessExists(listener);
+  return NS_OK;
 }
 
 NS_IMETHODIMP
 nsSHistory::RemoveSHistoryListener(nsISHistoryListener* aListener)
 {
   // Make sure the listener that wants to be removed is the
   // one we have in store.
   nsWeakPtr listener = do_GetWeakReference(aListener);
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -2095,19 +2095,17 @@ nsDocument::Init()
 
   // Force initialization.
   nsINode::nsSlots* slots = Slots();
 
   // Prepend self as mutation-observer whether we need it or not (some
   // subclasses currently do, other don't). This is because the code in
   // nsNodeUtils always notifies the first observer first, expecting the
   // first observer to be the document.
-  NS_ENSURE_TRUE(slots->mMutationObservers.PrependElementUnlessExists(static_cast<nsIMutationObserver*>(this)),
-                 NS_ERROR_OUT_OF_MEMORY);
-
+  slots->mMutationObservers.PrependElementUnlessExists(static_cast<nsIMutationObserver*>(this));
 
   mOnloadBlocker = new nsOnloadBlocker();
   mCSSLoader = new mozilla::css::Loader(this);
   // Assume we're not quirky, until we know otherwise
   mCSSLoader->SetCompatibilityMode(eCompatibility_FullStandards);
 
   mStyleImageLoader = new mozilla::css::ImageLoader(this);
 
--- a/toolkit/components/places/History.cpp
+++ b/toolkit/components/places/History.cpp
@@ -2311,21 +2311,17 @@ History::RegisterVisitedCallback(nsIURI*
   }
 
   // Sanity check that Links are not registered more than once for a given URI.
   // This will not catch a case where it is registered for two different URIs.
   NS_ASSERTION(!observers.Contains(aLink),
                "Already tracking this Link object!");
 
   // Start tracking our Link.
-  if (!observers.AppendElement(aLink)) {
-    // Curses - unregister and return failure.
-    (void)UnregisterVisitedCallback(aURI, aLink);
-    return NS_ERROR_OUT_OF_MEMORY;
-  }
+  observers.AppendElement(aLink);
 
   // If this link has already been visited, we cannot synchronously mark
   // ourselves as visited, so instead we fire a runnable into our docgroup,
   // which will handle it for us.
   if (key->mVisited) {
     DispatchNotifyVisited(aURI, GetLinkDocument(aLink));
   }