Bug 715110 - Don't use getPreventDefault in editor; r=ehsan
authorMs2ger <ms2ger@gmail.com>
Wed, 11 Jan 2012 09:23:07 +0100
changeset 85383 109e7285c5eee7650494ebf560f596cb7ff71fc3
parent 85382 2f310f45610707e33b63f292d144b946d7b8bec1
child 85384 d2e9c6b60088cd562458fd24d000f12cb85090fb
push id805
push userakeybl@mozilla.com
push dateWed, 01 Feb 2012 18:17:35 +0000
treeherdermozilla-aurora@6fb3bf232436 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs715110
milestone12.0a1
Bug 715110 - Don't use getPreventDefault in editor; r=ehsan
editor/libeditor/base/nsEditorEventListener.cpp
--- a/editor/libeditor/base/nsEditorEventListener.cpp
+++ b/editor/libeditor/base/nsEditorEventListener.cpp
@@ -497,22 +497,20 @@ nsEditorEventListener::KeyPress(nsIDOMEv
   nsAutoEditorKeypressOperation operation(mEditor, NSEvent);
 
   // DOM event handling happens in two passes, the client pass and the system
   // pass.  We do all of our processing in the system pass, to allow client
   // handlers the opportunity to cancel events and prevent typing in the editor.
   // If the client pass cancelled the event, defaultPrevented will be true
   // below.
 
-  if (NSEvent) {
-    bool defaultPrevented;
-    NSEvent->GetPreventDefault(&defaultPrevented);
-    if (defaultPrevented) {
-      return NS_OK;
-    }
+  bool defaultPrevented;
+  aKeyEvent->GetDefaultPrevented(&defaultPrevented);
+  if (defaultPrevented) {
+    return NS_OK;
   }
 
   nsCOMPtr<nsIDOMKeyEvent> keyEvent = do_QueryInterface(aKeyEvent);
   if (!keyEvent) {
     //non-key event passed to keypress.  bad things.
     return NS_OK;
   }
 
@@ -543,20 +541,18 @@ nsEditorEventListener::MouseClick(nsIDOM
       presShell ? presShell->GetPresContext() : nsnull;
     if (presContext && currentDoc) {
       nsIMEStateManager::OnClickInEditor(presContext,
         currentDoc->HasFlag(NODE_IS_EDITABLE) ? nsnull : focusedContent,
         mouseEvent);
     }
   }
 
-  nsCOMPtr<nsIDOMNSEvent> nsevent = do_QueryInterface(aMouseEvent);
-  NS_ASSERTION(nsevent, "nsevent must not be NULL here");
   bool preventDefault;
-  nsresult rv = nsevent->GetPreventDefault(&preventDefault);
+  nsresult rv = aMouseEvent->GetDefaultPrevented(&preventDefault);
   if (NS_FAILED(rv) || preventDefault) {
     // We're done if 'preventdefault' is true (see for example bug 70698).
     return rv;
   }
 
   // If we got a mouse down inside the editing area, we should force the 
   // IME to commit before we change the cursor position
   mEditor->ForceCompositionEnd();
@@ -686,22 +682,20 @@ nsEditorEventListener::DragEnter(nsIDOMD
 
   return DragOver(aDragEvent);
 }
 
 nsresult
 nsEditorEventListener::DragOver(nsIDOMDragEvent* aDragEvent)
 {
   nsCOMPtr<nsIDOMNode> parent;
-  nsCOMPtr<nsIDOMNSEvent> domNSEvent = do_QueryInterface(aDragEvent);
-  if (domNSEvent) {
-    bool defaultPrevented;
-    domNSEvent->GetPreventDefault(&defaultPrevented);
-    if (defaultPrevented)
-      return NS_OK;
+  bool defaultPrevented;
+  aDragEvent->GetDefaultPrevented(&defaultPrevented);
+  if (defaultPrevented) {
+    return NS_OK;
   }
 
   aDragEvent->GetRangeParent(getter_AddRefs(parent));
   nsCOMPtr<nsIContent> dropParent = do_QueryInterface(parent);
   NS_ENSURE_TRUE(dropParent, NS_ERROR_FAILURE);
 
   if (!dropParent->IsEditable()) {
     return NS_OK;
@@ -761,22 +755,20 @@ nsEditorEventListener::DragExit(nsIDOMDr
   return NS_OK;
 }
 
 nsresult
 nsEditorEventListener::Drop(nsIDOMDragEvent* aMouseEvent)
 {
   CleanupDragDropCaret();
 
-  nsCOMPtr<nsIDOMNSEvent> domNSEvent = do_QueryInterface(aMouseEvent);
-  if (domNSEvent) {
-    bool defaultPrevented;
-    domNSEvent->GetPreventDefault(&defaultPrevented);
-    if (defaultPrevented)
-      return NS_OK;
+  bool defaultPrevented;
+  aMouseEvent->GetDefaultPrevented(&defaultPrevented);
+  if (defaultPrevented) {
+    return NS_OK;
   }
 
   nsCOMPtr<nsIDOMNode> parent;
   aMouseEvent->GetRangeParent(getter_AddRefs(parent));
   nsCOMPtr<nsIContent> dropParent = do_QueryInterface(parent);
   NS_ENSURE_TRUE(dropParent, NS_ERROR_FAILURE);
 
   if (!dropParent->IsEditable()) {