Bug 663461 Part 1: Remove Add/RemoveEventListenerByIID from editor. r=smaug
authorJonas Sicking <jonas@sicking.cc>
Mon, 27 Jun 2011 16:34:54 -0700
changeset 71886 347d715650f6e33f70abcd36155b60257d7ddf18
parent 71885 b778e783e5f843d97471872b8a8a81ccffd48680
child 71887 383e60bc9089d677a74ec6b8fa1557c81d656b04
push idunknown
push userunknown
push dateunknown
reviewerssmaug
bugs663461
milestone7.0a1
Bug 663461 Part 1: Remove Add/RemoveEventListenerByIID from editor. r=smaug
dom/interfaces/events/nsIDOMEventTarget.idl
editor/libeditor/base/nsEditor.cpp
editor/libeditor/base/nsEditorEventListener.cpp
editor/libeditor/base/nsEditorEventListener.h
editor/libeditor/html/nsHTMLAbsPosition.cpp
editor/libeditor/html/nsHTMLEditor.cpp
editor/libeditor/html/nsHTMLObjectResizer.cpp
editor/libeditor/html/nsHTMLObjectResizer.h
--- a/dom/interfaces/events/nsIDOMEventTarget.idl
+++ b/dom/interfaces/events/nsIDOMEventTarget.idl
@@ -109,16 +109,24 @@ interface nsIDOMEventTarget : nsISupport
 %{C++
   // non-virtual so it won't affect the vtable
   nsresult AddEventListener(const nsAString& aType,
                             nsIDOMEventListener* aListener,
                             PRBool aUseCapture)
   {
     return AddEventListener(aType, aListener, aUseCapture, PR_FALSE, 1);
   }
+  // non-virtual so it won't affect the vtable
+  nsresult AddEventListener(const nsAString& aType,
+                            nsIDOMEventListener* aListener,
+                            PRBool aUseCapture,
+                            PRBool aWantsUntrusted)
+  {
+    return AddEventListener(aType, aListener, aUseCapture, aWantsUntrusted, 2);
+  }
 %}
 
   /**
    * This method allows the removal of event listeners from the event 
    * target. If an EventListener is removed from an EventTarget while it 
    * is processing an event, it will not be triggered by the current actions. 
    * EventListeners can never be invoked after being removed.
    * Calling removeEventListener with arguments which do not identify any 
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -326,21 +326,19 @@ nsEditor::PostCreate()
   }
   return NS_OK;
 }
 
 nsresult
 nsEditor::CreateEventListeners()
 {
   // Don't create the handler twice
-  if (mEventListener)
-    return NS_OK;
-  mEventListener = do_QueryInterface(
-    static_cast<nsIDOMKeyListener*>(new nsEditorEventListener()));
-  NS_ENSURE_TRUE(mEventListener, NS_ERROR_OUT_OF_MEMORY);
+  if (!mEventListener) {
+    mEventListener = new nsEditorEventListener();
+  }
   return NS_OK;
 }
 
 nsresult
 nsEditor::InstallEventListeners()
 {
   NS_ENSURE_TRUE(mDocWeak && mEventListener,
                  NS_ERROR_NOT_INITIALIZED);
--- a/editor/libeditor/base/nsEditorEventListener.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -127,70 +127,81 @@ nsEditorEventListener::InstallToEditor()
   NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE);
 
   nsresult rv;
 
   // register the event listeners with the listener manager
   nsEventListenerManager* elmP = piTarget->GetListenerManager(PR_TRUE);
   NS_ENSURE_STATE(elmP);
 
-  nsCOMPtr<nsIDOMEventListener> listenerBase;
-  CallQueryInterface(this, getter_AddRefs(listenerBase));
-
-  rv = elmP->AddEventListenerByType(listenerBase,
+  rv = elmP->AddEventListenerByType(this,
                                     NS_LITERAL_STRING("keypress"),
                                     NS_EVENT_FLAG_BUBBLE |
                                     NS_PRIV_EVENT_UNTRUSTED_PERMITTED |
                                     NS_EVENT_FLAG_SYSTEM_EVENT);
   NS_ENSURE_SUCCESS(rv, rv);
   // See bug 455215, we cannot use the standard dragstart event yet
-  rv = elmP->AddEventListenerByType(listenerBase,
+  rv = elmP->AddEventListenerByType(this,
                                     NS_LITERAL_STRING("draggesture"),
                                     NS_EVENT_FLAG_BUBBLE |
                                     NS_EVENT_FLAG_SYSTEM_EVENT);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(listenerBase,
+  rv = elmP->AddEventListenerByType(this,
                                     NS_LITERAL_STRING("dragenter"),
                                     NS_EVENT_FLAG_BUBBLE |
                                     NS_EVENT_FLAG_SYSTEM_EVENT);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(listenerBase,
+  rv = elmP->AddEventListenerByType(this,
                                     NS_LITERAL_STRING("dragover"),
                                     NS_EVENT_FLAG_BUBBLE |
                                     NS_EVENT_FLAG_SYSTEM_EVENT);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(listenerBase,
+  rv = elmP->AddEventListenerByType(this,
                                     NS_LITERAL_STRING("dragexit"),
                                     NS_EVENT_FLAG_BUBBLE |
                                     NS_EVENT_FLAG_SYSTEM_EVENT);
   NS_ENSURE_SUCCESS(rv, rv);
-  rv = elmP->AddEventListenerByType(listenerBase,
+  rv = elmP->AddEventListenerByType(this,
                                     NS_LITERAL_STRING("drop"),
                                     NS_EVENT_FLAG_BUBBLE |
                                     NS_EVENT_FLAG_SYSTEM_EVENT);
   NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = elmP->AddEventListenerByIID(listenerBase,
-                                   NS_GET_IID(nsIDOMMouseListener),
-                                   NS_EVENT_FLAG_CAPTURE);
+  rv = elmP->AddEventListenerByType(this,
+                                    NS_LITERAL_STRING("mousedown"),
+                                    NS_EVENT_FLAG_CAPTURE);
   NS_ENSURE_SUCCESS(rv, rv);
-
+  rv = elmP->AddEventListenerByType(this,
+                                    NS_LITERAL_STRING("mouseup"),
+                                    NS_EVENT_FLAG_CAPTURE);
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = elmP->AddEventListenerByType(this,
+                                    NS_LITERAL_STRING("click"),
+                                    NS_EVENT_FLAG_CAPTURE);
+  NS_ENSURE_SUCCESS(rv, rv);
   // Focus event doesn't bubble so adding the listener to capturing phase.
   // Make sure this works after bug 235441 gets fixed.
-  rv = elmP->AddEventListenerByIID(listenerBase,
-                                   NS_GET_IID(nsIDOMFocusListener),
-                                   NS_EVENT_FLAG_CAPTURE);
+  rv = elmP->AddEventListenerByType(this,
+                                    NS_LITERAL_STRING("blur"),
+                                    NS_EVENT_FLAG_CAPTURE);
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = elmP->AddEventListenerByType(this,
+                                    NS_LITERAL_STRING("focus"),
+                                    NS_EVENT_FLAG_CAPTURE);
   NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = piTarget->AddEventListenerByIID(listenerBase,
-                                       NS_GET_IID(nsIDOMTextListener));
+  rv = elmP->AddEventListenerByType(this,
+                                    NS_LITERAL_STRING("text"),
+                                    NS_EVENT_FLAG_BUBBLE);
   NS_ENSURE_SUCCESS(rv, rv);
-
-  rv = piTarget->AddEventListenerByIID(listenerBase,
-                                       NS_GET_IID(nsIDOMCompositionListener));
+  rv = elmP->AddEventListenerByType(this,
+                                    NS_LITERAL_STRING("compositionstart"),
+                                    NS_EVENT_FLAG_BUBBLE);
+  NS_ENSURE_SUCCESS(rv, rv);
+  rv = elmP->AddEventListenerByType(this,
+                                    NS_LITERAL_STRING("compositionend"),
+                                    NS_EVENT_FLAG_BUBBLE);
   NS_ENSURE_SUCCESS(rv, rv);
 
   return NS_OK;
 }
 
 void
 nsEditorEventListener::Disconnect()
 {
@@ -210,128 +221,125 @@ nsEditorEventListener::UninstallFromEdit
   }
 
   nsEventListenerManager* elmP =
     piTarget->GetListenerManager(PR_TRUE);
   if (!elmP) {
     return;
   }
 
-  nsCOMPtr<nsIDOMEventListener> listenerBase;
-  CallQueryInterface(this, getter_AddRefs(listenerBase));
-
-  elmP->RemoveEventListenerByType(listenerBase,
+  elmP->RemoveEventListenerByType(this,
                                   NS_LITERAL_STRING("keypress"),
                                   NS_EVENT_FLAG_BUBBLE |
                                   NS_EVENT_FLAG_SYSTEM_EVENT);
-  elmP->RemoveEventListenerByType(listenerBase,
+  elmP->RemoveEventListenerByType(this,
                                   NS_LITERAL_STRING("draggesture"),
                                   NS_EVENT_FLAG_BUBBLE |
                                   NS_EVENT_FLAG_SYSTEM_EVENT);
-  elmP->RemoveEventListenerByType(listenerBase,
+  elmP->RemoveEventListenerByType(this,
                                   NS_LITERAL_STRING("dragenter"),
                                   NS_EVENT_FLAG_BUBBLE |
                                   NS_EVENT_FLAG_SYSTEM_EVENT);
-  elmP->RemoveEventListenerByType(listenerBase,
+  elmP->RemoveEventListenerByType(this,
                                   NS_LITERAL_STRING("dragover"),
                                   NS_EVENT_FLAG_BUBBLE |
                                   NS_EVENT_FLAG_SYSTEM_EVENT);
-  elmP->RemoveEventListenerByType(listenerBase,
+  elmP->RemoveEventListenerByType(this,
                                   NS_LITERAL_STRING("dragexit"),
                                   NS_EVENT_FLAG_BUBBLE |
                                   NS_EVENT_FLAG_SYSTEM_EVENT);
-  elmP->RemoveEventListenerByType(listenerBase,
+  elmP->RemoveEventListenerByType(this,
                                   NS_LITERAL_STRING("drop"),
                                   NS_EVENT_FLAG_BUBBLE |
                                   NS_EVENT_FLAG_SYSTEM_EVENT);
-
-  elmP->RemoveEventListenerByIID(listenerBase,
-                                 NS_GET_IID(nsIDOMMouseListener),
-                                 NS_EVENT_FLAG_CAPTURE);
-
-  elmP->RemoveEventListenerByIID(listenerBase,
-                                 NS_GET_IID(nsIDOMFocusListener),
-                                 NS_EVENT_FLAG_CAPTURE);
-
-  piTarget->RemoveEventListenerByIID(listenerBase,
-                                     NS_GET_IID(nsIDOMTextListener));
-
-  piTarget->RemoveEventListenerByIID(listenerBase,
-                                     NS_GET_IID(nsIDOMCompositionListener));
+  elmP->RemoveEventListenerByType(this,
+                                  NS_LITERAL_STRING("mousedown"),
+                                  NS_EVENT_FLAG_CAPTURE);
+  elmP->RemoveEventListenerByType(this,
+                                  NS_LITERAL_STRING("mouseup"),
+                                  NS_EVENT_FLAG_CAPTURE);
+  elmP->RemoveEventListenerByType(this,
+                                  NS_LITERAL_STRING("click"),
+                                  NS_EVENT_FLAG_CAPTURE);
+  elmP->RemoveEventListenerByType(this,
+                                  NS_LITERAL_STRING("blur"),
+                                  NS_EVENT_FLAG_CAPTURE);
+  elmP->RemoveEventListenerByType(this,
+                                  NS_LITERAL_STRING("focus"),
+                                  NS_EVENT_FLAG_CAPTURE);
+  elmP->RemoveEventListenerByType(this,
+                                  NS_LITERAL_STRING("text"),
+                                  NS_EVENT_FLAG_BUBBLE);
+  elmP->RemoveEventListenerByType(this,
+                                  NS_LITERAL_STRING("compositionstart"),
+                                  NS_EVENT_FLAG_BUBBLE);
+  elmP->RemoveEventListenerByType(this,
+                                  NS_LITERAL_STRING("compositionend"),
+                                  NS_EVENT_FLAG_BUBBLE);
 }
 
 already_AddRefed<nsIPresShell>
 nsEditorEventListener::GetPresShell()
 {
   NS_PRECONDITION(mEditor,
     "The caller must check whether this is connected to an editor");
   return mEditor->GetPresShell();
 }
 
 /**
  *  nsISupports implementation
  */
 
-NS_IMPL_ADDREF(nsEditorEventListener)
-NS_IMPL_RELEASE(nsEditorEventListener)
-
-NS_INTERFACE_MAP_BEGIN(nsEditorEventListener)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMKeyListener)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMTextListener)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMCompositionListener)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMMouseListener)
-  NS_INTERFACE_MAP_ENTRY(nsIDOMFocusListener)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsIDOMEventListener, nsIDOMKeyListener)
-  NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMKeyListener)
-NS_INTERFACE_MAP_END
+NS_IMPL_ISUPPORTS1(nsEditorEventListener, nsIDOMEventListener)
 
 /**
  *  nsIDOMEventListener implementation
  */
 
 NS_IMETHODIMP
 nsEditorEventListener::HandleEvent(nsIDOMEvent* aEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
 
+  nsAutoString eventType;
+  aEvent->GetType(eventType);
+
   nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent);
   if (dragEvent) {
-    nsAutoString eventType;
-    aEvent->GetType(eventType);
     if (eventType.EqualsLiteral("draggesture"))
       return DragGesture(dragEvent);
     if (eventType.EqualsLiteral("dragenter"))
       return DragEnter(dragEvent);
     if (eventType.EqualsLiteral("dragover"))
       return DragOver(dragEvent);
     if (eventType.EqualsLiteral("dragexit"))
       return DragExit(dragEvent);
     if (eventType.EqualsLiteral("drop"))
       return Drop(dragEvent);
   }
-  return NS_OK;
-}
-
-/**
- * nsIDOMKeyListener implementation
- */
 
-NS_IMETHODIMP
-nsEditorEventListener::KeyDown(nsIDOMEvent* aKeyEvent)
-{
-  // WARNING: If you change this method, you comment out next line.
-  // NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
-  return NS_OK;
-}
+  if (eventType.EqualsLiteral("keypress"))
+    return KeyPress(aEvent);
+  if (eventType.EqualsLiteral("mousedown"))
+    return MouseDown(aEvent);
+  if (eventType.EqualsLiteral("mouseup"))
+    return MouseUp(aEvent);
+  if (eventType.EqualsLiteral("click"))
+    return MouseClick(aEvent);
+  if (eventType.EqualsLiteral("focus"))
+    return Focus(aEvent);
+  if (eventType.EqualsLiteral("blur"))
+    return Blur(aEvent);
+  if (eventType.EqualsLiteral("text"))
+    return HandleText(aEvent);
+  if (eventType.EqualsLiteral("compositionstart"))
+    return HandleStartComposition(aEvent);
+  if (eventType.EqualsLiteral("compositionend"))
+    return HandleEndComposition(aEvent);
 
-NS_IMETHODIMP
-nsEditorEventListener::KeyUp(nsIDOMEvent* aKeyEvent)
-{
-  // WARNING: If you change this method, you comment out next line.
-  // NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsEditorEventListener::KeyPress(nsIDOMEvent* aKeyEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
 
@@ -362,20 +370,16 @@ nsEditorEventListener::KeyPress(nsIDOMEv
   if (!keyEvent) {
     //non-key event passed to keypress.  bad things.
     return NS_OK;
   }
 
   return mEditor->HandleKeyPressEvent(keyEvent);
 }
 
-/**
- * nsIDOMMouseListener implementation
- */
-
 NS_IMETHODIMP
 nsEditorEventListener::MouseClick(nsIDOMEvent* aMouseEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
 
   nsCOMPtr<nsIDOMMouseEvent> mouseEvent = do_QueryInterface(aMouseEvent);
   nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(aMouseEvent);
   PRBool isTrusted = PR_FALSE;
@@ -458,52 +462,16 @@ NS_IMETHODIMP
 nsEditorEventListener::MouseDown(nsIDOMEvent* aMouseEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
   mEditor->ForceCompositionEnd();
   return NS_OK;
 }
 
 NS_IMETHODIMP
-nsEditorEventListener::MouseUp(nsIDOMEvent* aMouseEvent)
-{
-  // WARNING: If you change this method, you comment out next line.
-  // NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsEditorEventListener::MouseDblClick(nsIDOMEvent* aMouseEvent)
-{
-  // WARNING: If you change this method, you comment out next line.
-  // NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsEditorEventListener::MouseOver(nsIDOMEvent* aMouseEvent)
-{
-  // WARNING: If you change this method, you comment out next line.
-  // NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-nsEditorEventListener::MouseOut(nsIDOMEvent* aMouseEvent)
-{
-  // WARNING: If you change this method, you comment out next line.
-  // NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
-  return NS_OK;
-}
-
-/**
- * nsIDOMTextListener implementation
- */
-
-NS_IMETHODIMP
 nsEditorEventListener::HandleText(nsIDOMEvent* aTextEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
 
   if (!mEditor->IsAcceptableInputEvent(aTextEvent)) {
     return NS_OK;
   }
 
@@ -775,20 +743,16 @@ nsEditorEventListener::CanDrop(nsIDOMDra
           return PR_FALSE;  //okay, now you can bail, we are over the orginal selection
       }
     }
   }
   
   return PR_TRUE;
 }
 
-/**
- * nsIDOMCompositionListener implementation
- */
-
 NS_IMETHODIMP
 nsEditorEventListener::HandleStartComposition(nsIDOMEvent* aCompositionEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
   if (!mEditor->IsAcceptableInputEvent(aCompositionEvent)) {
     return NS_OK;
   }
   return mEditor->BeginIMEComposition();
@@ -804,20 +768,16 @@ nsEditorEventListener::HandleEndComposit
 
   // Transfer the event's trusted-ness to our editor
   nsCOMPtr<nsIDOMNSEvent> NSEvent = do_QueryInterface(aCompositionEvent);
   nsAutoEditorKeypressOperation operation(mEditor, NSEvent);
 
   return mEditor->EndIMEComposition();
 }
 
-/**
- * nsIDOMFocusListener implementation
- */
-
 NS_IMETHODIMP
 nsEditorEventListener::Focus(nsIDOMEvent* aEvent)
 {
   NS_ENSURE_TRUE(mEditor, NS_ERROR_NOT_AVAILABLE);
   NS_ENSURE_ARG(aEvent);
 
   // Don't turn on selection and caret when the editor is disabled.
   if (mEditor->IsDisabled()) {
--- a/editor/libeditor/base/nsEditorEventListener.h
+++ b/editor/libeditor/base/nsEditorEventListener.h
@@ -37,65 +37,48 @@
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsEditorEventListener_h__
 #define nsEditorEventListener_h__
 
 #include "nsCOMPtr.h"
 
 #include "nsIDOMEvent.h"
-#include "nsIDOMKeyListener.h"
-#include "nsIDOMMouseListener.h"
-#include "nsIDOMTextListener.h"
-#include "nsIDOMCompositionListener.h"
-#include "nsIDOMFocusListener.h"
+#include "nsIDOMEventListener.h"
 
 #include "nsCaret.h"
 
+// X.h defines KeyPress
+#ifdef KeyPress
+#undef KeyPress
+#endif
+
 class nsEditor;
 class nsIDOMDragEvent;
 
-class nsEditorEventListener : public nsIDOMKeyListener,
-                              public nsIDOMTextListener,
-                              public nsIDOMCompositionListener,
-                              public nsIDOMMouseListener,
-                              public nsIDOMFocusListener
+class nsEditorEventListener : public nsIDOMEventListener
 {
 public:
   nsEditorEventListener();
   virtual ~nsEditorEventListener();
 
   virtual nsresult Connect(nsEditor* aEditor);
 
   void Disconnect();
 
   NS_DECL_ISUPPORTS
   NS_DECL_NSIDOMEVENTLISTENER
 
-  // nsIDOMKeyListener
-  NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
-  NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
   NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
-
-  // nsIDOMTextListener
   NS_IMETHOD HandleText(nsIDOMEvent* aTextEvent);
-
-  // nsIDOMCompositionListener
   NS_IMETHOD HandleStartComposition(nsIDOMEvent* aCompositionEvent);
   NS_IMETHOD HandleEndComposition(nsIDOMEvent* aCompositionEvent);
-
-  // nsIDOMMouseListener
   NS_IMETHOD MouseDown(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent);
+  NS_IMETHOD MouseUp(nsIDOMEvent* aMouseEvent) { return NS_OK; }
   NS_IMETHOD MouseClick(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseDblClick(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseOver(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD MouseOut(nsIDOMEvent* aMouseEvent);
-
-  // nsIDOMFocusListener
   NS_IMETHOD Focus(nsIDOMEvent* aEvent);
   NS_IMETHOD Blur(nsIDOMEvent* aEvent);
 
 protected:
   nsresult InstallToEditor();
   void UninstallFromEditor();
 
   PRBool CanDrop(nsIDOMDragEvent* aEvent);
--- a/editor/libeditor/html/nsHTMLAbsPosition.cpp
+++ b/editor/libeditor/html/nsHTMLAbsPosition.cpp
@@ -409,18 +409,19 @@ nsHTMLEditor::GrabberClicked()
   nsresult res = NS_OK;
   if (!mMouseMotionListenerP) {
     mMouseMotionListenerP = new ResizerMouseMotionListener(this);
     if (!mMouseMotionListenerP) {return NS_ERROR_NULL_POINTER;}
 
     nsCOMPtr<nsIDOMEventTarget> piTarget = GetDOMEventTarget();
     NS_ENSURE_TRUE(piTarget, NS_ERROR_FAILURE);
 
-    res = piTarget->AddEventListenerByIID(mMouseMotionListenerP,
-                                          NS_GET_IID(nsIDOMMouseMotionListener));
+    res = piTarget->AddEventListener(NS_LITERAL_STRING("mousemove"),
+                                     mMouseMotionListenerP,
+                                     PR_FALSE, PR_FALSE);
     NS_ASSERTION(NS_SUCCEEDED(res),
                  "failed to register mouse motion listener");
   }
   mGrabberClicked = PR_TRUE;
   return res;
 }
 
 nsresult
@@ -442,18 +443,19 @@ nsHTMLEditor::EndMoving()
     mPositioningShadow = nsnull;
   }
   nsCOMPtr<nsIDOMEventTarget> piTarget = GetDOMEventTarget();
 
   if (piTarget && mMouseMotionListenerP) {
 #ifdef DEBUG
     nsresult res =
 #endif
-    piTarget->RemoveEventListenerByIID(mMouseMotionListenerP,
-                                       NS_GET_IID(nsIDOMMouseMotionListener));
+    piTarget->RemoveEventListener(NS_LITERAL_STRING("mousemove"),
+                                  mMouseMotionListenerP,
+                                  PR_FALSE);
     NS_ASSERTION(NS_SUCCEEDED(res), "failed to remove mouse motion listener");
   }
   mMouseMotionListenerP = nsnull;
 
   mGrabberClicked = PR_FALSE;
   mIsMoving = PR_FALSE;
   nsCOMPtr<nsISelection> selection;
   GetSelection(getter_AddRefs(selection));
--- a/editor/libeditor/html/nsHTMLEditor.cpp
+++ b/editor/libeditor/html/nsHTMLEditor.cpp
@@ -438,21 +438,19 @@ nsHTMLEditor::FindSelectionRoot(nsINode 
   content = content->GetEditingHost();
   return content.forget();
 }
 
 nsresult
 nsHTMLEditor::CreateEventListeners()
 {
   // Don't create the handler twice
-  if (mEventListener)
-    return NS_OK;
-  mEventListener = do_QueryInterface(
-    static_cast<nsIDOMKeyListener*>(new nsHTMLEditorEventListener()));
-  NS_ENSURE_TRUE(mEventListener, NS_ERROR_OUT_OF_MEMORY);
+  if (!mEventListener) {
+    mEventListener = new nsHTMLEditorEventListener();
+  }
   return NS_OK;
 }
 
 nsresult
 nsHTMLEditor::InstallEventListeners()
 {
   NS_ENSURE_TRUE(mDocWeak && mEventListener,
                  NS_ERROR_NOT_INITIALIZED);
@@ -481,21 +479,20 @@ nsHTMLEditor::RemoveEventListeners()
     // registerd with other targets than the DOM event receiver that
     // we can reach from here. But nonetheless, unregister the event
     // listeners with the DOM event reveiver (if it's registerd with
     // other targets, it'll get unregisterd once the target goes
     // away).
 
     if (mMouseMotionListenerP)
     {
-      // mMouseMotionListenerP might be registerd either by IID or
-      // name, unregister by both.
-      target->RemoveEventListenerByIID(mMouseMotionListenerP,
-                                       NS_GET_IID(nsIDOMMouseMotionListener));
-
+      // mMouseMotionListenerP might be registerd either as bubbling or
+      // capturing, unregister by both.
+      target->RemoveEventListener(NS_LITERAL_STRING("mousemove"),
+                                  mMouseMotionListenerP, PR_FALSE);
       target->RemoveEventListener(NS_LITERAL_STRING("mousemove"),
                                   mMouseMotionListenerP, PR_TRUE);
     }
 
     if (mResizeEventListenerP)
     {
       target->RemoveEventListener(NS_LITERAL_STRING("resize"),
                                   mResizeEventListenerP, PR_FALSE);
--- a/editor/libeditor/html/nsHTMLObjectResizer.cpp
+++ b/editor/libeditor/html/nsHTMLObjectResizer.cpp
@@ -125,30 +125,29 @@ ResizerSelectionListener::NotifySelectio
 
   return NS_OK;
 }
 
 // ==================================================================
 // ResizerMouseMotionListener
 // ==================================================================
 
-NS_IMPL_ISUPPORTS2(ResizerMouseMotionListener, nsIDOMEventListener, nsIDOMMouseMotionListener)
+NS_IMPL_ISUPPORTS1(ResizerMouseMotionListener, nsIDOMEventListener)
 
 ResizerMouseMotionListener::ResizerMouseMotionListener(nsIHTMLEditor * aEditor)
 {
   mEditor = do_GetWeakReference(aEditor);
 }
 
 ResizerMouseMotionListener::~ResizerMouseMotionListener() 
 {
 }
 
-
 NS_IMETHODIMP
-ResizerMouseMotionListener::MouseMove(nsIDOMEvent* aMouseEvent)
+ResizerMouseMotionListener::HandleEvent(nsIDOMEvent* aMouseEvent)
 {
   nsCOMPtr<nsIDOMMouseEvent> mouseEvent ( do_QueryInterface(aMouseEvent) );
   if (!mouseEvent) {
     //non-ui event passed in.  bad things.
     return NS_OK;
   }
 
   // Don't do anything special if not an HTML object resizer editor
@@ -157,28 +156,16 @@ ResizerMouseMotionListener::MouseMove(ns
   {
     // check if we have to redisplay a resizing shadow
     objectResizer->MouseMove(aMouseEvent);
   }
 
   return NS_OK;
 }
 
-NS_IMETHODIMP
-ResizerMouseMotionListener::HandleEvent(nsIDOMEvent* aMouseEvent)
-{
-  return NS_OK;
-}
-
-NS_IMETHODIMP
-ResizerMouseMotionListener::DragMove(nsIDOMEvent* aMouseEvent)
-{
-  return NS_OK;
-}
-
 // ==================================================================
 // nsHTMLEditor
 // ==================================================================
 
 nsresult
 nsHTMLEditor::CreateResizer(nsIDOMElement ** aReturn, PRInt16 aLocation, nsIDOMNode * aParentNode)
 {
   nsresult res = CreateAnonymousElement(NS_LITERAL_STRING("span"),
--- a/editor/libeditor/html/nsHTMLObjectResizer.h
+++ b/editor/libeditor/html/nsHTMLObjectResizer.h
@@ -48,17 +48,16 @@
 #include "nsString.h"
 #include "nsIHTMLEditor.h"
 #include "nsIHTMLObjectResizer.h"
 
 #include "nsIDOMMouseEvent.h"
 
 #include "nsIDOMEventListener.h"
 #include "nsISelectionListener.h"
-#include "nsIDOMMouseMotionListener.h"
 
 #define kTopLeft       NS_LITERAL_STRING("nw")
 #define kTop           NS_LITERAL_STRING("n")
 #define kTopRight      NS_LITERAL_STRING("ne")
 #define kLeft          NS_LITERAL_STRING("w")
 #define kRight         NS_LITERAL_STRING("e")
 #define kBottomLeft    NS_LITERAL_STRING("sw")
 #define kBottom        NS_LITERAL_STRING("s")
@@ -85,31 +84,28 @@ protected:
 
   nsWeakPtr mEditor;
 };
 
 // ==================================================================
 // ResizerMouseMotionListener
 // ==================================================================
 
-class ResizerMouseMotionListener: public nsIDOMMouseMotionListener
+class ResizerMouseMotionListener : public nsIDOMEventListener
 {
 public:
   ResizerMouseMotionListener(nsIHTMLEditor * aEditor);
   virtual ~ResizerMouseMotionListener();
 
 
 /*interfaces for addref and release and queryinterface*/
   NS_DECL_ISUPPORTS
 
   NS_DECL_NSIDOMEVENTLISTENER
 
-  NS_IMETHOD MouseMove(nsIDOMEvent* aMouseEvent);
-  NS_IMETHOD DragMove(nsIDOMEvent* aMouseEvent);
-
  protected:
   nsWeakPtr mEditor;
 
 };
 
 // ==================================================================
 // DocumentResizeEventListener
 // ==================================================================