Bug 460595 - Cannot drag text selection in input control. r=smaug, sr=neil.
authorAsaf Romano <mozilla.mano@sent.com>
Mon, 20 Oct 2008 18:29:55 +0200
changeset 20671 757e0b46013ac73c030daf1fa04fc5f9fdb64cd7
parent 20670 47a75839a0097df23a166cf0fedb4afa23bf0473
child 20672 52bb0a8280613f72609261686b967971518450b9
push idunknown
push userunknown
push dateunknown
reviewerssmaug, neil
bugs460595
milestone1.9.1b2pre
Bug 460595 - Cannot drag text selection in input control. r=smaug, sr=neil.
editor/libeditor/base/nsEditor.cpp
editor/libeditor/text/nsEditorEventListeners.cpp
editor/libeditor/text/nsEditorEventListeners.h
--- a/editor/libeditor/base/nsEditor.cpp
+++ b/editor/libeditor/base/nsEditor.cpp
@@ -317,17 +317,18 @@ nsEditor::InstallEventListeners()
   rv |= piTarget->AddEventListenerByIID(mTextListenerP,
                                         NS_GET_IID(nsIDOMTextListener));
 
   rv |= piTarget->AddEventListenerByIID(mCompositionListenerP,
                                         NS_GET_IID(nsIDOMCompositionListener));
 
   nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(piTarget));
   if (target) {
-    rv |= target->AddEventListener(NS_LITERAL_STRING("dragstart"), mDragListenerP, PR_FALSE);
+    // See bug 455215, we cannot use the standard dragstart yet
+    rv |= target->AddEventListener(NS_LITERAL_STRING("draggesture"), mDragListenerP, PR_FALSE);
     rv |= target->AddEventListener(NS_LITERAL_STRING("dragenter"), mDragListenerP, PR_FALSE);
     rv |= target->AddEventListener(NS_LITERAL_STRING("dragover"), mDragListenerP, PR_FALSE);
     rv |= target->AddEventListener(NS_LITERAL_STRING("dragleave"), mDragListenerP, PR_FALSE);
     rv |= target->AddEventListener(NS_LITERAL_STRING("drop"), mDragListenerP, PR_FALSE);
   }
 
   if (NS_FAILED(rv))
   {
@@ -392,17 +393,17 @@ nsEditor::RemoveEventListeners()
       piTarget->RemoveEventListenerByIID(mCompositionListenerP,
                                          NS_GET_IID(nsIDOMCompositionListener));
     }
 
     if (mDragListenerP)
     {
       nsCOMPtr<nsIDOMEventTarget> target(do_QueryInterface(piTarget));
       if (target) {
-        target->RemoveEventListener(NS_LITERAL_STRING("dragstart"), mDragListenerP, PR_FALSE);
+        target->RemoveEventListener(NS_LITERAL_STRING("draggesture"), mDragListenerP, PR_FALSE);
         target->RemoveEventListener(NS_LITERAL_STRING("dragenter"), mDragListenerP, PR_FALSE);
         target->RemoveEventListener(NS_LITERAL_STRING("dragover"), mDragListenerP, PR_FALSE);
         target->RemoveEventListener(NS_LITERAL_STRING("dragleave"), mDragListenerP, PR_FALSE);
         target->RemoveEventListener(NS_LITERAL_STRING("drop"), mDragListenerP, PR_FALSE);
       }
     }
   }
 }
--- a/editor/libeditor/text/nsEditorEventListeners.cpp
+++ b/editor/libeditor/text/nsEditorEventListeners.cpp
@@ -501,37 +501,37 @@ NS_IMPL_ISUPPORTS1(nsTextEditorDragListe
 nsresult
 nsTextEditorDragListener::HandleEvent(nsIDOMEvent* aEvent)
 {
   // make sure it's a drag event
   nsCOMPtr<nsIDOMDragEvent> dragEvent = do_QueryInterface(aEvent);
   if (dragEvent) {
     nsAutoString eventType;
     aEvent->GetType(eventType);
-    if (eventType.EqualsLiteral("dragstart"))
-      return DragStart(dragEvent);
+    if (eventType.EqualsLiteral("draggesture"))
+      return DragGesture(dragEvent);
     if (eventType.EqualsLiteral("dragenter"))
       return DragEnter(dragEvent);
     if (eventType.EqualsLiteral("dragover"))
       return DragOver(dragEvent);
     if (eventType.EqualsLiteral("dragleave"))
       return DragLeave(dragEvent);
     if (eventType.EqualsLiteral("drop"))
       return Drop(dragEvent);
   }
   return NS_OK;
 }
 
 
 nsresult
-nsTextEditorDragListener::DragStart(nsIDOMDragEvent* aDragEvent)
+nsTextEditorDragListener::DragGesture(nsIDOMDragEvent* aDragEvent)
 {
   if ( !mEditor )
     return NS_ERROR_NULL_POINTER;
-  
+
   // ...figure out if a drag should be started...
   PRBool canDrag;
   nsresult rv = mEditor->CanDrag(aDragEvent, &canDrag);
   if ( NS_SUCCEEDED(rv) && canDrag )
     rv = mEditor->DoDrag(aDragEvent);
 
   return rv;
 }
--- a/editor/libeditor/text/nsEditorEventListeners.h
+++ b/editor/libeditor/text/nsEditorEventListeners.h
@@ -218,17 +218,17 @@ public:
 
 protected:
 
   PRBool   CanDrop(nsIDOMDragEvent* aEvent);
   nsresult DragEnter(nsIDOMDragEvent* aDragEvent);
   nsresult DragOver(nsIDOMDragEvent* aDragEvent);
   nsresult DragLeave(nsIDOMDragEvent* aDragEvent);
   nsresult Drop(nsIDOMDragEvent* aDragEvent);
-  nsresult DragStart(nsIDOMDragEvent* aDragEvent);
+  nsresult DragGesture(nsIDOMDragEvent* aDragEvent);
 
 protected:
   nsIEditor* mEditor;
   nsWeakPtr  mPresShell;
   
   nsRefPtr<nsCaret> mCaret;
   PRBool            mCaretDrawn;
 };