Backed out changeset 9b832d90d637 (bug 462188) due to 7 test failures on Linux and 1 on Windows (0 on Mac).
authorL. David Baron <dbaron@dbaron.org>
Fri, 16 Jan 2009 15:00:40 -0800
changeset 23835 f5436f305f3a8917c651c798be17d63aa051cdaa
parent 23829 9b832d90d637d21c08ea8be077ebee04181e6037
child 23836 58b777f8849a6e5454262a962c8f1fdb295c8593
push id4751
push userdbaron@mozilla.com
push dateFri, 16 Jan 2009 23:01:46 +0000
treeherdermozilla-central@58b777f8849a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs462188
milestone1.9.2a1pre
backs out9b832d90d637d21c08ea8be077ebee04181e6037
Backed out changeset 9b832d90d637 (bug 462188) due to 7 test failures on Linux and 1 on Windows (0 on Mac).
editor/libeditor/html/nsHTMLEditRules.cpp
layout/generic/test/test_backspace_delete.html
--- a/editor/libeditor/html/nsHTMLEditRules.cpp
+++ b/editor/libeditor/html/nsHTMLEditRules.cpp
@@ -1943,34 +1943,20 @@ nsHTMLEditRules::WillDeleteSelection(nsI
     if (NS_FAILED(res)) return res;
     if (*aHandled) return NS_OK;
         
     // Test for distance between caret and text that will be deleted
     res = CheckBidiLevelForDeletion(aSelection, startNode, startOffset, aAction, aCancel);
     if (NS_FAILED(res)) return res;
     if (*aCancel) return NS_OK;
 
-    res = mHTMLEditor->ExtendSelectionForDelete(aSelection, &aAction);
-    NS_ENSURE_SUCCESS(res, res);
-
     // We should delete nothing.
     if (aAction == nsIEditor::eNone)
       return NS_OK;
 
-    // ExtendSelectionForDelete() may have changed the selection, update it
-    res = mHTMLEditor->GetStartNodeAndOffset(aSelection, address_of(startNode), &startOffset);
-    if (NS_FAILED(res)) return res;
-    if (!startNode) return NS_ERROR_FAILURE;
-    
-    res = aSelection->GetIsCollapsed(&bCollapsed);
-    if (NS_FAILED(res)) return res;
-  }
-
-  if (bCollapsed)
-  {
     // what's in the direction we are deleting?
     nsWSRunObject wsObj(mHTMLEditor, startNode, startOffset);
     nsCOMPtr<nsIDOMNode> visNode;
     PRInt32 visOffset;
     PRInt16 wsType;
 
     // find next visible node
     if (aAction == nsIEditor::eNext)
@@ -2005,34 +1991,35 @@ nsHTMLEditRules::WillDeleteSelection(nsI
       if (aAction == nsIEditor::ePrevious) 
       { 
         if (so == 0) return NS_ERROR_UNEXPECTED;
         so--; 
         eo--; 
       }
       else
       {
+        res = mHTMLEditor->ExtendSelectionForDelete(aSelection, &aAction);
+        NS_ENSURE_SUCCESS(res, res);
+
         nsCOMPtr<nsIDOMRange> range;
         res = aSelection->GetRangeAt(0, getter_AddRefs(range));
         NS_ENSURE_SUCCESS(res, res);
 
 #ifdef DEBUG
         nsIDOMNode *container;
 
         res = range->GetStartContainer(&container);
         NS_ENSURE_SUCCESS(res, res);
         NS_ASSERTION(container == visNode, "selection start not in visNode");
 
         res = range->GetEndContainer(&container);
         NS_ENSURE_SUCCESS(res, res);
         NS_ASSERTION(container == visNode, "selection end not in visNode");
 #endif
 
-        res = range->GetStartOffset(&so);
-        NS_ENSURE_SUCCESS(res, res);
         res = range->GetEndOffset(&eo);
         NS_ENSURE_SUCCESS(res, res);
       }
       res = nsWSRunObject::PrepareToDeleteRange(mHTMLEditor, address_of(visNode), &so, address_of(visNode), &eo);
       if (NS_FAILED(res)) return res;
       nsCOMPtr<nsIDOMCharacterData> nodeAsText(do_QueryInterface(visNode));
       res = mHTMLEditor->DeleteText(nodeAsText, PR_MIN(so, eo), PR_ABS(eo - so));
       *aHandled = PR_TRUE;
--- a/layout/generic/test/test_backspace_delete.html
+++ b/layout/generic/test/test_backspace_delete.html
@@ -45,18 +45,16 @@ function restoreEatSpace() {
 }
 
 function test() {
   netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
 
   var wordSelModifiers =
       (navigator.platform.indexOf("Mac") >= 0) ?
         {shiftKey:true, altKey:true} : {shiftKey:true, ctrlKey:true};
-  var wordModifiers =
-      (navigator.platform.indexOf("Mac") >= 0) ? {altKey:true} : {ctrlKey:true};
   var sel = window.getSelection();
   var editor = document.getElementById("editor");
 
   function testRight(node, offset) {
     synthesizeKey("VK_RIGHT", {});
     is(sel.anchorNode, node, "Right movement broken in \"" + editor.innerHTML + "\"");
     is(sel.anchorOffset, offset, "Right movement broken in \"" + editor.innerHTML + "\"");
   }
@@ -83,28 +81,16 @@ function test() {
 
   function testBackspace(node, offset, text) {
     synthesizeKey("VK_BACK_SPACE", {});
     is(sel.anchorNode, node, "Backspace broken in \"" + editor.innerHTML + "\"");
     is(sel.anchorOffset, offset, "Backspace broken in \"" + editor.innerHTML + "\"");
     is(editor.textContent, text, "Backspace broken in \"" + editor.innerHTML + "\"");
   }
 
-  function testDeletePrevWord(node, offset, text) {
-    synthesizeKey("VK_BACK_SPACE", wordModifiers);
-    is(sel.anchorNode, node, "Delete previous word broken in \"" + editor.innerHTML + "\"");
-    is(sel.anchorOffset, offset, "Delete previous word broken in \"" + editor.innerHTML + "\"");
-  }
-
-  function testDeleteNextWord(node, offset, text) {
-    synthesizeKey("VK_DELETE", wordModifiers);
-    is(sel.anchorNode, node, "Delete next word broken in \"" + editor.innerHTML + "\"");
-    is(sel.anchorOffset, offset, "Delete next word broken in \"" + editor.innerHTML + "\"");
-  }
-
   // Test cell-wise deletion of Delete
   editor.innerHTML = "สวัสดีพ่อแม่พี่น้อง";
   sel.collapse(editor.firstChild, 0);
   testRight(editor.firstChild, 1);
   testDelete(editor.firstChild, 1, "สสดีพ่อแม่พี่น้อง");
   testRight(editor.firstChild, 2);
   testDelete(editor.firstChild, 2, "สสพ่อแม่พี่น้อง");
   testRight(editor.firstChild, 4);
@@ -178,36 +164,16 @@ function test() {
 
   // Tests for Bug 419406
 
   editor.innerHTML = "helloשלום";
   sel.collapse(editor.firstChild, 4);
   testRight(editor.firstChild, 5);
   testDelete(editor.firstChild, 5, "helloשלום");
 
-  // Tests for Bug 462188
-
-  editor.innerHTML = "You should not see this text.";
-  sel.collapse(editor.firstChild, 29);
-  testDeletePrevWord(editor.firstChild, 24, "You should not see this ");
-  testDeletePrevWord(editor.firstChild, 19, "You should not see ");
-  testDeletePrevWord(editor.firstChild, 15, "You should not ");
-  testDeletePrevWord(editor.firstChild, 11, "You should ");
-  testDeletePrevWord(editor.firstChild,  4, "You ");
-  testDeletePrevWord(editor,  0, "");
-
-  editor.innerHTML = "You should not see this text.";
-  sel.collapse(editor.firstChild, 0);
-  testDeleteNextWord(editor.firstChild, 0, " should not see this text.");
-  testDeleteNextWord(editor.firstChild, 0, " not see this text.");
-  testDeleteNextWord(editor.firstChild, 0, " see this text.");
-  testDeleteNextWord(editor.firstChild, 0, " this text.");
-  testDeleteNextWord(editor.firstChild, 0, " text.");
-  testDeleteNextWord(editor, 0, "");
-
   SimpleTest.finish();
 }
 
 
 </script>
 </pre>
 </body>
 </html>