зеркало из https://github.com/mozilla/gecko-dev.git
Bug 742240 - Handle unsupported commands per spec in execCommand/queryCommand*; r=ehsan
This commit is contained in:
Родитель
1b562164d1
Коммит
e8bb3212b3
|
@ -3086,6 +3086,15 @@ nsHTMLDocument::ExecCommand(const nsAString & commandID,
|
|||
|
||||
*_retval = false;
|
||||
|
||||
nsCAutoString cmdToDispatch, paramStr;
|
||||
bool isBool, boolVal;
|
||||
if (!ConvertToMidasInternalCommand(commandID, value,
|
||||
cmdToDispatch, paramStr,
|
||||
isBool, boolVal)) {
|
||||
// Return false
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if editing is not on, bail
|
||||
if (!IsEditingOnAfterFlush())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -3119,12 +3128,6 @@ nsHTMLDocument::ExecCommand(const nsAString & commandID,
|
|||
if (!window)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCAutoString cmdToDispatch, paramStr;
|
||||
bool isBool, boolVal;
|
||||
if (!ConvertToMidasInternalCommand(commandID, value,
|
||||
cmdToDispatch, paramStr, isBool, boolVal))
|
||||
return NS_OK;
|
||||
|
||||
if ((cmdToDispatch.EqualsLiteral("cmd_paragraphState") ||
|
||||
cmdToDispatch.EqualsLiteral("cmd_fontSize")) && paramStr.IsEmpty()) {
|
||||
// Invalid value
|
||||
|
@ -3166,6 +3169,12 @@ nsHTMLDocument::QueryCommandEnabled(const nsAString & commandID,
|
|||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = false;
|
||||
|
||||
nsCAutoString cmdToDispatch;
|
||||
if (!ConvertToMidasInternalCommand(commandID, cmdToDispatch)) {
|
||||
// Return false
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if editing is not on, bail
|
||||
if (!IsEditingOnAfterFlush())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -3180,10 +3189,6 @@ nsHTMLDocument::QueryCommandEnabled(const nsAString & commandID,
|
|||
if (!window)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCAutoString cmdToDispatch;
|
||||
if (!ConvertToMidasInternalCommand(commandID, cmdToDispatch))
|
||||
return NS_OK; // queryCommandEnabled returns false on unsupported commands
|
||||
|
||||
return cmdMgr->IsCommandEnabled(cmdToDispatch.get(), window, _retval);
|
||||
}
|
||||
|
||||
|
@ -3195,6 +3200,12 @@ nsHTMLDocument::QueryCommandIndeterm(const nsAString & commandID,
|
|||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = false;
|
||||
|
||||
nsCAutoString cmdToDispatch;
|
||||
if (!ConvertToMidasInternalCommand(commandID, cmdToDispatch)) {
|
||||
// Return false
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if editing is not on, bail
|
||||
if (!IsEditingOnAfterFlush())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -3209,10 +3220,6 @@ nsHTMLDocument::QueryCommandIndeterm(const nsAString & commandID,
|
|||
if (!window)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCAutoString cmdToDispatch;
|
||||
if (!ConvertToMidasInternalCommand(commandID, cmdToDispatch))
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICommandParams> cmdParams = do_CreateInstance(
|
||||
NS_COMMAND_PARAMS_CONTRACTID, &rv);
|
||||
|
@ -3236,6 +3243,15 @@ nsHTMLDocument::QueryCommandState(const nsAString & commandID, bool *_retval)
|
|||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = false;
|
||||
|
||||
nsCAutoString cmdToDispatch, paramToCheck;
|
||||
bool dummy, dummy2;
|
||||
if (!ConvertToMidasInternalCommand(commandID, commandID,
|
||||
cmdToDispatch, paramToCheck,
|
||||
dummy, dummy2)) {
|
||||
// Return false
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if editing is not on, bail
|
||||
if (!IsEditingOnAfterFlush())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -3257,12 +3273,6 @@ nsHTMLDocument::QueryCommandState(const nsAString & commandID, bool *_retval)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCAutoString cmdToDispatch, paramToCheck;
|
||||
bool dummy, dummy2;
|
||||
if (!ConvertToMidasInternalCommand(commandID, commandID,
|
||||
cmdToDispatch, paramToCheck, dummy, dummy2))
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICommandParams> cmdParams = do_CreateInstance(
|
||||
NS_COMMAND_PARAMS_CONTRACTID, &rv);
|
||||
|
@ -3303,22 +3313,10 @@ nsHTMLDocument::QueryCommandSupported(const nsAString & commandID,
|
|||
bool *_retval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(_retval);
|
||||
*_retval = false;
|
||||
|
||||
// if editing is not on, bail
|
||||
if (!IsEditingOnAfterFlush())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// get command manager
|
||||
nsCOMPtr<nsICommandManager> cmdMgr;
|
||||
GetMidasCommandManager(getter_AddRefs(cmdMgr));
|
||||
if (!cmdMgr)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
// commandID is supported if it can be converted to a Midas command
|
||||
nsCAutoString cmdToDispatch;
|
||||
if (ConvertToMidasInternalCommand(commandID, cmdToDispatch))
|
||||
*_retval = true;
|
||||
*_retval = ConvertToMidasInternalCommand(commandID, cmdToDispatch);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3330,6 +3328,12 @@ nsHTMLDocument::QueryCommandValue(const nsAString & commandID,
|
|||
{
|
||||
_retval.SetLength(0);
|
||||
|
||||
nsCAutoString cmdToDispatch, paramStr;
|
||||
if (!ConvertToMidasInternalCommand(commandID, cmdToDispatch)) {
|
||||
// Return empty string
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
// if editing is not on, bail
|
||||
if (!IsEditingOnAfterFlush())
|
||||
return NS_ERROR_FAILURE;
|
||||
|
@ -3344,10 +3348,6 @@ nsHTMLDocument::QueryCommandValue(const nsAString & commandID,
|
|||
if (!window)
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
nsCAutoString cmdToDispatch, paramStr;
|
||||
if (!ConvertToMidasInternalCommand(commandID, cmdToDispatch))
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
// create params
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsICommandParams> cmdParams = do_CreateInstance(
|
||||
|
|
|
@ -27649,6 +27649,11 @@ var browserTests = [
|
|||
"foo[bar]baz",
|
||||
[true],
|
||||
{"usecss":[false,false,"",false,false,""]}],
|
||||
["foo[bar]baz",
|
||||
[["quasit",""]],
|
||||
"foo[bar]baz",
|
||||
[false],
|
||||
{"quasit":[false,false,"",false,false,""]}],
|
||||
["foo[]bar",
|
||||
[["bold",""],["inserttext","a"]],
|
||||
"foo<b>a[]</b>bar",
|
||||
|
|
|
@ -4079,7 +4079,7 @@ var tests = {
|
|||
['falsé', 'foo[bar]baz'],
|
||||
],
|
||||
//@}
|
||||
quasit: ['!foo[bar]baz'],
|
||||
quasit: ['foo[bar]baz'],
|
||||
multitest: [
|
||||
//@{
|
||||
// Insertion-affecting state. Test that insertText works right, and
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -96,7 +96,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
|
|||
["underline", "false"],
|
||||
["undo", "false"],
|
||||
["unlink", "false"],
|
||||
["not-a-command", "NS_ERROR_NOT_IMPLEMENTED"]
|
||||
["not-a-command", "false"]
|
||||
];
|
||||
|
||||
var commandStateResults = [
|
||||
|
@ -136,7 +136,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
|
|||
["underline", "false"],
|
||||
["undo", "false"],
|
||||
["unlink", "false"],
|
||||
["not-a-command", "NS_ERROR_NOT_IMPLEMENTED"]
|
||||
["not-a-command", "false"]
|
||||
];
|
||||
|
||||
var commandValueResults = [
|
||||
|
@ -176,7 +176,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=408231
|
|||
["underline", ""],
|
||||
["undo", ""],
|
||||
["unlink", ""],
|
||||
["not-a-command", "NS_ERROR_NOT_IMPLEMENTED"],
|
||||
["not-a-command", ""],
|
||||
];
|
||||
|
||||
|
||||
|
|
|
@ -414,27 +414,6 @@ const knownFailures = {
|
|||
"QE-Proposed-UNBOOKMARK_TEXT-1-dM": true,
|
||||
"QE-Proposed-UNBOOKMARK_TEXT-1-body": true,
|
||||
"QE-Proposed-UNBOOKMARK_TEXT-1-div": true,
|
||||
"QI-Proposed-UNSELECT_TEXT-1-dM": true,
|
||||
"QI-Proposed-UNSELECT_TEXT-1-body": true,
|
||||
"QI-Proposed-UNSELECT_TEXT-1-div": true,
|
||||
"QI-Proposed-INSERTLINEBREAK_TEXT-1-dM": true,
|
||||
"QI-Proposed-INSERTLINEBREAK_TEXT-1-body": true,
|
||||
"QI-Proposed-INSERTLINEBREAK_TEXT-1-div": true,
|
||||
"QI-Proposed-INSERTTEXT_TEXT-1-dM": true,
|
||||
"QI-Proposed-INSERTTEXT_TEXT-1-body": true,
|
||||
"QI-Proposed-INSERTTEXT_TEXT-1-div": true,
|
||||
"QI-Proposed-FORWARDDELETE_TEXT-1-dM": true,
|
||||
"QI-Proposed-FORWARDDELETE_TEXT-1-body": true,
|
||||
"QI-Proposed-FORWARDDELETE_TEXT-1-div": true,
|
||||
"QI-Proposed-CREATEBOOKMARK_TEXT-1-dM": true,
|
||||
"QI-Proposed-CREATEBOOKMARK_TEXT-1-body": true,
|
||||
"QI-Proposed-CREATEBOOKMARK_TEXT-1-div": true,
|
||||
"QI-Proposed-UNBOOKMARK_TEXT-1-dM": true,
|
||||
"QI-Proposed-UNBOOKMARK_TEXT-1-body": true,
|
||||
"QI-Proposed-UNBOOKMARK_TEXT-1-div": true,
|
||||
"QI-Proposed-garbage-1_TEXT-1-dM": true,
|
||||
"QI-Proposed-garbage-1_TEXT-1-body": true,
|
||||
"QI-Proposed-garbage-1_TEXT-1-div": true,
|
||||
"QS-Proposed-SUB_SPAN.sub-1-SI-dM": true,
|
||||
"QS-Proposed-SUB_SPAN.sub-1-SI-body": true,
|
||||
"QS-Proposed-SUB_SPAN.sub-1-SI-div": true,
|
||||
|
|
Загрузка…
Ссылка в новой задаче