Bug 980307 - Remove DataContainerEvent dependency from accessibility. r=tbsaunde
authorMasatoshi Kimura <VYV03354@nifty.ne.jp>
Fri, 21 Mar 2014 12:59:59 +0900
changeset 193191 9b0216df6e2af266d747858cdafa1e74995654b5
parent 193190 550f66e6106ee9a3b4a0ab2bd04d24d28c47691e
child 193192 70d66415ada6ab4abe61141ea84863645cc9782f
push id3624
push userasasaki@mozilla.com
push dateMon, 09 Jun 2014 21:49:01 +0000
treeherdermozilla-beta@b1a5da15899a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstbsaunde
bugs980307
milestone31.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 980307 - Remove DataContainerEvent dependency from accessibility. r=tbsaunde
accessible/src/generic/RootAccessible.cpp
accessible/tests/mochitest/events/test_tree.xul
layout/xul/tree/nsTreeBodyFrame.cpp
layout/xul/tree/nsTreeBodyFrame.h
--- a/accessible/src/generic/RootAccessible.cpp
+++ b/accessible/src/generic/RootAccessible.cpp
@@ -25,20 +25,21 @@
 
 #include "mozilla/dom/Element.h"
 
 #include "nsIAccessibleRelation.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIDocShellTreeOwner.h"
 #include "mozilla/dom/Event.h"
 #include "mozilla/dom/EventTarget.h"
-#include "nsIDOMDataContainerEvent.h"
+#include "nsIDOMCustomEvent.h"
 #include "nsIDOMXULMultSelectCntrlEl.h"
 #include "nsIDocument.h"
 #include "nsIInterfaceRequestorUtils.h"
+#include "nsIPropertyBag2.h"
 #include "nsIServiceManager.h"
 #include "nsPIDOMWindow.h"
 #include "nsIWebBrowserChrome.h"
 #include "nsReadableUtils.h"
 #include "nsFocusManager.h"
 
 #ifdef MOZ_XUL
 #include "nsIXULDocument.h"
@@ -652,68 +653,68 @@ RootAccessible::HandlePopupHidingEvent(n
   }
 }
 
 #ifdef MOZ_XUL
 void
 RootAccessible::HandleTreeRowCountChangedEvent(nsIDOMEvent* aEvent,
                                                XULTreeAccessible* aAccessible)
 {
-  nsCOMPtr<nsIDOMDataContainerEvent> dataEvent(do_QueryInterface(aEvent));
-  if (!dataEvent)
+  nsCOMPtr<nsIDOMCustomEvent> customEvent(do_QueryInterface(aEvent));
+  if (!customEvent)
     return;
 
-  nsCOMPtr<nsIVariant> indexVariant;
-  dataEvent->GetData(NS_LITERAL_STRING("index"),
-                     getter_AddRefs(indexVariant));
-  if (!indexVariant)
+  nsCOMPtr<nsIVariant> detailVariant;
+  customEvent->GetDetail(getter_AddRefs(detailVariant));
+  if (!detailVariant)
     return;
 
-  nsCOMPtr<nsIVariant> countVariant;
-  dataEvent->GetData(NS_LITERAL_STRING("count"),
-                     getter_AddRefs(countVariant));
-  if (!countVariant)
+  nsCOMPtr<nsISupports> supports;
+  detailVariant->GetAsISupports(getter_AddRefs(supports));
+  nsCOMPtr<nsIPropertyBag2> propBag(do_QueryInterface(supports));
+  if (!propBag)
     return;
 
+  nsresult rv;
   int32_t index, count;
-  indexVariant->GetAsInt32(&index);
-  countVariant->GetAsInt32(&count);
+  rv = propBag->GetPropertyAsInt32(NS_LITERAL_STRING("index"), &index);
+  if (NS_FAILED(rv))
+    return;
+
+  rv = propBag->GetPropertyAsInt32(NS_LITERAL_STRING("count"), &count);
+  if (NS_FAILED(rv))
+    return;
 
   aAccessible->InvalidateCache(index, count);
 }
 
 void
 RootAccessible::HandleTreeInvalidatedEvent(nsIDOMEvent* aEvent,
                                            XULTreeAccessible* aAccessible)
 {
-  nsCOMPtr<nsIDOMDataContainerEvent> dataEvent(do_QueryInterface(aEvent));
-  if (!dataEvent)
+  nsCOMPtr<nsIDOMCustomEvent> customEvent(do_QueryInterface(aEvent));
+  if (!customEvent)
+    return;
+
+  nsCOMPtr<nsIVariant> detailVariant;
+  customEvent->GetDetail(getter_AddRefs(detailVariant));
+  if (!detailVariant)
+    return;
+
+  nsCOMPtr<nsISupports> supports;
+  detailVariant->GetAsISupports(getter_AddRefs(supports));
+  nsCOMPtr<nsIPropertyBag2> propBag(do_QueryInterface(supports));
+  if (!propBag)
     return;
 
   int32_t startRow = 0, endRow = -1, startCol = 0, endCol = -1;
-
-  nsCOMPtr<nsIVariant> startRowVariant;
-  dataEvent->GetData(NS_LITERAL_STRING("startrow"),
-                     getter_AddRefs(startRowVariant));
-  if (startRowVariant)
-    startRowVariant->GetAsInt32(&startRow);
-
-  nsCOMPtr<nsIVariant> endRowVariant;
-  dataEvent->GetData(NS_LITERAL_STRING("endrow"),
-                     getter_AddRefs(endRowVariant));
-  if (endRowVariant)
-    endRowVariant->GetAsInt32(&endRow);
-
-  nsCOMPtr<nsIVariant> startColVariant;
-  dataEvent->GetData(NS_LITERAL_STRING("startcolumn"),
-                     getter_AddRefs(startColVariant));
-  if (startColVariant)
-    startColVariant->GetAsInt32(&startCol);
-
-  nsCOMPtr<nsIVariant> endColVariant;
-  dataEvent->GetData(NS_LITERAL_STRING("endcolumn"),
-                     getter_AddRefs(endColVariant));
-  if (endColVariant)
-    endColVariant->GetAsInt32(&endCol);
+  propBag->GetPropertyAsInt32(NS_LITERAL_STRING("startrow"),
+                              &startRow);
+  propBag->GetPropertyAsInt32(NS_LITERAL_STRING("endrow"),
+                              &endRow);
+  propBag->GetPropertyAsInt32(NS_LITERAL_STRING("startcolumn"),
+                              &startCol);
+  propBag->GetPropertyAsInt32(NS_LITERAL_STRING("endcolumn"),
+                              &endCol);
 
   aAccessible->TreeViewInvalidated(startRow, endRow, startCol, endCol);
 }
 #endif
--- a/accessible/tests/mochitest/events/test_tree.xul
+++ b/accessible/tests/mochitest/events/test_tree.xul
@@ -27,20 +27,21 @@
      * Check TreeRowCountChanged event.
      */
     function rowCountChangedChecker(aMsg, aIdx, aCount)
     {
       this.type = "TreeRowCountChanged";
       this.target = gTree;
       this.check = function check(aEvent)
       {
-        var index = aEvent.getData("index");
+        var propBag = aEvent.detail.QueryInterface(Components.interfaces.nsIPropertyBag2);
+        var index = propBag.getPropertyAsInt32("index");
         is(index, aIdx, "Wrong 'index' data of 'treeRowCountChanged' event.");
 
-        var count = aEvent.getData("count");
+        var count = propBag.getPropertyAsInt32("count");
         is(count, aCount, "Wrong 'count' data of 'treeRowCountChanged' event.");
       }
       this.getID = function getID()
       {
         return aMsg + "TreeRowCountChanged";
       }
     }
 
@@ -48,29 +49,46 @@
      * Check TreeInvalidated event.
      */
     function treeInvalidatedChecker(aMsg, aStartRow, aEndRow, aStartCol, aEndCol)
     {
       this.type = "TreeInvalidated";
       this.target = gTree;
       this.check = function check(aEvent)
       {
-        var startRow = aEvent.getData("startrow");
+        var propBag = aEvent.detail.QueryInterface(Components.interfaces.nsIPropertyBag2);
+        try {
+          var startRow = propBag.getPropertyAsInt32("startrow");
+        } catch (e if e.name == 'NS_ERROR_NOT_AVAILABLE') {
+          startRow = null;
+        }
         is(startRow, aStartRow,
            "Wrong 'startrow' of 'treeInvalidated' event on " + aMsg);
 
-        var endRow = aEvent.getData("endrow");
+        try {
+          var endRow = propBag.getPropertyAsInt32("endrow");
+        } catch (e if e.name == 'NS_ERROR_NOT_AVAILABLE') {
+          endRow = null;
+        }
         is(endRow, aEndRow,
            "Wrong 'endrow' of 'treeInvalidated' event on " + aMsg);
 
-        var startCol = aEvent.getData("startcolumn");
+        try {
+          var startCol = propBag.getPropertyAsInt32("startcolumn");
+        } catch (e if e.name == 'NS_ERROR_NOT_AVAILABLE') {
+          startCol = null;
+        }
         is(startCol, aStartCol,
            "Wrong 'startcolumn' of 'treeInvalidated' event on " + aMsg);
 
-        var endCol = aEvent.getData("endcolumn");
+        try {
+          var endCol = propBag.getPropertyAsInt32("endcolumn");
+        } catch (e if e.name == 'NS_ERROR_NOT_AVAILABLE') {
+          startCol = null;
+        }
         is(endCol, aEndCol,
            "Wrong 'endcolumn' of 'treeInvalidated' event on " + aMsg);
       }
       this.getID = function getID()
       {
         return "TreeInvalidated on " + aMsg;
       }
     }
--- a/layout/xul/tree/nsTreeBodyFrame.cpp
+++ b/layout/xul/tree/nsTreeBodyFrame.cpp
@@ -20,17 +20,17 @@
 #include "nsTreeImageListener.h"
 
 #include "nsGkAtoms.h"
 #include "nsCSSAnonBoxes.h"
 
 #include "nsIContent.h"
 #include "nsStyleContext.h"
 #include "nsIBoxObject.h"
-#include "nsIDOMDataContainerEvent.h"
+#include "nsIDOMCustomEvent.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIDOMElement.h"
 #include "nsIDOMNodeList.h"
 #include "nsIDOMDocument.h"
 #include "nsIDOMXULElement.h"
 #include "nsIDocument.h"
 #include "mozilla/css/StyleRule.h"
 #include "nsCSSRendering.h"
@@ -59,16 +59,17 @@
 #include "nsTreeBoxObject.h"
 #include "nsRenderingContext.h"
 #include "nsIScriptableRegion.h"
 #include <algorithm>
 #include "ScrollbarActivity.h"
 
 #ifdef ACCESSIBILITY
 #include "nsAccessibilityService.h"
+#include "nsIWritablePropertyBag2.h"
 #endif
 #ifdef IBMBIDI
 #include "nsBidiUtils.h"
 #endif
 
 using namespace mozilla;
 using namespace mozilla::layout;
 
@@ -4528,42 +4529,42 @@ nsTreeBodyFrame::FireRowCountChangedEven
   if (!content)
     return;
 
   nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(content->OwnerDoc());
   if (!domDoc)
     return;
 
   nsCOMPtr<nsIDOMEvent> event;
-  domDoc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"),
+  domDoc->CreateEvent(NS_LITERAL_STRING("customevent"),
                       getter_AddRefs(event));
 
-  nsCOMPtr<nsIDOMDataContainerEvent> treeEvent(do_QueryInterface(event));
+  nsCOMPtr<nsIDOMCustomEvent> treeEvent(do_QueryInterface(event));
   if (!treeEvent)
     return;
 
-  event->InitEvent(NS_LITERAL_STRING("TreeRowCountChanged"), true, false);
+  nsCOMPtr<nsIWritablePropertyBag2> propBag(
+    do_CreateInstance("@mozilla.org/hash-property-bag;1"));
+  if (!propBag)
+    return;
 
   // Set 'index' data - the row index rows are changed from.
-  nsCOMPtr<nsIWritableVariant> indexVariant(
-    do_CreateInstance("@mozilla.org/variant;1"));
-  if (!indexVariant)
-    return;
-
-  indexVariant->SetAsInt32(aIndex);
-  treeEvent->SetData(NS_LITERAL_STRING("index"), indexVariant);
+  propBag->SetPropertyAsInt32(NS_LITERAL_STRING("index"), aIndex);
 
   // Set 'count' data - the number of changed rows.
-  nsCOMPtr<nsIWritableVariant> countVariant(
+  propBag->SetPropertyAsInt32(NS_LITERAL_STRING("count"), aCount);
+
+  nsCOMPtr<nsIWritableVariant> detailVariant(
     do_CreateInstance("@mozilla.org/variant;1"));
-  if (!countVariant)
+  if (!detailVariant)
     return;
 
-  countVariant->SetAsInt32(aCount);
-  treeEvent->SetData(NS_LITERAL_STRING("count"), countVariant);
+  detailVariant->SetAsISupports(propBag);
+  treeEvent->InitCustomEvent(NS_LITERAL_STRING("TreeRowCountChanged"),
+                             true, false, detailVariant);
 
   event->SetTrusted(true);
 
   nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(content, event);
   asyncDispatcher->PostDOMEvent();
 }
 
@@ -4576,75 +4577,67 @@ nsTreeBodyFrame::FireInvalidateEvent(int
   if (!content)
     return;
 
   nsCOMPtr<nsIDOMDocument> domDoc = do_QueryInterface(content->OwnerDoc());
   if (!domDoc)
     return;
 
   nsCOMPtr<nsIDOMEvent> event;
-  domDoc->CreateEvent(NS_LITERAL_STRING("datacontainerevents"),
+  domDoc->CreateEvent(NS_LITERAL_STRING("customevent"),
                       getter_AddRefs(event));
 
-  nsCOMPtr<nsIDOMDataContainerEvent> treeEvent(do_QueryInterface(event));
+  nsCOMPtr<nsIDOMCustomEvent> treeEvent(do_QueryInterface(event));
   if (!treeEvent)
     return;
 
-  event->InitEvent(NS_LITERAL_STRING("TreeInvalidated"), true, false);
+  nsCOMPtr<nsIWritablePropertyBag2> propBag(
+    do_CreateInstance("@mozilla.org/hash-property-bag;1"));
+  if (!propBag)
+    return;
 
   if (aStartRowIdx != -1 && aEndRowIdx != -1) {
     // Set 'startrow' data - the start index of invalidated rows.
-    nsCOMPtr<nsIWritableVariant> startRowVariant(
-      do_CreateInstance("@mozilla.org/variant;1"));
-    if (!startRowVariant)
-      return;
-
-    startRowVariant->SetAsInt32(aStartRowIdx);
-    treeEvent->SetData(NS_LITERAL_STRING("startrow"), startRowVariant);
+    propBag->SetPropertyAsInt32(NS_LITERAL_STRING("startrow"),
+                                aStartRowIdx);
 
     // Set 'endrow' data - the end index of invalidated rows.
-    nsCOMPtr<nsIWritableVariant> endRowVariant(
-      do_CreateInstance("@mozilla.org/variant;1"));
-    if (!endRowVariant)
-      return;
-
-    endRowVariant->SetAsInt32(aEndRowIdx);
-    treeEvent->SetData(NS_LITERAL_STRING("endrow"), endRowVariant);
+    propBag->SetPropertyAsInt32(NS_LITERAL_STRING("endrow"),
+                                aEndRowIdx);
   }
 
   if (aStartCol && aEndCol) {
     // Set 'startcolumn' data - the start index of invalidated rows.
-    nsCOMPtr<nsIWritableVariant> startColVariant(
-      do_CreateInstance("@mozilla.org/variant;1"));
-    if (!startColVariant)
-      return;
-
     int32_t startColIdx = 0;
     nsresult rv = aStartCol->GetIndex(&startColIdx);
     if (NS_FAILED(rv))
       return;
 
-    startColVariant->SetAsInt32(startColIdx);
-    treeEvent->SetData(NS_LITERAL_STRING("startcolumn"), startColVariant);
+    propBag->SetPropertyAsInt32(NS_LITERAL_STRING("startcolumn"),
+                                startColIdx);
 
     // Set 'endcolumn' data - the start index of invalidated rows.
-    nsCOMPtr<nsIWritableVariant> endColVariant(
-      do_CreateInstance("@mozilla.org/variant;1"));
-    if (!endColVariant)
-      return;
-
     int32_t endColIdx = 0;
     rv = aEndCol->GetIndex(&endColIdx);
     if (NS_FAILED(rv))
       return;
 
-    endColVariant->SetAsInt32(endColIdx);
-    treeEvent->SetData(NS_LITERAL_STRING("endcolumn"), endColVariant);
+    propBag->SetPropertyAsInt32(NS_LITERAL_STRING("endcolumn"),
+                                endColIdx);
   }
 
+  nsCOMPtr<nsIWritableVariant> detailVariant(
+    do_CreateInstance("@mozilla.org/variant;1"));
+  if (!detailVariant)
+    return;
+
+  detailVariant->SetAsISupports(propBag);
+  treeEvent->InitCustomEvent(NS_LITERAL_STRING("TreeInvalidated"),
+                             true, false, detailVariant);
+
   event->SetTrusted(true);
 
   nsRefPtr<AsyncEventDispatcher> asyncDispatcher =
     new AsyncEventDispatcher(content, event);
   asyncDispatcher->PostDOMEvent();
 }
 #endif
 
--- a/layout/xul/tree/nsTreeBodyFrame.h
+++ b/layout/xul/tree/nsTreeBodyFrame.h
@@ -471,28 +471,28 @@ protected:
    * Clear the pointer to this frame for all nsTreeImageListeners that were
    * created by this frame.
    */
   void DetachImageListeners();
 
 #ifdef ACCESSIBILITY
   /**
    * Fires 'treeRowCountChanged' event asynchronously. The event supports
-   * nsIDOMDataContainerEvent interface that is used to expose the following
+   * nsIDOMCustomEvent interface that is used to expose the following
    * information structures.
    *
    * @param aIndex  the row index rows are added/removed from
    * @param aCount  the number of added/removed rows (the sign points to
    *                an operation, plus - addition, minus - removing)
    */
   void FireRowCountChangedEvent(int32_t aIndex, int32_t aCount);
 
   /**
    * Fires 'treeInvalidated' event asynchronously. The event supports
-   * nsIDOMDataContainerEvent interface that is used to expose the information
+   * nsIDOMCustomEvent interface that is used to expose the information
    * structures described by method arguments.
    *
    * @param aStartRow  the start index of invalidated rows, -1 means that
    *                   columns have been invalidated only
    * @param aEndRow    the end index of invalidated rows, -1 means that columns
    *                   have been invalidated only
    * @param aStartCol  the start invalidated column, nullptr means that only rows
    *                   have been invalidated