Bug 245367. Expose positional information for tree views in MSAA's get_accDescription(). r=pkw, sr=henry.jia

This commit is contained in:
aaronleventhal%moonset.net 2004-07-06 13:03:29 +00:00
Родитель 4c84b229a8
Коммит 9005f52277
10 изменённых файлов: 174 добавлений и 7 удалений

Просмотреть файл

@ -101,6 +101,7 @@ EXPORTS = \
nsDocAccessibleWrap.h \
nsRootAccessibleWrap.h \
nsTextAccessibleWrap.h \
nsXULTreeAccessibleWrap.h \
nsAccessibleText.h \
$(NULL)

Просмотреть файл

@ -43,6 +43,8 @@
#include "nsIAccessibleTable.h"
#include "nsXULTreeAccessible.h"
typedef class nsXULTreeitemAccessible nsXULTreeitemAccessibleWrap;
class nsXULTreeAccessibleWrap : public nsXULTreeAccessible,
public nsIAccessibleTable
{

Просмотреть файл

@ -60,6 +60,7 @@ typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
typedef class nsXULTreeAccessible nsXULTreeAccessibleWrap;
typedef class nsXULTreeColumnsAccessible nsXULTreeColumnsAccessibleWrap;
typedef class nsXULTreeitemAccessible nsXULTreeitemAccessibleWrap;
typedef class nsXULProgressMeterAccessible nsXULProgressMeterAccessibleWrap;
#endif

Просмотреть файл

@ -71,6 +71,7 @@ CPPSRCS = \
nsDocAccessibleWrap.cpp \
nsRootAccessibleWrap.cpp \
nsHTMLWin32ObjectAccessible.cpp \
nsXULTreeAccessibleWrap.cpp \
$(NULL)
EXPORTS = \
@ -80,6 +81,7 @@ EXPORTS = \
nsDocAccessibleWrap.h \
nsRootAccessibleWrap.h \
nsHTMLWin32ObjectAccessible.h \
nsXULTreeAccessibleWrap.h \
$(NULL)
# we don't want the shared lib, but we want to force the creation of a static lib.

Просмотреть файл

@ -0,0 +1,94 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 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 Netscape Corp.
* Portions created by Netscape Corp.are Copyright (C) 2003 Netscape
* Corp. All Rights Reserved.
*
* Original Author: Aaron Leventhal
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#include "nsXULTreeAccessibleWrap.h"
#include "nsTextFormatter.h"
// --------------------------------------------------------
// nsXULTreeitemAccessibleWrap Accessible
// --------------------------------------------------------
nsXULTreeitemAccessibleWrap::nsXULTreeitemAccessibleWrap(nsIAccessible *aParent,
nsIDOMNode *aDOMNode,
nsIWeakReference *aShell,
PRInt32 aRow,
nsITreeColumn* aColumn) :
nsXULTreeitemAccessible(aParent, aDOMNode, aShell, aRow, aColumn)
{
}
NS_IMETHODIMP nsXULTreeitemAccessibleWrap::GetDescription(nsAString& aDescription)
{
if (!mParent || !mWeakShell || !mTreeView) {
return NS_ERROR_FAILURE;
}
aDescription.Truncate();
PRInt32 level = 0;
mTreeView->GetLevel(mRow, &level);
PRInt32 testRow = -1;
if (level > 0) {
mTreeView->GetParentIndex(mRow, &testRow);
}
PRInt32 numRows;
mTreeView->GetRowCount(&numRows);
PRInt32 indexInParent = 0, numSiblings = 0;
while (++ testRow < numRows) {
PRInt32 testLevel;
mTreeView->GetLevel(testRow, &testLevel);
if (testLevel == level) {
if (testRow <= mRow) {
++indexInParent;
}
++numSiblings;
}
else if (testLevel < level) {
break;
}
}
nsTextFormatter::ssprintf(aDescription, L"L%d, %d of %d", level + 1, indexInParent, numSiblings);
return NS_OK;
}

Просмотреть файл

@ -0,0 +1,54 @@
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: NPL 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 Netscape Corp.
* Portions created by Netscape Corp.are Copyright (C) 2003 Netscape
* Corp. All Rights Reserved.
*
* Original Author: Aaron Leventhal
*
* Contributor(s):
*
*
* Alternatively, the contents of this file may be used under the terms of
* either 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 NPL, 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 NPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
#ifndef __nsXULTreeAccessibleWrap_h__
#define __nsXULTreeAccessibleWrap_h__
#include "nsXULTreeAccessible.h"
class nsXULTreeitemAccessibleWrap : public nsXULTreeitemAccessible
{
public:
nsXULTreeitemAccessibleWrap(nsIAccessible *aParent, nsIDOMNode *aDOMNode, nsIWeakReference *aShell,
PRInt32 aRow, nsITreeColumn* aColumn);
virtual ~nsXULTreeitemAccessibleWrap() {}
NS_IMETHOD GetDescription(nsAString &aDescription);
};
#endif

Просмотреть файл

@ -60,6 +60,7 @@ typedef class nsHTMLTableCellAccessible nsHTMLTableCellAccessibleWrap;
typedef class nsHTMLTableAccessible nsHTMLTableAccessibleWrap;
typedef class nsXULTreeAccessible nsXULTreeAccessibleWrap;
typedef class nsXULTreeColumnsAccessible nsXULTreeColumnsAccessibleWrap;
typedef class nsXULTreeitemAccessible nsXULTreeitemAccessibleWrap;
typedef class nsXULProgressMeterAccessible nsXULProgressMeterAccessibleWrap;
#endif

Просмотреть файл

@ -78,6 +78,7 @@ FORCE_STATIC_LIB = 1
include $(topsrcdir)/config/rules.mk
LOCAL_INCLUDES = \
-I$(srcdir) \
-I$(srcdir)/../base \
-I$(srcdir)/../html \
-I$(srcdir)/../../../layout/html/base/src \

Просмотреть файл

@ -41,7 +41,11 @@
#include "nsIDOMXULMultSelectCntrlEl.h"
#include "nsITreeSelection.h"
#include "nsITreeColumns.h"
#if defined(MOZ_ACCESSIBILITY_ATK) || defined(XP_WIN)
#include "nsXULTreeAccessibleWrap.h"
#else
#include "nsXULTreeAccessible.h"
#endif
#include "nsArray.h"
#ifdef MOZ_ACCESSIBILITY_ATK
@ -383,7 +387,7 @@ NS_IMETHODIMP nsXULTreeAccessible::GetCachedTreeitemAccessible(PRInt32 aRow, nsI
GetCacheEntry(*mAccessNodeCache, (void*)(aRow * kMaxTreeColumns + columnIndex), getter_AddRefs(accessNode));
if (!accessNode)
{
accessNode = new nsXULTreeitemAccessible(this, mDOMNode, mWeakShell, aRow, col);
accessNode = new nsXULTreeitemAccessibleWrap(this, mDOMNode, mWeakShell, aRow, col);
if (! accessNode)
return NS_ERROR_OUT_OF_MEMORY;
PutCacheEntry(*mAccessNodeCache, (void*)(aRow * kMaxTreeColumns + columnIndex), accessNode);
@ -572,9 +576,9 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetNextSibling(nsIAccessible **aNextSibli
}
nsresult rv = NS_OK;
#ifdef MOZ_ACCESSIBILITY_ATK
PRInt32 row = mRow;
nsCOMPtr<nsITreeColumn> column;
#ifdef MOZ_ACCESSIBILITY_ATK
rv = mColumn->GetNext(getter_AddRefs(column));
NS_ENSURE_SUCCESS(rv, rv);
@ -585,9 +589,13 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetNextSibling(nsIAccessible **aNextSibli
if (cols)
cols->GetFirstColumn(getter_AddRefs(column));
}
#else
if (++row >= rowCount) {
return NS_ERROR_FAILURE;
}
#endif //MOZ_ACCESSIBILITY_ATK
rv = treeCache->GetCachedTreeitemAccessible(row, column, aNextSibling);
#endif //MOZ_ACCESSIBILITY_ATK
return rv;
}
@ -609,9 +617,9 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetPreviousSibling(nsIAccessible **aPrevi
nsresult rv = NS_OK;
#ifdef MOZ_ACCESSIBILITY_ATK
PRInt32 row = mRow;
nsCOMPtr<nsITreeColumn> column;
#ifdef MOZ_ACCESSIBILITY_ATK
rv = mColumn->GetPrevious(getter_AddRefs(column));
NS_ENSURE_SUCCESS(rv, rv);
@ -622,11 +630,14 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetPreviousSibling(nsIAccessible **aPrevi
if (cols)
cols->GetLastColumn(getter_AddRefs(column));
}
#else
if (--row < 0) {
return NS_ERROR_FAILURE;
}
#endif
rv = treeCache->GetCachedTreeitemAccessible(row, column, aPreviousSibling);
#endif //MOZ_ACCESSIBILITY_ATK
return rv;
}

Просмотреть файл

@ -113,7 +113,7 @@ public:
/* ------ nsIAccessNode ----- */
NS_IMETHOD GetUniqueID(void **aUniqueID);
private:
protected:
nsCOMPtr<nsITreeBoxObject> mTree;
nsCOMPtr<nsITreeView> mTreeView;
PRInt32 mRow;