Bug 700741 - Add and implement nsIFocusManager.elementIsFocusable r=Enn
authorEitan Isaacson <eitan@monotonous.org>
Thu, 10 Nov 2011 08:20:47 -0800
changeset 80152 0b200d3bd4082e97ed9c0cf7415400b34a5dce7b
parent 80151 f18be484cb5abd0b20abdd846b4448c9b5a52dc5
child 80153 d4bd0f9bece82af8a3026e35bb5676ea7c2d9fb5
push id323
push userrcampbell@mozilla.com
push dateTue, 15 Nov 2011 21:58:36 +0000
treeherderfx-team@3ea216303184 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEnn
bugs700741
milestone11.0a1
Bug 700741 - Add and implement nsIFocusManager.elementIsFocusable r=Enn
dom/base/nsFocusManager.cpp
dom/interfaces/base/nsIFocusManager.idl
--- a/dom/base/nsFocusManager.cpp
+++ b/dom/base/nsFocusManager.cpp
@@ -461,16 +461,29 @@ nsFocusManager::SetFocus(nsIDOMElement* 
   NS_ENSURE_ARG(newFocus);
 
   SetFocusInner(newFocus, aFlags, true, true);
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
+nsFocusManager::ElementIsFocusable(nsIDOMElement* aElement, PRUint32 aFlags,
+                                   bool* aIsFocusable)
+{
+  NS_ENSURE_TRUE(aElement, NS_ERROR_INVALID_ARG);
+
+  nsCOMPtr<nsIContent> aContent = do_QueryInterface(aElement);
+
+  *aIsFocusable = CheckIfFocusable(aContent, aFlags) != nsnull;
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsFocusManager::MoveFocus(nsIDOMWindow* aWindow, nsIDOMElement* aStartElement,
                           PRUint32 aType, PRUint32 aFlags, nsIDOMElement** aElement)
 {
   *aElement = nsnull;
 
 #ifdef DEBUG_FOCUS
   printf("<<MoveFocus Type: %d Flags: %x>>\n<<", aType, aFlags);
 
--- a/dom/interfaces/base/nsIFocusManager.idl
+++ b/dom/interfaces/base/nsIFocusManager.idl
@@ -161,16 +161,21 @@ interface nsIFocusManager : nsISupports
   nsIDOMElement getFocusedElementForWindow(in nsIDOMWindow aWindow, in boolean aDeep,
                                            out nsIDOMWindow aFocusedWindow);
 
   /**
    * Moves the selection caret within aWindow to the current focus.
    */
   void moveCaretToFocus(in nsIDOMWindow aWindow);
 
+  /***
+   * Check if given element is focusable.
+   */
+  boolean elementIsFocusable(in nsIDOMElement aElement, in unsigned long aFlags);
+
   /*
    * Raise the window when switching focus
    */
   const unsigned long FLAG_RAISE = 1;
 
   /**
    * Do not scroll the element to focus into view
    */