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

This commit is contained in:
jst%mozilla.org 2007-02-22 22:38:25 +00:00
Родитель df34976698
Коммит 709adbc4ab
2 изменённых файлов: 15 добавлений и 11 удалений

Просмотреть файл

@ -76,16 +76,26 @@ 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();
if (--sTooltipListenerCount == 0) {
// Unregister our pref observer
nsContentUtils::UnregisterPrefCallback("browser.chrome.toolbar_tips",
ToolbarTipsPrefChanged, this);
}
}
NS_IMPL_ADDREF(nsXULTooltipListener)
NS_IMPL_RELEASE(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;
}

Просмотреть файл

@ -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();