Bug 1562292: Part 2b - Remove unused nsPIWindowWatcher::FindItemWithName method. r=nika
authorKris Maglione <maglione.k@gmail.com>
Fri, 28 Jun 2019 12:32:49 -0700
changeset 488067 ce60426d7e3152c92c9df31e1657bee4dc928d1b
parent 488066 40b61344f0da14f9700a75a8a1c67458e440b68a
child 488068 b47a29dc541a8cefda7c14274581e9c868944400
push id36435
push usercbrindusan@mozilla.com
push dateThu, 15 Aug 2019 09:46:49 +0000
treeherdermozilla-central@0db07ff50ab5 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnika
bugs1562292
milestone70.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 1562292: Part 2b - Remove unused nsPIWindowWatcher::FindItemWithName method. r=nika Differential Revision: https://phabricator.services.mozilla.com/D40499
toolkit/components/windowwatcher/nsPIWindowWatcher.idl
toolkit/components/windowwatcher/nsWindowWatcher.cpp
--- a/toolkit/components/windowwatcher/nsPIWindowWatcher.idl
+++ b/toolkit/components/windowwatcher/nsPIWindowWatcher.idl
@@ -118,33 +118,10 @@ interface nsPIWindowWatcher : nsISupport
    *         window.
    */
   nsIRemoteTab openWindowWithRemoteTab(in nsIRemoteTab aOpeningTab,
                                        in ACString aFeatures,
                                        in boolean aCalledFromJS,
                                        in float aOpenerFullZoom,
                                        in unsigned long long aNextRemoteTabId,
                                        in boolean aForceNoOpener);
-
-  /**
-   * Find a named docshell tree item amongst all windows registered
-   * with the window watcher.  This may be a subframe in some window,
-   * for example.
-   *
-   * @param aName the name of the window.  Must not be null.
-   * @param aRequestor the tree item immediately making the request.
-   *        We should make sure to not recurse down into its findItemWithName
-   *        method.
-   * @param aOriginalRequestor the original treeitem that made the request.
-   *        Used for security checks.
-   * @return the tree item with aName as the name, or null if there
-   *         isn't one.  "Special" names, like _self, _top, etc, will be
-   *         treated specially only if aRequestor is null; in that case they
-   *         will be resolved relative to the first window the windowwatcher
-   *         knows about.
-   * @see findItemWithName methods on nsIDocShellTreeItem and
-   *      nsIDocShellTreeOwner
-   */
-  nsIDocShellTreeItem findItemWithName(in AString aName,
-                                       in nsIDocShellTreeItem aRequestor,
-                                       in nsIDocShellTreeItem aOriginalRequestor);
 };
 
--- a/toolkit/components/windowwatcher/nsWindowWatcher.cpp
+++ b/toolkit/components/windowwatcher/nsWindowWatcher.cpp
@@ -1941,57 +1941,34 @@ int32_t nsWindowWatcher::WinHasOption(co
     if (found || !comma) {
       break;
     }
     options = comma + 1;
   }
   return found;
 }
 
-/* try to find an nsIDocShellTreeItem with the given name in any
-   known open window. a failure to find the item will not
-   necessarily return a failure method value. check aFoundItem.
-*/
-NS_IMETHODIMP
-nsWindowWatcher::FindItemWithName(const nsAString& aName,
-                                  nsIDocShellTreeItem* aRequestor,
-                                  nsIDocShellTreeItem* aOriginalRequestor,
-                                  nsIDocShellTreeItem** aFoundItem) {
-  *aFoundItem = nullptr;
-  if (aName.IsEmpty()) {
-    return NS_OK;
-  }
-
-  if (aName.LowerCaseEqualsLiteral("_blank") ||
-      aName.LowerCaseEqualsLiteral("_top") ||
-      aName.LowerCaseEqualsLiteral("_parent") ||
-      aName.LowerCaseEqualsLiteral("_self")) {
-    return NS_OK;
-  }
-
-  // If we are looking for an item and we don't have a docshell we are checking
-  // on, let's just look in the chrome tab group!
-  return TabGroup::GetChromeTabGroup()->FindItemWithName(
-      aName, aRequestor, aOriginalRequestor, aFoundItem);
-}
-
 already_AddRefed<nsIDocShellTreeItem> nsWindowWatcher::GetCallerTreeItem(
     nsIDocShellTreeItem* aParentItem) {
   nsCOMPtr<nsIWebNavigation> callerWebNav = do_GetInterface(GetEntryGlobal());
   nsCOMPtr<nsIDocShellTreeItem> callerItem = do_QueryInterface(callerWebNav);
   if (!callerItem) {
     callerItem = aParentItem;
   }
 
   return callerItem.forget();
 }
 
 nsPIDOMWindowOuter* nsWindowWatcher::SafeGetWindowByName(
     const nsAString& aName, bool aForceNoOpener,
     mozIDOMWindowProxy* aCurrentWindow) {
+  if (aName.IsEmpty()) {
+    return nullptr;
+  }
+
   if (aForceNoOpener) {
     if (!aName.LowerCaseEqualsLiteral("_self") &&
         !aName.LowerCaseEqualsLiteral("_top") &&
         !aName.LowerCaseEqualsLiteral("_parent")) {
       // Ignore all other names in the noopener case.
       return nullptr;
     }
   }
@@ -2002,17 +1979,27 @@ nsPIDOMWindowOuter* nsWindowWatcher::Saf
   nsCOMPtr<nsIDocShellTreeItem> callerItem = GetCallerTreeItem(startItem);
 
   nsCOMPtr<nsIDocShellTreeItem> foundItem;
   if (startItem) {
     startItem->FindItemWithName(aName, nullptr, callerItem,
                                 /* aSkipTabGroup = */ false,
                                 getter_AddRefs(foundItem));
   } else {
-    FindItemWithName(aName, nullptr, callerItem, getter_AddRefs(foundItem));
+    if (aName.LowerCaseEqualsLiteral("_blank") ||
+        aName.LowerCaseEqualsLiteral("_top") ||
+        aName.LowerCaseEqualsLiteral("_parent") ||
+        aName.LowerCaseEqualsLiteral("_self")) {
+      return nullptr;
+    }
+
+    // If we are looking for an item and we don't have a docshell we are
+    // checking on, let's just look in the chrome tab group!
+    Unused << TabGroup::GetChromeTabGroup()->FindItemWithName(
+        aName, nullptr, callerItem, getter_AddRefs(foundItem));
   }
 
   return foundItem ? foundItem->GetWindow() : nullptr;
 }
 
 /* Fetch the nsIDOMWindow corresponding to the given nsIDocShellTreeItem.
    This forces the creation of a script context, if one has not already
    been created. Note it also sets the window's opener to the parent,