Bug 665599: Remove AddRemoveEventListenerByIID from nsXBLWindowKeyHandler. r=jst
authorJonas Sicking <jonas@sicking.cc>
Fri, 24 Jun 2011 16:12:34 -0700
changeset 71736 3c6133b858cfb245a37852eaa83369921dd3878c
parent 71735 ecbf03bb7afe19c1bf8bb2e29d3de8ff7108f0e1
child 71737 62b49efaa72f96baa5511165ff81f0cf470efbc3
push id20601
push usermak77@bonardo.net
push dateSat, 25 Jun 2011 10:05:20 +0000
treeherdermozilla-central@48ad4ffc4230 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjst
bugs665599
milestone7.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 665599: Remove AddRemoveEventListenerByIID from nsXBLWindowKeyHandler. r=jst
content/xbl/src/nsXBLWindowKeyHandler.cpp
content/xbl/src/nsXBLWindowKeyHandler.h
--- a/content/xbl/src/nsXBLWindowKeyHandler.cpp
+++ b/content/xbl/src/nsXBLWindowKeyHandler.cpp
@@ -196,18 +196,17 @@ nsXBLWindowKeyHandler::~nsXBLWindowKeyHa
 
   --sRefCnt;
   if (!sRefCnt) {
     delete sXBLSpecialDocInfo;
     sXBLSpecialDocInfo = nsnull;
   }
 }
 
-NS_IMPL_ISUPPORTS2(nsXBLWindowKeyHandler,
-                   nsIDOMKeyListener,
+NS_IMPL_ISUPPORTS1(nsXBLWindowKeyHandler,
                    nsIDOMEventListener)
 
 static void
 BuildHandlerChain(nsIContent* aContent, nsXBLPrototypeHandler** aResult)
 {
   *aResult = nsnull;
 
   // Since we chain each handler onto the next handler,
@@ -388,38 +387,30 @@ nsXBLWindowKeyHandler::WalkHandlers(nsID
     if (handled)
       aKeyEvent->PreventDefault();
 
   }
   
   return NS_OK;
 }
 
-nsresult nsXBLWindowKeyHandler::KeyUp(nsIDOMEvent* aEvent)
-{
-  nsCOMPtr<nsIDOMKeyEvent> keyEvent(do_QueryInterface(aEvent));
-  NS_ENSURE_TRUE(keyEvent, NS_ERROR_INVALID_ARG);
-  return WalkHandlers(keyEvent, nsGkAtoms::keyup);
-}
-
-nsresult nsXBLWindowKeyHandler::KeyDown(nsIDOMEvent* aEvent)
+NS_IMETHODIMP
+nsXBLWindowKeyHandler::HandleEvent(nsIDOMEvent* aEvent)
 {
   nsCOMPtr<nsIDOMKeyEvent> keyEvent(do_QueryInterface(aEvent));
   NS_ENSURE_TRUE(keyEvent, NS_ERROR_INVALID_ARG);
-  return WalkHandlers(keyEvent, nsGkAtoms::keydown);
-}
 
-nsresult nsXBLWindowKeyHandler::KeyPress(nsIDOMEvent* aEvent)
-{
-  nsCOMPtr<nsIDOMKeyEvent> keyEvent(do_QueryInterface(aEvent));
-  NS_ENSURE_TRUE(keyEvent, NS_ERROR_INVALID_ARG);
-  return WalkHandlers(keyEvent, nsGkAtoms::keypress);
+  nsAutoString eventType;
+  aEvent->GetType(eventType);
+  nsCOMPtr<nsIAtom> eventTypeAtom = do_GetAtom(eventType);
+  NS_ENSURE_TRUE(eventTypeAtom, NS_ERROR_OUT_OF_MEMORY);
+
+  return WalkHandlers(keyEvent, eventTypeAtom);
 }
 
-
 //
 // EventMatched
 //
 // See if the given handler cares about this particular key event
 //
 PRBool
 nsXBLWindowKeyHandler::EventMatched(nsXBLPrototypeHandler* inHandler,
                                     nsIAtom* inEventType,
--- a/content/xbl/src/nsXBLWindowKeyHandler.h
+++ b/content/xbl/src/nsXBLWindowKeyHandler.h
@@ -36,44 +36,35 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef nsXBLWindowKeyHandler_h__
 #define nsXBLWindowKeyHandler_h__
 
 #include "nsWeakPtr.h"
-#include "nsIDOMKeyListener.h"
+#include "nsIDOMEventListener.h"
 
 class nsIAtom;
 class nsIDOMElement;
 class nsIDOMEventTarget;
 class nsIDOMKeyEvent;
 class nsIDOMEventTarget;
 class nsIXBLDocumentInfo;
 class nsXBLSpecialDocInfo;
 class nsXBLPrototypeHandler;
 
-class nsXBLWindowKeyHandler : public nsIDOMKeyListener
+class nsXBLWindowKeyHandler : public nsIDOMEventListener
 {
 public:
   nsXBLWindowKeyHandler(nsIDOMElement* aElement, nsIDOMEventTarget* aTarget);
   virtual ~nsXBLWindowKeyHandler();
-  
-  // nsIDOMetc.
-  NS_IMETHOD HandleEvent(nsIDOMEvent* aEvent)
-  {
-    return NS_OK;
-  }
 
-  NS_IMETHOD KeyUp(nsIDOMEvent* aKeyEvent);
-  NS_IMETHOD KeyDown(nsIDOMEvent* aKeyEvent);
-  NS_IMETHOD KeyPress(nsIDOMEvent* aKeyEvent);
-   
   NS_DECL_ISUPPORTS
+  NS_DECL_NSIDOMEVENTLISTENER
 
   // release globals
   static NS_HIDDEN_(void) ShutDown();
 
 protected:
   nsresult WalkHandlers(nsIDOMKeyEvent* aKeyEvent, nsIAtom* aEventType);
 
   // walk the handlers, looking for one to handle the event