2001-12-17 01:21:29 +00:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
2012-05-21 11:12:37 +00: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/. */
|
2001-12-17 01:21:29 +00:00
|
|
|
|
2012-06-10 23:44:50 +00:00
|
|
|
#include "XULTabAccessible.h"
|
2010-04-27 06:52:03 +00:00
|
|
|
|
|
|
|
#include "nsAccUtils.h"
|
2011-08-10 01:44:00 +00:00
|
|
|
#include "Relation.h"
|
2012-01-12 03:07:35 +00:00
|
|
|
#include "Role.h"
|
2011-04-09 23:38:06 +00:00
|
|
|
#include "States.h"
|
2010-04-27 06:52:03 +00:00
|
|
|
|
|
|
|
// NOTE: alphabetically ordered
|
2002-07-02 17:39:40 +00:00
|
|
|
#include "nsIDocument.h"
|
2001-12-17 01:21:29 +00:00
|
|
|
#include "nsIDOMXULSelectCntrlEl.h"
|
|
|
|
#include "nsIDOMXULSelectCntrlItemEl.h"
|
2010-05-14 09:55:00 +00:00
|
|
|
#include "nsIDOMXULRelatedElement.h"
|
2001-12-17 01:21:29 +00:00
|
|
|
|
2011-07-27 12:43:01 +00:00
|
|
|
using namespace mozilla::a11y;
|
|
|
|
|
2010-01-19 04:35:08 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 23:44:50 +00:00
|
|
|
// XULTabAccessible
|
2010-01-19 04:35:08 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-10 23:44:50 +00:00
|
|
|
XULTabAccessible::
|
|
|
|
XULTabAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2010-01-19 04:35:08 +00:00
|
|
|
{
|
2001-12-17 01:21:29 +00:00
|
|
|
}
|
|
|
|
|
2010-01-19 04:35:08 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2014-10-22 00:49:28 +00:00
|
|
|
// XULTabAccessible: Accessible
|
2010-01-19 04:35:08 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t
|
2012-06-10 23:44:50 +00:00
|
|
|
XULTabAccessible::ActionCount()
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2011-06-05 19:35:43 +00:00
|
|
|
return 1;
|
2001-12-17 01:21:29 +00:00
|
|
|
}
|
|
|
|
|
2014-09-16 17:30:23 +00:00
|
|
|
void
|
|
|
|
XULTabAccessible::ActionNameAt(uint8_t aIndex, nsAString& aName)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2014-09-16 17:30:23 +00:00
|
|
|
if (aIndex == eAction_Switch)
|
|
|
|
aName.AssignLiteral("switch");
|
2001-12-17 01:21:29 +00:00
|
|
|
}
|
|
|
|
|
2014-09-16 17:30:23 +00:00
|
|
|
bool
|
2012-08-22 15:56:38 +00:00
|
|
|
XULTabAccessible::DoAction(uint8_t index)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
|
|
|
if (index == eAction_Switch) {
|
2010-06-11 08:23:18 +00:00
|
|
|
nsCOMPtr<nsIDOMXULElement> tab(do_QueryInterface(mContent));
|
2014-09-16 17:30:23 +00:00
|
|
|
if (tab) {
|
2002-06-21 04:41:28 +00:00
|
|
|
tab->Click();
|
2014-09-16 17:30:23 +00:00
|
|
|
return true;
|
2001-12-17 01:21:29 +00:00
|
|
|
}
|
|
|
|
}
|
2014-09-16 17:30:23 +00:00
|
|
|
return false;
|
2001-12-17 01:21:29 +00:00
|
|
|
}
|
|
|
|
|
2010-01-19 04:35:08 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 23:44:50 +00:00
|
|
|
// XULTabAccessible: Accessible
|
2010-01-19 04:35:08 +00:00
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
role
|
2012-06-10 23:44:50 +00:00
|
|
|
XULTabAccessible::NativeRole()
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2012-01-12 03:07:35 +00:00
|
|
|
return roles::PAGETAB;
|
2001-12-17 01:21:29 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t
|
2012-06-10 23:44:50 +00:00
|
|
|
XULTabAccessible::NativeState()
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2010-01-19 04:35:08 +00:00
|
|
|
// Possible states: focused, focusable, unavailable(disabled), offscreen.
|
|
|
|
|
2001-12-17 01:21:29 +00:00
|
|
|
// get focus and disable status from base class
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t state = AccessibleWrap::NativeState();
|
2002-06-21 04:41:28 +00:00
|
|
|
|
2013-06-05 15:03:52 +00:00
|
|
|
// Check whether the tab is selected and/or pinned
|
2010-06-11 08:23:18 +00:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> tab(do_QueryInterface(mContent));
|
2005-02-01 03:43:37 +00:00
|
|
|
if (tab) {
|
2011-09-29 06:19:26 +00:00
|
|
|
bool selected = false;
|
2005-02-01 03:43:37 +00:00
|
|
|
if (NS_SUCCEEDED(tab->GetSelected(&selected)) && selected)
|
2011-04-09 23:38:06 +00:00
|
|
|
state |= states::SELECTED;
|
2013-06-05 15:03:52 +00:00
|
|
|
|
2013-06-10 14:43:18 +00:00
|
|
|
if (mContent->AttrValueIs(kNameSpaceID_None, nsGkAtoms::pinned,
|
2013-06-05 15:03:52 +00:00
|
|
|
nsGkAtoms::_true, eCaseMatters))
|
|
|
|
state |= states::PINNED;
|
2013-06-10 14:43:18 +00:00
|
|
|
|
2005-02-01 03:43:37 +00:00
|
|
|
}
|
2013-06-05 15:03:52 +00:00
|
|
|
|
2011-04-09 23:38:06 +00:00
|
|
|
return state;
|
2001-12-17 01:21:29 +00:00
|
|
|
}
|
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t
|
2012-06-10 23:44:50 +00:00
|
|
|
XULTabAccessible::NativeInteractiveState() const
|
2012-06-04 05:41:06 +00:00
|
|
|
{
|
2012-08-22 15:56:38 +00:00
|
|
|
uint64_t state = Accessible::NativeInteractiveState();
|
2012-06-04 05:41:06 +00:00
|
|
|
return (state & states::UNAVAILABLE) ? state : state | states::SELECTABLE;
|
|
|
|
}
|
|
|
|
|
2011-08-10 01:44:00 +00:00
|
|
|
Relation
|
2013-10-19 18:19:50 +00:00
|
|
|
XULTabAccessible::RelationByType(RelationType aType)
|
2007-11-12 06:02:42 +00:00
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
Relation rel = AccessibleWrap::RelationByType(aType);
|
2013-10-19 18:19:50 +00:00
|
|
|
if (aType != RelationType::LABEL_FOR)
|
2011-08-10 01:44:00 +00:00
|
|
|
return rel;
|
2007-11-12 06:02:42 +00:00
|
|
|
|
|
|
|
// Expose 'LABEL_FOR' relation on tab accessible for tabpanel accessible.
|
2010-05-14 09:55:00 +00:00
|
|
|
nsCOMPtr<nsIDOMXULRelatedElement> tabsElm =
|
2010-06-11 08:23:18 +00:00
|
|
|
do_QueryInterface(mContent->GetParent());
|
2010-05-14 09:55:00 +00:00
|
|
|
if (!tabsElm)
|
2011-08-10 01:44:00 +00:00
|
|
|
return rel;
|
2007-11-12 06:02:42 +00:00
|
|
|
|
2012-02-07 13:18:33 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> domNode(DOMNode());
|
2010-05-14 09:55:00 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> tabpanelNode;
|
2012-02-07 13:18:33 +00:00
|
|
|
tabsElm->GetRelatedElement(domNode, getter_AddRefs(tabpanelNode));
|
2010-05-14 09:55:00 +00:00
|
|
|
if (!tabpanelNode)
|
2011-08-10 01:44:00 +00:00
|
|
|
return rel;
|
2007-11-12 06:02:42 +00:00
|
|
|
|
2010-05-14 09:55:00 +00:00
|
|
|
nsCOMPtr<nsIContent> tabpanelContent(do_QueryInterface(tabpanelNode));
|
2012-05-08 00:00:29 +00:00
|
|
|
rel.AppendTarget(mDoc, tabpanelContent);
|
2011-08-10 01:44:00 +00:00
|
|
|
return rel;
|
2007-11-12 06:02:42 +00:00
|
|
|
}
|
|
|
|
|
2007-03-27 12:17:11 +00:00
|
|
|
|
2010-01-06 10:36:50 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 23:44:50 +00:00
|
|
|
// XULTabsAccessible
|
2010-01-06 10:36:50 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-27 12:17:11 +00:00
|
|
|
|
2012-06-10 23:44:50 +00:00
|
|
|
XULTabsAccessible::
|
|
|
|
XULTabsAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-02-07 22:38:54 +00:00
|
|
|
XULSelectControlAccessible(aContent, aDoc)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
role
|
2012-06-10 23:44:50 +00:00
|
|
|
XULTabsAccessible::NativeRole()
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2012-01-12 03:07:35 +00:00
|
|
|
return roles::PAGETABLIST;
|
2001-12-17 01:21:29 +00:00
|
|
|
}
|
2003-06-02 08:32:46 +00:00
|
|
|
|
2012-08-22 15:56:38 +00:00
|
|
|
uint8_t
|
2012-06-10 23:44:50 +00:00
|
|
|
XULTabsAccessible::ActionCount()
|
2003-06-02 08:32:46 +00:00
|
|
|
{
|
2011-06-05 19:35:43 +00:00
|
|
|
return 0;
|
2003-06-02 08:32:46 +00:00
|
|
|
}
|
|
|
|
|
2012-04-09 09:48:41 +00:00
|
|
|
void
|
2012-06-10 23:44:50 +00:00
|
|
|
XULTabsAccessible::Value(nsString& aValue)
|
2003-06-02 08:32:46 +00:00
|
|
|
{
|
2012-04-09 09:48:41 +00:00
|
|
|
aValue.Truncate();
|
2003-06-02 08:32:46 +00:00
|
|
|
}
|
|
|
|
|
2012-10-14 04:18:39 +00:00
|
|
|
ENameValueFlag
|
|
|
|
XULTabsAccessible::NativeName(nsString& aName)
|
2003-06-02 08:32:46 +00:00
|
|
|
{
|
2008-10-10 12:26:55 +00:00
|
|
|
// no name
|
2012-10-14 04:18:39 +00:00
|
|
|
return eNameOK;
|
2003-06-02 08:32:46 +00:00
|
|
|
}
|
2007-11-12 06:02:42 +00:00
|
|
|
|
2010-05-14 09:55:00 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-12-28 08:15:02 +00:00
|
|
|
// XULTabpanelsAccessible
|
2010-05-14 09:55:00 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
role
|
2012-12-28 08:15:02 +00:00
|
|
|
XULTabpanelsAccessible::NativeRole()
|
2010-05-14 09:55:00 +00:00
|
|
|
{
|
2012-01-12 03:07:35 +00:00
|
|
|
return roles::PANE;
|
2010-05-14 09:55:00 +00:00
|
|
|
}
|
|
|
|
|
2007-11-12 06:02:42 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 23:44:50 +00:00
|
|
|
// XULTabpanelAccessible
|
2010-05-14 09:55:00 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-11-12 06:02:42 +00:00
|
|
|
|
2012-06-10 23:44:50 +00:00
|
|
|
XULTabpanelAccessible::
|
|
|
|
XULTabpanelAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-29 01:18:45 +00:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2007-11-12 06:02:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
role
|
2012-06-10 23:44:50 +00:00
|
|
|
XULTabpanelAccessible::NativeRole()
|
2007-11-12 06:02:42 +00:00
|
|
|
{
|
2012-01-12 03:07:35 +00:00
|
|
|
return roles::PROPERTYPAGE;
|
2007-11-12 06:02:42 +00:00
|
|
|
}
|
|
|
|
|
2011-08-10 01:44:00 +00:00
|
|
|
Relation
|
2013-10-19 18:19:50 +00:00
|
|
|
XULTabpanelAccessible::RelationByType(RelationType aType)
|
2007-11-12 06:02:42 +00:00
|
|
|
{
|
2012-05-29 01:18:45 +00:00
|
|
|
Relation rel = AccessibleWrap::RelationByType(aType);
|
2013-10-19 18:19:50 +00:00
|
|
|
if (aType != RelationType::LABELLED_BY)
|
2011-08-10 01:44:00 +00:00
|
|
|
return rel;
|
2007-11-12 06:02:42 +00:00
|
|
|
|
|
|
|
// Expose 'LABELLED_BY' relation on tabpanel accessible for tab accessible.
|
2010-05-14 09:55:00 +00:00
|
|
|
nsCOMPtr<nsIDOMXULRelatedElement> tabpanelsElm =
|
2010-06-11 08:23:18 +00:00
|
|
|
do_QueryInterface(mContent->GetParent());
|
2010-05-14 09:55:00 +00:00
|
|
|
if (!tabpanelsElm)
|
2011-08-10 01:44:00 +00:00
|
|
|
return rel;
|
2007-11-12 06:02:42 +00:00
|
|
|
|
2012-02-07 13:18:33 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> domNode(DOMNode());
|
2010-05-14 09:55:00 +00:00
|
|
|
nsCOMPtr<nsIDOMNode> tabNode;
|
2012-02-07 13:18:33 +00:00
|
|
|
tabpanelsElm->GetRelatedElement(domNode, getter_AddRefs(tabNode));
|
2010-05-14 09:55:00 +00:00
|
|
|
if (!tabNode)
|
2011-08-10 01:44:00 +00:00
|
|
|
return rel;
|
2007-11-12 06:02:42 +00:00
|
|
|
|
2010-05-14 09:55:00 +00:00
|
|
|
nsCOMPtr<nsIContent> tabContent(do_QueryInterface(tabNode));
|
2012-05-08 00:00:29 +00:00
|
|
|
rel.AppendTarget(mDoc, tabContent);
|
2011-08-10 01:44:00 +00:00
|
|
|
return rel;
|
2007-11-12 06:02:42 +00:00
|
|
|
}
|