зеркало из https://github.com/mozilla/gecko-dev.git
Bug 551704 - Part 4: Set the selection to the beginning of the document when we're entering the design mode; r=bzbarsky a=blocking-betaN+
This commit is contained in:
Родитель
45318ab728
Коммит
f576d21989
|
@ -3278,6 +3278,13 @@ nsHTMLDocument::EditingStateChanged()
|
|||
nsCOMPtr<nsIPresShell> presShell = GetShell();
|
||||
NS_ENSURE_TRUE(presShell, NS_ERROR_FAILURE);
|
||||
|
||||
// If we're entering the design mode, put the selection at the beginning of
|
||||
// the document for compatibility reasons.
|
||||
if (designMode) {
|
||||
rv = editor->BeginningOfDocument();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMArray<nsIStyleSheet> agentSheets;
|
||||
rv = presShell->GetAgentStyleSheets(agentSheets);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
|
|
@ -77,6 +77,25 @@ SimpleTest.waitForFocus(function() {
|
|||
var preformatted = document.getElementById("preformatted");
|
||||
is(preformatted.innerHTML, "a\nb", "No BR node should be injected for preformatted editable fields");
|
||||
|
||||
var iframe = document.createElement("iframe");
|
||||
iframe.addEventListener("load", function() {
|
||||
var sel = iframe.contentWindow.getSelection();
|
||||
is(sel.rangeCount, 0, "There should be no range in the selection initially");
|
||||
iframe.contentDocument.designMode = "on";
|
||||
sel = iframe.contentWindow.getSelection();
|
||||
is(sel.rangeCount, 1, "There should be a single range in the selection after setting designMode");
|
||||
var range = sel.getRangeAt(0);
|
||||
ok(range.collapsed, "The range should be collapsed");
|
||||
is(range.startContainer, iframe.contentDocument.body.firstChild, "The range should start on the text");
|
||||
is(range.startOffset, 0, "The start offset should be zero");
|
||||
|
||||
continueTest();
|
||||
}, false);
|
||||
iframe.src = "data:text/html,foo";
|
||||
document.getElementById("content").appendChild(iframe);
|
||||
});
|
||||
|
||||
function continueTest() {
|
||||
var divs = [];
|
||||
for (var i = 0; i < 8; ++i) {
|
||||
divs[i] = document.getElementById("test" + (i+1));
|
||||
|
@ -99,7 +118,7 @@ SimpleTest.waitForFocus(function() {
|
|||
}
|
||||
|
||||
doNextTest();
|
||||
});
|
||||
}
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
|
|
Загрузка…
Ссылка в новой задаче