Bug 864166 - Part d: Outparamdel nsGlobalWindow::GetWebBrowserChrome; r=mounir
authorMs2ger <ms2ger@gmail.com>
Fri, 26 Apr 2013 08:51:04 +0200
changeset 140864 a6104e0e5a2c717fd3e36de8526d5ed6cedb7e56
parent 140863 5489465932a071384ce0987c965baf5dffbddcba
child 140878 6e51c05eee687645e1d6e2f1ac9a6652e518b563
child 140993 efc77de30962b6ad2213c08026f51e2f518efbac
push id2579
push userakeybl@mozilla.com
push dateMon, 24 Jun 2013 18:52:47 +0000
treeherdermozilla-beta@b69b7de8a05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmounir
bugs864166
milestone23.0a1
first release with
nightly linux32
a6104e0e5a2c / 23.0a1 / 20130426030834 / files
nightly linux64
a6104e0e5a2c / 23.0a1 / 20130426030834 / files
nightly mac
a6104e0e5a2c / 23.0a1 / 20130426030834 / files
nightly win32
a6104e0e5a2c / 23.0a1 / 20130426030834 / files
nightly win64
a6104e0e5a2c / 23.0a1 / 20130426030834 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 864166 - Part d: Outparamdel nsGlobalWindow::GetWebBrowserChrome; r=mounir
dom/base/nsBarProps.cpp
dom/base/nsGlobalWindow.cpp
dom/base/nsGlobalWindow.h
--- a/dom/base/nsBarProps.cpp
+++ b/dom/base/nsBarProps.cpp
@@ -89,19 +89,17 @@ nsBarProp::SetVisibleByFlag(bool aVisibl
 already_AddRefed<nsIWebBrowserChrome>
 nsBarProp::GetBrowserChrome()
 {
   // Check that the window is still alive.
   nsCOMPtr<nsIDOMWindow> domwin(do_QueryReferent(mDOMWindowWeakref));
   if (!domwin)
     return nullptr;
 
-  nsIWebBrowserChrome *browserChrome = nullptr;
-  mDOMWindow->GetWebBrowserChrome(&browserChrome);
-  return browserChrome;
+  return mDOMWindow->GetWebBrowserChrome();
 }
 
 //
 // MenubarProp class implementation
 //
 
 nsMenubarProp::nsMenubarProp(nsGlobalWindow *aWindow) 
   : nsBarProp(aWindow)
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -3887,19 +3887,18 @@ nsGlobalWindow::SetStatus(const nsAStrin
    * If caller is not chrome and dom.disable_window_status_change is true,
    * prevent propagating window.status to the UI by exiting early
    */
 
   if (!CanSetProperty("dom.disable_window_status_change")) {
     return NS_OK;
   }
 
-  nsCOMPtr<nsIWebBrowserChrome> browserChrome;
-  GetWebBrowserChrome(getter_AddRefs(browserChrome));
-  if(browserChrome) {
+  nsCOMPtr<nsIWebBrowserChrome> browserChrome = GetWebBrowserChrome();
+  if (browserChrome) {
     browserChrome->SetStatus(nsIWebBrowserChrome::STATUS_SCRIPT,
                              PromiseFlatString(aStatus).get());
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
@@ -9764,18 +9763,17 @@ nsGlobalWindow::OpenInternal(const nsASt
   NS_PRECONDITION(!aJSCallerContext || !aCalledNoScript,
                   "Shouldn't have caller context when called noscript");
 
   // Calls to window.open from script should navigate.
   MOZ_ASSERT(aCalledNoScript || aNavigate);
 
   *aReturn = nullptr;
 
-  nsCOMPtr<nsIWebBrowserChrome> chrome;
-  GetWebBrowserChrome(getter_AddRefs(chrome));
+  nsCOMPtr<nsIWebBrowserChrome> chrome = GetWebBrowserChrome();
   if (!chrome) {
     // No chrome means we don't want to go through with this open call
     // -- see nsIWindowWatcher.idl
     return NS_ERROR_NOT_AVAILABLE;
   }
 
   NS_ASSERTION(mDocShell, "Must have docshell here");
 
@@ -10734,25 +10732,23 @@ nsGlobalWindow::GetTreeOwnerWindow()
   if (mDocShell) {
     mDocShell->GetTreeOwner(getter_AddRefs(treeOwner));
   }
 
   nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(treeOwner);
   return baseWindow.forget();
 }
 
-nsresult
-nsGlobalWindow::GetWebBrowserChrome(nsIWebBrowserChrome **aBrowserChrome)
+already_AddRefed<nsIWebBrowserChrome>
+nsGlobalWindow::GetWebBrowserChrome()
 {
   nsCOMPtr<nsIDocShellTreeOwner> treeOwner = GetTreeOwner();
 
-  nsCOMPtr<nsIWebBrowserChrome> browserChrome(do_GetInterface(treeOwner));
-  NS_IF_ADDREF(*aBrowserChrome = browserChrome);
-
-  return NS_OK;
+  nsCOMPtr<nsIWebBrowserChrome> browserChrome = do_GetInterface(treeOwner);
+  return browserChrome.forget();
 }
 
 nsIScrollableFrame *
 nsGlobalWindow::GetScrollFrame()
 {
   FORWARD_TO_OUTER(GetScrollFrame, (), nullptr);
 
   if (!mDocShell) {
--- a/dom/base/nsGlobalWindow.h
+++ b/dom/base/nsGlobalWindow.h
@@ -886,17 +886,17 @@ protected:
   // Insert aTimeout into the list, before all timeouts that would
   // fire after it, but no earlier than mTimeoutInsertionPoint, if any.
   void InsertTimeoutIntoList(nsTimeout *aTimeout);
   static void TimerCallback(nsITimer *aTimer, void *aClosure);
 
   // Helper Functions
   already_AddRefed<nsIDocShellTreeOwner> GetTreeOwner();
   already_AddRefed<nsIBaseWindow> GetTreeOwnerWindow();
-  nsresult GetWebBrowserChrome(nsIWebBrowserChrome** aBrowserChrome);
+  already_AddRefed<nsIWebBrowserChrome> GetWebBrowserChrome();
   nsresult SecurityCheckURL(const char *aURL);
   nsresult BuildURIfromBase(const char *aURL,
                             nsIURI **aBuiltURI,
                             bool *aFreeSecurityPass, JSContext **aCXused);
   bool PopupWhitelisted();
   PopupControlState RevisePopupAbuseLevel(PopupControlState);
   void     FireAbuseEvents(bool aBlocked, bool aWindow,
                            const nsAString &aPopupURL,