Bug 363214 grabFocus to document frame doesn't remove focus from text entry

patch by Nian.Liu at sun.com r=aaronleventhal
This commit is contained in:
ginn.chen%sun.com 2007-01-10 06:32:15 +00:00
parent bd884ad4e0
commit 9d32decf77
2 changed files with 18 additions and 0 deletions

View File

@ -67,6 +67,7 @@
#include "nsUnicharUtils.h"
#include "nsIURI.h"
#include "nsIWebNavigation.h"
#include "nsIFocusController.h"
#ifdef MOZ_XUL
#include "nsIXULDocument.h"
#endif
@ -243,6 +244,22 @@ NS_IMETHODIMP nsDocAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
return accService->GetAccessibleFor(gLastFocusedNode, aFocusedChild);
}
NS_IMETHODIMP nsDocAccessible::TakeFocus()
{
nsCOMPtr<nsIDOMWindow> domWin;
GetWindow(getter_AddRefs(domWin));
nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(domWin));
NS_ENSURE_TRUE(privateDOMWindow, NS_ERROR_FAILURE);
nsIFocusController *focusController =
privateDOMWindow->GetRootFocusController();
if (focusController) {
nsCOMPtr<nsIDOMElement> ele(do_QueryInterface(mDOMNode));
focusController->SetFocusedElement(ele);
return NS_OK;
}
return NS_ERROR_FAILURE;
}
// ------- nsIAccessibleDocument Methods (5) ---------------
NS_IMETHODIMP nsDocAccessible::GetURL(nsAString& aURL)

View File

@ -80,6 +80,7 @@ class nsDocAccessible : public nsHyperTextAccessible,
NS_IMETHOD GetState(PRUint32 *aState);
NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild);
NS_IMETHOD GetParent(nsIAccessible **aParent);
NS_IMETHOD TakeFocus(void);
// ----- nsIScrollPositionListener ---------------------------
NS_IMETHOD ScrollPositionWillChange(nsIScrollableView *aView, nscoord aX, nscoord aY);