зеркало из https://github.com/mozilla/pjs.git
backing out bnesse at his request since he found conflicts with dougt's
checkin
This commit is contained in:
Родитель
7f89a44049
Коммит
2551ac5173
|
@ -211,7 +211,7 @@ interface nsIPref : nsISupports {
|
|||
* The observers have their |Observe| methods called with
|
||||
* ([the observer], "nsPref:changed", [pref name]).
|
||||
*/
|
||||
void addObserver(in string aDomain, in nsIObserver aObserver, in boolean aHoldWeak);
|
||||
void addObserver(in string aDomain, in nsIObserver aObserver);
|
||||
void removeObserver(in string aDomain, in nsIObserver aObserver);
|
||||
|
||||
|
||||
|
|
|
@ -65,27 +65,14 @@ interface nsIPrefBranchInternal : nsISupports
|
|||
*
|
||||
* @param aDomain The preference on which to listen for changes.
|
||||
* @param aObserver The object to be notified if the preference changes.
|
||||
* @param aHoldWeak true Hold a weak reference to |aObserver|. The object
|
||||
* must implement the nsISupportsWeakReference
|
||||
* interface or this will fail.
|
||||
* false Hold a strong reference to |aObserver|.
|
||||
*
|
||||
* @note
|
||||
* Registering as a preference observer can open an object to potential
|
||||
* cyclical references which will cause memory leaks. These cycles generally
|
||||
* occur because an object both registers itself as an observer (causing the
|
||||
* branch to hold a reference to the observer) and holds a reference to the
|
||||
* branch object for the purpose of getting/setting preference values. There
|
||||
* are 3 approaches which have been implemented in an attempt to avoid these
|
||||
* situations.
|
||||
* 1) The nsPrefBranch object supports nsISupportsWeakReference. Any consumer
|
||||
* may hold a weak reference to it instead of a strong one.
|
||||
* 2) The nsPrefBranch object listens for xpcom-shutdown and frees all of the
|
||||
* objects currently in its observer list. This insures that long lived
|
||||
* objects (services for example) will be freed correctly.
|
||||
* 3) The observer can request to be held as a weak reference when it is
|
||||
* registered. This insures that shorter lived objects (say one tied to an
|
||||
* open window) will not fall into the cyclical reference trap.
|
||||
* branch object for the purpose of getting/setting preference values. This
|
||||
* should be addressed in the near future.
|
||||
*
|
||||
* @return NS_OK The observer was successfully set.
|
||||
* @return Other The observer could not be created.
|
||||
|
@ -93,7 +80,7 @@ interface nsIPrefBranchInternal : nsISupports
|
|||
* @see nsIObserver
|
||||
* @see removeObserver
|
||||
*/
|
||||
void addObserver(in string aDomain, in nsIObserver aObserver, in boolean aHoldWeak);
|
||||
void addObserver(in string aDomain, in nsIObserver aObserver);
|
||||
|
||||
/**
|
||||
* Called by a preferences consumer to remove itself from the preference
|
||||
|
@ -117,6 +104,6 @@ interface nsIPrefBranchInternal : nsISupports
|
|||
/**
|
||||
* Notification sent when a preference changes.
|
||||
*/
|
||||
#define NS_PREFBRANCH_PREFCHANGE_TOPIC_ID "nsPref:changed"
|
||||
#define NS_PREFBRANCH_PREFCHANGE_OBSERVER_ID "nsPref:changed"
|
||||
|
||||
%}
|
||||
|
|
|
@ -171,12 +171,12 @@ interface nsIPrefService : nsISupports
|
|||
/**
|
||||
* Notification sent before reading the default user preferences files.
|
||||
*/
|
||||
#define NS_PREFSERVICE_READ_TOPIC_ID "prefservice:before-read-userprefs"
|
||||
#define NS_PREFSERVICE_READ_OBSERVER_ID "prefservice:before-read-userprefs"
|
||||
|
||||
/**
|
||||
* Notification sent when resetPrefs has been called, but before the actual
|
||||
* reset process occurs.
|
||||
*/
|
||||
#define NS_PREFSERVICE_RESET_TOPIC_ID "prefservice:before-reset"
|
||||
#define NS_PREFSERVICE_RESET_OBSERVER_ID "prefservice:before-reset"
|
||||
|
||||
%}
|
||||
|
|
|
@ -47,7 +47,8 @@ var gNavigatorRegionBundle;
|
|||
var gBrandRegionBundle;
|
||||
var gLastValidURL = "";
|
||||
|
||||
var pref = null;
|
||||
var pref = Components.classes["@mozilla.org/preferences;1"]
|
||||
.getService(Components.interfaces.nsIPref);
|
||||
|
||||
var appCore = null;
|
||||
|
||||
|
@ -131,7 +132,7 @@ function UpdateInternetSearchResults(event)
|
|||
var searchInProgressFlag = search.FindInternetSearchResults(url);
|
||||
|
||||
if (searchInProgressFlag) {
|
||||
var autoOpenSearchPanel = pref.getBoolPref("browser.search.opensidebarsearchpanel");
|
||||
var autoOpenSearchPanel = pref.GetBoolPref("browser.search.opensidebarsearchpanel");
|
||||
|
||||
if (autoOpenSearchPanel)
|
||||
RevealSearchPanel();
|
||||
|
@ -166,8 +167,7 @@ function getHomePage()
|
|||
{
|
||||
var url;
|
||||
try {
|
||||
url = pref.getComplexValue("browser.startup.homepage",
|
||||
Components.interfaces.nsIPrefLocalizedString);
|
||||
url = pref.getLocalizedUnicharPref("browser.startup.homepage");
|
||||
} catch (e) {
|
||||
}
|
||||
|
||||
|
@ -203,9 +203,7 @@ function UpdateBackForwardButtons()
|
|||
function nsButtonPrefListener()
|
||||
{
|
||||
try {
|
||||
var pbi = pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
|
||||
if (pbi)
|
||||
pbi.addObserver(this.domain, this, false);
|
||||
pref.addObserver(this.domain, this);
|
||||
} catch(ex) {
|
||||
dump("Failed to observe prefs: " + ex + "\n");
|
||||
}
|
||||
|
@ -225,7 +223,7 @@ nsButtonPrefListener.prototype =
|
|||
var buttonId = buttonName + "-button";
|
||||
var button = document.getElementById(buttonId);
|
||||
|
||||
var show = pref.getBoolPref(prefName);
|
||||
var show = pref.GetBoolPref(prefName);
|
||||
if (show)
|
||||
button.setAttribute("hidden","false");
|
||||
else
|
||||
|
@ -254,13 +252,6 @@ function Startup()
|
|||
if (!appCore)
|
||||
throw Components.results.NS_ERROR_FAILURE;
|
||||
|
||||
// Get the preferences service
|
||||
var prefService = Components.classes["@mozilla.org/preferences-service;1"]
|
||||
.getService(Components.interfaces.nsIPrefService);
|
||||
if (!prefService)
|
||||
throw Components.results.NS_ERROR_FAILURE;
|
||||
pref = prefService.getBranch(null);
|
||||
|
||||
webNavigation = getWebNavigation();
|
||||
if (!webNavigation)
|
||||
throw Components.results.NS_ERROR_FAILURE;
|
||||
|
@ -402,10 +393,8 @@ function Shutdown()
|
|||
}
|
||||
|
||||
// unregister us as a pref listener
|
||||
var pbi = pref.QueryInterface(Components.interfaces.nsIPrefBranchInternal);
|
||||
if (pbi)
|
||||
pbi.removeObserver(window.buttonPrefListener.domain,
|
||||
window.buttonPrefListener);
|
||||
pref.removeObserver(window.buttonPrefListener.domain,
|
||||
window.buttonPrefListener);
|
||||
|
||||
window.browserContentListener.close();
|
||||
// Close the app core.
|
||||
|
@ -624,9 +613,8 @@ function OpenSearch(tabName, forceDialogFlag, searchStr)
|
|||
var forceAsURL = urlmatch.test(searchStr);
|
||||
|
||||
try {
|
||||
autoOpenSearchPanel = pref.getBoolPref("browser.search.opensidebarsearchpanel");
|
||||
defaultSearchURL = pref.getComplexValue("browser.search.defaulturl",
|
||||
Components.interfaces.nsIPrefLocalizedString);
|
||||
autoOpenSearchPanel = pref.GetBoolPref("browser.search.opensidebarsearchpanel");
|
||||
defaultSearchURL = pref.getLocalizedUnicharPref("browser.search.defaulturl");
|
||||
} catch (ex) {
|
||||
}
|
||||
|
||||
|
@ -650,7 +638,7 @@ function OpenSearch(tabName, forceDialogFlag, searchStr)
|
|||
} else {
|
||||
var searchMode = 0;
|
||||
try {
|
||||
searchMode = pref.getIntPref("browser.search.powermode");
|
||||
searchMode = pref.GetIntPref("browser.search.powermode");
|
||||
} catch(ex) {
|
||||
}
|
||||
if (forceDialogFlag || searchMode == 1) {
|
||||
|
@ -678,7 +666,7 @@ function OpenSearch(tabName, forceDialogFlag, searchStr)
|
|||
|
||||
searchDS.RememberLastSearchText(escapedSearchStr);
|
||||
try {
|
||||
var searchEngineURI = pref.getCharPref("browser.search.defaultengine");
|
||||
var searchEngineURI = pref.CopyCharPref("browser.search.defaultengine");
|
||||
if (searchEngineURI) {
|
||||
var searchURL = searchDS.GetInternetSearchURL(searchEngineURI, escapedSearchStr);
|
||||
if (searchURL)
|
||||
|
@ -1255,7 +1243,7 @@ function getNewThemes()
|
|||
|
||||
function URLBarMouseupHandler(aEvent)
|
||||
{
|
||||
if (aEvent.button == 0 && pref.getBoolPref("browser.urlbar.clickSelectsAll")) {
|
||||
if (aEvent.button == 0 && pref.GetBoolPref("browser.urlbar.clickSelectsAll")) {
|
||||
var selectionLen = gURLBar.selectionEnd - gURLBar.selectionStart;
|
||||
if (selectionLen == 0)
|
||||
gURLBar.setSelectionRange(0, gURLBar.textLength);
|
||||
|
@ -1264,7 +1252,7 @@ function URLBarMouseupHandler(aEvent)
|
|||
|
||||
function URLBarBlurHandler(aEvent)
|
||||
{
|
||||
if (pref.getBoolPref("browser.urlbar.clickSelectsAll"))
|
||||
if (pref.GetBoolPref("browser.urlbar.clickSelectsAll"))
|
||||
gURLBar.setSelectionRange(0, 0);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче