Bug 1437362 - Remove nsIDOMWindowUtils.focus. r?bz
Replace the one use of it with element.focus().
MozReview-Commit-ID: 5qK6yfyuRoY
--- 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