Bug 1494745 part 4 - Make Loader::AddObserver void since it's infallible. r=bz
authorMats Palmgren <mats@mozilla.com>
Sun, 14 Oct 2018 18:12:23 +0200
changeset 496911 1ec0c8e82a3d11acae7dd7cfbc81fe0a9d1ef024
parent 496910 7fa23df410e43bab5f4c264b7095fc36eee44f35
child 496912 74198da29da55fc32fb6c7b102bda55d16058ae6
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 4 - Make Loader::AddObserver void since it's infallible. r=bz mObservers is a nsTObserverArray which is infallible, so no need to check the return value from AppendElementUnlessExists (which a later patch in this series will remove).
dom/xml/nsXMLContentSink.cpp
layout/style/Loader.cpp
layout/style/Loader.h
--- a/dom/xml/nsXMLContentSink.cpp
+++ b/dom/xml/nsXMLContentSink.cpp
@@ -314,18 +314,18 @@ nsXMLContentSink::DidBuildModel(bool aTe
 
     bool startLayout = true;
 
     if (mPrettyPrinting) {
       NS_ASSERTION(!mPendingSheetCount, "Shouldn't have pending sheets here!");
 
       // We're pretty-printing now.  See whether we should wait up on
       // stylesheet loads
-      if (mDocument->CSSLoader()->HasPendingLoads() &&
-          NS_SUCCEEDED(mDocument->CSSLoader()->AddObserver(this))) {
+      if (mDocument->CSSLoader()->HasPendingLoads()) {
+        mDocument->CSSLoader()->AddObserver(this);
         // wait for those sheets to load
         startLayout = false;
       }
     }
 
     if (startLayout) {
       StartLayout(false);
 
--- a/layout/style/Loader.cpp
+++ b/layout/style/Loader.cpp
@@ -2565,25 +2565,21 @@ Loader::HasPendingLoads()
 {
   return
     (mSheets && mSheets->mLoadingDatas.Count() != 0) ||
     (mSheets && mSheets->mPendingDatas.Count() != 0) ||
     mPostedEvents.Length() != 0 ||
     mDatasToNotifyOn != 0;
 }
 
-nsresult
+void
 Loader::AddObserver(nsICSSLoaderObserver* aObserver)
 {
   MOZ_ASSERT(aObserver, "Must have observer");
-  if (mObservers.AppendElementUnlessExists(aObserver)) {
-    return NS_OK;
-  }
-
-  return NS_ERROR_OUT_OF_MEMORY;
+  mObservers.AppendElementUnlessExists(aObserver);
 }
 
 void
 Loader::RemoveObserver(nsICSSLoaderObserver* aObserver)
 {
   mObservers.RemoveElement(aObserver);
 }
 
--- a/layout/style/Loader.h
+++ b/layout/style/Loader.h
@@ -424,17 +424,17 @@ public:
    * Add an observer to this loader.  The observer will be notified
    * for all loads that would have notified their own observers (even
    * if those loads don't have observers attached to them).
    * Load-specific observers will be notified before generic
    * observers.  The loader holds a reference to the observer.
    *
    * aObserver must not be null.
    */
-  nsresult AddObserver(nsICSSLoaderObserver* aObserver);
+  void AddObserver(nsICSSLoaderObserver* aObserver);
 
   /**
    * Remove an observer added via AddObserver.
    */
   void RemoveObserver(nsICSSLoaderObserver* aObserver);
 
   // These interfaces are public only for the benefit of static functions
   // within nsCSSLoader.cpp.