fix bug 93025. delay the checking of access key pref

so we will use the user's pref instead of the default vaule in the pref.
r=jbetak sr=kin
This commit is contained in:
ftang%netscape.com 2001-10-19 20:56:29 +00:00
Родитель 3edc819898
Коммит fec6db7e98
2 изменённых файлов: 30 добавлений и 15 удалений

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

@ -160,24 +160,35 @@ nsTextBoxFrame::Init(nsIPresContext* aPresContext,
mState |= NS_STATE_NEED_LAYOUT; mState |= NS_STATE_NEED_LAYOUT;
PRBool aResize; PRBool aResize;
PRBool aRedraw; PRBool aRedraw;
if (!gAccessKeyPrefInitialized) {
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
gAccessKeyPrefInitialized = PR_TRUE;
if (prefs) {
nsXPIDLString prefValue;
nsresult res = prefs->GetLocalizedUnicharPref("intl.menuitems.alwaysappendacceskeys", getter_Copies(prefValue));
if (NS_SUCCEEDED(res)) {
gAlwaysAppendAccessKey = nsDependentString(prefValue).Equals(NS_LITERAL_STRING("true"));
}
}
}
UpdateAttributes(aPresContext, nsnull, aResize, aRedraw); /* update all */ UpdateAttributes(aPresContext, nsnull, aResize, aRedraw); /* update all */
return rv; return rv;
} }
PRBool
nsTextBoxFrame::AlwaysAppendAccessKey()
{
if (!gAccessKeyPrefInitialized)
{
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
gAccessKeyPrefInitialized = PR_TRUE;
if (prefs)
{
nsXPIDLString prefValue;
nsresult res = prefs->GetLocalizedUnicharPref(
"intl.menuitems.alwaysappendacceskeys",
getter_Copies(prefValue));
if (NS_SUCCEEDED(res))
{
gAlwaysAppendAccessKey = nsDependentString(prefValue).Equals(
NS_LITERAL_STRING("true"));
}
}
}
return gAlwaysAppendAccessKey;
}
void void
nsTextBoxFrame::UpdateAttributes(nsIPresContext* aPresContext, nsTextBoxFrame::UpdateAttributes(nsIPresContext* aPresContext,
nsIAtom* aAttribute, nsIAtom* aAttribute,
@ -731,7 +742,9 @@ nsTextBoxFrame::UpdateAccessTitle()
nsMenuBarListener::GetMenuAccessKey(&menuAccessKey); nsMenuBarListener::GetMenuAccessKey(&menuAccessKey);
if (menuAccessKey) { if (menuAccessKey) {
if (!mAccessKey.IsEmpty()) { if (!mAccessKey.IsEmpty()) {
if ((mTitle.Find(mAccessKey, PR_TRUE) == kNotFound) || gAlwaysAppendAccessKey) { if ((mTitle.Find(mAccessKey, PR_TRUE) == kNotFound)
|| AlwaysAppendAccessKey())
{
nsAutoString tmpstring; tmpstring.AssignWithConversion("("); nsAutoString tmpstring; tmpstring.AssignWithConversion("(");
tmpstring += mAccessKey; tmpstring += mAccessKey;
tmpstring.ToUpperCase(); tmpstring.ToUpperCase();
@ -761,7 +774,7 @@ nsTextBoxFrame::UpdateAccessIndex()
if (!mAccessKeyInfo) if (!mAccessKeyInfo)
mAccessKeyInfo = new nsAccessKeyInfo(); mAccessKeyInfo = new nsAccessKeyInfo();
if (!gAlwaysAppendAccessKey) { if (!AlwaysAppendAccessKey()) {
// not appending access key - do case-sensitive search first // not appending access key - do case-sensitive search first
mAccessKeyInfo->mAccesskeyIndex = mCroppedTitle.Find(mAccessKey, PR_FALSE); mAccessKeyInfo->mAccesskeyIndex = mCroppedTitle.Find(mAccessKey, PR_FALSE);
if (mAccessKeyInfo->mAccesskeyIndex == kNotFound) { if (mAccessKeyInfo->mAccesskeyIndex == kNotFound) {

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

@ -120,6 +120,8 @@ protected:
private: private:
PRBool AlwaysAppendAccessKey();
CroppingStyle mCropType; CroppingStyle mCropType;
nsString mTitle; nsString mTitle;
nsString mCroppedTitle; nsString mCroppedTitle;