Bug 738385 part 1 - Refactor some editing logic in nsHTMLDocument.cpp; r=ehsan
authorAryeh Gregor <ayg@aryeh.name>
Tue, 17 Apr 2012 13:18:08 +0300
changeset 91851 307272b019d4dd45a6afa29032b57c9acd51512d
parent 91850 459b7d9d63d7191604d92848f651c775df5e0ad9
child 91852 bcc6fb80cd73b1016bac26505afcb2b62809d287
push id690
push usertim.taubert@gmx.de
push dateThu, 19 Apr 2012 08:49:11 +0000
treeherderfx-team@a9b543de6b67 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs738385
milestone14.0a1
Bug 738385 part 1 - Refactor some editing logic in nsHTMLDocument.cpp; r=ehsan
content/html/document/src/nsHTMLDocument.cpp
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -2948,17 +2948,19 @@ ConvertToMidasInternalCommandInner(const
             for (j = 0; j < ArrayLength(gBlocks); ++j) {
               if (convertedParam.Equals(gBlocks[j],
                                         nsCaseInsensitiveCStringComparator())) {
                 outParam.Assign(gBlocks[j]);
                 break;
               }
             }
 
-            return j != ArrayLength(gBlocks);
+            if (j == ArrayLength(gBlocks)) {
+              outParam.Truncate();
+            }
           }
           else {
             CopyUTF16toUTF8(inParam, outParam);
           }
         }
       }
     }
   } // end else for useNewParam (do convert existing param)
@@ -3096,16 +3098,21 @@ nsHTMLDocument::ExecCommand(const nsAStr
     return NS_ERROR_FAILURE;
 
   nsCAutoString cmdToDispatch, paramStr;
   bool isBool, boolVal;
   if (!ConvertToMidasInternalCommand(commandID, value,
                                      cmdToDispatch, paramStr, isBool, boolVal))
     return NS_OK;
 
+  if (cmdToDispatch.EqualsLiteral("cmd_paragraphState") && paramStr.IsEmpty()) {
+    // Invalid value
+    return NS_OK;
+  }
+
   if (!isBool && paramStr.IsEmpty()) {
     rv = cmdMgr->DoCommand(cmdToDispatch.get(), nsnull, window);
   } else {
     // we have a command that requires a parameter, create params
     nsCOMPtr<nsICommandParams> cmdParams = do_CreateInstance(
                                             NS_COMMAND_PARAMS_CONTRACTID, &rv);
     if (!cmdParams)
       return NS_ERROR_OUT_OF_MEMORY;
@@ -3174,20 +3181,18 @@ nsHTMLDocument::QueryCommandIndeterm(con
   GetMidasCommandManager(getter_AddRefs(cmdMgr));
   if (!cmdMgr)
     return NS_ERROR_FAILURE;
 
   nsIDOMWindow *window = GetWindow();
   if (!window)
     return NS_ERROR_FAILURE;
 
-  nsCAutoString cmdToDispatch, paramToCheck;
-  bool dummy;
-  if (!ConvertToMidasInternalCommand(commandID, commandID,
-                                     cmdToDispatch, paramToCheck, dummy, dummy))
+  nsCAutoString cmdToDispatch;
+  if (!ConvertToMidasInternalCommand(commandID, cmdToDispatch))
     return NS_ERROR_NOT_IMPLEMENTED;
 
   nsresult rv;
   nsCOMPtr<nsICommandParams> cmdParams = do_CreateInstance(
                                            NS_COMMAND_PARAMS_CONTRACTID, &rv);
   NS_ENSURE_SUCCESS(rv, rv);
 
   rv = cmdMgr->GetCommandState(cmdToDispatch.get(), window, cmdParams);