Part of bug 880595 - Fix the compose window spell check dialog. r=Neil,a=Standard8 and bustage fix on CLOSED TREE
authorMark Banner <bugzilla@standard8.plus.com>
Thu, 04 Jul 2013 22:53:03 +0100
changeset 14174 34152b9627ba2b1729b0f511589dcba075384e24
parent 14173 2bf197959dba108eb3d797969a97a3cb99ead1d3
child 14175 3777b122c29dc5f1459f6c2d0ac906fb73a834a6
push id973
push userbugzilla@standard8.plus.com
push dateMon, 08 Jul 2013 07:16:54 +0000
treeherdercomm-aurora@34152b9627ba [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersNeil, Standard8
bugs880595
Part of bug 880595 - Fix the compose window spell check dialog. r=Neil,a=Standard8 and bustage fix on CLOSED TREE
editor/ui/dialogs/content/EdSpellCheck.js
--- a/editor/ui/dialogs/content/EdSpellCheck.js
+++ b/editor/ui/dialogs/content/EdSpellCheck.js
@@ -8,18 +8,16 @@ var gSpellChecker = null;
 var gAllowSelectWord = true;
 var gPreviousReplaceWord = "";
 var gFirstTime = true;
 var gLastSelectedLang = null;
 var gDictCount = 0;
 
 function Startup()
 {
-  var sendMailMessageMode = false;
-
   var editor = GetCurrentEditor();
   if (!editor)
   {
     window.close();
     return;
   }
 
   // Get the spellChecker shell
@@ -30,35 +28,36 @@ function Startup()
     window.close();
     return;
   }
 
   // Start the spell checker module.
   try {
     // TxtSrv Filter Contract Id
     var filterContractId;
-    sendMailMessageMode = window.arguments[0];
     var skipBlockQuotes = window.arguments[1];
     var enableSelectionChecking = window.arguments[2];
 
     if (skipBlockQuotes)
       filterContractId = "@mozilla.org/editor/txtsrvfiltermail;1";
     else
       filterContractId = "@mozilla.org/editor/txtsrvfilter;1";
 
     gSpellChecker.setFilter(Components.classes[filterContractId].createInstance(Components.interfaces.nsITextServicesFilter));
-    gSpellChecker.InitSpellChecker(editor, enableSelectionChecking);
+    gSpellChecker.InitSpellChecker(editor, enableSelectionChecking, spellCheckStarted);
 
   }
   catch(ex) {
    dump("*** Exception error: InitSpellChecker\n");
     window.close();
     return;
   }
+}
 
+function spellCheckStarted() {
   gDialog.MisspelledWordLabel = document.getElementById("MisspelledWordLabel");
   gDialog.MisspelledWord      = document.getElementById("MisspelledWord");
   gDialog.ReplaceButton       = document.getElementById("Replace");
   gDialog.IgnoreButton        = document.getElementById("Ignore");
   gDialog.StopButton          = document.getElementById("Stop");
   gDialog.CloseButton         = document.getElementById("Close");
   gDialog.ReplaceWordInput    = document.getElementById("ReplaceWordInput");
   gDialog.SuggestedList       = document.getElementById("SuggestedList");
@@ -77,17 +76,17 @@ function Startup()
 
   InitLanguageMenu(curLang);
   
   // Get the first misspelled word and setup all UI
   NextWord();
 
   // When startup param is true, setup different UI when spell checking 
   //   just before sending mail message  
-  if (sendMailMessageMode)
+  if (window.arguments[0])
   {
     // If no misspelled words found, simply close dialog and send message
     if (!gMisspelledWord)
     {
       onClose();
       return;
     }
 
@@ -426,26 +425,31 @@ function SelectLanguage()
 
     if (gLastSelectedLang)
       gDialog.LanguageMenulist.selectedItem = gLastSelectedLang;
   }
 }
 
 function Recheck()
 {
+  var recheckLanguage;
+
+  function finishRecheck() {
+    gSpellChecker.SetCurrentDictionary(recheckLanguage);
+    gMisspelledWord = gSpellChecker.GetNextMisspelledWord();
+    SetWidgetsForMisspelledWord();
+  }
+
   //TODO: Should we bother to add a "Recheck" method to interface?
   try {
-    var curLang = gSpellChecker.GetCurrentDictionary();
+    recheckLanguage = gSpellChecker.GetCurrentDictionary();
     gSpellChecker.UninitSpellChecker();
-    gSpellChecker.InitSpellChecker(GetCurrentEditor(), false);
-    gSpellChecker.SetCurrentDictionary(curLang);
-    gMisspelledWord = gSpellChecker.GetNextMisspelledWord();
-    SetWidgetsForMisspelledWord();
+    gSpellChecker.InitSpellChecker(GetCurrentEditor(), false, finishRecheck);
   } catch(ex) {
-    dump(ex);
+    Components.utils.reportError(ex);
   }
 }
 
 function FillSuggestedList(misspelledWord)
 {
   var list = gDialog.SuggestedList;
 
   // Clear the current contents of the list