Bug 282097 - Part 9: Ensure editor commands are enabled. r=enndeakin
authorJ. Ryan Stinnett <jryans@gmail.com>
Wed, 10 Jul 2013 09:13:53 -0500
changeset 138145 116295f5b522a5be506d942319dc47c8d5bbf391
parent 138144 993613b4491443a6764b80f2bbeefd2457a28168
child 138146 0daef1c8ef648bfe2b2795d0ad7e8b2c14c3cc5c
push id30839
push userryanvm@gmail.com
push dateThu, 11 Jul 2013 14:25:52 +0000
treeherdermozilla-inbound@0daef1c8ef64 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersenndeakin
bugs282097
milestone25.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 282097 - Part 9: Ensure editor commands are enabled. r=enndeakin
content/xbl/src/nsXBLWindowKeyHandler.cpp
--- a/content/xbl/src/nsXBLWindowKeyHandler.cpp
+++ b/content/xbl/src/nsXBLWindowKeyHandler.cpp
@@ -283,22 +283,31 @@ GetEditorKeyBindings()
 
   return sNativeEditorBindings;
 }
 
 static void
 DoCommandCallback(const char *aCommand, void *aData)
 {
   nsIControllers *controllers = static_cast<nsIControllers*>(aData);
-  if (controllers) {
-    nsCOMPtr<nsIController> controller;
-    controllers->GetControllerForCommand(aCommand, getter_AddRefs(controller));
-    if (controller) {
-      controller->DoCommand(aCommand);
-    }
+  if (!controllers) {
+    return;
+  }
+
+  nsCOMPtr<nsIController> controller;
+  controllers->GetControllerForCommand(aCommand, getter_AddRefs(controller));
+  if (!controller) {
+    return;
+  }
+
+  bool commandEnabled;
+  nsresult rv = controller->IsCommandEnabled(aCommand, &commandEnabled);
+  NS_ENSURE_SUCCESS_VOID(rv);
+  if (commandEnabled) {
+    controller->DoCommand(aCommand);
   }
 }
 
 nsresult
 nsXBLWindowKeyHandler::WalkHandlers(nsIDOMKeyEvent* aKeyEvent, nsIAtom* aEventType)
 {
   bool prevent;
   aKeyEvent->GetDefaultPrevented(&prevent);