diff --git a/accessible/src/atk/Makefile.in b/accessible/src/atk/Makefile.in index 7f68ab9ae3d..ca13a8d89d4 100644 --- a/accessible/src/atk/Makefile.in +++ b/accessible/src/atk/Makefile.in @@ -101,6 +101,7 @@ EXPORTS = \ nsDocAccessibleWrap.h \ nsRootAccessibleWrap.h \ nsTextAccessibleWrap.h \ + nsXULTreeAccessibleWrap.h \ nsAccessibleText.h \ $(NULL) diff --git a/accessible/src/atk/nsXULTreeAccessibleWrap.h b/accessible/src/atk/nsXULTreeAccessibleWrap.h index 9ffd8fc7789..c816afcbe58 100644 --- a/accessible/src/atk/nsXULTreeAccessibleWrap.h +++ b/accessible/src/atk/nsXULTreeAccessibleWrap.h @@ -43,6 +43,8 @@ #include "nsIAccessibleTable.h" #include "nsXULTreeAccessible.h" +typedef class nsXULTreeitemAccessible nsXULTreeitemAccessibleWrap; + class nsXULTreeAccessibleWrap : public nsXULTreeAccessible, public nsIAccessibleTable { diff --git a/accessible/src/mac/nsAccessibleWrap.h b/accessible/src/mac/nsAccessibleWrap.h index 0aca467f393..dfe8aadec20 100644 --- a/accessible/src/mac/nsAccessibleWrap.h +++ b/accessible/src/mac/nsAccessibleWrap.h @@ -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 diff --git a/accessible/src/msaa/Makefile.in b/accessible/src/msaa/Makefile.in index da913253a2b..296fd01e368 100644 --- a/accessible/src/msaa/Makefile.in +++ b/accessible/src/msaa/Makefile.in @@ -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. diff --git a/accessible/src/msaa/nsXULTreeAccessibleWrap.cpp b/accessible/src/msaa/nsXULTreeAccessibleWrap.cpp new file mode 100644 index 00000000000..48c7d4eab0d --- /dev/null +++ b/accessible/src/msaa/nsXULTreeAccessibleWrap.cpp @@ -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; +} diff --git a/accessible/src/msaa/nsXULTreeAccessibleWrap.h b/accessible/src/msaa/nsXULTreeAccessibleWrap.h new file mode 100644 index 00000000000..651aec4df5a --- /dev/null +++ b/accessible/src/msaa/nsXULTreeAccessibleWrap.h @@ -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 diff --git a/accessible/src/other/nsAccessibleWrap.h b/accessible/src/other/nsAccessibleWrap.h index 0aca467f393..dfe8aadec20 100755 --- a/accessible/src/other/nsAccessibleWrap.h +++ b/accessible/src/other/nsAccessibleWrap.h @@ -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 diff --git a/accessible/src/xul/Makefile.in b/accessible/src/xul/Makefile.in index 8509cec8514..7cca98cae2f 100644 --- a/accessible/src/xul/Makefile.in +++ b/accessible/src/xul/Makefile.in @@ -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 \ diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp index 84c51cf3030..a6aeea9f1a7 100644 --- a/accessible/src/xul/nsXULTreeAccessible.cpp +++ b/accessible/src/xul/nsXULTreeAccessible.cpp @@ -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 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 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; } diff --git a/accessible/src/xul/nsXULTreeAccessible.h b/accessible/src/xul/nsXULTreeAccessible.h index ec8c1a2f572..a8e3d0b055a 100644 --- a/accessible/src/xul/nsXULTreeAccessible.h +++ b/accessible/src/xul/nsXULTreeAccessible.h @@ -113,7 +113,7 @@ public: /* ------ nsIAccessNode ----- */ NS_IMETHOD GetUniqueID(void **aUniqueID); -private: +protected: nsCOMPtr mTree; nsCOMPtr mTreeView; PRInt32 mRow;