mirror of
https://github.com/gryf/pentadactyl-pm.git
synced 2026-01-07 23:34:11 +01:00
Fix charset bustage.
This commit is contained in:
@@ -17,7 +17,7 @@ function module(url) {
|
||||
}
|
||||
|
||||
var { XPCOMUtils } = module("resource://gre/modules/XPCOMUtils.jsm");
|
||||
var { OS, TextDecoder, TextEncoder } = module("resource://gre/modules/osfile.jsm");
|
||||
var { OS } = module("resource://gre/modules/osfile.jsm");
|
||||
try {
|
||||
var { ctypes } = module("resource://gre/modules/ctypes.jsm");
|
||||
}
|
||||
@@ -748,9 +748,13 @@ function memoize(obj, key, getter) {
|
||||
}
|
||||
}
|
||||
|
||||
let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"].createInstance());
|
||||
|
||||
let sandbox = Cu.Sandbox(Cc["@mozilla.org/systemprincipal;1"].createInstance(),
|
||||
{ wantGlobalProperties: ["TextDecoder", "TextEncoder"] });
|
||||
sandbox.__proto__ = this;
|
||||
|
||||
var { TextEncoder, TextDecoder } = sandbox;
|
||||
|
||||
/**
|
||||
* Updates an object with the properties of another object. Getters
|
||||
* and setters are copied as expected. Moreover, any function
|
||||
|
||||
@@ -216,6 +216,28 @@ var IO = Module("io", {
|
||||
}
|
||||
}),
|
||||
|
||||
charsets: Class.Memoize(function () {
|
||||
const BASE = "@mozilla.org/intl/unicode/decoder;1?charset=";
|
||||
return [k.slice(BASE.length)
|
||||
for (k of Object.keys(Cc))
|
||||
if (k.startsWith(BASE))];
|
||||
}),
|
||||
|
||||
charsetBundle: Class.Memoize(
|
||||
() => services.stringBundle.createBundle("chrome://global/locale/charsetTitles.properties")),
|
||||
|
||||
charsetTitle: function charsetTitle(charset, default_=charset) {
|
||||
try {
|
||||
return this.charsetBundle.GetStringFromName(charset + ".title");
|
||||
}
|
||||
catch (e) {}
|
||||
return default_;
|
||||
},
|
||||
|
||||
validateCharset: function validateCharset(charset) {
|
||||
new TextDecoder(charset);
|
||||
},
|
||||
|
||||
// TODO: there seems to be no way, short of a new component, to change
|
||||
// the process's CWD - see https://bugzilla.mozilla.org/show_bug.cgi?id=280953
|
||||
/**
|
||||
@@ -942,16 +964,9 @@ unlet s:cpo_save
|
||||
context.anchored = false;
|
||||
context.keys = {
|
||||
text: util.identity,
|
||||
description: function (charset) {
|
||||
try {
|
||||
return services.charset.getCharsetTitle(charset);
|
||||
}
|
||||
catch (e) {
|
||||
return charset;
|
||||
}
|
||||
}
|
||||
description: charset => io.charsetTitle(charset),
|
||||
};
|
||||
context.generate = () => iter(services.charset.getDecoderList());
|
||||
context.completions = io.charsets;
|
||||
};
|
||||
|
||||
completion.directory = function directory(context, full) {
|
||||
|
||||
Reference in New Issue
Block a user