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 ***** */
|
|
|
|
|
|
|
|
// NOTE: alphabetically ordered
|
|
|
|
#include "nsXULTabAccessible.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"
|
|
|
|
|
|
|
|
/**
|
|
|
|
* XUL Tab
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
nsXULTabAccessible::nsXULTabAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
|
|
|
nsLeafAccessible(aNode, aShell)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Only one action available */
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabAccessible::GetNumActions(PRUint8 *_retval)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2006-07-31 04:31:13 +00:00
|
|
|
*_retval = 1;
|
2001-12-17 01:21:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** 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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Tell the tab to do it's 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) {
|
2004-04-07 16:55:24 +00:00
|
|
|
nsCOMPtr<nsIDOMXULElement> tab(do_QueryInterface(mDOMNode));
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** We are a tab */
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabAccessible::GetRole(PRUint32 *_retval)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*_retval = nsIAccessibleRole::ROLE_PAGETAB;
|
2001-12-17 01:21:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Possible states: focused, focusable, unavailable(disabled), offscreen
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabAccessible::GetState(PRUint32 *_retval)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
|
|
|
// get focus and disable status from base class
|
2003-07-31 08:09:39 +00:00
|
|
|
nsLeafAccessible::GetState(_retval);
|
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
|
2007-03-15 14:18:33 +00:00
|
|
|
*_retval &= ~nsIAccessibleStates::STATE_FOCUSABLE;
|
2002-06-21 04:41:28 +00:00
|
|
|
nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
|
2003-04-15 08:45:55 +00:00
|
|
|
nsCOMPtr<nsIPresShell> presShell(do_QueryReferent(mWeakShell));
|
2002-06-21 04:41:28 +00:00
|
|
|
if (presShell && content) {
|
2005-08-22 22:24:29 +00:00
|
|
|
nsIFrame *frame = presShell->GetPrimaryFrameFor(content);
|
2002-06-21 04:41:28 +00:00
|
|
|
if (frame) {
|
2003-05-15 03:42:21 +00:00
|
|
|
const nsStyleUserInterface* ui = frame->GetStyleUserInterface();
|
2002-06-21 04:41:28 +00:00
|
|
|
if (ui->mUserFocus == NS_STYLE_USER_FOCUS_NORMAL)
|
2007-03-15 14:18:33 +00:00
|
|
|
*_retval |= nsIAccessibleStates::STATE_FOCUSABLE;
|
2002-06-21 04:41:28 +00:00
|
|
|
}
|
|
|
|
}
|
2005-02-01 03:43:37 +00:00
|
|
|
// Check whether the tab is selected
|
2007-03-15 14:18:33 +00:00
|
|
|
*_retval |= nsIAccessibleStates::STATE_SELECTABLE;
|
|
|
|
*_retval &= ~nsIAccessibleStates::STATE_SELECTED;
|
2005-02-01 03:43:37 +00:00
|
|
|
nsCOMPtr<nsIDOMXULSelectControlItemElement> tab(do_QueryInterface(mDOMNode));
|
|
|
|
if (tab) {
|
|
|
|
PRBool selected = PR_FALSE;
|
|
|
|
if (NS_SUCCEEDED(tab->GetSelected(&selected)) && selected)
|
2007-03-15 14:18:33 +00:00
|
|
|
*_retval |= nsIAccessibleStates::STATE_SELECTED;
|
2005-02-01 03:43:37 +00:00
|
|
|
}
|
2001-12-17 01:21:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* XUL TabBox
|
|
|
|
* to facilitate naming of the tabPanels object we will give this the name
|
|
|
|
* of the selected tab in the tabs object.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
nsXULTabBoxAccessible::nsXULTabBoxAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
2003-04-01 20:02:51 +00:00
|
|
|
nsAccessibleWrap(aNode, aShell)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** We are a window*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabBoxAccessible::GetRole(PRUint32 *_retval)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*_retval = nsIAccessibleRole::ROLE_PANE;
|
2001-12-17 01:21:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** Possible states: normal */
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabBoxAccessible::GetState(PRUint32 *_retval)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2004-05-18 03:26:34 +00:00
|
|
|
nsAccessible::GetState(_retval);
|
2007-03-15 14:18:33 +00:00
|
|
|
*_retval &= ~nsIAccessibleStates::STATE_FOCUSABLE;
|
2001-12-17 01:21:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2003-04-15 08:45:55 +00:00
|
|
|
#ifdef NEVER
|
2001-12-17 01:21:29 +00:00
|
|
|
/** 2 children, tabs, tabpanels */
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabBoxAccessible::GetChildCount(PRInt32 *_retval)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
|
|
|
*_retval = 2;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2003-04-15 08:45:55 +00:00
|
|
|
#endif
|
2001-12-17 01:21:29 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* XUL TabPanels
|
|
|
|
* XXX jgaunt -- this has to report the info for the selected child, reachable through
|
|
|
|
* the DOMNode. The TabPanels object has as its children the different
|
|
|
|
* vbox/hbox/whatevers that provide what you look at when you click on
|
|
|
|
* a tab.
|
|
|
|
* Here is how this will work: when asked about an object the tabPanels object will find
|
|
|
|
* out the selected child and create the tabPanel object using the child. That should wrap
|
|
|
|
* any XUL/HTML content in the child, since it is a simple nsAccessible basically.
|
|
|
|
* or maybe we just do that on creation. Not use the DOMnode we are given, but cache the selected
|
|
|
|
* DOMnode and then run from there.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
nsXULTabPanelsAccessible::nsXULTabPanelsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
2003-04-15 08:45:55 +00:00
|
|
|
nsAccessibleWrap(aNode, aShell)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** We are a Property Page */
|
2006-08-02 14:40:32 +00:00
|
|
|
NS_IMETHODIMP nsXULTabPanelsAccessible::GetRole(PRUint32 *aRole)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*aRole = nsIAccessibleRole::ROLE_PROPERTYPAGE;
|
2001-12-17 01:21:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2002-06-21 04:41:28 +00:00
|
|
|
* Possible values: unavailable
|
2001-12-17 01:21:29 +00:00
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabPanelsAccessible::GetState(PRUint32 *_retval)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
|
|
|
// get focus and disable status from base class -- skip container because we have state
|
2003-07-31 08:09:39 +00:00
|
|
|
nsAccessible::GetState(_retval);
|
2001-12-17 01:21:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The name for the panel is the name from the tab associated with
|
|
|
|
* the panel. XXX not sure if the "panels" object should have the
|
|
|
|
* same name.
|
|
|
|
*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabPanelsAccessible::GetName(nsAString& _retval)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
|
|
|
return NS_ERROR_NOT_IMPLEMENTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* XUL Tabs - the s really stands for strip. this is a collection of tab objects
|
|
|
|
*/
|
|
|
|
|
|
|
|
/** Constructor */
|
|
|
|
nsXULTabsAccessible::nsXULTabsAccessible(nsIDOMNode* aNode, nsIWeakReference* aShell):
|
2005-02-01 03:43:37 +00:00
|
|
|
nsXULSelectableAccessible(aNode, aShell)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
/** We are a Page Tab List */
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabsAccessible::GetRole(PRUint32 *_retval)
|
2001-12-17 01:21:29 +00:00
|
|
|
{
|
2007-03-15 02:26:13 +00:00
|
|
|
*_retval = nsIAccessibleRole::ROLE_PAGETABLIST;
|
2001-12-17 01:21:29 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2003-06-02 08:32:46 +00:00
|
|
|
|
|
|
|
/** no actions */
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabsAccessible::GetNumActions(PRUint8 *_retval)
|
2003-06-02 08:32:46 +00:00
|
|
|
{
|
2006-07-31 04:31:13 +00:00
|
|
|
*_retval = 0;
|
2003-06-02 08:32:46 +00:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** no state -- normal */
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabsAccessible::GetState(PRUint32 *_retval)
|
2003-06-02 08:32:46 +00:00
|
|
|
{
|
2004-05-18 03:26:34 +00:00
|
|
|
return nsAccessible::GetState(_retval);
|
2003-06-02 08:32:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/** no value */
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabsAccessible::GetValue(nsAString& _retval)
|
2003-06-02 08:32:46 +00:00
|
|
|
{
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/** no name*/
|
2003-07-31 08:09:39 +00:00
|
|
|
NS_IMETHODIMP nsXULTabsAccessible::GetName(nsAString& _retval)
|
2003-06-02 08:32:46 +00:00
|
|
|
{
|
|
|
|
_retval.Truncate();
|
|
|
|
return NS_OK;
|
|
|
|
}
|