diff --git a/accessible/public/Makefile.in b/accessible/public/Makefile.in index 39c68e01f625..24c251d61b9a 100644 --- a/accessible/public/Makefile.in +++ b/accessible/public/Makefile.in @@ -73,11 +73,5 @@ XPIDLSRCS = \ nsIXBLAccessible.idl \ $(NULL) -ifdef MOZ_XUL -XPIDLSRCS += \ - nsIAccessibleTreeCache.idl \ - $(NULL) -endif - include $(topsrcdir)/config/rules.mk diff --git a/accessible/public/nsIAccessibleTreeCache.idl b/accessible/public/nsIAccessibleTreeCache.idl deleted file mode 100644 index 25b61e0716a5..000000000000 --- a/accessible/public/nsIAccessibleTreeCache.idl +++ /dev/null @@ -1,101 +0,0 @@ -/* -*- 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 - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 2002 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * Louie Zhao (original author) - * Alexander Surkov - * - * 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 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 ***** */ - -#include "nsISupports.idl" -#include "nsITreeColumns.idl" - -interface nsIAccessible; - -/** - * A private interface to operate with tree accessible. - * - * @status UNDER_REVIEW - */ -[uuid(1dde5c3b-bede-43d1-aabf-dabc461113bd)] -interface nsIAccessibleTreeCache : nsISupports -{ - /** - * Get tree item from cache according to row and column, create if doesn't - * exist in cache. - * - * @param aRow the given row index - * @param aColumn the given column object. If is is nsnull then primary - * column is used. It makes sense for ATK only. - */ - nsIAccessible getCachedTreeitemAccessible(in long aRow, - in nsITreeColumn aColumn); - - /** - * Invalidates the number of cached treeitem accessibles. - * - * @param aRow row index the invalidation starts from - * @param aCount the number of treeitem accessibles to invalidate, - * the number sign specifies whether rows have been - * inserted (plus) or removed (minus) - */ - void invalidateCache(in long aRow, in long aCount); - - /** - * Fires name change events for invalidated area of tree. - * - * @param aStartRow row index invalidation starts from - * @param aEndRow row index invalidation ends, -1 means last row index - * @param aStartCol column index invalidation starts from - * @param aEndCol column index invalidation ends, -1 mens last column - * index - */ - void treeViewInvalidated(in long aStartRow, in long aEndRow, - in long aStartCol, in long aEndCol); - - /** - * Invalidates children created for previous tree view. - */ - void treeViewChanged(); - -}; - -[uuid(b71532f9-53b2-4647-a5b2-1c5f57e9aed6)] -interface nsPIAccessibleTreeItem : nsISupports -{ - /** - * Get/set cached name. - */ - attribute AString cachedName; -}; - diff --git a/accessible/src/base/nsARIAMap.cpp b/accessible/src/base/nsARIAMap.cpp index 69579d8c50c1..d035b68cbc2c 100644 --- a/accessible/src/base/nsARIAMap.cpp +++ b/accessible/src/base/nsARIAMap.cpp @@ -123,7 +123,7 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = eSortAction, eNoLiveAttr, kNoReqStates, - eARIASelected, + eARIASelectable, eARIAReadonly }, { @@ -174,7 +174,7 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = eNoAction, eNoLiveAttr, kNoReqStates, - eARIASelected, + eARIASelectable, eARIAReadonly }, { @@ -251,7 +251,7 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = eNoAction, // XXX: should depend on state, parent accessible eNoLiveAttr, nsIAccessibleStates::STATE_READONLY, - eARIASelected, + eARIASelectable, eARIACheckedMixed }, { @@ -338,7 +338,7 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = eSelectAction, eNoLiveAttr, kNoReqStates, - eARIASelected, + eARIASelectable, eARIACheckedMixed }, { @@ -395,7 +395,7 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = eNoAction, eNoLiveAttr, kNoReqStates, - eARIASelected + eARIASelectable }, { "rowheader", @@ -405,7 +405,7 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = eSortAction, eNoLiveAttr, kNoReqStates, - eARIASelected, + eARIASelectable, eARIAReadonly }, { @@ -552,7 +552,7 @@ nsRoleMapEntry nsARIAMap::gWAIRoleMap[] = // on states eNoLiveAttr, kNoReqStates, - eARIASelected, + eARIASelectable, eARIACheckedMixed } }; @@ -655,10 +655,11 @@ nsStateMapEntry nsARIAMap::gWAIStateMap[] = { nsStateMapEntry(&nsAccessibilityAtoms::aria_required, kBoolType, 0, nsIAccessibleStates::STATE_REQUIRED, 0), - // eARIASelected + // eARIASelectable nsStateMapEntry(&nsAccessibilityAtoms::aria_selected, kBoolType, nsIAccessibleStates::STATE_SELECTABLE, - nsIAccessibleStates::STATE_SELECTED, 0) + nsIAccessibleStates::STATE_SELECTED, 0, + 0, 0, PR_TRUE) }; /** diff --git a/accessible/src/base/nsARIAMap.h b/accessible/src/base/nsARIAMap.h index 36c7aa0d0ced..82ce2a1b5b8a 100644 --- a/accessible/src/base/nsARIAMap.h +++ b/accessible/src/base/nsARIAMap.h @@ -178,7 +178,7 @@ enum eStateMapEntryID eARIAReadonly, eARIAReadonlyOrEditable, eARIARequired, - eARIASelected + eARIASelectable }; class nsStateMapEntry diff --git a/accessible/src/base/nsAccUtils.cpp b/accessible/src/base/nsAccUtils.cpp index 15eb09e95c76..3bc60a9ff3de 100644 --- a/accessible/src/base/nsAccUtils.cpp +++ b/accessible/src/base/nsAccUtils.cpp @@ -50,6 +50,7 @@ #include "nsAccessibleTreeWalker.h" #include "nsAccessible.h" #include "nsARIAMap.h" +#include "nsXULTreeAccessible.h" #include "nsIDOMXULContainerElement.h" #include "nsIDOMXULSelectCntrlEl.h" @@ -768,6 +769,28 @@ nsAccUtils::QueryAccessibleDocument(nsIAccessibleDocument *aAccessibleDocument) return accessible; } +#ifdef MOZ_XUL +already_AddRefed +nsAccUtils::QueryAccessibleTree(nsIAccessible *aAccessible) +{ + nsXULTreeAccessible* accessible = nsnull; + if (aAccessible) + CallQueryInterface(aAccessible, &accessible); + + return accessible; +} + +already_AddRefed +nsAccUtils::QueryAccessibleTreeitem(nsIAccessNode *aAccessNode) +{ + nsXULTreeitemAccessible* accessible = nsnull; + if (aAccessNode) + CallQueryInterface(aAccessNode, &accessible); + + return accessible; +} +#endif + #ifdef DEBUG_A11Y PRBool diff --git a/accessible/src/base/nsAccUtils.h b/accessible/src/base/nsAccUtils.h index 31e7b528ec5d..821b693c2fb1 100644 --- a/accessible/src/base/nsAccUtils.h +++ b/accessible/src/base/nsAccUtils.h @@ -56,6 +56,10 @@ class nsAccessNode; class nsAccessible; class nsHTMLTableAccessible; class nsDocAccessible; +#ifdef MOZ_XUL +class nsXULTreeAccessible; +class nsXULTreeitemAccessible; +#endif class nsAccUtils { @@ -354,6 +358,20 @@ public: static already_AddRefed QueryAccessibleDocument(nsIAccessibleDocument *aAccessibleDocument); +#ifdef MOZ_XUL + /** + * Query nsXULTreeAccessible from the given nsIAccessible. + */ + static already_AddRefed + QueryAccessibleTree(nsIAccessible *aAccessible); + + /** + * Query nsXULTreeitemAccessible from the given nsIAccessNode. + */ + static already_AddRefed + QueryAccessibleTreeitem(nsIAccessNode *aAccessNode); +#endif + #ifdef DEBUG_A11Y /** * Detect whether the given accessible object implements nsIAccessibleText, diff --git a/accessible/src/base/nsAccessibleEventData.cpp b/accessible/src/base/nsAccessibleEventData.cpp index cc0ec7c9e588..e6da9f783153 100644 --- a/accessible/src/base/nsAccessibleEventData.cpp +++ b/accessible/src/base/nsAccessibleEventData.cpp @@ -268,6 +268,7 @@ nsAccEvent::GetAccessibleByNode() nsIAccessible *accessible = nsnull; accService->GetAccessibleFor(mDOMNode, &accessible); + #ifdef MOZ_XUL // hack for xul tree table. We need a better way for firing delayed event // against xul tree table. see bug 386821. @@ -282,18 +283,12 @@ nsAccEvent::GetAccessibleByNode() PRInt32 treeIndex = -1; multiSelect->GetCurrentIndex(&treeIndex); if (treeIndex >= 0) { - nsCOMPtr treeCache(do_QueryInterface(accessible)); - NS_IF_RELEASE(accessible); - nsCOMPtr treeItemAccessible; - if (!treeCache || - NS_FAILED(treeCache->GetCachedTreeitemAccessible( - treeIndex, - nsnull, - getter_AddRefs(treeItemAccessible))) || - !treeItemAccessible) { - return nsnull; + nsRefPtr treeCache = + nsAccUtils::QueryAccessibleTree(accessible); + if (treeCache) { + treeCache->GetCachedTreeitemAccessible(treeIndex, nsnull, + &accessible); } - NS_IF_ADDREF(accessible = treeItemAccessible); } } } diff --git a/accessible/src/base/nsDocAccessible.cpp b/accessible/src/base/nsDocAccessible.cpp index 50d5901ef410..6565a0d71d15 100644 --- a/accessible/src/base/nsDocAccessible.cpp +++ b/accessible/src/base/nsDocAccessible.cpp @@ -257,12 +257,11 @@ nsDocAccessible::SetRoleMapEntry(nsRoleMapEntry* aRoleMapEntry) mRoleMapEntry = aRoleMapEntry; - // Allow use of ARIA role from outer to override nsIDocument *parentDoc = mDocument->GetParentDocument(); - NS_ASSERTION(parentDoc, "No parent document during initialization!"); if (!parentDoc) - return; + return; // No parent document for the root document + // Allow use of ARIA role from outer to override nsIContent *ownerContent = parentDoc->FindContentForSubDocument(mDocument); nsCOMPtr ownerNode(do_QueryInterface(ownerContent)); if (ownerNode) { @@ -807,8 +806,26 @@ nsresult nsDocAccessible::RemoveEventListeners() // Remove scroll position listener RemoveScrollListener(); - // Remove document observer - mDocument->RemoveObserver(this); + NS_ASSERTION(mDocument, "No document during removal of listeners."); + + if (mDocument) { + mDocument->RemoveObserver(this); + + nsCOMPtr container = mDocument->GetContainer(); + nsCOMPtr docShellTreeItem(do_QueryInterface(container)); + NS_ASSERTION(docShellTreeItem, "doc should support nsIDocShellTreeItem."); + + if (docShellTreeItem) { + PRInt32 itemType; + docShellTreeItem->GetItemType(&itemType); + if (itemType == nsIDocShellTreeItem::typeContent) { + nsCOMPtr commandManager = do_GetInterface(docShellTreeItem); + if (commandManager) { + commandManager->RemoveCommandObserver(this, "obs_documentCreated"); + } + } + } + } if (mScrollWatchTimer) { mScrollWatchTimer->Cancel(); @@ -826,19 +843,6 @@ nsresult nsDocAccessible::RemoveEventListeners() } } - nsCOMPtr container = mDocument->GetContainer(); - nsCOMPtr docShellTreeItem(do_QueryInterface(container)); - NS_ENSURE_TRUE(docShellTreeItem, NS_ERROR_FAILURE); - - PRInt32 itemType; - docShellTreeItem->GetItemType(&itemType); - if (itemType == nsIDocShellTreeItem::typeContent) { - nsCOMPtr commandManager = do_GetInterface(docShellTreeItem); - if (commandManager) { - commandManager->RemoveCommandObserver(this, "obs_documentCreated"); - } - } - return NS_OK; } @@ -1050,6 +1054,17 @@ NS_IMPL_NSIDOCUMENTOBSERVER_CORE_STUB(nsDocAccessible) NS_IMPL_NSIDOCUMENTOBSERVER_LOAD_STUB(nsDocAccessible) NS_IMPL_NSIDOCUMENTOBSERVER_STYLE_STUB(nsDocAccessible) +void +nsDocAccessible::AttributeWillChange(nsIDocument *aDocument, + nsIContent* aContent, PRInt32 aNameSpaceID, + nsIAtom* aAttribute, PRInt32 aModType) +{ + // XXX TODO: bugs 381599 467143 472142 472143 + // Here we will want to cache whatever state we are potentially interested in, + // such as the existence of aria-pressed for button (so we know if we need to + // newly expose it as a toggle button) etc. +} + void nsDocAccessible::AttributeChanged(nsIDocument *aDocument, nsIContent* aContent, PRInt32 aNameSpaceID, nsIAtom* aAttribute, diff --git a/accessible/src/base/nsRootAccessible.cpp b/accessible/src/base/nsRootAccessible.cpp index f2b51bb76011..ec3257aa7ef0 100644 --- a/accessible/src/base/nsRootAccessible.cpp +++ b/accessible/src/base/nsRootAccessible.cpp @@ -669,13 +669,16 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent, #ifdef MOZ_XUL if (isTree) { - nsCOMPtr treeAcc(do_QueryInterface(accessible)); + nsRefPtr treeAcc = + nsAccUtils::QueryAccessibleTree(accessible); NS_ASSERTION(treeAcc, - "Accessible for xul:tree doesn't implement nsIAccessibleTreeCache interface."); + "Accessible for xul:tree isn't nsXULTreeAccessible."); if (treeAcc) { - if (eventType.EqualsLiteral("TreeViewChanged")) - return treeAcc->TreeViewChanged(); + if (eventType.EqualsLiteral("TreeViewChanged")) { + treeAcc->TreeViewChanged(); + return NS_OK; + } if (eventType.EqualsLiteral("TreeRowCountChanged")) return HandleTreeRowCountChangedEvent(aEvent, treeAcc); @@ -730,16 +733,14 @@ nsresult nsRootAccessible::HandleEventWithTarget(nsIDOMEvent* aEvent, PRInt32 treeIndex = -1; multiSelect->GetCurrentIndex(&treeIndex); if (treeIndex >= 0) { - nsCOMPtr treeCache(do_QueryInterface(accessible)); - if (!treeCache || - NS_FAILED(treeCache->GetCachedTreeitemAccessible( - treeIndex, - nsnull, - getter_AddRefs(treeItemAccessible))) || - !treeItemAccessible) { - return NS_ERROR_OUT_OF_MEMORY; + nsRefPtr treeCache = + nsAccUtils::QueryAccessibleTree(accessible); + if (treeCache) { + treeCache->GetCachedTreeitemAccessible(treeIndex, nsnull, + getter_AddRefs(treeItemAccessible)); + if (treeItemAccessible) + accessible = treeItemAccessible; } - accessible = treeItemAccessible; } } } @@ -1181,7 +1182,7 @@ nsRootAccessible::HandlePopupHidingEvent(nsIDOMNode *aNode, #ifdef MOZ_XUL nsresult nsRootAccessible::HandleTreeRowCountChangedEvent(nsIDOMEvent *aEvent, - nsIAccessibleTreeCache *aAccessible) + nsXULTreeAccessible *aAccessible) { nsCOMPtr dataEvent(do_QueryInterface(aEvent)); if (!dataEvent) @@ -1203,12 +1204,13 @@ nsRootAccessible::HandleTreeRowCountChangedEvent(nsIDOMEvent *aEvent, indexVariant->GetAsInt32(&index); countVariant->GetAsInt32(&count); - return aAccessible->InvalidateCache(index, count); + aAccessible->InvalidateCache(index, count); + return NS_OK; } nsresult nsRootAccessible::HandleTreeInvalidatedEvent(nsIDOMEvent *aEvent, - nsIAccessibleTreeCache *aAccessible) + nsXULTreeAccessible *aAccessible) { nsCOMPtr dataEvent(do_QueryInterface(aEvent)); if (!dataEvent) @@ -1240,7 +1242,8 @@ nsRootAccessible::HandleTreeInvalidatedEvent(nsIDOMEvent *aEvent, if (endColVariant) endColVariant->GetAsInt32(&endCol); - return aAccessible->TreeViewInvalidated(startRow, endRow, startCol, endCol); + aAccessible->TreeViewInvalidated(startRow, endRow, startCol, endCol); + return NS_OK; } #endif diff --git a/accessible/src/base/nsRootAccessible.h b/accessible/src/base/nsRootAccessible.h index d5e79a95048a..74dc2df75f8b 100644 --- a/accessible/src/base/nsRootAccessible.h +++ b/accessible/src/base/nsRootAccessible.h @@ -43,7 +43,7 @@ #include "nsIAccessibleDocument.h" #ifdef MOZ_XUL -#include "nsIAccessibleTreeCache.h" +#include "nsXULTreeAccessible.h" #endif #include "nsHashtable.h" @@ -51,7 +51,6 @@ #include "nsIDocument.h" #include "nsIDOMFocusListener.h" #include "nsIDOMFormListener.h" -#include "nsIDOMXULListener.h" #include "nsITimer.h" #define NS_ROOTACCESSIBLE_IMPL_CID \ @@ -140,9 +139,9 @@ public: #ifdef MOZ_XUL nsresult HandleTreeRowCountChangedEvent(nsIDOMEvent *aEvent, - nsIAccessibleTreeCache *aAccessible); + nsXULTreeAccessible *aAccessible); nsresult HandleTreeInvalidatedEvent(nsIDOMEvent *aEvent, - nsIAccessibleTreeCache *aAccessible); + nsXULTreeAccessible *aAccessible); PRUint32 GetChromeFlags(); #endif diff --git a/accessible/src/html/nsHTMLTableAccessible.cpp b/accessible/src/html/nsHTMLTableAccessible.cpp index a83d3200b2c3..ce55020a5523 100644 --- a/accessible/src/html/nsHTMLTableAccessible.cpp +++ b/accessible/src/html/nsHTMLTableAccessible.cpp @@ -849,7 +849,11 @@ nsHTMLTableAccessible::GetIndexAt(PRInt32 aRow, PRInt32 aColumn, nsresult rv = GetTableLayout(&tableLayout); NS_ENSURE_SUCCESS(rv, rv); - return tableLayout->GetIndexByRowAndColumn(aRow, aColumn, aIndex); + rv = tableLayout->GetIndexByRowAndColumn(aRow, aColumn, aIndex); + if (rv == NS_TABLELAYOUT_CELL_NOT_FOUND) + return NS_ERROR_INVALID_ARG; + + return NS_OK; } NS_IMETHODIMP diff --git a/accessible/src/xul/nsXULTreeAccessible.cpp b/accessible/src/xul/nsXULTreeAccessible.cpp index 2184ce34be8a..c01bce07e03b 100644 --- a/accessible/src/xul/nsXULTreeAccessible.cpp +++ b/accessible/src/xul/nsXULTreeAccessible.cpp @@ -133,7 +133,9 @@ mAccessNodeCache(nsnull) mAccessNodeCache->Init(kDefaultTreeCacheSize); } -NS_IMPL_ISUPPORTS_INHERITED1(nsXULTreeAccessible, nsXULSelectableAccessible, nsIAccessibleTreeCache) +NS_IMPL_ISUPPORTS_INHERITED1(nsXULTreeAccessible, + nsXULSelectableAccessible, + nsXULTreeAccessible) @@ -220,6 +222,12 @@ NS_IMETHODIMP nsXULTreeAccessible::GetValue(nsAString& _retval) return NS_OK; } +PRBool +nsXULTreeAccessible::IsDefunct() +{ + return nsXULSelectableAccessible::IsDefunct() || !mTree || !mTreeView; +} + nsresult nsXULTreeAccessible::Shutdown() { @@ -262,7 +270,7 @@ NS_IMETHODIMP nsXULTreeAccessible::GetFirstChild(nsIAccessible **aFirstChild) mTreeView->GetRowCount(&rowCount); if (rowCount > 0) { nsCOMPtr column = GetFirstVisibleColumn(mTree); - return GetCachedTreeitemAccessible(0, column, aFirstChild); + GetCachedTreeitemAccessible(0, column, aFirstChild); } } @@ -281,12 +289,11 @@ nsXULTreeAccessible::GetLastChild(nsIAccessible **aLastChild) mTreeView->GetRowCount(&rowCount); if (rowCount > 0) { nsCOMPtr column = GetLastVisibleColumn(mTree); - nsresult rv = GetCachedTreeitemAccessible(rowCount - 1, column, aLastChild); - NS_ENSURE_SUCCESS(rv, rv); - } + GetCachedTreeitemAccessible(rowCount - 1, column, aLastChild); - if (*aLastChild) - return NS_OK; + if (*aLastChild) + return NS_OK; + } // If there is not any rows, use treecols as tree's last child. return nsAccessible::GetLastChild(aLastChild); @@ -316,9 +323,8 @@ NS_IMETHODIMP nsXULTreeAccessible::GetFocusedChild(nsIAccessible **aFocusedChild multiSelect->GetCurrentIndex(&row); if (row >= 0) { GetCachedTreeitemAccessible(row, nsnull, aFocusedChild); - if (*aFocusedChild) { - return NS_OK; // Already addref'd by getter - } + if (*aFocusedChild) + return NS_OK; } } NS_ADDREF(*aFocusedChild = this); @@ -360,13 +366,7 @@ nsXULTreeAccessible::GetChildAtPoint(PRInt32 aX, PRInt32 aY, return nsXULSelectableAccessible:: GetChildAtPoint(aX, aY, aDeepestChild, aChild); - nsCOMPtr treeitemAcc; - nsresult rv = GetCachedTreeitemAccessible(row, column, - getter_AddRefs(treeitemAcc)); - NS_ENSURE_SUCCESS(rv, rv); - - NS_IF_ADDREF(*aChild = treeitemAcc); - + GetCachedTreeitemAccessible(row, column, aChild); return NS_OK; } @@ -392,9 +392,10 @@ NS_IMETHODIMP nsXULTreeAccessible::GetSelectedChildren(nsIArray **_retval) selection->IsSelected(rowIndex, &isSelected); if (isSelected) { nsCOMPtr tempAccess; - if (NS_FAILED(GetCachedTreeitemAccessible(rowIndex, nsnull, getter_AddRefs(tempAccess))) || !tempAccess) + GetCachedTreeitemAccessible(rowIndex, nsnull, + getter_AddRefs(tempAccess)); + NS_ENSURE_STATE(tempAccess); - return NS_ERROR_OUT_OF_MEMORY; selectedAccessibles->AppendElement(tempAccess, PR_FALSE); } } @@ -468,9 +469,11 @@ NS_IMETHODIMP nsXULTreeAccessible::ClearSelection() return NS_OK; } -NS_IMETHODIMP nsXULTreeAccessible::RefSelection(PRInt32 aIndex, nsIAccessible **_retval) +NS_IMETHODIMP +nsXULTreeAccessible::RefSelection(PRInt32 aIndex, nsIAccessible **aAccessible) { - *_retval = nsnull; + NS_ENSURE_ARG_POINTER(aAccessible); + *aAccessible = nsnull; NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE); @@ -487,7 +490,8 @@ NS_IMETHODIMP nsXULTreeAccessible::RefSelection(PRInt32 aIndex, nsIAccessible ** selection->IsSelected(rowIndex, &isSelected); if (isSelected) { if (selCount == aIndex) { - return GetCachedTreeitemAccessible(rowIndex, nsnull, _retval); + GetCachedTreeitemAccessible(rowIndex, nsnull, aAccessible); + return NS_OK; } selCount++; } @@ -519,14 +523,13 @@ NS_IMETHODIMP nsXULTreeAccessible::SelectAllSelection(PRBool *_retval) return NS_OK; } -// nsIAccessible nsIAccessibleTreeCache:: -// GetCachedTreeitemAccessible(in long aRow, nsITreeColumn* aColumn) -NS_IMETHODIMP +// nsXULTreeAccessible + +void nsXULTreeAccessible::GetCachedTreeitemAccessible(PRInt32 aRow, nsITreeColumn* aColumn, nsIAccessible** aAccessible) { - NS_ENSURE_ARG_POINTER(aAccessible); *aAccessible = nsnull; NS_ASSERTION(mAccessNodeCache, "No accessibility cache for tree"); @@ -548,59 +551,61 @@ nsXULTreeAccessible::GetCachedTreeitemAccessible(PRInt32 aRow, // Do not create accessible for treeitem if there is no column in the tree // because it doesn't render treeitems properly. if (!col) - return NS_OK; + return; col->GetIndex(&columnIndex); nsCOMPtr accessNode; GetCacheEntry(*mAccessNodeCache, (void*)(aRow * kMaxTreeColumns + columnIndex), getter_AddRefs(accessNode)); - if (!accessNode) - { - nsXULTreeitemAccessibleWrap* treeItemAcc = + + if (!accessNode) { + nsRefPtr treeItemAcc = new nsXULTreeitemAccessibleWrap(this, mDOMNode, mWeakShell, aRow, col); - NS_ENSURE_TRUE(treeItemAcc, NS_ERROR_OUT_OF_MEMORY); + if (!treeItemAcc) + return; nsresult rv = treeItemAcc->Init(); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) + return; accessNode = treeItemAcc; PutCacheEntry(*mAccessNodeCache, (void*)(aRow * kMaxTreeColumns + columnIndex), accessNode); } - nsCOMPtr accessible(do_QueryInterface(accessNode)); - NS_IF_ADDREF(*aAccessible = accessible); - return NS_OK; + + CallQueryInterface(accessNode, aAccessible); } -// void nsIAccessibleTreeCache:: -// invalidateCache(in PRInt32 aRow, in PRInt32 aCount) -NS_IMETHODIMP +void nsXULTreeAccessible::InvalidateCache(PRInt32 aRow, PRInt32 aCount) { + if (IsDefunct()) + return; + // Do not invalidate the cache if rows have been inserted. if (aCount > 0) - return NS_OK; - - NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE); + return; nsCOMPtr cols; - nsresult rv = mTree->GetColumns(getter_AddRefs(cols)); - NS_ENSURE_STATE(cols); + mTree->GetColumns(getter_AddRefs(cols)); + if (!cols) + return; #ifdef MOZ_ACCESSIBILITY_ATK PRInt32 colsCount = 0; - rv = cols->GetCount(&colsCount); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = cols->GetCount(&colsCount); + if (NS_FAILED(rv)) + return; #else nsCOMPtr col; - rv = cols->GetKeyColumn(getter_AddRefs(col)); - NS_ENSURE_SUCCESS(rv, rv); - + cols->GetKeyColumn(getter_AddRefs(col)); if (!col) - return NS_OK; + return; PRInt32 colIdx = 0; - rv = col->GetIndex(&colIdx); - NS_ENSURE_SUCCESS(rv, rv); + nsresult rv = col->GetIndex(&colIdx); + if (NS_FAILED(rv)) + return; + #endif for (PRInt32 rowIdx = aRow; rowIdx < aRow - aCount; rowIdx++) { @@ -629,7 +634,8 @@ nsXULTreeAccessible::InvalidateCache(PRInt32 aRow, PRInt32 aCount) PRInt32 newRowCount = 0; rv = mTreeView->GetRowCount(&newRowCount); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) + return; PRInt32 oldRowCount = newRowCount - aCount; @@ -643,18 +649,14 @@ nsXULTreeAccessible::InvalidateCache(PRInt32 aRow, PRInt32 aCount) mAccessNodeCache->Remove(key); } } - - return NS_OK; } -// void nsIAccessibleTreeCache:: -// treeViewInvalidated(in long aStartRow, in long aEndRow, -// in long aStartCol, in long aEndCol); -NS_IMETHODIMP +void nsXULTreeAccessible::TreeViewInvalidated(PRInt32 aStartRow, PRInt32 aEndRow, PRInt32 aStartCol, PRInt32 aEndCol) { - NS_ENSURE_TRUE(mTree && mTreeView, NS_ERROR_FAILURE); + if (IsDefunct()) + return; PRInt32 endRow = aEndRow; @@ -662,14 +664,16 @@ nsXULTreeAccessible::TreeViewInvalidated(PRInt32 aStartRow, PRInt32 aEndRow, if (endRow == -1) { PRInt32 rowCount = 0; rv = mTreeView->GetRowCount(&rowCount); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) + return; endRow = rowCount - 1; } nsCOMPtr treeColumns; mTree->GetColumns(getter_AddRefs(treeColumns)); - NS_ENSURE_STATE(treeColumns); + if (!treeColumns) + return; #ifdef MOZ_ACCESSIBILITY_ATK PRInt32 endCol = aEndCol; @@ -677,21 +681,22 @@ nsXULTreeAccessible::TreeViewInvalidated(PRInt32 aStartRow, PRInt32 aEndRow, if (endCol == -1) { PRInt32 colCount = 0; rv = treeColumns->GetCount(&colCount); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) + return; endCol = colCount - 1; } #else nsCOMPtr col; rv = treeColumns->GetKeyColumn(getter_AddRefs(col)); - NS_ENSURE_SUCCESS(rv, rv); - if (!col) - return NS_OK; + return; PRInt32 colIdx = 0; rv = col->GetIndex(&colIdx); - NS_ENSURE_SUCCESS(rv, rv); + if (NS_FAILED(rv)) + return; + #endif for (PRInt32 rowIdx = aStartRow; rowIdx <= endRow; ++rowIdx) { @@ -705,37 +710,29 @@ nsXULTreeAccessible::TreeViewInvalidated(PRInt32 aStartRow, PRInt32 aEndRow, GetCacheEntry(*mAccessNodeCache, key, getter_AddRefs(accessNode)); if (accessNode) { - nsCOMPtr acc(do_QueryInterface(accessNode)); - NS_ENSURE_STATE(acc); - - nsCOMPtr treeItemAcc( - do_QueryInterface(accessNode)); - NS_ENSURE_STATE(treeItemAcc); + nsRefPtr treeitemAcc( + nsAccUtils::QueryAccessibleTreeitem(accessNode)); + NS_ASSERTION(treeitemAcc, "Wrong accessible at the given key!"); nsAutoString name, cachedName; - rv = acc->GetName(name); - NS_ENSURE_SUCCESS(rv, rv); - - rv = treeItemAcc->GetCachedName(cachedName); - NS_ENSURE_SUCCESS(rv, rv); + treeitemAcc->GetName(name); + treeitemAcc->GetCachedName(cachedName); if (name != cachedName) { - nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, acc); - treeItemAcc->SetCachedName(name); + nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, + treeitemAcc); + treeitemAcc->SetCachedName(name); } } } } - - return NS_OK; } -// void nsIAccessibleTreeCache::treeViewChanged(); -NS_IMETHODIMP +void nsXULTreeAccessible::TreeViewChanged() { - if (!mTree) - return NS_ERROR_FAILURE; + if (IsDefunct()) + return; // Fire only notification destroy/create events on accessible tree to lie to // AT because it should be expensive to fire destroy events for each tree item @@ -743,22 +740,22 @@ nsXULTreeAccessible::TreeViewChanged() nsCOMPtr eventDestroy = new nsAccEvent(nsIAccessibleEvent::EVENT_DOM_DESTROY, this, PR_FALSE); - NS_ENSURE_TRUE(eventDestroy, NS_ERROR_OUT_OF_MEMORY); + if (!eventDestroy) + return; - nsresult rv = FirePlatformEvent(eventDestroy); + FirePlatformEvent(eventDestroy); ClearCache(*mAccessNodeCache); mTree->GetView(getter_AddRefs(mTreeView)); - NS_ENSURE_SUCCESS(rv, rv); - nsCOMPtr eventCreate = new nsAccEvent(nsIAccessibleEvent::EVENT_DOM_CREATE, this, PR_FALSE); - NS_ENSURE_TRUE(eventCreate, NS_ERROR_OUT_OF_MEMORY); + if (!eventCreate) + return; - return FirePlatformEvent(eventCreate); + FirePlatformEvent(eventCreate); } nsresult nsXULTreeAccessible::GetColumnCount(nsITreeBoxObject* aBoxObject, PRInt32* aCount) @@ -795,9 +792,12 @@ nsXULTreeitemAccessible::nsXULTreeitemAccessible(nsIAccessible *aParent, nsIDOMN } } -NS_IMPL_ISUPPORTS_INHERITED1(nsXULTreeitemAccessible, nsLeafAccessible, - nsPIAccessibleTreeItem) +NS_IMPL_ISUPPORTS_INHERITED1(nsXULTreeitemAccessible, + nsLeafAccessible, + nsXULTreeitemAccessible) +// nsAccessNode + nsresult nsXULTreeitemAccessible::Shutdown() { @@ -807,6 +807,8 @@ nsXULTreeitemAccessible::Shutdown() return nsLeafAccessible::Shutdown(); } +// nsIAccessible + NS_IMETHODIMP nsXULTreeitemAccessible::GetName(nsAString& aName) { @@ -1102,7 +1104,8 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetNextSibling(nsIAccessible **aNextSibli if (IsDefunct()) return NS_ERROR_FAILURE; - nsCOMPtr treeCache(do_QueryInterface(mParent)); + nsRefPtr treeCache = + nsAccUtils::QueryAccessibleTree(mParent); NS_ENSURE_TRUE(treeCache, NS_ERROR_FAILURE); PRInt32 rowCount; @@ -1110,12 +1113,11 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetNextSibling(nsIAccessible **aNextSibli if (!mColumn) { if (mRow < rowCount - 1) - return treeCache->GetCachedTreeitemAccessible(mRow + 1, nsnull, aNextSibling); - else - return NS_OK; + treeCache->GetCachedTreeitemAccessible(mRow + 1, nsnull, aNextSibling); + + return NS_OK; } - nsresult rv = NS_OK; PRInt32 row = mRow; nsCOMPtr column; #ifdef MOZ_ACCESSIBILITY_ATK @@ -1136,9 +1138,8 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetNextSibling(nsIAccessible **aNextSibli } #endif //MOZ_ACCESSIBILITY_ATK - rv = treeCache->GetCachedTreeitemAccessible(row, column, aNextSibling); - - return rv; + treeCache->GetCachedTreeitemAccessible(row, column, aNextSibling); + return NS_OK; } // Return the previous row of tree if mColumn (if any), @@ -1151,12 +1152,13 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetPreviousSibling(nsIAccessible **aPrevi if (IsDefunct()) return NS_ERROR_FAILURE; - nsCOMPtr treeCache(do_QueryInterface(mParent)); + nsRefPtr treeCache = + nsAccUtils::QueryAccessibleTree(mParent); NS_ENSURE_TRUE(treeCache, NS_ERROR_FAILURE); if (!mColumn && mRow > 0) - return treeCache->GetCachedTreeitemAccessible(mRow - 1, nsnull, aPreviousSibling); - + treeCache->GetCachedTreeitemAccessible(mRow - 1, nsnull, aPreviousSibling); + nsresult rv = NS_OK; @@ -1176,9 +1178,8 @@ NS_IMETHODIMP nsXULTreeitemAccessible::GetPreviousSibling(nsIAccessible **aPrevi } #endif - rv = treeCache->GetCachedTreeitemAccessible(row, column, aPreviousSibling); - - return rv; + treeCache->GetCachedTreeitemAccessible(row, column, aPreviousSibling); + return NS_OK; } NS_IMETHODIMP nsXULTreeitemAccessible::DoAction(PRUint8 index) @@ -1294,13 +1295,12 @@ nsXULTreeitemAccessible::GetRelationByType(PRUint32 aRelationType, if (parentIndex == -1) return nsRelUtils::AddTarget(aRelationType, aRelation, mParent); - nsCOMPtr cache = - do_QueryInterface(mParent); + nsRefPtr treeCache = + nsAccUtils::QueryAccessibleTree(mParent); + nsCOMPtr accParent; - nsresult rv = cache-> - GetCachedTreeitemAccessible(parentIndex, mColumn, - getter_AddRefs(accParent)); - NS_ENSURE_SUCCESS(rv, rv); + treeCache->GetCachedTreeitemAccessible(parentIndex, mColumn, + getter_AddRefs(accParent)); return nsRelUtils::AddTarget(aRelationType, aRelation, accParent); } @@ -1312,20 +1312,17 @@ nsXULTreeitemAccessible::GetRelationByType(PRUint32 aRelationType, return nsAccessible::GetRelationByType(aRelationType, aRelation); } -// attribute AString nsIAccessibleTreeItem::cachedName -NS_IMETHODIMP +// nsXULTreeitemAccessible +void nsXULTreeitemAccessible::GetCachedName(nsAString &aName) { aName = mCachedName; - return NS_OK; } -// attribute AString nsIAccessibleTreeItem::cachedName -NS_IMETHODIMP +void nsXULTreeitemAccessible::SetCachedName(const nsAString &aName) { mCachedName = aName; - return NS_OK; } //////////////////////////////////////////////////////////////////////////////// @@ -1355,10 +1352,11 @@ nsXULTreeColumnsAccessible::GetNextSibling(nsIAccessible **aNextSibling) nsCOMPtr column = nsXULTreeAccessible::GetFirstVisibleColumn(tree); - nsCOMPtr treeCache(do_QueryInterface(mParent)); + nsRefPtr treeCache = + nsAccUtils::QueryAccessibleTree(mParent); NS_ENSURE_TRUE(treeCache, NS_ERROR_FAILURE); - return treeCache->GetCachedTreeitemAccessible(0, column, aNextSibling); + treeCache->GetCachedTreeitemAccessible(0, column, aNextSibling); } } } diff --git a/accessible/src/xul/nsXULTreeAccessible.h b/accessible/src/xul/nsXULTreeAccessible.h index f9ea24f2f518..13960b6c3662 100644 --- a/accessible/src/xul/nsXULTreeAccessible.h +++ b/accessible/src/xul/nsXULTreeAccessible.h @@ -42,7 +42,6 @@ #include "nsITreeView.h" #include "nsITreeColumns.h" #include "nsXULSelectAccessible.h" -#include "nsIAccessibleTreeCache.h" /* * A class the represents the XUL Tree widget. @@ -50,17 +49,30 @@ const PRUint32 kMaxTreeColumns = 100; const PRUint32 kDefaultTreeCacheSize = 256; -class nsXULTreeAccessible : public nsXULSelectableAccessible, - public nsIAccessibleTreeCache +/** + * Accessible class for XUL tree element. + */ + +#define NS_XULTREEACCESSIBLE_IMPL_CID \ +{ /* 2692e149-6176-42ee-b8e1-2c44b04185e3 */ \ + 0x2692e149, \ + 0x6176, \ + 0x42ee, \ + { 0xb8, 0xe1, 0x2c, 0x44, 0xb0, 0x41, 0x85, 0xe3 } \ +} + +class nsXULTreeAccessible : public nsXULSelectableAccessible { public: - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSIACCESSIBLESELECTABLE - NS_DECL_NSIACCESSIBLETREECACHE - nsXULTreeAccessible(nsIDOMNode* aDOMNode, nsIWeakReference* aShell); virtual ~nsXULTreeAccessible() {} + // nsISupports + NS_DECL_ISUPPORTS_INHERITED + + // nsIAccessibleSelectable + NS_DECL_NSIACCESSIBLESELECTABLE + // nsIAccessible NS_IMETHOD GetValue(nsAString& _retval); @@ -70,6 +82,7 @@ public: NS_IMETHOD GetFocusedChild(nsIAccessible **aFocusedChild); // nsAccessNode + virtual PRBool IsDefunct(); virtual nsresult Shutdown(); // nsAccessible @@ -80,6 +93,48 @@ public: nsIAccessible **aChild); // nsXULTreeAccessible + + NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEACCESSIBLE_IMPL_CID) + + /** + * Return tree item accessible at the givem row and column. If accessible + * doesn't exist in the cache then create it. + * + * @param aRow [in] the given row index + * @param aColumn [in] the given column object. If is is nsnull then + * primary column is used + * @param aAccessible [out] tree item accessible + */ + void GetCachedTreeitemAccessible(PRInt32 aRow, nsITreeColumn *aColumn, + nsIAccessible **aAccessible); + + /** + * Invalidates the number of cached treeitem accessibles. + * + * @param aRow [in] row index the invalidation starts from + * @param aCount [in] the number of treeitem accessibles to invalidate, + * the number sign specifies whether rows have been + * inserted (plus) or removed (minus) + */ + void InvalidateCache(PRInt32 aRow, PRInt32 aCount); + + /** + * Fires name change events for invalidated area of tree. + * + * @param aStartRow [in] row index invalidation starts from + * @param aEndRow [in] row index invalidation ends, -1 means last row index + * @param aStartCol [in] column index invalidation starts from + * @param aEndCol [in] column index invalidation ends, -1 mens last column + * index + */ + void TreeViewInvalidated(PRInt32 aStartRow, PRInt32 aEndRow, + PRInt32 aStartCol, PRInt32 aEndCol); + + /** + * Invalidates children created for previous tree view. + */ + void TreeViewChanged(); + static void GetTreeBoxObject(nsIDOMNode* aDOMNode, nsITreeBoxObject** aBoxObject); static nsresult GetColumnCount(nsITreeBoxObject* aBoxObject, PRInt32 *aCount); @@ -96,26 +151,36 @@ protected: NS_IMETHOD ChangeSelection(PRInt32 aIndex, PRUint8 aMethod, PRBool *aSelState); }; +NS_DEFINE_STATIC_IID_ACCESSOR(nsXULTreeAccessible, + NS_XULTREEACCESSIBLE_IMPL_CID) + /** - * Treeitems -- used in Trees - */ -class nsXULTreeitemAccessible : public nsLeafAccessible, - public nsPIAccessibleTreeItem + * Accessible class for items for XUL tree. + */ + +#define NS_XULTREEITEMACCESSIBLE_IMPL_CID \ +{ /* 7b1aa039-7270-4523-aeb3-61063a13ac3f */ \ + 0x7b1aa039, \ + 0x7270, \ + 0x4523, \ + { 0xae, 0xb3, 0x61, 0x06, 0x3a, 0x13, 0xac, 0x3f } \ +} + +class nsXULTreeitemAccessible : public nsLeafAccessible { public: enum { eAction_Click = 0, eAction_Expand = 1 }; - NS_DECL_ISUPPORTS_INHERITED - NS_DECL_NSPIACCESSIBLETREEITEM - nsXULTreeitemAccessible(nsIAccessible *aParent, nsIDOMNode *aDOMNode, nsIWeakReference *aShell, PRInt32 aRow, nsITreeColumn* aColumn = nsnull); virtual ~nsXULTreeitemAccessible() {} + // nsISupports + NS_DECL_ISUPPORTS_INHERITED + // nsIAccessible NS_IMETHOD GetName(nsAString& aName); NS_IMETHOD GetNumActions(PRUint8 *_retval); NS_IMETHOD GetActionName(PRUint8 aIndex, nsAString& aName); - virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes); NS_IMETHOD GetParent(nsIAccessible **_retval); NS_IMETHOD GetNextSibling(nsIAccessible **_retval); @@ -138,9 +203,19 @@ public: virtual nsresult Shutdown(); // nsAccessible + virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes); virtual nsresult GetRoleInternal(PRUint32 *aRole); virtual nsresult GetStateInternal(PRUint32 *aState, PRUint32 *aExtraState); + // nsXULTreeitemAccessible + NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEITEMACCESSIBLE_IMPL_CID) + + /** + * Get/set cached name. + */ + void GetCachedName(nsAString& aName); + void SetCachedName(const nsAString& aName); + protected: PRBool IsExpandable(); nsCOMPtr mTree; @@ -150,6 +225,12 @@ protected: nsString mCachedName; }; +NS_DEFINE_STATIC_IID_ACCESSOR(nsXULTreeitemAccessible, + NS_XULTREEITEMACCESSIBLE_IMPL_CID) + +/** + * Accessible class for columns element of XUL tree. + */ class nsXULTreeColumnsAccessible : public nsXULColumnsAccessible { public: diff --git a/accessible/tests/mochitest/Makefile.in b/accessible/tests/mochitest/Makefile.in index d9f40b50e1e9..1c557a6955e4 100644 --- a/accessible/tests/mochitest/Makefile.in +++ b/accessible/tests/mochitest/Makefile.in @@ -126,7 +126,7 @@ _TEST_FILES =\ test_table_2.html \ test_table_3.html \ test_table_4.html \ - $(warning test_table_indexes.html temporarily disabled) \ + test_table_indexes.html \ test_table_indexes_ariagrid.html \ test_table_sels_ariagrid.html \ test_textattrs.html \ diff --git a/accessible/tests/mochitest/table.js b/accessible/tests/mochitest/table.js index cdab744e1377..96e027888f99 100644 --- a/accessible/tests/mochitest/table.js +++ b/accessible/tests/mochitest/table.js @@ -2,70 +2,91 @@ * Test table indexes. * * @param aIdentifier [in] table accessible identifier - * @param aLen [in] cells count - * @param aRowIdxes [in] array of row indexes for each cell index - * @param aColIdxes [in] array of column indexes for each cell index + * @param aIdxes [in] two dimensional array of cell indexes */ -function testTableIndexes(aIdentifier, aLen, aRowIdxes, aColIdxes) +function testTableIndexes(aIdentifier, aIdxes) { var tableAcc = getAccessible(aIdentifier, [nsIAccessibleTable]); if (!tableAcc) return; - var row, column, index; + var obtainedRowIdx, obtainedColIdx, obtainedIdx; var cellAcc; var id = prettyName(aIdentifier); - for (var i = 0; i < aLen; i++) { - try { - row = tableAcc.getRowAtIndex(i); - } catch (e) { - ok(false, id + ": can't get row index for cell index " + i + "," + e); - } + var rowCount = aIdxes.length; + for (var rowIdx = 0; rowIdx < rowCount; rowIdx++) { + var colCount = aIdxes[rowIdx].length; + for (var colIdx = 0; colIdx < colCount; colIdx++) { + var idx = aIdxes[rowIdx][colIdx]; + if (idx != - 1) { + // getRowAtIndex + var origRowIdx = rowIdx; + while (origRowIdx > 0 && + aIdxes[rowIdx][colIdx] == aIdxes[origRowIdx - 1][colIdx]) + origRowIdx--; - try { - column = tableAcc.getColumnAtIndex(i); - } catch (e) { - ok(false, id + ": can't get column index for cell index " + i + "," + e); - } + try { + obtainedRowIdx = tableAcc.getRowAtIndex(idx); + } catch (e) { + ok(false, id + ": can't get row index for cell index " + idx + "," + e); + } - try { - index = tableAcc.getIndexAt(aRowIdxes[i], aColIdxes[i]); - } catch (e) { - ok(false, - id + ": can't get cell index by row index " + aRowIdxes[i] + - " and column index: " + aColIdxes[i] + ", " + e); - } + is(obtainedRowIdx, origRowIdx, + id + ": row for index " + idx +" is not correct"); - is(row, aRowIdxes[i], id + ": row for index " + i +" is nor correct"); - is(column, aColIdxes[i], - id + ": column for index " + i +" is not correct"); - is(index, i, - id + ": row " + row + " /column " + column + " and index " + index + " aren't inconsistent."); + // getColumnAtIndex + var origColIdx = colIdx; + while (origColIdx > 0 && + aIdxes[rowIdx][colIdx] == aIdxes[rowIdx][origColIdx - 1]) + origColIdx--; - try { - cellAcc = null; - cellAcc = tableAcc.cellRefAt(row, column); - } catch (e) { } + try { + obtainedColIdx = tableAcc.getColumnAtIndex(idx); + } catch (e) { + ok(false, id + ": can't get column index for cell index " + idx + "," + e); + } - ok(cellAcc, - id + ": Can't get cell accessible at row = " + row + ", column = " + column); + is(obtainedColIdx, origColIdx, + id + ": column for index " + idx +" is not correct"); - if (cellAcc) { - var attrs = cellAcc.attributes; - var strIdx = ""; + // cellRefAt + try { + cellAcc = null; + cellAcc = tableAcc.cellRefAt(rowIdx, colIdx); + } catch (e) { } + + ok(cellAcc, + id + ": Can't get cell accessible at row = " + rowIdx + ", column = " + colIdx); + + // 'table-cell-index' attribute + if (cellAcc) { + var attrs = cellAcc.attributes; + var strIdx = ""; + try { + strIdx = attrs.getStringProperty("table-cell-index"); + } catch (e) { + ok(false, + id + ": no cell index from object attributes on the cell accessible at index " + idx + "."); + } + + if (strIdx) { + is (parseInt(strIdx), idx, + id + ": cell index from object attributes of cell accessible isn't corrent."); + } + } + } + + // getIndexAt try { - strIdx = attrs.getStringProperty("table-cell-index"); + obtainedIdx = tableAcc.getIndexAt(rowIdx, colIdx); } catch (e) { - ok(false, - id + ": no cell index from object attributes on the cell accessible at index " + index + "."); + obtainedIdx = -1; } - if (strIdx) { - is (parseInt(strIdx), index, - id + ": cell index from object attributes of cell accessible isn't corrent."); - } + is(obtainedIdx, idx, + id + ": row " + rowIdx + " /column " + colIdx + " and index " + obtainedIdx + " aren't inconsistent."); } } } diff --git a/accessible/tests/mochitest/test_aria_token_attrs.html b/accessible/tests/mochitest/test_aria_token_attrs.html index b5cb8b2028f4..220ec618d7a0 100644 --- a/accessible/tests/mochitest/test_aria_token_attrs.html +++ b/accessible/tests/mochitest/test_aria_token_attrs.html @@ -151,7 +151,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=452388 testStates("treeitem_selected_false", STATE_SELECTABLE, 0, STATE_SELECTED); testStates("treeitem_selected_empty", 0, 0, (STATE_SELECTABLE | STATE_SELECTED)); testStates("treeitem_selected_undefined", 0, 0, (STATE_SELECTABLE | STATE_SELECTED)); - testStates("treeitem_selected_absent", 0, 0, (STATE_SELECTABLE | STATE_SELECTED)); + testStates("treeitem_selected_absent", STATE_SELECTABLE, 0, STATE_SELECTED); // test (treeitem) haspopup states testStates("treeitem_haspopup_true", STATE_HASPOPUP); diff --git a/accessible/tests/mochitest/test_table_indexes.html b/accessible/tests/mochitest/test_table_indexes.html index 4ef3fbab8299..f11313adb656 100644 --- a/accessible/tests/mochitest/test_table_indexes.html +++ b/accessible/tests/mochitest/test_table_indexes.html @@ -23,38 +23,90 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410052 { ////////////////////////////////////////////////////////////////////////// // table - var tRow = new Array(0,0,0,1,1,1,2,2,3,3); - var tCol = new Array(0,1,2,0,1,2,0,1,1,2); + var idxes = [ + [0, 1, 2], + [3, 4, 5], + [6, 7, 7], + [6, 8, 9] + ]; - testTableIndexes("table", 10, tRow, tCol); - - ////////////////////////////////////////////////////////////////////////// - // tableinsane1 - tRow = [0,0,0,1,1,1,2,2,3,3]; - tCol = [0,1,2,0,1,2,0,1,1,2]; - - testTableIndexes("tableinsane1", 10, tRow, tCol); - - ////////////////////////////////////////////////////////////////////////// - // tableinsane2 - tRow = [0,0,0,1,1,1,2,2,3,3,4,4,4]; - tCol = [0,1,2,0,1,2,0,1,1,2,1,3,4]; - - testTableIndexes("tableinsane2", 13, tRow, tCol); - - ////////////////////////////////////////////////////////////////////////// - // tableinsane4 - tRow = [0,0,0,1,1,1,2,2,3,4]; - tCol = [0,1,2,0,1,2,0,2,0,0]; - - testTableIndexes("tableinsane4", 10, tRow, tCol); + testTableIndexes("table", idxes); ////////////////////////////////////////////////////////////////////////// // tableborder - tRow = [0,0,0,1,1,1,2,2,3,3]; - tCol = [0,1,2,0,1,2,0,1,1,2]; + idxes = [ + [0, 1, 2], + [3, 4, 5], + [6, 7, 7], + [6, 8, 9] + ]; - testTableIndexes("tableborder", 10, tRow, tCol); + testTableIndexes("tableborder", idxes); + + ////////////////////////////////////////////////////////////////////////// + // table + var idxes = [ + [ 0, 1, 2, 2, 3, 4, 5, 6], + [ 7, 8, 9, 10, 11, 12, 13, 6], + [14, 15, 15, 16, 17, 18, 19, 6], + [20, 15, 15, 21, 22, 18, 23, 6] + ]; + + testTableIndexes("table2", idxes); + + ////////////////////////////////////////////////////////////////////////// + // tableinsane1 (empty row groups) + idxes = [ + [0, 1, 2], + [3, 4, 5], + [6, 7, 7], + [6, 8, 9] + ]; + + testTableIndexes("tableinsane1", idxes); + + ////////////////////////////////////////////////////////////////////////// + // tableinsane2 (empry rows) + idxes = [ + [-1, -1, -1], + [-1, -1, -1], + [ 0, 1, 2] + ]; + + testTableIndexes("tableinsane2", idxes); + + ////////////////////////////////////////////////////////////////////////// + // tableinsane3 (cell holes) + idxes = [ + [0, 1, -1], + [2, 3, 4] + ]; + + testTableIndexes("tableinsane3", idxes); + + ////////////////////////////////////////////////////////////////////////// + // tableinsane4 (empty row groups/rows and cell holes) + idxes = [ + [ 0, 1, 2], + [-1, -1, -1], + [ 3, 4, 5], + [ 6, 6, 7], + [ 8, -1, 7], + [ 9, 9, 9] + ]; + testTableIndexes("tableinsane4", idxes); + + ////////////////////////////////////////////////////////////////////////// + // tableinsane4 (just a crazy table) + idxes = [ + [ 0, 1, 2, -1, -1], + [-1, -1, -1, -1, -1], + [ 3, 4, 5, -1, -1], + [ 6, 7, 7, 7, 7], + [ 6, 8, 9, -1, -1], + [ 6, 10, 9, 11, 12] + ]; + testTableIndexes("tableinsane5", idxes); SimpleTest.finish(); } @@ -127,6 +179,44 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410052 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
column and row spans
0123456
78810111213
141516171819
20212223
+ @@ -156,8 +246,70 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410052
test empty row groups
- - +
empty rowgroup + empty rows
+ + + + + + + + + + +
empty rows
012
+ + + + + + + + + + + + + + + + +
missed cell
01
234
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
test empty rows + cellmap holes
col1col2col3
123
45
6
7
+ + + @@ -190,37 +342,5 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=410052 -
just a crazy table
col1
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
test cellmap holes
col1col2col3
123
45
6
7
- diff --git a/accessible/tests/mochitest/test_table_indexes_ariagrid.html b/accessible/tests/mochitest/test_table_indexes_ariagrid.html index 78e47031d0eb..3354d8a8bf59 100644 --- a/accessible/tests/mochitest/test_table_indexes_ariagrid.html +++ b/accessible/tests/mochitest/test_table_indexes_ariagrid.html @@ -22,10 +22,13 @@ { ////////////////////////////////////////////////////////////////////////// // ARIA grid - var tRow = new Array(0, 0, 0, 1, 1, 1, 2, 2, 2, 3, 3, 3); - var tCol = new Array(0, 1, 2, 0, 1, 2, 0, 1, 2, 0, 1, 2); - - testTableIndexes("grid", 12, tRow, tCol); + var idxes = [ + [0, 1, 2], + [3, 4, 5], + [6, 7, 8], + [9, 10, 11] + ]; + testTableIndexes("grid", idxes); SimpleTest.finish(); } diff --git a/allmakefiles.sh b/allmakefiles.sh index 9823e7e82650..415b781797b8 100755 --- a/allmakefiles.sh +++ b/allmakefiles.sh @@ -58,22 +58,32 @@ fi add_makefiles " Makefile build/Makefile +build/pgo/Makefile +build/pgo/blueprint/Makefile +build/pgo/js-input/Makefile build/unix/Makefile +build/win32/Makefile config/Makefile config/autoconf.mk config/mkdepend/Makefile +config/nspr/Makefile config/doxygen.cfg config/tests/src-simple/Makefile probes/Makefile extensions/Makefile -build/wince/tools/Makefile -build/wince/shunt/Makefile -build/wince/shunt/include/windows.h -build/wince/shunt/include/ymath.h -build/wince/shunt/include/stdlib.h -build/wince/shunt/include/sys/Makefile " +if [ "$WINCE" ]; then + add_makefiles " + build/wince/tools/Makefile + build/wince/shunt/Makefile + build/wince/shunt/include/windows.h + build/wince/shunt/include/ymath.h + build/wince/shunt/include/stdlib.h + build/wince/shunt/include/sys/Makefile + " +fi + if [ "$MOZ_MEMORY" ]; then add_makefiles " memory/jemalloc/Makefile diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 673096e7901e..f657f21dbd51 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -545,7 +545,7 @@