From 22f84df25cb6269c60f2c10cb2fb1a790571be5e Mon Sep 17 00:00:00 2001 From: "aaronl%netscape.com" Date: Fri, 21 Jun 2002 04:41:28 +0000 Subject: [PATCH] Bug 152425. Active accessibility: correct use of STATE_FOCUSABLE for XUL tabs. r=jgaunt, sr=kyle --- accessible/src/xul/nsXULTabAccessible.cpp | 25 +++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/accessible/src/xul/nsXULTabAccessible.cpp b/accessible/src/xul/nsXULTabAccessible.cpp index ae6ca64449a..b8cdda4e9bb 100644 --- a/accessible/src/xul/nsXULTabAccessible.cpp +++ b/accessible/src/xul/nsXULTabAccessible.cpp @@ -41,6 +41,8 @@ #include "nsXULTabAccessible.h" #include "nsIDOMXULSelectCntrlEl.h" #include "nsIDOMXULSelectCntrlItemEl.h" +#include "nsIFrame.h" +#include "nsIStyleContext.h" /** * XUL Tab @@ -87,7 +89,7 @@ NS_IMETHODIMP nsXULTabAccessible::AccDoAction(PRUint8 index) nsCOMPtr tab(do_QueryInterface(mDOMNode)); if ( tab ) { - tab->DoCommand(); + tab->Click(); return NS_OK; } return NS_ERROR_FAILURE; @@ -109,7 +111,23 @@ NS_IMETHODIMP nsXULTabAccessible::GetAccState(PRUint32 *_retval) { // get focus and disable status from base class nsLeafAccessible::GetAccState(_retval); - *_retval |= STATE_FOCUSABLE; + + // In the past, tabs have been focusable in classic theme + // They may be again in the future + // Check style for -moz-user-focus: normal to see if it's focusable + *_retval &= ~STATE_FOCUSABLE; + nsCOMPtr content(do_QueryInterface(mDOMNode)); + nsCOMPtr presShell(do_QueryReferent(mPresShell)); + if (presShell && content) { + nsIFrame *frame = nsnull; + const nsStyleUserInterface* ui; + presShell->GetPrimaryFrameFor(content, &frame); + if (frame) { + frame->GetStyleData(eStyleStruct_UserInterface, ((const nsStyleStruct*&)ui)); + if (ui->mUserFocus == NS_STYLE_USER_FOCUS_NORMAL) + *_retval |= STATE_FOCUSABLE; + } + } return NS_OK; } @@ -173,13 +191,12 @@ NS_IMETHODIMP nsXULTabPanelsAccessible::GetAccRole(PRUint32 *_retval) } /** - * Possible values: focused, focusable, unavailable + * Possible values: unavailable */ NS_IMETHODIMP nsXULTabPanelsAccessible::GetAccState(PRUint32 *_retval) { // get focus and disable status from base class -- skip container because we have state nsAccessible::GetAccState(_retval); - *_retval |= STATE_FOCUSABLE; return NS_OK; }