Bug 304871. Hitting enter with screen reader active will not open new window links. r=timeless, sr=jst

This commit is contained in:
aaronleventhal%moonset.net 2005-08-17 17:22:16 +00:00
Родитель f5b950e45d
Коммит 1e7f8acc76
3 изменённых файлов: 28 добавлений и 28 удалений

Просмотреть файл

@ -2166,17 +2166,29 @@ void nsAccessible::DoCommandCallback(nsITimer *aTimer, void *aClosure)
{
NS_ASSERTION(gDoCommandTimer, "How did we get here if there was no gDoCommandTimer?");
NS_RELEASE(gDoCommandTimer);
gDoCommandTimer = nsnull;
nsIDOMNode *node = NS_REINTERPRET_CAST(nsIDOMNode*, aClosure);
nsCOMPtr<nsIDOMXULElement> xulElement(do_QueryInterface(node));
nsIContent *content = NS_REINTERPRET_CAST(nsIContent*, aClosure);
nsCOMPtr<nsIDOMXULElement> xulElement(do_QueryInterface(content));
if (xulElement) {
xulElement->Click();
}
else {
nsCOMPtr<nsIDOMHTMLInputElement> htmlElement(do_QueryInterface(node));
if (htmlElement)
htmlElement->Click();
nsIDocument *doc = content->GetDocument();
if (!doc) {
return;
}
nsIPresShell *presShell = doc->GetShellAt(0);
nsPIDOMWindow *outerWindow = doc->GetWindow();
if (presShell && outerWindow) {
nsAutoPopupStatePusher popupStatePusher(outerWindow, openAllowed);
nsMouseEvent clickEvent(PR_TRUE, NS_MOUSE_LEFT_CLICK, nsnull,
nsMouseEvent::eSynthesized);
nsEventStatus eventStatus = nsEventStatus_eIgnore;
content->HandleDOMEvent(presShell->GetPresContext(), &clickEvent, nsnull,
NS_EVENT_FLAG_INIT, &eventStatus);
}
}
}
@ -2188,9 +2200,12 @@ void nsAccessible::DoCommandCallback(nsITimer *aTimer, void *aClosure)
* nsXXXAccessible::DoAction, it will block AT-Tools(e.g. GOK) that invoke
* "action" of mozilla accessibles direclty.
*/
nsresult nsAccessible::DoCommand()
nsresult nsAccessible::DoCommand(nsIContent *aContent)
{
nsCOMPtr<nsIContent> content = aContent;
if (!content) {
content = do_QueryInterface(mDOMNode);
}
if (gDoCommandTimer) {
// Already have timer going for another command
NS_WARNING("Doubling up on do command timers doesn't work. This wasn't expected.");
@ -2204,7 +2219,7 @@ nsresult nsAccessible::DoCommand()
NS_ADDREF(gDoCommandTimer = timer);
return gDoCommandTimer->InitWithFuncCallback(DoCommandCallback,
(void*)mDOMNode, 0,
(void*)content, 0,
nsITimer::TYPE_ONE_SHOT);
}

Просмотреть файл

@ -185,7 +185,7 @@ protected:
// For accessibles that have actions
static void DoCommandCallback(nsITimer *aTimer, void *aClosure);
nsresult DoCommand();
nsresult DoCommand(nsIContent *aContent = nsnull);
// Data Members
nsCOMPtr<nsIAccessible> mParent;

Просмотреть файл

@ -88,12 +88,7 @@ NS_IMETHODIMP nsHTMLCheckboxAccessible::GetActionName(PRUint8 index, nsAString&
NS_IMETHODIMP nsHTMLCheckboxAccessible::DoAction(PRUint8 index)
{
if (index == 0) { // 0 is the magic value for default action
nsCOMPtr<nsIDOMHTMLInputElement> htmlCheckboxElement(do_QueryInterface(mDOMNode));
if (htmlCheckboxElement) {
htmlCheckboxElement->Click();
return NS_OK;
}
return NS_ERROR_FAILURE;
return DoCommand();
}
return NS_ERROR_INVALID_ARG;
}
@ -123,11 +118,7 @@ nsRadioButtonAccessible(aNode, aShell)
NS_IMETHODIMP nsHTMLRadioButtonAccessible::DoAction(PRUint8 index)
{
if (index == eAction_Click) {
nsCOMPtr<nsIDOMHTMLInputElement> element(do_QueryInterface(mDOMNode));
if (element) {
element->Click();
return NS_OK;
}
return DoCommand();
}
return NS_ERROR_INVALID_ARG;
}
@ -270,13 +261,7 @@ NS_IMETHODIMP nsHTML4ButtonAccessible::GetActionName(PRUint8 index, nsAString& _
NS_IMETHODIMP nsHTML4ButtonAccessible::DoAction(PRUint8 index)
{
if (index == 0) {
nsCOMPtr<nsIDOMNSHTMLButtonElement> buttonElement(do_QueryInterface(mDOMNode));
if ( buttonElement )
{
buttonElement->Click();
return NS_OK;
}
return NS_ERROR_FAILURE;
return DoCommand();
}
return NS_ERROR_INVALID_ARG;
}