Bug 540262 - get rid nsAccEvent static helpers, r=ginn
authorAlexander Surkov <surkov.alexander@gmail.com>
Mon, 18 Jan 2010 17:27:31 +0800
changeset 37273 dc0226af099994828ac7cb049da30f12dfab397a
parent 37272 6ea1b12adda16db76cbed7b9fbe88d46ee1ed92d
child 37274 1aa561085c311778ddbd5aa43c0845660bfe22b3
push idunknown
push userunknown
push dateunknown
reviewersginn
bugs540262
milestone1.9.3a1pre
Bug 540262 - get rid nsAccEvent static helpers, r=ginn
accessible/src/base/nsAccessibleEventData.h
accessible/src/base/nsDocAccessible.cpp
--- a/accessible/src/base/nsAccessibleEventData.h
+++ b/accessible/src/base/nsAccessibleEventData.h
@@ -50,21 +50,21 @@
 #include "nsIDOMNode.h"
 #include "nsString.h"
 #include "nsCycleCollectionParticipant.h"
 #include "nsAccUtils.h"
 
 class nsIPresShell;
 
 #define NS_ACCEVENT_IMPL_CID                            \
-{  /* 55b89892-a83d-4252-ba78-cbdf53a86936 */           \
-  0x55b89892,                                           \
-  0xa83d,                                               \
-  0x4252,                                               \
-  { 0xba, 0x78, 0xcb, 0xdf, 0x53, 0xa8, 0x69, 0x36 }    \
+{  /* 39bde096-317e-4294-b23b-4af4a9b283f7 */           \
+  0x39bde096,                                           \
+  0x317e,                                               \
+  0x4294,                                               \
+  { 0xb2, 0x3b, 0x4a, 0xf4, 0xa9, 0xb2, 0x83, 0xf7 }    \
 }
 
 class nsAccEvent: public nsIAccessibleEvent
 {
 public:
 
   // Rule for accessible events.
   // The rule will be applied when flushing pending events.
@@ -95,16 +95,22 @@ public:
              EEventRule aEventRule = eRemoveDupes);
   virtual ~nsAccEvent() {}
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_CYCLE_COLLECTION_CLASS(nsAccEvent)
 
   NS_DECL_NSIACCESSIBLEEVENT
 
+  // nsAccEvent
+  PRUint32 GetEventType() const { return mEventType; }
+  EEventRule GetEventRule() const { return mEventRule; }
+  PRBool IsAsync() const { return mIsAsync; }
+  PRBool IsFromUserInput() const { return mIsFromUserInput; }
+
   static void GetLastEventAttributes(nsIDOMNode *aNode,
                                      nsIPersistentProperties *aAttributes);
 
 protected:
   already_AddRefed<nsIAccessible> GetAccessibleByNode();
 
   void CaptureIsFromUserInput();
   PRBool mIsFromUserInput;
@@ -116,37 +122,16 @@ protected:
   nsCOMPtr<nsIDOMNode> mDOMNode;
   nsCOMPtr<nsIAccessibleDocument> mDocAccessible;
 
 private:
   static PRBool gLastEventFromUserInput;
   static nsIDOMNode* gLastEventNodeWeak;
 
 public:
-  static PRUint32 EventType(nsIAccessibleEvent *aAccEvent) {
-    PRUint32 eventType;
-    aAccEvent->GetEventType(&eventType);
-    return eventType;
-  }
-  static EEventRule EventRule(nsIAccessibleEvent *aAccEvent) {
-    nsRefPtr<nsAccEvent> accEvent =
-      nsAccUtils::QueryObject<nsAccEvent>(aAccEvent);
-    return accEvent->mEventRule;
-  }
-  static PRBool IsAsyncEvent(nsIAccessibleEvent *aAccEvent) {
-    nsRefPtr<nsAccEvent> accEvent =
-      nsAccUtils::QueryObject<nsAccEvent>(aAccEvent);
-    return accEvent->mIsAsync;
-  }
-  static PRBool IsFromUserInput(nsIAccessibleEvent *aAccEvent) {
-    PRBool isFromUserInput;
-    aAccEvent->GetIsFromUserInput(&isFromUserInput);
-    return isFromUserInput;
-  }
-
   static void ResetLastInputState()
    {gLastEventFromUserInput = PR_FALSE; gLastEventNodeWeak = nsnull; }
 
   /**
    * Find and cache the last input state. This will be called automatically
    * for synchronous events. For asynchronous events it should be
    * called from the synchronous code which is the true source of the event,
    * before the event is fired.
--- a/accessible/src/base/nsDocAccessible.cpp
+++ b/accessible/src/base/nsDocAccessible.cpp
@@ -1676,29 +1676,31 @@ nsDocAccessible::FlushPendingEvents()
   // events will not be processed.
   for (PRUint32 index = 0; index < length; index ++) {
   
     // No presshell means the document was shut down duiring event handling
     // by AT.
     if (!mWeakShell)
       break;
 
-    nsCOMPtr<nsIAccessibleEvent> accessibleEvent(mEventsToFire[index]);
+    nsAccEvent *accEvent = mEventsToFire[index];
 
-    if (nsAccEvent::EventRule(accessibleEvent) == nsAccEvent::eDoNotEmit)
+    if (accEvent->GetEventRule() == nsAccEvent::eDoNotEmit)
       continue;
 
     nsCOMPtr<nsIAccessible> accessible;
-    accessibleEvent->GetAccessible(getter_AddRefs(accessible));
+    accEvent->GetAccessible(getter_AddRefs(accessible));
+
     nsCOMPtr<nsIDOMNode> domNode;
-    accessibleEvent->GetDOMNode(getter_AddRefs(domNode));
-    PRUint32 eventType = nsAccEvent::EventType(accessibleEvent);
-    PRBool isFromUserInput = nsAccEvent::IsFromUserInput(accessibleEvent);
+    accEvent->GetDOMNode(getter_AddRefs(domNode));
 
-    PRBool isAsync = nsAccEvent::IsAsyncEvent(accessibleEvent);
+    PRUint32 eventType = accEvent->GetEventType();
+    PRBool isFromUserInput = accEvent->IsFromUserInput();
+    PRBool isAsync = accEvent->IsAsync();
+
     if (domNode == gLastFocusedNode && isAsync &&
         (eventType == nsIAccessibleEvent::EVENT_SHOW ||
          eventType == nsIAccessibleEvent::EVENT_HIDE)) {
       // If frame type didn't change for this event, then we don't actually need to invalidate
       // However, we only keep track of the old frame type for the focus, where it's very
       // important not to destroy and recreate the accessible for minor style changes,
       // such as a:focus { overflow: scroll; }
       nsCOMPtr<nsIContent> focusContent(do_QueryInterface(domNode));
@@ -1807,34 +1809,34 @@ nsDocAccessible::FlushPendingEvents()
                                      accessible, PR_TRUE);
           }
         } 
       }
       else if (eventType == nsIAccessibleEvent::EVENT_REORDER) {
         // Fire reorder event if it's unconditional (see InvalidateCacheSubtree
         // method) or if changed node (that is the reason of this reorder event)
         // is accessible or has accessible children.
-        nsCOMPtr<nsAccReorderEvent> reorderEvent = do_QueryInterface(accessibleEvent);
+        nsCOMPtr<nsAccReorderEvent> reorderEvent = do_QueryInterface(accEvent);
         if (reorderEvent->IsUnconditionalEvent() ||
             reorderEvent->HasAccessibleInReasonSubtree()) {
-          nsAccEvent::PrepareForEvent(accessibleEvent);
-          FireAccessibleEvent(accessibleEvent);
+          nsAccEvent::PrepareForEvent(accEvent);
+          FireAccessibleEvent(accEvent);
         }
       }
       else {
         // The input state was previously stored with the nsIAccessibleEvent,
         // so use that state now when firing the event
-        nsAccEvent::PrepareForEvent(accessibleEvent);
-        FireAccessibleEvent(accessibleEvent);
+        nsAccEvent::PrepareForEvent(accEvent);
+        FireAccessibleEvent(accEvent);
         // Post event processing
         if (eventType == nsIAccessibleEvent::EVENT_HIDE) {
           // Shutdown nsIAccessNode's or nsIAccessibles for any DOM nodes in
           // this subtree.
           nsCOMPtr<nsIDOMNode> hidingNode;
-          accessibleEvent->GetDOMNode(getter_AddRefs(hidingNode));
+          accEvent->GetDOMNode(getter_AddRefs(hidingNode));
           if (hidingNode) {
             RefreshNodes(hidingNode); // Will this bite us with asynch events
           }
         }
       }
     }
   }