Bug 701669 - crash when changing profile in profile manager, r=tbsaunde, a=clegnitto
authorAlexander Surkov <surkov.alexanderggmail.com>
Tue, 29 Nov 2011 09:57:43 +0100
changeset 81414 63829f362db8d23733f216bfc4ff9c77893a6bcf
parent 81413 d36cab2ac025a42a3cb28d00e51290e878fb3dba
child 81415 3bae93f4651fff62bcbabecefb64cf9bf4a0b5ca
push id434
push userclegnitto@mozilla.com
push dateWed, 21 Dec 2011 12:10:54 +0000
treeherdermozilla-beta@bddb6ed8dd47 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde, clegnitto
bugs701669
milestone10.0a2
Bug 701669 - crash when changing profile in profile manager, r=tbsaunde, a=clegnitto
accessible/src/base/nsRootAccessible.cpp
--- a/accessible/src/base/nsRootAccessible.cpp
+++ b/accessible/src/base/nsRootAccessible.cpp
@@ -389,36 +389,33 @@ nsRootAccessible::ProcessDOMEvent(nsIDOM
   NS_ASSERTION(targetDocument, "No document while accessible is in document?!");
 
   nsINode* targetNode = accessible->GetNode();
 
 #ifdef MOZ_XUL
   bool isTree = targetNode->IsElement() &&
     targetNode->AsElement()->NodeInfo()->Equals(nsGkAtoms::tree, kNameSpaceID_XUL);
 
-  if (isTree) {
-    nsRefPtr<nsXULTreeAccessible> treeAcc = do_QueryObject(accessible);
-    NS_ASSERTION(treeAcc,
-                 "Accessible for xul:tree isn't nsXULTreeAccessible.");
+  nsRefPtr<nsXULTreeAccessible> treeAcc =
+    isTree ? do_QueryObject(accessible) : nsnull;
+
+  if (treeAcc) {
+    if (eventType.EqualsLiteral("TreeViewChanged")) {
+      treeAcc->TreeViewChanged();
+      return;
+    }
 
-    if (treeAcc) {
-      if (eventType.EqualsLiteral("TreeViewChanged")) {
-        treeAcc->TreeViewChanged();
-        return;
-      }
+    if (eventType.EqualsLiteral("TreeRowCountChanged")) {
+      HandleTreeRowCountChangedEvent(aDOMEvent, treeAcc);
+      return;
+    }
 
-      if (eventType.EqualsLiteral("TreeRowCountChanged")) {
-        HandleTreeRowCountChangedEvent(aDOMEvent, treeAcc);
-        return;
-      }
-      
-      if (eventType.EqualsLiteral("TreeInvalidated")) {
-        HandleTreeInvalidatedEvent(aDOMEvent, treeAcc);
-        return;
-      }
+    if (eventType.EqualsLiteral("TreeInvalidated")) {
+      HandleTreeInvalidatedEvent(aDOMEvent, treeAcc);
+      return;
     }
   }
 #endif
 
   if (eventType.EqualsLiteral("RadioStateChange")) {
     PRUint64 state = accessible->State();
 
     // radiogroup in prefWindow is exposed as a list,
@@ -446,38 +443,38 @@ nsRootAccessible::ProcessDOMEvent(nsIDOM
 
     nsRefPtr<AccEvent> accEvent =
       new AccStateChangeEvent(accessible, states::CHECKED, isEnabled);
 
     nsEventShell::FireEvent(accEvent);
     return;
   }
 
-  nsAccessible *treeItemAccessible = nsnull;
+  nsAccessible* treeItemAcc = nsnull;
 #ifdef MOZ_XUL
   // If it's a tree element, need the currently selected item
   if (isTree) {
-    treeItemAccessible = accessible->CurrentItem();
-    if (treeItemAccessible)
-      accessible = treeItemAccessible;
+    treeItemAcc = accessible->CurrentItem();
+    if (treeItemAcc)
+      accessible = treeItemAcc;
   }
 #endif
 
 #ifdef MOZ_XUL
-  if (treeItemAccessible && eventType.EqualsLiteral("OpenStateChange")) {
+  if (treeItemAcc && eventType.EqualsLiteral("OpenStateChange")) {
     PRUint64 state = accessible->State();
     bool isEnabled = (state & states::EXPANDED) != 0;
 
     nsRefPtr<AccEvent> accEvent =
       new AccStateChangeEvent(accessible, states::EXPANDED, isEnabled);
     nsEventShell::FireEvent(accEvent);
     return;
   }
 
-  if (treeItemAccessible && eventType.EqualsLiteral("select")) {
+  if (treeItemAcc && eventType.EqualsLiteral("select")) {
     // XXX: We shouldn't be based on DOM select event which doesn't provide us
     // any context info. We should integrate into nsTreeSelection instead.
     // If multiselect tree, we should fire selectionadd or selection removed
     if (FocusMgr()->HasDOMFocus(targetNode)) {
       nsCOMPtr<nsIDOMXULMultiSelectControlElement> multiSel =
         do_QueryInterface(targetNode);
       nsAutoString selType;
       multiSel->GetSelType(selType);
@@ -486,18 +483,20 @@ nsRootAccessible::ProcessDOMEvent(nsIDOM
         // for each tree item. Perhaps each tree item will need to cache its
         // selection state and fire an event after a DOM "select" event when
         // that state changes. nsXULTreeAccessible::UpdateTreeSelection();
         nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
                                 accessible);
         return;
       }
 
-      nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_SELECTION,
-                              treeItemAccessible);
+      nsRefPtr<AccSelChangeEvent> selChangeEvent =
+        new AccSelChangeEvent(treeAcc, treeItemAcc,
+                              AccSelChangeEvent::eSelectionAdd);
+      nsEventShell::FireEvent(selChangeEvent);
       return;
     }
   }
   else
 #endif
   if (eventType.EqualsLiteral("AlertActive")) {
     nsEventShell::FireEvent(nsIAccessibleEvent::EVENT_ALERT, accessible);
   }