2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* 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/
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
|
|
|
* Author: Eric Vaughan (evaughan@netscape.com)
|
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* 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"),
|
|
|
|
* 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
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* 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
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "nsHTMLFormControlAccessible.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
#include "Relation.h"
|
2011-04-09 16:38:06 -07:00
|
|
|
#include "States.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
#include "nsAccUtils.h"
|
|
|
|
#include "nsTextEquivUtils.h"
|
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
#include "nsIAccessibleRelation.h"
|
2007-04-06 08:44:46 -07:00
|
|
|
#include "nsIDOMDocument.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDOMHTMLInputElement.h"
|
|
|
|
#include "nsIDOMNSEditableElement.h"
|
|
|
|
#include "nsIDOMHTMLFormElement.h"
|
|
|
|
#include "nsIDOMHTMLLegendElement.h"
|
|
|
|
#include "nsIDOMHTMLTextAreaElement.h"
|
2011-08-11 06:29:50 -07:00
|
|
|
#include "nsIDOMNodeList.h"
|
2007-08-14 09:25:24 -07:00
|
|
|
#include "nsIEditor.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIFrame.h"
|
|
|
|
#include "nsINameSpaceManager.h"
|
|
|
|
#include "nsISelectionController.h"
|
2007-07-24 23:24:00 -07:00
|
|
|
#include "jsapi.h"
|
|
|
|
#include "nsIJSContextStack.h"
|
|
|
|
#include "nsIServiceManager.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsITextControlFrame.h"
|
|
|
|
|
2011-07-27 05:43:01 -07:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLCheckboxAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsHTMLCheckboxAccessible::
|
|
|
|
nsHTMLCheckboxAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
|
|
|
|
nsFormControlAccessible(aContent, aShell)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-09-04 19:14:01 -07:00
|
|
|
PRUint32
|
|
|
|
nsHTMLCheckboxAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-09-04 19:14:01 -07:00
|
|
|
return nsIAccessibleRole::ROLE_CHECKBUTTON;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
PRUint8
|
|
|
|
nsHTMLCheckboxAccessible::ActionCount()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-05 12:35:43 -07:00
|
|
|
return 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsHTMLCheckboxAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
|
|
|
{
|
|
|
|
if (aIndex == eAction_Click) { // 0 is the magic value for default action
|
2009-03-09 08:10:40 -07:00
|
|
|
// cycle, check or uncheck
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 state = NativeState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
if (state & states::CHECKED)
|
2007-03-22 10:30:00 -07:00
|
|
|
aName.AssignLiteral("uncheck");
|
2011-04-09 16:38:06 -07:00
|
|
|
else if (state & states::MIXED)
|
2009-03-09 08:10:40 -07:00
|
|
|
aName.AssignLiteral("cycle");
|
2007-03-22 10:30:00 -07:00
|
|
|
else
|
|
|
|
aName.AssignLiteral("check");
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2010-01-25 07:09:25 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLCheckboxAccessible::DoAction(PRUint8 aIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-25 07:09:25 -08:00
|
|
|
if (aIndex != 0)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
DoCommand();
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
|
|
|
nsHTMLCheckboxAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 state = nsFormControlAccessible::NativeState();
|
2007-05-06 07:50:03 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::CHECKABLE;
|
2011-09-28 23:19:26 -07:00
|
|
|
bool checkState = false; // Radio buttons and check boxes can be checked or mixed
|
2009-02-11 00:40:27 -08:00
|
|
|
|
2010-08-04 19:40:18 -07:00
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> htmlCheckboxElement =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent);
|
2009-02-11 00:40:27 -08:00
|
|
|
|
2010-08-04 19:40:18 -07:00
|
|
|
if (htmlCheckboxElement) {
|
2011-04-09 16:38:06 -07:00
|
|
|
htmlCheckboxElement->GetIndeterminate(&checkState);
|
2009-02-11 00:40:27 -08:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
if (checkState) {
|
|
|
|
state |= states::MIXED;
|
2010-08-04 19:40:18 -07:00
|
|
|
} else { // indeterminate can't be checked at the same time.
|
2011-04-09 16:38:06 -07:00
|
|
|
htmlCheckboxElement->GetChecked(&checkState);
|
2010-08-04 19:40:18 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
if (checkState)
|
|
|
|
state |= states::CHECKED;
|
2009-02-11 00:40:27 -08:00
|
|
|
}
|
|
|
|
}
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 20:13:08 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLCheckboxAccessible: Widgets
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsHTMLCheckboxAccessible::IsWidget() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLRadioButtonAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsHTMLRadioButtonAccessible::
|
|
|
|
nsHTMLRadioButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
|
|
|
|
nsRadioButtonAccessible(aContent, aShell)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
|
|
|
nsHTMLRadioButtonAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 state = nsAccessibleWrap::NativeState();
|
2007-04-02 08:56:24 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::CHECKABLE;
|
2007-05-06 07:50:03 -07:00
|
|
|
|
2011-09-28 23:19:26 -07:00
|
|
|
bool checked = false; // Radio buttons and check boxes can be checked
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> htmlRadioElement =
|
|
|
|
do_QueryInterface(mContent);
|
2007-04-02 08:56:24 -07:00
|
|
|
if (htmlRadioElement)
|
2007-03-22 10:30:00 -07:00
|
|
|
htmlRadioElement->GetChecked(&checked);
|
|
|
|
|
2007-04-02 08:56:24 -07:00
|
|
|
if (checked)
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::CHECKED;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
void
|
|
|
|
nsHTMLRadioButtonAccessible::GetPositionAndSizeInternal(PRInt32 *aPosInSet,
|
|
|
|
PRInt32 *aSetSize)
|
2007-03-27 05:17:11 -07:00
|
|
|
{
|
|
|
|
nsAutoString nsURI;
|
2010-06-11 01:23:18 -07:00
|
|
|
mContent->NodeInfo()->GetNamespaceURI(nsURI);
|
2007-03-27 05:17:11 -07:00
|
|
|
nsAutoString tagName;
|
2010-06-11 01:23:18 -07:00
|
|
|
mContent->NodeInfo()->GetName(tagName);
|
2007-04-03 01:27:43 -07:00
|
|
|
|
|
|
|
nsAutoString type;
|
2011-06-03 14:35:17 -07:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::type, type);
|
2007-04-03 01:27:43 -07:00
|
|
|
nsAutoString name;
|
2011-06-03 14:35:17 -07:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::name, name);
|
2007-04-03 01:27:43 -07:00
|
|
|
|
2007-04-06 08:44:46 -07:00
|
|
|
nsCOMPtr<nsIDOMNodeList> inputs;
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> radio(do_QueryInterface(mContent));
|
2007-03-27 05:17:11 -07:00
|
|
|
nsCOMPtr<nsIDOMHTMLFormElement> form;
|
|
|
|
radio->GetForm(getter_AddRefs(form));
|
2007-04-06 08:44:46 -07:00
|
|
|
if (form) {
|
|
|
|
form->GetElementsByTagNameNS(nsURI, tagName, getter_AddRefs(inputs));
|
|
|
|
} else {
|
2011-10-18 03:53:36 -07:00
|
|
|
nsIDocument* doc = mContent->OwnerDoc();
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMDocument> document(do_QueryInterface(doc));
|
2007-04-06 08:44:46 -07:00
|
|
|
if (document)
|
|
|
|
document->GetElementsByTagNameNS(nsURI, tagName, getter_AddRefs(inputs));
|
|
|
|
}
|
2007-03-27 05:17:11 -07:00
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
NS_ENSURE_TRUE(inputs, );
|
2007-03-27 05:17:11 -07:00
|
|
|
|
2007-04-03 01:27:43 -07:00
|
|
|
PRUint32 inputsCount = 0;
|
|
|
|
inputs->GetLength(&inputsCount);
|
2007-03-27 05:17:11 -07:00
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
// Compute posinset and setsize.
|
2007-03-27 05:17:11 -07:00
|
|
|
PRInt32 indexOf = 0;
|
2007-04-03 01:27:43 -07:00
|
|
|
PRInt32 count = 0;
|
|
|
|
|
|
|
|
for (PRUint32 index = 0; index < inputsCount; index++) {
|
|
|
|
nsCOMPtr<nsIDOMNode> itemNode;
|
|
|
|
inputs->Item(index, getter_AddRefs(itemNode));
|
|
|
|
|
|
|
|
nsCOMPtr<nsIContent> item(do_QueryInterface(itemNode));
|
|
|
|
if (item &&
|
2011-06-03 14:35:17 -07:00
|
|
|
item->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
2007-04-03 01:27:43 -07:00
|
|
|
type, eCaseMatters) &&
|
2011-06-03 14:35:17 -07:00
|
|
|
item->AttrValueIs(kNameSpaceID_None, nsGkAtoms::name,
|
2007-04-03 01:27:43 -07:00
|
|
|
name, eCaseMatters)) {
|
|
|
|
|
|
|
|
count++;
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
if (item == mContent)
|
2007-04-03 01:27:43 -07:00
|
|
|
indexOf = count;
|
2007-03-27 05:17:11 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
*aPosInSet = indexOf;
|
|
|
|
*aSetSize = count;
|
2007-03-27 05:17:11 -07:00
|
|
|
}
|
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLButtonAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsHTMLButtonAccessible::
|
|
|
|
nsHTMLButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
|
|
|
|
nsHyperTextAccessibleWrap(aContent, aShell)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
PRUint8
|
|
|
|
nsHTMLButtonAccessible::ActionCount()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-05 12:35:43 -07:00
|
|
|
return 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsHTMLButtonAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
|
|
|
{
|
|
|
|
if (aIndex == eAction_Click) {
|
|
|
|
aName.AssignLiteral("press");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2010-01-25 07:09:25 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTMLButtonAccessible::DoAction(PRUint8 aIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-25 07:09:25 -08:00
|
|
|
if (aIndex != eAction_Click)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
DoCommand();
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-11-30 04:36:20 -08:00
|
|
|
PRUint64
|
|
|
|
nsHTMLButtonAccessible::State()
|
|
|
|
{
|
|
|
|
PRUint64 state = nsHyperTextAccessibleWrap::State();
|
|
|
|
if (state == states::DEFUNCT)
|
|
|
|
return state;
|
|
|
|
|
|
|
|
// Inherit states from input@type="file" suitable for the button. Note,
|
|
|
|
// no special processing for unavailable state since inheritance is supplied
|
|
|
|
// other code paths.
|
|
|
|
if (mParent && mParent->IsHTMLFileInput()) {
|
|
|
|
PRUint64 parentState = mParent->State();
|
|
|
|
state |= parentState & (states::BUSY | states::REQUIRED |
|
|
|
|
states::HASPOPUP | states::INVALID);
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
|
|
|
nsHTMLButtonAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 state = nsHyperTextAccessibleWrap::NativeState();
|
2008-02-11 04:12:17 -08:00
|
|
|
|
2011-10-03 07:26:18 -07:00
|
|
|
nsEventStates elmState = mContent->AsElement()->State();
|
|
|
|
if (elmState.HasState(NS_EVENT_STATE_DEFAULT))
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::DEFAULT;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-09-04 19:14:01 -07:00
|
|
|
PRUint32
|
|
|
|
nsHTMLButtonAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-09-04 19:14:01 -07:00
|
|
|
return nsIAccessibleRole::ROLE_PUSHBUTTON;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
nsresult
|
|
|
|
nsHTMLButtonAccessible::GetNameInternal(nsAString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2009-06-24 16:18:46 -07:00
|
|
|
nsAccessible::GetNameInternal(aName);
|
2008-10-14 01:27:02 -07:00
|
|
|
if (!aName.IsEmpty())
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
// No name from HTML or ARIA
|
2007-03-22 10:30:00 -07:00
|
|
|
nsAutoString name;
|
2011-06-03 14:35:17 -07:00
|
|
|
if (!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::value,
|
2010-06-11 01:23:18 -07:00
|
|
|
name) &&
|
2011-06-03 14:35:17 -07:00
|
|
|
!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::alt,
|
2010-06-11 01:23:18 -07:00
|
|
|
name)) {
|
2008-10-14 01:27:02 -07:00
|
|
|
// Use the button's (default) label if nothing else works
|
|
|
|
nsIFrame* frame = GetFrame();
|
|
|
|
if (frame) {
|
2009-01-12 11:20:59 -08:00
|
|
|
nsIFormControlFrame* fcFrame = do_QueryFrame(frame);
|
2008-10-14 01:27:02 -07:00
|
|
|
if (fcFrame)
|
2011-06-03 14:35:17 -07:00
|
|
|
fcFrame->GetFormProperty(nsGkAtoms::defaultLabel, name);
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-10-14 01:27:02 -07:00
|
|
|
if (name.IsEmpty() &&
|
2011-06-03 14:35:17 -07:00
|
|
|
!mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::src, name)) {
|
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::data, name);
|
2008-10-14 01:27:02 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
name.CompressWhitespace();
|
|
|
|
aName = name;
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-09-28 20:13:08 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLButtonAccessible: Widgets
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsHTMLButtonAccessible::IsWidget() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTML4ButtonAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsHTML4ButtonAccessible::
|
|
|
|
nsHTML4ButtonAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
|
|
|
|
nsHyperTextAccessibleWrap(aContent, aShell)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
PRUint8
|
|
|
|
nsHTML4ButtonAccessible::ActionCount()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-05 12:35:43 -07:00
|
|
|
return 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsHTML4ButtonAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
|
|
|
{
|
|
|
|
if (aIndex == eAction_Click) {
|
|
|
|
aName.AssignLiteral("press");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2010-01-25 07:09:25 -08:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsHTML4ButtonAccessible::DoAction(PRUint8 aIndex)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-25 07:09:25 -08:00
|
|
|
if (aIndex != 0)
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
|
|
|
|
DoCommand();
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-09-04 19:14:01 -07:00
|
|
|
PRUint32
|
|
|
|
nsHTML4ButtonAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-09-04 19:14:01 -07:00
|
|
|
return nsIAccessibleRole::ROLE_PUSHBUTTON;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
|
|
|
nsHTML4ButtonAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 state = nsHyperTextAccessibleWrap::NativeState();
|
2008-02-11 04:12:17 -08:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::FOCUSABLE;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-10-03 07:26:18 -07:00
|
|
|
nsEventStates elmState = mContent->AsElement()->State();
|
|
|
|
if (elmState.HasState(NS_EVENT_STATE_DEFAULT))
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::DEFAULT;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-28 20:13:08 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTML4ButtonAccessible: Widgets
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsHTML4ButtonAccessible::IsWidget() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLTextFieldAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsHTMLTextFieldAccessible::
|
|
|
|
nsHTMLTextFieldAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
|
|
|
|
nsHyperTextAccessibleWrap(aContent, aShell)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-11-09 11:27:07 -08:00
|
|
|
NS_IMPL_ISUPPORTS_INHERITED3(nsHTMLTextFieldAccessible, nsAccessible, nsHyperTextAccessible, nsIAccessibleText, nsIAccessibleEditableText)
|
|
|
|
|
2010-09-04 19:14:01 -07:00
|
|
|
PRUint32
|
|
|
|
nsHTMLTextFieldAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-03 14:35:17 -07:00
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::password, eIgnoreCase)) {
|
2010-09-04 19:14:01 -07:00
|
|
|
return nsIAccessibleRole::ROLE_PASSWORD_TEXT;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2010-09-04 19:14:01 -07:00
|
|
|
return nsIAccessibleRole::ROLE_ENTRY;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-10-14 01:27:02 -07:00
|
|
|
nsresult
|
|
|
|
nsHTMLTextFieldAccessible::GetNameInternal(nsAString& aName)
|
2007-06-14 18:50:37 -07:00
|
|
|
{
|
2008-10-14 01:27:02 -07:00
|
|
|
nsresult rv = nsAccessible::GetNameInternal(aName);
|
2008-10-10 05:26:55 -07:00
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (!aName.IsEmpty())
|
|
|
|
return NS_OK;
|
|
|
|
|
2010-11-08 05:33:25 -08:00
|
|
|
if (mContent->GetBindingParent())
|
|
|
|
{
|
|
|
|
// XXX: bug 459640
|
|
|
|
// There's a binding parent.
|
|
|
|
// This means we're part of another control, so use parent accessible for name.
|
|
|
|
// This ensures that a textbox inside of a XUL widget gets
|
|
|
|
// an accessible name.
|
2011-07-23 01:38:33 -07:00
|
|
|
nsAccessible* parent = Parent();
|
|
|
|
if (parent)
|
|
|
|
parent->GetName(aName);
|
2010-11-08 05:33:25 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!aName.IsEmpty())
|
2008-10-14 01:27:02 -07:00
|
|
|
return NS_OK;
|
2007-06-14 18:50:37 -07:00
|
|
|
|
2010-11-08 05:33:25 -08:00
|
|
|
// text inputs and textareas might have useful placeholder text
|
2011-06-03 14:35:17 -07:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::placeholder, aName);
|
2010-11-08 05:33:25 -08:00
|
|
|
|
|
|
|
return NS_OK;
|
2007-06-14 18:50:37 -07:00
|
|
|
}
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetValue(nsAString& _retval)
|
|
|
|
{
|
2011-04-14 04:49:38 -07:00
|
|
|
if (IsDefunct())
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
if (NativeState() & states::PROTECTED) // Don't return password text!
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMHTMLTextAreaElement> textArea(do_QueryInterface(mContent));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (textArea) {
|
|
|
|
return textArea->GetValue(_retval);
|
|
|
|
}
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> inputElement(do_QueryInterface(mContent));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (inputElement) {
|
|
|
|
return inputElement->GetValue(_retval);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2011-09-01 08:37:24 -07:00
|
|
|
void
|
|
|
|
nsHTMLTextFieldAccessible::ApplyARIAState(PRUint64* aState)
|
|
|
|
{
|
|
|
|
nsHyperTextAccessibleWrap::ApplyARIAState(aState);
|
|
|
|
|
|
|
|
nsStateMapEntry::MapToStates(mContent, aState, eARIAAutoComplete);
|
2011-11-30 04:36:20 -08:00
|
|
|
}
|
2011-09-01 08:37:24 -07:00
|
|
|
|
2011-11-30 04:36:20 -08:00
|
|
|
PRUint64
|
|
|
|
nsHTMLTextFieldAccessible::State()
|
|
|
|
{
|
|
|
|
PRUint64 state = nsHyperTextAccessibleWrap::State();
|
|
|
|
if (state & states::DEFUNCT)
|
|
|
|
return state;
|
|
|
|
|
|
|
|
// Inherit states from input@type="file" suitable for the button. Note,
|
|
|
|
// no special processing for unavailable state since inheritance is supplied
|
|
|
|
// by other code paths.
|
|
|
|
if (mParent && mParent->IsHTMLFileInput()) {
|
|
|
|
PRUint64 parentState = mParent->State();
|
|
|
|
state |= parentState & (states::BUSY | states::REQUIRED |
|
|
|
|
states::HASPOPUP | states::INVALID);
|
|
|
|
}
|
|
|
|
|
|
|
|
return state;
|
2011-09-01 08:37:24 -07:00
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
|
|
|
nsHTMLTextFieldAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64 state = nsHyperTextAccessibleWrap::NativeState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// can be focusable, focused, protected. readonly, unavailable, selected
|
2011-06-03 14:35:17 -07:00
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::type,
|
|
|
|
nsGkAtoms::password, eIgnoreCase)) {
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::PROTECTED;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-06-03 14:35:17 -07:00
|
|
|
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::readonly)) {
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::READONLY;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
// Is it an <input> or a <textarea> ?
|
2011-09-27 18:46:11 -07:00
|
|
|
nsCOMPtr<nsIDOMHTMLInputElement> htmlInput(do_QueryInterface(mContent));
|
|
|
|
state |= htmlInput ? states::SINGLE_LINE : states::MULTI_LINE;
|
|
|
|
|
|
|
|
if (!(state & states::EDITABLE) ||
|
|
|
|
(state & (states::PROTECTED | states::MULTI_LINE)))
|
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
// Expose autocomplete states if this input is part of autocomplete widget.
|
|
|
|
nsAccessible* widget = ContainerWidget();
|
|
|
|
if (widget && widget-IsAutoComplete()) {
|
|
|
|
state |= states::HASPOPUP | states::SUPPORTS_AUTOCOMPLETION;
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2011-09-27 18:46:11 -07:00
|
|
|
}
|
2008-07-02 01:42:58 -07:00
|
|
|
|
2011-10-06 23:02:18 -07:00
|
|
|
// Expose autocomplete state if it has associated autocomplete list.
|
|
|
|
if (mContent->HasAttr(kNameSpaceID_None, nsGkAtoms::list))
|
|
|
|
return state | states::SUPPORTS_AUTOCOMPLETION;
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
// No parent can mean a fake widget created for XUL textbox. If accessible
|
|
|
|
// is unattached from tree then we don't care.
|
|
|
|
if (mParent && gIsFormFillEnabled) {
|
2007-04-05 15:14:08 -07:00
|
|
|
// Check to see if autocompletion is allowed on this input. We don't expose
|
|
|
|
// it for password fields even though the entire password can be remembered
|
|
|
|
// for a page if the user asks it to be. However, the kind of autocomplete
|
|
|
|
// we're talking here is based on what the user types, where a popup of
|
|
|
|
// possible choices comes up.
|
|
|
|
nsAutoString autocomplete;
|
2011-06-03 14:35:17 -07:00
|
|
|
mContent->GetAttr(kNameSpaceID_None, nsGkAtoms::autocomplete,
|
2010-06-11 01:23:18 -07:00
|
|
|
autocomplete);
|
2007-04-05 15:14:08 -07:00
|
|
|
|
|
|
|
if (!autocomplete.LowerCaseEqualsLiteral("off")) {
|
|
|
|
nsCOMPtr<nsIDOMHTMLFormElement> form;
|
|
|
|
htmlInput->GetForm(getter_AddRefs(form));
|
|
|
|
nsCOMPtr<nsIContent> formContent(do_QueryInterface(form));
|
|
|
|
if (formContent) {
|
|
|
|
formContent->GetAttr(kNameSpaceID_None,
|
2011-06-03 14:35:17 -07:00
|
|
|
nsGkAtoms::autocomplete, autocomplete);
|
2007-04-05 14:52:03 -07:00
|
|
|
}
|
2007-04-05 15:14:08 -07:00
|
|
|
|
|
|
|
if (!formContent || !autocomplete.LowerCaseEqualsLiteral("off"))
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::SUPPORTS_AUTOCOMPLETION;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
PRUint8
|
|
|
|
nsHTMLTextFieldAccessible::ActionCount()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-05 12:35:43 -07:00
|
|
|
return 1;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
|
|
|
{
|
|
|
|
if (aIndex == eAction_Click) {
|
|
|
|
aName.AssignLiteral("activate");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP nsHTMLTextFieldAccessible::DoAction(PRUint8 index)
|
|
|
|
{
|
|
|
|
if (index == 0) {
|
2011-04-11 09:56:37 -07:00
|
|
|
nsCOMPtr<nsIDOMHTMLElement> element(do_QueryInterface(mContent));
|
2007-05-07 11:51:36 -07:00
|
|
|
if ( element ) {
|
|
|
|
return element->Focus();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2007-08-14 09:25:24 -07:00
|
|
|
NS_IMETHODIMP nsHTMLTextFieldAccessible::GetAssociatedEditor(nsIEditor **aEditor)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-08-14 09:25:24 -07:00
|
|
|
*aEditor = nsnull;
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMNSEditableElement> editableElt(do_QueryInterface(mContent));
|
2007-08-14 09:25:24 -07:00
|
|
|
NS_ENSURE_TRUE(editableElt, NS_ERROR_FAILURE);
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-07-24 23:24:00 -07:00
|
|
|
// nsGenericHTMLElement::GetEditor has a security check.
|
|
|
|
// Make sure we're not restricted by the permissions of
|
|
|
|
// whatever script is currently running.
|
|
|
|
nsCOMPtr<nsIJSContextStack> stack =
|
|
|
|
do_GetService("@mozilla.org/js/xpc/ContextStack;1");
|
2011-09-28 23:19:26 -07:00
|
|
|
bool pushed = stack && NS_SUCCEEDED(stack->Push(nsnull));
|
2007-07-24 23:24:00 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
nsCOMPtr<nsIEditor> editor;
|
2007-08-14 09:25:24 -07:00
|
|
|
nsresult rv = editableElt->GetEditor(aEditor);
|
2007-07-24 23:24:00 -07:00
|
|
|
|
|
|
|
if (pushed) {
|
|
|
|
JSContext* cx;
|
|
|
|
stack->Pop(&cx);
|
|
|
|
NS_ASSERTION(!cx, "context should be null");
|
|
|
|
}
|
2007-08-14 09:25:24 -07:00
|
|
|
|
|
|
|
return rv;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2011-09-27 18:46:11 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLTextFieldAccessible: Widgets
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsHTMLTextFieldAccessible::IsWidget() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAccessible*
|
|
|
|
nsHTMLTextFieldAccessible::ContainerWidget() const
|
|
|
|
{
|
|
|
|
return mParent && mParent->Role() == nsIAccessibleRole::ROLE_AUTOCOMPLETE ?
|
|
|
|
mParent : nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-11-30 04:36:20 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLGroupboxAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsHTMLFileInputAccessible::
|
|
|
|
nsHTMLFileInputAccessible(nsIContent* aContent, nsIWeakReference* aShell) :
|
|
|
|
nsHyperTextAccessibleWrap(aContent, aShell)
|
|
|
|
{
|
|
|
|
mFlags |= eHTMLFileInputAccessible;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32
|
|
|
|
nsHTMLFileInputAccessible::NativeRole()
|
|
|
|
{
|
|
|
|
// JAWS wants a text container, others don't mind. No specific role in
|
|
|
|
// AT APIs.
|
|
|
|
return nsIAccessibleRole::ROLE_TEXT_CONTAINER;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsHTMLFileInputAccessible::HandleAccEvent(AccEvent* aEvent)
|
|
|
|
{
|
|
|
|
nsresult rv = nsHyperTextAccessibleWrap::HandleAccEvent(aEvent);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// Redirect state change events for inherited states to child controls. Note,
|
|
|
|
// unavailable state is not redirected. That's a standard for unavailable
|
|
|
|
// state handling.
|
|
|
|
AccStateChangeEvent* event = downcast_accEvent(aEvent);
|
|
|
|
if (event &&
|
|
|
|
(event->GetState() == states::BUSY ||
|
|
|
|
event->GetState() == states::REQUIRED ||
|
|
|
|
event->GetState() == states::HASPOPUP ||
|
|
|
|
event->GetState() == states::INVALID)) {
|
|
|
|
nsAccessible* input = GetChildAt(0);
|
|
|
|
if (input && input->Role() == nsIAccessibleRole::ROLE_ENTRY) {
|
|
|
|
nsRefPtr<AccStateChangeEvent> childEvent =
|
|
|
|
new AccStateChangeEvent(input, event->GetState(),
|
|
|
|
event->IsStateEnabled(),
|
|
|
|
(event->IsFromUserInput() ? eFromUserInput : eNoUserInput));
|
|
|
|
nsEventShell::FireEvent(childEvent);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAccessible* button = GetChildAt(1);
|
|
|
|
if (button && button->Role() == nsIAccessibleRole::ROLE_PUSHBUTTON) {
|
|
|
|
nsRefPtr<AccStateChangeEvent> childEvent =
|
|
|
|
new AccStateChangeEvent(button, event->GetState(),
|
|
|
|
event->IsStateEnabled(),
|
|
|
|
(event->IsFromUserInput() ? eFromUserInput : eNoUserInput));
|
|
|
|
nsEventShell::FireEvent(childEvent);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLGroupboxAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsHTMLGroupboxAccessible::
|
|
|
|
nsHTMLGroupboxAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
|
|
|
|
nsHyperTextAccessibleWrap(aContent, aShell)
|
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-09-04 19:14:01 -07:00
|
|
|
PRUint32
|
|
|
|
nsHTMLGroupboxAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-09-04 19:14:01 -07:00
|
|
|
return nsIAccessibleRole::ROLE_GROUPING;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2007-06-30 13:06:13 -07:00
|
|
|
nsIContent* nsHTMLGroupboxAccessible::GetLegend()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2007-06-30 13:06:13 -07:00
|
|
|
nsresult count = 0;
|
2010-06-11 01:23:18 -07:00
|
|
|
nsIContent *legendContent = nsnull;
|
|
|
|
while ((legendContent = mContent->GetChildAt(count++)) != nsnull) {
|
2011-06-03 14:35:17 -07:00
|
|
|
if (legendContent->NodeInfo()->Equals(nsGkAtoms::legend,
|
2010-06-11 01:23:18 -07:00
|
|
|
mContent->GetNameSpaceID())) {
|
2007-06-30 13:06:13 -07:00
|
|
|
// Either XHTML namespace or no namespace
|
2010-06-11 01:23:18 -07:00
|
|
|
return legendContent;
|
2007-06-30 13:06:13 -07:00
|
|
|
}
|
|
|
|
}
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-06-30 13:06:13 -07:00
|
|
|
return nsnull;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
nsresult
|
|
|
|
nsHTMLGroupboxAccessible::GetNameInternal(nsAString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-10-10 05:26:55 -07:00
|
|
|
nsresult rv = nsAccessible::GetNameInternal(aName);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
2008-08-24 09:45:56 -07:00
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
if (!aName.IsEmpty())
|
|
|
|
return NS_OK;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2007-06-30 13:06:13 -07:00
|
|
|
nsIContent *legendContent = GetLegend();
|
|
|
|
if (legendContent) {
|
2009-02-18 23:06:14 -08:00
|
|
|
return nsTextEquivUtils::
|
|
|
|
AppendTextEquivFromContent(this, legendContent, &aName);
|
2007-06-30 13:06:13 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
Relation
|
|
|
|
nsHTMLGroupboxAccessible::RelationByType(PRUint32 aType)
|
2007-06-30 13:06:13 -07:00
|
|
|
{
|
2011-08-09 18:44:00 -07:00
|
|
|
Relation rel = nsHyperTextAccessibleWrap::RelationByType(aType);
|
2007-06-30 13:06:13 -07:00
|
|
|
// No override for label, so use <legend> for this <fieldset>
|
2011-08-09 18:44:00 -07:00
|
|
|
if (aType == nsIAccessibleRelation::RELATION_LABELLED_BY)
|
|
|
|
rel.AppendTarget(GetLegend());
|
2007-06-30 13:06:13 -07:00
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2009-03-07 07:38:58 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLLegendAccessible
|
2010-06-11 01:23:18 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2009-03-07 07:38:58 -08:00
|
|
|
|
2010-06-11 01:23:18 -07:00
|
|
|
nsHTMLLegendAccessible::
|
|
|
|
nsHTMLLegendAccessible(nsIContent *aContent, nsIWeakReference *aShell) :
|
|
|
|
nsHyperTextAccessibleWrap(aContent, aShell)
|
|
|
|
{
|
2007-06-30 13:06:13 -07:00
|
|
|
}
|
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
Relation
|
|
|
|
nsHTMLLegendAccessible::RelationByType(PRUint32 aType)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-08-09 18:44:00 -07:00
|
|
|
Relation rel = nsHyperTextAccessibleWrap::RelationByType(aType);
|
|
|
|
if (aType != nsIAccessibleRelation::RELATION_LABEL_FOR)
|
|
|
|
return rel;
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
nsAccessible* groupbox = Parent();
|
|
|
|
if (groupbox && groupbox->Role() == nsIAccessibleRole::ROLE_GROUPING)
|
|
|
|
rel.AppendTarget(groupbox);
|
2007-06-30 13:06:13 -07:00
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2009-03-07 07:38:58 -08:00
|
|
|
|
2010-09-04 19:14:01 -07:00
|
|
|
PRUint32
|
|
|
|
nsHTMLLegendAccessible::NativeRole()
|
2009-03-07 07:38:58 -08:00
|
|
|
{
|
2010-09-04 19:14:01 -07:00
|
|
|
return nsIAccessibleRole::ROLE_LABEL;
|
2009-03-07 07:38:58 -08:00
|
|
|
}
|
2011-12-04 22:04:06 -08:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLFigureAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsHTMLFigureAccessible::
|
|
|
|
nsHTMLFigureAccessible(nsIContent* aContent, nsIWeakReference* aShell) :
|
|
|
|
nsHyperTextAccessibleWrap(aContent, aShell)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsHTMLFigureAccessible::GetAttributesInternal(nsIPersistentProperties* aAttributes)
|
|
|
|
{
|
|
|
|
nsresult rv = nsHyperTextAccessibleWrap::GetAttributesInternal(aAttributes);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
// Expose figure xml-role.
|
|
|
|
nsAccUtils::SetAccAttr(aAttributes, nsGkAtoms::xmlroles,
|
|
|
|
NS_LITERAL_STRING("figure"));
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32
|
|
|
|
nsHTMLFigureAccessible::NativeRole()
|
|
|
|
{
|
|
|
|
return nsIAccessibleRole::ROLE_FIGURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsresult
|
|
|
|
nsHTMLFigureAccessible::GetNameInternal(nsAString& aName)
|
|
|
|
{
|
|
|
|
nsresult rv = nsHyperTextAccessibleWrap::GetNameInternal(aName);
|
|
|
|
NS_ENSURE_SUCCESS(rv, rv);
|
|
|
|
|
|
|
|
if (!aName.IsEmpty())
|
|
|
|
return NS_OK;
|
|
|
|
|
|
|
|
nsIContent* captionContent = Caption();
|
|
|
|
if (captionContent) {
|
|
|
|
return nsTextEquivUtils::
|
|
|
|
AppendTextEquivFromContent(this, captionContent, &aName);
|
|
|
|
}
|
|
|
|
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
Relation
|
|
|
|
nsHTMLFigureAccessible::RelationByType(PRUint32 aType)
|
|
|
|
{
|
|
|
|
Relation rel = nsHyperTextAccessibleWrap::RelationByType(aType);
|
|
|
|
if (aType == nsIAccessibleRelation::RELATION_LABELLED_BY)
|
|
|
|
rel.AppendTarget(Caption());
|
|
|
|
|
|
|
|
return rel;
|
|
|
|
}
|
|
|
|
|
|
|
|
nsIContent*
|
|
|
|
nsHTMLFigureAccessible::Caption() const
|
|
|
|
{
|
|
|
|
for (nsIContent* childContent = mContent->GetFirstChild(); childContent;
|
|
|
|
childContent = childContent->GetNextSibling()) {
|
|
|
|
if (childContent->NodeInfo()->Equals(nsGkAtoms::figcaption,
|
|
|
|
mContent->GetNameSpaceID())) {
|
|
|
|
return childContent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return nsnull;
|
|
|
|
}
|
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsHTMLFigcaptionAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsHTMLFigcaptionAccessible::
|
|
|
|
nsHTMLFigcaptionAccessible(nsIContent* aContent, nsIWeakReference* aShell) :
|
|
|
|
nsHyperTextAccessibleWrap(aContent, aShell)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
PRUint32
|
|
|
|
nsHTMLFigcaptionAccessible::NativeRole()
|
|
|
|
{
|
|
|
|
return nsIAccessibleRole::ROLE_CAPTION;
|
|
|
|
}
|
|
|
|
|
|
|
|
Relation
|
|
|
|
nsHTMLFigcaptionAccessible::RelationByType(PRUint32 aType)
|
|
|
|
{
|
|
|
|
Relation rel = nsHyperTextAccessibleWrap::RelationByType(aType);
|
|
|
|
if (aType != nsIAccessibleRelation::RELATION_LABEL_FOR)
|
|
|
|
return rel;
|
|
|
|
|
|
|
|
nsAccessible* figure = Parent();
|
|
|
|
if (figure &&
|
|
|
|
figure->GetContent()->NodeInfo()->Equals(nsGkAtoms::figure,
|
|
|
|
mContent->GetNameSpaceID())) {
|
|
|
|
rel.AppendTarget(figure);
|
|
|
|
}
|
|
|
|
|
|
|
|
return rel;
|
|
|
|
}
|