2001-10-09 21:52:36 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
2004-04-17 21:52:36 +00:00
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
2001-10-09 21:52:36 +00:00
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
2001-10-09 21:52:36 +00:00
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is mozilla.org code.
|
|
|
|
*
|
2004-04-17 21:52:36 +00:00
|
|
|
* The Initial Developer of the Original Code is
|
2001-10-09 21:52:36 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2002-11-06 01:29:58 +00:00
|
|
|
* Aaron Leventhal (aaronl@netscape.com)
|
|
|
|
* Kyle Yuan (kyle.yuan@sun.com)
|
2001-10-09 21:52:36 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
2004-04-17 21:52:36 +00:00
|
|
|
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
|
|
|
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
2001-10-09 21:52:36 +00:00
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
2004-04-17 21:52:36 +00:00
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
2001-10-09 21:52:36 +00:00
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
2004-04-17 21:52:36 +00:00
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
2001-10-09 21:52:36 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
// NOTE: alphabetically ordered
|
2003-04-15 08:45:55 +00:00
|
|
|
#include "nsXULFormControlAccessible.h"
|
2004-06-02 05:32:45 +00:00
|
|
|
#include "nsHTMLFormControlAccessible.h"
|
2005-03-14 23:10:53 +00:00
|
|
|
#include "nsAccessibilityAtoms.h"
|
|
|
|
#include "nsAccessibleTreeWalker.h"
|
2004-06-02 04:06:28 +00:00
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2001-10-09 21:52:36 +00:00
|
|
|
#include "nsIDOMXULButtonElement.h"
|
|
|
|
#include "nsIDOMXULCheckboxElement.h"
|
2002-01-11 03:48:02 +00:00
|
|
|
#include "nsIDOMXULMenuListElement.h"
|
2001-11-07 00:12:16 +00:00
|
|
|
#include "nsIDOMXULSelectCntrlItemEl.h"
|
2004-06-02 05:32:45 +00:00
|
|
|
#include "nsIDOMXULTextboxElement.h"
|
2005-03-14 23:10:53 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
2001-10-09 21:52:36 +00:00
|
|
|
|
|
|
|
/**
|
2001-11-07 00:12:16 +00:00
|
|
|
* XUL Button: can contain arbitrary HTML content
|
2001-10-09 21:52:36 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2001-11-07 00:12:16 +00:00
|
|
|
* Default Constructor
|
2001-10-09 21:52:36 +00:00
|
|
|
*/
|
2002-01-09 10:02:29 +00:00
|
|
|
|
|
|
|
// Don't inherit from nsFormControlAccessible - it doesn't allow children and a button can have a dropmarker child
|
2001-10-09 21:52:36 +00:00
|
|
|
nsXULButtonAccessible::nsXULButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
2003-04-01 20:02:51 +00:00
|
|
|
nsAccessibleWrap(aNode, aShell)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* Only one actions available
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULButtonAccessible::GetNumActions(PRUint8 *_retval)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2001-11-07 00:12:16 +00:00
|
|
|
*_retval = eSingle_Action;
|
2001-10-09 21:52:36 +00:00
|
|
|
return NS_OK;;
|
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* Return the name of our only action
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULButtonAccessible::GetActionName(PRUint8 index, nsAString& _retval)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2001-11-07 00:12:16 +00:00
|
|
|
if (index == eAction_Click) {
|
2002-01-12 00:23:06 +00:00
|
|
|
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("press"), _retval);
|
2001-10-09 21:52:36 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* Tell the button to do it's action
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULButtonAccessible::DoAction(PRUint8 index)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
|
|
|
if (index == 0) {
|
2005-02-01 09:40:36 +00:00
|
|
|
return DoCommand();
|
2001-10-09 21:52:36 +00:00
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* We are a pushbutton
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULButtonAccessible::GetRole(PRUint32 *_retval)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
|
|
|
*_retval = ROLE_PUSHBUTTON;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* Possible states: focused, focusable, unavailable(disabled)
|
|
|
|
*/
|
2005-04-02 01:00:20 +00:00
|
|
|
NS_IMETHODIMP nsXULButtonAccessible::GetState(PRUint32 *aState)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2001-11-07 00:12:16 +00:00
|
|
|
// get focus and disable status from base class
|
2005-04-02 01:00:20 +00:00
|
|
|
nsAccessible::GetState(aState);
|
2002-01-09 10:02:29 +00:00
|
|
|
|
|
|
|
PRBool disabled = PR_FALSE;
|
|
|
|
nsCOMPtr<nsIDOMXULControlElement> xulFormElement(do_QueryInterface(mDOMNode));
|
|
|
|
if (xulFormElement) {
|
|
|
|
xulFormElement->GetDisabled(&disabled);
|
|
|
|
if (disabled)
|
2005-04-02 01:00:20 +00:00
|
|
|
*aState |= STATE_UNAVAILABLE;
|
2002-01-09 10:02:29 +00:00
|
|
|
else
|
2005-04-02 01:00:20 +00:00
|
|
|
*aState |= STATE_FOCUSABLE;
|
2002-01-09 10:02:29 +00:00
|
|
|
}
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
|
|
|
|
// Buttons can be checked -- they simply appear pressed in rather than checked
|
|
|
|
nsCOMPtr<nsIDOMXULButtonElement> xulButtonElement(do_QueryInterface(mDOMNode));
|
|
|
|
if (xulButtonElement) {
|
|
|
|
PRBool checked = PR_FALSE;
|
|
|
|
PRInt32 checkState = 0;
|
|
|
|
xulButtonElement->GetChecked(&checked);
|
|
|
|
if (checked) {
|
2005-04-02 01:00:20 +00:00
|
|
|
*aState |= STATE_PRESSED;
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
xulButtonElement->GetCheckState(&checkState);
|
|
|
|
if (checkState == nsIDOMXULButtonElement::CHECKSTATE_MIXED)
|
2005-04-02 01:00:20 +00:00
|
|
|
*aState |= STATE_MIXED;
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-03-10 05:14:24 +00:00
|
|
|
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
|
|
|
|
NS_ASSERTION(element, "No nsIDOMElement for button node!");
|
2005-04-05 11:11:57 +00:00
|
|
|
if (element) {
|
|
|
|
PRBool isDefault = PR_FALSE;
|
|
|
|
element->HasAttribute(NS_LITERAL_STRING("default"), &isDefault) ;
|
|
|
|
if (isDefault)
|
|
|
|
*aState |= STATE_DEFAULT;
|
|
|
|
}
|
2005-04-02 01:00:20 +00:00
|
|
|
|
|
|
|
nsAutoString type;
|
|
|
|
element->GetAttribute(NS_LITERAL_STRING("type"), type);
|
|
|
|
if (type.EqualsLiteral("menu") || type.EqualsLiteral("menu-button")) {
|
|
|
|
*aState |= STATE_HASPOPUP;
|
|
|
|
}
|
2002-03-10 05:14:24 +00:00
|
|
|
|
2001-10-09 21:52:36 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2002-01-09 10:02:29 +00:00
|
|
|
/**
|
|
|
|
* Perhaps 1 child - if there's a <dropmarker>
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULButtonAccessible::GetFirstChild(nsIAccessible **aResult)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
2003-04-15 08:45:55 +00:00
|
|
|
if (!mFirstChild) {
|
|
|
|
nsAccessibleTreeWalker walker(mWeakShell, mDOMNode, PR_TRUE);
|
2004-06-25 20:27:29 +00:00
|
|
|
walker.GetFirstChild();
|
|
|
|
nsCOMPtr<nsIAccessible> dropMarkerAccessible;
|
|
|
|
while (walker.mState.accessible) {
|
|
|
|
dropMarkerAccessible = walker.mState.accessible;
|
|
|
|
walker.GetNextSibling();
|
|
|
|
}
|
2002-01-09 10:02:29 +00:00
|
|
|
|
2003-04-15 08:45:55 +00:00
|
|
|
// If the anonymous tree walker can find accessible children,
|
|
|
|
// and the last one is a push button, then use it as the only accessible
|
|
|
|
// child -- because this is the scenario where we have a dropmarker child
|
2002-01-09 10:02:29 +00:00
|
|
|
|
2004-06-25 20:27:29 +00:00
|
|
|
if (dropMarkerAccessible) {
|
2003-04-15 08:45:55 +00:00
|
|
|
PRUint32 role;
|
2004-06-25 20:27:29 +00:00
|
|
|
if (NS_SUCCEEDED(dropMarkerAccessible->GetRole(&role)) && role == ROLE_PUSHBUTTON) {
|
|
|
|
mFirstChild = dropMarkerAccessible;
|
|
|
|
nsCOMPtr<nsPIAccessible> privChildAcc = do_QueryInterface(dropMarkerAccessible);
|
2003-07-31 08:09:39 +00:00
|
|
|
privChildAcc->SetNextSibling(nsnull);
|
2003-04-15 08:45:55 +00:00
|
|
|
}
|
2002-01-09 10:02:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2003-04-15 08:45:55 +00:00
|
|
|
mAccChildCount = (mFirstChild != nsnull);
|
|
|
|
NS_IF_ADDREF(*aResult = mFirstChild);
|
2002-01-09 10:02:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULButtonAccessible::GetLastChild(nsIAccessible **aResult)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
2003-07-31 08:09:39 +00:00
|
|
|
return GetFirstChild(aResult);
|
2002-01-09 10:02:29 +00:00
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULButtonAccessible::GetChildCount(PRInt32 *aResult)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIAccessible> accessible;
|
2003-07-31 08:09:39 +00:00
|
|
|
GetFirstChild(getter_AddRefs(accessible));
|
2003-04-15 08:45:55 +00:00
|
|
|
*aResult = mAccChildCount;
|
2002-01-09 10:02:29 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* XUL Dropmarker: can contain arbitrary HTML content
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default Constructor
|
|
|
|
*/
|
|
|
|
nsXULDropmarkerAccessible::nsXULDropmarkerAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
|
|
|
nsFormControlAccessible(aNode, aShell)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Only one actions available
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULDropmarkerAccessible::GetNumActions(PRUint8 *aResult)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
|
|
|
*aResult = eSingle_Action;
|
|
|
|
return NS_OK;;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRBool nsXULDropmarkerAccessible::DropmarkerOpen(PRBool aToggleOpen)
|
|
|
|
{
|
|
|
|
PRBool isOpen = PR_FALSE;
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMNode> parentButtonNode;
|
|
|
|
mDOMNode->GetParentNode(getter_AddRefs(parentButtonNode));
|
|
|
|
nsCOMPtr<nsIDOMXULButtonElement> parentButtonElement(do_QueryInterface(parentButtonNode));
|
|
|
|
|
|
|
|
if (parentButtonElement) {
|
|
|
|
parentButtonElement->GetOpen(&isOpen);
|
|
|
|
if (aToggleOpen)
|
|
|
|
parentButtonElement->SetOpen(!isOpen);
|
|
|
|
}
|
2002-01-11 03:48:02 +00:00
|
|
|
else {
|
|
|
|
nsCOMPtr<nsIDOMXULMenuListElement> parentMenuListElement(do_QueryInterface(parentButtonNode));
|
|
|
|
if (parentMenuListElement) {
|
|
|
|
parentMenuListElement->GetOpen(&isOpen);
|
|
|
|
if (aToggleOpen)
|
|
|
|
parentMenuListElement->SetOpen(!isOpen);
|
|
|
|
}
|
|
|
|
}
|
2002-01-09 10:02:29 +00:00
|
|
|
|
|
|
|
return isOpen;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return the name of our only action
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULDropmarkerAccessible::GetActionName(PRUint8 index, nsAString& aResult)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
|
|
|
if (index == eAction_Click) {
|
|
|
|
if (DropmarkerOpen(PR_FALSE))
|
2004-06-17 00:13:25 +00:00
|
|
|
aResult.AssignLiteral("close");
|
2002-01-09 10:02:29 +00:00
|
|
|
else
|
2004-06-17 00:13:25 +00:00
|
|
|
aResult.AssignLiteral("open");
|
2002-01-09 10:02:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tell the Dropmarker to do it's action
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULDropmarkerAccessible::DoAction(PRUint8 index)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
|
|
|
if (index == eAction_Click) {
|
|
|
|
DropmarkerOpen(PR_TRUE); // Reverse the open attribute
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We are a pushbutton
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULDropmarkerAccessible::GetRole(PRUint32 *aResult)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
|
|
|
*aResult = ROLE_PUSHBUTTON;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULDropmarkerAccessible::GetState(PRUint32 *aResult)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
|
|
|
*aResult = 0;
|
|
|
|
|
|
|
|
if (DropmarkerOpen(PR_FALSE))
|
|
|
|
*aResult = STATE_PRESSED;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* XUL checkbox
|
|
|
|
*/
|
2001-10-09 21:52:36 +00:00
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* Default Constructor
|
|
|
|
*/
|
2001-10-09 21:52:36 +00:00
|
|
|
nsXULCheckboxAccessible::nsXULCheckboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
2001-11-07 00:12:16 +00:00
|
|
|
nsFormControlAccessible(aNode, aShell)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* We are a CheckButton
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULCheckboxAccessible::GetRole(PRUint32 *_retval)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
|
|
|
*_retval = ROLE_CHECKBUTTON;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* Only one action available
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULCheckboxAccessible::GetNumActions(PRUint8 *_retval)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2001-11-07 00:12:16 +00:00
|
|
|
*_retval = eSingle_Action;
|
2001-10-09 21:52:36 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* Return the name of our only action
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULCheckboxAccessible::GetActionName(PRUint8 index, nsAString& _retval)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2001-11-07 00:12:16 +00:00
|
|
|
if (index == eAction_Click) {
|
2001-10-09 21:52:36 +00:00
|
|
|
// check or uncheck
|
|
|
|
PRUint32 state;
|
2003-07-31 08:09:39 +00:00
|
|
|
GetState(&state);
|
2001-10-09 21:52:36 +00:00
|
|
|
|
|
|
|
if (state & STATE_CHECKED)
|
2004-06-17 00:13:25 +00:00
|
|
|
_retval.AssignLiteral("uncheck");
|
2001-10-09 21:52:36 +00:00
|
|
|
else
|
2004-06-17 00:13:25 +00:00
|
|
|
_retval.AssignLiteral("check");
|
2001-10-09 21:52:36 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* Tell the checkbox to do its only action -- check( or uncheck) itself
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULCheckboxAccessible::DoAction(PRUint8 index)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2001-11-07 00:12:16 +00:00
|
|
|
if (index == eAction_Click) {
|
2005-02-01 09:40:36 +00:00
|
|
|
return DoCommand();
|
2001-10-09 21:52:36 +00:00
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* Possible states: focused, focusable, unavailable(disabled), checked
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULCheckboxAccessible::GetState(PRUint32 *_retval)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2001-11-07 00:12:16 +00:00
|
|
|
// Get focus and disable status from base class
|
2003-07-31 08:09:39 +00:00
|
|
|
nsFormControlAccessible::GetState(_retval);
|
2001-10-09 21:52:36 +00:00
|
|
|
|
|
|
|
// Determine Checked state
|
|
|
|
nsCOMPtr<nsIDOMXULCheckboxElement> xulCheckboxElement(do_QueryInterface(mDOMNode));
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
if (xulCheckboxElement) {
|
|
|
|
PRBool checked = PR_FALSE;
|
|
|
|
xulCheckboxElement->GetChecked(&checked);
|
|
|
|
if (checked) {
|
|
|
|
*_retval |= STATE_CHECKED;
|
|
|
|
PRInt32 checkState = 0;
|
|
|
|
xulCheckboxElement->GetCheckState(&checkState);
|
|
|
|
if (checkState == nsIDOMXULCheckboxElement::CHECKSTATE_MIXED)
|
|
|
|
*_retval |= STATE_MIXED;
|
|
|
|
}
|
|
|
|
}
|
2001-10-09 21:52:36 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
/**
|
|
|
|
* XUL groupbox
|
|
|
|
*/
|
|
|
|
|
|
|
|
nsXULGroupboxAccessible::nsXULGroupboxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
2003-04-01 20:02:51 +00:00
|
|
|
nsAccessibleWrap(aNode, aShell)
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULGroupboxAccessible::GetRole(PRUint32 *_retval)
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
{
|
|
|
|
*_retval = ROLE_GROUPING;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULGroupboxAccessible::GetState(PRUint32 *_retval)
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
{
|
2005-01-19 07:10:38 +00:00
|
|
|
// Groupbox doesn't support focusable state!
|
|
|
|
nsAccessible::GetState(_retval);
|
|
|
|
*_retval &= ~STATE_FOCUSABLE;
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-06-01 14:03:38 +00:00
|
|
|
NS_IMETHODIMP nsXULGroupboxAccessible::GetName(nsAString& aName)
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
{
|
2005-06-01 14:03:38 +00:00
|
|
|
aName.Truncate(); // Default name is blank
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
|
2005-06-01 14:03:38 +00:00
|
|
|
if (mRoleMapEntry) {
|
|
|
|
nsAccessible::GetName(aName);
|
|
|
|
if (!aName.IsEmpty()) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
|
|
|
|
if (element) {
|
|
|
|
nsCOMPtr<nsIDOMNodeList> captions;
|
2004-05-04 20:14:58 +00:00
|
|
|
nsAutoString nameSpaceURI;
|
|
|
|
element->GetNamespaceURI(nameSpaceURI);
|
|
|
|
element->GetElementsByTagNameNS(nameSpaceURI, NS_LITERAL_STRING("caption"),
|
|
|
|
getter_AddRefs(captions));
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
if (captions) {
|
|
|
|
nsCOMPtr<nsIDOMNode> captionNode;
|
|
|
|
captions->Item(0, getter_AddRefs(captionNode));
|
|
|
|
if (captionNode) {
|
|
|
|
element = do_QueryInterface(captionNode);
|
|
|
|
NS_ASSERTION(element, "No nsIDOMElement for caption node!");
|
2005-06-01 14:03:38 +00:00
|
|
|
element->GetAttribute(NS_LITERAL_STRING("label"), aName) ;
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* progressmeter
|
|
|
|
*/
|
2003-04-22 07:38:18 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED0(nsXULProgressMeterAccessible, nsFormControlAccessible)
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
|
|
|
|
nsXULProgressMeterAccessible::nsXULProgressMeterAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
2002-06-14 01:47:32 +00:00
|
|
|
nsFormControlAccessible(aNode, aShell)
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULProgressMeterAccessible::GetRole(PRUint32 *_retval)
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
{
|
|
|
|
*_retval = ROLE_PROGRESSBAR;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* No states supported for progressmeter
|
|
|
|
*/
|
2005-04-04 15:48:06 +00:00
|
|
|
NS_IMETHODIMP nsXULProgressMeterAccessible::GetState(PRUint32 *aState)
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
{
|
2005-04-04 15:48:06 +00:00
|
|
|
nsresult rv = nsAccessible::GetState(aState);
|
|
|
|
*aState &= ~STATE_FOCUSABLE;
|
|
|
|
return rv;
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULProgressMeterAccessible::GetValue(nsAString& _retval)
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
{
|
|
|
|
nsCOMPtr<nsIDOMElement> element(do_QueryInterface(mDOMNode));
|
|
|
|
NS_ASSERTION(element, "No element for DOM node!");
|
|
|
|
element->GetAttribute(NS_LITERAL_STRING("value"), _retval);
|
2002-06-14 01:47:32 +00:00
|
|
|
if (!_retval.IsEmpty() && _retval.Last() != '%')
|
2004-06-17 00:13:25 +00:00
|
|
|
_retval.AppendLiteral("%");
|
Bug 109851, bug 108629, bug 109921, bug 109977, bug 109153, bug 109187, bug 109213, bug 109221. Check in latest XUL accessibility support - menus, <colorpicker>, <progressmeter>, <groupbox>, mixed states for checkboxes, buttons that can be 'checked' ie pressed down, fixes extra MSAA events being generated, couldn't see HTML content
2001-11-20 02:05:26 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2001-12-11 20:49:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* XUL Radio Button
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
nsXULRadioButtonAccessible::nsXULRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
|
|
|
nsRadioButtonAccessible(aNode, aShell)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Our only action is to click */
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULRadioButtonAccessible::DoAction(PRUint8 index)
|
2001-12-11 20:49:49 +00:00
|
|
|
{
|
|
|
|
if (index == eAction_Click) {
|
2005-02-01 09:40:36 +00:00
|
|
|
return DoCommand();
|
2001-12-11 20:49:49 +00:00
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** We are Focusable and can be Checked and focused */
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULRadioButtonAccessible::GetState(PRUint32 *_retval)
|
2001-12-11 20:49:49 +00:00
|
|
|
{
|
2003-07-31 08:09:39 +00:00
|
|
|
nsFormControlAccessible::GetState(_retval);
|
2001-12-11 20:49:49 +00:00
|
|
|
PRBool selected = PR_FALSE; // Radio buttons can be selected
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> radioButton(do_QueryInterface(mDOMNode));
|
2004-07-01 20:43:03 +00:00
|
|
|
if (radioButton) {
|
2001-12-11 20:49:49 +00:00
|
|
|
radioButton->GetSelected(&selected);
|
2004-07-01 20:43:03 +00:00
|
|
|
if (selected) {
|
|
|
|
*_retval |= STATE_CHECKED;
|
2002-06-21 04:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
2001-12-11 20:49:49 +00:00
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* XUL Radio Group
|
|
|
|
* The Radio Group proxies for the Radio Buttons themselves. The Group gets
|
|
|
|
* focus whereas the Buttons do not. So we only have an accessible object for
|
|
|
|
* this for the purpose of getting the proper RadioButton. Need this here to
|
|
|
|
* avoid circular reference problems when navigating the accessible tree and
|
|
|
|
* for getting to the radiobuttons.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
nsXULRadioGroupAccessible::nsXULRadioGroupAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
2003-04-01 20:02:51 +00:00
|
|
|
nsAccessibleWrap(aNode, aShell)
|
2001-12-11 20:49:49 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULRadioGroupAccessible::GetRole(PRUint32 *_retval)
|
2002-06-21 04:54:34 +00:00
|
|
|
{
|
|
|
|
*_retval = ROLE_GROUPING;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULRadioGroupAccessible::GetState(PRUint32 *_retval)
|
2002-06-21 04:54:34 +00:00
|
|
|
{
|
|
|
|
// The radio group is not focusable.
|
|
|
|
// Sometimes the focus controller will report that it is focused.
|
|
|
|
// That means that the actual selected radio button should be considered focused
|
2003-07-31 08:09:39 +00:00
|
|
|
nsAccessible::GetState(_retval);
|
2002-06-21 04:54:34 +00:00
|
|
|
*_retval &= ~(STATE_FOCUSABLE | STATE_FOCUSED);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2002-01-09 10:02:29 +00:00
|
|
|
/**
|
|
|
|
* XUL StatusBar: can contain arbitrary HTML content
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default Constructor
|
|
|
|
*/
|
|
|
|
nsXULStatusBarAccessible::nsXULStatusBarAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
2003-04-01 20:02:51 +00:00
|
|
|
nsAccessibleWrap(aNode, aShell)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* We are a statusbar
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULStatusBarAccessible::GetRole(PRUint32 *_retval)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
|
|
|
*_retval = ROLE_STATUSBAR;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULStatusBarAccessible::GetState(PRUint32 *_retval)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
2004-05-18 03:26:34 +00:00
|
|
|
return nsAccessible::GetState(_retval);
|
2002-01-09 10:02:29 +00:00
|
|
|
}
|
2002-11-06 01:29:58 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* XUL ToolBar
|
|
|
|
*/
|
|
|
|
|
|
|
|
nsXULToolbarAccessible::nsXULToolbarAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
2003-04-01 20:02:51 +00:00
|
|
|
nsAccessibleWrap(aNode, aShell)
|
2002-11-06 01:29:58 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULToolbarAccessible::GetRole(PRUint32 *_retval)
|
2002-11-06 01:29:58 +00:00
|
|
|
{
|
|
|
|
*_retval = ROLE_TOOLBAR;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULToolbarAccessible::GetState(PRUint32 *_retval)
|
2002-11-06 01:29:58 +00:00
|
|
|
{
|
2003-07-31 08:09:39 +00:00
|
|
|
nsAccessible::GetState(_retval);
|
2002-11-06 01:29:58 +00:00
|
|
|
*_retval &= ~STATE_FOCUSABLE; // toolbar is not focusable
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* XUL Toolbar Separator
|
|
|
|
*/
|
|
|
|
|
|
|
|
nsXULToolbarSeparatorAccessible::nsXULToolbarSeparatorAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
|
|
|
nsLeafAccessible(aNode, aShell)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULToolbarSeparatorAccessible::GetRole(PRUint32 *_retval)
|
2002-11-06 01:29:58 +00:00
|
|
|
{
|
|
|
|
*_retval = ROLE_SEPARATOR;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULToolbarSeparatorAccessible::GetState(PRUint32 *_retval)
|
2002-11-06 01:29:58 +00:00
|
|
|
{
|
|
|
|
*_retval = 0; // no special state flags for toolbar separator
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2004-06-02 04:06:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* XUL Textfield
|
|
|
|
*/
|
|
|
|
|
|
|
|
nsXULTextFieldAccessible::nsXULTextFieldAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell) :
|
2004-06-02 05:32:45 +00:00
|
|
|
nsLeafAccessible(aNode, aShell)
|
2004-06-02 04:06:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::GetValue(nsAString& aValue)
|
|
|
|
{
|
2005-01-19 07:10:38 +00:00
|
|
|
PRUint32 state;
|
|
|
|
GetState(&state);
|
|
|
|
if (state & STATE_PROTECTED) // Don't return password text!
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2004-06-02 04:06:28 +00:00
|
|
|
nsCOMPtr<nsIDOMXULTextBoxElement> textBox(do_QueryInterface(mDOMNode));
|
|
|
|
if (textBox) {
|
|
|
|
return textBox->GetValue(aValue);
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2005-03-14 23:10:53 +00:00
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::GetExtState(PRUint32 *aExtState)
|
|
|
|
{
|
|
|
|
nsresult rv = nsAccessible::GetExtState(aExtState);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
return rv;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
|
|
|
NS_ASSERTION(content, "Should not have gotten past nsAccessible::GetExtState() without node");
|
|
|
|
|
|
|
|
PRBool isMultiLine = content->HasAttr(kNameSpaceID_None, nsAccessibilityAtoms::multiline);
|
|
|
|
*aExtState |= (isMultiLine ? EXT_STATE_MULTI_LINE : EXT_STATE_SINGLE_LINE);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2004-06-02 04:06:28 +00:00
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::GetState(PRUint32 *aState)
|
|
|
|
{
|
|
|
|
*aState = 0;
|
|
|
|
nsCOMPtr<nsIDOMXULTextBoxElement> textBox(do_QueryInterface(mDOMNode));
|
|
|
|
if (!textBox) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2005-07-21 01:09:54 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> inputField;
|
2004-06-02 04:06:28 +00:00
|
|
|
textBox->GetInputField(getter_AddRefs(inputField));
|
|
|
|
if (!inputField) {
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
// Create a temporary accessible from the HTML text field
|
|
|
|
// to get the accessible state from. Doesn't add to cache
|
|
|
|
// because Init() is not called.
|
|
|
|
nsHTMLTextFieldAccessible tempAccessible(inputField, mWeakShell);
|
2004-06-15 02:31:20 +00:00
|
|
|
nsresult rv = tempAccessible.GetState(aState);
|
|
|
|
if (gLastFocusedNode == mDOMNode) {
|
|
|
|
*aState |= STATE_FOCUSED;
|
|
|
|
}
|
|
|
|
return rv;
|
2004-06-02 04:06:28 +00:00
|
|
|
}
|
|
|
|
|
2005-04-05 11:16:34 +00:00
|
|
|
/**
|
|
|
|
* Only one actions available
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::GetNumActions(PRUint8 *_retval)
|
|
|
|
{
|
|
|
|
*_retval = eSingle_Action;
|
|
|
|
return NS_OK;;
|
|
|
|
}
|
2004-06-02 04:06:28 +00:00
|
|
|
|
2005-04-05 11:16:34 +00:00
|
|
|
/**
|
|
|
|
* Return the name of our only action
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::GetActionName(PRUint8 index, nsAString& _retval)
|
|
|
|
{
|
|
|
|
if (index == eAction_Click) {
|
|
|
|
nsAccessible::GetTranslatedString(NS_LITERAL_STRING("activate"), _retval);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Tell the button to do it's action
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::DoAction(PRUint8 index)
|
|
|
|
{
|
|
|
|
if (index == 0) {
|
|
|
|
nsCOMPtr<nsIDOMXULElement> element(do_QueryInterface(mDOMNode));
|
|
|
|
if (element)
|
|
|
|
{
|
|
|
|
element->Focus();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|