зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1250805 - Respect type-in state when caching inline styles; r=masayuki
MozReview-Commit-ID: OZCUbNUvmz
This commit is contained in:
Родитель
9a8de4b899
Коммит
f5cce8463c
|
@ -6969,6 +6969,17 @@ HTMLEditRules::CacheInlineStyles(nsIDOMNode* aNode)
|
|||
|
||||
for (int32_t j = 0; j < SIZE_STYLE_TABLE; ++j)
|
||||
{
|
||||
// If type-in state is set, don't intervene
|
||||
bool typeInSet, unused;
|
||||
if (NS_WARN_IF(!mHTMLEditor)) {
|
||||
return NS_ERROR_UNEXPECTED;
|
||||
}
|
||||
mHTMLEditor->mTypeInState->GetTypingState(typeInSet, unused,
|
||||
mCachedStyles[j].tag, mCachedStyles[j].attr, nullptr);
|
||||
if (typeInSet) {
|
||||
continue;
|
||||
}
|
||||
|
||||
bool isSet = false;
|
||||
nsAutoString outValue;
|
||||
// Don't use CSS for <font size>, we don't support it usefully (bug 780035)
|
||||
|
|
|
@ -37664,6 +37664,12 @@
|
|||
"url": "/domparsing/style_attribute_html.html"
|
||||
}
|
||||
],
|
||||
"editing/other/restoration.html": [
|
||||
{
|
||||
"path": "editing/other/restoration.html",
|
||||
"url": "/editing/other/restoration.html"
|
||||
}
|
||||
],
|
||||
"editing/other/delete.html": [
|
||||
{
|
||||
"path": "editing/other/delete.html",
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset=utf-8>
|
||||
<title>Restoration of style tests</title>
|
||||
<!--
|
||||
No spec, based on: https://bugzilla.mozilla.org/show_bug.cgi?id=1250805
|
||||
If the user presses Ctrl+B and then hits Enter and then types text, the text
|
||||
should still be bold. Hitting Enter shouldn't make it forget. And so too for
|
||||
other commands.
|
||||
-->
|
||||
<script src=/resources/testharness.js></script>
|
||||
<script src=/resources/testharnessreport.js></script>
|
||||
<div contenteditable></div>
|
||||
<script>
|
||||
var div = document.querySelector("div");
|
||||
|
||||
function doTestInner(cmd, param, startBold) {
|
||||
div.innerHTML = startBold ? "<b>foo</b>bar" : "foobar";
|
||||
getSelection().collapse(startBold ? div.firstChild.firstChild
|
||||
: div.firstChild, 3);
|
||||
|
||||
// Set/unset bold, then run command and see if it's still there
|
||||
assert_true(document.execCommand("bold", false, ""),
|
||||
"execCommand needs to return true for bold");
|
||||
|
||||
assert_true(document.execCommand(cmd, false, param),
|
||||
"execCommand needs to return true for " + cmd + " " + param);
|
||||
|
||||
assert_equals(document.queryCommandState("bold"), !startBold,
|
||||
"bold state");
|
||||
|
||||
assert_true(document.execCommand("inserttext", false, "x"),
|
||||
"execCommand needs to return true for inserttext x");
|
||||
|
||||
// Find the new text node and check that it's actually bold (or not)
|
||||
var node = div;
|
||||
while (node) {
|
||||
if (node.nodeType == Node.TEXT_NODE && node.nodeValue.indexOf("x") != -1) {
|
||||
assert_in_array(getComputedStyle(node.parentNode).fontWeight,
|
||||
!startBold ? ["700", "bold"] : ["400", "normal"],
|
||||
"font-weight");
|
||||
return;
|
||||
}
|
||||
if (node.firstChild) {
|
||||
node = node.firstChild;
|
||||
continue;
|
||||
}
|
||||
while (node != div && !node.nextSibling) {
|
||||
node = node.parentNode;
|
||||
}
|
||||
if (node == div) {
|
||||
assert_unreached("x not found!");
|
||||
break;
|
||||
}
|
||||
node = node.nextSibling;
|
||||
}
|
||||
}
|
||||
|
||||
function doTest(cmd, param) {
|
||||
if (param === undefined) {
|
||||
param = "";
|
||||
}
|
||||
|
||||
test(function() {
|
||||
doTestInner(cmd, param, true);
|
||||
}, cmd + " " + param + " starting bold");
|
||||
|
||||
test(function() {
|
||||
doTestInner(cmd, param, false);
|
||||
}, cmd + " " + param + " starting not bold");
|
||||
}
|
||||
|
||||
doTest("insertparagraph");
|
||||
doTest("insertlinebreak");
|
||||
doTest("delete");
|
||||
doTest("forwarddelete");
|
||||
doTest("insertorderedlist");
|
||||
doTest("insertunorderedlist");
|
||||
doTest("indent");
|
||||
// Outdent does nothing here, but should be harmless.
|
||||
doTest("outdent");
|
||||
doTest("justifyleft");
|
||||
doTest("justifyright");
|
||||
doTest("justifycenter");
|
||||
doTest("justifyfull");
|
||||
doTest("formatblock", "div");
|
||||
doTest("formatblock", "blockquote");
|
||||
doTest("inserthorizontalrule");
|
||||
doTest("insertimage", "a");
|
||||
doTest("inserttext", "bar");
|
||||
</script>
|
Загрузка…
Ссылка в новой задаче