зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
df34976698
Коммит
709adbc4ab
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Загрузка…
Ссылка в новой задаче