Backed out changeset 967b254211be. This was the wrong patch and probably won't compile.
authorJonas Sicking <jonas@sicking.cc>
Fri, 24 Jun 2011 17:36:06 -0700
changeset 71687 41c88f1b3b8883cf6d72718a329e62367af4fbb7
parent 71686 967b254211be298118248bd270d1a5463eb319fd
child 71688 8904812b90a7721eabf0d497fd2615456f6b92d1
child 71738 f5e4c69084c84717915df0fc2469440b95043467
push id20596
push usersicking@mozilla.com
push dateSat, 25 Jun 2011 00:38:10 +0000
treeherdermozilla-central@41c88f1b3b88 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone7.0a1
backs out967b254211be298118248bd270d1a5463eb319fd
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
Backed out changeset 967b254211be. This was the wrong patch and probably won't compile.
extensions/spellcheck/src/mozInlineSpellChecker.cpp
extensions/spellcheck/src/mozInlineSpellChecker.h
extensions/widgetutils/src/nsWidgetUtils.cpp
--- a/extensions/spellcheck/src/mozInlineSpellChecker.cpp
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.cpp
@@ -503,22 +503,25 @@ public:
   {
     mStatus.mSpellChecker->ResumeCheck(&mStatus);
     return NS_OK;
   }
 };
 
 
 NS_INTERFACE_MAP_BEGIN(mozInlineSpellChecker)
-  NS_INTERFACE_MAP_ENTRY(nsIInlineSpellChecker)
-  NS_INTERFACE_MAP_ENTRY(nsIEditActionListener)
-  NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMEventListener)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMEventListener)
-  NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(mozInlineSpellChecker)
+NS_INTERFACE_MAP_ENTRY(nsIInlineSpellChecker)
+NS_INTERFACE_MAP_ENTRY(nsIEditActionListener)
+NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
+NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
+NS_INTERFACE_MAP_ENTRY(nsISupportsWeakReference)
+NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMKeyListener)
+NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
+NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMKeyListener)
+NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(mozInlineSpellChecker)
 NS_INTERFACE_MAP_END
 
 NS_IMPL_CYCLE_COLLECTING_ADDREF(mozInlineSpellChecker)
 NS_IMPL_CYCLE_COLLECTING_RELEASE(mozInlineSpellChecker)
 
 NS_IMPL_CYCLE_COLLECTION_5(mozInlineSpellChecker,
                            mSpellCheck,
                            mTextServicesDocument,
@@ -639,22 +642,29 @@ mozInlineSpellChecker::RegisterEventList
 
   nsCOMPtr<nsIDOMDocument> doc;
   nsresult rv = editor->GetDocument(getter_AddRefs(doc));
   NS_ENSURE_SUCCESS(rv, rv);
 
   nsCOMPtr<nsIDOMEventTarget> piTarget = do_QueryInterface(doc, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
-  piTarget->AddEventListener(NS_LITERAL_STRING("blur"), this,
-                             PR_TRUE, PR_FALSE);
-  piTarget->AddEventListener(NS_LITERAL_STRING("click"), this,
-                             PR_FALSE, PR_FALSE);
-  piTarget->AddEventListener(NS_LITERAL_STRING("keypress"), this,
-                             PR_FALSE, PR_FALSE);
+  nsEventListenerManager* elmP = piTarget->GetListenerManager(PR_TRUE);
+  if (elmP) {
+    // Focus event doesn't bubble so adding the listener to capturing phase
+    elmP->AddEventListenerByIID(static_cast<nsIDOMFocusListener *>(this),
+                                NS_GET_IID(nsIDOMFocusListener),
+                                NS_EVENT_FLAG_CAPTURE);
+  }
+
+  piTarget->AddEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
+                                  NS_GET_IID(nsIDOMMouseListener));
+  piTarget->AddEventListenerByIID(static_cast<nsIDOMKeyListener*>(this),
+                                  NS_GET_IID(nsIDOMKeyListener));
+
   return NS_OK;
 }
 
 // mozInlineSpellChecker::UnregisterEventListeners
 
 nsresult
 mozInlineSpellChecker::UnregisterEventListeners()
 {
@@ -665,19 +675,29 @@ mozInlineSpellChecker::UnregisterEventLi
 
   nsCOMPtr<nsIDOMDocument> doc;
   editor->GetDocument(getter_AddRefs(doc));
   NS_ENSURE_TRUE(doc, NS_ERROR_NULL_POINTER);
   
   nsCOMPtr<nsIDOMEventTarget> piTarget = do_QueryInterface(doc);
   NS_ENSURE_TRUE(piTarget, NS_ERROR_NULL_POINTER);
 
-  piTarget->RemoveEventListener(NS_LITERAL_STRING("blur"), this, PR_TRUE);
-  piTarget->RemoveEventListener(NS_LITERAL_STRING("click"), this, PR_FALSE);
-  piTarget->RemoveEventListener(NS_LITERAL_STRING("keypress"), this, PR_FALSE);
+  nsEventListenerManager* elmP =
+    piTarget->GetListenerManager(PR_TRUE);
+  if (elmP) {
+    elmP->RemoveEventListenerByIID(static_cast<nsIDOMFocusListener *>(this),
+                                   NS_GET_IID(nsIDOMFocusListener),
+                                   NS_EVENT_FLAG_CAPTURE);
+  }
+
+  piTarget->RemoveEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
+                                     NS_GET_IID(nsIDOMMouseListener));
+  piTarget->RemoveEventListenerByIID(static_cast<nsIDOMKeyListener*>(this),
+                                     NS_GET_IID(nsIDOMKeyListener));
+  
   return NS_OK;
 }
 
 // mozInlineSpellChecker::GetEnableRealTimeSpell
 
 NS_IMETHODIMP
 mozInlineSpellChecker::GetEnableRealTimeSpell(PRBool* aEnabled)
 {
@@ -1632,17 +1652,18 @@ ContentIsDescendantOf(nsINode* aPossible
 //    This is complicated by the fact that our mouse events are happening after
 //    selection has been changed to account for the mouse click. But keyboard
 //    events are happening before the caret selection has changed. Working
 //    around this by letting keyboard events setting forceWordSpellCheck to
 //    true. aNewPositionOffset also tries to work around this for the
 //    DOM_VK_RIGHT and DOM_VK_LEFT cases.
 
 nsresult
-mozInlineSpellChecker::HandleNavigationEvent(PRBool aForceWordSpellCheck,
+mozInlineSpellChecker::HandleNavigationEvent(nsIDOMEvent* aEvent,
+                                             PRBool aForceWordSpellCheck,
                                              PRInt32 aNewPositionOffset)
 {
   nsresult rv;
 
   // If we already handled the navigation event and there is no possibility
   // anything has changed since then, we don't have to do anything. This
   // optimization makes a noticeable difference when you hold down a navigation
   // key like Page Down.
@@ -1668,71 +1689,103 @@ mozInlineSpellChecker::HandleNavigationE
     NS_ENSURE_SUCCESS(rv, rv);
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP mozInlineSpellChecker::HandleEvent(nsIDOMEvent* aEvent)
 {
-  nsAutoString eventType;
-  aEvent->GetType(eventType);
+  return NS_OK;
+}
 
-  if (eventType.EqualsLiteral("blur")) {
-    return Blur(aEvent);
-  }
-  if (eventType.EqualsLiteral("click")) {
-    return MouseClick(aEvent);
-  }
-  if (eventType.EqualsLiteral("keypress")) {
-    return KeyPress(aEvent);
-  }
-
+NS_IMETHODIMP mozInlineSpellChecker::Focus(nsIDOMEvent* aEvent)
+{
   return NS_OK;
 }
 
-nsresult mozInlineSpellChecker::Blur(nsIDOMEvent* aEvent)
+NS_IMETHODIMP mozInlineSpellChecker::Blur(nsIDOMEvent* aEvent)
 {
   // force spellcheck on blur, for instance when tabbing out of a textbox
-  HandleNavigationEvent(PR_TRUE);
+  HandleNavigationEvent(aEvent, PR_TRUE);
   return NS_OK;
 }
 
-nsresult mozInlineSpellChecker::MouseClick(nsIDOMEvent *aMouseEvent)
+NS_IMETHODIMP mozInlineSpellChecker::MouseClick(nsIDOMEvent *aMouseEvent)
 {
   nsCOMPtr<nsIDOMMouseEvent>mouseEvent = do_QueryInterface(aMouseEvent);
   NS_ENSURE_TRUE(mouseEvent, NS_OK);
 
   // ignore any errors from HandleNavigationEvent as we don't want to prevent 
   // anyone else from seeing this event.
   PRUint16 button;
   mouseEvent->GetButton(&button);
-  HandleNavigationEvent(button != 0);
+  if (button == 0)
+    HandleNavigationEvent(mouseEvent, PR_FALSE);
+  else
+    HandleNavigationEvent(mouseEvent, PR_TRUE);
+  return NS_OK;
+}
+
+NS_IMETHODIMP mozInlineSpellChecker::MouseDown(nsIDOMEvent* aMouseEvent)
+{
+  return NS_OK;
+}
+
+NS_IMETHODIMP mozInlineSpellChecker::MouseUp(nsIDOMEvent* aMouseEvent)
+{
+  return NS_OK;
+}
+
+NS_IMETHODIMP mozInlineSpellChecker::MouseDblClick(nsIDOMEvent* aMouseEvent)
+{
   return NS_OK;
 }
 
-nsresult mozInlineSpellChecker::KeyPress(nsIDOMEvent* aKeyEvent)
+NS_IMETHODIMP mozInlineSpellChecker::MouseOver(nsIDOMEvent* aMouseEvent)
+{
+  return NS_OK;
+}
+
+NS_IMETHODIMP mozInlineSpellChecker::MouseOut(nsIDOMEvent* aMouseEvent)
+{
+  return NS_OK;
+}
+
+NS_IMETHODIMP mozInlineSpellChecker::KeyDown(nsIDOMEvent* aKeyEvent)
+{
+  return NS_OK;
+}
+
+
+NS_IMETHODIMP mozInlineSpellChecker::KeyUp(nsIDOMEvent* aKeyEvent)
+{
+  return NS_OK;
+}
+
+
+NS_IMETHODIMP mozInlineSpellChecker::KeyPress(nsIDOMEvent* aKeyEvent)
 {
   nsCOMPtr<nsIDOMKeyEvent>keyEvent = do_QueryInterface(aKeyEvent);
   NS_ENSURE_TRUE(keyEvent, NS_OK);
 
   PRUint32 keyCode;
   keyEvent->GetKeyCode(&keyCode);
 
   // we only care about navigation keys that moved selection 
   switch (keyCode)
   {
     case nsIDOMKeyEvent::DOM_VK_RIGHT:
     case nsIDOMKeyEvent::DOM_VK_LEFT:
-      HandleNavigationEvent(PR_FALSE, keyCode == nsIDOMKeyEvent::DOM_VK_RIGHT ? 1 : -1);
+      HandleNavigationEvent(aKeyEvent, PR_FALSE, keyCode == nsIDOMKeyEvent::DOM_VK_RIGHT ? 1 : -1);
       break;
     case nsIDOMKeyEvent::DOM_VK_UP:
     case nsIDOMKeyEvent::DOM_VK_DOWN:
     case nsIDOMKeyEvent::DOM_VK_HOME:
     case nsIDOMKeyEvent::DOM_VK_END:
     case nsIDOMKeyEvent::DOM_VK_PAGE_UP:
     case nsIDOMKeyEvent::DOM_VK_PAGE_DOWN:
-      HandleNavigationEvent(PR_TRUE /* force a spelling correction */);
+      HandleNavigationEvent(aKeyEvent, PR_TRUE /* force a spelling correction */);
       break;
   }
 
   return NS_OK;
 }
--- a/extensions/spellcheck/src/mozInlineSpellChecker.h
+++ b/extensions/spellcheck/src/mozInlineSpellChecker.h
@@ -43,26 +43,23 @@
 #include "nsIDOMRange.h"
 #include "nsIEditorSpellCheck.h"
 #include "nsIEditActionListener.h"
 #include "nsIInlineSpellChecker.h"
 #include "nsITextServicesDocument.h"
 #include "nsIDOMTreeWalker.h"
 #include "nsWeakReference.h"
 #include "nsIEditor.h"
-#include "nsIDOMEventListener.h"
+#include "nsIDOMFocusListener.h"
+#include "nsIDOMMouseListener.h"
+#include "nsIDOMKeyListener.h"
 #include "nsWeakReference.h"
 #include "mozISpellI18NUtil.h"
 #include "nsCycleCollectionParticipant.h"
 
-// X.h defines KeyPress
-#ifdef KeyPress
-#undef KeyPress
-#endif
-
 class nsIDOMMouseEventListener;
 class mozInlineSpellWordUtil;
 class mozInlineSpellChecker;
 class mozInlineSpellResume;
 
 class mozInlineSpellStatus
 {
 public:
@@ -137,20 +134,18 @@ protected:
   nsresult FillNoCheckRangeFromAnchor(mozInlineSpellWordUtil& aWordUtil);
 
   nsresult GetDocument(nsIDOMDocument** aDocument);
   nsresult PositionToCollapsedRange(nsIDOMDocument* aDocument,
                                     nsIDOMNode* aNode, PRInt32 aOffset,
                                     nsIDOMRange** aRange);
 };
 
-class mozInlineSpellChecker : public nsIInlineSpellChecker,
-                              public nsIEditActionListener,
-                              public nsIDOMEventListener,
-                              public nsSupportsWeakReference
+class mozInlineSpellChecker : public nsIInlineSpellChecker, nsIEditActionListener, nsIDOMFocusListener, nsIDOMMouseListener, nsIDOMKeyListener,
+                                     nsSupportsWeakReference
 {
 private:
   friend class mozInlineSpellStatus;
 
   // Access with CanEnableInlineSpellChecking
   enum SpellCheckingState { SpellCheck_Uninitialized = -1,
                             SpellCheck_NotAvailable = 0,
                             SpellCheck_Available = 1};
@@ -221,25 +216,41 @@ private:
     kOpIncreaseZIndex      = 3018
   };
 
 public:
 
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
   NS_DECL_NSIEDITACTIONLISTENER
   NS_DECL_NSIINLINESPELLCHECKER
-  NS_DECL_NSIDOMEVENTLISTENER
-  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(mozInlineSpellChecker, nsIDOMEventListener)
+  NS_DECL_CYCLE_COLLECTION_CLASS_AMBIGUOUS(mozInlineSpellChecker, nsIDOMKeyListener)
 
   // returns true if it looks likely that we can enable real-time spell checking
   static PRBool CanEnableInlineSpellChecking();
 
-  nsresult Blur(nsIDOMEvent* aEvent);
-  nsresult MouseClick(nsIDOMEvent* aMouseEvent);
-  nsresult KeyPress(nsIDOMEvent* aKeyEvent);
+  /*BEGIN implementations of focus event handler interface*/
+  NS_IMETHOD Focus(nsIDOMEvent* aEvent);
+  NS_IMETHOD Blur(nsIDOMEvent* aEvent);
+  /*END implementations of focus event handler interface*/
+
+  /*BEGIN implementations of mouseevent handler interface*/
+  NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent);
+  NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
+  NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
+  NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
+  NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
+  NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
+  NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);
+  /*END implementations of mouseevent handler interface*/
+
+  /* BEGIN interfaces in to the keylistener  interface. */
+  NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
+  NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
+  NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
+  /* END interfaces from nsIDOMKeyListener */ 
 
   mozInlineSpellChecker();
   virtual ~mozInlineSpellChecker();
 
   // spell checks all of the words between two nodes
   nsresult SpellCheckBetweenNodes(nsIDOMNode *aStartNode,
                                   PRInt32 aStartOffset,
                                   nsIDOMNode *aEndNode,
@@ -281,17 +292,17 @@ public:
 
   nsresult MakeSpellCheckRange(nsIDOMNode* aStartNode, PRInt32 aStartOffset,
                                nsIDOMNode* aEndNode, PRInt32 aEndOffset,
                                nsIDOMRange** aRange);
 
   // DOM and editor event registration helper routines
   nsresult RegisterEventListeners();
   nsresult UnregisterEventListeners();
-  nsresult HandleNavigationEvent(PRBool aForceWordSpellCheck, PRInt32 aNewPositionOffset = 0);
+  nsresult HandleNavigationEvent(nsIDOMEvent * aEvent, PRBool aForceWordSpellCheck, PRInt32 aNewPositionOffset = 0);
 
   nsresult GetSpellCheckSelection(nsISelection ** aSpellCheckSelection);
   nsresult SaveCurrentSelectionPosition();
 
   nsresult ResumeCheck(mozInlineSpellStatus* aStatus);
 };
 
 #endif /* __mozinlinespellchecker_h__ */
--- a/extensions/widgetutils/src/nsWidgetUtils.cpp
+++ b/extensions/widgetutils/src/nsWidgetUtils.cpp
@@ -61,18 +61,21 @@
 #include "nsRect.h"
 #include "nsStringGlue.h"
 #include "nsWeakReference.h"
 #include "nsIWebBrowser.h"
 #include "nsIObserverService.h"
 #include "nsIDOMEventTarget.h"
 #include "nsPIDOMWindow.h"
 #include "nsIDOMWindow.h"
+#include "nsIDOMKeyListener.h"
 #include "nsIDOMCompositionListener.h"
 #include "nsIDOMTextListener.h"
+#include "nsIDOMMouseMotionListener.h"
+#include "nsIDOMMouseListener.h"
 #include "nsIDOMMouseEvent.h"
 #include "nsIDOMNSEvent.h"
 #include "nsIView.h"
 #include "nsGUIEvent.h"
 #include "nsIViewManager.h"
 #include "nsIContentPolicy.h"
 #include "nsIDocShellTreeItem.h"
 #include "nsIContent.h"
@@ -90,40 +93,50 @@ static PRBool g_is_scrollable = PR_FALSE
 #define NS_FRAME_HAS_OPTIMIZEDVIEW 0x02000000
 #define BEHAVIOR_ACCEPT nsIPermissionManager::ALLOW_ACTION
 #define BEHAVIOR_REJECT nsIPermissionManager::DENY_ACTION
 #define BEHAVIOR_NOFOREIGN 3
 #define NUMBER_OF_TYPES 13
 
 // TODO auto reload nsWidgetUtils in C.
 class nsWidgetUtils : public nsIObserver,
-                      public nsIDOMEventListener,
+                      public nsIDOMMouseMotionListener,
+                      public nsIDOMMouseListener,
                       public nsIContentPolicy,
                       public nsSupportsWeakReference
 {
 public:
   nsWidgetUtils();
   virtual ~nsWidgetUtils();
 
+  // nsIDOMMouseMotionListener
+  NS_IMETHOD MouseMove(nsIDOMEvent* aDOMEvent);
+  NS_IMETHOD DragMove(nsIDOMEvent* aMouseEvent);
+  NS_IMETHOD HandleEvent(nsIDOMEvent* aDOMEvent);
+
+  // nsIDOMMouseListener
+  NS_IMETHOD MouseDown(nsIDOMEvent* aDOMEvent);
+  NS_IMETHOD MouseUp(nsIDOMEvent* aDOMEvent);
+  NS_IMETHOD MouseClick(nsIDOMEvent* aDOMEvent);
+  NS_IMETHOD MouseDblClick(nsIDOMEvent* aDOMEvent);
+  NS_IMETHOD MouseOver(nsIDOMEvent* aDOMEvent);
+  NS_IMETHOD MouseOut(nsIDOMEvent* aDOMEvent);
+
   NS_DECL_ISUPPORTS
-  NS_DECL_NSIDOMEVENTLISTENER
   NS_DECL_NSIOBSERVER 
   NS_DECL_NSICONTENTPOLICY
 
 private:
   nsresult Init(void);
   void RemoveWindowListeners(nsIDOMWindow *aDOMWin);
   void GetChromeEventHandler(nsIDOMWindow *aDOMWin, nsIDOMEventTarget **aChromeTarget);
   void AttachWindowListeners(nsIDOMWindow *aDOMWin);
   PRBool IsXULNode(nsIDOMNode *aNode, PRUint32 *aType = 0);
   nsresult GetDOMWindowByNode(nsIDOMNode *aNode, nsIDOMWindow * *aDOMWindow);
   nsresult UpdateFromEvent(nsIDOMEvent *aDOMEvent);
-  nsresult MouseDown(nsIDOMEvent* aDOMEvent);
-  nsresult MouseUp(nsIDOMEvent* aDOMEvent);
-  nsresult MouseMove(nsIDOMEvent* aDOMEvent);
 
   static void StopPanningCallback(nsITimer *timer, void *closure);
 
   nsCOMPtr<nsIWidget> mWidget;
   nsCOMPtr<nsIViewManager> mViewManager;
   nsCOMPtr<nsITimer> mTimer;
 };
 
@@ -198,17 +211,17 @@ nsWidgetUtils::UpdateFromEvent(nsIDOMEve
   NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE);
   mViewManager = shell->GetViewManager();
   NS_ENSURE_TRUE(mViewManager, NS_ERROR_FAILURE);
   mViewManager->GetRootWidget(getter_AddRefs(mWidget));
   NS_ENSURE_TRUE(mWidget, NS_ERROR_FAILURE);
   return NS_OK;
 }
 
-nsresult
+NS_IMETHODIMP
 nsWidgetUtils::MouseDown(nsIDOMEvent* aDOMEvent)
 {
   g_is_scrollable = PR_FALSE;
   // Return TRUE from your signal handler to mark the event as consumed.
   if (NS_FAILED(UpdateFromEvent(aDOMEvent)))
     return NS_OK;
   g_is_scrollable = PR_TRUE;
   if (g_is_scrollable) {
@@ -219,17 +232,17 @@ nsWidgetUtils::MouseDown(nsIDOMEvent* aD
 }
 
 /* static */ void
 nsWidgetUtils::StopPanningCallback(nsITimer *timer, void *closure)
 {
   g_panning = PR_FALSE;
 }
 
-nsresult
+NS_IMETHODIMP
 nsWidgetUtils::MouseUp(nsIDOMEvent* aDOMEvent)
 {
   nsCOMPtr <nsIDOMMouseEvent> mouseEvent;
   mouseEvent = do_QueryInterface(aDOMEvent);
   if (!mouseEvent)
     return NS_OK;
   // Return TRUE from your signal handler to mark the event as consumed.
   g_lastX = MIN_INT;
@@ -245,17 +258,17 @@ nsWidgetUtils::MouseUp(nsIDOMEvent* aDOM
        if (NS_SUCCEEDED(rv))
          return NS_OK;
      }
      g_panning = PR_FALSE;
   }
   return NS_OK;
 }
 
-nsresult
+NS_IMETHODIMP
 nsWidgetUtils::MouseMove(nsIDOMEvent* aDOMEvent)
 {
   if (!g_is_scrollable) return NS_OK;
 
   nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aDOMEvent);
   if (!mouseEvent)
     return NS_OK;
   int x, y;
@@ -330,31 +343,49 @@ nsWidgetUtils::ShouldLoad(PRUint32      
         !lscheme.EqualsLiteral("https"))
         return NS_OK;
     if (g_panning > 0)
       *aDecision = nsIContentPolicy::REJECT_REQUEST;
     return NS_OK;
 }
 
 NS_IMETHODIMP
+nsWidgetUtils::MouseClick(nsIDOMEvent* aDOMEvent)
+{
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsWidgetUtils::MouseDblClick(nsIDOMEvent* aDOMEvent)
+{
+  return NS_OK;
+}
+
+NS_IMETHODIMP
 nsWidgetUtils::HandleEvent(nsIDOMEvent* aDOMEvent)
 {
-  nsAutoString eventType;
-  aEvent->GetType(eventType);
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsWidgetUtils::MouseOver(nsIDOMEvent* aDOMEvent)
+{
+  return NS_OK;
+}
 
-  if (eventType.EqualsLiteral("mousedown")) {
-    return MouseDown(aEvent);
-  }
-  if (eventType.EqualsLiteral("mouseup")) {
-    return MouseUp(aEvent);
-  }
-  if (eventType.EqualsLiteral("mousemove")) {
-    return MouseMove(aEvent);
-  }
+NS_IMETHODIMP
+nsWidgetUtils::MouseOut(nsIDOMEvent* aDOMEvent)
+{
+  return NS_OK;
+}
 
+
+NS_IMETHODIMP
+nsWidgetUtils::DragMove(nsIDOMEvent* aDOMEvent)
+{
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsWidgetUtils::ShouldProcess(PRUint32          aContentType,
                              nsIURI           *aContentLocation,
                              nsIURI           *aRequestingLocation,
                              nsISupports      *aRequestingContext,
@@ -429,54 +460,66 @@ nsWidgetUtils::RemoveWindowListeners(nsI
     GetChromeEventHandler(aDOMWin, getter_AddRefs(chromeEventHandler));
     if (!chromeEventHandler) {
         return;
     }
 
     // Use capturing, otherwise the normal find next will get activated when ours should
 
     // Remove DOM Text listener for IME text events
-    chromeEventHandler->RemoveEventListener(NS_LITERAL_STRING("mousedown"),
-                                            this, PR_FALSE);
-    chromeEventHandler->RemoveEventListener(NS_LITERAL_STRING("mouseup"),
-                                            this, PR_FALSE);
-    chromeEventHandler->RemoveEventListener(NS_LITERAL_STRING("mousemove"),
-                                            this, PR_FALSE);
+    rv = chromeEventHandler->
+      RemoveEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
+                               NS_GET_IID(nsIDOMMouseListener));
+    if (NS_FAILED(rv)) {
+        NS_WARNING("Failed to add Mouse Motion listener\n");
+        return;
+    }
+    rv = chromeEventHandler->
+      RemoveEventListenerByIID(static_cast<nsIDOMMouseMotionListener*>(this),
+                               NS_GET_IID(nsIDOMMouseMotionListener));
+    if (NS_FAILED(rv)) {
+        NS_WARNING("Failed to add Mouse Motion listener\n");
+        return;
+    }
 }
 
 void
 nsWidgetUtils::AttachWindowListeners(nsIDOMWindow *aDOMWin)
 {
     nsresult rv;
     nsCOMPtr<nsIDOMEventTarget> chromeEventHandler;
     GetChromeEventHandler(aDOMWin, getter_AddRefs(chromeEventHandler));
     if (!chromeEventHandler) {
         return;
     }
 
     // Use capturing, otherwise the normal find next will get activated when ours should
 
     // Attach menu listeners, this will help us ignore keystrokes meant for menus
-    chromeEventHandler->AddEventListener(NS_LITERAL_STRING("mousedown"), this,
-                                         PR_FALSE, PR_FALSE);
-    chromeEventHandler->AddEventListener(NS_LITERAL_STRING("mouseup"), this,
-                                         PR_FALSE, PR_FALSE);
-    chromeEventHandler->AddEventListener(NS_LITERAL_STRING("mousemove"), this,
-                                         PR_FALSE, PR_FALSE);
+    rv = chromeEventHandler->
+      AddEventListenerByIID(static_cast<nsIDOMMouseListener*>(this),
+                            NS_GET_IID(nsIDOMMouseListener));
+    if (NS_FAILED(rv)) {
+        NS_WARNING("Failed to add Mouse Motion listener\n");
+        return;
+    }
+    rv = chromeEventHandler->
+      AddEventListenerByIID(static_cast<nsIDOMMouseMotionListener*>(this),
+                            NS_GET_IID(nsIDOMMouseMotionListener));
+    if (NS_FAILED(rv)) {
+        NS_WARNING("Failed to add Mouse Motion listener\n");
+        return;
+    }
 }
 
 nsWidgetUtils::~nsWidgetUtils()
 {
 }
 
-NS_IMPL_ISUPPORTS4(nsWidgetUtils,
-                   nsIObserver,
-                   nsIDOMEventListener,
-                   nsIContentPolicy,
-                   nsISupportsWeakReference)
+NS_IMPL_ISUPPORTS5(nsWidgetUtils, nsIObserver, nsIDOMMouseMotionListener, nsIDOMMouseListener, nsIContentPolicy, nsISupportsWeakReference)
 
 NS_IMETHODIMP
 nsWidgetUtils::Observe(nsISupports *aSubject, const char *aTopic, const PRUnichar *aData)
 {
   nsresult rv;
   if (!strcmp(aTopic,"domwindowopened")) 
   {
     nsCOMPtr<nsIDOMWindow> chromeWindow = do_QueryInterface(aSubject);