Bug 1101392 - Part 1: Fix coding style in nsEditorCommands.cpp. r=roc

This commit is contained in:
Morris Tseng 2014-11-24 22:08:00 +01:00
parent ec19acd1d8
commit 739173819c

View File

@ -3,7 +3,6 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "mozFlushType.h"
#include "mozilla/ArrayUtils.h"
#include "mozilla/Assertions.h"
@ -28,18 +27,13 @@
class nsISupports;
#define STATE_ENABLED "state_enabled"
#define STATE_DATA "state_data"
nsBaseEditorCommand::nsBaseEditorCommand()
{
}
nsBaseEditorCommand::nsBaseEditorCommand() {}
NS_IMPL_ISUPPORTS(nsBaseEditorCommand, nsIControllerCommand)
NS_IMETHODIMP
nsUndoCommand::IsCommandEnabled(const char *aCommandName,
nsISupports *aCommandRefCon,
@ -47,8 +41,7 @@ nsUndoCommand::IsCommandEnabled(const char * aCommandName,
{
NS_ENSURE_ARG_POINTER(outCmdEnabled);
nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
if (editor)
{
if (editor) {
bool isEnabled, isEditable = false;
nsresult rv = editor->GetIsSelectionEditable(&isEditable);
NS_ENSURE_SUCCESS(rv, rv);
@ -60,7 +53,6 @@ nsUndoCommand::IsCommandEnabled(const char * aCommandName,
return NS_OK;
}
NS_IMETHODIMP
nsUndoCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon)
{
@ -96,8 +88,7 @@ nsRedoCommand::IsCommandEnabled(const char * aCommandName,
{
NS_ENSURE_ARG_POINTER(outCmdEnabled);
nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
if (editor)
{
if (editor) {
bool isEnabled, isEditable = false;
nsresult rv = editor->GetIsSelectionEditable(&isEditable);
NS_ENSURE_SUCCESS(rv, rv);
@ -109,7 +100,6 @@ nsRedoCommand::IsCommandEnabled(const char * aCommandName,
return NS_OK;
}
NS_IMETHODIMP
nsRedoCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon)
{
@ -151,7 +141,6 @@ nsClearUndoCommand::IsCommandEnabled(const char * aCommandName,
return NS_OK;
}
NS_IMETHODIMP
nsClearUndoCommand::DoCommand(const char *aCommandName, nsISupports *refCon)
{
@ -188,13 +177,11 @@ nsClearUndoCommand::GetCommandStateParams(const char *aCommandName,
NS_IMETHODIMP
nsCutCommand::IsCommandEnabled(const char *aCommandName,
nsISupports *aCommandRefCon,
bool *outCmdEnabled)
nsISupports *aCommandRefCon, bool *outCmdEnabled)
{
NS_ENSURE_ARG_POINTER(outCmdEnabled);
nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
if (editor)
{
if (editor) {
bool isEditable = false;
nsresult rv = editor->GetIsSelectionEditable(&isEditable);
NS_ENSURE_SUCCESS(rv, rv);
@ -206,7 +193,6 @@ nsCutCommand::IsCommandEnabled(const char * aCommandName,
return NS_OK;
}
NS_IMETHODIMP
nsCutCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon)
{
@ -235,7 +221,6 @@ nsCutCommand::GetCommandStateParams(const char *aCommandName,
return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
}
NS_IMETHODIMP
nsCutOrDeleteCommand::IsCommandEnabled(const char *aCommandName,
nsISupports *aCommandRefCon,
@ -250,14 +235,12 @@ nsCutOrDeleteCommand::IsCommandEnabled(const char * aCommandName,
return NS_OK;
}
NS_IMETHODIMP
nsCutOrDeleteCommand::DoCommand(const char *aCommandName,
nsISupports *aCommandRefCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
if (editor)
{
if (editor) {
nsCOMPtr<nsISelection> selection;
nsresult rv = editor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(rv) && selection && selection->Collapsed()) {
@ -301,7 +284,6 @@ nsCopyCommand::IsCommandEnabled(const char * aCommandName,
return NS_OK;
}
NS_IMETHODIMP
nsCopyCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon)
{
@ -344,14 +326,12 @@ nsCopyOrDeleteCommand::IsCommandEnabled(const char * aCommandName,
return NS_OK;
}
NS_IMETHODIMP
nsCopyOrDeleteCommand::DoCommand(const char *aCommandName,
nsISupports *aCommandRefCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
if (editor)
{
if (editor) {
nsCOMPtr<nsISelection> selection;
nsresult rv = editor->GetSelection(getter_AddRefs(selection));
if (NS_SUCCEEDED(rv) && selection && selection->Collapsed()) {
@ -388,8 +368,7 @@ nsPasteCommand::IsCommandEnabled(const char *aCommandName,
{
NS_ENSURE_ARG_POINTER(outCmdEnabled);
nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
if (editor)
{
if (editor) {
bool isEditable = false;
nsresult rv = editor->GetIsSelectionEditable(&isEditable);
NS_ENSURE_SUCCESS(rv, rv);
@ -401,7 +380,6 @@ nsPasteCommand::IsCommandEnabled(const char *aCommandName,
return NS_OK;
}
NS_IMETHODIMP
nsPasteCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon)
{
@ -436,8 +414,7 @@ nsPasteTransferableCommand::IsCommandEnabled(const char *aCommandName,
{
NS_ENSURE_ARG_POINTER(outCmdEnabled);
nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
if (editor)
{
if (editor) {
bool isEditable = false;
nsresult rv = editor->GetIsSelectionEditable(&isEditable);
NS_ENSURE_SUCCESS(rv, rv);
@ -450,7 +427,8 @@ nsPasteTransferableCommand::IsCommandEnabled(const char *aCommandName,
}
NS_IMETHODIMP
nsPasteTransferableCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon)
nsPasteTransferableCommand::DoCommand(const char *aCommandName,
nsISupports *aCommandRefCon)
{
return NS_ERROR_FAILURE;
}
@ -512,7 +490,8 @@ nsSwitchTextDirectionCommand::IsCommandEnabled(const char *aCommandName,
}
NS_IMETHODIMP
nsSwitchTextDirectionCommand::DoCommand(const char *aCommandName, nsISupports *aCommandRefCon)
nsSwitchTextDirectionCommand::DoCommand(const char *aCommandName,
nsISupports *aCommandRefCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
NS_ENSURE_TRUE(editor, NS_ERROR_FAILURE);
@ -563,7 +542,6 @@ nsDeleteCommand::IsCommandEnabled(const char* aCommandName,
return NS_OK;
}
NS_IMETHODIMP
nsDeleteCommand::DoCommand(const char *aCommandName,
nsISupports *aCommandRefCon)
@ -639,7 +617,6 @@ nsSelectAllCommand::IsCommandEnabled(const char * aCommandName,
return rv;
}
NS_IMETHODIMP
nsSelectAllCommand::DoCommand(const char *aCommandName,
nsISupports *aCommandRefCon)
@ -669,7 +646,6 @@ nsSelectAllCommand::GetCommandStateParams(const char *aCommandName,
return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
}
NS_IMETHODIMP
nsSelectionMoveCommands::IsCommandEnabled(const char *aCommandName,
nsISupports *aCommandRefCon,
@ -824,7 +800,6 @@ nsSelectionMoveCommands::GetCommandStateParams(const char *aCommandName,
return aParams->SetBooleanValue(STATE_ENABLED, canUndo);
}
NS_IMETHODIMP
nsInsertPlaintextCommand::IsCommandEnabled(const char *aCommandName,
nsISupports *refCon,
@ -839,7 +814,6 @@ nsInsertPlaintextCommand::IsCommandEnabled(const char * aCommandName,
return NS_ERROR_NOT_IMPLEMENTED;
}
NS_IMETHODIMP
nsInsertPlaintextCommand::DoCommand(const char *aCommandName,
nsISupports *refCon)
@ -880,7 +854,6 @@ nsInsertPlaintextCommand::GetCommandStateParams(const char *aCommandName,
return aParams->SetBooleanValue(STATE_ENABLED, outCmdEnabled);
}
NS_IMETHODIMP
nsPasteQuotationCommand::IsCommandEnabled(const char *aCommandName,
nsISupports *refCon,
@ -901,7 +874,6 @@ nsPasteQuotationCommand::IsCommandEnabled(const char * aCommandName,
return NS_OK;
}
NS_IMETHODIMP
nsPasteQuotationCommand::DoCommand(const char *aCommandName,
nsISupports *refCon)
@ -931,8 +903,7 @@ nsPasteQuotationCommand::GetCommandStateParams(const char *aCommandName,
nsISupports *refCon)
{
nsCOMPtr<nsIEditor> editor = do_QueryInterface(refCon);
if (editor)
{
if (editor) {
bool enabled = false;
editor->CanPaste(nsIClipboard::kGlobalClipboard, &enabled);
aParams->SetBooleanValue(STATE_ENABLED, enabled);
@ -940,4 +911,3 @@ nsPasteQuotationCommand::GetCommandStateParams(const char *aCommandName,
return NS_OK;
}