Bug 743568 - Fire name change event when a XUL row's name changes, r=surkov.
authorJonathan Wei <jwei@mozilla.com>
Fri, 14 Mar 2014 14:22:08 -0400
changeset 173611 ee4a12bb13a718bbbd33e0360c47fdeb8718cba4
parent 173610 b80f97b00d2fefbea2c55dd3b4d36e3e3b6f5786
child 173612 6350391f85508f9d1365791212b09fa60181a472
push id41051
push userjwei@mozilla.com
push dateFri, 14 Mar 2014 18:23:42 +0000
treeherdermozilla-inbound@ee4a12bb13a7 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssurkov
bugs743568
milestone30.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 743568 - Fire name change event when a XUL row's name changes, r=surkov.
accessible/src/xul/XULTreeGridAccessible.cpp
accessible/src/xul/XULTreeGridAccessible.h
--- a/accessible/src/xul/XULTreeGridAccessible.cpp
+++ b/accessible/src/xul/XULTreeGridAccessible.cpp
@@ -392,36 +392,33 @@ void
 XULTreeGridRowAccessible::RowInvalidated(int32_t aStartColIdx,
                                          int32_t aEndColIdx)
 {
   nsCOMPtr<nsITreeColumns> treeColumns;
   mTree->GetColumns(getter_AddRefs(treeColumns));
   if (!treeColumns)
     return;
 
+  bool nameChanged = false;
   for (int32_t colIdx = aStartColIdx; colIdx <= aEndColIdx; ++colIdx) {
     nsCOMPtr<nsITreeColumn> column;
     treeColumns->GetColumnAt(colIdx, getter_AddRefs(column));
     if (column && !nsCoreUtils::IsColumnHidden(column)) {
       Accessible* cellAccessible = GetCellAccessible(column);
       if (cellAccessible) {
         nsRefPtr<XULTreeGridCellAccessible> cellAcc = do_QueryObject(cellAccessible);
 
-        cellAcc->CellInvalidated();
+        nameChanged |= cellAcc->CellInvalidated();
       }
     }
   }
 
-  nsAutoString name;
-  Name(name);
+  if (nameChanged)
+    nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, this);
 
-  if (name != mCachedName) {
-    nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, this);
-    mCachedName = name;
-  }
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridRowAccessible: Accessible protected implementation
 
 void
 XULTreeGridRowAccessible::CacheChildren()
 {
@@ -758,43 +755,47 @@ Relation
 XULTreeGridCellAccessible::RelationByType(RelationType aType)
 {
   return Relation();
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridCellAccessible: public implementation
 
-void
+bool
 XULTreeGridCellAccessible::CellInvalidated()
 {
 
   nsAutoString textEquiv;
 
   int16_t type;
   mColumn->GetType(&type);
   if (type == nsITreeColumn::TYPE_CHECKBOX) {
     mTreeView->GetCellValue(mRow, mColumn, textEquiv);
     if (mCachedTextEquiv != textEquiv) {
       bool isEnabled = textEquiv.EqualsLiteral("true");
       nsRefPtr<AccEvent> accEvent =
         new AccStateChangeEvent(this, states::CHECKED, isEnabled);
       nsEventShell::FireEvent(accEvent);
 
       mCachedTextEquiv = textEquiv;
+      return true;
     }
 
-    return;
+    return false;
   }
 
   mTreeView->GetCellText(mRow, mColumn, textEquiv);
   if (mCachedTextEquiv != textEquiv) {
     nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, this);
     mCachedTextEquiv = textEquiv;
+    return true;
   }
+
+  return false;
 }
 
 ////////////////////////////////////////////////////////////////////////////////
 // XULTreeGridCellAccessible: Accessible protected implementation
 
 Accessible*
 XULTreeGridCellAccessible::GetSiblingAtOffset(int32_t aOffset,
                                               nsresult* aError) const
--- a/accessible/src/xul/XULTreeGridAccessible.h
+++ b/accessible/src/xul/XULTreeGridAccessible.h
@@ -101,17 +101,16 @@ public:
 
 protected:
 
   // Accessible
   virtual void CacheChildren();
 
   // XULTreeItemAccessibleBase
   mutable AccessibleHashtable mAccessibleCache;
-  nsString mCachedName;
 };
 
 
 /**
  * Represents an accessible for XUL tree cell in the case when XUL tree has
  * multiple columns.
  */
 
@@ -175,18 +174,19 @@ public:
   virtual bool Selected() MOZ_OVERRIDE;
 
   // XULTreeGridCellAccessible
   NS_DECLARE_STATIC_IID_ACCESSOR(XULTREEGRIDCELLACCESSIBLE_IMPL_CID)
 
   /**
    * Fire name or state change event if the accessible text or value has been
    * changed.
+   * @return true if name has changed
    */
-  void CellInvalidated();
+  bool CellInvalidated();
 
 protected:
   // Accessible
   virtual Accessible* GetSiblingAtOffset(int32_t aOffset,
                                          nsresult* aError = nullptr) const;
   virtual void DispatchClickEvent(nsIContent* aContent, uint32_t aActionIndex);
 
   // XULTreeGridCellAccessible