From ae21d8429d8ebc1a9f61be3bea07a65d83ff204b Mon Sep 17 00:00:00 2001 From: "sfraser%netscape.com" Date: Wed, 4 Apr 2001 23:48:03 +0000 Subject: [PATCH] Fix for 74143, change nsIController to use DOMStrings. sr=hyatt, r=kin --- content/xbl/src/nsXBLPrototypeHandler.cpp | 2 +- content/xul/document/public/nsIController.idl | 8 +- .../document/public/nsIControllerCommand.idl | 22 +- .../xul/document/public/nsIControllers.idl | 2 +- .../src/nsControllerCommandManager.cpp | 29 +-- content/xul/document/src/nsXULControllers.cpp | 2 +- docshell/base/nsWebShell.cpp | 18 +- docshell/base/nsWebShell.h | 6 +- dom/src/base/nsFocusController.cpp | 9 +- dom/src/base/nsGlobalWindow.cpp | 205 +++++++++--------- editor/base/nsComposerCommands.cpp | 68 +++--- editor/base/nsComposerCommands.h | 12 +- editor/base/nsEditorCommands.cpp | 88 ++++---- editor/base/nsEditorCommands.h | 11 +- editor/base/nsEditorController.cpp | 21 +- editor/base/nsEditorShell.cpp | 25 +-- editor/base/nsEditorShell.h | 2 +- editor/composer/src/nsComposerCommands.cpp | 68 +++--- editor/composer/src/nsComposerCommands.h | 12 +- editor/composer/src/nsEditorShell.cpp | 25 +-- editor/composer/src/nsEditorShell.h | 2 +- editor/idl/nsIEditorController.idl | 2 +- editor/libeditor/base/nsEditorCommands.cpp | 88 ++++---- editor/libeditor/base/nsEditorCommands.h | 11 +- editor/libeditor/base/nsEditorController.cpp | 21 +- 25 files changed, 377 insertions(+), 382 deletions(-) diff --git a/content/xbl/src/nsXBLPrototypeHandler.cpp b/content/xbl/src/nsXBLPrototypeHandler.cpp index dc624c66bd19..0999710e4916 100644 --- a/content/xbl/src/nsXBLPrototypeHandler.cpp +++ b/content/xbl/src/nsXBLPrototypeHandler.cpp @@ -277,7 +277,7 @@ nsXBLPrototypeHandler::ExecuteHandler(nsIDOMEventReceiver* aReceiver, nsIDOMEven else GetController(aReceiver, getter_AddRefs(controller)); // We're attached to the receiver possibly. if (controller) - controller->DoCommand(command.GetUnicode()); + controller->DoCommand(command); return NS_OK; } diff --git a/content/xul/document/public/nsIController.idl b/content/xul/document/public/nsIController.idl index 45162bcad8c6..dc7d167f63fa 100644 --- a/content/xul/document/public/nsIController.idl +++ b/content/xul/document/public/nsIController.idl @@ -24,10 +24,10 @@ [scriptable, uuid(D5B61B82-1DA4-11d3-BF87-00105A1B0627)] interface nsIController : nsISupports { - boolean isCommandEnabled(in wstring command); - boolean supportsCommand(in wstring command); + boolean isCommandEnabled(in DOMString command); + boolean supportsCommand(in DOMString command); - void doCommand(in wstring command); + void doCommand(in DOMString command); - void onEvent(in wstring eventName); + void onEvent(in DOMString eventName); }; diff --git a/content/xul/document/public/nsIControllerCommand.idl b/content/xul/document/public/nsIControllerCommand.idl index 773353b860ae..7f3174d6def8 100644 --- a/content/xul/document/public/nsIControllerCommand.idl +++ b/content/xul/document/public/nsIControllerCommand.idl @@ -45,8 +45,8 @@ interface nsIControllerCommand : nsISupports * allowing the command to get some context information. * The contents of this cookie are implementation-defined. */ - boolean isCommandEnabled(in wstring aCommandName, in nsISupports aCommandRefCon); - + boolean isCommandEnabled(in DOMString aCommandName, in nsISupports aCommandRefCon); + /** * Execute the name command. * @@ -56,7 +56,7 @@ interface nsIControllerCommand : nsISupports * allowing the command to get some context information. * The contents of this cookie are implementation-defined. */ - void doCommand(in wstring aCommandName, in nsISupports aCommandRefCon); + void doCommand(in DOMString aCommandName, in nsISupports aCommandRefCon); }; @@ -84,7 +84,7 @@ interface nsIStateUpdatingControllerCommand : nsISupports * allowing the command to get some context information. * The contents of this cookie are implementation-defined. */ - void updateCommandState(in wstring aCommandName, in nsISupports aCommandRefCon); + void updateCommandState(in DOMString aCommandName, in nsISupports aCommandRefCon); }; @@ -113,15 +113,15 @@ interface nsIControllerCommandManager : nsISupports * * @param aCommand the handler for this command. */ - void registerCommand(in wstring aCommandName, in nsIControllerCommand aCommand); - void unregisterCommand(in wstring aCommandName, in nsIControllerCommand aCommand); + void registerCommand(in DOMString aCommandName, in nsIControllerCommand aCommand); + void unregisterCommand(in DOMString aCommandName, in nsIControllerCommand aCommand); /** * Find the command handler which has been registered to handle the named command. * * @param aCommandName the name of the command to find the handler for. */ - nsIControllerCommand findCommandHandler(in wstring aCommandName); + nsIControllerCommand findCommandHandler(in DOMString aCommandName); /** * Get whether the named command is enabled. @@ -129,7 +129,7 @@ interface nsIControllerCommandManager : nsISupports * @param aCommandName the name of the command to test * @param aCommandRefCon the command context data */ - boolean isCommandEnabled(in wstring aCommandName, in nsISupports aCommandRefCon); + boolean isCommandEnabled(in DOMString aCommandName, in nsISupports aCommandRefCon); /** * Tell the command to udpate its state (if it is a state updating command) @@ -137,7 +137,7 @@ interface nsIControllerCommandManager : nsISupports * @param aCommandName the name of the command to update * @param aCommandRefCon the command context data */ - void updateCommandState(in wstring aCommandName, in nsISupports aCommandRefCon); + void updateCommandState(in DOMString aCommandName, in nsISupports aCommandRefCon); /** * Get whether the named command is supported. @@ -145,7 +145,7 @@ interface nsIControllerCommandManager : nsISupports * @param aCommandName the name of the command to test * @param aCommandRefCon the command context data */ - boolean supportsCommand(in wstring aCommandName, in nsISupports aCommandRefCon); + boolean supportsCommand(in DOMString aCommandName, in nsISupports aCommandRefCon); /** * Execute the named command. @@ -153,7 +153,7 @@ interface nsIControllerCommandManager : nsISupports * @param aCommandName the name of the command to execute * @param aCommandRefCon the command context data */ - void doCommand(in wstring aCommandName, in nsISupports aCommandRefCon); + void doCommand(in DOMString aCommandName, in nsISupports aCommandRefCon); }; diff --git a/content/xul/document/public/nsIControllers.idl b/content/xul/document/public/nsIControllers.idl index fa7e2cd2320b..3d369190332e 100644 --- a/content/xul/document/public/nsIControllers.idl +++ b/content/xul/document/public/nsIControllers.idl @@ -30,7 +30,7 @@ interface nsIControllers : nsISecurityCheckedComponent { attribute nsIDOMXULCommandDispatcher commandDispatcher; - nsIController getControllerForCommand(in wstring command); + nsIController getControllerForCommand(in DOMString command); void insertControllerAt(in unsigned long index, in nsIController controller); nsIController removeControllerAt(in unsigned long index); diff --git a/content/xul/document/src/nsControllerCommandManager.cpp b/content/xul/document/src/nsControllerCommandManager.cpp index 6dad63c0f812..b6dde6f7a3b7 100644 --- a/content/xul/document/src/nsControllerCommandManager.cpp +++ b/content/xul/document/src/nsControllerCommandManager.cpp @@ -20,7 +20,7 @@ * Contributor(s): */ - +#include "nsString.h" #include "nsControllerCommandManager.h" // prototype; @@ -48,15 +48,15 @@ NS_IMPL_ISUPPORTS2(nsControllerCommandManager, nsIControllerCommandManager, nsIS NS_IMETHODIMP -nsControllerCommandManager::RegisterCommand(const PRUnichar *commandName, nsIControllerCommand *aCommand) +nsControllerCommandManager::RegisterCommand(const nsAReadableString & aCommandName, nsIControllerCommand *aCommand) { - nsStringKey commandKey(commandName); + nsStringKey commandKey(aCommandName); if (mCommandsTable.Put (&commandKey, aCommand)) { #if DEBUG nsCAutoString msg("Replacing existing command -- "); - msg.AppendWithConversion(commandName); + msg.AppendWithConversion(aCommandName); NS_WARNING(msg); #endif } @@ -65,9 +65,9 @@ nsControllerCommandManager::RegisterCommand(const PRUnichar *commandName, nsICon NS_IMETHODIMP -nsControllerCommandManager::UnregisterCommand(const PRUnichar *commandName, nsIControllerCommand *aCommand) +nsControllerCommandManager::UnregisterCommand(const nsAReadableString & aCommandName, nsIControllerCommand *aCommand) { - nsStringKey commandKey(commandName); + nsStringKey commandKey(aCommandName); PRBool any_object_actually_removed_p = mCommandsTable.Remove (&commandKey); return any_object_actually_removed_p? NS_OK : NS_ERROR_FAILURE; @@ -75,7 +75,7 @@ nsControllerCommandManager::UnregisterCommand(const PRUnichar *commandName, nsIC NS_IMETHODIMP -nsControllerCommandManager::FindCommandHandler(const PRUnichar *aCommandName, nsIControllerCommand **outCommand) +nsControllerCommandManager::FindCommandHandler(const nsAReadableString & aCommandName, nsIControllerCommand **outCommand) { NS_ENSURE_ARG_POINTER(outCommand); @@ -93,9 +93,8 @@ nsControllerCommandManager::FindCommandHandler(const PRUnichar *aCommandName, ns /* boolean isCommandEnabled (in wstring command); */ NS_IMETHODIMP -nsControllerCommandManager::IsCommandEnabled(const PRUnichar *aCommandName, nsISupports *aCommandRefCon, PRBool *aResult) +nsControllerCommandManager::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *aResult) { - NS_ENSURE_ARG_POINTER(aCommandName); NS_ENSURE_ARG_POINTER(aResult); *aResult = PR_FALSE; @@ -118,10 +117,8 @@ nsControllerCommandManager::IsCommandEnabled(const PRUnichar *aCommandName, nsIS NS_IMETHODIMP -nsControllerCommandManager::UpdateCommandState(const PRUnichar *aCommandName, nsISupports *aCommandRefCon) +nsControllerCommandManager::UpdateCommandState(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - NS_ENSURE_ARG_POINTER(aCommandName); - // find the command nsCOMPtr commandHandler; FindCommandHandler(aCommandName, getter_AddRefs(commandHandler)); @@ -150,9 +147,8 @@ nsControllerCommandManager::UpdateCommandState(const PRUnichar *aCommandName, ns } NS_IMETHODIMP -nsControllerCommandManager::SupportsCommand(const PRUnichar *aCommandName, nsISupports *aCommandRefCon, PRBool *aResult) +nsControllerCommandManager::SupportsCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *aResult) { - NS_ENSURE_ARG_POINTER(aCommandName); NS_ENSURE_ARG_POINTER(aResult); // XXX: need to check the readonly and disabled states @@ -169,10 +165,8 @@ nsControllerCommandManager::SupportsCommand(const PRUnichar *aCommandName, nsISu /* void doCommand (in wstring command); */ NS_IMETHODIMP -nsControllerCommandManager::DoCommand(const PRUnichar *aCommandName, nsISupports *aCommandRefCon) +nsControllerCommandManager::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - NS_ENSURE_ARG_POINTER(aCommandName); - // find the command nsCOMPtr commandHandler; FindCommandHandler(aCommandName, getter_AddRefs(commandHandler)); @@ -189,7 +183,6 @@ nsControllerCommandManager::DoCommand(const PRUnichar *aCommandName, nsISupports return commandHandler->DoCommand(aCommandName, aCommandRefCon); } - nsresult NS_NewControllerCommandManager(nsIControllerCommandManager** aResult) { diff --git a/content/xul/document/src/nsXULControllers.cpp b/content/xul/document/src/nsXULControllers.cpp index e9b8df339b6d..d2b3ae49d529 100644 --- a/content/xul/document/src/nsXULControllers.cpp +++ b/content/xul/document/src/nsXULControllers.cpp @@ -105,7 +105,7 @@ nsXULControllers::SetCommandDispatcher(nsIDOMXULCommandDispatcher* aCommandDispa } NS_IMETHODIMP -nsXULControllers::GetControllerForCommand(const PRUnichar *aCommand, nsIController** _retval) +nsXULControllers::GetControllerForCommand(const nsAReadableString& aCommand, nsIController** _retval) { NS_ENSURE_ARG_POINTER(_retval); *_retval = nsnull; diff --git a/docshell/base/nsWebShell.cpp b/docshell/base/nsWebShell.cpp index 7f0e86918a53..7bd292fbc4d5 100644 --- a/docshell/base/nsWebShell.cpp +++ b/docshell/base/nsWebShell.cpp @@ -1181,8 +1181,11 @@ nsresult nsWebShell::EndPageLoad(nsIWebProgress *aProgress, #endif nsresult -nsWebShell :: GetControllerForCommand ( const nsAReadableString & inCommand, nsIController** outController ) +nsWebShell::GetControllerForCommand ( const nsAReadableString & inCommand, nsIController** outController ) { + NS_ENSURE_ARG_POINTER(outController); + *outController = nsnull; + nsresult rv = NS_ERROR_FAILURE; nsCOMPtr window ( do_QueryInterface(mScriptGlobal) ); @@ -1190,7 +1193,7 @@ nsWebShell :: GetControllerForCommand ( const nsAReadableString & inCommand, nsI nsCOMPtr focusController; rv = window->GetRootFocusController ( getter_AddRefs(focusController) ); if ( focusController ) - rv = focusController->GetControllerForCommand ( inCommand, getter_AddRefs(outController) ) ; + rv = focusController->GetControllerForCommand ( inCommand, getter_AddRefs(outController) ); } // if window return rv; @@ -1199,28 +1202,31 @@ nsWebShell :: GetControllerForCommand ( const nsAReadableString & inCommand, nsI nsresult -nsWebShell :: IsCommandEnabled ( const nsAReadableString & inCommand, PRBool* outEnabled ) +nsWebShell::IsCommandEnabled ( const nsAReadableString & inCommand, PRBool* outEnabled ) { + NS_ENSURE_ARG_POINTER(outEnabled); + *outEnabled = PR_FALSE; + nsresult rv = NS_ERROR_FAILURE; nsCOMPtr controller; rv = GetControllerForCommand ( inCommand, getter_AddRefs(controller) ); if ( controller ) - rv = controller->IsCommandEnabled(PromiseFlatString(inCommand).get(), outEnabled); + rv = controller->IsCommandEnabled(inCommand, outEnabled); return rv; } nsresult -nsWebShell :: DoCommand ( const nsAReadableString & inCommand ) +nsWebShell::DoCommand ( const nsAReadableString & inCommand ) { nsresult rv = NS_ERROR_FAILURE; nsCOMPtr controller; rv = GetControllerForCommand ( inCommand, getter_AddRefs(controller) ); if ( controller ) - rv = controller->DoCommand(PromiseFlatString(inCommand).get()); + rv = controller->DoCommand(inCommand); return rv; } diff --git a/docshell/base/nsWebShell.h b/docshell/base/nsWebShell.h index 707b016846fe..ebf2aefa35d9 100644 --- a/docshell/base/nsWebShell.h +++ b/docshell/base/nsWebShell.h @@ -129,9 +129,9 @@ protected: void InitFrameData(); // helpers for executing commands - virtual nsresult GetControllerForCommand ( const nsAReadableString & inCommand, nsIController** outController ) ; - virtual nsresult IsCommandEnabled ( const nsAReadableString & inCommand, PRBool* outEnabled ) ; - virtual nsresult DoCommand ( const nsAReadableString & inCommand ) ; + virtual nsresult GetControllerForCommand ( const nsAReadableString & inCommand, nsIController** outController ); + virtual nsresult IsCommandEnabled ( const nsAReadableString & inCommand, PRBool* outEnabled ); + virtual nsresult DoCommand ( const nsAReadableString & inCommand ); // // Helper method that is called when a new document (including any diff --git a/dom/src/base/nsFocusController.cpp b/dom/src/base/nsFocusController.cpp index 0da7d68d1756..562475737deb 100644 --- a/dom/src/base/nsFocusController.cpp +++ b/dom/src/base/nsFocusController.cpp @@ -249,6 +249,8 @@ nsFocusController::Blur(nsIDOMEvent* aEvent) nsresult nsFocusController::GetParentWindowFromDocument(nsIDOMDocument* aDocument, nsIDOMWindowInternal** aWindow) { + NS_ENSURE_ARG_POINTER(aWindow); + nsCOMPtr objectOwner = do_QueryInterface(aDocument); if(!objectOwner) return NS_OK; @@ -265,15 +267,14 @@ nsFocusController::GetParentWindowFromDocument(nsIDOMDocument* aDocument, nsIDOM NS_IMETHODIMP nsFocusController::GetControllerForCommand(const nsAReadableString& aCommand, nsIController** _retval) { - const nsPromiseFlatString& flatCommand = PromiseFlatString(aCommand); - const PRUnichar *command = flatCommand.get(); + NS_ENSURE_ARG_POINTER(_retval); *_retval = nsnull; nsCOMPtr controllers; GetControllers(getter_AddRefs(controllers)); if(controllers) { nsCOMPtr controller; - controllers->GetControllerForCommand(command, getter_AddRefs(controller)); + controllers->GetControllerForCommand(aCommand, getter_AddRefs(controller)); if(controller) { *_retval = controller; NS_ADDREF(*_retval); @@ -303,7 +304,7 @@ nsFocusController::GetControllerForCommand(const nsAReadableString& aCommand, ns domWindow->GetControllers(getter_AddRefs(controllers2)); if(controllers2) { nsCOMPtr controller; - controllers2->GetControllerForCommand(command, getter_AddRefs(controller)); + controllers2->GetControllerForCommand(aCommand, getter_AddRefs(controller)); if(controller) { *_retval = controller; NS_ADDREF(*_retval); diff --git a/dom/src/base/nsGlobalWindow.cpp b/dom/src/base/nsGlobalWindow.cpp index e2360a023eea..5f4ca4756c62 100644 --- a/dom/src/base/nsGlobalWindow.cpp +++ b/dom/src/base/nsGlobalWindow.cpp @@ -121,8 +121,8 @@ static NS_DEFINE_IID(kISupportsIID, NS_ISUPPORTS_IID); static char *sWindowWatcherContractID = "@mozilla.org/embedcomp/window-watcher;1"; -static const char *kCryptoContractID = NS_CRYPTO_CONTRACTID; -static const char *kPkcs11ContractID = NS_PKCS11_CONTRACTID; +static const char * const kCryptoContractID = NS_CRYPTO_CONTRACTID; +static const char * const kPkcs11ContractID = NS_PKCS11_CONTRACTID; //***************************************************************************** //*** GlobalWindowImpl: Object Management @@ -3031,8 +3031,8 @@ void GlobalWindowImpl::CloseWindow(nsISupports *aWindow) // GlobalWindowImpl: Timeout Functions //***************************************************************************** -static const char *kSetIntervalStr = "setInterval"; -static const char *kSetTimeoutStr = "setTimeout"; +static const char * const kSetIntervalStr = "setInterval"; +static const char * const kSetTimeoutStr = "setTimeout"; NS_IMETHODIMP GlobalWindowImpl::SetTimeoutOrInterval(JSContext *cx, jsval *argv, PRUint32 argc, @@ -4415,44 +4415,44 @@ NS_IMETHODIMP NavigatorImpl::Preference(JSContext *cx, jsval *argv, #ifdef DOM_CONTROLLER // nsDOMWindowController -const char *sCopyString = "cmd_copy"; -const char *sCutString = "cmd_cut"; -const char *sPasteString = "cmd_paste"; -const char *sSelectAllString = "cmd_selectAll"; +const char * const sCopyString = "cmd_copy"; +const char * const sCutString = "cmd_cut"; +const char * const sPasteString = "cmd_paste"; +const char * const sSelectAllString = "cmd_selectAll"; -const char *sScrollTopString = "cmd_scrollTop"; -const char *sScrollBottomString = "cmd_scrollBottom"; -const char *sScrollPageUpString = "cmd_scrollPageUp"; -const char *sScrollPageDownString = "cmd_scrollPageDown"; -const char *sScrollLineUpString = "cmd_scrollLineUp"; -const char *sScrollLineDownString = "cmd_scrollLineDown"; -const char *sScrollLeftString = "cmd_scrollLeft"; -const char *sScrollRightString = "cmd_scrollRight"; +const char * const sScrollTopString = "cmd_scrollTop"; +const char * const sScrollBottomString = "cmd_scrollBottom"; +const char * const sScrollPageUpString = "cmd_scrollPageUp"; +const char * const sScrollPageDownString = "cmd_scrollPageDown"; +const char * const sScrollLineUpString = "cmd_scrollLineUp"; +const char * const sScrollLineDownString = "cmd_scrollLineDown"; +const char * const sScrollLeftString = "cmd_scrollLeft"; +const char * const sScrollRightString = "cmd_scrollRight"; // These are so the browser can use editor navigation key bindings // helps with accessibility (boolean pref accessibility.browsewithcaret) -const char *sSelectCharPreviousString = "cmd_selectCharPrevious"; -const char *sSelectCharNextString = "cmd_selectCharNext"; +const char * const sSelectCharPreviousString = "cmd_selectCharPrevious"; +const char * const sSelectCharNextString = "cmd_selectCharNext"; -const char *sWordPreviousString = "cmd_wordPrevious"; -const char *sWordNextString = "cmd_wordNext"; -const char *sSelectWordPreviousString = "cmd_selectWordPrevious"; -const char *sSelectWordNextString = "cmd_selectWordNext"; +const char * const sWordPreviousString = "cmd_wordPrevious"; +const char * const sWordNextString = "cmd_wordNext"; +const char * const sSelectWordPreviousString = "cmd_selectWordPrevious"; +const char * const sSelectWordNextString = "cmd_selectWordNext"; -const char *sBeginLineString = "cmd_beginLine"; -const char *sEndLineString = "cmd_endLine"; -const char *sSelectBeginLineString = "cmd_selectBeginLine"; -const char *sSelectEndLineString = "cmd_selectEndLine"; +const char * const sBeginLineString = "cmd_beginLine"; +const char * const sEndLineString = "cmd_endLine"; +const char * const sSelectBeginLineString = "cmd_selectBeginLine"; +const char * const sSelectEndLineString = "cmd_selectEndLine"; -const char *sSelectLinePreviousString = "cmd_selectLinePrevious"; -const char *sSelectLineNextString = "cmd_selectLineNext"; +const char * const sSelectLinePreviousString = "cmd_selectLinePrevious"; +const char * const sSelectLineNextString = "cmd_selectLineNext"; -const char *sSelectPagePreviousString = "cmd_selectPagePrevious"; -const char *sSelectPageNextString = "cmd_selectPageNext"; +const char * const sSelectPagePreviousString = "cmd_selectPagePrevious"; +const char * const sSelectPageNextString = "cmd_selectPageNext"; -const char *sSelectMoveTopString = "cmd_selectMoveTop"; -const char *sSelectMoveBottomString = "cmd_selectMoveBottom"; +const char * const sSelectMoveTopString = "cmd_selectMoveTop"; +const char * const sSelectMoveBottomString = "cmd_selectMoveBottom"; NS_IMPL_ADDREF(nsDOMWindowController) NS_IMPL_RELEASE(nsDOMWindowController) @@ -4528,10 +4528,8 @@ nsDOMWindowController::GetSelectionController(nsISelectionController **aSelCon) -NS_IMETHODIMP nsDOMWindowController::IsCommandEnabled(const PRUnichar *aCommand, - PRBool *aResult) +NS_IMETHODIMP nsDOMWindowController::IsCommandEnabled(const nsAReadableString & aCommand, PRBool *aResult) { - NS_ENSURE_ARG_POINTER(aCommand); NS_ENSURE_ARG_POINTER(aResult); *aResult = PR_FALSE; @@ -4542,16 +4540,18 @@ NS_IMETHODIMP nsDOMWindowController::IsCommandEnabled(const PRUnichar *aCommand, if (NS_FAILED(rv)) return rv; - if (nsCAutoString(sCopyString).EqualsWithConversion(aCommand)) { + nsCAutoString commandName; commandName.AssignWithConversion(aCommand); + + if (commandName.Equals(sCopyString)) { rv = editInterface->GetCopyable(aResult); } - else if (nsCAutoString(sCutString).EqualsWithConversion(aCommand)) { + else if (commandName.Equals(sCutString)) { rv = editInterface->GetCutable(aResult); } - else if (nsCAutoString(sPasteString).EqualsWithConversion(aCommand)) { + else if (commandName.Equals(sPasteString)) { rv = editInterface->GetPasteable(aResult); } - else if (nsCAutoString(sSelectAllString).EqualsWithConversion(aCommand)) { + else if (commandName.Equals(sSelectAllString)) { *aResult = PR_TRUE; rv = NS_OK; } @@ -4559,63 +4559,64 @@ NS_IMETHODIMP nsDOMWindowController::IsCommandEnabled(const PRUnichar *aCommand, } -NS_IMETHODIMP nsDOMWindowController::SupportsCommand(const PRUnichar *aCommand, - PRBool *aResult) +NS_IMETHODIMP nsDOMWindowController::SupportsCommand(const nsAReadableString & aCommand, PRBool *outSupported) { - NS_ENSURE_ARG_POINTER(aCommand); - NS_ENSURE_ARG_POINTER(aResult); + NS_ENSURE_ARG_POINTER(outSupported); - *aResult = PR_FALSE; + *outSupported = PR_FALSE; - if (nsCAutoString(sCopyString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectAllString).EqualsWithConversion(aCommand) || - nsCAutoString(sCutString).EqualsWithConversion(aCommand) || - nsCAutoString(sPasteString).EqualsWithConversion(aCommand) || - nsCAutoString(sScrollTopString).EqualsWithConversion(aCommand) || - nsCAutoString(sScrollBottomString).EqualsWithConversion(aCommand) || - nsCAutoString(sScrollPageUpString).EqualsWithConversion(aCommand) || - nsCAutoString(sScrollPageDownString).EqualsWithConversion(aCommand) || - nsCAutoString(sScrollLineUpString).EqualsWithConversion(aCommand) || - nsCAutoString(sScrollLineDownString).EqualsWithConversion(aCommand) || - nsCAutoString(sScrollLeftString).EqualsWithConversion(aCommand) || - nsCAutoString(sScrollRightString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectCharPreviousString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectCharNextString).EqualsWithConversion(aCommand) || - nsCAutoString(sWordPreviousString).EqualsWithConversion(aCommand) || - nsCAutoString(sWordNextString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectWordPreviousString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectWordNextString).EqualsWithConversion(aCommand) || - nsCAutoString(sBeginLineString).EqualsWithConversion(aCommand) || - nsCAutoString(sEndLineString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectBeginLineString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectEndLineString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectLinePreviousString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectLineNextString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectPagePreviousString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectPageNextString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectMoveTopString).EqualsWithConversion(aCommand) || - nsCAutoString(sSelectMoveBottomString).EqualsWithConversion(aCommand) + nsCAutoString commandName; commandName.AssignWithConversion(aCommand); + + if (commandName.Equals(sCopyString) || + commandName.Equals(sSelectAllString) || + commandName.Equals(sCutString) || + commandName.Equals(sPasteString) || + commandName.Equals(sScrollTopString) || + commandName.Equals(sScrollBottomString) || + commandName.Equals(sScrollPageUpString) || + commandName.Equals(sScrollPageDownString) || + commandName.Equals(sScrollLineUpString) || + commandName.Equals(sScrollLineDownString) || + commandName.Equals(sScrollLeftString) || + commandName.Equals(sScrollRightString) || + commandName.Equals(sSelectCharPreviousString) || + commandName.Equals(sSelectCharNextString) || + commandName.Equals(sWordPreviousString) || + commandName.Equals(sWordNextString) || + commandName.Equals(sSelectWordPreviousString) || + commandName.Equals(sSelectWordNextString) || + commandName.Equals(sBeginLineString) || + commandName.Equals(sEndLineString) || + commandName.Equals(sSelectBeginLineString) || + commandName.Equals(sSelectEndLineString) || + commandName.Equals(sSelectLinePreviousString) || + commandName.Equals(sSelectLineNextString) || + commandName.Equals(sSelectPagePreviousString) || + commandName.Equals(sSelectPageNextString) || + commandName.Equals(sSelectMoveTopString) || + commandName.Equals(sSelectMoveBottomString) ) { - *aResult=PR_TRUE; + *outSupported=PR_TRUE; } return NS_OK; } -NS_IMETHODIMP nsDOMWindowController::DoCommand(const PRUnichar *aCommand) +NS_IMETHODIMP nsDOMWindowController::DoCommand(const nsAReadableString & aCommand) { - NS_ENSURE_ARG_POINTER(aCommand); nsresult rv = NS_ERROR_FAILURE; nsCOMPtr editInterface; rv = GetEditInterface(getter_AddRefs(editInterface)); if (!editInterface) return rv; - if (nsCAutoString(sCopyString).EqualsWithConversion(aCommand)) + nsCAutoString commandName; commandName.AssignWithConversion(aCommand); + + if (commandName.Equals(sCopyString)) return editInterface->CopySelection(); - if (nsCAutoString(sSelectAllString).EqualsWithConversion(aCommand)) + if (commandName.Equals(sSelectAllString)) return editInterface->SelectAll(); - if (nsCAutoString(sCutString).EqualsWithConversion(aCommand)) + if (commandName.Equals(sCutString)) return editInterface->CutSelection(); nsCOMPtr selCont; @@ -4623,59 +4624,59 @@ NS_IMETHODIMP nsDOMWindowController::DoCommand(const PRUnichar *aCommand) if (!selCont) return rv; - if (nsCAutoString(sPasteString).EqualsWithConversion(aCommand)) + if (commandName.Equals(sPasteString)) rv = editInterface->Paste(); - else if (nsCAutoString(sScrollTopString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sScrollTopString)) rv = (mBrowseWithCaret? selCont->CompleteMove(PR_FALSE, PR_FALSE): selCont->CompleteScroll(PR_FALSE)); - else if (nsCAutoString(sScrollBottomString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sScrollBottomString)) rv = (mBrowseWithCaret? selCont->CompleteMove(PR_TRUE, PR_FALSE): selCont->CompleteScroll(PR_TRUE)); - else if (nsCAutoString(sScrollPageUpString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sScrollPageUpString)) rv = (mBrowseWithCaret? selCont->PageMove(PR_FALSE, PR_FALSE): selCont->ScrollPage(PR_FALSE)); - else if (nsCAutoString(sScrollPageDownString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sScrollPageDownString)) rv = (mBrowseWithCaret? selCont->PageMove(PR_TRUE, PR_FALSE): selCont->ScrollPage(PR_TRUE)); - else if (nsCAutoString(sScrollLineUpString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sScrollLineUpString)) rv = (mBrowseWithCaret? selCont->LineMove(PR_FALSE, PR_FALSE): selCont->ScrollLine(PR_FALSE)); - else if (nsCAutoString(sScrollLineDownString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sScrollLineDownString)) rv = (mBrowseWithCaret? selCont->LineMove(PR_TRUE, PR_FALSE): selCont->ScrollLine(PR_TRUE)); - else if (nsCAutoString(sScrollLeftString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sScrollLeftString)) rv = (mBrowseWithCaret? selCont->CharacterMove(PR_FALSE, PR_FALSE): selCont->ScrollHorizontal(PR_TRUE)); - else if (nsCAutoString(sScrollRightString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sScrollRightString)) rv = (mBrowseWithCaret? selCont->CharacterMove(PR_TRUE, PR_FALSE): selCont->ScrollHorizontal(PR_FALSE)); // These commands are so the browser can use editor navigation key bindings - // Helps with accessibility - aaronl@chorus.net - else if (nsCAutoString(sSelectCharPreviousString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sSelectCharPreviousString)) rv = selCont->CharacterMove(PR_FALSE, PR_TRUE); - else if (nsCAutoString(sSelectCharNextString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sSelectCharNextString)) rv = selCont->CharacterMove(PR_TRUE, PR_TRUE); - else if (nsCAutoString(sWordPreviousString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sWordPreviousString)) rv = selCont->WordMove(PR_FALSE, PR_FALSE); - else if (nsCAutoString(sWordNextString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sWordNextString)) rv = selCont->WordMove(PR_TRUE, PR_FALSE); - else if (nsCAutoString(sSelectWordPreviousString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sSelectWordPreviousString)) rv = selCont->WordMove(PR_FALSE, PR_TRUE); - else if (nsCAutoString(sSelectWordNextString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sSelectWordNextString)) rv = selCont->WordMove(PR_TRUE, PR_TRUE); - else if (nsCAutoString(sBeginLineString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sBeginLineString)) rv = selCont->IntraLineMove(PR_FALSE, PR_FALSE); - else if (nsCAutoString(sEndLineString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sEndLineString)) rv = selCont->IntraLineMove(PR_TRUE, PR_FALSE); - else if (nsCAutoString(sSelectBeginLineString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sSelectBeginLineString)) rv = selCont->IntraLineMove(PR_FALSE, PR_TRUE); - else if (nsCAutoString(sSelectEndLineString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sSelectEndLineString)) rv = selCont->IntraLineMove(PR_TRUE, PR_TRUE); - else if (nsCAutoString(sSelectLinePreviousString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sSelectLinePreviousString)) rv = selCont->LineMove(PR_FALSE, PR_TRUE); - else if (nsCAutoString(sSelectLineNextString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sSelectLineNextString)) rv = selCont->LineMove(PR_TRUE, PR_TRUE); - else if (nsCAutoString(sSelectMoveTopString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sSelectMoveTopString)) rv = selCont->CompleteMove(PR_FALSE, PR_TRUE); - else if (nsCAutoString(sSelectMoveBottomString).EqualsWithConversion(aCommand)) + else if (commandName.Equals(sSelectMoveBottomString)) rv = selCont->CompleteMove(PR_TRUE, PR_TRUE); return rv; } -NS_IMETHODIMP nsDOMWindowController::OnEvent(const PRUnichar *aEventName) +NS_IMETHODIMP nsDOMWindowController::OnEvent(const nsAReadableString & aEventName) { return NS_OK; } diff --git a/editor/base/nsComposerCommands.cpp b/editor/base/nsComposerCommands.cpp index 7b446cb6f969..e1c598f0d3c8 100644 --- a/editor/base/nsComposerCommands.cpp +++ b/editor/base/nsComposerCommands.cpp @@ -51,7 +51,7 @@ NS_IMPL_ISUPPORTS(nsBaseComposerCommand, NS_GET_IID(nsIControllerCommand)); //-------------------------------------------------------------------------------------------------------------------- nsresult -nsBaseComposerCommand::GetInterfaceNode(const PRUnichar* nodeID, nsIEditorShell* editorShell, nsIDOMElement **outNode) +nsBaseComposerCommand::GetInterfaceNode(const nsAReadableString & nodeID, nsIEditorShell* editorShell, nsIDOMElement **outNode) //-------------------------------------------------------------------------------------------------------------------- { *outNode = nsnull; @@ -71,11 +71,11 @@ nsBaseComposerCommand::GetInterfaceNode(const PRUnichar* nodeID, nsIEditorShell* //-------------------------------------------------------------------------------------------------------------------- nsresult -nsBaseComposerCommand::GetCommandNodeState(const PRUnichar *aCommand, nsIEditorShell* editorShell, nsString& outNodeState) +nsBaseComposerCommand::GetCommandNodeState(const nsAReadableString & aCommandName, nsIEditorShell* editorShell, nsString& outNodeState) //-------------------------------------------------------------------------------------------------------------------- { nsCOMPtr uiNode; - GetInterfaceNode(aCommand, editorShell, getter_AddRefs(uiNode)); + GetInterfaceNode(aCommandName, editorShell, getter_AddRefs(uiNode)); if (!uiNode) return NS_ERROR_FAILURE; return uiNode->GetAttribute(NS_ConvertASCIItoUCS2("state"), outNodeState); @@ -84,11 +84,11 @@ nsBaseComposerCommand::GetCommandNodeState(const PRUnichar *aCommand, nsIEditorS //-------------------------------------------------------------------------------------------------------------------- nsresult -nsBaseComposerCommand::SetCommandNodeState(const PRUnichar *aCommand, nsIEditorShell* editorShell, const nsString& inNodeState) +nsBaseComposerCommand::SetCommandNodeState(const nsAReadableString & aCommandName, nsIEditorShell* editorShell, const nsString& inNodeState) //-------------------------------------------------------------------------------------------------------------------- { nsCOMPtr uiNode; - GetInterfaceNode(aCommand, editorShell, getter_AddRefs(uiNode)); + GetInterfaceNode(aCommandName, editorShell, getter_AddRefs(uiNode)); if (!uiNode) return NS_ERROR_FAILURE; return uiNode->SetAttribute(NS_ConvertASCIItoUCS2("state"), inNodeState); @@ -113,7 +113,7 @@ nsBaseStateUpdatingCommand::~nsBaseStateUpdatingCommand() NS_IMPL_ISUPPORTS_INHERITED1(nsBaseStateUpdatingCommand, nsBaseComposerCommand, nsIStateUpdatingControllerCommand); NS_IMETHODIMP -nsBaseStateUpdatingCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsBaseStateUpdatingCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -129,7 +129,7 @@ nsBaseStateUpdatingCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISuppo *outCmdEnabled = !sourceMode; // also udpate the command state - nsresult rv = UpdateCommandState(aCommand, refCon); + nsresult rv = UpdateCommandState(aCommandName, refCon); if (NS_FAILED(rv)) { *outCmdEnabled = PR_FALSE; @@ -141,7 +141,7 @@ nsBaseStateUpdatingCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISuppo NS_IMETHODIMP -nsBaseStateUpdatingCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsBaseStateUpdatingCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); if (!editorShell) return NS_ERROR_NOT_INITIALIZED; @@ -149,11 +149,11 @@ nsBaseStateUpdatingCommand::DoCommand(const PRUnichar *aCommand, nsISupports * r nsresult rv = ToggleState(editorShell, mTagName); if (NS_FAILED(rv)) return rv; - return UpdateCommandState(aCommand, refCon); + return UpdateCommandState(aCommandName, refCon); } NS_IMETHODIMP -nsBaseStateUpdatingCommand::UpdateCommandState(const PRUnichar *aCommandName, nsISupports * refCon) +nsBaseStateUpdatingCommand::UpdateCommandState(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); nsresult rv = NS_OK; @@ -196,7 +196,7 @@ nsCloseCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon NS_IMETHODIMP -nsCloseCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsCloseCommand::DoCommand(const nsAReadableString & aCommandName, const nsAReadableString & aCommandParams, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -218,13 +218,13 @@ nsCloseCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) #endif NS_IMETHODIMP -nsPrintingCommands::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsPrintingCommands::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; if (!editorShell) return NS_OK; - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); if (cmdString.EqualsWithConversion("cmd_print")) *outCmdEnabled = PR_TRUE; else if (cmdString.EqualsWithConversion("cmd_printSetup")) @@ -241,7 +241,7 @@ nsPrintingCommands::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * re NS_IMETHODIMP -nsPrintingCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsPrintingCommands::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); if (!editorShell) return NS_ERROR_NULL_POINTER; @@ -249,7 +249,7 @@ nsPrintingCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) editorShell->FinishHTMLSource(); - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); if (cmdString.EqualsWithConversion("cmd_print")) rv = editorShell->Print(); else if (cmdString.EqualsWithConversion("cmd_printSetup")) @@ -265,7 +265,7 @@ nsPrintingCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) #endif NS_IMETHODIMP -nsPasteQuotationCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsPasteQuotationCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -282,7 +282,7 @@ nsPasteQuotationCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports NS_IMETHODIMP -nsPasteQuotationCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsPasteQuotationCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -467,7 +467,7 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam #endif NS_IMETHODIMP -nsRemoveListCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsRemoveListCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -492,7 +492,7 @@ nsRemoveListCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * r NS_IMETHODIMP -nsRemoveListCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsRemoveListCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -510,7 +510,7 @@ nsRemoveListCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) #endif NS_IMETHODIMP -nsIndentCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsIndentCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -527,7 +527,7 @@ nsIndentCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCo NS_IMETHODIMP -nsIndentCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsIndentCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -542,7 +542,7 @@ nsIndentCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) } NS_IMETHODIMP -nsOutdentCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsOutdentCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -565,7 +565,7 @@ nsOutdentCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refC NS_IMETHODIMP -nsOutdentCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsOutdentCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -597,7 +597,7 @@ nsMultiStateCommand::~nsMultiStateCommand() NS_IMPL_ISUPPORTS_INHERITED1(nsMultiStateCommand, nsBaseComposerCommand, nsIStateUpdatingControllerCommand); NS_IMETHODIMP -nsMultiStateCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsMultiStateCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -612,7 +612,7 @@ nsMultiStateCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * r } } - nsresult rv = UpdateCommandState(aCommand, refCon); + nsresult rv = UpdateCommandState(aCommandName, refCon); if (NS_FAILED(rv)) { *outCmdEnabled = PR_FALSE; return NS_OK; @@ -623,7 +623,7 @@ nsMultiStateCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * r NS_IMETHODIMP -nsMultiStateCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsMultiStateCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -633,7 +633,7 @@ nsMultiStateCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) // we have to grab the state attribute on our command node to find out // what format to set the paragraph to nsAutoString stateAttribute; - rv = GetCommandNodeState(aCommand, editorShell, stateAttribute); + rv = GetCommandNodeState(aCommandName, editorShell, stateAttribute); if (NS_FAILED(rv)) return rv; rv = SetState(editorShell, stateAttribute); @@ -644,7 +644,7 @@ nsMultiStateCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsMultiStateCommand::UpdateCommandState(const PRUnichar *aCommandName, nsISupports * refCon) +nsMultiStateCommand::UpdateCommandState(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); nsresult rv = NS_OK; @@ -924,7 +924,7 @@ nsAlignCommand::SetState(nsIEditorShell *aEditorShell, nsString& newState) #endif NS_IMETHODIMP -nsRemoveStylesCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsRemoveStylesCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -944,7 +944,7 @@ nsRemoveStylesCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * NS_IMETHODIMP -nsRemoveStylesCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsRemoveStylesCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -969,7 +969,7 @@ nsRemoveStylesCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon #endif NS_IMETHODIMP -nsIncreaseFontSizeCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsIncreaseFontSizeCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -989,7 +989,7 @@ nsIncreaseFontSizeCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISuppor NS_IMETHODIMP -nsIncreaseFontSizeCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsIncreaseFontSizeCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -1007,7 +1007,7 @@ nsIncreaseFontSizeCommand::DoCommand(const PRUnichar *aCommand, nsISupports * re #endif NS_IMETHODIMP -nsDecreaseFontSizeCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsDecreaseFontSizeCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -1027,7 +1027,7 @@ nsDecreaseFontSizeCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISuppor NS_IMETHODIMP -nsDecreaseFontSizeCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsDecreaseFontSizeCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); diff --git a/editor/base/nsComposerCommands.h b/editor/base/nsComposerCommands.h index 2c685b4c426d..a288e4d6d997 100644 --- a/editor/base/nsComposerCommands.h +++ b/editor/base/nsComposerCommands.h @@ -43,18 +43,20 @@ public: nsBaseComposerCommand(); virtual ~nsBaseComposerCommand() {} + // nsISupports NS_DECL_ISUPPORTS - NS_IMETHOD IsCommandEnabled(const PRUnichar *aCommand, nsISupports* refCon, PRBool *_retval) = 0; - NS_IMETHOD DoCommand(const PRUnichar *aCommand, nsISupports* refCon) = 0; + // nsIControllerCommand. Declared longhand so we can make them pure virtual + NS_IMETHOD IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *_retval) = 0; + NS_IMETHOD DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) = 0; protected: // utility methods to get/set the "state" attribute on the command node in the XUL - nsresult GetInterfaceNode(const PRUnichar* nodeID, nsIEditorShell* editorShell, nsIDOMElement **outNode); + nsresult GetInterfaceNode(const nsAReadableString & nodeID, nsIEditorShell* editorShell, nsIDOMElement **outNode); - nsresult GetCommandNodeState(const PRUnichar *aCommand, nsIEditorShell* editorShell, nsString& outNodeState); - nsresult SetCommandNodeState(const PRUnichar *aCommand, nsIEditorShell* editorShell, const nsString& inNodeState); + nsresult GetCommandNodeState(const nsAReadableString & aCommandName, nsIEditorShell* editorShell, nsString& outNodeState); + nsresult SetCommandNodeState(const nsAReadableString & aCommandName, nsIEditorShell* editorShell, const nsString& inNodeState); }; diff --git a/editor/base/nsEditorCommands.cpp b/editor/base/nsEditorCommands.cpp index 1eccf701997d..0b3b470c8e37 100644 --- a/editor/base/nsEditorCommands.cpp +++ b/editor/base/nsEditorCommands.cpp @@ -46,9 +46,9 @@ NS_IMPL_ISUPPORTS(nsBaseEditorCommand, NS_GET_IID(nsIControllerCommand)); NS_IMETHODIMP -nsUndoCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsUndoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) { @@ -60,9 +60,9 @@ nsUndoCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, NS_IMETHODIMP -nsUndoCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsUndoCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (aEditor) return aEditor->Undo(1); @@ -71,9 +71,9 @@ nsUndoCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsRedoCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsRedoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) { @@ -85,9 +85,9 @@ nsRedoCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, NS_IMETHODIMP -nsRedoCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsRedoCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (aEditor) return aEditor->Redo(1); @@ -96,9 +96,9 @@ nsRedoCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsCutCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsCutCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) return aEditor->CanCut(*outCmdEnabled); @@ -108,9 +108,9 @@ nsCutCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, NS_IMETHODIMP -nsCutCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsCutCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (aEditor) return aEditor->Cut(); @@ -119,18 +119,18 @@ nsCutCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsCutOrDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsCutOrDeleteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr editor = do_QueryInterface(refCon); + nsCOMPtr editor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = (editor != nsnull); return NS_OK; } NS_IMETHODIMP -nsCutOrDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsCutOrDeleteCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr editor = do_QueryInterface(refCon); + nsCOMPtr editor = do_QueryInterface(aCommandRefCon); if (editor) { nsCOMPtr selection; @@ -150,9 +150,9 @@ nsCutOrDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsCopyCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsCopyCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) return aEditor->CanCopy(*outCmdEnabled); @@ -162,9 +162,9 @@ nsCopyCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, NS_IMETHODIMP -nsCopyCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsCopyCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (aEditor) return aEditor->Copy(); @@ -173,18 +173,18 @@ nsCopyCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsCopyOrDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsCopyOrDeleteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr editor = do_QueryInterface(refCon); + nsCOMPtr editor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = (editor != nsnull); return NS_OK; } NS_IMETHODIMP -nsCopyOrDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsCopyOrDeleteCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr editor = do_QueryInterface(refCon); + nsCOMPtr editor = do_QueryInterface(aCommandRefCon); if (editor) { nsCOMPtr selection; @@ -204,9 +204,9 @@ nsCopyOrDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon NS_IMETHODIMP -nsPasteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsPasteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) return aEditor->CanPaste(nsIClipboard::kGlobalClipboard, *outCmdEnabled); @@ -216,14 +216,14 @@ nsPasteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon NS_IMETHODIMP -nsPasteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsPasteCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (!aEditor) return NS_ERROR_FAILURE; nsresult rv = NS_OK; - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); if (cmdString.EqualsWithConversion("cmd_paste")) rv = aEditor->Paste(nsIClipboard::kGlobalClipboard); else if (cmdString.EqualsWithConversion("cmd_pasteQuote")) @@ -237,9 +237,9 @@ nsPasteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) } NS_IMETHODIMP -nsDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsDeleteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; // we can delete when we can cut if (!aEditor) @@ -247,7 +247,7 @@ nsDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCo nsresult rv = NS_OK; - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); if (cmdString.EqualsWithConversion("cmd_delete")) rv = aEditor->CanCut(*outCmdEnabled); @@ -269,13 +269,13 @@ nsDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCo NS_IMETHODIMP -nsDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsDeleteCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (!aEditor) return NS_ERROR_FAILURE; - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); nsIEditor::EDirection deleteDir = nsIEditor::eNone; @@ -298,9 +298,9 @@ nsDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) } NS_IMETHODIMP -nsSelectAllCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsSelectAllCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) *outCmdEnabled = PR_TRUE; // you can always select all @@ -310,9 +310,9 @@ nsSelectAllCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * re NS_IMETHODIMP -nsSelectAllCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsSelectAllCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (aEditor) return aEditor->SelectAll(); @@ -320,9 +320,9 @@ nsSelectAllCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) } NS_IMETHODIMP -nsSelectionMoveCommands::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsSelectionMoveCommands::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (!aEditor) return NS_ERROR_FAILURE; @@ -333,9 +333,9 @@ nsSelectionMoveCommands::IsCommandEnabled(const PRUnichar *aCommand, nsISupports NS_IMETHODIMP -nsSelectionMoveCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsSelectionMoveCommands::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (!aEditor) return NS_ERROR_FAILURE; @@ -346,7 +346,7 @@ nsSelectionMoveCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refC if (NS_FAILED(rv) || !selCont) return rv?rv:NS_ERROR_FAILURE; - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); // complete scroll commands if (cmdString.EqualsWithConversion("cmd_scrollTop")) diff --git a/editor/base/nsEditorCommands.h b/editor/base/nsEditorCommands.h index 147688917f7a..c46275ba072b 100644 --- a/editor/base/nsEditorCommands.h +++ b/editor/base/nsEditorCommands.h @@ -40,8 +40,8 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD IsCommandEnabled(const PRUnichar *aCommand, nsISupports* refCon, PRBool *_retval) = 0; - NS_IMETHOD DoCommand(const PRUnichar *aCommand, nsISupports* refCon) = 0; + NS_IMETHOD IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *_retval) = 0; + NS_IMETHOD DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) = 0; }; @@ -50,7 +50,8 @@ public: class _cmd : public nsBaseEditorCommand \ { \ public: \ - NS_DECL_NSICONTROLLERCOMMAND \ + NS_IMETHOD IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *_retval); \ + NS_IMETHOD DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon); \ }; @@ -74,14 +75,14 @@ NS_DECL_EDITOR_COMMAND(nsSelectionMoveCommands) #if 0 // template for new command NS_IMETHODIMP -nsFooCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsFooCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *_retval) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsFooCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsFooCommand::DoCommand(const nsAReadableString & aCommandName, const nsAReadableString & aCommandParams, nsISupports *aCommandRefCon) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/editor/base/nsEditorController.cpp b/editor/base/nsEditorController.cpp index c37da53869dc..331850b8307d 100644 --- a/editor/base/nsEditorController.cpp +++ b/editor/base/nsEditorController.cpp @@ -22,6 +22,7 @@ * Ryan Cassin */ +#include "nsString.h" #include "nsIComponentManager.h" #include "nsEditorController.h" #include "nsIEditor.h" @@ -98,7 +99,7 @@ NS_IMETHODIMP nsEditorController::GetInterface(const nsIID & aIID, void * *resul _cmdClass* theCmd; \ NS_NEWXPCOM(theCmd, _cmdClass); \ if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \ - rv = inCommandManager->RegisterCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), \ + rv = inCommandManager->RegisterCommand(NS_LITERAL_STRING(_cmdName), \ NS_STATIC_CAST(nsIControllerCommand *, theCmd)); \ } @@ -107,15 +108,15 @@ NS_IMETHODIMP nsEditorController::GetInterface(const nsIID & aIID, void * *resul _cmdClass* theCmd; \ NS_NEWXPCOM(theCmd, _cmdClass); \ if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \ - rv = inCommandManager->RegisterCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), \ + rv = inCommandManager->RegisterCommand(NS_LITERAL_STRING(_cmdName), \ NS_STATIC_CAST(nsIControllerCommand *, theCmd)); #define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \ - rv = inCommandManager->RegisterCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), \ + rv = inCommandManager->RegisterCommand(NS_LITERAL_STRING(_cmdName), \ NS_STATIC_CAST(nsIControllerCommand *, theCmd)); #define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName) \ - rv = inCommandManager->RegisterCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), \ + rv = inCommandManager->RegisterCommand(NS_LITERAL_STRING(_cmdName), \ NS_STATIC_CAST(nsIControllerCommand *, theCmd)); \ } @@ -185,27 +186,25 @@ nsresult nsEditorController::RegisterEditorCommands(nsIControllerCommandManager * nsIController * ======================================================================= */ -NS_IMETHODIMP nsEditorController::IsCommandEnabled(const PRUnichar *aCommand, PRBool *aResult) +NS_IMETHODIMP nsEditorController::IsCommandEnabled(const nsAReadableString & aCommand, PRBool *aResult) { NS_ENSURE_ARG_POINTER(aResult); return mCommandManager->IsCommandEnabled(aCommand, mCommandRefCon, aResult); } -NS_IMETHODIMP nsEditorController::SupportsCommand(const PRUnichar *aCommand, PRBool *aResult) +NS_IMETHODIMP nsEditorController::SupportsCommand(const nsAReadableString & aCommand, PRBool *aResult) { NS_ENSURE_ARG_POINTER(aResult); return mCommandManager->SupportsCommand(aCommand, mCommandRefCon, aResult); } -NS_IMETHODIMP nsEditorController::DoCommand(const PRUnichar *aCommand) +NS_IMETHODIMP nsEditorController::DoCommand(const nsAReadableString & aCommand) { return mCommandManager->DoCommand(aCommand, mCommandRefCon); } -NS_IMETHODIMP nsEditorController::OnEvent(const PRUnichar *aEventName) +NS_IMETHODIMP nsEditorController::OnEvent(const nsAReadableString & aEventName) { - NS_ENSURE_ARG_POINTER(aEventName); - return NS_OK; } @@ -282,7 +281,7 @@ NS_IMETHODIMP nsComposerController::Init(nsISupports *aCommandRefCon) { \ _cmdClass* theCmd = new _cmdClass(_styleTag); \ if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \ - rv = inCommandManager->RegisterCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), \ + rv = inCommandManager->RegisterCommand(NS_LITERAL_STRING(_cmdName), \ NS_STATIC_CAST(nsIControllerCommand *, theCmd)); \ } diff --git a/editor/base/nsEditorShell.cpp b/editor/base/nsEditorShell.cpp index 48fa00f06816..ec302a60a97f 100644 --- a/editor/base/nsEditorShell.cpp +++ b/editor/base/nsEditorShell.cpp @@ -1476,8 +1476,7 @@ nsEditorShell::FinishHTMLSource(void) if (mHTMLSourceMode) { // Call the JS command to convert and switch to previous edit mode - nsAutoString command(NS_LITERAL_STRING("cmd_FinishHTMLSource")); - return DoControllerCommand(command); + return DoControllerCommand(NS_LITERAL_STRING("cmd_FinishHTMLSource")); } return NS_OK; } @@ -2180,8 +2179,7 @@ nsEditorShell::UpdateWindowTitleAndRecentMenu(PRBool aSaveToPrefs) // For now, don't update the menu at all if aSaveToPrefs is false if (aSaveToPrefs) { - nsAutoString commandName(NS_LITERAL_STRING("cmd_buildRecentPagesMenu")); - res = DoControllerCommand(commandName); + res = DoControllerCommand(NS_LITERAL_STRING("cmd_buildRecentPagesMenu")); } return res; @@ -3003,7 +3001,7 @@ nsEditorShell::ConfirmWithCancel(const nsString& aTitle, const nsString& aQuesti { // Stuff in Parameters block->SetString( nsICommonDialogs::eMsg, aQuestion.GetUnicode()); - nsAutoString url; url.AssignWithConversion( "chrome://global/skin/question-icon.gif" ); + nsAutoString url; url.AssignWithConversion( "chrome://global/skin/question-icon.gif" ); block->SetString( nsICommonDialogs::eIconURL, url.GetUnicode()); nsAutoString yesStr, noStr; @@ -5389,15 +5387,12 @@ nsEditorShell::HandleMouseClickOnElement(nsIDOMElement *aElement, PRInt32 aClick // For double-click, edit element properties if (aClickCount == 2) { - nsAutoString commandName; - // In "All Tags" mode, use AdvancedProperties, // in others use appriate object property dialog - if (mDisplayMode != eDisplayModeAllTags) - commandName = NS_LITERAL_STRING("cmd_objectProperties"); - else - commandName = NS_LITERAL_STRING("cmd_advancedProperties"); - + nsAReadableString &commandName = (mDisplayMode != eDisplayModeAllTags) ? + NS_LITERAL_STRING("cmd_objectProperties") : + NS_LITERAL_STRING("cmd_advancedProperties"); + rv = DoControllerCommand(commandName); if (NS_SUCCEEDED(rv)) @@ -5408,7 +5403,7 @@ nsEditorShell::HandleMouseClickOnElement(nsIDOMElement *aElement, PRInt32 aClick } nsresult -nsEditorShell::DoControllerCommand(nsString& aCommand) +nsEditorShell::DoControllerCommand(const nsAReadableString& aCommand) { // Get the list of controllers... nsCOMPtr controllers; @@ -5424,7 +5419,7 @@ nsEditorShell::DoControllerCommand(nsString& aCommand) //... then find the specific controller supporting desired command nsCOMPtr controller; - rv = controllers->GetControllerForCommand(aCommand.GetUnicode(), getter_AddRefs(controller)); + rv = controllers->GetControllerForCommand(aCommand, getter_AddRefs(controller)); if (NS_SUCCEEDED(rv)) { @@ -5432,7 +5427,7 @@ nsEditorShell::DoControllerCommand(nsString& aCommand) nsCOMPtr composerController = do_QueryInterface(controller); // Execute the command - rv = composerController->DoCommand(aCommand.GetUnicode()); + rv = composerController->DoCommand(aCommand); } return rv; } diff --git a/editor/base/nsEditorShell.h b/editor/base/nsEditorShell.h index 26b7136dfa30..20d0e165c643 100644 --- a/editor/base/nsEditorShell.h +++ b/editor/base/nsEditorShell.h @@ -131,7 +131,7 @@ class nsEditorShell : public nsIEditorShell, nsresult RemoveOneProperty(const nsString& aProp, const nsString& aAttr); nsresult DoFind(PRBool aFindNext); // To allow executing JavaScript commands from C++ via nsIEditorControler interface - nsresult DoControllerCommand(nsString& aCommand); + nsresult DoControllerCommand(const nsAReadableString& aCommand); void Alert(const nsString& aTitle, const nsString& aMsg); // Bring up a Yes/No dialog WE REALLY NEED A Yes/No/Cancel dialog and would like to set our own caption as well! diff --git a/editor/composer/src/nsComposerCommands.cpp b/editor/composer/src/nsComposerCommands.cpp index 7b446cb6f969..e1c598f0d3c8 100644 --- a/editor/composer/src/nsComposerCommands.cpp +++ b/editor/composer/src/nsComposerCommands.cpp @@ -51,7 +51,7 @@ NS_IMPL_ISUPPORTS(nsBaseComposerCommand, NS_GET_IID(nsIControllerCommand)); //-------------------------------------------------------------------------------------------------------------------- nsresult -nsBaseComposerCommand::GetInterfaceNode(const PRUnichar* nodeID, nsIEditorShell* editorShell, nsIDOMElement **outNode) +nsBaseComposerCommand::GetInterfaceNode(const nsAReadableString & nodeID, nsIEditorShell* editorShell, nsIDOMElement **outNode) //-------------------------------------------------------------------------------------------------------------------- { *outNode = nsnull; @@ -71,11 +71,11 @@ nsBaseComposerCommand::GetInterfaceNode(const PRUnichar* nodeID, nsIEditorShell* //-------------------------------------------------------------------------------------------------------------------- nsresult -nsBaseComposerCommand::GetCommandNodeState(const PRUnichar *aCommand, nsIEditorShell* editorShell, nsString& outNodeState) +nsBaseComposerCommand::GetCommandNodeState(const nsAReadableString & aCommandName, nsIEditorShell* editorShell, nsString& outNodeState) //-------------------------------------------------------------------------------------------------------------------- { nsCOMPtr uiNode; - GetInterfaceNode(aCommand, editorShell, getter_AddRefs(uiNode)); + GetInterfaceNode(aCommandName, editorShell, getter_AddRefs(uiNode)); if (!uiNode) return NS_ERROR_FAILURE; return uiNode->GetAttribute(NS_ConvertASCIItoUCS2("state"), outNodeState); @@ -84,11 +84,11 @@ nsBaseComposerCommand::GetCommandNodeState(const PRUnichar *aCommand, nsIEditorS //-------------------------------------------------------------------------------------------------------------------- nsresult -nsBaseComposerCommand::SetCommandNodeState(const PRUnichar *aCommand, nsIEditorShell* editorShell, const nsString& inNodeState) +nsBaseComposerCommand::SetCommandNodeState(const nsAReadableString & aCommandName, nsIEditorShell* editorShell, const nsString& inNodeState) //-------------------------------------------------------------------------------------------------------------------- { nsCOMPtr uiNode; - GetInterfaceNode(aCommand, editorShell, getter_AddRefs(uiNode)); + GetInterfaceNode(aCommandName, editorShell, getter_AddRefs(uiNode)); if (!uiNode) return NS_ERROR_FAILURE; return uiNode->SetAttribute(NS_ConvertASCIItoUCS2("state"), inNodeState); @@ -113,7 +113,7 @@ nsBaseStateUpdatingCommand::~nsBaseStateUpdatingCommand() NS_IMPL_ISUPPORTS_INHERITED1(nsBaseStateUpdatingCommand, nsBaseComposerCommand, nsIStateUpdatingControllerCommand); NS_IMETHODIMP -nsBaseStateUpdatingCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsBaseStateUpdatingCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -129,7 +129,7 @@ nsBaseStateUpdatingCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISuppo *outCmdEnabled = !sourceMode; // also udpate the command state - nsresult rv = UpdateCommandState(aCommand, refCon); + nsresult rv = UpdateCommandState(aCommandName, refCon); if (NS_FAILED(rv)) { *outCmdEnabled = PR_FALSE; @@ -141,7 +141,7 @@ nsBaseStateUpdatingCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISuppo NS_IMETHODIMP -nsBaseStateUpdatingCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsBaseStateUpdatingCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); if (!editorShell) return NS_ERROR_NOT_INITIALIZED; @@ -149,11 +149,11 @@ nsBaseStateUpdatingCommand::DoCommand(const PRUnichar *aCommand, nsISupports * r nsresult rv = ToggleState(editorShell, mTagName); if (NS_FAILED(rv)) return rv; - return UpdateCommandState(aCommand, refCon); + return UpdateCommandState(aCommandName, refCon); } NS_IMETHODIMP -nsBaseStateUpdatingCommand::UpdateCommandState(const PRUnichar *aCommandName, nsISupports * refCon) +nsBaseStateUpdatingCommand::UpdateCommandState(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); nsresult rv = NS_OK; @@ -196,7 +196,7 @@ nsCloseCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon NS_IMETHODIMP -nsCloseCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsCloseCommand::DoCommand(const nsAReadableString & aCommandName, const nsAReadableString & aCommandParams, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -218,13 +218,13 @@ nsCloseCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) #endif NS_IMETHODIMP -nsPrintingCommands::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsPrintingCommands::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; if (!editorShell) return NS_OK; - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); if (cmdString.EqualsWithConversion("cmd_print")) *outCmdEnabled = PR_TRUE; else if (cmdString.EqualsWithConversion("cmd_printSetup")) @@ -241,7 +241,7 @@ nsPrintingCommands::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * re NS_IMETHODIMP -nsPrintingCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsPrintingCommands::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); if (!editorShell) return NS_ERROR_NULL_POINTER; @@ -249,7 +249,7 @@ nsPrintingCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) editorShell->FinishHTMLSource(); - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); if (cmdString.EqualsWithConversion("cmd_print")) rv = editorShell->Print(); else if (cmdString.EqualsWithConversion("cmd_printSetup")) @@ -265,7 +265,7 @@ nsPrintingCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) #endif NS_IMETHODIMP -nsPasteQuotationCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsPasteQuotationCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -282,7 +282,7 @@ nsPasteQuotationCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports NS_IMETHODIMP -nsPasteQuotationCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsPasteQuotationCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -467,7 +467,7 @@ nsListItemCommand::ToggleState(nsIEditorShell *aEditorShell, const char* aTagNam #endif NS_IMETHODIMP -nsRemoveListCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsRemoveListCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -492,7 +492,7 @@ nsRemoveListCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * r NS_IMETHODIMP -nsRemoveListCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsRemoveListCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -510,7 +510,7 @@ nsRemoveListCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) #endif NS_IMETHODIMP -nsIndentCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsIndentCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -527,7 +527,7 @@ nsIndentCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCo NS_IMETHODIMP -nsIndentCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsIndentCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -542,7 +542,7 @@ nsIndentCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) } NS_IMETHODIMP -nsOutdentCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsOutdentCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -565,7 +565,7 @@ nsOutdentCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refC NS_IMETHODIMP -nsOutdentCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsOutdentCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -597,7 +597,7 @@ nsMultiStateCommand::~nsMultiStateCommand() NS_IMPL_ISUPPORTS_INHERITED1(nsMultiStateCommand, nsBaseComposerCommand, nsIStateUpdatingControllerCommand); NS_IMETHODIMP -nsMultiStateCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsMultiStateCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -612,7 +612,7 @@ nsMultiStateCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * r } } - nsresult rv = UpdateCommandState(aCommand, refCon); + nsresult rv = UpdateCommandState(aCommandName, refCon); if (NS_FAILED(rv)) { *outCmdEnabled = PR_FALSE; return NS_OK; @@ -623,7 +623,7 @@ nsMultiStateCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * r NS_IMETHODIMP -nsMultiStateCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsMultiStateCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -633,7 +633,7 @@ nsMultiStateCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) // we have to grab the state attribute on our command node to find out // what format to set the paragraph to nsAutoString stateAttribute; - rv = GetCommandNodeState(aCommand, editorShell, stateAttribute); + rv = GetCommandNodeState(aCommandName, editorShell, stateAttribute); if (NS_FAILED(rv)) return rv; rv = SetState(editorShell, stateAttribute); @@ -644,7 +644,7 @@ nsMultiStateCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsMultiStateCommand::UpdateCommandState(const PRUnichar *aCommandName, nsISupports * refCon) +nsMultiStateCommand::UpdateCommandState(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); nsresult rv = NS_OK; @@ -924,7 +924,7 @@ nsAlignCommand::SetState(nsIEditorShell *aEditorShell, nsString& newState) #endif NS_IMETHODIMP -nsRemoveStylesCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsRemoveStylesCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -944,7 +944,7 @@ nsRemoveStylesCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * NS_IMETHODIMP -nsRemoveStylesCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsRemoveStylesCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -969,7 +969,7 @@ nsRemoveStylesCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon #endif NS_IMETHODIMP -nsIncreaseFontSizeCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsIncreaseFontSizeCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -989,7 +989,7 @@ nsIncreaseFontSizeCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISuppor NS_IMETHODIMP -nsIncreaseFontSizeCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsIncreaseFontSizeCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); @@ -1007,7 +1007,7 @@ nsIncreaseFontSizeCommand::DoCommand(const PRUnichar *aCommand, nsISupports * re #endif NS_IMETHODIMP -nsDecreaseFontSizeCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsDecreaseFontSizeCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *refCon, PRBool *outCmdEnabled) { nsCOMPtr editorShell = do_QueryInterface(refCon); *outCmdEnabled = PR_FALSE; @@ -1027,7 +1027,7 @@ nsDecreaseFontSizeCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISuppor NS_IMETHODIMP -nsDecreaseFontSizeCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsDecreaseFontSizeCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *refCon) { nsCOMPtr editorShell = do_QueryInterface(refCon); diff --git a/editor/composer/src/nsComposerCommands.h b/editor/composer/src/nsComposerCommands.h index 2c685b4c426d..a288e4d6d997 100644 --- a/editor/composer/src/nsComposerCommands.h +++ b/editor/composer/src/nsComposerCommands.h @@ -43,18 +43,20 @@ public: nsBaseComposerCommand(); virtual ~nsBaseComposerCommand() {} + // nsISupports NS_DECL_ISUPPORTS - NS_IMETHOD IsCommandEnabled(const PRUnichar *aCommand, nsISupports* refCon, PRBool *_retval) = 0; - NS_IMETHOD DoCommand(const PRUnichar *aCommand, nsISupports* refCon) = 0; + // nsIControllerCommand. Declared longhand so we can make them pure virtual + NS_IMETHOD IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *_retval) = 0; + NS_IMETHOD DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) = 0; protected: // utility methods to get/set the "state" attribute on the command node in the XUL - nsresult GetInterfaceNode(const PRUnichar* nodeID, nsIEditorShell* editorShell, nsIDOMElement **outNode); + nsresult GetInterfaceNode(const nsAReadableString & nodeID, nsIEditorShell* editorShell, nsIDOMElement **outNode); - nsresult GetCommandNodeState(const PRUnichar *aCommand, nsIEditorShell* editorShell, nsString& outNodeState); - nsresult SetCommandNodeState(const PRUnichar *aCommand, nsIEditorShell* editorShell, const nsString& inNodeState); + nsresult GetCommandNodeState(const nsAReadableString & aCommandName, nsIEditorShell* editorShell, nsString& outNodeState); + nsresult SetCommandNodeState(const nsAReadableString & aCommandName, nsIEditorShell* editorShell, const nsString& inNodeState); }; diff --git a/editor/composer/src/nsEditorShell.cpp b/editor/composer/src/nsEditorShell.cpp index 48fa00f06816..ec302a60a97f 100644 --- a/editor/composer/src/nsEditorShell.cpp +++ b/editor/composer/src/nsEditorShell.cpp @@ -1476,8 +1476,7 @@ nsEditorShell::FinishHTMLSource(void) if (mHTMLSourceMode) { // Call the JS command to convert and switch to previous edit mode - nsAutoString command(NS_LITERAL_STRING("cmd_FinishHTMLSource")); - return DoControllerCommand(command); + return DoControllerCommand(NS_LITERAL_STRING("cmd_FinishHTMLSource")); } return NS_OK; } @@ -2180,8 +2179,7 @@ nsEditorShell::UpdateWindowTitleAndRecentMenu(PRBool aSaveToPrefs) // For now, don't update the menu at all if aSaveToPrefs is false if (aSaveToPrefs) { - nsAutoString commandName(NS_LITERAL_STRING("cmd_buildRecentPagesMenu")); - res = DoControllerCommand(commandName); + res = DoControllerCommand(NS_LITERAL_STRING("cmd_buildRecentPagesMenu")); } return res; @@ -3003,7 +3001,7 @@ nsEditorShell::ConfirmWithCancel(const nsString& aTitle, const nsString& aQuesti { // Stuff in Parameters block->SetString( nsICommonDialogs::eMsg, aQuestion.GetUnicode()); - nsAutoString url; url.AssignWithConversion( "chrome://global/skin/question-icon.gif" ); + nsAutoString url; url.AssignWithConversion( "chrome://global/skin/question-icon.gif" ); block->SetString( nsICommonDialogs::eIconURL, url.GetUnicode()); nsAutoString yesStr, noStr; @@ -5389,15 +5387,12 @@ nsEditorShell::HandleMouseClickOnElement(nsIDOMElement *aElement, PRInt32 aClick // For double-click, edit element properties if (aClickCount == 2) { - nsAutoString commandName; - // In "All Tags" mode, use AdvancedProperties, // in others use appriate object property dialog - if (mDisplayMode != eDisplayModeAllTags) - commandName = NS_LITERAL_STRING("cmd_objectProperties"); - else - commandName = NS_LITERAL_STRING("cmd_advancedProperties"); - + nsAReadableString &commandName = (mDisplayMode != eDisplayModeAllTags) ? + NS_LITERAL_STRING("cmd_objectProperties") : + NS_LITERAL_STRING("cmd_advancedProperties"); + rv = DoControllerCommand(commandName); if (NS_SUCCEEDED(rv)) @@ -5408,7 +5403,7 @@ nsEditorShell::HandleMouseClickOnElement(nsIDOMElement *aElement, PRInt32 aClick } nsresult -nsEditorShell::DoControllerCommand(nsString& aCommand) +nsEditorShell::DoControllerCommand(const nsAReadableString& aCommand) { // Get the list of controllers... nsCOMPtr controllers; @@ -5424,7 +5419,7 @@ nsEditorShell::DoControllerCommand(nsString& aCommand) //... then find the specific controller supporting desired command nsCOMPtr controller; - rv = controllers->GetControllerForCommand(aCommand.GetUnicode(), getter_AddRefs(controller)); + rv = controllers->GetControllerForCommand(aCommand, getter_AddRefs(controller)); if (NS_SUCCEEDED(rv)) { @@ -5432,7 +5427,7 @@ nsEditorShell::DoControllerCommand(nsString& aCommand) nsCOMPtr composerController = do_QueryInterface(controller); // Execute the command - rv = composerController->DoCommand(aCommand.GetUnicode()); + rv = composerController->DoCommand(aCommand); } return rv; } diff --git a/editor/composer/src/nsEditorShell.h b/editor/composer/src/nsEditorShell.h index 26b7136dfa30..20d0e165c643 100644 --- a/editor/composer/src/nsEditorShell.h +++ b/editor/composer/src/nsEditorShell.h @@ -131,7 +131,7 @@ class nsEditorShell : public nsIEditorShell, nsresult RemoveOneProperty(const nsString& aProp, const nsString& aAttr); nsresult DoFind(PRBool aFindNext); // To allow executing JavaScript commands from C++ via nsIEditorControler interface - nsresult DoControllerCommand(nsString& aCommand); + nsresult DoControllerCommand(const nsAReadableString& aCommand); void Alert(const nsString& aTitle, const nsString& aMsg); // Bring up a Yes/No dialog WE REALLY NEED A Yes/No/Cancel dialog and would like to set our own caption as well! diff --git a/editor/idl/nsIEditorController.idl b/editor/idl/nsIEditorController.idl index 4eac888e9875..8408c0af4206 100644 --- a/editor/idl/nsIEditorController.idl +++ b/editor/idl/nsIEditorController.idl @@ -43,7 +43,7 @@ interface nsIEditorController : nsISupports /** Execute the command identified by the ID string * param: commandName ID string of the command */ - void DoCommand( in wstring commandName ); + void DoCommand( in DOMString commandName ); /* Should we expose nsEditorController::IsCommandEnabled() as well? */ }; diff --git a/editor/libeditor/base/nsEditorCommands.cpp b/editor/libeditor/base/nsEditorCommands.cpp index 1eccf701997d..0b3b470c8e37 100644 --- a/editor/libeditor/base/nsEditorCommands.cpp +++ b/editor/libeditor/base/nsEditorCommands.cpp @@ -46,9 +46,9 @@ NS_IMPL_ISUPPORTS(nsBaseEditorCommand, NS_GET_IID(nsIControllerCommand)); NS_IMETHODIMP -nsUndoCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsUndoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) { @@ -60,9 +60,9 @@ nsUndoCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, NS_IMETHODIMP -nsUndoCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsUndoCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (aEditor) return aEditor->Undo(1); @@ -71,9 +71,9 @@ nsUndoCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsRedoCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsRedoCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) { @@ -85,9 +85,9 @@ nsRedoCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, NS_IMETHODIMP -nsRedoCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsRedoCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (aEditor) return aEditor->Redo(1); @@ -96,9 +96,9 @@ nsRedoCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsCutCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsCutCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) return aEditor->CanCut(*outCmdEnabled); @@ -108,9 +108,9 @@ nsCutCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, NS_IMETHODIMP -nsCutCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsCutCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (aEditor) return aEditor->Cut(); @@ -119,18 +119,18 @@ nsCutCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsCutOrDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsCutOrDeleteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr editor = do_QueryInterface(refCon); + nsCOMPtr editor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = (editor != nsnull); return NS_OK; } NS_IMETHODIMP -nsCutOrDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsCutOrDeleteCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr editor = do_QueryInterface(refCon); + nsCOMPtr editor = do_QueryInterface(aCommandRefCon); if (editor) { nsCOMPtr selection; @@ -150,9 +150,9 @@ nsCutOrDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsCopyCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsCopyCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) return aEditor->CanCopy(*outCmdEnabled); @@ -162,9 +162,9 @@ nsCopyCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, NS_IMETHODIMP -nsCopyCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsCopyCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (aEditor) return aEditor->Copy(); @@ -173,18 +173,18 @@ nsCopyCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) NS_IMETHODIMP -nsCopyOrDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsCopyOrDeleteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr editor = do_QueryInterface(refCon); + nsCOMPtr editor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = (editor != nsnull); return NS_OK; } NS_IMETHODIMP -nsCopyOrDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsCopyOrDeleteCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr editor = do_QueryInterface(refCon); + nsCOMPtr editor = do_QueryInterface(aCommandRefCon); if (editor) { nsCOMPtr selection; @@ -204,9 +204,9 @@ nsCopyOrDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon NS_IMETHODIMP -nsPasteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsPasteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) return aEditor->CanPaste(nsIClipboard::kGlobalClipboard, *outCmdEnabled); @@ -216,14 +216,14 @@ nsPasteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon NS_IMETHODIMP -nsPasteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsPasteCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (!aEditor) return NS_ERROR_FAILURE; nsresult rv = NS_OK; - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); if (cmdString.EqualsWithConversion("cmd_paste")) rv = aEditor->Paste(nsIClipboard::kGlobalClipboard); else if (cmdString.EqualsWithConversion("cmd_pasteQuote")) @@ -237,9 +237,9 @@ nsPasteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) } NS_IMETHODIMP -nsDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsDeleteCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; // we can delete when we can cut if (!aEditor) @@ -247,7 +247,7 @@ nsDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCo nsresult rv = NS_OK; - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); if (cmdString.EqualsWithConversion("cmd_delete")) rv = aEditor->CanCut(*outCmdEnabled); @@ -269,13 +269,13 @@ nsDeleteCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCo NS_IMETHODIMP -nsDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsDeleteCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (!aEditor) return NS_ERROR_FAILURE; - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); nsIEditor::EDirection deleteDir = nsIEditor::eNone; @@ -298,9 +298,9 @@ nsDeleteCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) } NS_IMETHODIMP -nsSelectAllCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsSelectAllCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (aEditor) *outCmdEnabled = PR_TRUE; // you can always select all @@ -310,9 +310,9 @@ nsSelectAllCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * re NS_IMETHODIMP -nsSelectAllCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsSelectAllCommand::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (aEditor) return aEditor->SelectAll(); @@ -320,9 +320,9 @@ nsSelectAllCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) } NS_IMETHODIMP -nsSelectionMoveCommands::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsSelectionMoveCommands::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *outCmdEnabled) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); *outCmdEnabled = PR_FALSE; if (!aEditor) return NS_ERROR_FAILURE; @@ -333,9 +333,9 @@ nsSelectionMoveCommands::IsCommandEnabled(const PRUnichar *aCommand, nsISupports NS_IMETHODIMP -nsSelectionMoveCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsSelectionMoveCommands::DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) { - nsCOMPtr aEditor = do_QueryInterface(refCon); + nsCOMPtr aEditor = do_QueryInterface(aCommandRefCon); if (!aEditor) return NS_ERROR_FAILURE; @@ -346,7 +346,7 @@ nsSelectionMoveCommands::DoCommand(const PRUnichar *aCommand, nsISupports * refC if (NS_FAILED(rv) || !selCont) return rv?rv:NS_ERROR_FAILURE; - nsAutoString cmdString(aCommand); + nsAutoString cmdString(aCommandName); // complete scroll commands if (cmdString.EqualsWithConversion("cmd_scrollTop")) diff --git a/editor/libeditor/base/nsEditorCommands.h b/editor/libeditor/base/nsEditorCommands.h index 147688917f7a..c46275ba072b 100644 --- a/editor/libeditor/base/nsEditorCommands.h +++ b/editor/libeditor/base/nsEditorCommands.h @@ -40,8 +40,8 @@ public: NS_DECL_ISUPPORTS - NS_IMETHOD IsCommandEnabled(const PRUnichar *aCommand, nsISupports* refCon, PRBool *_retval) = 0; - NS_IMETHOD DoCommand(const PRUnichar *aCommand, nsISupports* refCon) = 0; + NS_IMETHOD IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *_retval) = 0; + NS_IMETHOD DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon) = 0; }; @@ -50,7 +50,8 @@ public: class _cmd : public nsBaseEditorCommand \ { \ public: \ - NS_DECL_NSICONTROLLERCOMMAND \ + NS_IMETHOD IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *_retval); \ + NS_IMETHOD DoCommand(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon); \ }; @@ -74,14 +75,14 @@ NS_DECL_EDITOR_COMMAND(nsSelectionMoveCommands) #if 0 // template for new command NS_IMETHODIMP -nsFooCommand::IsCommandEnabled(const PRUnichar *aCommand, nsISupports * refCon, PRBool *outCmdEnabled) +nsFooCommand::IsCommandEnabled(const nsAReadableString & aCommandName, nsISupports *aCommandRefCon, PRBool *_retval) { return NS_ERROR_NOT_IMPLEMENTED; } NS_IMETHODIMP -nsFooCommand::DoCommand(const PRUnichar *aCommand, nsISupports * refCon) +nsFooCommand::DoCommand(const nsAReadableString & aCommandName, const nsAReadableString & aCommandParams, nsISupports *aCommandRefCon) { return NS_ERROR_NOT_IMPLEMENTED; } diff --git a/editor/libeditor/base/nsEditorController.cpp b/editor/libeditor/base/nsEditorController.cpp index c37da53869dc..331850b8307d 100644 --- a/editor/libeditor/base/nsEditorController.cpp +++ b/editor/libeditor/base/nsEditorController.cpp @@ -22,6 +22,7 @@ * Ryan Cassin */ +#include "nsString.h" #include "nsIComponentManager.h" #include "nsEditorController.h" #include "nsIEditor.h" @@ -98,7 +99,7 @@ NS_IMETHODIMP nsEditorController::GetInterface(const nsIID & aIID, void * *resul _cmdClass* theCmd; \ NS_NEWXPCOM(theCmd, _cmdClass); \ if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \ - rv = inCommandManager->RegisterCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), \ + rv = inCommandManager->RegisterCommand(NS_LITERAL_STRING(_cmdName), \ NS_STATIC_CAST(nsIControllerCommand *, theCmd)); \ } @@ -107,15 +108,15 @@ NS_IMETHODIMP nsEditorController::GetInterface(const nsIID & aIID, void * *resul _cmdClass* theCmd; \ NS_NEWXPCOM(theCmd, _cmdClass); \ if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \ - rv = inCommandManager->RegisterCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), \ + rv = inCommandManager->RegisterCommand(NS_LITERAL_STRING(_cmdName), \ NS_STATIC_CAST(nsIControllerCommand *, theCmd)); #define NS_REGISTER_NEXT_COMMAND(_cmdClass, _cmdName) \ - rv = inCommandManager->RegisterCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), \ + rv = inCommandManager->RegisterCommand(NS_LITERAL_STRING(_cmdName), \ NS_STATIC_CAST(nsIControllerCommand *, theCmd)); #define NS_REGISTER_LAST_COMMAND(_cmdClass, _cmdName) \ - rv = inCommandManager->RegisterCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), \ + rv = inCommandManager->RegisterCommand(NS_LITERAL_STRING(_cmdName), \ NS_STATIC_CAST(nsIControllerCommand *, theCmd)); \ } @@ -185,27 +186,25 @@ nsresult nsEditorController::RegisterEditorCommands(nsIControllerCommandManager * nsIController * ======================================================================= */ -NS_IMETHODIMP nsEditorController::IsCommandEnabled(const PRUnichar *aCommand, PRBool *aResult) +NS_IMETHODIMP nsEditorController::IsCommandEnabled(const nsAReadableString & aCommand, PRBool *aResult) { NS_ENSURE_ARG_POINTER(aResult); return mCommandManager->IsCommandEnabled(aCommand, mCommandRefCon, aResult); } -NS_IMETHODIMP nsEditorController::SupportsCommand(const PRUnichar *aCommand, PRBool *aResult) +NS_IMETHODIMP nsEditorController::SupportsCommand(const nsAReadableString & aCommand, PRBool *aResult) { NS_ENSURE_ARG_POINTER(aResult); return mCommandManager->SupportsCommand(aCommand, mCommandRefCon, aResult); } -NS_IMETHODIMP nsEditorController::DoCommand(const PRUnichar *aCommand) +NS_IMETHODIMP nsEditorController::DoCommand(const nsAReadableString & aCommand) { return mCommandManager->DoCommand(aCommand, mCommandRefCon); } -NS_IMETHODIMP nsEditorController::OnEvent(const PRUnichar *aEventName) +NS_IMETHODIMP nsEditorController::OnEvent(const nsAReadableString & aEventName) { - NS_ENSURE_ARG_POINTER(aEventName); - return NS_OK; } @@ -282,7 +281,7 @@ NS_IMETHODIMP nsComposerController::Init(nsISupports *aCommandRefCon) { \ _cmdClass* theCmd = new _cmdClass(_styleTag); \ if (!theCmd) return NS_ERROR_OUT_OF_MEMORY; \ - rv = inCommandManager->RegisterCommand(NS_ConvertASCIItoUCS2(_cmdName).GetUnicode(), \ + rv = inCommandManager->RegisterCommand(NS_LITERAL_STRING(_cmdName), \ NS_STATIC_CAST(nsIControllerCommand *, theCmd)); \ }