зеркало из https://github.com/mozilla/gecko-dev.git
Backout Bug 507936, Due to test failures. roc claimed to have done it already but I don't see it
This commit is contained in:
Родитель
21e79119b6
Коммит
527c629d8a
|
@ -1919,17 +1919,10 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection,
|
|||
nsresult res = NS_OK;
|
||||
PRBool bPlaintext = mFlags & nsIPlaintextEditor::eEditorPlaintextMask;
|
||||
|
||||
PRBool bCollapsed, join = PR_FALSE;
|
||||
PRBool bCollapsed;
|
||||
res = aSelection->GetIsCollapsed(&bCollapsed);
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// origCollapsed is used later to determine whether we should join
|
||||
// blocks. We don't really care about bCollapsed because it will be
|
||||
// modified by ExtendSelectionForDelete later. JoinBlocks should
|
||||
// happen if the original selection is collapsed and the cursor is
|
||||
// at the end of a block element, in which case ExtendSelectionForDelete
|
||||
// would always make the selection not collapsed.
|
||||
PRBool origCollapsed = bCollapsed;
|
||||
|
||||
nsCOMPtr<nsIDOMNode> startNode, selNode;
|
||||
PRInt32 startOffset, selOffset;
|
||||
|
||||
|
@ -2473,8 +2466,6 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection,
|
|||
if (NS_FAILED(res)) return res;
|
||||
if (!enumerator) return NS_ERROR_UNEXPECTED;
|
||||
|
||||
join = PR_TRUE;
|
||||
|
||||
for (enumerator->First(); NS_OK!=enumerator->IsDone(); enumerator->Next())
|
||||
{
|
||||
nsCOMPtr<nsISupports> currentItem;
|
||||
|
@ -2501,17 +2492,6 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection,
|
|||
nsIDOMNode* somenode = arrayOfNodes[0];
|
||||
res = DeleteNonTableElements(somenode);
|
||||
arrayOfNodes.RemoveObjectAt(0);
|
||||
// If something visible is deleted, no need to join.
|
||||
// Visible means all nodes except non-visible textnodes and breaks.
|
||||
if (join && origCollapsed) {
|
||||
if (mHTMLEditor->IsTextNode(somenode)) {
|
||||
mHTMLEditor->IsVisTextNode(somenode, &join, PR_TRUE);
|
||||
}
|
||||
else {
|
||||
join = nsTextEditUtils::IsBreak(somenode) &&
|
||||
!mHTMLEditor->IsVisBreak(somenode);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2545,6 +2525,14 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection,
|
|||
}
|
||||
}
|
||||
|
||||
PRBool join = leftBlockParent == rightBlockParent;
|
||||
if (!join) {
|
||||
nsCOMPtr<nsINode> parent1 = do_QueryInterface(leftParent);
|
||||
nsCOMPtr<nsINode> parent2 = do_QueryInterface(rightParent);
|
||||
PRUint16 pos = nsContentUtils::ComparePosition(parent1, parent2);
|
||||
join = (pos & (nsIDOM3Node::DOCUMENT_POSITION_CONTAINS |
|
||||
nsIDOM3Node::DOCUMENT_POSITION_CONTAINED_BY)) != 0;
|
||||
}
|
||||
if (join) {
|
||||
res = JoinBlocks(address_of(leftParent), address_of(rightParent),
|
||||
aCancel);
|
||||
|
@ -2553,15 +2541,7 @@ nsHTMLEditRules::WillDeleteSelection(nsISelection *aSelection,
|
|||
}
|
||||
}
|
||||
}
|
||||
//If we're joining blocks: if deleting forward the selection should be
|
||||
//collapsed to the end of the selection, if deleting backward the selection
|
||||
//should be collapsed to the beginning of the selection. But if we're not
|
||||
//joining then the selection should collapse to the beginning of the
|
||||
//selection if we'redeleting forward, because the end of the selection will
|
||||
//still be in the next block. And same thing for deleting backwards
|
||||
//(selection should collapse to the end, because the beginning will still
|
||||
//be in the first block). See Bug 507936
|
||||
if (join ? aAction == nsIEditor::eNext : aAction == nsIEditor::ePrevious)
|
||||
if (aAction == nsIEditor::eNext)
|
||||
{
|
||||
res = aSelection->Collapse(endNode,endOffset);
|
||||
}
|
||||
|
|
|
@ -19,18 +19,14 @@ function execTests() {
|
|||
var sel = win.getSelection();
|
||||
win.focus();
|
||||
|
||||
function setupTest(html, firstChildOffsetForCaret, node) {
|
||||
function setupTest(html, firstChildOffsetForCaret) {
|
||||
// Work around bug 474255 --- we need to have nonempty content before we turn on
|
||||
// editing, or the tests below break because the editor doesn't notice when we
|
||||
// insert non-empty content using innerHTML.
|
||||
doc.designMode = 'off';
|
||||
editor.innerHTML = html;
|
||||
doc.designMode = 'on';
|
||||
var n = editor.firstChild;
|
||||
if (node) {
|
||||
n = node();
|
||||
}
|
||||
sel.collapse(n, firstChildOffsetForCaret);
|
||||
sel.collapse(editor.firstChild, firstChildOffsetForCaret);
|
||||
}
|
||||
|
||||
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
|
||||
|
@ -114,7 +110,7 @@ function execTests() {
|
|||
var msg = "Delete next word broken in \"" + editor.innerHTML + "\", offset " + offset;
|
||||
is(sel.anchorNode, node, msg);
|
||||
is(sel.anchorOffset, offset, msg);
|
||||
is(editor.textContent, text, msg);
|
||||
todo_is(editor.textContent, text, msg);
|
||||
}
|
||||
|
||||
// Test cell-wise deletion of Delete
|
||||
|
@ -204,58 +200,17 @@ function execTests() {
|
|||
testDeletePrevWord(editor, 0, "");
|
||||
|
||||
setupTest("You should not see this text.", 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.firstChild, 0, "\u00A0should not see this text.");
|
||||
testDeleteNextWord(editor.firstChild, 0, "\u00A0not see this text.");
|
||||
testDeleteNextWord(editor.firstChild, 0, "\u00A0see this text.");
|
||||
testDeleteNextWord(editor.firstChild, 0, "\u00A0this text.");
|
||||
testDeleteNextWord(editor.firstChild, 0, "\u00A0text.");
|
||||
// testDeleteNextWord(editor, 0, "");
|
||||
|
||||
// Tests for Bug 502259
|
||||
setupTest("<p>Bug</p>\n<p>502259</p>", 1);
|
||||
testDelete(function(){return editor.firstChild.firstChild;}, 3, "<p>Bug502259</p>", true);
|
||||
|
||||
// Tests for Bug 507936
|
||||
var nodecallback = function(){return editor.firstChild.firstChild.lastChild.firstChild.lastChild;};
|
||||
setupTest("<ol><li>one<ol><li>two</li></ol></li></ol>\n<p>three</p>", 3, nodecallback);
|
||||
testDelete(nodecallback, 0, "<ol><li>one<ol><li>twothree</li></ol></li></ol>", true);
|
||||
|
||||
setupTest("<ol><li>one<ol><li>two</li></ol></li></ol>\n<hr>\n<p>three</p>", 3, nodecallback);
|
||||
testDelete(nodecallback, 3,
|
||||
"<ol><li>one<ol><li>two</li></ol></li></ol><p>three</p>", true);
|
||||
|
||||
// Tests for Bug 519751
|
||||
var nodecallback = function(){return editor.firstChild.lastChild;};
|
||||
setupTest("<p>one</p><ol><li>two</li><li>three</li></ol>", 3, nodecallback);
|
||||
testDelete(nodecallback, 0, "<p>onetwo</p><ol><li>three</li></ol>", true);
|
||||
|
||||
nodecallback = function(){return editor.firstChild.childNodes[1].firstChild;};
|
||||
setupTest("<ol><li>one</li><li>two</li></ol><ol><li>three</li><li>four</li></ol>", 3, nodecallback);
|
||||
testDelete(function(){return editor.firstChild.childNodes[2].firstChild;},
|
||||
0, "<ol><li>one</li><li>two</li><li>three</li><li>four</li></ol>", true);
|
||||
/*todo_is(false, true, 'The above testDelete should use the same nodecallback' +
|
||||
'as in the proceeding setupTest: the cursor should stay at the end of "two", while currently it is at the beginning of "three" after delete');*/
|
||||
|
||||
// More Tests for Bug 507936
|
||||
nodecallback = function(){return editor.firstChild.firstChild.firstChild;}
|
||||
setupTest("<div><div>abcdef</div><div>bar</div><div>ghi</div></div>", 5, nodecallback);
|
||||
sel.extend(editor.lastChild.lastChild.lastChild, 1);
|
||||
testDelete(editor.lastChild.lastChild.lastChild, 5, "<div><div>abcdehi</div></div>", true);
|
||||
|
||||
setupTest("<div><div>abcdef</div><div>ghi</div></div>", 5, nodecallback);
|
||||
sel.extend(editor.lastChild.lastChild.lastChild, 1);
|
||||
testDelete(editor.lastChild.lastChild.lastChild, 5, "<div><div>abcdehi</div></div>", true);
|
||||
|
||||
nodecallback = function(){return editor.firstChild.firstChild;}
|
||||
setupTest("<div>abcdef<div><div>bar</div>ghi</div></div>", 5, nodecallback);
|
||||
sel.extend(editor.lastChild.lastChild.lastChild, 1);
|
||||
expectednodecallback = function(){return editor.lastChild.lastChild;}
|
||||
testDelete(expectednodecallback, 0, "<div>abcdehi</div>", true);
|
||||
|
||||
setupTest("<div>abcdef<div>ghi</div></div>", 5, nodecallback);
|
||||
sel.extend(editor.lastChild.lastChild.lastChild, 1);
|
||||
testDelete(expectednodecallback, 0, "<div>abcdehi</div>", true);
|
||||
|
||||
SimpleTest.finish();
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче