bug 657719 - nsAccessible::GetIndexInParent() overloaded virtual method r=surkov
authorTrevor Saunders <trev.saunders@gmail.com>
Mon, 13 Jun 2011 02:08:40 -0700
changeset 71766 a874d24d19b6ad2901dd42eb0f08ed185ac703b7
parent 71765 82b9558a9eeb1011206f3a3abeaef370d1f5a061
child 71767 0f5f486a0a23fe8bb480285ce0c10a8c8914b75c
push id20606
push usertrev.saunders@gmail.com
push dateSun, 26 Jun 2011 05:03:23 +0000
treeherdermozilla-central@fc7d76664c79 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs657719
milestone7.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 657719 - nsAccessible::GetIndexInParent() overloaded virtual method r=surkov From 9456a3d1de8d5d707de94c040627d6daf871fcf1 Mon Sep 17 00:00:00 2001 --- accessible/src/atk/nsApplicationAccessibleWrap.cpp | 2 +- accessible/src/base/AccGroupInfo.cpp | 2 +- accessible/src/base/NotificationController.cpp | 8 ++++---- accessible/src/base/nsARIAGridAccessible.cpp | 4 ++-- accessible/src/base/nsAccessible.cpp | 6 +++--- accessible/src/base/nsAccessible.h | 2 +- accessible/src/html/nsHTMLImageMapAccessible.cpp | 4 ++-- accessible/src/html/nsHyperTextAccessible.cpp | 4 ++-- accessible/src/msaa/nsAccessibleWrap.cpp | 15 +++++++-------- accessible/src/xul/nsXULListboxAccessible.cpp | 4 ++-- accessible/src/xul/nsXULTextAccessible.cpp | 4 ++-- accessible/src/xul/nsXULTreeAccessible.cpp | 4 ++-- accessible/src/xul/nsXULTreeAccessible.h | 2 +- accessible/src/xul/nsXULTreeGridAccessible.cpp | 2 +- accessible/src/xul/nsXULTreeGridAccessible.h | 2 +- 15 files changed, 32 insertions(+), 33 deletions(-)
accessible/src/atk/nsApplicationAccessibleWrap.cpp
accessible/src/base/AccGroupInfo.cpp
accessible/src/base/NotificationController.cpp
accessible/src/base/nsARIAGridAccessible.cpp
accessible/src/base/nsAccessible.cpp
accessible/src/base/nsAccessible.h
accessible/src/html/nsHTMLImageMapAccessible.cpp
accessible/src/html/nsHyperTextAccessible.cpp
accessible/src/msaa/nsAccessibleWrap.cpp
accessible/src/xul/nsXULListboxAccessible.cpp
accessible/src/xul/nsXULTextAccessible.cpp
accessible/src/xul/nsXULTreeAccessible.cpp
accessible/src/xul/nsXULTreeAccessible.h
accessible/src/xul/nsXULTreeGridAccessible.cpp
accessible/src/xul/nsXULTreeGridAccessible.h
--- a/accessible/src/atk/nsApplicationAccessibleWrap.cpp
+++ b/accessible/src/atk/nsApplicationAccessibleWrap.cpp
@@ -700,17 +700,17 @@ nsApplicationAccessibleWrap::AppendChild
     }
 
     return PR_TRUE;
 }
 
 PRBool
 nsApplicationAccessibleWrap::RemoveChild(nsAccessible* aChild)
 {
-    PRInt32 index = aChild->GetIndexInParent();
+    PRInt32 index = aChild->IndexInParent();
 
     AtkObject *atkAccessible = nsAccessibleWrap::GetAtkObject(aChild);
     atk_object_set_parent(atkAccessible, NULL);
     g_signal_emit_by_name(mAtkObject, "children_changed::remove", index,
                           atkAccessible, NULL);
 
     return nsApplicationAccessible::RemoveChild(aChild);
 }
--- a/accessible/src/base/AccGroupInfo.cpp
+++ b/accessible/src/base/AccGroupInfo.cpp
@@ -42,17 +42,17 @@
 AccGroupInfo::AccGroupInfo(nsAccessible* aItem, PRUint32 aRole) :
   mPosInSet(0), mSetSize(0), mParent(nsnull)
 {
   MOZ_COUNT_CTOR(AccGroupInfo);
   nsAccessible* parent = aItem->GetParent();
   if (!parent)
     return;
 
-  PRInt32 indexInParent = aItem->GetIndexInParent();
+  PRInt32 indexInParent = aItem->IndexInParent();
   PRInt32 level = nsAccUtils::GetARIAOrDefaultLevel(aItem);
 
   // Compute position in set.
   mPosInSet = 1;
   for (PRInt32 idx = indexInParent - 1; idx >=0 ; idx--) {
     nsAccessible* sibling = parent->GetChildAt(idx);
     PRUint32 siblingRole = sibling->Role();
 
--- a/accessible/src/base/NotificationController.cpp
+++ b/accessible/src/base/NotificationController.cpp
@@ -510,24 +510,24 @@ NotificationController::CoalesceTextChan
 void
 NotificationController::CoalesceTextChangeEventsFor(AccShowEvent* aTailEvent,
                                                     AccShowEvent* aThisEvent)
 {
   AccTextChangeEvent* textEvent = aThisEvent->mTextChangeEvent;
   if (!textEvent)
     return;
 
-  if (aTailEvent->mAccessible->GetIndexInParent() ==
-      aThisEvent->mAccessible->GetIndexInParent() + 1) {
+  if (aTailEvent->mAccessible->IndexInParent() ==
+      aThisEvent->mAccessible->IndexInParent() + 1) {
     // If tail target was inserted after this target, i.e. tail target is next
     // sibling of this target.
     aTailEvent->mAccessible->AppendTextTo(textEvent->mModifiedText);
 
-  } else if (aTailEvent->mAccessible->GetIndexInParent() ==
-             aThisEvent->mAccessible->GetIndexInParent() -1) {
+  } else if (aTailEvent->mAccessible->IndexInParent() ==
+             aThisEvent->mAccessible->IndexInParent() -1) {
     // If tail target was inserted before this target, i.e. tail target is
     // previous sibling of this target.
     nsAutoString startText;
     aTailEvent->mAccessible->AppendTextTo(startText);
     textEvent->mModifiedText = startText + textEvent->mModifiedText;
     textEvent->mStart -= startText.Length();
   }
 
--- a/accessible/src/base/nsARIAGridAccessible.cpp
+++ b/accessible/src/base/nsARIAGridAccessible.cpp
@@ -976,17 +976,17 @@ nsARIAGridCellAccessible::GetColumnIndex
     return NS_ERROR_FAILURE;
 
   nsAccessible* row = GetParent();
   if (!row)
     return NS_OK;
 
   *aColumnIndex = 0;
 
-  PRInt32 indexInRow = GetIndexInParent();
+  PRInt32 indexInRow = IndexInParent();
   for (PRInt32 idx = 0; idx < indexInRow; idx++) {
     nsAccessible* cell = row->GetChildAt(idx);
     PRUint32 role = cell->Role();
     if (role == nsIAccessibleRole::ROLE_GRID_CELL ||
         role == nsIAccessibleRole::ROLE_ROWHEADER ||
         role == nsIAccessibleRole::ROLE_COLUMNHEADER)
       (*aColumnIndex)++;
   }
@@ -1008,17 +1008,17 @@ nsARIAGridCellAccessible::GetRowIndex(PR
     return NS_OK;
 
   nsAccessible* table = row->GetParent();
   if (!table)
     return NS_OK;
 
   *aRowIndex = 0;
 
-  PRInt32 indexInTable = row->GetIndexInParent();
+  PRInt32 indexInTable = row->IndexInParent();
   for (PRInt32 idx = 0; idx < indexInTable; idx++) {
     row = table->GetChildAt(idx);
     if (row->Role() == nsIAccessibleRole::ROLE_ROW)
       (*aRowIndex)++;
   }
 
   return NS_OK;
 }
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -583,17 +583,17 @@ nsAccessible::GetChildCount(PRInt32 *aCh
 }
 
 /* readonly attribute long indexInParent; */
 NS_IMETHODIMP
 nsAccessible::GetIndexInParent(PRInt32 *aIndexInParent)
 {
   NS_ENSURE_ARG_POINTER(aIndexInParent);
 
-  *aIndexInParent = GetIndexInParent();
+  *aIndexInParent = IndexInParent();
   return *aIndexInParent != -1 ? NS_OK : NS_ERROR_FAILURE;
 }
 
 nsresult nsAccessible::GetTranslatedString(const nsAString& aKey, nsAString& aStringOut)
 {
   nsXPIDLString xsValue;
 
   if (!gStringBundle || 
@@ -2839,21 +2839,21 @@ PRInt32
 nsAccessible::GetChildCount()
 {
   return mChildren.Length();
 }
 
 PRInt32
 nsAccessible::GetIndexOf(nsAccessible* aChild)
 {
-  return (aChild->mParent != this) ? -1 : aChild->GetIndexInParent();
+  return (aChild->mParent != this) ? -1 : aChild->IndexInParent();
 }
 
 PRInt32
-nsAccessible::GetIndexInParent() const
+nsAccessible::IndexInParent() const
 {
   return mIndexInParent;
 }
 
 PRInt32
 nsAccessible::GetEmbeddedChildCount()
 {
   if (IsChildrenFlag(eMixedChildren)) {
--- a/accessible/src/base/nsAccessible.h
+++ b/accessible/src/base/nsAccessible.h
@@ -292,17 +292,17 @@ public:
   /**
    * Return index of the given child accessible.
    */
   virtual PRInt32 GetIndexOf(nsAccessible* aChild);
 
   /**
    * Return index in parent accessible.
    */
-  virtual PRInt32 GetIndexInParent() const;
+  virtual PRInt32 IndexInParent() const;
 
   /**
    * Return true if accessible has children;
    */
   PRBool HasChildren() { return !!GetChildAt(0); }
 
   /**
    * Return next/previous sibling of the accessible.
--- a/accessible/src/html/nsHTMLImageMapAccessible.cpp
+++ b/accessible/src/html/nsHTMLImageMapAccessible.cpp
@@ -256,23 +256,23 @@ nsHTMLAreaAccessible::GetChildAtPoint(PR
 PRUint32
 nsHTMLAreaAccessible::StartOffset()
 {
   // Image map accessible is not hypertext accessible therefore
   // StartOffset/EndOffset implementations of nsAccessible doesn't work here.
   // We return index in parent because image map contains area links only which
   // are embedded objects.
   // XXX: image map should be a hypertext accessible.
-  return GetIndexInParent();
+  return IndexInParent();
 }
 
 PRUint32
 nsHTMLAreaAccessible::EndOffset()
 {
-  return GetIndexInParent() + 1;
+  return IndexInParent() + 1;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsHTMLAreaAccessible: nsAccessible protected
 
 void
 nsHTMLAreaAccessible::CacheChildren()
 {
--- a/accessible/src/html/nsHyperTextAccessible.cpp
+++ b/accessible/src/html/nsHyperTextAccessible.cpp
@@ -1149,17 +1149,17 @@ nsHyperTextAccessible::GetTextAttributes
         nsTextAttrsMgr textAttrsMgr(this, PR_TRUE, nsnull, -1);
         return textAttrsMgr.GetAttributes(*aAttributes);
       }
       return NS_OK;
     }
     return NS_ERROR_INVALID_ARG;
   }
 
-  PRInt32 accAtOffsetIdx = accAtOffset->GetIndexInParent();
+  PRInt32 accAtOffsetIdx = accAtOffset->IndexInParent();
   PRInt32 startOffset = GetChildOffset(accAtOffsetIdx);
   PRInt32 endOffset = GetChildOffset(accAtOffsetIdx + 1);
   PRInt32 offsetInAcc = aOffset - startOffset;
 
   nsTextAttrsMgr textAttrsMgr(this, aIncludeDefAttrs, accAtOffset,
                               accAtOffsetIdx);
   nsresult rv = textAttrsMgr.GetAttributes(*aAttributes, &startOffset,
                                            &endOffset);
@@ -2088,17 +2088,17 @@ nsHyperTextAccessible::InvalidateChildre
   mOffsets.Clear();
 
   nsAccessibleWrap::InvalidateChildren();
 }
 
 PRBool
 nsHyperTextAccessible::RemoveChild(nsAccessible* aAccessible)
 {
-  PRInt32 childIndex = aAccessible->GetIndexInParent();
+  PRInt32 childIndex = aAccessible->IndexInParent();
   PRInt32 count = mOffsets.Length() - childIndex;
   if (count > 0)
     mOffsets.RemoveElementsAt(childIndex, count);
 
   return nsAccessible::RemoveChild(aAccessible);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
--- a/accessible/src/msaa/nsAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsAccessibleWrap.cpp
@@ -1377,29 +1377,28 @@ nsAccessibleWrap::get_windowHandle(HWND 
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return E_FAIL;
 }
 
 STDMETHODIMP
 nsAccessibleWrap::get_indexInParent(long *aIndexInParent)
 {
 __try {
-  *aIndexInParent = -1;
+  if (!aIndexInParent)
+    return E_INVALIDARG;
 
-  PRInt32 index = -1;
-  nsresult rv = GetIndexInParent(&index);
-  if (NS_FAILED(rv))
-    return GetHRESULT(rv);
+  *aIndexInParent = -1;
+  if (IsDefunct())
+    return E_FAIL;
 
-  if (index == -1)
+  *aIndexInParent = IndexInParent();
+  if (*aIndexInParent == -1)
     return S_FALSE;
 
-  *aIndexInParent = index;
   return S_OK;
-
 } __except(nsAccessNodeWrap::FilterA11yExceptions(::GetExceptionCode(), GetExceptionInformation())) { }
   return E_FAIL;
 }
 
 STDMETHODIMP
 nsAccessibleWrap::get_locale(IA2Locale *aLocale)
 {
 __try {
--- a/accessible/src/xul/nsXULListboxAccessible.cpp
+++ b/accessible/src/xul/nsXULListboxAccessible.cpp
@@ -1020,17 +1020,17 @@ nsXULListCellAccessible::GetColumnIndex(
     return NS_ERROR_FAILURE;
 
   nsAccessible* row = GetParent();
   if (!row)
     return NS_OK;
 
   *aColumnIndex = 0;
 
-  PRInt32 indexInRow = GetIndexInParent();
+  PRInt32 indexInRow = IndexInParent();
   for (PRInt32 idx = 0; idx < indexInRow; idx++) {
     nsAccessible* cell = row->GetChildAt(idx);
     PRUint32 role = cell->Role();
     if (role == nsIAccessibleRole::ROLE_CELL ||
         role == nsIAccessibleRole::ROLE_GRID_CELL ||
         role == nsIAccessibleRole::ROLE_ROWHEADER ||
         role == nsIAccessibleRole::ROLE_COLUMNHEADER)
       (*aColumnIndex)++;
@@ -1053,17 +1053,17 @@ nsXULListCellAccessible::GetRowIndex(PRI
     return NS_OK;
 
   nsAccessible* table = row->GetParent();
   if (!table)
     return NS_OK;
 
   *aRowIndex = 0;
 
-  PRInt32 indexInTable = row->GetIndexInParent();
+  PRInt32 indexInTable = row->IndexInParent();
   for (PRInt32 idx = 0; idx < indexInTable; idx++) {
     row = table->GetChildAt(idx);
     if (row->Role() == nsIAccessibleRole::ROLE_ROW)
       (*aRowIndex)++;
   }
 
   return NS_OK;
 }
--- a/accessible/src/xul/nsXULTextAccessible.cpp
+++ b/accessible/src/xul/nsXULTextAccessible.cpp
@@ -236,25 +236,25 @@ nsXULLinkAccessible::StartOffset()
 {
   // If XUL link accessible is not contained by hypertext accessible then
   // start offset matches index in parent because the parent doesn't contains
   // a text.
   // XXX: accessible parent of XUL link accessible should be a hypertext
   // accessible.
   if (nsAccessible::IsHyperLink())
     return nsAccessible::StartOffset();
-  return GetIndexInParent();
+  return IndexInParent();
 }
 
 PRUint32
 nsXULLinkAccessible::EndOffset()
 {
   if (nsAccessible::IsHyperLink())
     return nsAccessible::EndOffset();
-  return GetIndexInParent() + 1;
+  return IndexInParent() + 1;
 }
 
 already_AddRefed<nsIURI>
 nsXULLinkAccessible::GetAnchorURI(PRUint32 aAnchorIndex)
 {
   if (aAnchorIndex != 0)
     return nsnull;
 
--- a/accessible/src/xul/nsXULTreeAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeAccessible.cpp
@@ -981,17 +981,17 @@ nsXULTreeItemAccessibleBase::NativeState
   mTree->GetLastVisibleRow(&lastVisibleRow);
   if (mRow < firstVisibleRow || mRow > lastVisibleRow)
     state |= states::INVISIBLE;
 
   return state;
 }
 
 PRInt32
-nsXULTreeItemAccessibleBase::GetIndexInParent() const
+nsXULTreeItemAccessibleBase::IndexInParent() const
 {
   return mParent ? mParent->ContentChildCount() + mRow : -1;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULTreeItemAccessibleBase: nsAccessible protected methods
 
 void
@@ -1025,17 +1025,17 @@ nsXULTreeItemAccessibleBase::DispatchCli
 
 nsAccessible*
 nsXULTreeItemAccessibleBase::GetSiblingAtOffset(PRInt32 aOffset,
                                                 nsresult* aError) const
 {
   if (aError)
     *aError = NS_OK; // fail peacefully
 
-  return mParent->GetChildAt(GetIndexInParent() + aOffset);
+  return mParent->GetChildAt(IndexInParent() + aOffset);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULTreeItemAccessibleBase: protected implementation
 
 PRBool
 nsXULTreeItemAccessibleBase::IsExpandable()
 {
--- a/accessible/src/xul/nsXULTreeAccessible.h
+++ b/accessible/src/xul/nsXULTreeAccessible.h
@@ -204,17 +204,17 @@ public:
 
   // nsAccessNode
   virtual bool IsDefunct() const;
   virtual void Shutdown();
   virtual bool IsPrimaryForNode() const;
 
   // nsAccessible
   virtual PRUint64 NativeState();
-  virtual PRInt32 GetIndexInParent() const;
+  virtual PRInt32 IndexInParent() const;
 
   // nsXULTreeItemAccessibleBase
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEITEMBASEACCESSIBLE_IMPL_CID)
 
   /**
    * Return row index associated with the accessible.
    */
   PRInt32 GetRowIndex() const { return mRow; }
--- a/accessible/src/xul/nsXULTreeGridAccessible.cpp
+++ b/accessible/src/xul/nsXULTreeGridAccessible.cpp
@@ -1225,17 +1225,17 @@ nsXULTreeGridCellAccessible::NativeState
     if (checked.EqualsIgnoreCase("true"))
       states |= states::CHECKED;
   }
 
   return states;
 }
 
 PRInt32
-nsXULTreeGridCellAccessible::GetIndexInParent() const
+nsXULTreeGridCellAccessible::IndexInParent() const
 {
   return GetColumnIndex();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // nsXULTreeGridCellAccessible: public implementation
 
 PRInt32
--- a/accessible/src/xul/nsXULTreeGridAccessible.h
+++ b/accessible/src/xul/nsXULTreeGridAccessible.h
@@ -161,17 +161,17 @@ public:
   virtual bool IsDefunct() const;
   virtual PRBool Init();
   virtual bool IsPrimaryForNode() const;
 
   // nsAccessible
   virtual nsresult GetAttributesInternal(nsIPersistentProperties *aAttributes);
   virtual PRUint32 NativeRole();
   virtual PRUint64 NativeState();
-  virtual PRInt32 GetIndexInParent() const;
+  virtual PRInt32 IndexInParent() const;
 
   // nsXULTreeGridCellAccessible
   NS_DECLARE_STATIC_IID_ACCESSOR(NS_XULTREEGRIDCELLACCESSIBLE_IMPL_CID)
 
   /**
    * Return index of the column.
    */
   PRInt32 GetColumnIndex() const;