зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1706268 - Add telemetry probes to collect usage of `Document.execCommand` etc with Gecko-specific commands r=smaug, data-review=travis_
Currently, `increasefontsize`, `decreasefontsize`, `gethtml`, `heading`, `contentReadOnly`, `readonly` and `insertBrOnReturn` commands are supported only by Gecko. So, if nobody uses some or all of them, we can drop the unused commands. For saving the space of `Document.mUseCounters`, this patch groups `Document.queryCommandState` and `Document.queryCommandValue` because they are both getter of the command. The difference is not important. And also this patch groups `Document.queryCommandSupported` and `Document.queryCommandEnabled` because they may be used for feature detection and the difference is not important. Differential Revision: https://phabricator.services.mozilla.com/D118956
This commit is contained in:
Родитель
9b0d666eda
Коммит
d9481b8a6a
|
@ -5180,12 +5180,31 @@ bool Document::ExecCommand(const nsAString& aHTMLCommandName, bool aShowUI,
|
|||
nsAutoString adjustedValue;
|
||||
InternalCommandData commandData =
|
||||
ConvertToInternalCommand(aHTMLCommandName, aValue, &adjustedValue);
|
||||
if (commandData.mCommand == Command::DoNothing) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (commandData.mCommand == Command::GetHTML) {
|
||||
return false;
|
||||
switch (commandData.mCommand) {
|
||||
case Command::DoNothing:
|
||||
// "gethtml" command is a command to retrieve a string value, not executing
|
||||
// anything and not enough the `bool` value of `execCommand`. So, at here,
|
||||
// we do nothing for "gethtml" command.
|
||||
case Command::GetHTML:
|
||||
return false;
|
||||
case Command::FormatIncreaseFontSize:
|
||||
SetUseCounter(eUseCounter_custom_DocumentExecCommandIncreaseFontSize);
|
||||
break;
|
||||
case Command::FormatDecreaseFontSize:
|
||||
SetUseCounter(eUseCounter_custom_DocumentExecCommandDecreaseFontSize);
|
||||
break;
|
||||
case Command::FormatBlock:
|
||||
if (aHTMLCommandName.LowerCaseEqualsLiteral("heading")) {
|
||||
SetUseCounter(eUseCounter_custom_DocumentExecCommandHeading);
|
||||
}
|
||||
break;
|
||||
case Command::SetDocumentReadOnly:
|
||||
SetUseCounter(aHTMLCommandName.LowerCaseEqualsLiteral("contentreadonly")
|
||||
? eUseCounter_custom_DocumentExecCommandContentReadOnly
|
||||
: eUseCounter_custom_DocumentExecCommandReadOnly);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Do security check first.
|
||||
|
@ -5344,8 +5363,39 @@ bool Document::QueryCommandEnabled(const nsAString& aHTMLCommandName,
|
|||
// Otherwise, don't throw exception for compatibility with Chrome.
|
||||
|
||||
InternalCommandData commandData = ConvertToInternalCommand(aHTMLCommandName);
|
||||
if (commandData.mCommand == Command::DoNothing) {
|
||||
return false;
|
||||
switch (commandData.mCommand) {
|
||||
case Command::DoNothing:
|
||||
return false;
|
||||
case Command::FormatIncreaseFontSize:
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledIncreaseFontSize);
|
||||
break;
|
||||
case Command::FormatDecreaseFontSize:
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledDecreaseFontSize);
|
||||
break;
|
||||
case Command::GetHTML:
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledGetHTML);
|
||||
break;
|
||||
case Command::FormatBlock:
|
||||
if (aHTMLCommandName.LowerCaseEqualsLiteral("heading")) {
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledHeading);
|
||||
}
|
||||
break;
|
||||
case Command::SetDocumentReadOnly:
|
||||
SetUseCounter(
|
||||
aHTMLCommandName.LowerCaseEqualsLiteral("contentreadonly")
|
||||
? eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledContentReadOnly
|
||||
: eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledReadOnly);
|
||||
break;
|
||||
case Command::SetDocumentInsertBROnEnterKeyPress:
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledInsertBrOnReturn);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// cut & copy are always allowed
|
||||
|
@ -5445,8 +5495,30 @@ bool Document::QueryCommandState(const nsAString& aHTMLCommandName,
|
|||
// Otherwise, don't throw exception for compatibility with Chrome.
|
||||
|
||||
InternalCommandData commandData = ConvertToInternalCommand(aHTMLCommandName);
|
||||
if (commandData.mCommand == Command::DoNothing) {
|
||||
return false;
|
||||
switch (commandData.mCommand) {
|
||||
case Command::DoNothing:
|
||||
return false;
|
||||
case Command::GetHTML:
|
||||
SetUseCounter(eUseCounter_custom_DocumentQueryCommandStateOrValueGetHTML);
|
||||
break;
|
||||
case Command::FormatBlock:
|
||||
if (aHTMLCommandName.LowerCaseEqualsLiteral("heading")) {
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandStateOrValueHeading);
|
||||
}
|
||||
break;
|
||||
case Command::SetDocumentReadOnly:
|
||||
SetUseCounter(
|
||||
aHTMLCommandName.LowerCaseEqualsLiteral("contentreadonly")
|
||||
? eUseCounter_custom_DocumentQueryCommandStateOrValueContentReadOnly
|
||||
: eUseCounter_custom_DocumentQueryCommandStateOrValueReadOnly);
|
||||
break;
|
||||
case Command::SetDocumentInsertBROnEnterKeyPress:
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandStateOrValueInsertBrOnReturn);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (aHTMLCommandName.LowerCaseEqualsLiteral("usecss")) {
|
||||
|
@ -5544,8 +5616,39 @@ bool Document::QueryCommandSupported(const nsAString& aHTMLCommandName,
|
|||
// Otherwise, don't throw exception for compatibility with Chrome.
|
||||
|
||||
InternalCommandData commandData = ConvertToInternalCommand(aHTMLCommandName);
|
||||
if (commandData.mCommand == Command::DoNothing) {
|
||||
return false;
|
||||
switch (commandData.mCommand) {
|
||||
case Command::DoNothing:
|
||||
return false;
|
||||
case Command::FormatIncreaseFontSize:
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledIncreaseFontSize);
|
||||
break;
|
||||
case Command::FormatDecreaseFontSize:
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledDecreaseFontSize);
|
||||
break;
|
||||
case Command::GetHTML:
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledGetHTML);
|
||||
break;
|
||||
case Command::FormatBlock:
|
||||
if (aHTMLCommandName.LowerCaseEqualsLiteral("heading")) {
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledHeading);
|
||||
}
|
||||
break;
|
||||
case Command::SetDocumentReadOnly:
|
||||
SetUseCounter(
|
||||
aHTMLCommandName.LowerCaseEqualsLiteral("contentreadonly")
|
||||
? eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledContentReadOnly
|
||||
: eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledReadOnly);
|
||||
break;
|
||||
case Command::SetDocumentInsertBROnEnterKeyPress:
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandSupportedOrEnabledInsertBrOnReturn);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// Gecko technically supports all the clipboard commands including
|
||||
|
@ -5584,9 +5687,31 @@ void Document::QueryCommandValue(const nsAString& aHTMLCommandName,
|
|||
// Otherwise, don't throw exception for compatibility with Chrome.
|
||||
|
||||
InternalCommandData commandData = ConvertToInternalCommand(aHTMLCommandName);
|
||||
if (commandData.mCommand == Command::DoNothing) {
|
||||
// Return empty string
|
||||
return;
|
||||
switch (commandData.mCommand) {
|
||||
case Command::DoNothing:
|
||||
// Return empty string
|
||||
return;
|
||||
case Command::GetHTML:
|
||||
SetUseCounter(eUseCounter_custom_DocumentQueryCommandStateOrValueGetHTML);
|
||||
break;
|
||||
case Command::FormatBlock:
|
||||
if (aHTMLCommandName.LowerCaseEqualsLiteral("heading")) {
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandStateOrValueHeading);
|
||||
}
|
||||
break;
|
||||
case Command::SetDocumentReadOnly:
|
||||
SetUseCounter(
|
||||
aHTMLCommandName.LowerCaseEqualsLiteral("contentreadonly")
|
||||
? eUseCounter_custom_DocumentQueryCommandStateOrValueContentReadOnly
|
||||
: eUseCounter_custom_DocumentQueryCommandStateOrValueReadOnly);
|
||||
break;
|
||||
case Command::SetDocumentInsertBROnEnterKeyPress:
|
||||
SetUseCounter(
|
||||
eUseCounter_custom_DocumentQueryCommandStateOrValueInsertBrOnReturn);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
RefPtr<nsPresContext> presContext = GetPresContext();
|
||||
|
|
|
@ -362,3 +362,26 @@ method Window.webkitSpeechRecognitionEvent
|
|||
method Window.webkitStorageInfo
|
||||
method Window.Worklet
|
||||
method Window.WritableStream
|
||||
|
||||
// Gecko-specific command usage of `Document.execCommand`
|
||||
custom DocumentExecCommandIncreaseFontSize calls execCommand with increasefontsize
|
||||
custom DocumentExecCommandDecreaseFontSize calls execCommand with decreasefontsize
|
||||
custom DocumentExecCommandHeading calls execCommand with heading
|
||||
custom DocumentExecCommandContentReadOnly calls execCommand with contentReadOnly
|
||||
custom DocumentExecCommandReadOnly calls execCommand with readonly
|
||||
|
||||
// Gecko-specific command usage of `Document.queryCommandState` or `Document.queryCommandValue`
|
||||
custom DocumentQueryCommandStateOrValueGetHTML calls queryCommandState or queryCommandValue with gethtml
|
||||
custom DocumentQueryCommandStateOrValueHeading calls queryCommandState or queryCommandValue with heading
|
||||
custom DocumentQueryCommandStateOrValueContentReadOnly calls queryCommandState or queryCommandValue with contentReadOnly
|
||||
custom DocumentQueryCommandStateOrValueReadOnly calls queryCommandState or queryCommandValue with readonly
|
||||
custom DocumentQueryCommandStateOrValueInsertBrOnReturn calls queryCommandState or queryCommandValue with insertBrOnReturn
|
||||
|
||||
// Gecko-specific command usage of `Document.queryCommandSupported` or `Document.queryCommandEnabled`
|
||||
custom DocumentQueryCommandSupportedOrEnabledIncreaseFontSize calls queryCommandSupported or queryCommandEnabled with increasefontsize
|
||||
custom DocumentQueryCommandSupportedOrEnabledDecreaseFontSize calls queryCommandSupported or queryCommandEnabled with decreasefontsize
|
||||
custom DocumentQueryCommandSupportedOrEnabledGetHTML calls queryCommandSupported or queryCommandEnabled with gethtml
|
||||
custom DocumentQueryCommandSupportedOrEnabledHeading calls queryCommandSupported or queryCommandEnabled with heading
|
||||
custom DocumentQueryCommandSupportedOrEnabledContentReadOnly calls queryCommandSupported or queryCommandEnabled with contentReadOnly
|
||||
custom DocumentQueryCommandSupportedOrEnabledReadOnly calls queryCommandSupported or queryCommandEnabled with readonly
|
||||
custom DocumentQueryCommandSupportedOrEnabledInsertBrOnReturn calls queryCommandSupported or queryCommandEnabled with insertBrOnReturn
|
||||
|
|
Загрузка…
Ссылка в новой задаче