Bug 738440 - Support queryCommandState("stylewithcss"); r=ehsan

This commit is contained in:
Aryeh Gregor 2012-03-23 15:03:42 -04:00
Родитель 6bd0728a3b
Коммит 770ebbde43
5 изменённых файлов: 49 добавлений и 3 удалений

Просмотреть файл

@ -90,7 +90,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
["removeformat", "exception"],
["selectall", "exception"],
["strikethrough", "false"],
["styleWithCSS", "exception"],
["styleWithCSS", "false"],
["subscript", "false"],
["superscript", "false"],
["underline", "false"],
@ -130,7 +130,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
["removeformat", ""],
["selectall", ""],
["strikethrough", ""],
["styleWithCSS", "exception"],
["styleWithCSS", ""],
["subscript", ""],
["superscript", ""],
["underline", ""],

Просмотреть файл

@ -3233,6 +3233,13 @@ nsHTMLDocument::QueryCommandState(const nsAString & commandID, bool *_retval)
if (!window)
return NS_ERROR_FAILURE;
if (commandID.LowerCaseEqualsLiteral("usecss")) {
// Per spec, state is supported for styleWithCSS but not useCSS, so we just
// return false always.
*_retval = false;
return NS_OK;
}
nsCAutoString cmdToDispatch, paramToCheck;
bool dummy, dummy2;
if (!ConvertToMidasInternalCommand(commandID, commandID,

Просмотреть файл

@ -63,6 +63,7 @@
//defines
#define STATE_ENABLED "state_enabled"
#define STATE_ALL "state_all"
#define STATE_ATTRIBUTE "state_attribute"
#define STATE_DATA "state_data"
@ -378,7 +379,7 @@ nsSetDocumentStateCommand::GetCommandStateParams(const char *aCommandName,
bool isCSS;
htmleditor->GetIsCSSEnabled(&isCSS);
return aParams->SetBooleanValue(STATE_ATTRIBUTE, isCSS);
return aParams->SetBooleanValue(STATE_ALL, isCSS);
}
if (!nsCRT::strcmp(aCommandName, "cmd_insertBrOnReturn"))

Просмотреть файл

@ -50,6 +50,7 @@ _TEST_FILES = \
test_bug389350.html \
test_bug519928.html \
bug678842_subframe.html \
test_bug738440.html \
$(NULL)
_CHROME_TEST_FILES = \

Просмотреть файл

@ -0,0 +1,37 @@
<!doctype html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=738440
-->
<title>Test for Bug 738440</title>
<script src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" href="/tests/SimpleTest/test.css" />
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=738440">Mozilla Bug 738440</a>
<div contenteditable></div>
<script>
/** Test for Bug 738440 **/
document.execCommand("stylewithcss", false, "true");
is(document.queryCommandState("stylewithcss"), true,
"setting stylewithcss to true should cause its state to be true");
is(document.queryCommandState("usecss"), false,
"usecss state should always be false");
document.execCommand("stylewithcss", false, "false");
is(document.queryCommandState("stylewithcss"), false,
"setting stylewithcss to false should cause its state to be false");
is(document.queryCommandState("usecss"), false,
"usecss state should always be false");
document.execCommand("usecss", false, "true");
is(document.queryCommandState("stylewithcss"), false,
"setting usecss to true should cause stylewithcss state to be false");
is(document.queryCommandState("usecss"), false,
"usecss state should always be false");
document.execCommand("usecss", false, "false");
is(document.queryCommandState("stylewithcss"), true,
"setting usecss to false should cause stylewithcss state to be true");
is(document.queryCommandState("usecss"), false,
"usecss state should always be false");
</script>