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:37:47 -07:00
|
|
|
#include "nsXULTabAccessible.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 "nsIFrame.h"
|
|
|
|
#include "nsIDOMDocument.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:37:47 -07:00
|
|
|
// nsXULTabAccessible
|
2010-01-18 20:35:08 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabAccessible::
|
|
|
|
nsXULTabAccessible(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:37:47 -07:00
|
|
|
// nsXULTabAccessible: nsIAccessible
|
2010-01-18 20:35:08 -08:00
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
PRUint8
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabAccessible::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:37:47 -07:00
|
|
|
NS_IMETHODIMP nsXULTabAccessible::GetActionName(PRUint8 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:37:47 -07:00
|
|
|
NS_IMETHODIMP nsXULTabAccessible::DoAction(PRUint8 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:37:47 -07:00
|
|
|
// nsXULTabAccessible: Accessible
|
2010-01-18 20:35:08 -08:00
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabAccessible::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
|
|
|
}
|
|
|
|
|
2011-04-09 16:38:06 -07:00
|
|
|
PRUint64
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabAccessible::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-05-28 18:18:45 -07:00
|
|
|
PRUint64 state = AccessibleWrap::NativeState();
|
2007-03-22 10:30:00 -07:00
|
|
|
|
|
|
|
// Check whether the tab is selected
|
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;
|
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
|
|
|
}
|
|
|
|
|
2012-06-03 22:41:06 -07:00
|
|
|
PRUint64
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabAccessible::NativeInteractiveState() const
|
2012-06-03 22:41:06 -07:00
|
|
|
{
|
|
|
|
PRUint64 state = Accessible::NativeInteractiveState();
|
|
|
|
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
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabAccessible::RelationByType(PRUint32 aType)
|
2007-11-11 22:02:42 -08:00
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
Relation rel = AccessibleWrap::RelationByType(aType);
|
2011-08-09 18:44:00 -07:00
|
|
|
if (aType != nsIAccessibleRelation::RELATION_LABEL_FOR)
|
|
|
|
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:37:47 -07:00
|
|
|
// nsXULTabsAccessible
|
2010-01-06 02:36:50 -08:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-27 05:17:11 -07:00
|
|
|
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabsAccessible::
|
|
|
|
nsXULTabsAccessible(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:37:47 -07:00
|
|
|
nsXULTabsAccessible::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
|
|
|
}
|
|
|
|
|
2011-06-05 12:35:43 -07:00
|
|
|
PRUint8
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabsAccessible::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:37:47 -07:00
|
|
|
nsXULTabsAccessible::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
|
|
|
}
|
|
|
|
|
2008-10-10 05:26:55 -07:00
|
|
|
nsresult
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabsAccessible::GetNameInternal(nsAString& aName)
|
2007-03-22 10:30:00 -07:00
|
|
|
{
|
2008-10-10 05:26:55 -07:00
|
|
|
// no name
|
2007-03-22 10:30:00 -07:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-11-11 22:02:42 -08:00
|
|
|
|
2010-05-14 02:55:00 -07:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2012-06-10 16:37:47 -07:00
|
|
|
// nsXULTabpanelsAccessible
|
2010-05-14 02:55:00 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabpanelsAccessible::
|
|
|
|
nsXULTabpanelsAccessible(nsIContent* aContent, DocAccessible* aDoc) :
|
2012-05-28 18:18:45 -07:00
|
|
|
AccessibleWrap(aContent, aDoc)
|
2010-05-14 02:55:00 -07:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-11 19:07:35 -08:00
|
|
|
role
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabpanelsAccessible::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:37:47 -07:00
|
|
|
// nsXULTabpanelAccessible
|
2010-05-14 02:55:00 -07:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-11-11 22:02:42 -08:00
|
|
|
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabpanelAccessible::
|
|
|
|
nsXULTabpanelAccessible(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:37:47 -07:00
|
|
|
nsXULTabpanelAccessible::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
|
2012-06-10 16:37:47 -07:00
|
|
|
nsXULTabpanelAccessible::RelationByType(PRUint32 aType)
|
2007-11-11 22:02:42 -08:00
|
|
|
{
|
2012-05-28 18:18:45 -07:00
|
|
|
Relation rel = AccessibleWrap::RelationByType(aType);
|
2011-08-09 18:44:00 -07:00
|
|
|
if (aType != nsIAccessibleRelation::RELATION_LABELLED_BY)
|
|
|
|
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
|
|
|
}
|