mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 03:15:11 +00:00
Bug 805374 - Clean up the Character Encoding menu. r=Gijs,Unfocused.
This commit is contained in:
parent
7b95f9e668
commit
a581322e18
@ -6,140 +6,37 @@
|
||||
|
||||
#expand <menu id="__ID_PREFIX__charsetMenu"
|
||||
label="&charsetMenu.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenu.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu"
|
||||
ref="NC:BrowserCharsetMenuRoot"
|
||||
oncommand="MultiplexHandler(event)"
|
||||
onpopupshowing="CreateMenu('browser'); CreateMenu('more-menu');"
|
||||
onpopupshowing="CharsetMenu.build(event);"
|
||||
onpopupshown="UpdateMenus(event);"
|
||||
observes="isImage">
|
||||
<template>
|
||||
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
|
||||
<menupopup>
|
||||
<menuseparator uri="..." />
|
||||
</menupopup>
|
||||
</rule>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem type="radio" name="charsetGroup" checked="rdf:http://home.netscape.com/NC-rdf#Checked" uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
|
||||
<menupopup>
|
||||
<menu label="&charsetMenuAutodet.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuAutodet.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserAutodetMenuRoot">
|
||||
<template>
|
||||
<rule rdf:type="http://home.netscape.com/NC-rdf#CharsetDetector">
|
||||
<menupopup>
|
||||
<menuitem type="radio" name="detectorGroup" checked="rdf:http://home.netscape.com/NC-rdf#Checked" uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&charsetMenuMore.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMoreCharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
<menu label="&charsetMenuMore1.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore1.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMore1CharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&charsetMenuMore2.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore2.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMore2CharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&charsetMenuMore3.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore3.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMore3CharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&charsetMenuMore4.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore4.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMore4CharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu label="&charsetMenuMore5.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenuMore5.accesskey;"
|
||||
#endif
|
||||
datasources="rdf:charset-menu" ref="NC:BrowserMore5CharsetMenuRoot">
|
||||
<template>
|
||||
<rule>
|
||||
<menupopup>
|
||||
<menuitem uri="..." label="rdf:http://home.netscape.com/NC-rdf#Name"/>
|
||||
</menupopup>
|
||||
</rule>
|
||||
</template>
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuseparator />
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuitem name="charsetCustomize"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetCustomize.accesskey;"
|
||||
#endif
|
||||
label="&charsetCustomize.label;"
|
||||
oncommand="window.openDialog('chrome://global/content/customizeCharset.xul', 'PrefWindow', 'chrome,modal=yes,resizable=yes', 'browser');"/>
|
||||
<menu label="&charsetMenuAutodet.label;"
|
||||
accesskey="&charsetMenuAutodet.accesskey;">
|
||||
<menupopup>
|
||||
<menuitem type="radio"
|
||||
name="detectorGroup"
|
||||
id="chardet.off"
|
||||
label="&charsetMenuAutodet.off.label;"
|
||||
accesskey="&charsetMenuAutodet.off.accesskey;"/>
|
||||
<menuitem type="radio"
|
||||
name="detectorGroup"
|
||||
id="chardet.ja_parallel_state_machine"
|
||||
label="&charsetMenuAutodet.ja.label;"
|
||||
accesskey="&charsetMenuAutodet.ja.accesskey;"/>
|
||||
<menuitem type="radio"
|
||||
name="detectorGroup"
|
||||
id="chardet.ruprob"
|
||||
label="&charsetMenuAutodet.ru.label;"
|
||||
accesskey="&charsetMenuAutodet.ru.accesskey;"/>
|
||||
<menuitem type="radio"
|
||||
name="detectorGroup"
|
||||
id="chardet.ukprob"
|
||||
label="&charsetMenuAutodet.uk.label;"
|
||||
accesskey="&charsetMenuAutodet.uk.accesskey;"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuseparator/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
@ -5,7 +5,7 @@
|
||||
%browserDTD;
|
||||
<!ENTITY % baseMenuDTD SYSTEM "chrome://browser/locale/baseMenuOverlay.dtd" >
|
||||
%baseMenuDTD;
|
||||
<!ENTITY % charsetDTD SYSTEM "chrome://global/locale/charsetOverlay.dtd" >
|
||||
<!ENTITY % charsetDTD SYSTEM "chrome://browser/locale/charsetMenu.dtd" >
|
||||
%charsetDTD;
|
||||
<!ENTITY % textcontextDTD SYSTEM "chrome://global/locale/textcontext.dtd" >
|
||||
%textcontextDTD;
|
||||
|
@ -12,10 +12,11 @@ Cu.import("resource:///modules/RecentWindow.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "Task",
|
||||
"resource://gre/modules/Task.jsm");
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "CharsetMenu",
|
||||
"resource:///modules/CharsetMenu.jsm");
|
||||
|
||||
const nsIWebNavigation = Ci.nsIWebNavigation;
|
||||
|
||||
var gCharsetMenu = null;
|
||||
var gLastBrowserCharset = null;
|
||||
var gPrevCharset = null;
|
||||
var gProxyFavIcon = null;
|
||||
@ -5176,17 +5177,10 @@ function UpdateMenus(event) {
|
||||
UpdateCharsetDetector(event.target);
|
||||
}
|
||||
|
||||
function CreateMenu(node) {
|
||||
Services.obs.notifyObservers(null, "charsetmenu-selected", node);
|
||||
}
|
||||
|
||||
function charsetLoadListener() {
|
||||
var charset = window.content.document.characterSet;
|
||||
|
||||
if (charset.length > 0 && (charset != gLastBrowserCharset)) {
|
||||
if (!gCharsetMenu)
|
||||
gCharsetMenu = Cc['@mozilla.org/rdf/datasource;1?name=charset-menu'].getService(Ci.nsICurrentCharsetListener);
|
||||
gCharsetMenu.SetCurrentCharset(charset);
|
||||
gPrevCharset = gLastBrowserCharset;
|
||||
gLastBrowserCharset = charset;
|
||||
}
|
||||
|
@ -106,8 +106,6 @@
|
||||
|
||||
<panelview id="PanelUI-characterEncodingView" flex="1">
|
||||
<label value="&charsetMenu.label;"/>
|
||||
<toolbarbutton label="&charsetCustomize.label;"
|
||||
oncommand="PanelUI.onCharsetCustomizeCommand();"/>
|
||||
|
||||
<vbox id="PanelUI-characterEncodingView-customlist"
|
||||
class="PanelUI-characterEncodingView-list"/>
|
||||
|
18
browser/locales/en-US/chrome/browser/charsetMenu.dtd
Normal file
18
browser/locales/en-US/chrome/browser/charsetMenu.dtd
Normal file
@ -0,0 +1,18 @@
|
||||
<!-- This Source Code Form is subject to the terms of the Mozilla Public
|
||||
- License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
- file, You can obtain one at http://mozilla.org/MPL/2.0/. -->
|
||||
|
||||
<!ENTITY charsetMenu.label "Character Encoding">
|
||||
<!ENTITY charsetMenu.accesskey "C">
|
||||
<!ENTITY charsetMenuAutodet.label "Auto-Detect">
|
||||
<!ENTITY charsetMenuAutodet.accesskey "D"><!-- A reserved for Arabic -->
|
||||
|
||||
<!ENTITY charsetMenuAutodet.off.label "(off)">
|
||||
<!ENTITY charsetMenuAutodet.off.accesskey "o">
|
||||
<!ENTITY charsetMenuAutodet.ja.label "Japanese">
|
||||
<!ENTITY charsetMenuAutodet.ja.accesskey "J">
|
||||
<!ENTITY charsetMenuAutodet.ru.label "Russian">
|
||||
<!ENTITY charsetMenuAutodet.ru.accesskey "R">
|
||||
<!ENTITY charsetMenuAutodet.uk.label "Ukranian">
|
||||
<!ENTITY charsetMenuAutodet.uk.accesskey "U">
|
||||
|
105
browser/locales/en-US/chrome/browser/charsetMenu.properties
Normal file
105
browser/locales/en-US/chrome/browser/charsetMenu.properties
Normal file
@ -0,0 +1,105 @@
|
||||
# This Source Code Form is subject to the terms of the Mozilla Public
|
||||
# License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
# LOCALIZATION NOTE: The property keys ending with ".key" are for access keys.
|
||||
# Localizations may add or delete properties where the property key ends with
|
||||
# ".key" as appropriate for the localization. The code that uses this data can
|
||||
# deal with the absence of an access key for an item.
|
||||
#
|
||||
# Make sure the keys defined here don't collide with
|
||||
# charsetMenuAutodet.accesskey in charsetMenu.dtd.
|
||||
#
|
||||
# In the en-US version of this file, access keys are given to the following:
|
||||
# * UTF-8
|
||||
# * All encodings that are the fallback encoding for some locale in Firefox
|
||||
# * All encodings that are the fallback encoding for some locale in IE
|
||||
# * All Japanese encodings
|
||||
#
|
||||
# For the items whose property key does not end in ".key" and whose value
|
||||
# includes "(" U+0028 LEFT PARENTHESIS, the "(" character is significant for
|
||||
# processing by CharsetMenu.jsm. If your localization does not use ASCII
|
||||
# parentheses where en-US does in this file, please file a bug to make
|
||||
# CharsetMenu.jsm also recognize the delimiter your localization uses.
|
||||
# (When this code was developed, all localizations appeared to use
|
||||
# U+0028 LEFT PARENTHESIS for this purpose.)
|
||||
|
||||
# Globally-relevant
|
||||
UTF-8.key = U
|
||||
UTF-8 = Unicode
|
||||
windows-1252.key = W
|
||||
windows-1252 = Western
|
||||
|
||||
# Arabic
|
||||
windows-1256.key = A
|
||||
windows-1256 = Arabic (Windows)
|
||||
ISO-8859-6 = Arabic (ISO)
|
||||
|
||||
# Baltic
|
||||
windows-1257.key = B
|
||||
windows-1257 = Baltic (Windows)
|
||||
ISO-8859-4 = Baltic (ISO)
|
||||
|
||||
# Central European
|
||||
windows-1250.key = E
|
||||
windows-1250 = Central European (Windows)
|
||||
ISO-8859-2.key = l
|
||||
ISO-8859-2 = Central European (ISO)
|
||||
|
||||
# Chinese, Simplified
|
||||
gbk.key = S
|
||||
gbk = Chinese, Simplified (GBK)
|
||||
gb18030 = Chinese, Simplified (GB18030)
|
||||
|
||||
# Chinese, Traditional
|
||||
Big5.key = T
|
||||
Big5 = Chinese, Traditional
|
||||
|
||||
# Cyrillic
|
||||
windows-1251.key = C
|
||||
windows-1251 = Cyrillic (Windows)
|
||||
ISO-8859-5 = Cyrillic (ISO)
|
||||
KOI8-R = Cyrillic (KOI8-R)
|
||||
KOI8-U = Cyrillic (KOI8-U)
|
||||
IBM866 = Cyrillic (DOS)
|
||||
|
||||
# Greek
|
||||
windows-1253.key = G
|
||||
windows-1253 = Greek (Windows)
|
||||
ISO-8859-7.key = O
|
||||
ISO-8859-7 = Greek (ISO)
|
||||
|
||||
# Hebrew
|
||||
windows-1255.key = H
|
||||
windows-1255 = Hebrew (Windows)
|
||||
ISO-8859-8-I = Hebrew (ISO)
|
||||
# LOCALIZATION NOTE (ISO-8859-8): The value for this item should begin with
|
||||
# the same word for Hebrew as the values for windows-1255 and ISO-8859-8-I
|
||||
# so that this item sorts right after those two in the collation order for your
|
||||
# locale.
|
||||
ISO-8859-8 = Hebrew, Visual
|
||||
|
||||
# Japanese
|
||||
Shift_JIS.key = J
|
||||
Shift_JIS = Japanese (Shift_JIS)
|
||||
EUC-JP.key = p
|
||||
EUC-JP = Japanese (EUC-JP)
|
||||
ISO-2022-JP.key = n
|
||||
ISO-2022-JP = Japanese (ISO-2022-JP)
|
||||
|
||||
# Korean
|
||||
EUC-KR.key = K
|
||||
EUC-KR = Korean
|
||||
|
||||
# Thai
|
||||
windows-874.key = i
|
||||
windows-874 = Thai
|
||||
|
||||
# Turkish
|
||||
windows-1254.key = r
|
||||
windows-1254 = Turkish
|
||||
|
||||
# Vietnamese
|
||||
windows-1258.key = V
|
||||
windows-1258 = Vietnamese
|
||||
|
@ -22,6 +22,8 @@
|
||||
locale/browser/browser.dtd (%chrome/browser/browser.dtd)
|
||||
locale/browser/baseMenuOverlay.dtd (%chrome/browser/baseMenuOverlay.dtd)
|
||||
locale/browser/browser.properties (%chrome/browser/browser.properties)
|
||||
locale/browser/charsetMenu.properties (%chrome/browser/charsetMenu.properties)
|
||||
locale/browser/charsetMenu.dtd (%chrome/browser/charsetMenu.dtd)
|
||||
locale/browser/customizableui/customizableWidgets.properties (%chrome/browser/customizableui/customizableWidgets.properties)
|
||||
locale/browser/devtools/appcacheutils.properties (%chrome/browser/devtools/appcacheutils.properties)
|
||||
locale/browser/devtools/debugger.dtd (%chrome/browser/devtools/debugger.dtd)
|
||||
|
160
browser/modules/CharsetMenu.jsm
Normal file
160
browser/modules/CharsetMenu.jsm
Normal file
@ -0,0 +1,160 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
this.EXPORTED_SYMBOLS = [ "CharsetMenu" ];
|
||||
|
||||
const { classes: Cc, interfaces: Ci, utils: Cu} = Components;
|
||||
|
||||
Cu.import("resource://gre/modules/Services.jsm");
|
||||
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
|
||||
XPCOMUtils.defineLazyGetter(this, "gBundle", function() {
|
||||
const kUrl = "chrome://browser/locale/charsetMenu.properties";
|
||||
return Services.strings.createBundle(kUrl);
|
||||
});
|
||||
/**
|
||||
* This set contains encodings that are in the Encoding Standard, except:
|
||||
* - XSS-dangerous encodings (except ISO-2022-JP which is assumed to be
|
||||
* too common not to be included).
|
||||
* - x-user-defined, which practically never makes sense as an end-user-chosen
|
||||
* override.
|
||||
* - Encodings that IE11 doesn't have in its correspoding menu.
|
||||
*/
|
||||
const kEncodings = new Set([
|
||||
// Globally relevant
|
||||
"UTF-8",
|
||||
"windows-1252",
|
||||
// Arabic
|
||||
"windows-1256",
|
||||
"ISO-8859-6",
|
||||
// Baltic
|
||||
"windows-1257",
|
||||
"ISO-8859-4",
|
||||
// "ISO-8859-13", // Hidden since not in menu in IE11
|
||||
// Central European
|
||||
"windows-1250",
|
||||
"ISO-8859-2",
|
||||
// Chinese, Simplified
|
||||
"gbk",
|
||||
"gb18030",
|
||||
// Chinese, Traditional
|
||||
"Big5",
|
||||
// Cyrillic
|
||||
"windows-1251",
|
||||
"ISO-8859-5",
|
||||
"KOI8-R",
|
||||
"KOI8-U",
|
||||
"IBM866", // Not in menu in Chromium. Maybe drop this?
|
||||
// "x-mac-cyrillic", // Not in menu in IE11 or Chromium.
|
||||
// Greek
|
||||
"windows-1253",
|
||||
"ISO-8859-7",
|
||||
// Hebrew
|
||||
"windows-1255",
|
||||
"ISO-8859-8-I",
|
||||
"ISO-8859-8",
|
||||
// Japanese
|
||||
"Shift_JIS",
|
||||
"EUC-JP",
|
||||
"ISO-2022-JP",
|
||||
// Korean
|
||||
"EUC-KR",
|
||||
// Thai
|
||||
"windows-874",
|
||||
// Turkish
|
||||
"windows-1254",
|
||||
// Vietnamese
|
||||
"windows-1258",
|
||||
// Hiding rare European encodings that aren't in the menu in IE11 and would
|
||||
// make the menu messy by sorting all over the place
|
||||
// "ISO-8859-3",
|
||||
// "ISO-8859-10",
|
||||
// "ISO-8859-14",
|
||||
// "ISO-8859-15",
|
||||
// "ISO-8859-16",
|
||||
// "macintosh"
|
||||
]);
|
||||
|
||||
// Always at the start of the menu, in this order, followed by a separator.
|
||||
const kPinned = [
|
||||
"UTF-8",
|
||||
"windows-1252"
|
||||
];
|
||||
|
||||
this.CharsetMenu = Object.freeze({
|
||||
build: function BuildCharsetMenu(event) {
|
||||
let parent = event.target;
|
||||
if (parent.lastChild.localName != "menuseparator") {
|
||||
// Detector menu or charset menu already built
|
||||
return;
|
||||
}
|
||||
let doc = parent.ownerDocument;
|
||||
|
||||
function createItem(encoding) {
|
||||
let menuItem = doc.createElement("menuitem");
|
||||
menuItem.setAttribute("type", "radio");
|
||||
menuItem.setAttribute("name", "charsetGroup");
|
||||
try {
|
||||
menuItem.setAttribute("label", gBundle.GetStringFromName(encoding));
|
||||
} catch (e) {
|
||||
// Localization error but put *something* in the menu to recover.
|
||||
menuItem.setAttribute("label", encoding);
|
||||
}
|
||||
try {
|
||||
menuItem.setAttribute("accesskey",
|
||||
gBundle.GetStringFromName(encoding + ".key"));
|
||||
} catch (e) {
|
||||
// Some items intentionally don't have an accesskey
|
||||
}
|
||||
menuItem.setAttribute("id", "charset." + encoding);
|
||||
return menuItem;
|
||||
}
|
||||
|
||||
// Clone the set in order to be able to remove the pinned encodings from
|
||||
// the cloned set.
|
||||
let encodings = new Set(kEncodings);
|
||||
for (let encoding of kPinned) {
|
||||
encodings.delete(encoding);
|
||||
parent.appendChild(createItem(encoding));
|
||||
}
|
||||
parent.appendChild(doc.createElement("menuseparator"));
|
||||
let list = [];
|
||||
for (let encoding of encodings) {
|
||||
list.push(createItem(encoding));
|
||||
}
|
||||
|
||||
list.sort(function (a, b) {
|
||||
let titleA = a.getAttribute("label");
|
||||
let titleB = b.getAttribute("label");
|
||||
// Normal sorting sorts the part in parenthesis in an order that
|
||||
// happens to make the less frequently-used items first.
|
||||
let index;
|
||||
if ((index = titleA.indexOf("(")) > -1) {
|
||||
titleA = titleA.substring(0, index);
|
||||
}
|
||||
if ((index = titleB.indexOf("(")) > -1) {
|
||||
titleA = titleB.substring(0, index);
|
||||
}
|
||||
let comp = titleA.localeCompare(titleB);
|
||||
if (comp) {
|
||||
return comp;
|
||||
}
|
||||
// secondarily reverse sort by encoding name to sort "windows" or
|
||||
// "shift_jis" first. This works regardless of localization, because
|
||||
// the ids aren't localized.
|
||||
let idA = a.getAttribute("id");
|
||||
let idB = b.getAttribute("id");
|
||||
if (idA < idB) {
|
||||
return 1;
|
||||
}
|
||||
if (idB < idA) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
|
||||
for (let item of list) {
|
||||
parent.appendChild(item);
|
||||
}
|
||||
},
|
||||
});
|
@ -8,6 +8,7 @@ TEST_DIRS += ['test']
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'BrowserNewTabPreloader.jsm',
|
||||
'CharsetMenu.jsm',
|
||||
'ContentClick.jsm',
|
||||
'NetworkPrioritizer.jsm',
|
||||
'offlineAppCache.jsm',
|
||||
|
@ -8,8 +8,6 @@
|
||||
|
||||
## Format of this file:
|
||||
##
|
||||
## charset_name.notForBrowser = anything - specifies that this charset is
|
||||
## not to be exposed in the browser charset selection UI
|
||||
## charset_name.notForOutgoing = anything - specifies that this charset is
|
||||
## not to be used for exporting files ('SaveAsCharset' in composer)
|
||||
##
|
||||
@ -21,74 +19,6 @@
|
||||
##
|
||||
## charset_name.isMultibyte = multi byte charsets
|
||||
|
||||
# notForBrowser falls into four categories:
|
||||
#
|
||||
# charsets that we need decoders for, that we don't expect ever to appear in
|
||||
# web content
|
||||
# XXX do we still need to support t.61?
|
||||
t.61-8bit.notForBrowser = true
|
||||
|
||||
# charsets that are subsets or variants of other charsets. We implement them
|
||||
# as aliases to the superset
|
||||
us-ascii.notForBrowser = true
|
||||
iso-8859-6-e.notForBrowser = true
|
||||
iso-8859-6-i.notForBrowser = true
|
||||
iso-8859-8-e.notForBrowser = true
|
||||
|
||||
# platform charsets that don't appear in web content
|
||||
ibm869.notForBrowser = true
|
||||
ibm1125.notForBrowser = true
|
||||
ibm1131.notForBrowser = true
|
||||
|
||||
# encodings not in the Encoding Standard
|
||||
# keep ISO-8859-1 at the moment
|
||||
#iso-8859-1.notForBrowser = true
|
||||
#iso-8859-9.notForBrowser = true
|
||||
#iso-8859-11.notForBrowser = true
|
||||
#ibm850.notForBrowser = true
|
||||
#ibm852.notForBrowser = true
|
||||
#ibm855.notForBrowser = true
|
||||
#ibm857.notForBrowser = true
|
||||
#ibm862.notForBrowser = true
|
||||
#x-mac-greek.notForBrowser = true
|
||||
#x-mac-icelandic.notForBrowser = true
|
||||
#x-mac-ce.notForBrowser = true
|
||||
#x-mac-croatian.notForBrowser = true
|
||||
#x-mac-ukrainian.notForBrowser = true
|
||||
#x-mac-romanian.notForBrowser = true
|
||||
#x-mac-turkish.notForBrowser = true
|
||||
#x-mac-devanagari.notForBrowser = true
|
||||
#x-mac-gujarati.notForBrowser = true
|
||||
#x-mac-gurmukhi.notForBrowser = true
|
||||
#iso-ir-111.notForBrowser = true
|
||||
#gb2312.notForBrowser = true
|
||||
#iso-2022-cn.notForBrowser = true
|
||||
#big5-hkscs.notForBrowser = true
|
||||
#x-euc-tw.notForBrowser = true
|
||||
#x-johab.notForBrowser = true
|
||||
#armscii-8.notForBrowser = true
|
||||
#tis-620.notForBrowser = true
|
||||
#viscii.notForBrowser = true
|
||||
#x-viet-tcvn5712.notForBrowser = true
|
||||
#x-viet-vps.notForBrowser = true
|
||||
utf-16.notForBrowser = true
|
||||
|
||||
# blacklisted from the menu to prevent self-XSS
|
||||
#hz-gb-2312.notForBrowser = true
|
||||
#iso-2022-jp.notForBrowser = true
|
||||
#iso-2022-kr.notForBrowser = true
|
||||
utf-16le.notForBrowser = true
|
||||
utf-16be.notForBrowser = true
|
||||
|
||||
# charset with isInternal
|
||||
x-mac-arabic.notForBrowser = true
|
||||
x-mac-farsi.notForBrowser = true
|
||||
x-mac-hebrew.notForBrowser = true
|
||||
x-imap4-modified-utf7.notForBrowser = true
|
||||
utf-7.notForBrowser = true
|
||||
ibm864.notForBrowser = true
|
||||
replacement.notForBrowser = true
|
||||
|
||||
x-mac-arabic.isInternal = true
|
||||
x-mac-farsi.isInternal = true
|
||||
x-mac-hebrew.isInternal = true
|
||||
|
@ -133,7 +133,6 @@ private:
|
||||
static nsIRDFDataSource * mInner;
|
||||
|
||||
bool mInitialized;
|
||||
bool mBrowserMenuInitialized;
|
||||
bool mMailviewMenuInitialized;
|
||||
bool mComposerMenuInitialized;
|
||||
bool mMaileditMenuInitialized;
|
||||
@ -141,11 +140,6 @@ private:
|
||||
bool mAutoDetectInitialized;
|
||||
bool mOthersInitialized;
|
||||
|
||||
nsTArray<nsMenuEntry*> mBrowserMenu;
|
||||
int32_t mBrowserCacheStart;
|
||||
int32_t mBrowserCacheSize;
|
||||
int32_t mBrowserMenuRDFPosition;
|
||||
|
||||
nsTArray<nsMenuEntry*> mMailviewMenu;
|
||||
int32_t mMailviewCacheStart;
|
||||
int32_t mMailviewCacheSize;
|
||||
@ -248,14 +242,12 @@ public:
|
||||
virtual ~nsCharsetMenu();
|
||||
|
||||
nsresult Init();
|
||||
nsresult InitBrowserMenu();
|
||||
nsresult InitMaileditMenu();
|
||||
nsresult InitMailviewMenu();
|
||||
nsresult InitComposerMenu();
|
||||
nsresult InitOthers();
|
||||
nsresult InitSecondaryTiers();
|
||||
nsresult InitAutodetMenu();
|
||||
nsresult RefreshBrowserMenu();
|
||||
nsresult RefreshMailviewMenu();
|
||||
nsresult RefreshMaileditMenu();
|
||||
nsresult RefreshComposerMenu();
|
||||
@ -385,9 +377,6 @@ NS_IMETHODIMP nsCharsetMenuObserver::Observe(nsISupports *aSubject, const char *
|
||||
if (!nsCRT::strcmp(aTopic, "charsetmenu-selected")) {
|
||||
nsDependentString nodeName(someData);
|
||||
rv = mCharsetMenu->Init();
|
||||
if (nodeName.EqualsLiteral("browser")) {
|
||||
rv = mCharsetMenu->InitBrowserMenu();
|
||||
}
|
||||
if (nodeName.EqualsLiteral("composer")) {
|
||||
rv = mCharsetMenu->InitComposerMenu();
|
||||
}
|
||||
@ -414,8 +403,6 @@ NS_IMETHODIMP nsCharsetMenuObserver::Observe(nsISupports *aSubject, const char *
|
||||
|
||||
if (prefName.EqualsLiteral(kBrowserStaticPrefKey)) {
|
||||
// refresh menus which share this pref
|
||||
rv = mCharsetMenu->RefreshBrowserMenu();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mCharsetMenu->RefreshMailviewMenu();
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
rv = mCharsetMenu->RefreshComposerMenu();
|
||||
@ -467,7 +454,6 @@ nsIRDFResource * nsCharsetMenu::kRDF_type = nullptr;
|
||||
|
||||
nsCharsetMenu::nsCharsetMenu()
|
||||
: mInitialized(false),
|
||||
mBrowserMenuInitialized(false),
|
||||
mMailviewMenuInitialized(false),
|
||||
mComposerMenuInitialized(false),
|
||||
mMaileditMenuInitialized(false),
|
||||
@ -517,53 +503,12 @@ nsCharsetMenu::~nsCharsetMenu()
|
||||
{
|
||||
Done();
|
||||
|
||||
FreeMenuItemArray(&mBrowserMenu);
|
||||
FreeMenuItemArray(&mMailviewMenu);
|
||||
FreeMenuItemArray(&mComposerMenu);
|
||||
|
||||
FreeResources();
|
||||
}
|
||||
|
||||
// XXX collapse these 2 in one
|
||||
|
||||
nsresult nsCharsetMenu::RefreshBrowserMenu()
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
res = NewRDFContainer(mInner, kNC_BrowserCharsetMenuRoot, getter_AddRefs(container));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// clean the menu
|
||||
res = ClearMenu(container, &mBrowserMenu);
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
// rebuild the menu
|
||||
nsCOMPtr<nsIUTF8StringEnumerator> decoders;
|
||||
res = mCCManager->GetDecoderList(getter_AddRefs(decoders));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
nsTArray<nsCString> decs;
|
||||
SetArrayFromEnumerator(decoders, decs);
|
||||
|
||||
res = AddFromPrefsToMenu(&mBrowserMenu, container, kBrowserStaticPrefKey,
|
||||
decs, "charset.");
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "error initializing static charset menu from prefs");
|
||||
|
||||
// mark the end of the static area, the rest is cache
|
||||
mBrowserCacheStart = mBrowserMenu.Length();
|
||||
|
||||
// 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");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsCharsetMenu::RefreshMailviewMenu()
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
@ -800,49 +745,6 @@ nsresult nsCharsetMenu::FreeResources()
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsCharsetMenu::InitBrowserMenu()
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
|
||||
if (!mBrowserMenuInitialized) {
|
||||
nsCOMPtr<nsIRDFContainer> container;
|
||||
res = NewRDFContainer(mInner, kNC_BrowserCharsetMenuRoot, getter_AddRefs(container));
|
||||
if (NS_FAILED(res)) return res;
|
||||
|
||||
nsTArray<nsCString> browserDecoderList(mDecoderList);
|
||||
|
||||
res = InitStaticMenu(browserDecoderList, kNC_BrowserCharsetMenuRoot,
|
||||
kBrowserStaticPrefKey, &mBrowserMenu);
|
||||
NS_ASSERTION(NS_SUCCEEDED(res), "error initializing browser static charset menu");
|
||||
|
||||
// mark the end of the static area, the rest is cache
|
||||
mBrowserCacheStart = mBrowserMenu.Length();
|
||||
mPrefs->GetIntPref(kBrowserCacheSizePrefKey, &mBrowserCacheSize);
|
||||
|
||||
// compute the position of the menu in the RDF container
|
||||
res = container->GetCount(&mBrowserMenuRDFPosition);
|
||||
if (NS_FAILED(res)) return res;
|
||||
// this "1" here is a correction necessary because the RDF container
|
||||
// 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");
|
||||
|
||||
// register prefs callback
|
||||
mPrefs->AddObserver(kBrowserStaticPrefKey, mCharsetMenuObserver, false);
|
||||
}
|
||||
|
||||
mBrowserMenuInitialized = NS_SUCCEEDED(res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
nsresult nsCharsetMenu::InitMaileditMenu()
|
||||
{
|
||||
nsresult res = NS_OK;
|
||||
@ -1685,31 +1587,7 @@ nsresult nsCharsetMenu::GetCollation(nsICollation ** aCollation)
|
||||
|
||||
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,
|
||||
mBrowserMenuRDFPosition);
|
||||
if (NS_FAILED(res)) {
|
||||
return res;
|
||||
}
|
||||
|
||||
res = WriteCacheToPrefs(&mBrowserMenu, mBrowserCacheStart,
|
||||
kBrowserCachePrefKey);
|
||||
} else {
|
||||
res = UpdateCachePrefs(kBrowserCachePrefKey, kBrowserCacheSizePrefKey,
|
||||
kBrowserStaticPrefKey, aCharset);
|
||||
}
|
||||
return res;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsCharsetMenu::SetCurrentMailCharset(const PRUnichar * aCharset)
|
||||
|
@ -8,7 +8,6 @@
|
||||
<?xml-stylesheet href="chrome://global/content/viewSource.css" type="text/css"?>
|
||||
<?xml-stylesheet href="chrome://mozapps/skin/viewsource/viewsource.css" type="text/css"?>
|
||||
<?xul-overlay href="chrome://global/content/editMenuOverlay.xul"?>
|
||||
<?xul-overlay href="chrome://global/content/charsetOverlay.xul"?>
|
||||
|
||||
<!DOCTYPE window [
|
||||
<!ENTITY % brandDTD SYSTEM "chrome://branding/locale/brand.dtd" >
|
||||
@ -195,7 +194,6 @@
|
||||
key="key_textZoomReset"/>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menu id="charsetMenu"/>
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_wrapLongLines" type="checkbox" command="cmd_wrapLongLines"
|
||||
label="&menu_wrapLongLines.title;" accesskey="&menu_wrapLongLines.accesskey;"/>
|
||||
|
Loading…
Reference in New Issue
Block a user