Bug 1549661 - part 2: Create `EditorCommand::DoCommandParam(Command aCommand, const Maybe<bool>& aBoolParam, TextEditor& aTextEditor)` r=m_kato
authorMasayuki Nakano <masayuki@d-toybox.com>
Tue, 21 May 2019 07:44:39 +0000
changeset 474693 b9fd628d913acbb9d70eb04809e4f1008a61fc15
parent 474692 cc344bcbf49d0f99d8a76fa15bdbb91a934728cb
child 474694 7c1521b96d93706a984c57c81f44f1f4864317a8
push id113168
push userrmaries@mozilla.com
push dateTue, 21 May 2019 16:39:23 +0000
treeherdermozilla-inbound@3c0f78074b72 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersm_kato
bugs1549661
milestone69.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1549661 - part 2: Create `EditorCommand::DoCommandParam(Command aCommand, const Maybe<bool>& aBoolParam, TextEditor& aTextEditor)` r=m_kato We should use `Maybe` for `bool` because some command may treat the default value when the parameter is omitted as `true` or `false. Although, current implementation does not do that. Differential Revision: https://phabricator.services.mozilla.com/D30496
editor/libeditor/EditorCommands.cpp
editor/libeditor/EditorCommands.h
editor/libeditor/HTMLEditorDocumentCommands.cpp
--- a/editor/libeditor/EditorCommands.cpp
+++ b/editor/libeditor/EditorCommands.cpp
@@ -3,34 +3,39 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "EditorCommands.h"
 
 #include "mozilla/ArrayUtils.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/FlushType.h"
+#include "mozilla/Maybe.h"
+#include "mozilla/MozPromise.h"  // for mozilla::detail::Any
 #include "mozilla/TextEditor.h"
 #include "mozilla/dom/Document.h"
 #include "mozilla/dom/Selection.h"
 #include "nsCommandParams.h"
 #include "nsIClipboard.h"
 #include "nsIEditingSession.h"
 #include "nsISelectionController.h"
 #include "nsITransferable.h"
 #include "nsString.h"
 #include "nsAString.h"
 
 class nsISupports;
 
 #define STATE_ENABLED "state_enabled"
+#define STATE_ATTRIBUTE "state_attribute"
 #define STATE_DATA "state_data"
 
 namespace mozilla {
 
+using namespace detail;
+
 /******************************************************************************
  * mozilla::EditorCommand
  ******************************************************************************/
 
 NS_IMPL_ISUPPORTS(EditorCommand, nsIControllerCommand)
 
 NS_IMETHODIMP
 EditorCommand::IsCommandEnabled(const char* aCommandName,
@@ -71,17 +76,17 @@ EditorCommand::DoCommandParams(const cha
   if (NS_WARN_IF(!aCommandName) || NS_WARN_IF(!aCommandRefCon)) {
     return NS_ERROR_INVALID_ARG;
   }
   nsCOMPtr<nsIEditor> editor = do_QueryInterface(aCommandRefCon);
   if (NS_WARN_IF(!editor)) {
     return NS_ERROR_INVALID_ARG;
   }
   Command command;
-  nsCommandParams* params = aParams->AsCommandParams();
+  nsCommandParams* params = aParams ? aParams->AsCommandParams() : nullptr;
   if (params) {
     nsAutoString value;
     params->GetString(aCommandName, value);
     command = GetInternalCommand(aCommandName, value);
   } else {
     command = GetInternalCommand(aCommandName);
   }
 
@@ -90,16 +95,37 @@ EditorCommand::DoCommandParams(const cha
     nsresult rv =
         DoCommandParam(command, MOZ_KnownLive(*editor->AsTextEditor()));
     NS_WARNING_ASSERTION(
         NS_SUCCEEDED(rv),
         "Failed to do command from nsIControllerCommand::DoCommandParams()");
     return rv;
   }
 
+  if (Any(paramType & EditorCommandParamType::Bool)) {
+    if (Any(paramType & EditorCommandParamType::StateAttribute)) {
+      Maybe<bool> boolParam = Nothing();
+      if (params) {
+        ErrorResult error;
+        boolParam = Some(params->GetBool(STATE_ATTRIBUTE, error));
+        if (NS_WARN_IF(error.Failed())) {
+          return error.StealNSResult();
+        }
+      }
+      nsresult rv = DoCommandParam(command, boolParam,
+                                   MOZ_KnownLive(*editor->AsTextEditor()));
+      NS_WARNING_ASSERTION(
+          NS_SUCCEEDED(rv),
+          "Failed to do command from nsIControllerCommand::DoCommandParams()");
+      return rv;
+    }
+    MOZ_ASSERT_UNREACHABLE("Unexpected state for bool");
+    return NS_ERROR_NOT_IMPLEMENTED;
+  }
+
   nsresult rv = DoCommandParams(command, MOZ_KnownLive(params),
                                 MOZ_KnownLive(*editor->AsTextEditor()));
   NS_WARNING_ASSERTION(
       NS_SUCCEEDED(rv),
       "Failed to do command from nsIControllerCommand::DoCommandParams()");
   return rv;
 }
 
--- a/editor/libeditor/EditorCommands.h
+++ b/editor/libeditor/EditorCommands.h
@@ -1,16 +1,17 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #ifndef mozilla_EditorCommands_h
 #define mozilla_EditorCommands_h
 
+#include "mozilla/Maybe.h"
 #include "mozilla/StaticPtr.h"
 #include "mozilla/TypedEnumBits.h"
 #include "nsIControllerCommand.h"
 #include "nsISupportsImpl.h"
 #include "nsRefPtrHashtable.h"
 #include "nsStringFwd.h"
 
 class nsAtom;
@@ -167,16 +168,31 @@ class EditorCommand : public nsIControll
       case Command::PasteWithoutFormat:
         return EditorCommandParamType::None;
 
       // DocumentStateCommand
       case Command::EditorObserverDocumentCreated:
       case Command::EditorObserverDocumentLocationChanged:
       case Command::EditorObserverDocumentWillBeDestroyed:
         return EditorCommandParamType::None;
+      // SetDocumentStateCommand
+      case Command::SetDocumentModified:
+      case Command::SetDocumentUseCSS:
+      case Command::SetDocumentReadOnly:
+      case Command::SetDocumentInsertBROnEnterKeyPress:
+        return EditorCommandParamType::Bool |
+               EditorCommandParamType::StateAttribute;
+      case Command::SetDocumentDefaultParagraphSeparator:
+        // XXX Treat as Unknown for now
+        return EditorCommandParamType::Transferable;
+      case Command::ToggleObjectResizers:
+      case Command::ToggleInlineTableEditor:
+      case Command::ToggleAbsolutePositionEditor:
+        return EditorCommandParamType::Bool |
+               EditorCommandParamType::StateAttribute;
 
       // IndentCommand
       case Command::FormatIndent:
         return EditorCommandParamType::None;
       // OutdentCommand
       case Command::FormatOutdent:
         return EditorCommandParamType::None;
       // StyleUpdatingCommand
@@ -286,16 +302,29 @@ class EditorCommand : public nsIControll
    */
   MOZ_CAN_RUN_SCRIPT
   virtual nsresult DoCommandParam(Command aCommand,
                                   TextEditor& aTextEditor) const {
     MOZ_ASSERT_UNREACHABLE("Wrong overload is called");
     return NS_ERROR_NOT_IMPLEMENTED;
   }
 
+  /**
+   * Called only when the result of EditorCommand::GetParamType(aCommand)
+   * includes EditorCommandParamType::Bool.  If aBoolParam is Nothing, it
+   * means that given param was nullptr.
+   */
+  MOZ_CAN_RUN_SCRIPT
+  virtual nsresult DoCommandParam(Command aCommand,
+                                  const Maybe<bool>& aBoolParam,
+                                  TextEditor& aTextEditor) const {
+    MOZ_ASSERT_UNREACHABLE("Wrong overload is called");
+    return NS_ERROR_NOT_IMPLEMENTED;
+  }
+
  protected:
   EditorCommand() = default;
   virtual ~EditorCommand() = default;
 };
 
 #define NS_DECL_EDITOR_COMMAND_COMMON_METHODS                              \
  public:                                                                   \
   MOZ_CAN_RUN_SCRIPT                                                       \
@@ -322,16 +351,23 @@ class EditorCommand : public nsIControll
 #define NS_DECL_DO_COMMAND_PARAM_DELEGATE_TO_DO_COMMAND                      \
  public:                                                                     \
   MOZ_CAN_RUN_SCRIPT                                                         \
   virtual nsresult DoCommandParam(Command aCommand, TextEditor& aTextEditor) \
       const final {                                                          \
     return DoCommand(aCommand, aTextEditor);                                 \
   }
 
+#define NS_DECL_DO_COMMAND_PARAM_FOR_BOOL_PARAM                  \
+ public:                                                         \
+  MOZ_CAN_RUN_SCRIPT                                             \
+  virtual nsresult DoCommandParam(Command aCommand,              \
+                                  const Maybe<bool>& aBoolParam, \
+                                  TextEditor& aTextEditor) const final;
+
 #define NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(_cmd) \
  public:                                                   \
   static _cmd* GetInstance() {                             \
     if (!sInstance) {                                      \
       sInstance = new _cmd();                              \
     }                                                      \
     return sInstance;                                      \
   }                                                        \
@@ -358,16 +394,27 @@ class EditorCommand : public nsIControll
     NS_DECL_DO_COMMAND_PARAM_DELEGATE_TO_DO_COMMAND             \
     NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(_cmd)          \
                                                                 \
    protected:                                                   \
     _cmd() = default;                                           \
     virtual ~_cmd() = default;                                  \
   };
 
+#define NS_DECL_EDITOR_COMMAND_FOR_BOOL_PARAM(_cmd)    \
+  class _cmd final : public EditorCommand {            \
+    NS_DECL_EDITOR_COMMAND_COMMON_METHODS              \
+    NS_DECL_DO_COMMAND_PARAM_FOR_BOOL_PARAM            \
+    NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(_cmd) \
+                                                       \
+   protected:                                          \
+    _cmd() = default;                                  \
+    virtual ~_cmd() = default;                         \
+  };
+
 // basic editor commands
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(UndoCommand)
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(RedoCommand)
 
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(CutCommand)
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(CutOrDeleteCommand)
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(CopyCommand)
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(CopyOrDeleteCommand)
@@ -693,17 +740,30 @@ class AbsolutePositioningCommand final :
                            nsCommandParams& aParams) const final;
   MOZ_CAN_RUN_SCRIPT
   nsresult ToggleState(nsAtom* aTagName, HTMLEditor* aHTMLEditor) const final;
 };
 
 // composer commands
 
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(DocumentStateCommand)
-NS_DECL_EDITOR_COMMAND(SetDocumentStateCommand)
+
+class SetDocumentStateCommand final : public EditorCommand {
+ public:
+  NS_INLINE_DECL_REFCOUNTING_INHERITED(SetDocumentStateCommand, EditorCommand)
+
+  NS_DECL_EDITOR_COMMAND_COMMON_METHODS
+  NS_DECL_DO_COMMAND_PARAMS
+  NS_DECL_DO_COMMAND_PARAM_FOR_BOOL_PARAM
+  NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON(SetDocumentStateCommand)
+
+ private:
+  SetDocumentStateCommand() = default;
+  virtual ~SetDocumentStateCommand() = default;
+};
 
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(DecreaseZIndexCommand)
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(IncreaseZIndexCommand)
 
 // Generic commands
 
 // Edit menu
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(PasteNoFormattingCommand)
@@ -717,16 +777,18 @@ NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(IncreaseFontSizeCommand)
 NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE(DecreaseFontSizeCommand)
 
 // Insert content commands
 NS_DECL_EDITOR_COMMAND(InsertHTMLCommand)
 
 #undef NS_DECL_EDITOR_COMMAND
 #undef NS_DECL_EDITOR_COMMAND_FOR_NO_PARAM_WITH_DELEGATE
+#undef NS_DECL_EDITOR_COMMAND_FOR_BOOL_PARAM
 #undef NS_DECL_EDITOR_COMMAND_COMMON_METHODS
 #undef NS_DECL_DO_COMMAND_PARAMS
 #undef NS_DECL_DO_COMMAND_PARAM_DELEGATE_TO_DO_COMMAND
+#undef NS_DECL_DO_COMMAND_PARAM_FOR_BOOL_PARAM
 #undef NS_INLINE_DECL_EDITOR_COMMAND_MAKE_SINGLETON
 
 }  // namespace mozilla
 
 #endif  // #ifndef mozilla_EditorCommands_h
--- a/editor/libeditor/HTMLEditorDocumentCommands.cpp
+++ b/editor/libeditor/HTMLEditorDocumentCommands.cpp
@@ -43,102 +43,101 @@ bool SetDocumentStateCommand::IsCommandE
   return aTextEditor && aTextEditor->AsHTMLEditor();
 }
 
 nsresult SetDocumentStateCommand::DoCommand(Command aCommand,
                                             TextEditor& aTextEditor) const {
   return NS_ERROR_NOT_IMPLEMENTED;
 }
 
+nsresult SetDocumentStateCommand::DoCommandParam(
+    Command aCommand, const Maybe<bool>& aBoolParam,
+    TextEditor& aTextEditor) const {
+  if (NS_WARN_IF(aBoolParam.isNothing())) {
+    return NS_ERROR_INVALID_ARG;
+  }
+
+  if (NS_WARN_IF(!aTextEditor.AsHTMLEditor())) {
+    return NS_ERROR_FAILURE;
+  }
+
+  switch (aCommand) {
+    case Command::SetDocumentModified: {
+      if (aBoolParam.value()) {
+        nsresult rv = aTextEditor.IncrementModificationCount(1);
+        NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                             "IncrementModificationCount() failed");
+        return rv;
+      }
+      nsresult rv = aTextEditor.ResetModificationCount();
+      NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "ResetModificationCount() failed");
+      return rv;
+    }
+    case Command::SetDocumentReadOnly: {
+      ErrorResult error;
+      if (aBoolParam.value()) {
+        nsresult rv =
+            aTextEditor.AddFlags(nsIPlaintextEditor::eEditorReadonlyMask);
+        NS_WARNING_ASSERTION(
+            NS_SUCCEEDED(rv),
+            "AddFlags(nsIPlaintextEditor::eEditorReadonlyMask) failed");
+        return rv;
+      }
+      nsresult rv =
+          aTextEditor.RemoveFlags(nsIPlaintextEditor::eEditorReadonlyMask);
+      NS_WARNING_ASSERTION(
+          NS_SUCCEEDED(rv),
+          "RemoveFlags(nsIPlaintextEditor::eEditorReadonlyMask) failed");
+      return rv;
+    }
+    case Command::SetDocumentUseCSS: {
+      nsresult rv =
+          aTextEditor.AsHTMLEditor()->SetIsCSSEnabled(aBoolParam.value());
+      NS_WARNING_ASSERTION(NS_SUCCEEDED(rv), "SetIsCSSEnabled() failed");
+      return rv;
+    }
+    case Command::SetDocumentInsertBROnEnterKeyPress: {
+      nsresult rv =
+          aTextEditor.AsHTMLEditor()->SetReturnInParagraphCreatesNewParagraph(
+              !aBoolParam.value());
+      NS_WARNING_ASSERTION(NS_SUCCEEDED(rv),
+                           "SetReturnInParagraphCreatesNewParagraph() failed");
+      return rv;
+    }
+    case Command::ToggleObjectResizers: {
+      MOZ_KnownLive(aTextEditor.AsHTMLEditor())
+          ->EnableObjectResizer(aBoolParam.value());
+      return NS_OK;
+    }
+    case Command::ToggleInlineTableEditor: {
+      MOZ_KnownLive(aTextEditor.AsHTMLEditor())
+          ->EnableInlineTableEditor(aBoolParam.value());
+      return NS_OK;
+    }
+    case Command::ToggleAbsolutePositionEditor: {
+      MOZ_KnownLive(aTextEditor.AsHTMLEditor())
+          ->EnableAbsolutePositionEditor(aBoolParam.value());
+      return NS_OK;
+    }
+    default:
+      return NS_ERROR_NOT_IMPLEMENTED;
+  }
+}
+
 nsresult SetDocumentStateCommand::DoCommandParams(
     Command aCommand, nsCommandParams* aParams, TextEditor& aTextEditor) const {
   if (NS_WARN_IF(!aParams)) {
     return NS_ERROR_INVALID_ARG;
   }
 
   if (NS_WARN_IF(!aTextEditor.AsHTMLEditor())) {
     return NS_ERROR_FAILURE;
   }
 
   switch (aCommand) {
-    case Command::SetDocumentModified: {
-      ErrorResult error;
-      bool modified = aParams->GetBool(STATE_ATTRIBUTE, error);
-      // Should we fail if this param wasn't set?
-      // I'm not sure we should be that strict
-      if (NS_WARN_IF(error.Failed())) {
-        return error.StealNSResult();
-      }
-      if (modified) {
-        nsresult rv = aTextEditor.IncrementModificationCount(1);
-        if (NS_WARN_IF(NS_FAILED(rv))) {
-          return rv;
-        }
-        return NS_OK;
-      }
-      nsresult rv = aTextEditor.ResetModificationCount();
-      if (NS_WARN_IF(NS_FAILED(rv))) {
-        return rv;
-      }
-      return NS_OK;
-    }
-    case Command::SetDocumentReadOnly: {
-      ErrorResult error;
-      bool isReadOnly = aParams->GetBool(STATE_ATTRIBUTE, error);
-      if (NS_WARN_IF(error.Failed())) {
-        return error.StealNSResult();
-      }
-      if (isReadOnly) {
-        nsresult rv =
-            aTextEditor.AddFlags(nsIPlaintextEditor::eEditorReadonlyMask);
-        if (NS_WARN_IF(NS_FAILED(rv))) {
-          return rv;
-        }
-        return NS_OK;
-      }
-      nsresult rv =
-          aTextEditor.RemoveFlags(nsIPlaintextEditor::eEditorReadonlyMask);
-      if (NS_WARN_IF(NS_FAILED(rv))) {
-        return rv;
-      }
-      return NS_OK;
-    }
-    case Command::SetDocumentUseCSS: {
-      HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
-      if (NS_WARN_IF(!htmlEditor)) {
-        return NS_ERROR_INVALID_ARG;
-      }
-      ErrorResult error;
-      bool desireCSS = aParams->GetBool(STATE_ATTRIBUTE, error);
-      if (NS_WARN_IF(error.Failed())) {
-        return error.StealNSResult();
-      }
-      nsresult rv = htmlEditor->SetIsCSSEnabled(desireCSS);
-      if (NS_WARN_IF(NS_FAILED(rv))) {
-        return rv;
-      }
-      return NS_OK;
-    }
-    case Command::SetDocumentInsertBROnEnterKeyPress: {
-      HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
-      if (NS_WARN_IF(!htmlEditor)) {
-        return NS_ERROR_INVALID_ARG;
-      }
-      ErrorResult error;
-      bool insertBrOnReturn = aParams->GetBool(STATE_ATTRIBUTE, error);
-      if (NS_WARN_IF(error.Failed())) {
-        return error.StealNSResult();
-      }
-      nsresult rv = htmlEditor->SetReturnInParagraphCreatesNewParagraph(
-          !insertBrOnReturn);
-      if (NS_WARN_IF(NS_FAILED(rv))) {
-        return rv;
-      }
-      return NS_OK;
-    }
     case Command::SetDocumentDefaultParagraphSeparator: {
       HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
       if (NS_WARN_IF(!htmlEditor)) {
         return NS_ERROR_INVALID_ARG;
       }
 
       nsAutoCString newValue;
       nsresult rv = aParams->GetCString(STATE_ATTRIBUTE, newValue);
@@ -159,65 +158,24 @@ nsresult SetDocumentStateCommand::DoComm
         htmlEditor->SetDefaultParagraphSeparator(ParagraphSeparator::br);
         return NS_OK;
       }
 
       // This should not be reachable from nsHTMLDocument::ExecCommand
       NS_WARNING("Invalid default paragraph separator");
       return NS_ERROR_UNEXPECTED;
     }
-    case Command::ToggleObjectResizers: {
-      HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
-      if (NS_WARN_IF(!htmlEditor)) {
-        return NS_ERROR_INVALID_ARG;
-      }
-      ErrorResult error;
-      bool enabled = aParams->GetBool(STATE_ATTRIBUTE, error);
-      if (NS_WARN_IF(error.Failed())) {
-        return error.StealNSResult();
-      }
-      MOZ_KnownLive(htmlEditor)->EnableObjectResizer(enabled);
-      return NS_OK;
-    }
-    case Command::ToggleInlineTableEditor: {
-      HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
-      if (NS_WARN_IF(!htmlEditor)) {
-        return NS_ERROR_INVALID_ARG;
-      }
-      ErrorResult error;
-      bool enabled = aParams->GetBool(STATE_ATTRIBUTE, error);
-      if (NS_WARN_IF(error.Failed())) {
-        return error.StealNSResult();
-      }
-      MOZ_KnownLive(htmlEditor)->EnableInlineTableEditor(enabled);
-      return NS_OK;
-    }
-    case Command::ToggleAbsolutePositionEditor: {
-      HTMLEditor* htmlEditor = aTextEditor.AsHTMLEditor();
-      if (NS_WARN_IF(!htmlEditor)) {
-        return NS_ERROR_INVALID_ARG;
-      }
-      ErrorResult error;
-      bool enabled = aParams->GetBool(STATE_ATTRIBUTE, error);
-      if (NS_WARN_IF(error.Failed())) {
-        return error.StealNSResult();
-      }
-      MOZ_KnownLive(htmlEditor)->EnableAbsolutePositionEditor(enabled);
-      return NS_OK;
-    }
     default:
       return NS_ERROR_NOT_IMPLEMENTED;
   }
 }
 
 nsresult SetDocumentStateCommand::GetCommandStateParams(
     Command aCommand, nsCommandParams& aParams, TextEditor* aTextEditor,
     nsIEditingSession* aEditingSession) const {
-  // If the result is set to STATE_ALL as bool value, queryCommandState()
-  // returns the bool value.
   // If the result is set to STATE_ATTRIBUTE as CString value,
   // queryCommandValue() returns the string value.
   // Otherwise, ignored.
 
   // The base editor owns most state info
   if (NS_WARN_IF(!aTextEditor)) {
     return NS_ERROR_INVALID_ARG;
   }