Bug 795158 - Switch to Services.jsm: /editor/ui/: Services.prefs. r=mconley, r=IanN
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 05 Feb 2013 00:28:36 +0100
changeset 14798 65556fa263e6d432d6fff56124b25bd66a5aafe0
parent 14797 48831ce7db7d70f53fecdf2748f0b9f2c5d10d57
child 14799 8a508a9ee4856e4c7f539d66634017529a2b5c14
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmconley, IanN
bugs795158
Bug 795158 - Switch to Services.jsm: /editor/ui/: Services.prefs. r=mconley, r=IanN
editor/ui/composer/content/ComposerCommands.js
editor/ui/composer/content/editingOverlay.js
editor/ui/composer/content/editor.js
editor/ui/composer/content/editorUtilities.js
editor/ui/composer/content/pref-editing.js
editor/ui/composer/content/publishprefs.js
editor/ui/dialogs/content/EdColorPicker.js
editor/ui/dialogs/content/EdConvertToTable.js
editor/ui/dialogs/content/EdHLineProps.js
editor/ui/dialogs/content/EdInsertTable.js
editor/ui/dialogs/content/EdPageProps.js
editor/ui/dialogs/content/EdSnapToGrid.js
editor/ui/dialogs/content/EdTableProps.js
editor/ui/dialogs/content/EditorPublish.js
editor/ui/dialogs/content/EditorPublishSettings.js
--- a/editor/ui/composer/content/ComposerCommands.js
+++ b/editor/ui/composer/content/ComposerCommands.js
@@ -638,44 +638,39 @@ var nsPublishCommand =
   
   getCommandStateParams: function(aCommand, aParams, aRefCon) {},
   doCommandParams: function(aCommand, aParams, aRefCon) {},
 
   doCommand: function(aCommand)
   {
     if (GetCurrentEditor())
     {
-      var docUrl = GetDocumentUrl();
-      var filename = GetFilename(docUrl);
-      var publishData;
-      var showPublishDialog = false;
+      let docUrl = GetDocumentUrl();
+      let filename = GetFilename(docUrl);
+      let publishData;
 
       // First check pref to always show publish dialog
-      try {
-        var prefs = GetPrefs();
-        if (prefs)
-          showPublishDialog = prefs.getBoolPref("editor.always_show_publish_dialog");
-      } catch(e) {}
+      let showPublishDialog = Services.prefs.getBoolPref("editor.always_show_publish_dialog");
 
       if (!showPublishDialog && filename)
       {
         // Try to get publish data from the document url
         publishData = CreatePublishDataFromUrl(docUrl);
 
         // If none, use default publishing site? Need a pref for this
         //if (!publishData)
         //  publishData = GetPublishDataFromSiteName(GetDefaultPublishSiteName(), filename);
       }
 
       if (showPublishDialog || !publishData)
       {
         // Show the publish dialog
         publishData = {};
         window.ok = false;
-        var oldTitle = GetDocumentTitle();
+        let oldTitle = GetDocumentTitle();
         window.openDialog("chrome://editor/content/EditorPublish.xul","_blank", 
                           "chrome,close,titlebar,modal", "", "", publishData);
         if (GetDocumentTitle() != oldTitle)
           UpdateWindowTitle();
 
         if (!window.ok)
           return false;
       }
@@ -960,25 +955,23 @@ function GetOutputFlags(aMimeType, aWrap
     : webPersist.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES;
   if (aMimeType == "text/plain")
   {
     // When saving in "text/plain" format, always do formatting
     outputFlags |= webPersist.ENCODE_FLAGS_FORMATTED;
   }
   else
   {
+    // Should we prettyprint? Check the pref
+    if (Services.prefs.getBoolPref("editor.prettyprint"))
+      outputFlags |= webPersist.ENCODE_FLAGS_FORMATTED;
+
     try {
-      // Should we prettyprint? Check the pref
-      var prefs = GetPrefs();
-      if (prefs.getBoolPref("editor.prettyprint"))
-        outputFlags |= webPersist.ENCODE_FLAGS_FORMATTED;
-
       // How much entity names should we output? Check the pref
-      var encodeEntity = prefs.getCharPref("editor.encode_entity");
-      switch (encodeEntity) {
+      switch (Services.prefs.getCharPref("editor.encode_entity")) {
         case "basic"  : outputEntity = webPersist.ENCODE_FLAGS_ENCODE_BASIC_ENTITIES; break;
         case "latin1" : outputEntity = webPersist.ENCODE_FLAGS_ENCODE_LATIN1_ENTITIES; break;
         case "html"   : outputEntity = webPersist.ENCODE_FLAGS_ENCODE_HTML_ENTITIES; break;
         case "none"   : outputEntity = 0; break;
       }
     }
     catch (e) {}
   }
@@ -1706,26 +1699,19 @@ function SaveDocument(aSaveAs, aSaveCopy
         var fileHandler = GetFileProtocolHandler();
         tempLocalFile = fileHandler.getFileFromURLSpec(urlstring).QueryInterface(Components.interfaces.nsILocalFile);
       }
     }
 
     // this is the location where the related files will go
     var relatedFilesDir = null;
     
-    // First check pref for saving associated files
-    var saveAssociatedFiles = false;
-    try {
-      var prefs = GetPrefs();
-      saveAssociatedFiles = prefs.getBoolPref("editor.save_associated_files");
-    } catch (e) {}
-
     // Only change links or move files if pref is set 
-    //  and we are saving to a new location
-    if (saveAssociatedFiles && aSaveAs)
+    // and we are saving to a new location
+    if (Services.prefs.getBoolPref("editor.save_associated_files") && aSaveAs)
     {
       try {
         if (tempLocalFile)
         {
           // if we are saving to the same parent directory, don't set relatedFilesDir
           // grab old location, chop off file
           // grab new location, chop off file, compare
           var oldLocation = GetDocumentUrl();
@@ -2709,37 +2695,34 @@ var nsHLineCommand =
       window.openDialog("chrome://editor/content/EdHLineProps.xul", "_blank", "chrome,close,titlebar,modal");
     } 
     else
     {
       try {
         hLine = editor.createElementWithDefaults(tagName);
 
         // We change the default attributes to those saved in the user prefs
-        var prefs = GetPrefs();
-        var align = prefs.getIntPref("editor.hrule.align");
+        let align = Services.prefs.getIntPref("editor.hrule.align");
         if (align == 0)
           editor.setAttributeOrEquivalent(hLine, "align", "left", true);
         else if (align == 2)
           editor.setAttributeOrEquivalent(hLine, "align", "right", true);
 
         //Note: Default is center (don't write attribute)
   
-        var width = prefs.getIntPref("editor.hrule.width");
-        var percent = prefs.getBoolPref("editor.hrule.width_percent");
-        if (percent)
+        let width = Services.prefs.getIntPref("editor.hrule.width");
+        if (Services.prefs.getBoolPref("editor.hrule.width_percent"))
           width = width +"%";
 
         editor.setAttributeOrEquivalent(hLine, "width", width, true);
 
-        var height = prefs.getIntPref("editor.hrule.height");
+        let height = Services.prefs.getIntPref("editor.hrule.height");
         editor.setAttributeOrEquivalent(hLine, "size", String(height), true);
 
-        var shading = prefs.getBoolPref("editor.hrule.shading");
-        if (shading)
+        if (Services.prefs.getBoolPref("editor.hrule.shading"))
           hLine.removeAttribute("noshade");
         else
           hLine.setAttribute("noshade", "noshade");
 
         editor.insertElementAtSelection(hLine, true);
 
       } catch (e) {}
     }
--- a/editor/ui/composer/content/editingOverlay.js
+++ b/editor/ui/composer/content/editingOverlay.js
@@ -50,17 +50,17 @@ function EditorOnLoad()
 
   // Continue with normal startup.
   EditorStartup(url, charset);
 
   // Hide Highlight button if we are in an HTML editor with CSS mode off
   // and tell the editor if a CR in a paragraph creates a new paragraph.
   var cmd = document.getElementById("cmd_highlight");
   if (cmd) {
-    if (!gPrefs.getBoolPref(kUseCssPref))
+    if (!Services.prefs.getBoolPref(kUseCssPref))
       cmd.collapsed = true;
   }
 
   // Initialize our source text <editor>
   try {
     gSourceContentWindow = document.getElementById("content-source");
     gSourceContentWindow.makeEditable("text", false);
     gSourceTextEditor = gSourceContentWindow.getEditor(gSourceContentWindow.contentWindow);
@@ -91,19 +91,16 @@ function EditorStartup(aUrl, aCharset)
   var ds = GetCurrentEditorElement().docShell;
   ds.useErrorPages = false;
   var root = ds.QueryInterface(Components.interfaces.nsIDocShellTreeItem)
                .rootTreeItem.QueryInterface(Components.interfaces.nsIDocShell);
 
   root.QueryInterface(Components.interfaces.nsIDocShell).appType =
     Components.interfaces.nsIDocShell.APP_TYPE_EDITOR;
 
-  // Set up our global prefs object.
-  GetPrefsService();
-
   // EditorSharedStartup also used by Message Composer.
   EditorSharedStartup();
 
   // Commands specific to the Composer Application window,
   //  (i.e., not embedded editors)
   //  such as file-related commands, HTML Source editing, Edit Modes...
   SetupComposerWindowCommands();
 
--- a/editor/ui/composer/content/editor.js
+++ b/editor/ui/composer/content/editor.js
@@ -42,17 +42,16 @@ var gColorObj = { LastTextColor:"", Last
                   HighlightColor:"", BackgroundColor:"", PageColor:"",
                   TextColor:"", TableColor:"", CellColor:""
                 };
 var gDefaultTextColor = "";
 var gDefaultBackgroundColor = "";
 var gCSSPrefListener;
 var gEditorToolbarPrefListener;
 var gReturnInParagraphPrefListener;
-var gPrefs;
 var gLocalFonts = null;
 
 var gLastFocusNode = null;
 var gLastFocusNodeWasSelected = false;
 
 // These must be kept in synch with the XUL <options> lists
 var gFontSizeNames = ["xx-small","x-small","small","medium","large","x-large","xx-large"];
 
@@ -80,24 +79,24 @@ function ShowHideToolbarSeparators(toolb
       separator = null;
       hideSeparator = false;
     }
   }
 }
 
 function ShowHideToolbarButtons()
 {
-  var array = gPrefs.getChildList(kEditorToolbarPrefs);
-  for (var i in array) {
-    var prefName = array[i];
-    var id = prefName.substr(kEditorToolbarPrefs.length);
-    var button = document.getElementById(id + "Button") ||
+  let array = Services.prefs.getChildList(kEditorToolbarPrefs);
+  for (let i in array) {
+    let prefName = array[i];
+    let id = prefName.substr(kEditorToolbarPrefs.length);
+    let button = document.getElementById(id + "Button") ||
                  document.getElementById(id + "-button");
     if (button)
-      button.hidden = !gPrefs.getBoolPref(prefName);
+      button.hidden = !Services.prefs.getBoolPref(prefName);
   }
   ShowHideToolbarSeparators(document.getElementById("EditToolbar"));
   ShowHideToolbarSeparators(document.getElementById("FormatToolbar"));
 }
   
 function nsPrefListener(prefName)
 {
   this.startup(prefName);
@@ -124,51 +123,52 @@ nsPrefListener.prototype =
       dump("Failed to remove pref observers: " + ex + "\n");
     }
   },
   observe: function(subject, topic, prefName)
   {
     if (!IsHTMLEditor())
       return;
     // verify that we're changing a button pref
-    if (topic != "nsPref:changed") return;
+    if (topic != "nsPref:changed")
+      return;
     
-    var editor = GetCurrentEditor();
+    let editor = GetCurrentEditor();
     if (prefName == kUseCssPref)
     {
-      var cmd = document.getElementById("cmd_highlight");
+      let cmd = document.getElementById("cmd_highlight");
       if (cmd) {
-        var useCSS = gPrefs.getBoolPref(prefName);
+        let useCSS = Services.prefs.getBoolPref(prefName);
 
         if (useCSS && editor) {
-          var mixedObj = {};
-          var state = editor.getHighlightColorState(mixedObj);
+          let mixedObj = {};
+          let state = editor.getHighlightColorState(mixedObj);
           cmd.setAttribute("state", state);
           cmd.collapsed = false;
         }      
         else {
           cmd.setAttribute("state", "transparent");
           cmd.collapsed = true;
         }
 
         if (editor)
           editor.isCSSEnabled = useCSS;
       }
     }
     else if (prefName.substr(0, kEditorToolbarPrefs.length) == kEditorToolbarPrefs)
     {
-      var id = prefName.substr(kEditorToolbarPrefs.length) + "Button";
-      var button = document.getElementById(id);
+      let id = prefName.substr(kEditorToolbarPrefs.length) + "Button";
+      let button = document.getElementById(id);
       if (button) {
-        button.hidden = !gPrefs.getBoolPref(prefName);
+        button.hidden = !Services.prefs.getBoolPref(prefName);
         ShowHideToolbarSeparators(button.parentNode);
       }
     }
     else if (editor && (prefName == kCRInParagraphsPref))
-      editor.returnInParagraphCreatesNewParagraph = gPrefs.getBoolPref(prefName);
+      editor.returnInParagraphCreatesNewParagraph = Services.prefs.getBoolPref(prefName);
   }
 }
 
 const gSourceTextListener =
 {
   NotifyDocumentCreated: function NotifyDocumentCreated() {},
   NotifyDocumentWillBeDestroyed: function NotifyDocumentWillBeDestroyed() {},
   NotifyDocumentStateChanged: function NotifyDocumentStateChanged(isChanged)
@@ -284,17 +284,17 @@ var gEditorDocumentObserver =
         } catch (e) {}
 
         // Things for just the Web Composer application
         if (IsWebComposer())
         {
           InlineSpellCheckerUI.init(editor);
           document.getElementById('menu_inlineSpellCheck').setAttribute('disabled', !InlineSpellCheckerUI.canSpellCheck);
 
-          editor.returnInParagraphCreatesNewParagraph = gPrefs.getBoolPref(kCRInParagraphsPref);
+          editor.returnInParagraphCreatesNewParagraph = Services.prefs.getBoolPref(kCRInParagraphsPref);
 
           // Set focus to content window if not a mail composer
           // Race conditions prevent us from setting focus here
           //   when loading a url into blank window
           setTimeout(SetFocusOnStartup, 0);
 
           // Call EditorSetDefaultPrefsAndDoctype first so it gets the default author before initing toolbars
           editor.enableUndo(false);
@@ -471,18 +471,16 @@ function EditorSharedStartup()
   // And add "Del" or "Clear"
   SafeSetAttribute("menu_DeleteCellContents", "acceltext", delStr);
 
   // Set text for indent, outdent keybinding
 
   // hide UI that we don't have components for
   RemoveInapplicableUIElements();
 
-  gPrefs = GetPrefs();
-
   // Use browser colors as initial values for editor's default colors
   var BrowserColors = GetDefaultBrowserColors();
   if (BrowserColors)
   {
     gDefaultTextColor = BrowserColors.TextColor;
     gDefaultBackgroundColor = BrowserColors.BackgroundColor;
   }
 
@@ -1148,20 +1146,20 @@ function GetBackgroundElementWithColor()
     {
       gColorObj.Type = "Table";
       gColorObj.TableColor = gColorObj.BackgroundColor;
     }
     gColorObj.SelectedType = gColorObj.Type;
   }
   else
   {
-    var IsCSSPrefChecked = gPrefs.getBoolPref(kUseCssPref);
+    let IsCSSPrefChecked = Services.prefs.getBoolPref(kUseCssPref);
     if (IsCSSPrefChecked && IsHTMLEditor())
     {
-      var selection = editor.selection;
+      let selection = editor.selection;
       if (selection)
       {
         element = selection.focusNode;
         while (!editor.nodeIsBlock(element))
           element = element.parentNode;
       }
       else
       {
@@ -1572,31 +1570,27 @@ function SetEditMode(mode)
       }
     }
     // Get the entire document's source string
 
     var flags = (editor.documentCharacterSet == "ISO-8859-1")
       ? kOutputEncodeLatin1Entities
       : kOutputEncodeBasicEntities;
     try { 
-      var encodeEntity = gPrefs.getCharPref("editor.encode_entity");
+      let encodeEntity = Services.prefs.getCharPref("editor.encode_entity");
       switch (encodeEntity) {
         case "basic"  : flags = kOutputEncodeBasicEntities; break;
         case "latin1" : flags = kOutputEncodeLatin1Entities; break;
         case "html"   : flags = kOutputEncodeHTMLEntities; break;
         case "none"   : flags = 0;     break;
       }
     } catch (e) { }
 
-    try { 
-      var prettyPrint = gPrefs.getBoolPref("editor.prettyprint");
-      if (prettyPrint)
-        flags |= kOutputFormatted;
-
-    } catch (e) {}
+    if (Services.prefs.getBoolPref("editor.prettyprint"))
+      flags |= kOutputFormatted;
 
     flags |= kOutputLFLineBreak;
     var source = editor.outputToString(editor.contentsMIMEType, flags);
     var start = source.search(/<html/i);
     if (start == -1) start = 0;
     gSourceTextEditor.insertText(source.slice(start));
     gSourceTextEditor.resetModificationCount();
     gSourceTextEditor.addDocumentStateListener(gSourceTextListener);
@@ -1838,60 +1832,54 @@ function UpdateWindowTitle()
                      windowTitle +
                      xulWin.getAttribute("titlemenuseparator") + 
                      xulWin.getAttribute("titlemodifier");
   } catch (e) { dump(e); }
 }
 
 function SaveRecentFilesPrefs(aTitle, aFileType)
 {
-  // Can't do anything if no prefs
-  if (!gPrefs) return;
-
   var curUrl = StripPassword(GetDocumentUrl());
-  var historyCount = 10;
-  try {
-    historyCount = gPrefs.getIntPref("editor.history.url_maximum"); 
-  } catch(e) {}
+  var historyCount = Services.prefs.getIntPref("editor.history.url_maximum");
 
   var titleArray = [];
   var urlArray = [];
   var typeArray = [];
 
   if (historyCount && !IsUrlAboutBlank(curUrl) &&  GetScheme(curUrl) != "data")
   {
     titleArray.push(aTitle);
     urlArray.push(curUrl);
     typeArray.push(aFileType);
   }
 
-  for (var i = 0; i < historyCount && urlArray.length < historyCount; i++)
+  for (let i = 0; i < historyCount && urlArray.length < historyCount; i++)
   {
-    var url = GetUnicharPref("editor.history_url_"+i);
+    let url = 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")
     {
-      var title = GetUnicharPref("editor.history_title_"+i);
-      var fileType = GetUnicharPref("editor.history_type_" + i);
+      let title = GetStringPref("editor.history_title_" + i);
+      let fileType = 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 (i = 0; i < urlArray.length; i++)
+  for (let i = 0; i < urlArray.length; i++)
   {
-    SetUnicharPref("editor.history_title_"+i, titleArray[i]);
-    SetUnicharPref("editor.history_url_"+i, urlArray[i]);
-    SetUnicharPref("editor.history_type_" + i, typeArray[i]);
+    SetStringPref("editor.history_title_" + i, titleArray[i]);
+    SetStringPref("editor.history_url_" + i, urlArray[i]);
+    SetStringPref("editor.history_type_" + i, typeArray[i]);
   }
 }
 
 function EditorInitFormatMenu()
 {
   try {
     InitObjectPropertiesMenuitem();
     InitRemoveStylesMenuitems("removeStylesMenuitem", "removeLinksMenuitem", "removeNamedAnchorsMenuitem");
@@ -2180,18 +2168,18 @@ function EditorSetDefaultPrefsAndDoctype
   {
     // we should do charset first since we need to have charset before
     // hitting other 8-bit char in other meta tags
     // grab charset pref and make it the default charset
     var element;
     var prefCharsetString = 0;
     try
     {
-      prefCharsetString = gPrefs.getComplexValue("intl.charset.default",
-                                                 Components.interfaces.nsIPrefLocalizedString).data;
+      prefCharsetString = Services.prefs.getComplexValue("intl.charset.default",
+                                                         Components.interfaces.nsIPrefLocalizedString).data;
     }
     catch (ex) {}
     if ( prefCharsetString && prefCharsetString != 0)
       editor.documentCharacterSet = prefCharsetString;
 
     var node = 0;
     var listlength = nodelist.length;
 
@@ -2208,18 +2196,18 @@ function EditorSetDefaultPrefsAndDoctype
           authorFound = true;
         }
       }
     }
 
     var prefAuthorString = 0;
     try
     {
-      prefAuthorString = gPrefs.getComplexValue("editor.author",
-                                                Components.interfaces.nsISupportsString).data;
+      prefAuthorString = Services.prefs.getComplexValue("editor.author",
+                                                        Components.interfaces.nsISupportsString).data;
     }
     catch (ex) {}
     if ( prefAuthorString && prefAuthorString != 0)
     {
       if ( !authorFound && headelement)
       {
         /* create meta tag with 2 attributes */
         element = domdoc.createElement("meta");
@@ -2237,67 +2225,38 @@ function EditorSetDefaultPrefsAndDoctype
   var titlenodelist = editor.document.getElementsByTagName("title");
   if (headelement && titlenodelist && titlenodelist.length == 0)
   {
      var titleElement = domdoc.createElement("title");
      if (titleElement)
        headelement.appendChild(titleElement);
   }
 
-  // Get editor color prefs
-  var use_custom_colors = false;
-  try {
-    use_custom_colors = gPrefs.getBoolPref("editor.use_custom_colors");
-  }
-  catch (ex) {}
-
   // find body node
   var bodyelement = GetBodyElement();
   if (bodyelement)
   {
-    if ( use_custom_colors )
+    if (Services.prefs.getBoolPref("editor.use_custom_colors"))
     {
-      // try to get the default color values.  ignore them if we don't have them.
-      var text_color;
-      var link_color;
-      var active_link_color;
-      var followed_link_color;
-      var background_color;
-
-      try { text_color = gPrefs.getCharPref("editor.text_color"); } catch (e) {}
-      try { link_color = gPrefs.getCharPref("editor.link_color"); } catch (e) {}
-      try { active_link_color = gPrefs.getCharPref("editor.active_link_color"); } catch (e) {}
-      try { followed_link_color = gPrefs.getCharPref("editor.followed_link_color"); } catch (e) {}
-      try { background_color = gPrefs.getCharPref("editor.background_color"); } catch(e) {}
+      let text_color = Services.prefs.getCharPref("editor.text_color");
+      let background_color = Services.prefs.getCharPref("editor.background_color");
 
       // add the color attributes to the body tag.
       // and use them for the default text and background colors if not empty
-      try {
-        if (text_color)
-        {
-          editor.setAttributeOrEquivalent(bodyelement, "text", text_color, true);
-          gDefaultTextColor = text_color;
-        }
-        if (background_color)
-        {
-          editor.setAttributeOrEquivalent(bodyelement, "bgcolor", background_color, true);
-          gDefaultBackgroundColor = background_color
-        }
-
-        if (link_color)
-          bodyelement.setAttribute("link", link_color);
-        if (active_link_color)
-          bodyelement.setAttribute("alink", active_link_color);
-        if (followed_link_color)
-          bodyelement.setAttribute("vlink", followed_link_color);
-      } catch (e) {}
+      editor.setAttributeOrEquivalent(bodyelement, "text", text_color, true);
+      gDefaultTextColor = text_color;
+      editor.setAttributeOrEquivalent(bodyelement, "bgcolor", background_color, true);
+      gDefaultBackgroundColor = background_color
+      bodyelement.setAttribute("link", Services.prefs.getCharPref("editor.link_color"));
+      bodyelement.setAttribute("alink", Services.prefs.getCharPref("editor.active_link_color"));
+      bodyelement.setAttribute("vlink", Services.prefs.getCharPref("editor.followed_link_color"));
     }
     // Default image is independent of Custom colors???
     try {
-      var background_image = gPrefs.getCharPref("editor.default_background_image");
+      let background_image = Services.prefs.getCharPref("editor.default_background_image");
       if (background_image)
         editor.setAttributeOrEquivalent(bodyelement, "background", background_image, true);
     } catch (e) {dump("BACKGROUND EXCEPTION: "+e+"\n"); }
 
   }
   // auto-save???
 }
 
--- a/editor/ui/composer/content/editorUtilities.js
+++ b/editor/ui/composer/content/editorUtilities.js
@@ -1,12 +1,14 @@
 /* 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/. */
 
+Components.utils.import("resource://gre/modules/Services.jsm");
+
 /**** NAMESPACES ****/
 const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
 
 // Each editor window must include this file
 // Variables  shared by all dialogs:
 
 // Object to attach commonly-used widgets (all dialogs should use this)
 var gDialog = {};
@@ -17,18 +19,16 @@ const kOutputEncodeLatin1Entities = Comp
 const kOutputEncodeW3CEntities = Components.interfaces.nsIDocumentEncoder.OutputEncodeW3CEntities;
 const kOutputFormatted = Components.interfaces.nsIDocumentEncoder.OutputFormatted;
 const kOutputLFLineBreak = Components.interfaces.nsIDocumentEncoder.OutputLFLineBreak;
 const kOutputSelectionOnly = Components.interfaces.nsIDocumentEncoder.OutputSelectionOnly;
 const kOutputWrap = Components.interfaces.nsIDocumentEncoder.OutputWrap;
 
 var gStringBundle;
 var gIOService;
-var gPrefsService;
-var gPrefsBranch;
 var gFilePickerDirectory;
 
 var gOS = "";
 const gWin = "Win";
 const gUNIX = "UNIX";
 const gMac = "Mac";
 
 const kWebComposerWindowID = "editorWindow";
@@ -461,168 +461,100 @@ function GetIOService()
 
 function GetFileProtocolHandler()
 {
   var ios = GetIOService();
   var handler = ios.getProtocolHandler("file");
   return handler.QueryInterface(Components.interfaces.nsIFileProtocolHandler);
 }
 
-function GetPrefsService()
-{
-  if (gPrefsService)
-    return gPrefsService;
-
-  try {
-    gPrefsService = Components.classes["@mozilla.org/preferences-service;1"].getService(Components.interfaces.nsIPrefService);
-  }
-  catch(ex) {
-    dump("failed to get prefs service!\n");
-  }
-
-  return gPrefsService;
-}
-
-function GetPrefs()
-{
-  if (gPrefsBranch)
-    return gPrefsBranch;
-
-  try {
-    var prefService = GetPrefsService();
-    if (prefService)
-      gPrefsBranch = prefService.getBranch(null);
-
-    if (gPrefsBranch)
-      return gPrefsBranch;
-    else
-      dump("failed to get root prefs!\n");
-  }
-  catch(ex) {
-    dump("failed to get root prefs!\n");
-  }
-  return null;
-}
-
 function GetStringPref(name)
 {
   try {
-    return GetPrefs().getComplexValue(name, Components.interfaces.nsISupportsString).data;
+    return Services.prefs.getComplexValue(name, Components.interfaces.nsISupportsString).data;
   } catch (e) {}
   return "";
 }
 
-function GetBoolPref(name)
+function SetStringPref(aPrefName, aPrefValue)
 {
   try {
-    return GetPrefs().getBoolPref(name);
-  } catch (e) {}
-  return false;
-}
-
-function SetUnicharPref(aPrefName, aPrefValue)
-{
-  var prefs = GetPrefs();
-  if (prefs)
-  {
-    try {
-      var str = Components.classes["@mozilla.org/supports-string;1"]
-                          .createInstance(Components.interfaces.nsISupportsString);
-      str.data = aPrefValue;
-      prefs.setComplexValue(aPrefName, Components.interfaces.nsISupportsString, str);
-    }
-    catch(e) {}
+    let str = Components.classes["@mozilla.org/supports-string;1"]
+                        .createInstance(Components.interfaces.nsISupportsString);
+    str.data = aPrefValue;
+    Services.prefs.setComplexValue(aPrefName, Components.interfaces.nsISupportsString, str);
   }
-}
-
-function GetUnicharPref(aPrefName, aDefVal)
-{
-  var prefs = GetPrefs();
-  if (prefs)
-  {
-    try {
-      return prefs.getComplexValue(aPrefName, Components.interfaces.nsISupportsString).data;
-    }
-    catch(e) {}
-  }
-  return "";
+  catch(e) {}
 }
 
 // Set initial directory for a filepicker from URLs saved in prefs
 function SetFilePickerDirectory(filePicker, fileType)
 {
   if (filePicker)
   {
     try {
-      var prefBranch = GetPrefs();
-      if (prefBranch)
-      {
-        // Save current directory so we can reset it in SaveFilePickerDirectory
-        gFilePickerDirectory = filePicker.displayDirectory;
+      // Save current directory so we can reset it in SaveFilePickerDirectory
+      gFilePickerDirectory = filePicker.displayDirectory;
 
-        var location = prefBranch.getComplexValue("editor.lastFileLocation."+fileType, Components.interfaces.nsILocalFile);
-        if (location)
-          filePicker.displayDirectory = location;
-      }
+      let location = Services.prefs.getComplexValue("editor.lastFileLocation."+fileType,
+                                                    Components.interfaces.nsILocalFile);
+      if (location)
+        filePicker.displayDirectory = location;
     }
     catch(e) {}
   }
 }
 
 // Save the directory of the selected file to prefs
 function SaveFilePickerDirectory(filePicker, fileType)
 {
   if (filePicker && filePicker.file)
   {
     try {
-      var prefBranch = GetPrefs();
-
       var fileDir;
       if (filePicker.file.parent)
         fileDir = filePicker.file.parent.QueryInterface(Components.interfaces.nsILocalFile);
 
-      if (prefBranch)
-       prefBranch.setComplexValue("editor.lastFileLocation."+fileType, Components.interfaces.nsILocalFile, fileDir);
-    
-      var prefsService = GetPrefsService();
-        prefsService.savePrefFile(null);
+        Services.prefs.setComplexValue("editor.lastFileLocation." + fileType,
+                                       Components.interfaces.nsILocalFile, fileDir);
+
+        Services.prefs.savePrefFile(null);
     } catch (e) {}
   }
 
   // Restore the directory used before SetFilePickerDirectory was called;
   // This reduces interference with Browser and other module directory defaults
   if (gFilePickerDirectory)
     filePicker.displayDirectory = gFilePickerDirectory;
 
   gFilePickerDirectory = null;
 }
 
 function GetDefaultBrowserColors()
 {
-  var prefs = GetPrefs();
   var colors = { TextColor:0, BackgroundColor:0, LinkColor:0, ActiveLinkColor:0 , VisitedLinkColor:0 };
   var useSysColors = false;
-  try { useSysColors = prefs.getBoolPref("browser.display.use_system_colors"); } catch (e) {}
+  try { useSysColors = Services.prefs.getBoolPref("browser.display.use_system_colors"); } catch (e) {}
 
   if (!useSysColors)
   {
-    try { colors.TextColor = prefs.getCharPref("browser.display.foreground_color"); } catch (e) {}
+    try { colors.TextColor = Services.prefs.getCharPref("browser.display.foreground_color"); } catch (e) {}
 
-    try { colors.BackgroundColor = prefs.getCharPref("browser.display.background_color"); } catch (e) {}
+    try { colors.BackgroundColor = Services.prefs.getCharPref("browser.display.background_color"); } catch (e) {}
   }
   // Use OS colors for text and background if explicitly asked or pref is not set
   if (!colors.TextColor)
     colors.TextColor = "windowtext";
 
   if (!colors.BackgroundColor)
     colors.BackgroundColor = "window";
 
-  colors.LinkColor = prefs.getCharPref("browser.anchor_color");
-  colors.ActiveLinkColor = prefs.getCharPref("browser.active_color");
-  colors.VisitedLinkColor = prefs.getCharPref("browser.visited_color");
+  colors.LinkColor = Services.prefs.getCharPref("browser.anchor_color");
+  colors.ActiveLinkColor = Services.prefs.getCharPref("browser.active_color");
+  colors.VisitedLinkColor = Services.prefs.getCharPref("browser.visited_color");
 
   return colors;
 }
 
 /************* URL handling ***************/
 
 function TextIsURI(selectedText)
 {
@@ -1059,20 +991,18 @@ function ConvertRGBColorIntoHEXColor(col
     return color;
   }
 }
 
 /************* CSS ***************/
 
 function GetHTMLOrCSSStyleValue(element, attrName, cssPropertyName)
 {
-  var prefs = GetPrefs();
-  var IsCSSPrefChecked = prefs.getBoolPref("editor.use_css");
   var value;
-  if (IsCSSPrefChecked && IsHTMLEditor())
+  if (Services.prefs.getBoolPref("editor.use_css") && IsHTMLEditor())
     value = element.style.getPropertyValue(cssPropertyName);
 
   if (!value)
     value = element.getAttribute(attrName);
 
   if (!value)
     return "";
 
--- a/editor/ui/composer/content/pref-editing.js
+++ b/editor/ui/composer/content/pref-editing.js
@@ -1,47 +1,45 @@
 /* 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/. */
 
-var gPrefService = Components.classes["@mozilla.org/preferences-service;1"]
-                             .getService(Components.interfaces.nsIPrefBranch);
 const browserPrefsObserver =
 {
   observe: function(aSubject, aTopic, aData)
   {
     if (aTopic != "nsPref:changed" || document.getElementById("editor.use_custom_colors").value)
       return;
 
     switch (aData)
     {
       case "browser.anchor_color":
-        SetColorPreview("linkText", gPrefService.getCharPref(aData));
+        SetColorPreview("linkText", Services.prefs.getCharPref(aData));
         break;
       case "browser.active_color":
-        SetColorPreview("activeLinkText", gPrefService.getCharPref(aData));
+        SetColorPreview("activeLinkText", Services.prefs.getCharPref(aData));
         break;
       case "browser.visited_color":
-        SetColorPreview("visitedLinkText", gPrefService.getCharPref(aData));
+        SetColorPreview("visitedLinkText", Services.prefs.getCharPref(aData));
         break;
       default:
-        SetBgAndFgColors(gPrefService.getBoolPref("browser.display.use_system_colors"))
+        SetBgAndFgColors(Services.prefs.getBoolPref("browser.display.use_system_colors"))
     }
   }
 };
 
 function Startup()
 {
   // Add browser prefs observers
-  gPrefService.addObserver("browser.display.use_system_colors", browserPrefsObserver, false);
-  gPrefService.addObserver("browser.display.foreground_color", browserPrefsObserver, false);
-  gPrefService.addObserver("browser.display.background_color", browserPrefsObserver, false);
-  gPrefService.addObserver("browser.anchor_color", browserPrefsObserver, false);
-  gPrefService.addObserver("browser.active_color", browserPrefsObserver, false);
-  gPrefService.addObserver("browser.visited_color", browserPrefsObserver, false);
+  Services.prefs.addObserver("browser.display.use_system_colors", browserPrefsObserver, false);
+  Services.prefs.addObserver("browser.display.foreground_color", browserPrefsObserver, false);
+  Services.prefs.addObserver("browser.display.background_color", browserPrefsObserver, false);
+  Services.prefs.addObserver("browser.anchor_color", browserPrefsObserver, false);
+  Services.prefs.addObserver("browser.active_color", browserPrefsObserver, false);
+  Services.prefs.addObserver("browser.visited_color", browserPrefsObserver, false);
 
   // Add event listener so we can remove our observers
   window.addEventListener("unload", WindowOnUnload, false);
   UpdateDependent(document.getElementById("editor.use_custom_colors").value);
 }
 
 function GetColorAndUpdatePref(aType, aButtonID)
 {
@@ -78,20 +76,20 @@ function UpdateDependent(aCustomEnabled)
     SetColors("textCW", "normalText", document.getElementById("editor.text_color").value);
     SetColors("linkCW", "linkText", document.getElementById("editor.link_color").value);
     SetColors("activeCW", "activeLinkText", document.getElementById("editor.active_link_color").value);
     SetColors("visitedCW", "visitedLinkText", document.getElementById("editor.followed_link_color").value);
     SetColors("backgroundCW", "ColorPreview", document.getElementById("editor.background_color").value);
   }
   else
   { // Set current browser colors on preview
-    SetBgAndFgColors(gPrefService.getBoolPref("browser.display.use_system_colors"));
-    SetColorPreview("linkText", gPrefService.getCharPref("browser.anchor_color"));
-    SetColorPreview("activeLinkText", gPrefService.getCharPref("browser.active_color"));
-    SetColorPreview("visitedLinkText", gPrefService.getCharPref("browser.visited_color"));
+    SetBgAndFgColors(Services.prefs.getBoolPref("browser.display.use_system_colors"));
+    SetColorPreview("linkText", Services.prefs.getCharPref("browser.anchor_color"));
+    SetColorPreview("activeLinkText", Services.prefs.getCharPref("browser.active_color"));
+    SetColorPreview("visitedLinkText", Services.prefs.getCharPref("browser.visited_color"));
   }
 }
 
 function ToggleElements(aCustomEnabled)
 {
   var buttons = document.getElementById("color-rows").getElementsByTagName("button");
   
   for (var i = 0; i < buttons.length; i++)
@@ -148,18 +146,18 @@ function SetBgAndFgColors(aSysPrefEnable
 {
   if (aSysPrefEnabled)
   { // Use system colors
     SetColorPreview("normalText", "windowtext");
     SetColorPreview("ColorPreview", "window");
   }
   else
   {
-    SetColorPreview("normalText", gPrefService.getCharPref("browser.display.foreground_color"));
-    SetColorPreview("ColorPreview", gPrefService.getCharPref("browser.display.background_color"));
+    SetColorPreview("normalText", Services.prefs.getCharPref("browser.display.foreground_color"));
+    SetColorPreview("ColorPreview", Services.prefs.getCharPref("browser.display.background_color"));
   }
 }
 
 function ChooseImageFile()
 {
   const nsIFilePicker = Components.interfaces.nsIFilePicker;
   var fp = Components.classes["@mozilla.org/filepicker;1"]
                      .createInstance(nsIFilePicker);
@@ -172,16 +170,16 @@ function ChooseImageFile()
 
   var textbox = document.getElementById("backgroundImageInput");
   textbox.focus();
   textbox.select();
 }
 
 function WindowOnUnload()
 {
-  gPrefService.removeObserver("browser.display.use_system_colors", browserPrefsObserver, false);
-  gPrefService.removeObserver("browser.display.foreground_color", browserPrefsObserver, false);
-  gPrefService.removeObserver("browser.display.background_color", browserPrefsObserver, false);
-  gPrefService.removeObserver("browser.anchor_color", browserPrefsObserver, false);
-  gPrefService.removeObserver("browser.active_color", browserPrefsObserver, false);
-  gPrefService.removeObserver("browser.visited_color", browserPrefsObserver, false);
+  Services.prefs.removeObserver("browser.display.use_system_colors", browserPrefsObserver, false);
+  Services.prefs.removeObserver("browser.display.foreground_color", browserPrefsObserver, false);
+  Services.prefs.removeObserver("browser.display.background_color", browserPrefsObserver, false);
+  Services.prefs.removeObserver("browser.anchor_color", browserPrefsObserver, false);
+  Services.prefs.removeObserver("browser.active_color", browserPrefsObserver, false);
+  Services.prefs.removeObserver("browser.visited_color", browserPrefsObserver, false);
   window.removeEventListener("unload", WindowOnUnload, false);
 }
--- a/editor/ui/composer/content/publishprefs.js
+++ b/editor/ui/composer/content/publishprefs.js
@@ -1,14 +1,13 @@
 /* -*- Mode: Java; tab-width: 4; 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/. */
 
-
 /****************** Get publishing data methods *******************/
 
 // Build an array of all publish site data obtained from prefs
 function GetPublishSiteData()
 {
   var publishBranch = GetPublishPrefsBranch();
   if (!publishBranch)
     return null;
@@ -537,31 +536,26 @@ function SetDefaultSiteName(name)
 
     SavePrefFile();
   }
 }
 
 function SavePrefFile()
 {
   try {
-    if (gPrefsService)
-      gPrefsService.savePrefFile(null);
+    Services.prefs.savePrefFile(null);
   }
   catch (e) {}
 }
 
 /***************** Helper / utility methods ********************/
 
 function GetPublishPrefsBranch()
 {
-  var prefsService = GetPrefsService();
-  if (!prefsService)
-    return null;
-
-  return prefsService.getBranch("editor.publish.");
+  return Services.prefs.getBranch("editor.publish.");
 }
 
 function GetSiteNameList(doSort, defaultFirst)
 {
   var publishBranch = GetPublishPrefsBranch();
   if (!publishBranch)
     return null;
 
--- a/editor/ui/dialogs/content/EdColorPicker.js
+++ b/editor/ui/dialogs/content/EdColorPicker.js
@@ -1,14 +1,15 @@
 /* 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/. */
 
 
 //Cancel() is in EdDialogCommon.js
+
 var insertNew = true;
 var tagname = "TAG NAME"
 var gColor = "";
 var LastPickedColor = "";
 var ColorType = "Text";
 var TextType = false;
 var HighlightType = false;
 var TableOrCell = false;
@@ -42,18 +43,17 @@ function Startup()
   // The type of color we are setting: 
   //  text: Text, Link, ActiveLink, VisitedLink, 
   //  or background: Page, Table, or Cell
   if (gColorObj.Type)
   {
     ColorType = gColorObj.Type;
     // Get string for dialog title from passed-in type 
     //   (note constraint on editor.properties string name)
-    var prefs = GetPrefs();
-    var IsCSSPrefChecked = prefs.getBoolPref("editor.use_css");
+    let IsCSSPrefChecked = Services.prefs.getBoolPref("editor.use_css");
 
     if (GetCurrentEditor())
     {
       if (ColorType == "Page" && IsCSSPrefChecked && IsHTMLEditor())
         document.title = GetString("BlockColor");
       else
         document.title = GetString(ColorType + "Color");
     }
--- a/editor/ui/dialogs/content/EdConvertToTable.js
+++ b/editor/ui/dialogs/content/EdConvertToTable.js
@@ -66,17 +66,17 @@ function SelectCharacter(radioGroupIndex
   gIndex = radioGroupIndex;
   SetElementEnabledById("SepCharacterInput", gIndex == gOtherIndex);
   SetElementEnabledById("CollapseSpaces", gIndex == gSpaceIndex);
 }
 
 function onAccept()
 {
   var sepCharacter = "";
-  switch ( gIndex )
+  switch (gIndex)
   {
     case gCommaIndex:
       sepCharacter = ",";
       break;
     case gSpaceIndex:
       sepCharacter = " ";
       break;
     case gOtherIndex:
@@ -135,28 +135,28 @@ function onAccept()
 
     if (start >= 0)
     {
       end = str.indexOf(">", start+1);
       if (end > start)
       {
         var tagContent = TrimString(str.slice(start+1, end));
 
-        if ( /^ol|^ul|^dl/.test(tagContent) )
+        if (/^ol|^ul|^dl/.test(tagContent))
         {
           //  Replace list tag with <BR> to start new row 
           //   at begining of second or greater list tag
           str = str.slice(0, start) + listSeparator + str.slice(end+1);
           if (listSeparator == "")
             listSeparator = "<br>";
           
           // Reset for list item separation into cells
           listItemSeparator = "";
         }
-        else if ( /^li|^dt|^dd/.test(tagContent) )
+        else if (/^li|^dt|^dd/.test(tagContent))
         {
           // Start a new row if this is first item after the ending the last list
           if (endList)
             listItemSeparator = "<br>";
 
           // Start new cell at begining of second or greater list items
           str = str.slice(0, start) + listItemSeparator + str.slice(end+1);
 
@@ -164,17 +164,17 @@ function onAccept()
             listItemSeparator = sepCharacter;
 
           endList = false;
         }
         else 
         {
           // Find end tags
           endList = /^\/ol|^\/ul|^\/dl/.test(tagContent);
-          if ( endList || /^\/li|^\/dt|^\/dd/.test(tagContent) )
+          if (endList || /^\/li|^\/dt|^\/dd/.test(tagContent))
           {
             // Strip out tag
             str = str.slice(0, start) + str.slice(end+1);
           }
           else
           {
             // Not a list-related tag: Store tag contents in an array
             stack.push(tagContent);
@@ -287,20 +287,19 @@ function onAccept()
     var next = nodeBeforeTable.nextSibling;
     if (next && next.nodeName.toLowerCase() == "table")
       table = next;
   }
 
   if (table)
   {
     // Fixup table only if pref is set
-    var prefs = GetPrefs();
     var firstRow;
     try {
-      if (prefs && prefs.getBoolPref("editor.table.maintain_structure") )
+      if (Services.prefs.getBoolPref("editor.table.maintain_structure"))
         editor.normalizeTable(table);
 
       firstRow = editor.getFirstRow(table);
     } catch(e) {}
 
     // Put caret in first cell
     if (firstRow)
     {
--- a/editor/ui/dialogs/content/EdHLineProps.js
+++ b/editor/ui/dialogs/content/EdHLineProps.js
@@ -95,61 +95,55 @@ function InitDialog()
   gDialog.shading.checked = !globalElement.hasAttribute("noshade");
 }
 
 function onSaveDefault()
 {
   // "false" means set attributes on the globalElement,
   //   not the real element being edited
   if (ValidateData()) {
-    var prefs = GetPrefs();
-    if (prefs) {
+    var alignInt;
+    if (align == "left") {
+      alignInt = 0;
+    } else if (align == "right") {
+      alignInt = 2;
+    } else {
+      alignInt = 1;
+    }
+    Services.prefs.setIntPref("editor.hrule.align", alignInt);
 
-      var alignInt;
-      if (align == "left") {
-        alignInt = 0;
-      } else if (align == "right") {
-        alignInt = 2;
-      } else {
-        alignInt = 1;
-      }
-      prefs.setIntPref("editor.hrule.align", alignInt);
-
-      var percent;
-      var widthInt;
-      var heightInt;
+    var percent;
+    var widthInt;
+    var heightInt;
 
-      if (width)
-      {
-        if (/%/.test(width)) {
-          percent = true;
-          widthInt = Number(RegExp.leftContext);
-        } else {
-          percent = false;
-          widthInt = Number(width);
-        }
-      }
-      else
-      {
+    if (width)
+    {
+      if (/%/.test(width)) {
         percent = true;
-        widthInt = Number(100);
+        widthInt = Number(RegExp.leftContext);
+      } else {
+        percent = false;
+        widthInt = Number(width);
       }
-
-      heightInt = height ? Number(height) : 2;
+    }
+    else
+    {
+      percent = true;
+      widthInt = Number(100);
+    }
 
-      prefs.setIntPref("editor.hrule.width", widthInt);
-      prefs.setBoolPref("editor.hrule.width_percent", percent);
-      prefs.setIntPref("editor.hrule.height", heightInt);
-      prefs.setBoolPref("editor.hrule.shading", shading);
+    heightInt = height ? Number(height) : 2;
 
-      // Write the prefs out NOW!
-      var prefService = Components.classes["@mozilla.org/preferences-service;1"]
-                                  .getService(Components.interfaces.nsIPrefService);
-      prefService.savePrefFile(null);
-    }
+    Services.prefs.setIntPref("editor.hrule.width", widthInt);
+    Services.prefs.setBoolPref("editor.hrule.width_percent", percent);
+    Services.prefs.setIntPref("editor.hrule.height", heightInt);
+    Services.prefs.setBoolPref("editor.hrule.shading", shading);
+
+    // Write the prefs out NOW!
+    Services.prefs.savePrefFile(null);
 	}
 }
 
 // Get and validate data from widgets.
 // Set attributes on globalElement so they can be accessed by AdvancedEdit()
 function ValidateData()
 {
   // Height is always pixels
--- a/editor/ui/dialogs/content/EdInsertTable.js
+++ b/editor/ui/dialogs/content/EdInsertTable.js
@@ -1,13 +1,14 @@
 /* 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/. */
 
 //Cancel() is in EdDialogCommon.js
+
 var gTableElement = null;
 var gRows;
 var gColumns;
 var gActiveEditor;
 
 // dialog initialization code
 function Startup()
 {
@@ -34,17 +35,17 @@ function Startup()
   gDialog.widthInput = document.getElementById("widthInput");
   gDialog.borderInput = document.getElementById("borderInput");
   gDialog.widthPixelOrPercentMenulist = document.getElementById("widthPixelOrPercentMenulist");
   gDialog.OkButton = document.documentElement.getButton("accept");
 
   // Make a copy to use for AdvancedEdit
   globalElement = gTableElement.cloneNode(false);
   try {
-    if (GetPrefs().getBoolPref("editor.use_css") && IsHTMLEditor()
+    if (Services.prefs.getBoolPref("editor.use_css") && IsHTMLEditor()
         && !(gActiveEditor.flags & Components.interfaces.nsIPlaintextEditor.eEditorMailMask))
     {
       // only for Composer and not for htmlmail
       globalElement.setAttribute("style", "text-align: left;");
     }
   } catch (e) {}
 
   // Initialize all widgets with image attributes
--- a/editor/ui/dialogs/content/EdPageProps.js
+++ b/editor/ui/dialogs/content/EdPageProps.js
@@ -103,19 +103,17 @@ function Startup()
 function InitDialog()
 {
   gDialog.TitleInput.value = GetDocumentTitle();
 
   var gAuthor = TrimString(gAuthorElement.getAttribute("content"));
   if (!gAuthor)
   {
     // Fill in with value from editor prefs
-    var prefs = GetPrefs();
-    if (prefs) 
-      gAuthor = prefs.getCharPref("editor.author");
+    gAuthor = Services.prefs.getCharPref("editor.author");
   }
   gDialog.AuthorInput.value = gAuthor;
   gDialog.DescriptionInput.value = gDescriptionElement.getAttribute("content");
 }
 
 function TextboxChanged(ID)
 {
   switch(ID)
--- a/editor/ui/dialogs/content/EdSnapToGrid.js
+++ b/editor/ui/dialogs/content/EdSnapToGrid.js
@@ -1,13 +1,12 @@
 /* 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/. */
 
-var gPrefs = GetPrefs();
 var gEditor;
 
 // dialog initialization code
 function Startup()
 {
   gEditor = GetCurrentEditor();
   if (!gEditor)
   {
--- a/editor/ui/dialogs/content/EdTableProps.js
+++ b/editor/ui/dialogs/content/EdTableProps.js
@@ -1,13 +1,14 @@
 /* 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/. */
 
 //Cancel() is in EdDialogCommon.js
+
 var gTableElement;
 var gCellElement;
 var gTableCaptionElement;
 var globalCellElement;
 var globalTableElement
 var gValidateTab;
 const defHAlign =   "left";
 const centerStr =   "center";  //Index=1
@@ -54,17 +55,16 @@ From C++:
  3 TABLESELECTION_COLUMN All cells are in 1 or more columns
 */
 
 var gSelectedCellCount = 0;
 var gApplyUsed = false;
 var gSelection;
 var gCellDataChanged = false;
 var gCanDelete = false;
-var gPrefs = GetPrefs();
 var gUseCSS = true;
 var gActiveEditor;
 
 // dialog initialization code
 function Startup()
 {
   gActiveEditor = GetCurrentTableEditor();
   if (!gActiveEditor)
@@ -81,17 +81,17 @@ function Startup()
   // Get dialog widgets - Table Panel
   gDialog.TableRowsInput = document.getElementById("TableRowsInput");
   gDialog.TableColumnsInput = document.getElementById("TableColumnsInput");
   gDialog.TableWidthInput = document.getElementById("TableWidthInput");
   gDialog.TableWidthUnits = document.getElementById("TableWidthUnits");
   gDialog.TableHeightInput = document.getElementById("TableHeightInput");
   gDialog.TableHeightUnits = document.getElementById("TableHeightUnits");
   try {
-    if (!gPrefs.getBoolPref("editor.use_css") || (gActiveEditor.flags & 1))
+    if (!Services.prefs.getBoolPref("editor.use_css") || (gActiveEditor.flags & 1))
     {
       gUseCSS = false;
       var tableHeightLabel = document.getElementById("TableHeightLabel");
       tableHeightLabel.parentNode.removeChild(tableHeightLabel);
       gDialog.TableHeightInput.parentNode.removeChild(gDialog.TableHeightInput);
       gDialog.TableHeightUnits.parentNode.removeChild(gDialog.TableHeightUnits);
     }
   } catch (e) {}
--- a/editor/ui/dialogs/content/EditorPublish.js
+++ b/editor/ui/dialogs/content/EditorPublish.js
@@ -46,17 +46,17 @@ function Startup()
   // Settings Panel
   gDialog.SiteNameInput       = document.getElementById("SiteNameInput");
   gDialog.PublishUrlInput     = document.getElementById("PublishUrlInput");
   gDialog.BrowseUrlInput      = document.getElementById("BrowseUrlInput");
   gDialog.UsernameInput       = document.getElementById("UsernameInput");
   gDialog.PasswordInput       = document.getElementById("PasswordInput");
   gDialog.SavePassword        = document.getElementById("SavePassword");
 
-  gPasswordManagerOn = GetBoolPref("signon.rememberSignons");
+  gPasswordManagerOn = Services.prefs.getBoolPref("signon.rememberSignons");
   gDialog.SavePassword.disabled = !gPasswordManagerOn;
 
   gPublishSiteData = GetPublishSiteData();
   gDefaultSiteName = GetDefaultPublishSiteName();
 
   var addNewSite = false;
   if (gPublishSiteData)
   {
--- a/editor/ui/dialogs/content/EditorPublishSettings.js
+++ b/editor/ui/dialogs/content/EditorPublishSettings.js
@@ -33,17 +33,17 @@ function Startup()
   gDialog.SetDefaultButton    = document.getElementById("SetDefaultButton");
   gDialog.RemoveSiteButton    = document.getElementById("RemoveSiteButton");
   gDialog.OkButton            = document.documentElement.getButton("accept");
 
   gPublishSiteData = GetPublishSiteData();
   gDefaultSiteName = GetDefaultPublishSiteName();
   gPreviousDefaultSite = gDefaultSiteName;
 
-  gPasswordManagerOn = GetBoolPref("signon.rememberSignons");
+  gPasswordManagerOn = Services.prefs.getBoolPref("signon.rememberSignons");
   gDialog.SavePassword.disabled = !gPasswordManagerOn;
 
   InitDialog();
 
   SetWindowLocation();
 }
 
 function InitDialog()