2007-03-22 10:30:00 -07:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 04:12:37 -07:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
#include "XULTabAccessible.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
|
|
|
#include "nsAccUtils.h"
|
2011-08-09 18:44:00 -07:00
|
|
|
#include "Relation.h"
|
2012-01-11 19:07:35 -08:00
|
|
|
#include "Role.h"
|
2011-04-09 16:38:06 -07:00
|
|
|
#include "States.h"
|
2010-04-26 23:52:03 -07:00
|
|
|
|
|
|
|
// NOTE: alphabetically ordered
|
2011-08-09 18:44:00 -07:00
|
|
|
#include "nsIAccessibleRelation.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
#include "nsIDocument.h"
|
|
|
|
#include "nsIDOMXULSelectCntrlEl.h"
|
|
|
|
#include "nsIDOMXULSelectCntrlItemEl.h"
|
2010-05-14 02:55:00 -07:00
|
|
|
#include "nsIDOMXULRelatedElement.h"
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2011-07-27 05:43:01 -07:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2010-01-18 20:35:08 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULTabAccessible
|
2010-01-18 20:35:08 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTabAccessible::
|
|
|
|
XULTabAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2010-01-18 20:35:08 -08:00
|
|
|
{
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2010-01-18 20:35:08 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULTabAccessible: nsIAccessible
|
2010-01-18 20:35:08 -08:00
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTabAccessible::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
|
|
|
}
|
|
|
|
|
|
|
|
/** Return the name of our only action */
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTabAccessible::GetActionName(uint8_t aIndex, nsAString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (aIndex == eAction_Switch) {
|
|
|
|
aName.AssignLiteral("switch");
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2008-10-01 23:49:45 -07:00
|
|
|
/** Tell the tab to do its action */
|
2012-06-10 16:44:50 -07:00
|
|
|
NS_IMETHODIMP
|
2012-08-22 08:56:38 -07:00
|
|
|
XULTabAccessible::DoAction(uint8_t index)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
if (index == eAction_Switch) {
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMXULElement> tab(do_QueryInterface(mContent));
|
2007-03-22 10:30:00 -07:00
|
|
|
if ( tab )
|
|
|
|
{
|
|
|
|
tab->Click();
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2010-01-18 20:35:08 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULTabAccessible: Accessible
|
2010-01-18 20:35:08 -08:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTabAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::PAGETAB;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTabAccessible::NativeState()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2010-01-18 20:35:08 -08:00
|
|
|
// Possible states: focused, focusable, unavailable(disabled), offscreen.
|
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
// get focus and disable status from base class
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = AccessibleWrap::NativeState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
2013-06-05 08:03:52 -07:00
|
|
|
// Check whether the tab is selected and/or pinned
|
2010-06-11 01:23:18 -07:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> tab(do_QueryInterface(mContent));
|
2007-03-22 10:30:00 -07:00
|
|
|
if (tab) {
|
2011-09-28 23:19:26 -07:00
|
|
|
bool selected = false;
|
2007-03-22 10:30:00 -07:00
|
|
|
if (NS_SUCCEEDED(tab->GetSelected(&selected)) && selected)
|
2011-04-09 16:38:06 -07:00
|
|
|
state |= states::SELECTED;
|
2013-06-05 08:03:52 -07:00
|
|
|
|
2013-06-10 07:43:18 -07:00
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::pinned,
|
2013-06-05 08:03:52 -07:00
|
|
|
nsGkAtoms::_true, eCaseMatters))
|
|
|
|
state |= states::PINNED;
|
2013-06-10 07:43:18 -07:00
|
|
|
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2013-06-05 08:03:52 -07:00
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
return state;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTabAccessible::NativeInteractiveState() const
|
2012-06-03 22:41:06 -07:00
|
|
|
{
|
2012-08-22 08:56:38 -07:00
|
|
|
uint64_t state = Accessible::NativeInteractiveState();
|
2012-06-03 22:41:06 -07:00
|
|
|
return (state & states::UNAVAILABLE) ? state : state | states::SELECTABLE;
|
|
|
|
}
|
|
|
|
|
2010-01-18 20:35:08 -08:00
|
|
|
// nsIAccessible
|
2011-08-09 18:44:00 -07:00
|
|
|
Relation
|
2013-10-19 11:19:50 -07:00
|
|
|
XULTabAccessible::RelationByType(RelationType aType)
|
2007-11-11 22:02:42 -08:00
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
Relation rel = AccessibleWrap::RelationByType(aType);
|
2013-10-19 11:19:50 -07:00
|
|
|
if (aType != RelationType::LABEL_FOR)
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-11-11 22:02:42 -08:00
|
|
|
|
|
|
|
// Expose 'LABEL_FOR' relation on tab accessible for tabpanel accessible.
|
2010-05-14 02:55:00 -07:00
|
|
|
nsCOMPtr<nsIDOMXULRelatedElement> tabsElm =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent->GetParent());
|
2010-05-14 02:55:00 -07:00
|
|
|
if (!tabsElm)
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-11-11 22:02:42 -08:00
|
|
|
|
2012-02-07 05:18:33 -08:00
|
|
|
nsCOMPtr<nsIDOMNode> domNode(DOMNode());
|
2010-05-14 02:55:00 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> tabpanelNode;
|
2012-02-07 05:18:33 -08:00
|
|
|
tabsElm->GetRelatedElement(domNode, getter_AddRefs(tabpanelNode));
|
2010-05-14 02:55:00 -07:00
|
|
|
if (!tabpanelNode)
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-11-11 22:02:42 -08:00
|
|
|
|
2010-05-14 02:55:00 -07:00
|
|
|
nsCOMPtr<nsIContent> tabpanelContent(do_QueryInterface(tabpanelNode));
|
2012-05-07 17:00:29 -07:00
|
|
|
rel.AppendTarget(mDoc, tabpanelContent);
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-11-11 22:02:42 -08:00
|
|
|
}
|
|
|
|
|
2007-03-27 05:17:11 -07:00
|
|
|
|
2010-01-06 02:36:50 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULTabsAccessible
|
2010-01-06 02:36:50 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-27 05:17:11 -07:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTabsAccessible::
|
|
|
|
XULTabsAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-02-07 14:38:54 -08:00
|
|
|
XULSelectControlAccessible(aContent, aDoc)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTabsAccessible::NativeRole()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::PAGETABLIST;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-08-22 08:56:38 -07:00
|
|
|
uint8_t
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTabsAccessible::ActionCount()
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2011-06-05 12:35:43 -07:00
|
|
|
return 0;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-04-09 02:48:41 -07:00
|
|
|
void
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTabsAccessible::Value(nsString& aValue)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2012-04-09 02:48:41 -07:00
|
|
|
aValue.Truncate();
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
|
|
|
|
2012-10-13 21:18:39 -07:00
|
|
|
ENameValueFlag
|
|
|
|
XULTabsAccessible::NativeName(nsString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-10-10 05:26:55 -07:00
|
|
|
// no name
|
2012-10-13 21:18:39 -07:00
|
|
|
return eNameOK;
|
2007-03-22 10:30:00 -07:00
|
|
|
}
|
2007-11-11 22:02:42 -08:00
|
|
|
|
2010-05-14 02:55:00 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-12-28 00:15:02 -08:00
|
|
|
// XULTabpanelsAccessible
|
2010-05-14 02:55:00 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-12-28 00:15:02 -08:00
|
|
|
XULTabpanelsAccessible::NativeRole()
|
2010-05-14 02:55:00 -07:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::PANE;
|
2010-05-14 02:55:00 -07:00
|
|
|
}
|
|
|
|
|
2007-11-11 22:02:42 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:44:50 -07:00
|
|
|
// XULTabpanelAccessible
|
2010-05-14 02:55:00 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-11-11 22:02:42 -08:00
|
|
|
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTabpanelAccessible::
|
|
|
|
XULTabpanelAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2007-11-11 22:02:42 -08:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-10 16:44:50 -07:00
|
|
|
XULTabpanelAccessible::NativeRole()
|
2007-11-11 22:02:42 -08:00
|
|
|
{
|
2012-01-11 19:07:35 -08:00
|
|
|
return roles::PROPERTYPAGE;
|
2007-11-11 22:02:42 -08:00
|
|
|
}
|
|
|
|
|
2011-08-09 18:44:00 -07:00
|
|
|
Relation
|
2013-10-19 11:19:50 -07:00
|
|
|
XULTabpanelAccessible::RelationByType(RelationType aType)
|
2007-11-11 22:02:42 -08:00
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
Relation rel = AccessibleWrap::RelationByType(aType);
|
2013-10-19 11:19:50 -07:00
|
|
|
if (aType != RelationType::LABELLED_BY)
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-11-11 22:02:42 -08:00
|
|
|
|
|
|
|
// Expose 'LABELLED_BY' relation on tabpanel accessible for tab accessible.
|
2010-05-14 02:55:00 -07:00
|
|
|
nsCOMPtr<nsIDOMXULRelatedElement> tabpanelsElm =
|
2010-06-11 01:23:18 -07:00
|
|
|
do_QueryInterface(mContent->GetParent());
|
2010-05-14 02:55:00 -07:00
|
|
|
if (!tabpanelsElm)
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-11-11 22:02:42 -08:00
|
|
|
|
2012-02-07 05:18:33 -08:00
|
|
|
nsCOMPtr<nsIDOMNode> domNode(DOMNode());
|
2010-05-14 02:55:00 -07:00
|
|
|
nsCOMPtr<nsIDOMNode> tabNode;
|
2012-02-07 05:18:33 -08:00
|
|
|
tabpanelsElm->GetRelatedElement(domNode, getter_AddRefs(tabNode));
|
2010-05-14 02:55:00 -07:00
|
|
|
if (!tabNode)
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-11-11 22:02:42 -08:00
|
|
|
|
2010-05-14 02:55:00 -07:00
|
|
|
nsCOMPtr<nsIContent> tabContent(do_QueryInterface(tabNode));
|
2012-05-07 17:00:29 -07:00
|
|
|
rel.AppendTarget(mDoc, tabContent);
|
2011-08-09 18:44:00 -07:00
|
|
|
return rel;
|
2007-11-11 22:02:42 -08:00
|
|
|
}
|