2001-12-17 01:21:29 +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-12-17 01:21:29 +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-12-17 01:21:29 +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-12-17 01:21:29 +00:00
|
|
|
* Netscape Communications Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 1998
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s):
|
2004-04-17 21:52:36 +00:00
|
|
|
* Author: John Gaunt (jgaunt@netscape.com)
|
2001-12-17 01:21:29 +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-12-17 01:21:29 +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-12-17 01:21:29 +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-12-17 01:21:29 +00:00
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
#include "nsXULTabAccessible.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
|
2011-08-10 01:44:00 +00:00
|
|
|
#include "nsIAccessibleRelation.h"
|
2002-07-02 17:39:40 +00:00
|
|
|
#include "nsIDocument.h"
|
2003-04-15 08:45:55 +00:00
|
|
|
#include "nsIFrame.h"
|
2002-07-02 17:39:40 +00:00
|
|
|
#include "nsIDOMDocument.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
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTabAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsXULTabAccessible::
|
2012-02-07 22:38:54 +00:00
|
|
|
nsXULTabAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
|
|
|
|
nsAccessibleWrap(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
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTabAccessible: nsIAccessible
|
|
|
|
|
2011-06-05 19:35:43 +00:00
|
|
|
PRUint8
|
|
|
|
nsXULTabAccessible::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
|
|
|
}
|
|
|
|
|
|
|
|
/** Return the name of our only action */
|
2007-02-25 03:43:20 +00:00
|
|
|
NS_IMETHODIMP nsXULTabAccessible::GetActionName(PRUint8 aIndex, nsAString& aName)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2007-02-25 03:43:20 +00:00
|
|
|
if (aIndex == eAction_Switch) {
|
|
|
|
aName.AssignLiteral("switch");
|
2001-12-17 01:21:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2008-10-02 06:49:45 +00:00
|
|
|
/** Tell the tab to do its action */
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabAccessible::DoAction(PRUint8 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));
|
2001-12-17 01:21:29 +00:00
|
|
|
if ( tab )
|
|
|
|
{
|
2002-06-21 04:41:28 +00:00
|
|
|
tab->Click();
|
2001-12-17 01:21:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
return NS_ERROR_INVALID_ARG;
|
|
|
|
}
|
|
|
|
|
2010-01-19 04:35:08 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTabAccessible: nsAccessible
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
role
|
2010-09-05 02:14:01 +00:00
|
|
|
nsXULTabAccessible::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
|
|
|
}
|
|
|
|
|
2011-04-09 23:38:06 +00:00
|
|
|
PRUint64
|
|
|
|
nsXULTabAccessible::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
|
2011-04-09 23:38:06 +00:00
|
|
|
PRUint64 state = nsAccessibleWrap::NativeState();
|
2002-06-21 04:41:28 +00:00
|
|
|
|
|
|
|
// In the past, tabs have been focusable in classic theme
|
|
|
|
// They may be again in the future
|
|
|
|
// Check style for -moz-user-focus: normal to see if it's focusable
|
2011-04-09 23:38:06 +00:00
|
|
|
state &= ~states::FOCUSABLE;
|
2010-06-11 08:23:18 +00:00
|
|
|
|
|
|
|
nsIFrame *frame = mContent->GetPrimaryFrame();
|
|
|
|
if (frame) {
|
|
|
|
const nsStyleUserInterface* ui = frame->GetStyleUserInterface();
|
|
|
|
if (ui->mUserFocus == NS_STYLE_USER_FOCUS_NORMAL)
|
2011-04-09 23:38:06 +00:00
|
|
|
state |= states::FOCUSABLE;
|
2002-06-21 04:41:28 +00:00
|
|
|
}
|
2010-06-11 08:23:18 +00:00
|
|
|
|
2005-02-01 03:43:37 +00:00
|
|
|
// Check whether the tab is selected
|
2011-04-09 23:38:06 +00:00
|
|
|
state |= states::SELECTABLE;
|
|
|
|
state &= ~states::SELECTED;
|
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;
|
2005-02-01 03:43:37 +00:00
|
|
|
}
|
2011-04-09 23:38:06 +00:00
|
|
|
return state;
|
2001-12-17 01:21:29 +00:00
|
|
|
}
|
|
|
|
|
2010-01-19 04:35:08 +00:00
|
|
|
// nsIAccessible
|
2011-08-10 01:44:00 +00:00
|
|
|
Relation
|
|
|
|
nsXULTabAccessible::RelationByType(PRUint32 aType)
|
2007-11-12 06:02:42 +00:00
|
|
|
{
|
2011-08-10 01:44:00 +00:00
|
|
|
Relation rel = nsAccessibleWrap::RelationByType(aType);
|
|
|
|
if (aType != nsIAccessibleRelation::RELATION_LABEL_FOR)
|
|
|
|
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));
|
2011-08-10 01:44:00 +00:00
|
|
|
rel.AppendTarget(tabpanelContent);
|
|
|
|
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
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2010-05-14 09:55:00 +00:00
|
|
|
// nsXULTabsAccessible
|
2010-01-06 10:36:50 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-03-27 12:17:11 +00:00
|
|
|
|
2010-05-14 09:55:00 +00:00
|
|
|
nsXULTabsAccessible::
|
2012-02-07 22:38:54 +00:00
|
|
|
nsXULTabsAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
|
|
|
|
XULSelectControlAccessible(aContent, aDoc)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
role
|
2010-09-05 02:14:01 +00:00
|
|
|
nsXULTabsAccessible::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
|
|
|
|
2011-06-05 19:35:43 +00:00
|
|
|
PRUint8
|
|
|
|
nsXULTabsAccessible::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
|
|
|
|
nsXULTabsAccessible::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
|
|
|
}
|
|
|
|
|
2008-10-10 12:26:55 +00:00
|
|
|
nsresult
|
|
|
|
nsXULTabsAccessible::GetNameInternal(nsAString& aName)
|
2003-06-02 08:32:46 +00:00
|
|
|
{
|
2008-10-10 12:26:55 +00:00
|
|
|
// no name
|
2003-06-02 08:32:46 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2007-11-12 06:02:42 +00:00
|
|
|
|
2010-05-14 09:55:00 +00:00
|
|
|
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTabpanelsAccessible
|
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
nsXULTabpanelsAccessible::
|
2012-02-07 22:38:54 +00:00
|
|
|
nsXULTabpanelsAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
|
|
|
|
nsAccessibleWrap(aContent, aDoc)
|
2010-05-14 09:55:00 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
role
|
2010-09-05 02:14:01 +00:00
|
|
|
nsXULTabpanelsAccessible::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
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
|
|
|
// nsXULTabpanelAccessible
|
2010-05-14 09:55:00 +00:00
|
|
|
////////////////////////////////////////////////////////////////////////////////
|
2007-11-12 06:02:42 +00:00
|
|
|
|
|
|
|
nsXULTabpanelAccessible::
|
2012-02-07 22:38:54 +00:00
|
|
|
nsXULTabpanelAccessible(nsIContent* aContent, nsDocAccessible* aDoc) :
|
|
|
|
nsAccessibleWrap(aContent, aDoc)
|
2007-11-12 06:02:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2012-01-12 03:07:35 +00:00
|
|
|
role
|
2010-09-05 02:14:01 +00:00
|
|
|
nsXULTabpanelAccessible::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
|
|
|
|
nsXULTabpanelAccessible::RelationByType(PRUint32 aType)
|
2007-11-12 06:02:42 +00:00
|
|
|
{
|
2011-08-10 01:44:00 +00:00
|
|
|
Relation rel = nsAccessibleWrap::RelationByType(aType);
|
|
|
|
if (aType != nsIAccessibleRelation::RELATION_LABELLED_BY)
|
|
|
|
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));
|
2011-08-10 01:44:00 +00:00
|
|
|
rel.AppendTarget(tabContent);
|
|
|
|
return rel;
|
2007-11-12 06:02:42 +00:00
|
|
|
}
|