mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Backed out 3 changesets (bug 956657, bug 974824, bug 974258) for mochitest-other failures on a CLOSED TREE.
Backed out changeset 792ce962cad6 (bug 956657) Backed out changeset a1574a6b0544 (bug 974824) Backed out changeset ad851c771c04 (bug 974258)
This commit is contained in:
parent
ac85a0c7a8
commit
4f25d52cfa
@ -2,18 +2,20 @@
|
||||
# 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/.
|
||||
|
||||
<menu id="charsetMenu"
|
||||
#filter substitution
|
||||
|
||||
#expand <menu id="__ID_PREFIX__charsetMenu"
|
||||
label="&charsetMenu.label;"
|
||||
#ifndef OMIT_ACCESSKEYS
|
||||
accesskey="&charsetMenu.accesskey;"
|
||||
#endif
|
||||
oncommand="BrowserSetForcedCharacterSet(event.target.getAttribute('charset'));"
|
||||
oncommand="MultiplexHandler(event)"
|
||||
#ifdef OMIT_ACCESSKEYS
|
||||
onpopupshowing="CharsetMenu.build(event.target, false);"
|
||||
#expand onpopupshowing="CharsetMenu.build(event.target, '__ID_PREFIX__', false);"
|
||||
#else
|
||||
onpopupshowing="CharsetMenu.build(event.target);"
|
||||
#expand onpopupshowing="CharsetMenu.build(event.target, '__ID_PREFIX__');"
|
||||
#endif
|
||||
onpopupshown="UpdateCurrentCharset(this);">
|
||||
onpopupshown="UpdateMenus(event);">
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
|
@ -5139,15 +5139,55 @@ function handleDroppedLink(event, url, name)
|
||||
event.preventDefault();
|
||||
};
|
||||
|
||||
function MultiplexHandler(event)
|
||||
{ try {
|
||||
var node = event.target;
|
||||
var name = node.getAttribute('name');
|
||||
|
||||
if (name == 'detectorGroup') {
|
||||
BrowserCharsetReload();
|
||||
SelectDetector(event, false);
|
||||
} else if (name == 'charsetGroup') {
|
||||
var charset = node.getAttribute('id');
|
||||
charset = charset.substring(charset.indexOf('charset.') + 'charset.'.length);
|
||||
BrowserSetForcedCharacterSet(charset);
|
||||
} else if (name == 'charsetCustomize') {
|
||||
//do nothing - please remove this else statement, once the charset prefs moves to the pref window
|
||||
} else {
|
||||
BrowserSetForcedCharacterSet(node.getAttribute('id'));
|
||||
}
|
||||
} catch(ex) { alert(ex); }
|
||||
}
|
||||
|
||||
function SelectDetector(event, doReload)
|
||||
{
|
||||
var uri = event.target.getAttribute("id");
|
||||
var prefvalue = uri.substring(uri.indexOf('chardet.') + 'chardet.'.length);
|
||||
if ("off" == prefvalue) { // "off" is special value to turn off the detectors
|
||||
prefvalue = "";
|
||||
}
|
||||
|
||||
try {
|
||||
var str = Cc["@mozilla.org/supports-string;1"].
|
||||
createInstance(Ci.nsISupportsString);
|
||||
|
||||
str.data = prefvalue;
|
||||
gPrefService.setComplexValue("intl.charset.detector", Ci.nsISupportsString, str);
|
||||
if (doReload)
|
||||
window.content.location.reload();
|
||||
}
|
||||
catch (ex) {
|
||||
dump("Failed to set the intl.charset.detector preference.\n");
|
||||
}
|
||||
}
|
||||
|
||||
function BrowserSetForcedCharacterSet(aCharset)
|
||||
{
|
||||
if (aCharset) {
|
||||
gBrowser.docShell.gatherCharsetMenuTelemetry();
|
||||
gBrowser.docShell.charset = aCharset;
|
||||
// Save the forced character-set
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(window))
|
||||
PlacesUtils.setCharsetForURI(getWebNavigation().currentURI, aCharset);
|
||||
}
|
||||
gBrowser.docShell.gatherCharsetMenuTelemetry();
|
||||
gBrowser.docShell.charset = aCharset;
|
||||
// Save the forced character-set
|
||||
if (!PrivateBrowsingUtils.isWindowPrivate(window))
|
||||
PlacesUtils.setCharsetForURI(getWebNavigation().currentURI, aCharset);
|
||||
BrowserCharsetReload();
|
||||
}
|
||||
|
||||
@ -5156,8 +5196,8 @@ function BrowserCharsetReload()
|
||||
BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
|
||||
}
|
||||
|
||||
function charsetMenuGetElement(parent, charset) {
|
||||
return parent.getElementsByAttribute("charset", charset)[0];
|
||||
function charsetMenuGetElement(parent, id) {
|
||||
return parent.getElementsByAttribute("id", id)[0];
|
||||
}
|
||||
|
||||
function UpdateCurrentCharset(target) {
|
||||
@ -5167,19 +5207,54 @@ function UpdateCurrentCharset(target) {
|
||||
|
||||
// Uncheck previous item
|
||||
if (gPrevCharset) {
|
||||
var pref_item = charsetMenuGetElement(target, gPrevCharset);
|
||||
var pref_item = charsetMenuGetElement(target, "charset." + gPrevCharset);
|
||||
if (pref_item)
|
||||
pref_item.setAttribute('checked', 'false');
|
||||
}
|
||||
|
||||
var menuitem = charsetMenuGetElement(target, CharsetMenu.foldCharset(wnd.document.characterSet));
|
||||
var menuitem = charsetMenuGetElement(target, "charset." + FoldCharset(wnd.document.characterSet));
|
||||
if (menuitem) {
|
||||
menuitem.setAttribute('checked', 'true');
|
||||
}
|
||||
}
|
||||
|
||||
function FoldCharset(charset) {
|
||||
// For substantially similar encodings, treat two encodings as the same
|
||||
// for the purpose of the check mark.
|
||||
if (charset == "ISO-8859-8-I") {
|
||||
return "windows-1255";
|
||||
}
|
||||
|
||||
if (charset == "gb18030") {
|
||||
return "gbk";
|
||||
}
|
||||
|
||||
return charset;
|
||||
}
|
||||
|
||||
function UpdateCharsetDetector(target) {
|
||||
var prefvalue;
|
||||
|
||||
try {
|
||||
prefvalue = gPrefService.getComplexValue("intl.charset.detector", Ci.nsIPrefLocalizedString).data;
|
||||
}
|
||||
catch (ex) {}
|
||||
|
||||
if (!prefvalue)
|
||||
prefvalue = "off";
|
||||
|
||||
var menuitem = charsetMenuGetElement(target, "chardet." + prefvalue);
|
||||
if (menuitem)
|
||||
menuitem.setAttribute("checked", "true");
|
||||
}
|
||||
|
||||
function UpdateMenus(event) {
|
||||
UpdateCurrentCharset(event.target);
|
||||
UpdateCharsetDetector(event.target);
|
||||
}
|
||||
|
||||
function charsetLoadListener() {
|
||||
var charset = CharsetMenu.fold(window.content.document.characterSet);
|
||||
var charset = FoldCharset(window.content.document.characterSet);
|
||||
|
||||
if (charset.length > 0 && (charset != gLastBrowserCharset)) {
|
||||
gPrevCharset = gLastBrowserCharset;
|
||||
|
@ -19,7 +19,7 @@
|
||||
|
||||
<binding id="urlbar" extends="chrome://global/content/bindings/autocomplete.xml#autocomplete">
|
||||
|
||||
<content>
|
||||
<content sizetopopup="pref">
|
||||
<xul:hbox anonid="textbox-container"
|
||||
class="autocomplete-textbox-container urlbar-textbox-container"
|
||||
flex="1" xbl:inherits="focused">
|
||||
|
@ -657,13 +657,84 @@ function BrowserCharsetReload()
|
||||
}
|
||||
}
|
||||
|
||||
function BrowserSetCharacterSet(aEvent)
|
||||
function BrowserSetForcedCharacterSet(aCharset)
|
||||
{
|
||||
if (aEvent.target.hasAttribute("charset"))
|
||||
gBrowser.docShell.charset = aEvent.target.getAttribute("charset");
|
||||
gBrowser.docShell.charset = aCharset;
|
||||
BrowserCharsetReload();
|
||||
}
|
||||
|
||||
function MultiplexHandler(event)
|
||||
{
|
||||
var node = event.target;
|
||||
var name = node.getAttribute("name");
|
||||
|
||||
if (name == "detectorGroup") {
|
||||
SelectDetector(event);
|
||||
BrowserCharsetReload();
|
||||
} else if (name == "charsetGroup") {
|
||||
var charset = node.getAttribute("id");
|
||||
charset = charset.substring(charset.indexOf("charset.") + "charset.".length);
|
||||
BrowserSetForcedCharacterSet(charset);
|
||||
}
|
||||
}
|
||||
|
||||
function SelectDetector(event)
|
||||
{
|
||||
var uri = event.target.getAttribute("id");
|
||||
var prefvalue = uri.substring(uri.indexOf("chardet.") + "chardet.".length);
|
||||
if ("off" == prefvalue) { // "off" is special value to turn off the detectors
|
||||
prefvalue = "";
|
||||
}
|
||||
|
||||
try {
|
||||
var str = Cc["@mozilla.org/supports-string;1"].
|
||||
createInstance(Ci.nsISupportsString);
|
||||
str.data = prefvalue;
|
||||
gPrefService.setComplexValue("intl.charset.detector", Ci.nsISupportsString, str);
|
||||
}
|
||||
catch (ex) {
|
||||
dump("Failed to set the intl.charset.detector preference.\n");
|
||||
}
|
||||
}
|
||||
|
||||
function FoldCharset(charset) {
|
||||
// For substantially similar encodings, treat two encodings as the same
|
||||
// for the purpose of the check mark.
|
||||
if (charset == "ISO-8859-8-I") {
|
||||
return "windows-1255";
|
||||
} else if (charset == "gb18030") {
|
||||
return "gbk";
|
||||
}
|
||||
return charset;
|
||||
}
|
||||
|
||||
function UpdateCurrentCharset() {
|
||||
var menuitem = document.getElementById("charset." + FoldCharset(content.document.characterSet));
|
||||
if (menuitem)
|
||||
menuitem.setAttribute("checked", "true");
|
||||
}
|
||||
|
||||
function UpdateCharsetDetector() {
|
||||
var prefvalue;
|
||||
|
||||
try {
|
||||
prefvalue = gPrefService.getComplexValue("intl.charset.detector", Ci.nsIPrefLocalizedString).data;
|
||||
}
|
||||
catch (ex) {}
|
||||
|
||||
if (!prefvalue)
|
||||
prefvalue = "off";
|
||||
|
||||
var menuitem = document.getElementById("chardet." + prefvalue);
|
||||
if (menuitem)
|
||||
menuitem.setAttribute("checked", "true");
|
||||
}
|
||||
|
||||
function UpdateMenus() {
|
||||
UpdateCurrentCharset();
|
||||
UpdateCharsetDetector();
|
||||
}
|
||||
|
||||
function BrowserForward(aEvent) {
|
||||
try {
|
||||
gBrowser.goForward();
|
||||
|
@ -201,10 +201,11 @@
|
||||
<menu id="charsetMenu"
|
||||
label="&charsetMenu.label;"
|
||||
accesskey="&charsetMenu.accesskey;"
|
||||
oncommand="BrowserSetCharacterSet(event);"
|
||||
oncommand="MultiplexHandler(event);"
|
||||
onpopupshowing="CharsetMenu.build(event.target);"
|
||||
onpopupshown="CharsetMenu.update(event, content.document.characterSet);">
|
||||
<menupopup/>
|
||||
onpopupshown="UpdateMenus();">
|
||||
<menupopup>
|
||||
</menupopup>
|
||||
</menu>
|
||||
<menuseparator/>
|
||||
<menuitem id="menu_wrapLongLines" type="checkbox" command="cmd_wrapLongLines"
|
||||
|
@ -22,7 +22,7 @@
|
||||
<stylesheet src="chrome://global/skin/autocomplete.css"/>
|
||||
</resources>
|
||||
|
||||
<content>
|
||||
<content sizetopopup="pref">
|
||||
<xul:hbox class="autocomplete-textbox-container" flex="1" xbl:inherits="focused">
|
||||
<children includes="image|deck|stack|box">
|
||||
<xul:image class="autocomplete-icon" allowevents="true"/>
|
||||
|
@ -14,7 +14,7 @@ XPCOMUtils.defineLazyGetter(this, "gBundle", function() {
|
||||
});
|
||||
|
||||
const kAutoDetectors = [
|
||||
["off", ""],
|
||||
["off", "off"],
|
||||
["ja", "ja_parallel_state_machine"],
|
||||
["ru", "ruprob"],
|
||||
["uk", "ukprob"]
|
||||
@ -89,71 +89,46 @@ const kPinned = [
|
||||
|
||||
kPinned.forEach(x => kEncodings.delete(x));
|
||||
|
||||
function CharsetComparator(a, b) {
|
||||
// Normal sorting sorts the part in parenthesis in an order that
|
||||
// happens to make the less frequently-used items first.
|
||||
let titleA = a.label.replace(/\(.*/, "") + b.value;
|
||||
let titleB = b.label.replace(/\(.*/, "") + a.value;
|
||||
// Secondarily reverse sort by encoding name to sort "windows" or
|
||||
// "shift_jis" first.
|
||||
return titleA.localeCompare(titleB) || b.value.localeCompare(a.value);
|
||||
}
|
||||
|
||||
function SetDetector(event) {
|
||||
let str = Cc["@mozilla.org/supports-string;1"].createInstance(Ci.nsISupportsString);
|
||||
str.data = event.target.getAttribute("detector");
|
||||
Services.prefs.setComplexValue("intl.charset.detector", Ci.nsISupportsString, str);
|
||||
}
|
||||
|
||||
function UpdateDetectorMenu(event) {
|
||||
event.stopPropagation();
|
||||
let detector = Services.prefs.getComplexValue("intl.charset.detector", Ci.nsIPrefLocalizedString);
|
||||
let menuitem = this.getElementsByAttribute("detector", detector).item(0);
|
||||
if (menuitem) {
|
||||
menuitem.setAttribute("checked", "true");
|
||||
}
|
||||
}
|
||||
|
||||
let gDetectorInfoCache, gCharsetInfoCache, gPinnedInfoCache;
|
||||
|
||||
let CharsetMenu = {
|
||||
build: function(parent, showAccessKeys=true, showDetector=true) {
|
||||
build: function(parent, idPrefix="", showAccessKeys=true) {
|
||||
function createDOMNode(doc, nodeInfo) {
|
||||
let node = doc.createElement("menuitem");
|
||||
node.setAttribute("type", "radio");
|
||||
node.setAttribute("name", nodeInfo.name + "Group");
|
||||
node.setAttribute(nodeInfo.name, nodeInfo.value);
|
||||
node.setAttribute("name", nodeInfo.name);
|
||||
node.setAttribute("label", nodeInfo.label);
|
||||
if (showAccessKeys && nodeInfo.accesskey) {
|
||||
node.setAttribute("accesskey", nodeInfo.accesskey);
|
||||
}
|
||||
if (idPrefix) {
|
||||
node.id = idPrefix + nodeInfo.id;
|
||||
} else {
|
||||
node.id = nodeInfo.id;
|
||||
}
|
||||
return node;
|
||||
}
|
||||
|
||||
if (parent.hasChildNodes()) {
|
||||
if (parent.childElementCount > 0) {
|
||||
// Detector menu or charset menu already built
|
||||
return;
|
||||
}
|
||||
this._ensureDataReady();
|
||||
let doc = parent.ownerDocument;
|
||||
|
||||
if (showDetector) {
|
||||
let menuNode = doc.createElement("menu");
|
||||
menuNode.setAttribute("label", gBundle.GetStringFromName("charsetMenuAutodet"));
|
||||
if (showAccessKeys) {
|
||||
menuNode.setAttribute("accesskey", gBundle.GetStringFromName("charsetMenuAutodet.key"));
|
||||
}
|
||||
parent.appendChild(menuNode);
|
||||
|
||||
let menuPopupNode = doc.createElement("menupopup");
|
||||
menuNode.appendChild(menuPopupNode);
|
||||
menuPopupNode.addEventListener("command", SetDetector);
|
||||
menuPopupNode.addEventListener("popupshown", UpdateDetectorMenu);
|
||||
|
||||
gDetectorInfoCache.forEach(detectorInfo => menuPopupNode.appendChild(createDOMNode(doc, detectorInfo)));
|
||||
parent.appendChild(doc.createElement("menuseparator"));
|
||||
let menuNode = doc.createElement("menu");
|
||||
menuNode.setAttribute("label", gBundle.GetStringFromName("charsetMenuAutodet"));
|
||||
if (showAccessKeys) {
|
||||
menuNode.setAttribute("accesskey", gBundle.GetStringFromName("charsetMenuAutodet.key"));
|
||||
}
|
||||
parent.appendChild(menuNode);
|
||||
|
||||
let menuPopupNode = doc.createElement("menupopup");
|
||||
menuNode.appendChild(menuPopupNode);
|
||||
|
||||
this._ensureDataReady();
|
||||
gDetectorInfoCache.forEach(detectorInfo => menuPopupNode.appendChild(createDOMNode(doc, detectorInfo)));
|
||||
parent.appendChild(doc.createElement("menuseparator"));
|
||||
gPinnedInfoCache.forEach(charsetInfo => parent.appendChild(createDOMNode(doc, charsetInfo)));
|
||||
parent.appendChild(doc.createElement("menuseparator"));
|
||||
gCharsetInfoCache.forEach(charsetInfo => parent.appendChild(createDOMNode(doc, charsetInfo)));
|
||||
@ -172,30 +147,58 @@ let CharsetMenu = {
|
||||
if (!gDetectorInfoCache) {
|
||||
gDetectorInfoCache = this.getDetectorInfo();
|
||||
gPinnedInfoCache = this.getCharsetInfo(kPinned, false);
|
||||
gCharsetInfoCache = this.getCharsetInfo(kEncodings);
|
||||
gCharsetInfoCache = this.getCharsetInfo([...kEncodings]);
|
||||
}
|
||||
},
|
||||
|
||||
getDetectorInfo: function() {
|
||||
return kAutoDetectors.map(([detectorName, nodeId]) => ({
|
||||
id: "chardet." + nodeId,
|
||||
label: this._getDetectorLabel(detectorName),
|
||||
accesskey: this._getDetectorAccesskey(detectorName),
|
||||
name: "detector",
|
||||
value: nodeId
|
||||
name: "detectorGroup",
|
||||
}));
|
||||
},
|
||||
|
||||
getCharsetInfo: function(charsets, sort=true) {
|
||||
let list = [{
|
||||
let list = charsets.map(charset => ({
|
||||
id: "charset." + charset,
|
||||
label: this._getCharsetLabel(charset),
|
||||
accesskey: this._getCharsetAccessKey(charset),
|
||||
name: "charset",
|
||||
value: charset
|
||||
} for (charset of charsets)];
|
||||
name: "charsetGroup",
|
||||
}));
|
||||
|
||||
if (sort) {
|
||||
list.sort(CharsetComparator);
|
||||
if (!sort) {
|
||||
return list;
|
||||
}
|
||||
|
||||
list.sort(function (a, b) {
|
||||
let titleA = a.label;
|
||||
let titleB = b.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.
|
||||
if (a.id < b.id) {
|
||||
return 1;
|
||||
}
|
||||
if (b.id < a.id) {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
});
|
||||
return list;
|
||||
},
|
||||
|
||||
@ -232,30 +235,6 @@ let CharsetMenu = {
|
||||
} catch (ex) {}
|
||||
return "";
|
||||
},
|
||||
|
||||
/**
|
||||
* For substantially similar encodings, treat two encodings as the same
|
||||
* for the purpose of the check mark.
|
||||
*/
|
||||
foldCharset: function(charset) {
|
||||
switch (charset) {
|
||||
case "ISO-8859-8-I":
|
||||
return "windows-1255";
|
||||
|
||||
case "gb18030":
|
||||
return "gbk";
|
||||
|
||||
default:
|
||||
return charset;
|
||||
}
|
||||
},
|
||||
|
||||
update: function(event, charset) {
|
||||
let menuitem = event.target.getElementsByAttribute("charset", this.foldCharset(charset)).item(0);
|
||||
if (menuitem) {
|
||||
menuitem.setAttribute("checked", "true");
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
Object.freeze(CharsetMenu);
|
||||
|
@ -17,7 +17,7 @@
|
||||
<stylesheet src="chrome://global/skin/autocomplete.css"/>
|
||||
</resources>
|
||||
|
||||
<content>
|
||||
<content sizetopopup="pref">
|
||||
<children includes="menupopup"/>
|
||||
|
||||
<xul:hbox class="autocomplete-textbox-container" flex="1" align="center">
|
||||
@ -1628,9 +1628,6 @@
|
||||
var textbox = document.getBindingParent(this);
|
||||
var kids = textbox.getElementsByClassName("autocomplete-history-popup");
|
||||
if (kids.item(0) && textbox.getAttribute("open") != "true") { // Open history popup
|
||||
var w = textbox.boxObject.width;
|
||||
if (w != kids[0].boxObject.width)
|
||||
kids[0].width = w;
|
||||
kids[0].showPopup(textbox, -1, -1, "popup", "bottomleft", "topleft");
|
||||
textbox.setAttribute("open", "true");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user