Bug 1454408 - Replace getPref calls needing a default value with standard Services calls. SeaMonkey Composer part. r=IanN a=IanN
authorFrank-Rainer Grahl <frgrahl@gmx.net>
Mon, 07 May 2018 12:41:29 +0200
changeset 31468 a59b0b5ac649
parent 31467 e7ec4d4f2a40
child 31469 78712c7817d3
push id383
push userclokep@gmail.com
push date2018-05-07 21:52 +0000
reviewersIanN, IanN
bugs1454408
Bug 1454408 - Replace getPref calls needing a default value with standard Services calls. SeaMonkey Composer part. r=IanN a=IanN
editor/ui/composer/content/editingOverlay.js
editor/ui/composer/content/editor.js
editor/ui/composer/content/editorUtilities.js
--- a/editor/ui/composer/content/editingOverlay.js
+++ b/editor/ui/composer/content/editingOverlay.js
@@ -256,29 +256,29 @@ function BuildRecentPagesMenu()
 
   // Delete existing menu
   while (popup.hasChildNodes())
     popup.lastChild.remove();
 
   // Current page is the "0" item in the list we save in prefs,
   //  but we don't include it in the menu.
   var curUrl = StripPassword(GetDocumentUrl());
-  var historyCount = GetIntPref("editor.history.url_maximum", 10);
+  var historyCount = Services.prefs.getIntPref("editor.history.url_maximum", 10);
 
   var menuIndex = 1;
   for (var i = 0; i < historyCount; i++)
   {
-    var url = GetStringPref("editor.history_url_" + i);
+    var url = Services.prefs.getStringPref("editor.history_url_" + i, "");
 
     // Skip over current url
     if (url && url != curUrl)
     {
       // Build the menu
-      var title = GetStringPref("editor.history_title_" + i);
-      var fileType = GetStringPref("editor.history_type_" + i);
+      var title = Services.prefs.getStringPref("editor.history_title_" + i, "");
+      var fileType = Services.prefs.getStringPref("editor.history_type_" + i, "");
       AppendRecentMenuitem(popup, title, url, fileType, menuIndex);
       menuIndex++;
     }
   }
 }
 
 function AppendRecentMenuitem(aPopup, aTitle, aUrl, aFileType, aIndex)
 {
@@ -311,23 +311,23 @@ function EditorInitFileMenu()
   var docUrl = GetDocumentUrl();
   var scheme = GetScheme(docUrl);
   if (scheme && scheme != "file")
     SetElementEnabledById("menu_saveCmd", false);
 
   // Enable recent pages submenu if there are any history entries in prefs.
   var historyUrl = "";
 
-  if (GetIntPref("editor.history.url_maximum", 10))
+  if (Services.prefs.getIntPref("editor.history.url_maximum", 10))
   {
-    historyUrl = GetStringPref("editor.history_url_0");
+    historyUrl = Services.prefs.getStringPref("editor.history_url_0", "");
 
     // See if there's more if current file is only entry in history list.
     if (historyUrl && historyUrl == docUrl)
-      historyUrl = GetStringPref("editor.history_url_1");
+      historyUrl = Services.prefs.getStringPref("editor.history_url_1", "");
   }
   SetElementEnabledById("menu_RecentFiles", historyUrl != "");
 }
 
 function EditorUpdateCharsetMenu(aMenuPopup)
 {
   if (IsDocumentModified() && !IsDocumentEmpty())
   {
--- a/editor/ui/composer/content/editor.js
+++ b/editor/ui/composer/content/editor.js
@@ -2001,26 +2001,26 @@ function SaveRecentFilesPrefs(aTitle, aF
   {
     titleArray.push(aTitle);
     urlArray.push(curUrl);
     typeArray.push(aFileType);
   }
 
   for (let i = 0; i < historyCount && urlArray.length < historyCount; i++)
   {
-    let url = GetStringPref("editor.history_url_" + i);
+    let url = Services.prefs.getStringPref("editor.history_url_" + i, "");
 
     // Continue if URL pref is missing because 
     //  a URL not found during loading may have been removed
 
     // Skip over current an "data" URLs
     if (url && url != curUrl && GetScheme(url) != "data")
     {
-      let title = GetStringPref("editor.history_title_" + i);
-      let fileType = GetStringPref("editor.history_type_" + i);
+      let title = Services.prefs.getStringPref("editor.history_title_" + i, "");
+      let fileType = Services.prefs.getStringPref("editor.history_type_" + i, "");
       titleArray.push(title);
       urlArray.push(url);
       typeArray.push(fileType);
     }
   }
 
   // Resave the list back to prefs in the new order
   for (let i = 0; i < urlArray.length; i++)
--- a/editor/ui/composer/content/editorUtilities.js
+++ b/editor/ui/composer/content/editorUtilities.js
@@ -388,24 +388,16 @@ function SetElementEnabled(element, doEn
 /************* Services / Prefs ***************/
 
 function GetFileProtocolHandler()
 {
   let handler = Services.io.getProtocolHandler("file");
   return handler.QueryInterface(Ci.nsIFileProtocolHandler);
 }
 
-function GetStringPref(name)
-{
-  try {
-    return Services.prefs.getStringPref(name);
-  } catch (e) {}
-  return "";
-}
-
 function SetStringPref(aPrefName, aPrefValue)
 {
   try {
     Services.prefs.setStringPref(aPrefName, aPrefValue);
   }
   catch(e) {}
 }