mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 363214. TakeFocus/grabFocus not working on document accessible. r=mats
This commit is contained in:
parent
bad0dbfdae
commit
bac12bc2af
@ -254,18 +254,27 @@ NS_IMETHODIMP nsDocAccessible::GetFocusedChild(nsIAccessible **aFocusedChild)
|
|||||||
|
|
||||||
NS_IMETHODIMP nsDocAccessible::TakeFocus()
|
NS_IMETHODIMP nsDocAccessible::TakeFocus()
|
||||||
{
|
{
|
||||||
nsCOMPtr<nsIDOMWindow> domWin;
|
NS_ENSURE_TRUE(mDocument, NS_ERROR_FAILURE);
|
||||||
GetWindow(getter_AddRefs(domWin));
|
PRUint32 state;
|
||||||
nsCOMPtr<nsPIDOMWindow> privateDOMWindow(do_QueryInterface(domWin));
|
GetState(&state, nsnull);
|
||||||
NS_ENSURE_TRUE(privateDOMWindow, NS_ERROR_FAILURE);
|
if (0 == (state & nsIAccessibleStates::STATE_FOCUSABLE)) {
|
||||||
nsIFocusController *focusController =
|
return NS_ERROR_FAILURE; // Not focusable
|
||||||
privateDOMWindow->GetRootFocusController();
|
|
||||||
if (focusController) {
|
|
||||||
nsCOMPtr<nsIDOMElement> ele(do_QueryInterface(mDOMNode));
|
|
||||||
focusController->SetFocusedElement(ele);
|
|
||||||
return NS_OK;
|
|
||||||
}
|
}
|
||||||
return NS_ERROR_FAILURE;
|
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> treeItem = GetDocShellTreeItemFor(mDOMNode);
|
||||||
|
nsCOMPtr<nsIDocShell> docShell = do_QueryInterface(treeItem);
|
||||||
|
NS_ENSURE_TRUE(docShell, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
nsCOMPtr<nsIPresShell> shell(GetPresShell());
|
||||||
|
nsIEventStateManager *esm = shell->GetPresContext()->EventStateManager();
|
||||||
|
NS_ENSURE_TRUE(esm, NS_ERROR_FAILURE);
|
||||||
|
|
||||||
|
// Focus the document
|
||||||
|
nsresult rv = docShell->SetHasFocus(PR_TRUE);
|
||||||
|
NS_ENSURE_SUCCESS(rv, rv);
|
||||||
|
|
||||||
|
// Clear out any existing focus state
|
||||||
|
return esm->SetContentState(nsnull, NS_EVENT_STATE_FOCUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
// ------- nsIAccessibleDocument Methods (5) ---------------
|
// ------- nsIAccessibleDocument Methods (5) ---------------
|
||||||
|
Loading…
Reference in New Issue
Block a user