Remove obsolete getPref helpers.

This commit is contained in:
Ascrod 2019-03-24 20:22:03 -04:00 • committed by Roy Tam
commit 8d45fa6874
15 changed files with 103 additions and 307 deletions

View file

@ -52,11 +52,9 @@ var browserMenuDragging = {
initPref: function(){
this.STAY_OPEN_ONDRAGEXIT =
this.getPref('browser.menu.dragging.stayOpen',
'bool', false);
Services.prefs.getBoolPref('browser.menu.dragging.stayOpen', false);
this.DEBUG =
this.getPref('browser.menu.dragging.debug',
'bool', false);
Services.prefs.getBoolPref('browser.menu.dragging.debug', false);
},
//delayed startup
@ -291,26 +289,6 @@ var browserMenuDragging = {
.logStringMessage(aMsg);
},
getPref: function(aPrefString, aPrefType, aDefault){
var xpPref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);
try{
switch (aPrefType){
case 'complex':
return xpPref.getComplexValue(aPrefString, Components.interfaces.nsILocalFile); break;
case 'str':
return xpPref.getCharPref(aPrefString).toString(); break;
case 'int':
return xpPref.getIntPref(aPrefString); break;
case 'bool':
default:
return xpPref.getBoolPref(aPrefString); break;
}
}catch(e){
}
return aDefault;
},
setPref: function(aPrefString, aPrefType, aValue){
var xpPref = Components.classes["@mozilla.org/preferences-service;1"]
.getService(Components.interfaces.nsIPrefService);

View file

@ -1147,7 +1147,7 @@ var gBrowserInit = {
// Setup click-and-hold gestures access to the session history
// menus if global click-and-hold isn't turned on
if (!getBoolPref("ui.click_hold_context_menus", false))
if (!Services.prefs.getBoolPref("ui.click_hold_context_menus", false))
SetClickAndHoldHandlers();
// Initialize the full zoom setting.
@ -1783,7 +1783,7 @@ function BrowserGoHome(aEvent) {
case "tabshifted":
case "tab":
urls = homePage.split("|");
var loadInBackground = getBoolPref("browser.tabs.loadBookmarksInBackground", false);
var loadInBackground = Services.prefs.getBoolPref("browser.tabs.loadBookmarksInBackground", false);
gBrowser.loadTabs(urls, loadInBackground);
break;
case "window":
@ -3402,7 +3402,7 @@ function BrowserCustomizeToolbar() {
TabsInTitlebar.allowedBy("customizing-toolbars", false);
var customizeURL = "chrome://global/content/customizeToolbar.xul";
gCustomizeSheet = getBoolPref("toolbar.customization.usesheet", false);
gCustomizeSheet = Services.prefs.getBoolPref("toolbar.customization.usesheet", false);
if (gCustomizeSheet) {
let sheetFrame = document.createElement("iframe");
@ -3486,7 +3486,7 @@ function BrowserToolboxCustomizeDone(aToolboxChanged) {
cmd.removeAttribute("disabled");
// make sure to re-enable click-and-hold
if (!getBoolPref("ui.click_hold_context_menus", false))
if (!Services.prefs.getBoolPref("ui.click_hold_context_menus", false))
SetClickAndHoldHandlers();
gBrowser.selectedBrowser.focus();

View file

@ -75,16 +75,6 @@ function openTopWin(url) {
openUILinkIn(url, "current");
}
function getBoolPref(prefname, def)
{
try {
return Services.prefs.getBoolPref(prefname);
}
catch(er) {
return def;
}
}
/* openUILink handles clicks on UI elements that cause URLs to load.
*
* As the third argument, you may pass an object with the same properties as
@ -151,7 +141,7 @@ function whereToOpenLink( e, ignoreButton, ignoreAlt )
// ignoreButton allows "middle-click paste" to use function without always opening in a new window.
var middle = !ignoreButton && e.button == 1;
var middleUsesTabs = getBoolPref("browser.tabs.opentabfor.middleclick", true);
var middleUsesTabs = Services.prefs.getBoolPref("browser.tabs.opentabfor.middleclick", true);
// Don't do anything special with right-mouse clicks. They're probably clicks on context menu items.
@ -162,7 +152,7 @@ function whereToOpenLink( e, ignoreButton, ignoreAlt )
#endif
return shift ? "tabshifted" : "tab";
if (alt && getBoolPref("browser.altClickSave", false))
if (alt && Services.prefs.getBoolPref("browser.altClickSave", false))
return "save";
if (shift || (middle && !middleUsesTabs))
@ -334,7 +324,7 @@ function openLinkIn(url, where, params) {
if (loadInBackground == null) {
loadInBackground = aFromChrome ?
false :
getBoolPref("browser.tabs.loadInBackground");
Services.prefs.getBoolPref("browser.tabs.loadInBackground");
}
let uriObj;
@ -515,7 +505,7 @@ function getShellService()
function isBidiEnabled() {
// first check the pref.
if (getBoolPref("bidi.browser.ui", false))
if (Services.prefs.getBoolPref("bidi.browser.ui", false))
return true;
// if the pref isn't set, check for an RTL locale and force the pref to true
@ -673,7 +663,7 @@ function openAboutDialog() {
function openPreferences(paneID, extraArgs)
{
var instantApply = getBoolPref("browser.preferences.instantApply", false);
var instantApply = Services.prefs.getBoolPref("browser.preferences.instantApply", false);
var features = "chrome,titlebar,toolbar,centerscreen" + (instantApply ? ",dialog=no" : ",modal");
var win = Services.wm.getMostRecentWindow("Browser:Preferences");
@ -854,7 +844,7 @@ function openHelpLink(aHelpTopic, aCalledFromModal) {
function openPrefsHelp() {
// non-instant apply prefwindows are usually modal, so we can't open in the topmost window,
// since its probably behind the window.
var instantApply = getBoolPref("browser.preferences.instantApply");
var instantApply = Services.prefs.getBoolPref("browser.preferences.instantApply");
var helpTopic = document.getElementsByTagName("prefwindow")[0].currentPane.helpTopic;
openHelpLink(helpTopic, !instantApply);