mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-02-13 11:38:16 +00:00
bug 286029. Fixes for tree accessibility. r=pkw, sr=Neil
This commit is contained in:
parent
82d21b3017
commit
06d061747b
@ -83,7 +83,7 @@
|
||||
#include "nsXULSelectAccessible.h"
|
||||
#include "nsXULTabAccessibleWrap.h"
|
||||
#include "nsXULTextAccessible.h"
|
||||
#include "nsXULTreeAccessible.h"
|
||||
#include "nsXULTreeAccessibleWrap.h"
|
||||
#endif
|
||||
|
||||
// For native window support for object/embed/applet tags
|
||||
@ -97,7 +97,6 @@
|
||||
#include "nsHTMLFormControlAccessibleWrap.h"
|
||||
#include "nsHTMLTableAccessibleWrap.h"
|
||||
#include "nsXULFormControlAccessibleWrap.h"
|
||||
#include "nsXULTreeAccessibleWrap.h"
|
||||
#endif
|
||||
|
||||
nsAccessibilityService *nsAccessibilityService::gAccessibilityService = nsnull;
|
||||
|
@ -103,7 +103,10 @@ NS_IMETHODIMP nsOuterDocAccessible::GetBounds(PRInt32 *x, PRInt32 *y,
|
||||
|
||||
NS_IMETHODIMP nsOuterDocAccessible::Init()
|
||||
{
|
||||
nsresult rv = nsAccessibleWrap::Init();
|
||||
nsresult rv = nsAccessibleWrap::Init();
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
|
||||
// We're in the accessibility cache now
|
||||
// In these variable names, "outer" relates to the nsOuterDocAccessible
|
||||
|
@ -72,6 +72,7 @@ EXPORTS = \
|
||||
nsDocAccessibleWrap.h \
|
||||
nsRootAccessibleWrap.h \
|
||||
nsXULTabAccessibleWrap.h \
|
||||
nsXULTreeAccessibleWrap.h \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
@ -58,9 +58,6 @@ typedef class nsHTMLTextFieldAccessible nsHTMLTextFieldAccessibleWrap;
|
||||
typedef class nsHTMLLinkAccessible nsHTMLLinkAccessibleWrap;
|
||||
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
|
||||
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
|
||||
typedef class nsXULTreeAccessible nsXULTreeAccessibleWrap;
|
||||
typedef class nsXULTreeColumnsAccessible nsXULTreeColumnsAccessibleWrap;
|
||||
typedef class nsXULTreeitemAccessible nsXULTreeitemAccessibleWrap;
|
||||
typedef class nsXULProgressMeterAccessible nsXULProgressMeterAccessibleWrap;
|
||||
typedef class nsXULTextFieldAccessible nsXULTextFieldAccessibleWrap;
|
||||
|
||||
|
46
accessible/src/mac/nsXULTreeAccessibleWrap.h
Executable file
46
accessible/src/mac/nsXULTreeAccessibleWrap.h
Executable file
@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Author: Aaron Leventhal (aleventh@us.ibm.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* 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"),
|
||||
* 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
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* 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
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsXULTreeAccessibleWrap_h__
|
||||
#define __nsXULTreeAccessibleWrap_h__
|
||||
|
||||
#include "nsXULTreeitemAccessible.h"
|
||||
typedef class nsXULTreeAccessible nsXULTreeAccessibleWrap;
|
||||
typedef class nsXULTreeitemAccessible nsXULTreeitemAccessibleWrap;
|
||||
typedef class nsXULTreeColumnsAccessible nsXULTreeColumnsAccessibleWrap;
|
||||
|
||||
#endif
|
@ -199,8 +199,6 @@ typedef class nsHTMLTextFieldAccessible nsHTMLTextFieldAccessibleWrap;
|
||||
typedef class nsHTMLLinkAccessible nsHTMLLinkAccessibleWrap;
|
||||
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
|
||||
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
|
||||
typedef class nsXULTreeAccessible nsXULTreeAccessibleWrap;
|
||||
typedef class nsXULTreeColumnsAccessible nsXULTreeColumnsAccessibleWrap;
|
||||
typedef class nsXULProgressMeterAccessible nsXULProgressMeterAccessibleWrap;
|
||||
typedef class nsXULTextFieldAccessible nsXULTextFieldAccessibleWrap;
|
||||
|
||||
|
@ -39,6 +39,33 @@
|
||||
|
||||
#include "nsXULTreeAccessibleWrap.h"
|
||||
#include "nsTextFormatter.h"
|
||||
#include "nsIFrame.h"
|
||||
|
||||
// --------------------------------------------------------
|
||||
// nsXULTreeAccessibleWrap
|
||||
// --------------------------------------------------------
|
||||
|
||||
nsXULTreeAccessibleWrap::nsXULTreeAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell):
|
||||
nsXULTreeAccessible(aDOMNode, aShell)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTreeAccessibleWrap::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
NS_ASSERTION(mTree, "No tree view");
|
||||
|
||||
nsCOMPtr<nsITreeColumns> cols;
|
||||
mTree->GetColumns(getter_AddRefs(cols));
|
||||
nsCOMPtr<nsITreeColumn> primaryCol;
|
||||
if (cols) {
|
||||
cols->GetPrimaryColumn(getter_AddRefs(primaryCol));
|
||||
}
|
||||
// No primary column means we're in a list
|
||||
// In fact, history and mail turn off the primary flag when switching to a flat view
|
||||
*aRole = primaryCol ? ROLE_OUTLINE : ROLE_LIST;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// nsXULTreeitemAccessibleWrap Accessible
|
||||
@ -53,9 +80,52 @@ nsXULTreeitemAccessible(aParent, aDOMNode, aShell, aRow, aColumn)
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetRole(PRUint32 *_retval)
|
||||
NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
*_retval = ROLE_OUTLINEITEM;
|
||||
// No primary column means we're in a list
|
||||
// In fact, history and mail turn off the primary flag when switching to a flat view
|
||||
NS_ASSERTION(mColumn, "mColumn is null");
|
||||
PRBool isPrimary = PR_FALSE;
|
||||
mColumn->GetPrimary(&isPrimary);
|
||||
*aRole = isPrimary ? ROLE_OUTLINEITEM : ROLE_LISTITEM;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height)
|
||||
{
|
||||
nsresult rv = nsXULTreeitemAccessible::GetBounds(x, y, width, height);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsIFrame *frame = GetFrame();
|
||||
if (frame) {
|
||||
// Will subtract first cell's start x from total width
|
||||
PRInt32 cellStartX, cellStartY;
|
||||
mTree->GetCoordsForCellItem(mRow, mColumn, EmptyCString(), &cellStartX, &cellStartY, width, height);
|
||||
// Use entire row width, not just key column's width
|
||||
float t2p = GetPresContext()->TwipsToPixels();
|
||||
*width = NSTwipsToIntPixels(frame->GetRect().width, t2p) - cellStartX;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetName(nsAString& aName)
|
||||
{
|
||||
nsCOMPtr<nsITreeColumns> cols;
|
||||
mTree->GetColumns(getter_AddRefs(cols));
|
||||
if (!cols) {
|
||||
return NS_OK;
|
||||
}
|
||||
nsCOMPtr<nsITreeColumn> column;
|
||||
cols->GetFirstColumn(getter_AddRefs(column));
|
||||
while (column) {
|
||||
nsAutoString colText;
|
||||
mTreeView->GetCellText(mRow, column, colText);
|
||||
aName += colText + NS_LITERAL_STRING(" ");
|
||||
nsCOMPtr<nsITreeColumn> nextColumn;
|
||||
column->GetNext(getter_AddRefs(nextColumn));
|
||||
column = nextColumn;
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -67,8 +137,10 @@ NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetDescription(nsAString& aDescriptio
|
||||
|
||||
aDescription.Truncate();
|
||||
|
||||
PRInt32 level = 0;
|
||||
mTreeView->GetLevel(mRow, &level);
|
||||
PRInt32 level;
|
||||
if (NS_FAILED(mTreeView->GetLevel(mRow, &level))) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
PRInt32 testRow = -1;
|
||||
if (level > 0) {
|
||||
@ -81,7 +153,7 @@ NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetDescription(nsAString& aDescriptio
|
||||
PRInt32 indexInParent = 0, numSiblings = 0;
|
||||
|
||||
while (++ testRow < numRows) {
|
||||
PRInt32 testLevel;
|
||||
PRInt32 testLevel = 0;
|
||||
mTreeView->GetLevel(testRow, &testLevel);
|
||||
if (testLevel == level) {
|
||||
if (testRow <= mRow) {
|
||||
@ -98,3 +170,4 @@ NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetDescription(nsAString& aDescriptio
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -42,13 +42,25 @@
|
||||
|
||||
#include "nsXULTreeAccessible.h"
|
||||
|
||||
typedef class nsXULTreeColumnsAccessible nsXULTreeColumnsAccessibleWrap;
|
||||
|
||||
class nsXULTreeAccessibleWrap : public nsXULTreeAccessible
|
||||
{
|
||||
public:
|
||||
nsXULTreeAccessibleWrap(nsIDOMNode *aDOMNode, nsIWeakReference *aShell);
|
||||
virtual ~nsXULTreeAccessibleWrap() {}
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole);
|
||||
};
|
||||
|
||||
class nsXULTreeitemAccessibleWrap : public nsXULTreeitemAccessible
|
||||
{
|
||||
public:
|
||||
nsXULTreeitemAccessibleWrap(nsIAccessible *aParent, nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
|
||||
PRInt32 aRow, nsITreeColumn* aColumn);
|
||||
virtual ~nsXULTreeitemAccessibleWrap() {}
|
||||
NS_IMETHOD GetBounds(PRInt32 *x, PRInt32 *y, PRInt32 *width, PRInt32 *height);
|
||||
NS_IMETHOD GetRole(PRUint32 *aRole);
|
||||
NS_IMETHOD GetName(nsAString &aName);
|
||||
NS_IMETHOD GetDescription(nsAString &aDescription);
|
||||
};
|
||||
|
||||
|
@ -80,6 +80,7 @@ EXPORTS = \
|
||||
nsDocAccessibleWrap.h \
|
||||
nsRootAccessibleWrap.h \
|
||||
nsXULTabAccessibleWrap.h \
|
||||
nsXULTreeAccessibleWrap.h \
|
||||
$(NULL)
|
||||
|
||||
# we don't want the shared lib, but we want to force the creation of a static lib.
|
||||
|
@ -58,9 +58,6 @@ typedef class nsHTMLTextFieldAccessible nsHTMLTextFieldAccessibleWrap;
|
||||
typedef class nsHTMLLinkAccessible nsHTMLLinkAccessibleWrap;
|
||||
typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
|
||||
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
|
||||
typedef class nsXULTreeAccessible nsXULTreeAccessibleWrap;
|
||||
typedef class nsXULTreeColumnsAccessible nsXULTreeColumnsAccessibleWrap;
|
||||
typedef class nsXULTreeitemAccessible nsXULTreeitemAccessibleWrap;
|
||||
typedef class nsXULProgressMeterAccessible nsXULProgressMeterAccessibleWrap;
|
||||
typedef class nsXULTextFieldAccessible nsXULTextFieldAccessibleWrap;
|
||||
|
||||
|
46
accessible/src/other/nsXULTreeAccessibleWrap.h
Executable file
46
accessible/src/other/nsXULTreeAccessibleWrap.h
Executable file
@ -0,0 +1,46 @@
|
||||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* 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/
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
* The Initial Developer of the Original Code is IBM Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2005
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Author: Aaron Leventhal (aleventh@us.ibm.com)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* 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"),
|
||||
* 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
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* 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
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef __nsXULTreeAccessibleWrap_h__
|
||||
#define __nsXULTreeAccessibleWrap_h__
|
||||
|
||||
#include "nsXULTreeitemAccessible.h"
|
||||
typedef class nsXULTreeAccessible nsXULTreeAccessibleWrap;
|
||||
typedef class nsXULTreeitemAccessible nsXULTreeitemAccessibleWrap;
|
||||
typedef class nsXULTreeColumnsAccessible nsXULTreeColumnsAccessibleWrap;
|
||||
|
||||
#endif
|
@ -164,13 +164,14 @@ NS_IMETHODIMP nsXULTreeAccessible::Shutdown()
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTreeAccessible::GetRole(PRUint32 *_retval)
|
||||
NS_IMETHODIMP nsXULTreeAccessible::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
NS_ASSERTION(mTree, "No tree view");
|
||||
PRInt32 colCount = 0;
|
||||
if (NS_SUCCEEDED(GetColumnCount(mTree, &colCount)) && (colCount > 1))
|
||||
*_retval = ROLE_TREE_TABLE;
|
||||
*aRole = ROLE_TREE_TABLE;
|
||||
else
|
||||
*_retval = ROLE_OUTLINE;
|
||||
*aRole = ROLE_OUTLINE;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -460,11 +461,10 @@ nsXULTreeitemAccessible::nsXULTreeitemAccessible(nsIAccessible *aParent, nsIDOMN
|
||||
|
||||
NS_IMPL_ISUPPORTS_INHERITED0(nsXULTreeitemAccessible, nsLeafAccessible)
|
||||
|
||||
NS_IMETHODIMP nsXULTreeitemAccessible::GetName(nsAString& _retval)
|
||||
NS_IMETHODIMP nsXULTreeitemAccessible::GetName(nsAString& aName)
|
||||
{
|
||||
NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE);
|
||||
|
||||
return mTreeView->GetCellText(mRow, mColumn, _retval);
|
||||
return mTreeView->GetCellText(mRow, mColumn, aName);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTreeitemAccessible::GetValue(nsAString& _retval)
|
||||
@ -472,7 +472,9 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetValue(nsAString& _retval)
|
||||
NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE);
|
||||
|
||||
PRInt32 level;
|
||||
mTreeView->GetLevel(mRow, &level);
|
||||
if (NS_FAILED(mTreeView->GetLevel(mRow, &level))) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsString str;
|
||||
str.AppendInt(level);
|
||||
@ -488,13 +490,13 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetUniqueID(void **aUniqueID)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsXULTreeitemAccessible::GetRole(PRUint32 *_retval)
|
||||
NS_IMETHODIMP nsXULTreeitemAccessible::GetRole(PRUint32 *aRole)
|
||||
{
|
||||
PRInt32 colCount = 0;
|
||||
if (NS_SUCCEEDED(nsXULTreeAccessible::GetColumnCount(mTree, &colCount)) && colCount > 1)
|
||||
*_retval = ROLE_CELL;
|
||||
*aRole = ROLE_CELL;
|
||||
else
|
||||
*_retval = ROLE_OUTLINEITEM;
|
||||
*aRole = ROLE_OUTLINEITEM;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user