bug 309027: Make sure we unsuppress the old focus controller to avoid making focus go out of whack. Patch by aaronlev and mrbkap. r/sr=mats/jst

This commit is contained in:
jst%mozilla.jstenback.com 2005-10-24 07:36:05 +00:00
Родитель 7c3560b7b5
Коммит b2e0f3b8e4
1 изменённых файлов: 38 добавлений и 0 удалений

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

@ -1,4 +1,5 @@
/* -*- Mode: C++; tab-width: 3; indent-tabs-mode: nil; c-basic-offset: 2 -*-
* vim: set ts=3 sw=2 et tw=80:
*
* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
@ -85,4 +86,41 @@ public:
NS_IMETHOD ResetElementFocus() = 0;
};
class nsFocusSuppressor {
public:
~nsFocusSuppressor()
{
Unsuppress();
}
void Suppress(nsIFocusController *aController, const char *aReason)
{
Unsuppress();
mController = aController;
mReason = aReason;
if (aController) {
mController->SetSuppressFocus(PR_TRUE, mReason);
}
}
void Unsuppress()
{
if (mController) {
mController->SetSuppressFocus(PR_FALSE, mReason);
mController = nsnull;
mReason = nsnull;
}
}
PRBool Suppressing()
{
return mController != nsnull;
}
private:
nsCOMPtr<nsIFocusController> mController;
const char *mReason;
};
#endif // nsIFocusController_h__