Bug 1342303 part 5 - Remove nsCOMArray::EnumerateForwards uses in xpfe. r=erahm
☠☠ backed out by b0b40ce3dfe5 ☠ ☠
authorXidorn Quan <me@upsuper.org>
Fri, 24 Feb 2017 22:01:42 +1100
changeset 374709 20a1bcb47c33f96691fabd451bc54db13d3c7e26
parent 374708 bc3b2e7a383b6b0ee08363d642ead4188ecc8a2d
child 374710 89137679a68cce70e8307b58e91cc9ade3f56b2c
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1342303
milestone54.0a1
Bug 1342303 part 5 - Remove nsCOMArray::EnumerateForwards uses in xpfe. r=erahm MozReview-Commit-ID: j8csvjSYUM
xpfe/appshell/nsWindowMediator.cpp
--- a/xpfe/appshell/nsWindowMediator.cpp
+++ b/xpfe/appshell/nsWindowMediator.cpp
@@ -22,26 +22,16 @@
 
 #include "nsIDocShell.h"
 #include "nsIInterfaceRequestor.h"
 #include "nsIInterfaceRequestorUtils.h"
 #include "nsIXULWindow.h"
 
 using namespace mozilla;
 
-static bool notifyOpenWindow(nsIWindowMediatorListener *aElement, void* aData);
-static bool notifyCloseWindow(nsIWindowMediatorListener *aElement, void* aData);
-static bool notifyWindowTitleChange(nsIWindowMediatorListener *aElement, void* aData);
-
-// for notifyWindowTitleChange
-struct WindowTitleData {
-  nsIXULWindow* mWindow;
-  const char16_t *mTitle;
-};
-
 nsresult
 nsWindowMediator::GetDOMWindow(nsIXULWindow* inWindow,
                                nsCOMPtr<nsPIDOMWindowOuter>& outDOMWindow)
 {
   nsCOMPtr<nsIDocShell> docShell;
 
   outDOMWindow = nullptr;
   inWindow->GetDocShell(getter_AddRefs(docShell));
@@ -86,19 +76,20 @@ NS_IMETHODIMP nsWindowMediator::Register
     return NS_ERROR_FAILURE;
   }
 
   mTimeStamp++;
 
   // Create window info struct and add to list of windows
   nsWindowInfo* windowInfo = new nsWindowInfo(inWindow, mTimeStamp);
 
-  WindowTitleData winData = { inWindow, nullptr };
-  mListeners.EnumerateForwards(notifyOpenWindow, &winData);
-  
+  for (nsIWindowMediatorListener* listener : mListeners) {
+    listener->OnOpenWindow(inWindow);
+  }
+
   if (mOldestWindow)
     windowInfo->InsertAfter(mOldestWindow->mOlder, nullptr);
   else
     mOldestWindow = windowInfo;
 
   return NS_OK;
 }
 
@@ -118,18 +109,19 @@ nsWindowMediator::UnregisterWindow(nsWin
 {
   // Inform the iterators
   uint32_t index = 0;
   while (index < mEnumeratorList.Length()) {
     mEnumeratorList[index]->WindowRemoved(inInfo);
     index++;
   }
   
-  WindowTitleData winData = { inInfo->mWindow.get(), nullptr };
-  mListeners.EnumerateForwards(notifyCloseWindow, &winData);
+  for (nsIWindowMediatorListener* listener : mListeners) {
+    listener->OnCloseWindow(inInfo->mWindow.get());
+  }
 
   // Remove from the lists and free up 
   if (inInfo == mOldestWindow)
     mOldestWindow = inInfo->mYounger;
   if (inInfo == mTopmostWindow)
     mTopmostWindow = inInfo->mLower;
   inInfo->Unlink(true, true);
   if (inInfo == mOldestWindow)
@@ -402,18 +394,19 @@ nsWindowMediator::UpdateWindowTimeStamp(
 
 NS_IMETHODIMP
 nsWindowMediator::UpdateWindowTitle(nsIXULWindow* inWindow,
                                     const char16_t* inTitle)
 {
   MOZ_RELEASE_ASSERT(NS_IsMainThread());
   NS_ENSURE_STATE(mReady);
   if (GetInfoFor(inWindow)) {
-    WindowTitleData winData = { inWindow, inTitle };
-    mListeners.EnumerateForwards(notifyWindowTitleChange, &winData);
+    for (nsIWindowMediatorListener* listener : mListeners) {
+      listener->OnWindowTitleChange(inWindow, inTitle);
+    }
   }
 
   return NS_OK;
 }
 
 /* This method's plan is to intervene only when absolutely necessary.
    We will get requests to place our windows behind unknown windows.
    For the most part, we need to leave those alone (turning them into
@@ -812,35 +805,8 @@ nsWindowMediator::Observe(nsISupports* a
   if (!strcmp(aTopic, "xpcom-shutdown") && mReady) {
     MOZ_RELEASE_ASSERT(NS_IsMainThread());
     while (mOldestWindow)
       UnregisterWindow(mOldestWindow);
     mReady = false;
   }
   return NS_OK;
 }
-
-bool
-notifyOpenWindow(nsIWindowMediatorListener *aListener, void* aData)
-{
-  WindowTitleData* winData = static_cast<WindowTitleData*>(aData);
-  aListener->OnOpenWindow(winData->mWindow);
-
-  return true;
-}
-
-bool
-notifyCloseWindow(nsIWindowMediatorListener *aListener, void* aData)
-{
-  WindowTitleData* winData = static_cast<WindowTitleData*>(aData);
-  aListener->OnCloseWindow(winData->mWindow);
-
-  return true;
-}
-
-bool 
-notifyWindowTitleChange(nsIWindowMediatorListener *aListener, void* aData)
-{
-  WindowTitleData* titleData = reinterpret_cast<WindowTitleData*>(aData);
-  aListener->OnWindowTitleChange(titleData->mWindow, titleData->mTitle);
-
-  return true;
-}