Fixing bug 371200. Make us have only one pref observer for browser.chrome.toolbar_tips rather than having every single XUL tooltip listener listen for changes to the pref only to update a global variable. r+sr=jonas@sicking.cc

git-svn-id: svn://10.0.0.236/trunk@220768 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jst%mozilla.org
2007-02-22 22:38:25 +00:00
parent 56a61985cf
commit 096097fad9
2 changed files with 15 additions and 11 deletions

View File

@@ -76,15 +76,25 @@ nsXULTooltipListener::nsXULTooltipListener()
, mLastTreeRow(-1)
#endif
{
if (sTooltipListenerCount++ == 0) {
// register the callback so we get notified of updates
nsContentUtils::RegisterPrefCallback("browser.chrome.toolbar_tips",
ToolbarTipsPrefChanged, this);
// Call the pref callback to initialize our state.
ToolbarTipsPrefChanged("browser.chrome.toolbar_tips", nsnull);
}
}
nsXULTooltipListener::~nsXULTooltipListener()
{
HideTooltip();
// Unregister our pref observer
nsContentUtils::UnregisterPrefCallback("browser.chrome.toolbar_tips",
ToolbarTipsPrefChanged, this);
if (--sTooltipListenerCount == 0) {
// Unregister our pref observer
nsContentUtils::UnregisterPrefCallback("browser.chrome.toolbar_tips",
ToolbarTipsPrefChanged, this);
}
}
NS_IMPL_ADDREF(nsXULTooltipListener)
@@ -272,6 +282,7 @@ nsXULTooltipListener::PopupHiding(nsIDOMEvent* aEvent)
//// nsXULTooltipListener
PRBool nsXULTooltipListener::sShowTooltips = PR_FALSE;
PRUint32 nsXULTooltipListener::sTooltipListenerCount = 0;
// XXX: This could all be done in the ctor.
nsresult
@@ -286,14 +297,6 @@ nsXULTooltipListener::Init(nsIContent* aSourceNode)
mIsSourceTree = mSourceNode->Tag() == nsGkAtoms::treechildren;
#endif
// get the initial value of the pref
sShowTooltips =
nsContentUtils::GetBoolPref("browser.chrome.toolbar_tips", sShowTooltips);
// register the callback so we get notified of updates
nsContentUtils::RegisterPrefCallback("browser.chrome.toolbar_tips",
ToolbarTipsPrefChanged, this);
return NS_OK;
}

View File

@@ -105,6 +105,7 @@ protected:
// pref callback for when the "show tooltips" pref changes
static int sTooltipPrefChanged (const char* aPref, void* aData);
static PRBool sShowTooltips;
static PRUint32 sTooltipListenerCount;
void KillTooltipTimer();
void CreateAutoHideTimer();