Bug 441876: remove UTF-7 from browser encoding menus, r=smontagu, sr=bzbarsky, a=ss

This commit is contained in:
gavin%gavinsharp.com 2008-07-23 18:05:13 +00:00
Родитель 15aafe98ab
Коммит 48e71d03fb
5 изменённых файлов: 39 добавлений и 28 удалений

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

@ -5107,21 +5107,19 @@ function BrowserSetForcedDetector(doReload)
function UpdateCurrentCharset()
{
var menuitem = null;
// exctract the charset from DOM
// extract the charset from DOM
var wnd = document.commandDispatcher.focusedWindow;
if ((window == wnd) || (wnd == null)) wnd = window.content;
menuitem = document.getElementById('charset.' + wnd.document.characterSet);
// Uncheck previous item
if (gPrevCharset) {
var pref_item = document.getElementById('charset.' + gPrevCharset);
if (pref_item)
pref_item.setAttribute('checked', 'false');
}
var menuitem = document.getElementById('charset.' + wnd.document.characterSet);
if (menuitem) {
// uncheck previously checked item to workaround Mac checkmark problem
// bug 98625
if (gPrevCharset) {
var pref_item = document.getElementById('charset.' + gPrevCharset);
if (pref_item)
pref_item.setAttribute('checked', 'false');
}
menuitem.setAttribute('checked', 'true');
}
}

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

@ -66,6 +66,7 @@ ibm1125.notForBrowser = true
ibm1131.notForBrowser = true
x-ibm1046.notForBrowser = true
iso-8859-8-e.notForBrowser = true
utf-7.notForBrowser = true
t.61-8bit.notForOutgoing = true
utf-7.notForOutgoing = true

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

@ -118,21 +118,19 @@ function SetForcedCharset(charset)
var gPrevCharset = null;
function UpdateCurrentCharset()
{
var menuitem = null;
// exctract the charset from DOM
// extract the charset from DOM
var wnd = document.commandDispatcher.focusedWindow;
if ((window == wnd) || (wnd == null)) wnd = window.content;
menuitem = document.getElementById('charset.' + wnd.document.characterSet);
// Uncheck previous item
if (gPrevCharset) {
var pref_item = document.getElementById('charset.' + gPrevCharset);
if (pref_item)
pref_item.setAttribute('checked', 'false');
}
var menuitem = document.getElementById('charset.' + wnd.document.characterSet);
if (menuitem) {
// uncheck previously checked item to workaround Mac checkmark problem
// bug 98625
if (gPrevCharset) {
var pref_item = document.getElementById('charset.' + gPrevCharset);
if (pref_item)
pref_item.setAttribute('checked', 'false');
}
menuitem.setAttribute('checked', 'true');
}
}

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

@ -29,7 +29,7 @@ intl.charsetmenu.browser.more3=GB2312, x-gbk, gb18030, HZ-GB-2312, ISO-2022-CN,
intl.charsetmenu.browser.more4=armscii-8, GEOSTD8, TIS-620, ISO-8859-11, windows-874, IBM857, ISO-8859-9, x-mac-turkish, windows-1254, x-viet-tcvn5712, VISCII, x-viet-vps, windows-1258, x-mac-devanagari, x-mac-gujarati, x-mac-gurmukhi
intl.charsetmenu.browser.more5=ISO-8859-6, windows-1256, IBM864, x-mac-arabic, x-mac-farsi, ISO-8859-8-I, windows-1255, ISO-8859-8, IBM862, x-mac-hebrew
# Localization Note: Never change the following entry.
intl.charsetmenu.browser.unicode=UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE, UTF-7
intl.charsetmenu.browser.unicode=UTF-8, UTF-16LE, UTF-16BE, UTF-32LE, UTF-32BE
intl.charset.default=ISO-8859-1
intl.charset.detector=
intl.charsetmenu.mailedit=ISO-8859-1, ISO-8859-15, ISO-8859-6, armscii-8, geostd8, ISO-8859-13, ISO-8859-14, ISO-8859-2, GB2312, GB18030, Big5, KOI8-R, windows-1251, KOI8-U, ISO-8859-7, ISO-8859-8-I, windows-1255, ISO-2022-JP, EUC-KR, ISO-8859-10, ISO-8859-3, TIS-620, ISO-8859-9, UTF-8, VISCII

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

@ -282,7 +282,7 @@ private:
nsresult RemoveLastMenuItem(nsIRDFContainer * aContainer,
nsVoidArray * aArray);
nsresult RemoveFlaggedCharsets(nsCStringArray& aList, nsString * aProp);
nsresult RemoveFlaggedCharsets(nsCStringArray& aList, const nsString& aProp);
nsresult NewRDFContainer(nsIRDFDataSource * aDataSource,
nsIRDFResource * aResource, nsIRDFContainer ** aResult);
void FreeMenuItemArray(nsVoidArray * aArray);
@ -593,6 +593,10 @@ nsresult nsCharsetMenu::RefreshBrowserMenu()
// mark the end of the static area, the rest is cache
mBrowserCacheStart = mBrowserMenu.Count();
// Remove "notForBrowser" entries before populating cache menu
res = RemoveFlaggedCharsets(decs, NS_LITERAL_STRING(".notForBrowser"));
NS_ASSERTION(NS_SUCCEEDED(res), "error removing flagged charsets");
res = InitCacheMenu(decs, kNC_BrowserCharsetMenuRoot, kBrowserCachePrefKey,
&mBrowserMenu);
NS_ASSERTION(NS_SUCCEEDED(res), "error initializing browser cache charset menu");
@ -903,6 +907,10 @@ nsresult nsCharsetMenu::InitBrowserMenu()
// elements are numbered from 1 (why god, WHY?!?!?!)
mBrowserMenuRDFPosition -= mBrowserCacheStart - 1;
// Remove "notForBrowser" entries before populating cache menu
res = RemoveFlaggedCharsets(browserDecoderList, NS_LITERAL_STRING(".notForBrowser"));
NS_ASSERTION(NS_SUCCEEDED(res), "error initializing static charset menu from prefs");
res = InitCacheMenu(browserDecoderList, kNC_BrowserCharsetMenuRoot, kBrowserCachePrefKey,
&mBrowserMenu);
NS_ASSERTION(NS_SUCCEEDED(res), "error initializing browser cache charset menu");
@ -1210,13 +1218,12 @@ nsresult nsCharsetMenu::InitMoreMenu(nsCStringArray& aDecs,
nsresult res = NS_OK;
nsCOMPtr<nsIRDFContainer> container;
nsVoidArray moreMenu;
nsAutoString prop; prop.AssignWithConversion(aFlag);
res = NewRDFContainer(mInner, aResource, getter_AddRefs(container));
if (NS_FAILED(res)) goto done;
// remove charsets "not for browser"
res = RemoveFlaggedCharsets(aDecs, &prop);
res = RemoveFlaggedCharsets(aDecs, NS_ConvertASCIItoUTF16(aFlag));
if (NS_FAILED(res)) goto done;
res = AddCharsetArrayToItemArray(moreMenu, aDecs);
@ -1698,7 +1705,7 @@ nsresult nsCharsetMenu::RemoveLastMenuItem(nsIRDFContainer * aContainer,
}
nsresult nsCharsetMenu::RemoveFlaggedCharsets(nsCStringArray& aList,
nsString * aProp)
const nsString& aProp)
{
nsresult res = NS_OK;
PRUint32 count;
@ -1713,7 +1720,7 @@ nsresult nsCharsetMenu::RemoveFlaggedCharsets(nsCStringArray& aList,
charset = aList.CStringAt(i);
if (!charset) continue;
res = mCCManager->GetCharsetData(charset->get(), aProp->get(), str);
res = mCCManager->GetCharsetData(charset->get(), aProp.get(), str);
if (NS_FAILED(res)) continue;
aList.RemoveCStringAt(i);
@ -1841,6 +1848,13 @@ NS_IMETHODIMP nsCharsetMenu::SetCurrentCharset(const PRUnichar * aCharset)
nsresult res = NS_OK;
if (mBrowserMenuInitialized) {
// Don't add item to the cache if it's marked "notForBrowser"
nsAutoString str;
res = mCCManager->GetCharsetData(NS_LossyConvertUTF16toASCII(aCharset).get(),
NS_LITERAL_STRING(".notForBrowser").get(), str);
if (NS_SUCCEEDED(res)) // succeeded means attribute exists
return res; // don't throw
res = AddCharsetToCache(NS_LossyConvertUTF16toASCII(aCharset),
&mBrowserMenu, kNC_BrowserCharsetMenuRoot,
mBrowserCacheStart, mBrowserCacheSize,