From 5472d1ac7331666d3c66031204f1f10c14503082 Mon Sep 17 00:00:00 2001 From: "brade%netscape.com" Date: Wed, 13 Nov 2002 15:23:03 +0000 Subject: [PATCH] implement queryCommandEnabled (bug 179730, r=akkana, sr=peterv) --- content/html/document/src/nsHTMLDocument.cpp | 32 ++++++++++++++------ 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 95e262e4d13d..66593fb61c62 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -4261,9 +4261,7 @@ nsHTMLDocument::ExecCommand(const nsAString & commandID, // get command manager and dispatch command to our window if it's acceptable nsCOMPtr cmdMgr; - nsresult rv = GetMidasCommandManager(getter_AddRefs(cmdMgr)); - if (NS_FAILED(rv)) - return rv; + GetMidasCommandManager(getter_AddRefs(cmdMgr)); if (!cmdMgr) return NS_ERROR_FAILURE; @@ -4275,6 +4273,7 @@ nsHTMLDocument::ExecCommand(const nsAString & commandID, if (!ConvertToMidasInternalCommand(commandID, value, cmdToDispatch, paramStr)) return NS_ERROR_NOT_IMPLEMENTED; + nsresult rv; if (paramStr.IsEmpty()) { rv = cmdMgr->DoCommand(cmdToDispatch.get(), nsnull, window); } else { @@ -4322,7 +4321,22 @@ nsHTMLDocument::QueryCommandEnabled(const nsAString & commandID, if (!mEditingIsOn) return NS_ERROR_FAILURE; - return NS_ERROR_NOT_IMPLEMENTED; + // get command manager and dispatch command to our window if it's acceptable + nsCOMPtr cmdMgr; + GetMidasCommandManager(getter_AddRefs(cmdMgr)); + if (!cmdMgr) + return NS_ERROR_FAILURE; + + nsCOMPtr window = do_QueryInterface(mScriptGlobalObject); + if (!window) + return NS_ERROR_FAILURE; + + nsCAutoString cmdToDispatch, paramStr; + if (!ConvertToMidasInternalCommand(commandID, commandID, + cmdToDispatch, paramStr)) + return NS_ERROR_NOT_IMPLEMENTED; + + return cmdMgr->IsCommandEnabled(cmdToDispatch.get(), window, _retval); } /* boolean queryCommandIndeterm (in DOMString commandID); */ @@ -4353,9 +4367,7 @@ nsHTMLDocument::QueryCommandState(const nsAString & commandID, PRBool *_retval) // get command manager and dispatch command to our window if it's acceptable nsCOMPtr cmdMgr; - nsresult rv = GetMidasCommandManager(getter_AddRefs(cmdMgr)); - if (NS_FAILED(rv)) - return rv; + GetMidasCommandManager(getter_AddRefs(cmdMgr)); if (!cmdMgr) return NS_ERROR_FAILURE; @@ -4368,6 +4380,7 @@ nsHTMLDocument::QueryCommandState(const nsAString & commandID, PRBool *_retval) cmdToDispatch, paramToCheck)) return NS_ERROR_NOT_IMPLEMENTED; + nsresult rv; nsCOMPtr cmdParams = do_CreateInstance( NS_COMMAND_PARAMS_CONTRACTID, &rv); if (!cmdParams) @@ -4442,9 +4455,7 @@ nsHTMLDocument::QueryCommandValue(const nsAString & commandID, // get command manager and dispatch command to our window if it's acceptable nsCOMPtr cmdMgr; - nsresult rv = GetMidasCommandManager(getter_AddRefs(cmdMgr)); - if (NS_FAILED(rv)) - return rv; + GetMidasCommandManager(getter_AddRefs(cmdMgr)); if (!cmdMgr) return NS_ERROR_FAILURE; @@ -4458,6 +4469,7 @@ nsHTMLDocument::QueryCommandValue(const nsAString & commandID, return NS_ERROR_NOT_IMPLEMENTED; // create params + nsresult rv; nsCOMPtr cmdParams = do_CreateInstance( NS_COMMAND_PARAMS_CONTRACTID, &rv); if (!cmdParams)