Bug 1102906 - Fix immovable caret after drag-and-drop. r=roc
authorTing-Yu Lin <tlin@mozilla.com>
Wed, 26 Nov 2014 20:36:00 +0100
changeset 242148 e70f4f5c543f5d3c6b54d1dcd0b0f48b43b482b2
parent 242147 a019791fc44f930741a45b37be142981fca823c3
child 242149 a5b0c43fe95140f176c025ad4cf8f8323cbd1618
push id4311
push userraliiev@mozilla.com
push dateMon, 12 Jan 2015 19:37:41 +0000
treeherdermozilla-beta@150c9fed433b [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs1102906, 924692
milestone36.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 1102906 - Fix immovable caret after drag-and-drop. r=roc The deleted lines were added in bug 924692 part 4. It will incorrectly disable the caret in PresShell so that the caret cannot be moved by using keyboard in nsSelectMoveScrollCommand::DoCommand().
editor/libeditor/nsEditorEventListener.cpp
editor/libeditor/tests/chrome.ini
editor/libeditor/tests/test_bug1102906.html
--- a/editor/libeditor/nsEditorEventListener.cpp
+++ b/editor/libeditor/nsEditorEventListener.cpp
@@ -871,20 +871,16 @@ nsEditorEventListener::CleanupDragDropCa
   if (!mCaret) {
     return;
   }
 
   mCaret->SetVisible(false);    // hide it, so that it turns off its timer
 
   nsCOMPtr<nsIPresShell> presShell = GetPresShell();
   if (presShell) {
-    nsCOMPtr<nsISelectionController> selCon(do_QueryInterface(presShell));
-    if (selCon) {
-      selCon->SetCaretEnabled(false);
-    }
     presShell->RestoreCaret();
   }
 
   mCaret->Terminate();
   mCaret = nullptr;
 }
 
 nsresult
--- a/editor/libeditor/tests/chrome.ini
+++ b/editor/libeditor/tests/chrome.ini
@@ -14,16 +14,17 @@ skip-if = buildapp == 'mulet'
 [test_bug607584.xul]
 [test_bug616590.xul]
 [test_bug635636.html]
 [test_bug636465.xul]
 [test_bug646194.xul]
 [test_bug780908.xul]
 [test_bug830600.html]
 [test_bug1053048.html]
+[test_bug1102906.html]
 [test_composition_event_created_in_chrome.html]
 [test_contenteditable_text_input_handling.html]
 [test_dragdrop.html]
 skip-if = buildapp == 'mulet'
 [test_htmleditor_keyevent_handling.html]
 [test_selection_move_commands.xul]
 [test_texteditor_keyevent_handling.html]
 # disables the key handling test on gtk because gtk overrides some key events
new file mode 100644
--- /dev/null
+++ b/editor/libeditor/tests/test_bug1102906.html
@@ -0,0 +1,57 @@
+<!DOCTYPE HTML>
+<html>
+<!--
+https://bugzilla.mozilla.org/show_bug.cgi?id=1102906
+-->
+<head>
+  <meta charset="utf-8">
+  <title>Test for Bug 1102906</title>
+
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/ChromeUtils.js"></script>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/EventUtils.js"></script>
+  <script type="application/javascript"
+          src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script>
+
+  <link rel="stylesheet" type="text/css" href="chrome://global/skin"/>
+  <link rel="stylesheet" type="text/css"
+        href="chrome://mochikit/content/tests/SimpleTest/test.css"/>
+
+  <script type="application/javascript;version=1.8"">
+   "use strict";
+
+  /* Test for Bug 1102906 */
+  /* The caret should be movable by using keyboard after drag-and-drop. */
+
+  SimpleTest.waitForExplicitFinish();
+  SimpleTest.waitForFocus( () => {
+    let content = document.getElementById("content");
+    let drag = document.getElementById("drag")
+      let selection = window.getSelection();
+
+    /* Perform drag-and-drop for an arbitrary content. The caret should be at
+       the end of the contenteditable. */
+    selection.selectAllChildren(drag);
+    synthesizeDrop(drag, content, {}, "copy");
+
+    let textContentAfterDrop = content.textContent;
+
+    /* Move the caret to the front of the contenteditable by using keyboard. */
+    for (let i = 0; i < content.textContent.length; ++i) {
+      sendKey("LEFT");
+    }
+    sendChar("!");
+
+    is(content.textContent, "!" + textContentAfterDrop,
+       "The exclamation mark should be inserted at the front.");
+
+    SimpleTest.finish();
+  });
+  </script>
+</head>
+<body>
+<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1102906">Mozilla Bug 1102906</a>
+<div id="content" contenteditable="true"><span id="drag">Drag</span></div>
+</body>
+</html>