Bug 1437362 - Remove nsIDOMWindowUtils.focus. r?bz draft
authorCameron McCormack <cam@mcc.id.au>
Sun, 11 Feb 2018 17:16:58 +0800
changeset 753627 08692185c476710c2bde4cd24c3ca3fa8948fd53
parent 752848 35dfa0882568c06f2d81b6749179815cd4f82886
child 753628 945e05c9ea77e89d215e7f7f10682a397e3f9ae9
push id98615
push userbmo:cam@mcc.id.au
push dateSun, 11 Feb 2018 11:44:00 +0000
reviewersbz
bugs1437362
milestone60.0a1
Bug 1437362 - Remove nsIDOMWindowUtils.focus. r?bz Replace the one use of it with element.focus(). MozReview-Commit-ID: 5qK6yfyuRoY
dom/base/nsDOMWindowUtils.cpp
dom/interfaces/base/nsIDOMWindowUtils.idl
layout/forms/test/test_bug348236.html
--- a/dom/base/nsDOMWindowUtils.cpp
+++ b/dom/base/nsDOMWindowUtils.cpp
@@ -1262,31 +1262,16 @@ nsDOMWindowUtils::GetWidgetForElement(ns
     if (frame)
       return frame->GetNearestWidget();
   }
 
   return nullptr;
 }
 
 NS_IMETHODIMP
-nsDOMWindowUtils::Focus(nsIDOMElement* aElement)
-{
-  nsCOMPtr<nsPIDOMWindowOuter> window = do_QueryReferent(mWindow);
-  nsIFocusManager* fm = nsFocusManager::GetFocusManager();
-  if (fm) {
-    if (aElement)
-      fm->SetFocus(aElement, 0);
-    else
-      fm->ClearFocus(window);
-  }
-
-  return NS_OK;
-}
-
-NS_IMETHODIMP
 nsDOMWindowUtils::GarbageCollect(nsICycleCollectorListener *aListener)
 {
   AUTO_PROFILER_LABEL("nsDOMWindowUtils::GarbageCollect", GC);
 
   nsJSContext::GarbageCollectNow(JS::gcreason::DOM_UTILS);
   nsJSContext::CycleCollectNow(aListener);
 
   return NS_OK;
--- a/dom/interfaces/base/nsIDOMWindowUtils.idl
+++ b/dom/interfaces/base/nsIDOMWindowUtils.idl
@@ -714,32 +714,16 @@ interface nsIDOMWindowUtils : nsISupport
    * different from the result of sendQueryContentEvent(QUERY_SELECTED_TEXT).
    * This result is computed by native API with transferable data. In other
    * words, when the OS treats the selection as plaintext, it treats current
    * selection as this result.
    */
   AString GetSelectionAsPlaintext();
 
   /**
-   * Focus the element aElement. The element should be in the same document
-   * that the window is displaying. Pass null to blur the element, if any,
-   * that currently has focus, and focus the document.
-   *
-   * Cannot be accessed from unprivileged context (not content-accessible)
-   * Will throw a DOM security error if called without chrome privileges.
-   *
-   * @param aElement the element to focus
-   *
-   * Do not use this method. Just use element.focus if available or
-   * nsIFocusManager::SetFocus instead.
-   *
-   */
-  void focus(in nsIDOMElement aElement);
-
-  /**
    * Force a garbage collection followed by a cycle collection.
    *
    * Will throw a DOM security error if called without chrome privileges in
    * non-debug builds. Available to all callers in debug builds.
    *
    * @param aListener listener that receives information about the CC graph
    *                  (see @mozilla.org/cycle-collector-logger;1 for a logger
    *                   component)
--- a/layout/forms/test/test_bug348236.html
+++ b/layout/forms/test/test_bug348236.html
@@ -40,17 +40,17 @@ addLoadEvent(function test() {
     var
         CI = SpecialPowers.Components.interfaces,
         WinUtils = SpecialPowers.getDOMWindowUtils(window),
         sec = netscape.security,
         eSelect = $("eSelect"),
         timeout = 0 // Choose a larger value like 500 ms if you want to see what's happening.
 
     function keypressOnSelect(key) {
-        WinUtils.focus(eSelect)
+        eSelect.focus();
         synthesizeKey(key.key, {code: key.code, altKey: key.altKey});
     }
 
     function testKey(key, keyString, functionToContinue) {
         var selectGotClick
         function clickListener() { selectGotClick = true }
         eSelect.selectedIndex = 0
         eSelect.onchangeCount = 0