Bug 963607 - add some consts, make cache members mutable, GetChildAt part, r=tbsaunde
authorAlexander Surkov <surkov.alexander@gmail.com>
Fri, 24 Jan 2014 22:08:17 -0500
changeset 181219 15edf6b80226c1b327eca5f83963fbbe26a124f5
parent 181218 87b0be26bea9c10cbf6cd76dbd10c85c4d519515
child 181220 4f18e4ee1d81b136ed52109468e72efd9efee48c
push id3343
push userffxbld
push dateMon, 17 Mar 2014 21:55:32 +0000
treeherdermozilla-beta@2f7d3415f79f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs963607
milestone29.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 963607 - add some consts, make cache members mutable, GetChildAt part, r=tbsaunde
accessible/src/generic/Accessible.cpp
accessible/src/generic/Accessible.h
accessible/src/xul/XULTreeAccessible.cpp
accessible/src/xul/XULTreeAccessible.h
accessible/src/xul/XULTreeGridAccessible.cpp
accessible/src/xul/XULTreeGridAccessible.h
--- a/accessible/src/generic/Accessible.cpp
+++ b/accessible/src/generic/Accessible.cpp
@@ -2643,17 +2643,17 @@ Accessible::RemoveChild(Accessible* aChi
   aChild->UnbindFromParent();
   mChildren.RemoveElementAt(index);
   mEmbeddedObjCollector = nullptr;
 
   return true;
 }
 
 Accessible*
-Accessible::GetChildAt(uint32_t aIndex)
+Accessible::GetChildAt(uint32_t aIndex) const
 {
   Accessible* child = mChildren.SafeElementAt(aIndex, nullptr);
   if (!child)
     return nullptr;
 
 #ifdef DEBUG
   Accessible* realParent = child->mParent;
   NS_ASSERTION(!realParent || realParent == this,
--- a/accessible/src/generic/Accessible.h
+++ b/accessible/src/generic/Accessible.h
@@ -384,17 +384,17 @@ public:
   /**
    * Return parent accessible.
    */
   Accessible* Parent() const { return mParent; }
 
   /**
    * Return child accessible at the given index.
    */
-  virtual Accessible* GetChildAt(uint32_t aIndex);
+  virtual Accessible* GetChildAt(uint32_t aIndex) const;
 
   /**
    * Return child accessible count.
    */
   virtual uint32_t ChildCount() const;
 
   /**
    * Return index of the given child accessible.
--- a/accessible/src/xul/XULTreeAccessible.cpp
+++ b/accessible/src/xul/XULTreeAccessible.cpp
@@ -409,17 +409,17 @@ XULTreeAccessible::SelectAll()
 
   return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeAccessible: Accessible implementation
 
 Accessible*
-XULTreeAccessible::GetChildAt(uint32_t aIndex)
+XULTreeAccessible::GetChildAt(uint32_t aIndex) const
 {
   uint32_t childCount = Accessible::ChildCount();
   if (aIndex < childCount)
     return Accessible::GetChildAt(aIndex);
 
   return GetTreeItemAccessible(aIndex - childCount);
 }
 
@@ -517,17 +517,17 @@ XULTreeAccessible::ContainerWidget() con
   }
   return nullptr;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeAccessible: public implementation
 
 Accessible*
-XULTreeAccessible::GetTreeItemAccessible(int32_t aRow)
+XULTreeAccessible::GetTreeItemAccessible(int32_t aRow) const
 {
   if (aRow < 0 || IsDefunct() || !mTreeView)
     return nullptr;
 
   int32_t rowCount = 0;
   nsresult rv = mTreeView->GetRowCount(&rowCount);
   if (NS_FAILED(rv) || aRow >= rowCount)
     return nullptr;
@@ -674,20 +674,21 @@ XULTreeAccessible::TreeViewChanged(nsITr
   ClearCache(mAccessibleCache);
   mTreeView = aView;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeAccessible: protected implementation
 
 already_AddRefed<Accessible>
-XULTreeAccessible::CreateTreeItemAccessible(int32_t aRow)
+XULTreeAccessible::CreateTreeItemAccessible(int32_t aRow) const
 {
   nsRefPtr<Accessible> accessible =
-    new XULTreeItemAccessible(mContent, mDoc, this, mTree, mTreeView, aRow);
+    new XULTreeItemAccessible(mContent, mDoc, const_cast<XULTreeAccessible*>(this),
+                              mTree, mTreeView, aRow);
 
   return accessible.forget();
 }
                              
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeItemAccessibleBase
 ////////////////////////////////////////////////////////////////////////////////
 
--- a/accessible/src/xul/XULTreeAccessible.h
+++ b/accessible/src/xul/XULTreeAccessible.h
@@ -41,18 +41,18 @@ public:
   // Accessible
   virtual void Shutdown();
   virtual void Value(nsString& aValue);
   virtual a11y::role NativeRole();
   virtual uint64_t NativeState();
   virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
                                    EWhichChildAtPoint aWhichChild);
 
-  virtual Accessible* GetChildAt(uint32_t aIndex);
-  virtual uint32_t ChildCount() const;
+  virtual Accessible* GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
+  virtual uint32_t ChildCount() const MOZ_OVERRIDE;
   virtual Relation RelationByType(RelationType aType) MOZ_OVERRIDE;
 
   // SelectAccessible
   virtual already_AddRefed<nsIArray> SelectedItems();
   virtual uint32_t SelectedItemCount();
   virtual Accessible* GetSelectedItem(uint32_t aIndex);
   virtual bool IsItemSelected(uint32_t aIndex);
   virtual bool AddItemToSelection(uint32_t aIndex);
@@ -72,17 +72,17 @@ public:
   // XULTreeAccessible
 
   /**
    * Return tree item accessible at the givem row. If accessible doesn't exist
    * in the cache then create and cache it.
    *
    * @param aRow         [in] the given row index
    */
-  Accessible* GetTreeItemAccessible(int32_t aRow);
+  Accessible* GetTreeItemAccessible(int32_t aRow) const;
 
   /**
    * 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)
@@ -105,21 +105,22 @@ public:
    * Invalidates children created for previous tree view.
    */
   void TreeViewChanged(nsITreeView* aView);
 
 protected:
   /**
    * Creates tree item accessible for the given row index.
    */
-  virtual already_AddRefed<Accessible> CreateTreeItemAccessible(int32_t aRow);
+  virtual already_AddRefed<Accessible>
+    CreateTreeItemAccessible(int32_t aRow) const;
 
   nsCOMPtr<nsITreeBoxObject> mTree;
   nsITreeView* mTreeView;
-  AccessibleHashtable mAccessibleCache;
+  mutable AccessibleHashtable mAccessibleCache;
 };
 
 /**
  * Base class for tree item accessibles.
  */
 
 #define XULTREEITEMBASEACCESSIBLE_IMPL_CID            \
 {  /* 1ab79ae7-766a-443c-940b-b1e6b0831dfc */         \
@@ -175,17 +176,17 @@ public:
    * Return row index associated with the accessible.
    */
   int32_t GetRowIndex() const { return mRow; }
 
   /**
    * Return cell accessible for the given column. If XUL tree accessible is not
    * accessible table then return null.
    */
-  virtual Accessible* GetCellAccessible(nsITreeColumn* aColumn)
+  virtual Accessible* GetCellAccessible(nsITreeColumn* aColumn) const
     { return nullptr; }
 
   /**
    * Proccess row invalidation. Used to fires name change events.
    */
   virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx) = 0;
 
 protected:
--- a/accessible/src/xul/XULTreeGridAccessible.cpp
+++ b/accessible/src/xul/XULTreeGridAccessible.cpp
@@ -232,20 +232,22 @@ XULTreeGridAccessible::NativeRole()
 
   return primaryColumn ? roles::TREE_TABLE : roles::TABLE;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridAccessible: XULTreeAccessible implementation
 
 already_AddRefed<Accessible>
-XULTreeGridAccessible::CreateTreeItemAccessible(int32_t aRow)
+XULTreeGridAccessible::CreateTreeItemAccessible(int32_t aRow) const
 {
   nsRefPtr<Accessible> accessible =
-    new XULTreeGridRowAccessible(mContent, mDoc, this, mTree, mTreeView, aRow);
+    new XULTreeGridRowAccessible(mContent, mDoc,
+                                 const_cast<XULTreeGridAccessible*>(this),
+                                 mTree, mTreeView, aRow);
 
   return accessible.forget();
 }
 
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridRowAccessible
 ////////////////////////////////////////////////////////////////////////////////
@@ -340,17 +342,17 @@ XULTreeGridRowAccessible::ChildAtPoint(i
   // Return if we failed to find tree cell in the row for the given point.
   if (row != mRow || !column)
     return nullptr;
 
   return GetCellAccessible(column);
 }
 
 Accessible*
-XULTreeGridRowAccessible::GetChildAt(uint32_t aIndex)
+XULTreeGridRowAccessible::GetChildAt(uint32_t aIndex) const
 {
   if (IsDefunct())
     return nullptr;
 
   nsCOMPtr<nsITreeColumn> column =
     nsCoreUtils::GetSensibleColumnAt(mTree, aIndex);
   if (!column)
     return nullptr;
@@ -363,28 +365,29 @@ XULTreeGridRowAccessible::ChildCount() c
 {
   return nsCoreUtils::GetSensibleColumnCount(mTree);
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridRowAccessible: XULTreeItemAccessibleBase implementation
 
 Accessible*
-XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn)
+XULTreeGridRowAccessible::GetCellAccessible(nsITreeColumn* aColumn) const
 {
   NS_PRECONDITION(aColumn, "No tree column!");
 
   void* key = static_cast<void*>(aColumn);
   Accessible* cachedCell = mAccessibleCache.GetWeak(key);
   if (cachedCell)
     return cachedCell;
 
   nsRefPtr<Accessible> cell =
-    new XULTreeGridCellAccessibleWrap(mContent, mDoc, this, mTree,
-                                      mTreeView, mRow, aColumn);
+    new XULTreeGridCellAccessibleWrap(mContent, mDoc,
+                                      const_cast<XULTreeGridRowAccessible*>(this),
+                                      mTree, mTreeView, mRow, aColumn);
   mAccessibleCache.Put(key, cell);
   Document()->BindToDocument(cell, nullptr);
   return cell;
 }
 
 void
 XULTreeGridRowAccessible::RowInvalidated(int32_t aStartColIdx,
                                          int32_t aEndColIdx)
--- a/accessible/src/xul/XULTreeGridAccessible.h
+++ b/accessible/src/xul/XULTreeGridAccessible.h
@@ -57,17 +57,18 @@ public:
   // Accessible
   virtual void Shutdown();
   virtual TableAccessible* AsTable() { return this; }
   virtual a11y::role NativeRole();
 
 protected:
 
   // XULTreeAccessible
-  virtual already_AddRefed<Accessible> CreateTreeItemAccessible(int32_t aRow);
+  virtual already_AddRefed<Accessible>
+    CreateTreeItemAccessible(int32_t aRow) const MOZ_OVERRIDE;
 };
 
 
 /**
  * Represents accessible for XUL tree item in the case when XUL tree has
  * multiple columns.
  */
 class XULTreeGridRowAccessible : public XULTreeItemAccessibleBase
@@ -86,30 +87,30 @@ public:
 
   // Accessible
   virtual void Shutdown();
   virtual a11y::role NativeRole();
   virtual ENameValueFlag Name(nsString& aName);
   virtual Accessible* ChildAtPoint(int32_t aX, int32_t aY,
                                    EWhichChildAtPoint aWhichChild);
 
-  virtual Accessible* GetChildAt(uint32_t aIndex);
-  virtual uint32_t ChildCount() const;
+  virtual Accessible* GetChildAt(uint32_t aIndex) const MOZ_OVERRIDE;
+  virtual uint32_t ChildCount() const MOZ_OVERRIDE;
 
   // XULTreeItemAccessibleBase
-  virtual Accessible* GetCellAccessible(nsITreeColumn* aColumn);
+  virtual Accessible* GetCellAccessible(nsITreeColumn* aColumn) const MOZ_OVERRIDE;
   virtual void RowInvalidated(int32_t aStartColIdx, int32_t aEndColIdx);
 
 protected:
 
   // Accessible
   virtual void CacheChildren();
 
   // XULTreeItemAccessibleBase
-  AccessibleHashtable mAccessibleCache;
+  mutable AccessibleHashtable mAccessibleCache;
 };
 
 
 /**
  * Represents an accessible for XUL tree cell in the case when XUL tree has
  * multiple columns.
  */