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"
|
2007-02-09 02:03:08 +00:00
|
|
|
#include "nsXULMenuAccessible.h"
|
2004-06-02 04:06:28 +00:00
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
2006-11-29 16:10:31 +00:00
|
|
|
#include "nsIDOMNSEditableElement.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"
|
2006-07-12 13:14:53 +00:00
|
|
|
#include "nsIFrame.h"
|
2005-03-14 23:10:53 +00:00
|
|
|
#include "nsINameSpaceManager.h"
|
2006-07-12 13:14:53 +00:00
|
|
|
#include "nsITextControlFrame.h"
|
|
|
|
#include "nsIPresShell.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
|
|
|
{
|
2006-07-31 04:31:13 +00:00
|
|
|
*_retval = 1;
|
2006-07-12 13:14:53 +00:00
|
|
|
return NS_OK;
|
2001-10-09 21:52:36 +00:00
|
|
|
}
|
|
|
|
|
2001-11-07 00:12:16 +00:00
|
|
|
/**
|
|
|
|
* Return the name of our only action
|
|
|
|
*/
|
2007-02-25 03:43:20 +00:00
|
|
|
NS_IMETHODIMP nsXULButtonAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2007-02-25 03:43:20 +00:00
|
|
|
if (aIndex == eAction_Click) {
|
|
|
|
aName.AssignLiteral("press");
|
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
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*_retval = nsIAccessibleRole::ROLE_PUSHBUTTON;
|
2001-10-09 21:52:36 +00:00
|
|
|
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));
|
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
|
|
|
|
2005-12-16 05:20:31 +00:00
|
|
|
nsAutoString type;
|
|
|
|
element->GetAttribute(NS_LITERAL_STRING("type"), type);
|
|
|
|
if (type.EqualsLiteral("menu") || type.EqualsLiteral("menu-button")) {
|
|
|
|
*aState |= STATE_HASPOPUP;
|
|
|
|
}
|
2005-04-02 01:00:20 +00:00
|
|
|
}
|
2002-03-10 05:14:24 +00:00
|
|
|
|
2001-10-09 21:52:36 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-07-26 19:38:25 +00:00
|
|
|
void nsXULButtonAccessible::CacheChildren()
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
2005-08-19 19:24:38 +00:00
|
|
|
// An XUL button accessible may have 1 child dropmarker accessible
|
|
|
|
if (!mWeakShell) {
|
|
|
|
mAccChildCount = eChildCountUninitialized;
|
|
|
|
return; // This outer doc node has been shut down
|
|
|
|
}
|
|
|
|
if (mAccChildCount == eChildCountUninitialized) {
|
|
|
|
mAccChildCount = 0;
|
|
|
|
SetFirstChild(nsnull);
|
2006-07-26 19:38:25 +00:00
|
|
|
PRBool allowsAnonChildren = PR_FALSE;
|
|
|
|
GetAllowsAnonChildAccessibles(&allowsAnonChildren);
|
|
|
|
nsAccessibleTreeWalker walker(mWeakShell, mDOMNode, allowsAnonChildren);
|
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;
|
2007-03-15 02:26:13 +00:00
|
|
|
if (NS_SUCCEEDED(dropMarkerAccessible->GetRole(&role)) &&
|
|
|
|
role == nsIAccessibleRole::ROLE_PUSHBUTTON) {
|
2005-08-19 19:24:38 +00:00
|
|
|
SetFirstChild(dropMarkerAccessible);
|
2004-06-25 20:27:29 +00:00
|
|
|
nsCOMPtr<nsPIAccessible> privChildAcc = do_QueryInterface(dropMarkerAccessible);
|
2003-07-31 08:09:39 +00:00
|
|
|
privChildAcc->SetNextSibling(nsnull);
|
2005-08-19 19:24:38 +00:00
|
|
|
privChildAcc->SetParent(this);
|
|
|
|
mAccChildCount = 1;
|
2003-04-15 08:45:55 +00:00
|
|
|
}
|
2002-01-09 10:02:29 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* XUL Dropmarker: can contain arbitrary HTML content
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Default Constructor
|
|
|
|
*/
|
|
|
|
nsXULDropmarkerAccessible::nsXULDropmarkerAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
|
|
|
nsFormControlAccessible(aNode, aShell)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2006-12-11 09:37:01 +00:00
|
|
|
* Only one action available
|
2002-01-09 10:02:29 +00:00
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULDropmarkerAccessible::GetNumActions(PRUint8 *aResult)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
2006-07-31 04:31:13 +00:00
|
|
|
*aResult = 1;
|
2006-07-12 13:14:53 +00:00
|
|
|
return NS_OK;
|
2002-01-09 10:02:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
*/
|
2007-02-25 03:43:20 +00:00
|
|
|
NS_IMETHODIMP nsXULDropmarkerAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
2002-01-09 10:02:29 +00:00
|
|
|
{
|
2007-02-25 03:43:20 +00:00
|
|
|
if (aIndex == eAction_Click) {
|
2002-01-09 10:02:29 +00:00
|
|
|
if (DropmarkerOpen(PR_FALSE))
|
2007-02-25 03:43:20 +00:00
|
|
|
aName.AssignLiteral("close");
|
2002-01-09 10:02:29 +00:00
|
|
|
else
|
2007-02-25 03:43:20 +00:00
|
|
|
aName.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
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*aResult = nsIAccessibleRole::ROLE_PUSHBUTTON;
|
2002-01-09 10:02:29 +00:00
|
|
|
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
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*_retval = nsIAccessibleRole::ROLE_CHECKBUTTON;
|
2001-10-09 21:52:36 +00:00
|
|
|
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
|
|
|
{
|
2006-07-31 04:31:13 +00:00
|
|
|
*_retval = 1;
|
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
|
|
|
|
*/
|
2007-02-25 03:43:20 +00:00
|
|
|
NS_IMETHODIMP nsXULCheckboxAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
2001-10-09 21:52:36 +00:00
|
|
|
{
|
2007-02-25 03:43:20 +00:00
|
|
|
if (aIndex == 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)
|
2007-02-25 03:43:20 +00:00
|
|
|
aName.AssignLiteral("uncheck");
|
2001-10-09 21:52:36 +00:00
|
|
|
else
|
2007-02-25 03:43:20 +00:00
|
|
|
aName.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
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*_retval = nsIAccessibleRole::ROLE_GROUPING;
|
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;
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
*/
|
2006-06-15 16:55:32 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED1(nsXULProgressMeterAccessible, nsFormControlAccessible, nsIAccessibleValue)
|
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
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*_retval = nsIAccessibleRole::ROLE_PROGRESSBAR;
|
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-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);
|
2006-06-15 16:55:32 +00:00
|
|
|
*aState &= ~STATE_FOCUSABLE; // Progress meters are not focusable
|
2005-04-04 15:48:06 +00:00
|
|
|
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
|
|
|
}
|
|
|
|
|
2006-06-15 16:55:32 +00:00
|
|
|
NS_IMETHODIMP nsXULProgressMeterAccessible::GetValue(nsAString& aValue)
|
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
|
|
|
{
|
2006-06-15 16:55:32 +00:00
|
|
|
aValue.Truncate();
|
|
|
|
nsAccessible::GetValue(aValue);
|
|
|
|
if (!aValue.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));
|
|
|
|
NS_ASSERTION(element, "No element for DOM node!");
|
2006-06-15 16:55:32 +00:00
|
|
|
element->GetAttribute(NS_LITERAL_STRING("value"), aValue);
|
|
|
|
if (!aValue.IsEmpty() && aValue.Last() != '%')
|
|
|
|
aValue.AppendLiteral("%");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsXULProgressMeterAccessible::GetMaximumValue(double *aMaximumValue)
|
|
|
|
{
|
|
|
|
*aMaximumValue = 1; // 100% = 1;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsXULProgressMeterAccessible::GetMinimumValue(double *aMinimumValue)
|
|
|
|
{
|
|
|
|
*aMinimumValue = 0;
|
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
|
|
|
|
2006-06-15 16:55:32 +00:00
|
|
|
NS_IMETHODIMP nsXULProgressMeterAccessible::GetMinimumIncrement(double *aMinimumIncrement)
|
|
|
|
{
|
|
|
|
*aMinimumIncrement = 0;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsXULProgressMeterAccessible::GetCurrentValue(double *aCurrentValue)
|
|
|
|
{
|
|
|
|
nsAutoString currentValue;
|
|
|
|
GetValue(currentValue);
|
|
|
|
PRInt32 error;
|
|
|
|
*aCurrentValue = currentValue.ToFloat(&error) / 100;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsXULProgressMeterAccessible::SetCurrentValue(double aValue)
|
|
|
|
{
|
|
|
|
return NS_ERROR_FAILURE; // Progress meters are readonly!
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2001-12-11 20:49:49 +00:00
|
|
|
/**
|
|
|
|
* XUL Radio Button
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
nsXULRadioButtonAccessible::nsXULRadioButtonAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
|
|
|
nsRadioButtonAccessible(aNode, aShell)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 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):
|
2006-04-21 06:26:09 +00:00
|
|
|
nsXULSelectableAccessible(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
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*_retval = nsIAccessibleRole::ROLE_GROUPING;
|
2002-06-21 04:54:34 +00:00
|
|
|
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
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*_retval = nsIAccessibleRole::ROLE_STATUSBAR;
|
2002-01-09 10:02:29 +00:00
|
|
|
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
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*_retval = nsIAccessibleRole::ROLE_TOOLBAR;
|
2002-11-06 01:29:58 +00:00
|
|
|
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
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*_retval = nsIAccessibleRole::ROLE_SEPARATOR;
|
2002-11-06 01:29:58 +00:00
|
|
|
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) :
|
2006-07-12 13:14:53 +00:00
|
|
|
nsHyperTextAccessible(aNode, aShell)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-03-13 03:22:44 +00:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED2(nsXULTextFieldAccessible, nsAccessible, nsIAccessibleText, nsIAccessibleEditableText)
|
2006-07-12 13:14:53 +00:00
|
|
|
|
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::Init()
|
|
|
|
{
|
|
|
|
CheckForEditor();
|
|
|
|
return nsHyperTextAccessible::Init();
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::Shutdown()
|
2004-06-02 04:06:28 +00:00
|
|
|
{
|
2006-07-12 13:14:53 +00:00
|
|
|
if (mEditor) {
|
|
|
|
mEditor->RemoveEditActionListener(this);
|
|
|
|
mEditor = nsnull;
|
|
|
|
}
|
|
|
|
return nsHyperTextAccessible::Shutdown();
|
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);
|
|
|
|
}
|
2007-02-09 02:03:08 +00:00
|
|
|
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
|
|
|
|
if (menuList) {
|
|
|
|
return menuList->GetLabel(aValue);
|
|
|
|
}
|
2004-06-02 04:06:28 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2005-03-14 23:10:53 +00:00
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::GetExtState(PRUint32 *aExtState)
|
|
|
|
{
|
2006-07-12 13:14:53 +00:00
|
|
|
nsresult rv = nsHyperTextAccessible::GetExtState(aExtState);
|
2005-03-14 23:10:53 +00:00
|
|
|
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);
|
2006-06-16 17:13:37 +00:00
|
|
|
|
2007-03-13 03:22:44 +00:00
|
|
|
PRUint32 state;
|
|
|
|
GetState(&state);
|
|
|
|
const PRUint32 kNonEditableStates = STATE_READONLY | STATE_UNAVAILABLE;
|
|
|
|
if (0 == (state & kNonEditableStates)) {
|
|
|
|
*aExtState |= EXT_STATE_EDITABLE;
|
|
|
|
}
|
|
|
|
|
2005-03-14 23:10:53 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-02-09 02:03:08 +00:00
|
|
|
already_AddRefed<nsIDOMNode> nsXULTextFieldAccessible::GetInputField()
|
|
|
|
{
|
|
|
|
nsIDOMNode *inputField = nsnull;
|
|
|
|
nsCOMPtr<nsIDOMXULTextBoxElement> textBox = do_QueryInterface(mDOMNode);
|
|
|
|
if (textBox) {
|
|
|
|
textBox->GetInputField(&inputField);
|
|
|
|
return inputField;
|
|
|
|
}
|
|
|
|
nsCOMPtr<nsIDOMXULMenuListElement> menuList = do_QueryInterface(mDOMNode);
|
|
|
|
if (menuList) { // <xul:menulist droppable="false">
|
|
|
|
menuList->GetInputField(&inputField);
|
|
|
|
}
|
|
|
|
NS_ASSERTION(inputField, "No input field for nsXULTextFieldAccessible");
|
|
|
|
return inputField;
|
|
|
|
}
|
|
|
|
|
2004-06-02 04:06:28 +00:00
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::GetState(PRUint32 *aState)
|
|
|
|
{
|
2007-02-09 02:03:08 +00:00
|
|
|
if (!mDOMNode) {
|
2004-06-02 04:06:28 +00:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
2006-07-12 13:14:53 +00:00
|
|
|
nsHyperTextAccessible::GetState(aState);
|
2004-06-02 04:06:28 +00:00
|
|
|
|
2007-02-09 02:03:08 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> inputField = GetInputField();
|
2004-06-02 04:06:28 +00:00
|
|
|
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;
|
|
|
|
}
|
2006-06-16 17:13:37 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
2007-02-09 02:03:08 +00:00
|
|
|
NS_ASSERTION(content, "Not possible since we have an mDOMNode");
|
|
|
|
|
|
|
|
nsCOMPtr<nsIDOMXULMenuListElement> menuList(do_QueryInterface(mDOMNode));
|
|
|
|
if (menuList) {
|
|
|
|
// <xul:menulist droppable="false">
|
|
|
|
if (!content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::editable,
|
|
|
|
nsAccessibilityAtoms::_true, eIgnoreCase)) {
|
|
|
|
*aState |= STATE_READONLY;
|
|
|
|
}
|
2006-06-16 17:13:37 +00:00
|
|
|
}
|
2007-02-09 02:03:08 +00:00
|
|
|
else {
|
|
|
|
// <xul:textbox>
|
|
|
|
if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
|
|
|
|
nsAccessibilityAtoms::password, eIgnoreCase)) {
|
|
|
|
*aState |= STATE_PROTECTED;
|
|
|
|
}
|
|
|
|
if (content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::readonly,
|
|
|
|
nsAccessibilityAtoms::_true, eIgnoreCase)) {
|
|
|
|
*aState |= STATE_READONLY;
|
|
|
|
}
|
2006-06-16 17:13:37 +00:00
|
|
|
}
|
|
|
|
|
2004-06-15 02:31:20 +00:00
|
|
|
return rv;
|
2004-06-02 04:06:28 +00:00
|
|
|
}
|
|
|
|
|
2006-06-16 17:13:37 +00:00
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::GetRole(PRUint32 *aRole)
|
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*aRole = nsIAccessibleRole::ROLE_ENTRY;
|
2006-07-12 13:14:53 +00:00
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
|
|
|
if (content &&
|
|
|
|
content->AttrValueIs(kNameSpaceID_None, nsAccessibilityAtoms::type,
|
2006-06-16 17:13:37 +00:00
|
|
|
nsAccessibilityAtoms::password, eIgnoreCase)) {
|
2007-03-15 02:26:13 +00:00
|
|
|
*aRole = nsIAccessibleRole::ROLE_PASSWORD_TEXT;
|
2006-06-16 17:13:37 +00:00
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-04-05 11:16:34 +00:00
|
|
|
/**
|
|
|
|
* Only one actions available
|
|
|
|
*/
|
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::GetNumActions(PRUint8 *_retval)
|
|
|
|
{
|
2006-07-31 04:31:13 +00:00
|
|
|
*_retval = 1;
|
2006-07-12 13:14:53 +00:00
|
|
|
return NS_OK;
|
2005-04-05 11:16:34 +00:00
|
|
|
}
|
2004-06-02 04:06:28 +00:00
|
|
|
|
2005-04-05 11:16:34 +00:00
|
|
|
/**
|
|
|
|
* Return the name of our only action
|
|
|
|
*/
|
2007-02-25 03:43:20 +00:00
|
|
|
NS_IMETHODIMP nsXULTextFieldAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
2005-04-05 11:16:34 +00:00
|
|
|
{
|
2007-02-25 03:43:20 +00:00
|
|
|
if (aIndex == eAction_Click) {
|
|
|
|
aName.AssignLiteral("activate");
|
2005-04-05 11:16:34 +00:00
|
|
|
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;
|
|
|
|
}
|
2006-07-12 13:14:53 +00:00
|
|
|
|
2006-10-30 03:05:43 +00:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsXULTextFieldAccessible::GetAllowsAnonChildAccessibles(PRBool *aAllowsAnonChildren)
|
|
|
|
{
|
|
|
|
*aAllowsAnonChildren = PR_FALSE;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2006-07-12 13:14:53 +00:00
|
|
|
void nsXULTextFieldAccessible::SetEditor(nsIEditor* aEditor)
|
|
|
|
{
|
|
|
|
mEditor = aEditor;
|
|
|
|
if (mEditor)
|
|
|
|
mEditor->AddEditActionListener(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsXULTextFieldAccessible::CheckForEditor()
|
|
|
|
{
|
2007-02-09 02:03:08 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> inputField = GetInputField();
|
2006-11-29 16:10:31 +00:00
|
|
|
nsCOMPtr<nsIDOMNSEditableElement> editableElt(do_QueryInterface(inputField));
|
|
|
|
if (!editableElt) {
|
2006-07-12 13:14:53 +00:00
|
|
|
return;
|
|
|
|
}
|
2006-11-29 16:10:31 +00:00
|
|
|
|
|
|
|
nsCOMPtr<nsIEditor> editor;
|
|
|
|
nsresult rv = editableElt->GetEditor(getter_AddRefs(editor));
|
|
|
|
if (NS_SUCCEEDED(rv)) {
|
2006-07-12 13:14:53 +00:00
|
|
|
SetEditor(editor);
|
|
|
|
}
|
|
|
|
}
|