Bug 1342303 part 5 - Remove nsCOMArray::EnumerateForwards uses in xpfe. r=erahm
authorXidorn Quan <me@upsuper.org>
Fri, 24 Feb 2017 22:01:42 +1100
changeset 392355 2d861e4e01ef372c9ae1bdabf379c8658a79a4f2
parent 392354 a6b68a941e559399a8b39671099d8cdcbc379d4b
child 392356 6e4c4e2e714794f73b06633ac42cf2a90da1d4c8
push id7198
push userjlorenzo@mozilla.com
push dateTue, 18 Apr 2017 12:07:49 +0000
treeherdermozilla-beta@d57aa49c3948 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerserahm
bugs1342303
milestone54.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 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;
-}