diff --git a/editor/libeditor/html/nsHTMLEditRules.cpp b/editor/libeditor/html/nsHTMLEditRules.cpp index 482b4f3905db..d71fbacafcd9 100644 --- a/editor/libeditor/html/nsHTMLEditRules.cpp +++ b/editor/libeditor/html/nsHTMLEditRules.cpp @@ -1948,24 +1948,10 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection, 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 visNode; @@ -2010,6 +1996,9 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection, } else { + res = mHTMLEditor->ExtendSelectionForDelete(aSelection, &aAction); + NS_ENSURE_SUCCESS(res, res); + nsCOMPtr range; res = aSelection->GetRangeAt(0, getter_AddRefs(range)); NS_ENSURE_SUCCESS(res, res); @@ -2026,8 +2015,6 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection, 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); } diff --git a/layout/generic/test/test_backspace_delete.html b/layout/generic/test/test_backspace_delete.html index 84b72de1c680..ef2a9c3d8c39 100644 --- a/layout/generic/test/test_backspace_delete.html +++ b/layout/generic/test/test_backspace_delete.html @@ -50,8 +50,6 @@ function test() { 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"); @@ -88,18 +86,6 @@ function test() { 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); @@ -183,26 +169,6 @@ function test() { 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(); }