Bug 386978 - get rid FireToolkitEvent, r=aaronlev
authorsurkov.alexander@gmail.com
Thu, 05 Jul 2007 09:02:55 -0700
changeset 3152 336d3c539dc862e527ab6b7e75091f6716d6f307
parent 3151 c72c50e6cd8565fcd08aafdc4e4e7ced054ecdc9
child 3153 aaed82fcf4139e6fd4a856cc225139b649392901
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersaaronlev
bugs386978
milestone1.9a7pre
Bug 386978 - get rid FireToolkitEvent, r=aaronlev
accessible/public/nsPIAccessible.idl
accessible/src/base/nsAccessibilityUtils.cpp
accessible/src/base/nsAccessibilityUtils.h
accessible/src/base/nsAccessible.cpp
accessible/src/base/nsDocAccessible.cpp
accessible/src/base/nsDocAccessible.h
accessible/src/base/nsRootAccessible.cpp
accessible/src/html/nsHTMLSelectAccessible.cpp
accessible/src/mac/nsAccessibleWrap.h
accessible/src/mac/nsAccessibleWrap.mm
accessible/src/mac/nsDocAccessibleWrap.h
accessible/src/msaa/nsDocAccessibleWrap.cpp
accessible/src/other/nsDocAccessibleWrap.h
--- a/accessible/public/nsPIAccessible.idl
+++ b/accessible/public/nsPIAccessible.idl
@@ -36,17 +36,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
 interface nsIAccessible;
 interface nsIAccessibleEvent;
 
-[uuid(e4865da3-f292-4f1a-9c56-dd307f1bdc17)]
+[uuid(96518e2e-b142-4b5d-9324-0fa5ba4f8bab)]
 interface nsPIAccessible : nsISupports
 {
   /**
    * Set accessible parent.
    */
   void setParent(in nsIAccessible aAccParent);
 
   /**
@@ -66,28 +66,16 @@ interface nsPIAccessible : nsISupports
 
   /**
    * Set the child count to -1 (unknown) and null out cached child pointers
    */
   void invalidateChildren();
 
   /**
    * Fire accessible event.
-   *
-   * @param aEvent - DOM event
-   * @param aTarget - target of DOM event
-   * @param aData - additional information for accessible event.
-   *
-   * XXX: eventually this method will be removed (see bug 377022)
-   */
-  void fireToolkitEvent(in unsigned long aEvent, in nsIAccessible aTarget,
-                        in voidPtr aData);
-
-  /**
-   * Fire accessible event.
    */
   void fireAccessibleEvent(in nsIAccessibleEvent aAccEvent);
 
   /**
    * Return true if there are accessible children in anonymous content
    */
   readonly attribute boolean allowsAnonChildAccessibles;
 
--- a/accessible/src/base/nsAccessibilityUtils.cpp
+++ b/accessible/src/base/nsAccessibilityUtils.cpp
@@ -32,16 +32,20 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsAccessibilityUtils.h"
+
+#include "nsPIAccessible.h"
+#include "nsAccessibleEventData.h"
+
 #include "nsIDOMXULSelectCntrlEl.h"
 #include "nsIDOMXULSelectCntrlItemEl.h"
 #include "nsIEventListenerManager.h"
 
 void
 nsAccUtils::GetAccAttr(nsIPersistentProperties *aAttributes, nsIAtom *aAttrName,
                        nsAString& aAttrValue)
 {
@@ -158,8 +162,23 @@ nsAccUtils::HasListener(nsIContent *aCon
 {
   NS_ENSURE_ARG_POINTER(aContent);
   nsCOMPtr<nsIEventListenerManager> listenerManager;
   aContent->GetListenerManager(PR_FALSE, getter_AddRefs(listenerManager));
 
   return listenerManager && listenerManager->HasListenersFor(aEventType);  
 }
 
+nsresult
+nsAccUtils::FireAccEvent(PRUint32 aEventType, nsIAccessible *aAccessible)
+{
+  NS_ENSURE_ARG(aAccessible);
+
+  nsCOMPtr<nsPIAccessible> pAccessible(do_QueryInterface(aAccessible));
+  NS_ASSERTION(pAccessible, "Accessible doesn't implement nsPIAccessible");
+
+  nsCOMPtr<nsIAccessibleEvent> event =
+    new nsAccEvent(aEventType, aAccessible, nsnull);
+  NS_ENSURE_TRUE(event, NS_ERROR_OUT_OF_MEMORY);
+
+  return pAccessible->FireAccessibleEvent(event);
+}
+
--- a/accessible/src/base/nsAccessibilityUtils.h
+++ b/accessible/src/base/nsAccessibilityUtils.h
@@ -35,16 +35,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsAccessibilityUtils_h_
 #define nsAccessibilityUtils_h_
 
 #include "nsAccessibilityAtoms.h"
+#include "nsIAccessible.h"
 
 #include "nsIDOMNode.h"
 #include "nsIPersistentProperties2.h"
 #include "nsIContent.h"
 
 class nsAccUtils
 {
 public:
@@ -96,12 +97,21 @@ public:
    *
    * @param aNode - XUL element that implements
    *                nsIDOMXULSelectControlItemElement interface
    * @param aAttributes - attributes container
    */
   static void SetAccAttrsForXULSelectControlItem(nsIDOMNode *aNode,
                                                  nsIPersistentProperties *aAttributes);
 
+  /**
+   * Return true if the given node has registered event listener of the given
+   * type.
+   */
   static PRBool HasListener(nsIContent *aContent, const nsAString& aEventType);
+
+  /**
+   * Fire accessible event of the given type for the given accessible.
+   */
+  static nsresult FireAccEvent(PRUint32 aEventType, nsIAccessible *aAccessible);
 };
 
 #endif
--- a/accessible/src/base/nsAccessible.cpp
+++ b/accessible/src/base/nsAccessible.cpp
@@ -2002,32 +2002,16 @@ PRBool nsAccessible::IsNodeRelevant(nsID
   nsCOMPtr<nsIAccessibilityService> accService =
     do_GetService("@mozilla.org/accessibilityService;1");
   NS_ENSURE_TRUE(accService, PR_FALSE);
   nsCOMPtr<nsIDOMNode> relevantNode;
   accService->GetRelevantContentNodeFor(aNode, getter_AddRefs(relevantNode));
   return aNode == relevantNode;
 }
 
-NS_IMETHODIMP nsAccessible::FireToolkitEvent(PRUint32 aEvent, nsIAccessible *aTarget, void * aData)
-{
-  // Don't fire event for accessible that has been shut down
-  if (!mWeakShell)
-    return NS_ERROR_FAILURE;
-
-  NS_ENSURE_TRUE(IsNodeRelevant(mDOMNode), NS_ERROR_FAILURE);
-
-  nsCOMPtr<nsIAccessibleDocument> docAccessible(GetDocAccessible());
-  nsCOMPtr<nsPIAccessible> eventHandlingAccessible(do_QueryInterface(docAccessible));
-  if (eventHandlingAccessible)
-    return eventHandlingAccessible->FireToolkitEvent(aEvent, aTarget, aData);
-
-  return NS_ERROR_FAILURE;
-}
-
 NS_IMETHODIMP
 nsAccessible::FireAccessibleEvent(nsIAccessibleEvent *aEvent)
 {
   NS_ENSURE_ARG_POINTER(aEvent);
   nsCOMPtr<nsIDOMNode> eventNode;
   aEvent->GetDOMNode(getter_AddRefs(eventNode));
   NS_ENSURE_TRUE(IsNodeRelevant(eventNode), NS_ERROR_FAILURE);
 
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -752,18 +752,18 @@ NS_IMETHODIMP nsDocAccessible::FireAncho
   if (currentAnchor.Equals(lastAnchor)) {
     mIsAnchorJumped = PR_FALSE;
   } else {
     mIsAnchorJumped = PR_TRUE;
     lastAnchor.Assign(currentAnchor);
   }
 
   if (mIsAnchorJumped) {
-    FireToolkitEvent(nsIAccessibleEvent::EVENT_DOCUMENT_ATTRIBUTES_CHANGED,
-                     this, nsnull);
+    nsAccUtils::
+      FireAccEvent(nsIAccessibleEvent::EVENT_DOCUMENT_ATTRIBUTES_CHANGED, this);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP nsDocAccessible::FireDocLoadEvents(PRUint32 aEventType)
 {
   if (!mDocument || !mWeakShell) {
@@ -811,32 +811,32 @@ NS_IMETHODIMP nsDocAccessible::FireDocLo
 
     // Loading document: fire EVENT_STATE_CHANGE to set STATE_BUSY
     nsCOMPtr<nsIAccessibleStateChangeEvent> accEvent =
       new nsAccStateChangeEvent(this, nsIAccessibleStates::STATE_BUSY,
                                 PR_FALSE, PR_TRUE);
     FireAccessibleEvent(accEvent);
   }
 
-  FireToolkitEvent(aEventType, this, nsnull);
+  nsAccUtils::FireAccEvent(aEventType, this);
   return NS_OK;
 }
 
 void nsDocAccessible::ScrollTimerCallback(nsITimer *aTimer, void *aClosure)
 {
   nsDocAccessible *docAcc = NS_REINTERPRET_CAST(nsDocAccessible*, aClosure);
 
   if (docAcc && docAcc->mScrollPositionChangedTicks &&
       ++docAcc->mScrollPositionChangedTicks > 2) {
     // Whenever scroll position changes, mScrollPositionChangeTicks gets reset to 1
     // We only want to fire accessibilty scroll event when scrolling stops or pauses
     // Therefore, we wait for no scroll events to occur between 2 ticks of this timer
     // That indicates a pause in scrolling, so we fire the accessibilty scroll event
-    docAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_SCROLLING_END, docAcc,
-                             nsnull);
+    nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SCROLLING_END, docAcc);
+
     docAcc->mScrollPositionChangedTicks = 0;
     if (docAcc->mScrollWatchTimer) {
       docAcc->mScrollWatchTimer->Cancel();
       docAcc->mScrollWatchTimer = nsnull;
     }
   }
 }
 
@@ -1273,18 +1273,18 @@ NS_IMETHODIMP nsDocAccessible::FlushPend
             new nsAccCaretMoveEvent(accessible, caretOffset);
           NS_ENSURE_TRUE(caretMoveEvent, NS_ERROR_OUT_OF_MEMORY);
 
           FireAccessibleEvent(caretMoveEvent);
 
           PRInt32 selectionCount;
           accessibleText->GetSelectionCount(&selectionCount);
           if (selectionCount) {  // There's a selection so fire selection change as well
-            FireToolkitEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED,
-                                                 accessible, nsnull);
+            nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_TEXT_SELECTION_CHANGED,
+                                     accessible);
           }
         } 
       }
       else {
         FireAccessibleEvent(accessibleEvent);
       }
     }
   }
@@ -1323,18 +1323,18 @@ void nsDocAccessible::RefreshNodes(nsIDO
           PRUint32 role = Role(accessible);
           if (role == nsIAccessibleRole::ROLE_MENUPOPUP) {
             nsCOMPtr<nsIDOMNode> domNode;
             accessNode->GetDOMNode(getter_AddRefs(domNode));
             nsCOMPtr<nsIDOMXULPopupElement> popup(do_QueryInterface(domNode));
             if (!popup) {
               // Popup elements already fire these via DOMMenuInactive
               // handling in nsRootAccessible::HandleEvent
-              FireToolkitEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
-                               accessible, nsnull);
+              nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
+                                       accessible);
             }
           }
         }
 
         void *uniqueID;
         accessNode->GetUniqueID(&uniqueID);
         nsCOMPtr<nsPIAccessNode> privateAccessNode(do_QueryInterface(accessNode));
         privateAccessNode->Shutdown();
@@ -1423,21 +1423,18 @@ NS_IMETHODIMP nsDocAccessible::Invalidat
     printf("[Reorder %s %s]\n", NS_ConvertUTF16toUTF8(localName).get(), hasAccessible);
   }
 #endif
 
   if (aChangeEventType == nsIAccessibleEvent::EVENT_HIDE ||
       aChangeEventType == nsIAccessibleEvent::EVENT_REORDER) {
     // Fire EVENT_HIDE if previous accessible existed for node being hidden.
     // Fire this before the accessible goes away.
-    nsCOMPtr<nsPIAccessible> privateChildAccessible =
-      do_QueryInterface(childAccessible);
-    if (privateChildAccessible)
-      privateChildAccessible->FireToolkitEvent(nsIAccessibleEvent::EVENT_HIDE,
-                                               childAccessible, nsnull);
+    if (childAccessible)
+      nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_HIDE, childAccessible);
   }
 
   // Shutdown nsIAccessNode's or nsIAccessibles for any DOM nodes in this subtree
   if (aChangeEventType != nsIAccessibleEvent::EVENT_SHOW) {
     RefreshNodes(childNode, aChangeEventType);
   }
 
   // We need to get an accessible for the mutation event's container node
@@ -1534,31 +1531,16 @@ nsDocAccessible::GetAccessibleInParentCh
     }
 
     accService->GetAccessibleInWeakShell(currentNode, mWeakShell, aAccessible);
   } while (!*aAccessible);
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsDocAccessible::FireToolkitEvent(PRUint32 aEvent, nsIAccessible *aTarget,
-                                  void * aData)
-{
-  // Don't fire event for accessible that has been shut down.
-  if (!mWeakShell)
-    return NS_ERROR_FAILURE;
-
-  nsCOMPtr<nsIAccessibleEvent> accEvent =
-    new nsAccEvent(aEvent, aTarget, aData);
-  NS_ENSURE_TRUE(accEvent, NS_ERROR_OUT_OF_MEMORY);
-
-  return FireAccessibleEvent(accEvent);
-}
-
 void nsDocAccessible::DocLoadCallback(nsITimer *aTimer, void *aClosure)
 {
   // Doc has finished loading, fire "load finished" event
   // By using short timer we can wait make the window visible, 
   // which it does asynchronously. This avoids confusing the screen reader with a
   // hidden window. Waiting also allows us to see of the document has focus,
   // which is important because we only fire doc loaded events for focused documents.
 
--- a/accessible/src/base/nsDocAccessible.h
+++ b/accessible/src/base/nsDocAccessible.h
@@ -85,19 +85,16 @@ class nsDocAccessible : public nsHyperTe
 
     // ----- nsIScrollPositionListener ---------------------------
     NS_IMETHOD ScrollPositionWillChange(nsIScrollableView *aView, nscoord aX, nscoord aY);
     NS_IMETHOD ScrollPositionDidChange(nsIScrollableView *aView, nscoord aX, nscoord aY);
 
     // nsIDocumentObserver
     NS_DECL_NSIDOCUMENTOBSERVER
 
-    NS_IMETHOD FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible,
-                                void* aData);
-
     static void FlushEventsCallback(nsITimer *aTimer, void *aClosure);
 
     // nsIAccessNode
     NS_IMETHOD Shutdown();
     NS_IMETHOD Init();
 
     // nsPIAccessNode
     NS_IMETHOD_(nsIFrame *) GetFrame(void);
--- a/accessible/src/base/nsRootAccessible.cpp
+++ b/accessible/src/base/nsRootAccessible.cpp
@@ -478,23 +478,23 @@ PRBool nsRootAccessible::FireAccessibleF
   }
 
   PRUint32 role = Role(finalFocusAccessible);
   if (role == nsIAccessibleRole::ROLE_MENUITEM) {
     if (!mIsInDHTMLMenu) {  // Entering menus
       PRUint32 naturalRole; // The natural role is the role that this type of element normally has
       finalFocusAccessible->GetRole(&naturalRole);
       if (role != naturalRole) { // Must be a DHTML menuitem
-         FireToolkitEvent(nsIAccessibleEvent::EVENT_MENU_START, this, nsnull);
+         nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENU_START, this);
          mIsInDHTMLMenu = nsIAccessibleRole::ROLE_MENUITEM;
       }
     }
   }
   else if (mIsInDHTMLMenu) {
-    FireToolkitEvent(nsIAccessibleEvent::EVENT_MENU_END, this, nsnull);
+    nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENU_END, this);
     mIsInDHTMLMenu = PR_FALSE;
   }
 
   NS_IF_RELEASE(gLastFocusedNode);
   gLastFocusedNode = finalFocusNode;
   NS_IF_ADDREF(gLastFocusedNode);
 
   nsCOMPtr<nsIAccessibleDocument> docAccessible = do_QueryInterface(finalFocusAccessible);
@@ -699,22 +699,22 @@ nsresult nsRootAccessible::HandleEventWi
         do_QueryInterface(aTargetNode);
       nsAutoString selType;
       multiSel->GetSelType(selType);
       if (selType.IsEmpty() || !selType.EqualsLiteral("single")) {
         // XXX: We need to fire EVENT_SELECTION_ADD and EVENT_SELECTION_REMOVE
         // 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();
-        return privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
-                                         accessible, nsnull);
+        return nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
+                                        accessible);
       }
 
-      return privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION,
-                                       treeItemAccessible, nsnull);
+      return nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SELECTION,
+                                      treeItemAccessible);
     }
   }
   else
 #endif
   if (eventType.EqualsLiteral("focus")) {
     // Keep a reference to the target node. We might want to change
     // it to the individual radio button or selected item, and send
     // the focus event to that.
@@ -742,39 +742,37 @@ nsresult nsRootAccessible::HandleEventWi
           if (!accessible)
             return NS_OK;
         }
       }
     }
     FireAccessibleFocusEvent(accessible, focusedItem, aEvent);
   }
   else if (eventType.EqualsLiteral("NameChange")) {
-    privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE,
-                              accessible, nsnull);
+    nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_NAME_CHANGE, accessible);
   }
   else if (eventType.EqualsLiteral("AlertActive")) { 
-    privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_ALERT, 
-                              accessible, nsnull);
+    nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_ALERT, accessible);
   }
   else if (eventType.EqualsLiteral("popupshown")) {
     // Don't fire menupopup events for combobox and autocomplete lists
     PRUint32 role = Role(accessible);
     PRInt32 event = 0;
     if (role == nsIAccessibleRole::ROLE_MENUPOPUP) {
       event = nsIAccessibleEvent::EVENT_MENUPOPUP_START;
     }
     else if (role == nsIAccessibleRole::ROLE_TOOLTIP) {
       // There is a single <xul:tooltip> node which Mozilla moves around.
       // The accessible for it stays the same no matter where it moves. 
       // AT's expect to get an EVENT_SHOW for the tooltip. 
       // In event callback the tooltip's accessible will be ready.
       event = nsIAccessibleEvent::EVENT_SHOW;
     }
     if (event) {
-      privAcc->FireToolkitEvent(event, accessible, nsnull);
+      nsAccUtils::FireAccEvent(event, accessible);
     }
   }
 
   else if (eventType.EqualsLiteral("popuphiding")) {
     // If accessible focus was on or inside popup that closes,
     // then restore it to true current focus.
     // This is the case when we've been getting DOMMenuItemActive events
     // inside of a combo box that closes. The real focus is on the combo box.
@@ -791,18 +789,18 @@ nsresult nsRootAccessible::HandleEventWi
         return NS_OK;  // And was not focused on an item inside the popup
       }
     }
     // Focus was on or inside of a popup that's being hidden
     FireCurrentFocusEvent();
   }
   else if (eventType.EqualsLiteral("DOMMenuInactive")) {
     if (Role(accessible) == nsIAccessibleRole::ROLE_MENUPOPUP) {
-      privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
-                                accessible, nsnull);
+      nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENUPOPUP_END,
+                               accessible);
     }
   }
   else if (eventType.EqualsLiteral("DOMMenuItemActive")) {
     if (!treeItemAccessible) {
       nsCOMPtr<nsPIAccessNode> menuAccessNode = do_QueryInterface(accessible);
       NS_ENSURE_TRUE(menuAccessNode, NS_ERROR_FAILURE);
       nsIFrame* menuFrame = menuAccessNode->GetFrame();
       NS_ENSURE_TRUE(menuFrame, NS_ERROR_FAILURE);
@@ -823,27 +821,24 @@ nsresult nsRootAccessible::HandleEventWi
         // Only fire focus event if it is not inside collapsed popup
         if (State(containerAccessible) & nsIAccessibleStates::STATE_COLLAPSED)
           return NS_OK;
       }
     }
     FireAccessibleFocusEvent(accessible, aTargetNode, aEvent, PR_TRUE);
   }
   else if (eventType.EqualsLiteral("DOMMenuBarActive")) {
-    privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_MENU_START,
-                              accessible, nsnull);
+    nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENU_START, accessible);
   }
   else if (eventType.EqualsLiteral("DOMMenuBarInactive")) {
-    privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_MENU_END,
-                              accessible, nsnull);
+    nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_MENU_END, accessible);
     FireCurrentFocusEvent();
   }
   else if (eventType.EqualsLiteral("ValueChange")) {
-    privAcc->FireToolkitEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, 
-                              accessible, nsnull);
+    nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_VALUE_CHANGE, accessible);
   }
   return NS_OK;
 }
 
 void nsRootAccessible::GetTargetNode(nsIDOMEvent *aEvent, nsIDOMNode **aTargetNode)
 {
   *aTargetNode = nsnull;
 
--- a/accessible/src/html/nsHTMLSelectAccessible.cpp
+++ b/accessible/src/html/nsHTMLSelectAccessible.cpp
@@ -814,27 +814,29 @@ void nsHTMLSelectOptionAccessible::Selec
   nsCOMPtr<nsIAccessibilityService> accService = 
     do_GetService("@mozilla.org/accessibilityService;1");
   nsCOMPtr<nsIAccessible> optionAccessible;
   accService->GetAccessibleFor(optionNode, getter_AddRefs(optionAccessible));
   if (!optionAccessible) {
     return;
   }
 
-  privateMultiSelect->FireToolkitEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
-                      multiSelect, nsnull);
+  nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SELECTION_WITHIN,
+                           multiSelect);
+
   PRUint32 state = State(optionAccessible);
   PRUint32 eventType;
   if (state & nsIAccessibleStates::STATE_SELECTED) {
     eventType = nsIAccessibleEvent::EVENT_SELECTION_ADD;
   }
   else {
     eventType = nsIAccessibleEvent::EVENT_SELECTION_REMOVE;
-  } 
-  privateMultiSelect->FireToolkitEvent(eventType, optionAccessible, nsnull);
+  }
+
+  nsAccUtils::FireAccEvent(eventType, optionAccessible);
 }
 
 nsIContent* nsHTMLSelectOptionAccessible::GetSelectState(PRUint32* aState,
                                                          PRUint32* aExtraState)
 {
   nsCOMPtr<nsIContent> content(do_QueryInterface(mDOMNode));
   while (content && content->Tag() != nsAccessibilityAtoms::select) {
     content = content->GetParent();
--- a/accessible/src/mac/nsAccessibleWrap.h
+++ b/accessible/src/mac/nsAccessibleWrap.h
@@ -71,17 +71,19 @@ class nsAccessibleWrap : public nsAccess
     // right type for this accessible's associated native object.
     virtual objc_class* GetNativeType ();
     
     // returns a pointer to the native window for this accessible tree.
     void GetNativeWindow (void **aOutNativeWindow);
     
     virtual nsresult Shutdown ();
     virtual nsresult InvalidateChildren ();
-    
+
+    NS_IMETHOD FireAccessibleEvent(nsIAccessibleEvent *aEvent);
+
     // we'll flatten buttons and checkboxes. usually they have a text node
     // child, that is their title. Works in conjunction with IsPruned() below.
     PRBool IsFlat() {
       PRUint32 role = Role(this);
       return (role == nsIAccessibleRole::ROLE_CHECKBUTTON ||
               role == nsIAccessibleRole::ROLE_PUSHBUTTON ||
               role == nsIAccessibleRole::ROLE_TOGGLE_BUTTON ||
               role == nsIAccessibleRole::ROLE_SPLITBUTTON ||
--- a/accessible/src/mac/nsAccessibleWrap.mm
+++ b/accessible/src/mac/nsAccessibleWrap.mm
@@ -149,16 +149,53 @@ nsAccessibleWrap::Shutdown ()
   if (mNativeWrapper) {
     delete mNativeWrapper;
     mNativeWrapper = nsnull;
   }
   
   return nsAccessible::Shutdown();
 }
 
+nsAccessibleWrap::FireAccessibleEvent(nsIAccessibleEvent *aEvent)
+{
+  NS_ENSURE_ARG_POINTER(aEvent);
+
+  nsresult rv = nsAccessible::FireAccessibleEvent(aEvent);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  PRUint32 eventType;
+  rv = aEvent->GetEventType(&eventType);
+  NS_ENSURE_SUCCESS(rv, rv);
+
+  // ignore everything but focus-changed and value-changed events for now.
+  if (eventType != nsIAccessibleEvent::EVENT_FOCUS &&
+      eventType != nsIAccessibleEvent::EVENT_VALUE_CHANGE)
+    return NS_OK;
+
+  nsCOMPtr<nsIAccessible> accessible;
+  rv = aEvent->GetAccessible(getter_AddRefs(accessible));
+  NS_ENSURE_STATE(accessible);
+
+  mozAccessible *nativeAcc = nil;
+  accessible->GetNativeInterface((void**)&nativeAcc);
+  if (!nativeAcc)
+    return NS_ERROR_FAILURE;
+
+  switch (eventType) {
+    case nsIAccessibleEvent::EVENT_FOCUS:
+      [nativeAcc didReceiveFocus];
+      break;
+    case nsIAccessibleEvent::EVENT_VALUE_CHANGE:
+      [nativeAcc valueDidChange];
+      break;
+  }
+
+  return NS_OK;
+}
+
 nsresult
 nsAccessibleWrap::InvalidateChildren ()
 {
   if (mNativeWrapper) {
     mozAccessible *object = mNativeWrapper->getNativeObject();
     [object invalidateChildren];
   }
   return nsAccessible::InvalidateChildren();
--- a/accessible/src/mac/nsDocAccessibleWrap.h
+++ b/accessible/src/mac/nsDocAccessibleWrap.h
@@ -36,22 +36,12 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef _nsDocAccessibleWrap_H_
 #define _nsDocAccessibleWrap_H_
 
 #include "nsDocAccessible.h"
 
-struct objc_class;
-
-class nsDocAccessibleWrap: public nsDocAccessible
-{
-  public:
-    nsDocAccessibleWrap(nsIDOMNode *aNode, nsIWeakReference *aShell);
-    virtual ~nsDocAccessibleWrap();
-    
-    NS_IMETHOD FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible, 
-                                void* aData);
-};
+typedef nsDocAccessible nsDocAccessibleWrap;
 
 #endif
 
--- a/accessible/src/msaa/nsDocAccessibleWrap.cpp
+++ b/accessible/src/msaa/nsDocAccessibleWrap.cpp
@@ -189,21 +189,19 @@ NS_IMETHODIMP nsDocAccessibleWrap::FireA
     }
     domSel->GetFocusNode(getter_AddRefs(focusNode));
   }
   else {
     focusNode = mDOMNode; // Moved to top, so event is for 1st leaf after root
   }
 
   nsCOMPtr<nsIAccessible> accessible = GetFirstAvailableAccessible(focusNode, PR_TRUE);
-  nsCOMPtr<nsPIAccessible> privateAccessible = do_QueryInterface(accessible);
-  if (privateAccessible) {
-    privateAccessible->FireToolkitEvent(nsIAccessibleEvent::EVENT_SCROLLING_START,
-                                        accessible, nsnull);
-  }
+  nsAccUtils::FireAccEvent(nsIAccessibleEvent::EVENT_SCROLLING_START,
+                           accessible);
+
   return NS_OK;
 }
 
 STDMETHODIMP nsDocAccessibleWrap::get_URL(/* [out] */ BSTR __RPC_FAR *aURL)
 {
   *aURL = NULL;
   nsAutoString URL;
   if (NS_SUCCEEDED(GetURL(URL))) {
--- a/accessible/src/other/nsDocAccessibleWrap.h
+++ b/accessible/src/other/nsDocAccessibleWrap.h
@@ -40,17 +40,11 @@
  * see http://lxr.mozilla.org/seamonkey/source/accessible/accessible-docs.html
  */
 
 #ifndef _nsDocAccessibleWrap_H_
 #define _nsDocAccessibleWrap_H_
 
 #include "nsDocAccessible.h"
 
-class nsDocAccessibleWrap: public nsDocAccessible
-{
-public:
-    nsDocAccessibleWrap(nsIDOMNode *aNode, nsIWeakReference *aShell);
-    virtual ~nsDocAccessibleWrap();
-    NS_IMETHOD FireToolkitEvent(PRUint32 aEvent, nsIAccessible* aAccessible, void* aData);
-};
+typedef nsDocAccessible nsDocAccessibleWrap;
 
 #endif