diff options
author | Kris Maglione <maglione.k@gmail.com> | 2012-11-28 20:24:44 -0800 |
---|---|---|
committer | Kris Maglione <maglione.k@gmail.com> | 2012-11-28 20:24:44 -0800 |
commit | 276956284eb49d89592821bf2dbcee41852a1aae (patch) | |
tree | 4e277e99f89e7fabd2dbb3a9101623d90c7aadb6 | |
parent | 23b6c07666ed6b21699ac76675d5ea0e73b2331f (diff) | |
download | pentadactyl-276956284eb49d89592821bf2dbcee41852a1aae.tar.gz |
Death to E4X and stuff.
-rw-r--r-- | common/content/dactyl.js | 12 | ||||
-rw-r--r-- | common/content/editor.js | 2 | ||||
-rw-r--r-- | common/content/modes.js | 4 | ||||
-rw-r--r-- | common/content/statusline.js | 19 | ||||
-rw-r--r-- | common/content/tabs.js | 4 | ||||
-rw-r--r-- | common/modules/base.jsm | 29 | ||||
-rw-r--r-- | common/modules/cache.jsm | 10 | ||||
-rw-r--r-- | common/modules/commands.jsm | 14 | ||||
-rw-r--r-- | common/modules/config.jsm | 4 | ||||
-rw-r--r-- | common/modules/help.jsm | 4 | ||||
-rw-r--r-- | common/modules/highlight.jsm | 14 | ||||
-rw-r--r-- | common/modules/io.jsm | 16 | ||||
-rw-r--r-- | common/modules/prefs.jsm | 8 | ||||
-rw-r--r-- | common/modules/protocol.jsm | 4 | ||||
-rw-r--r-- | common/modules/services.jsm | 2 | ||||
-rw-r--r-- | common/modules/storage.jsm | 2 | ||||
-rw-r--r-- | common/modules/styles.jsm | 20 | ||||
-rw-r--r-- | common/modules/template.jsm | 41 | ||||
-rw-r--r-- | common/modules/util.jsm | 8 |
19 files changed, 129 insertions, 88 deletions
diff --git a/common/content/dactyl.js b/common/content/dactyl.js index e4012eab..12fa5836 100644 --- a/common/content/dactyl.js +++ b/common/content/dactyl.js @@ -57,9 +57,9 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { delete window.liberator; // Prevents box ordering bugs after our stylesheet is removed. - styles.system.add("cleanup-sheet", config.styleableChrome, <![CDATA[ + styles.system.add("cleanup-sheet", config.styleableChrome, literal(/* #TabsToolbar tab { display: none; } - ]]>); + */)); styles.unregisterSheet("resource://dactyl-skin/dactyl.css"); DOM('#TabsToolbar tab', document).style.display; }, @@ -1055,15 +1055,15 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { }, this); }, stringToURLArray: deprecated("dactyl.parseURLs", "parseURLs"), - urlish: Class.Memoize(function () util.regexp(<![CDATA[ + urlish: Class.Memoize(function () util.regexp(literal(/* ^ ( <domain>+ (:\d+)? (/ .*) | <domain>+ (:\d+) | <domain>+ \. [a-z0-9]+ | localhost ) $ - ]]>, "ix", { - domain: util.regexp(String.replace(<![CDATA[ + */), "ix", { + domain: util.regexp(String.replace(literal(/* [^ U0000-U002c // U002d-U002e --. U002f // / @@ -1072,7 +1072,7 @@ var Dactyl = Module("dactyl", XPCOM(Ci.nsISupportsWeakReference, ModuleBase), { U005b-U0060 // U0061-U007a A-Z U007b-U007f ] - ]]>, /U/g, "\\u"), "x") + */), /U/g, "\\u"), "x") })), pluginFiles: {}, diff --git a/common/content/editor.js b/common/content/editor.js index b86b4d9a..e6982513 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -3,7 +3,7 @@ // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; /** @scope modules */ diff --git a/common/content/modes.js b/common/content/modes.js index 127fa95a..799b1259 100644 --- a/common/content/modes.js +++ b/common/content/modes.js @@ -487,7 +487,9 @@ var Modes = Module("modes", { update(StackElement.prototype, { get toStringParams() !loaded.modes ? this.main.name : [ this.main.name, - <>({ modes.all.filter(function (m) this.extended & m, this).map(function (m) m.name).join("|") })</> + ["(", modes.all.filter(function (m) this.extended & m, this) + .map(function (m) m.name).join("|"), + ")"].join("") ] }); return StackElement; diff --git a/common/content/statusline.js b/common/content/statusline.js index 4152f8cf..6ff7c0db 100644 --- a/common/content/statusline.js +++ b/common/content/statusline.js @@ -4,7 +4,7 @@ // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; /** @scope modules */ @@ -15,28 +15,26 @@ var StatusLine = Module("statusline", { this.baseGroup = this.statusBar == this._statusLine ? "StatusLine " : ""; if (this.statusBar.localName == "toolbar") { - styles.system.add("addon-bar", config.styleableChrome, <css><![CDATA[ + styles.system.add("addon-bar", config.styleableChrome, literal(/* #status-bar { margin-top: 0 !important; } #addon-bar > statusbar { -moz-box-flex: 1 } #addon-bar > #addonbar-closebutton { visibility: collapse; } #addon-bar > xul|toolbarspring { visibility: collapse; } - ]]></css>); + */)); overlay.overlayWindow(window, { append: [ ["statusbar", { id: "status-bar", ordinal: "0" }]] }); - highlight.loadCSS(util.compileMacro(<![CDATA[ + highlight.loadCSS(util.compileMacro(literal(/* !AddonBar;#addon-bar { - /* The Add-on Bar */ padding-left: 0 !important; min-height: 18px !important; -moz-appearance: none !important; <padding> } !AddonButton;#addon-bar xul|toolbarbutton { - /* An Add-on Bar button */ -moz-appearance: none !important; padding: 0 !important; border-width: 0px !important; @@ -44,13 +42,12 @@ var StatusLine = Module("statusline", { color: inherit !important; } AddonButton:not(:hover) background: transparent; - ]]>)({ padding: config.OS.isMacOSX ? "padding-right: 10px !important;" : "" })); + */))({ padding: config.OS.isMacOSX ? "padding-right: 10px !important;" : "" })); if (document.getElementById("appmenu-button")) - highlight.loadCSS(<![CDATA[ - AppmenuButton /* The app-menu button */ \ - min-width: 0 !important; padding: 0 .5em !important; - ]]>); + highlight.loadCSS(literal(/* + AppmenuButton min-width: 0 !important; padding: 0 .5em !important; + */)); } XML.ignoreWhitespace = true; diff --git a/common/content/tabs.js b/common/content/tabs.js index fb03dce4..e6fc862a 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -35,9 +35,9 @@ var Tabs = Module("tabs", { tabs.switchTo(event.originalTarget.getAttribute("identifier")); }; - this.tabBinding = styles.system.add("tab-binding", "chrome://browser/content/browser.xul", String.replace(<><![CDATA[ + this.tabBinding = styles.system.add("tab-binding", "chrome://browser/content/browser.xul", String.replace(literal(/* xul|tab { -moz-binding: url(chrome://dactyl/content/bindings.xml#tab) !important; } - ]]></>, /tab-./g, function (m) config.OS.isMacOSX ? "tab-mac" : m), + */), /tab-./g, function (m) config.OS.isMacOSX ? "tab-mac" : m), false, true); this.timeout(function () { diff --git a/common/modules/base.jsm b/common/modules/base.jsm index 203c1558..0c25917b 100644 --- a/common/modules/base.jsm +++ b/common/modules/base.jsm @@ -144,17 +144,40 @@ defineModule("base", { "Set", "Struct", "StructBase", "Timer", "UTF8", "XPCOM", "XPCOMShim", "XPCOMUtils", "XPCSafeJSObjectWrapper", "array", "bind", "call", "callable", "ctypes", "curry", "debuggerProperties", "defineModule", "deprecated", "endModule", "forEach", "isArray", - "isGenerator", "isinstance", "isObject", "isString", "isSubclass", "isXML", "iter", "iterAll", - "iterOwnProperties", "keys", "memoize", "octal", "properties", "require", "set", "update", - "values" + "isGenerator", "isinstance", "isObject", "isString", "isSubclass", "isXML", "iter", + "iterAll", "iterOwnProperties", "keys", "literal", "memoize", "octal", "properties", + "require", "set", "update", "values" ] }); +this.lazyRequire("cache", ["cache"]); this.lazyRequire("config", ["config"]); this.lazyRequire("messages", ["_", "Messages"]); this.lazyRequire("services", ["services"]); this.lazyRequire("util", ["FailedAssertion", "util"]); +function literal(/* comment */) { + let { caller } = Components.stack; + let file = caller.filename.replace(/.* -> /, ""); + let key = "literal:" + file + ":" + caller.line; + + let source = util.httpGet(file).responseText; + + let match = RegExp("(?:.*\\n){" + (caller.lineNumber - 1) + "}" + + ".*literal\\(/\\*([^]*?)\\*/\\)").exec(source); + return match[1]; + + // Later... + return cache.get(key, function () { + let source = cache.get("literal:" + file, + function () util.httpGet(file).responseText); + + let match = RegExp("(?:.*\\n){" + (caller.lineNumber - 1) + "}" + + ".*literal\\(/\\*([^]*?)\\*/\\)").exec(source); + return match[1]; + }); +} + /** * Returns a list of all of the top-level properties of an object, by * way of the debugger. diff --git a/common/modules/cache.jsm b/common/modules/cache.jsm index f48d22e3..719611d5 100644 --- a/common/modules/cache.jsm +++ b/common/modules/cache.jsm @@ -118,7 +118,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), { } }, - closeWriter: function closeWriter() { + closeWriter: util.wrapCallback(function closeWriter() { this.closeReader(); if (this._cacheWriter) { @@ -129,7 +129,7 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), { if (this.cacheFile.fileSize <= 22) this.cacheFile.remove(false); } - }, + }), flush: function flush() { cache.cache = {}; @@ -202,8 +202,12 @@ var Cache = Module("Cache", XPCOM(Ci.nsIRequestObserver), { return cache.force(name); }, - get: function get(name) { + get: function get(name, callback, self) { if (!Set.has(this.cache, name)) { + if (callback && !(Set.has(this.providers, name) || + Set.has(this.localProviders, name))) + this.register(name, callback, self); + this.cache[name] = this.force(name); util.assert(this.cache[name] !== undefined, "No such cache key", false); diff --git a/common/modules/commands.jsm b/common/modules/commands.jsm index 417d09b8..8fdd4b43 100644 --- a/common/modules/commands.jsm +++ b/common/modules/commands.jsm @@ -488,7 +488,7 @@ var CommandHive = Class("CommandHive", Contexts.Hive, { let { cache } = this.modules; this.cached = true; - cache.register(this.cacheKey, function () { + let cached = cache.get(this.cacheKey, function () { self.cached = false; this.modules.moduleManager.initDependencies("commands"); @@ -1225,14 +1225,14 @@ var Commands = Module("commands", { } }, - nameRegexp: util.regexp(<![CDATA[ + nameRegexp: util.regexp(literal(/* [^ 0-9 <forbid> ] [^ <forbid> ]* - ]]>, "gx", { - forbid: util.regexp(String.replace(<![CDATA[ + */), "gx", { + forbid: util.regexp(String.replace(literal(/* U0000-U002c // U002d - U002e-U002f U003a-U0040 // U0041-U005a a-z @@ -1255,12 +1255,12 @@ var Commands = Module("commands", { Ufe70-Ufeff // Arabic Presentation Forms-B Uff00-Uffef // Halfwidth and Fullwidth Forms Ufff0-Uffff // Specials - ]]>, /U/g, "\\u"), "x") + */), /U/g, "\\u"), "x") }), validName: Class.Memoize(function validName() util.regexp("^" + this.nameRegexp.source + "$")), - commandRegexp: Class.Memoize(function commandRegexp() util.regexp(<![CDATA[ + commandRegexp: Class.Memoize(function commandRegexp() util.regexp(literal(/* ^ (?P<spec> (?P<prespace> [:\s]*) @@ -1275,7 +1275,7 @@ var Commands = Module("commands", { (?:. | \n)*? )? $ - ]]>, "x", { + */), "x", { name: this.nameRegexp })), diff --git a/common/modules/config.jsm b/common/modules/config.jsm index 981ad662..60850acb 100644 --- a/common/modules/config.jsm +++ b/common/modules/config.jsm @@ -155,7 +155,7 @@ var ConfigBase = Class("ConfigBase", { highlight.loadCSS(this.helpCSS.replace(/__MSG_(.*?)__/g, function (m0, m1) _(m1))); if (!this.haveGecko("2b")) - highlight.loadCSS(<![CDATA[ + highlight.loadCSS(literal(/* !TabNumber font-weight: bold; margin: 0px; padding-right: .8ex; !TabIconNumber { font-weight: bold; @@ -163,7 +163,7 @@ var ConfigBase = Class("ConfigBase", { text-align: center; text-shadow: black -1px 0 1px, black 0 1px 1px, black 1px 0 1px, black 0 -1px 1px; } - ]]>); + */)); let hl = highlight.set("Find", ""); hl.onChange = function () { diff --git a/common/modules/help.jsm b/common/modules/help.jsm index cf9d3cea..1564d161 100644 --- a/common/modules/help.jsm +++ b/common/modules/help.jsm @@ -108,7 +108,7 @@ var Help = Module("Help", { { mimeType: "text/plain;charset=UTF-8" }) .responseText; - let re = util.regexp(UTF8(<![CDATA[ + let re = util.regexp(UTF8(literal(/* ^ (?P<comment> \s* # .*\n) | ^ (?P<space> \s*) @@ -124,7 +124,7 @@ var Help = Module("Help", { ) | (?: ^ [^\S\n]* \n) + - ]]>), "gmxy"); + */)), "gmxy"); let betas = util.regexp(/\[((?:b|rc)\d)\]/, "gx"); diff --git a/common/modules/highlight.jsm b/common/modules/highlight.jsm index 77f00642..3c5e4999 100644 --- a/common/modules/highlight.jsm +++ b/common/modules/highlight.jsm @@ -2,7 +2,7 @@ // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; defineModule("highlight", { exports: ["Highlight", "Highlights", "highlight"], @@ -224,14 +224,14 @@ var Highlights = Module("Highlight", { (self.highlight[hl] && self.highlight[hl].class != class_ ? self.highlight[hl].selector : "[dactyl|highlight~=" + hl + "]")), - groupRegexp: util.regexp(<![CDATA[ + groupRegexp: util.regexp(literal(/* ^ (\s* (?:\S|\s\S)+ \s+) \{ ([^}]*) \} \s* $ - ]]>, "gmx"), - sheetRegexp: util.regexp(<![CDATA[ + */), "gmx"), + sheetRegexp: util.regexp(literal(/* ^\s* !? \*? (?P<group> (?:[^;\s]|\s[^;\s])+ ) @@ -240,7 +240,7 @@ var Highlights = Module("Highlight", { (?:; (?P<extends> (?:[^;\s]|\s[^;\s])+ )? )? \s* (?P<css> .*) $ - ]]>, "x"), + */), "x"), /** * Bulk loads new CSS rules, in the format of, @@ -322,7 +322,7 @@ var Highlights = Module("Highlight", { commands.add(["hi[ghlight]"], "Set the style of certain display elements", function (args) { - let style = <![CDATA[ + let style = literal(/* ; display: inline-block !important; position: static !important; @@ -330,7 +330,7 @@ var Highlights = Module("Highlight", { width: 3em !important; min-width: 3em !important; max-width: 3em !important; height: 1em !important; min-height: 1em !important; max-height: 1em !important; overflow: hidden !important; - ]]>; + */); let clear = args[0] == "clear"; if (clear) args.shift(); diff --git a/common/modules/io.jsm b/common/modules/io.jsm index 744c0de4..5095b520 100644 --- a/common/modules/io.jsm +++ b/common/modules/io.jsm @@ -676,13 +676,13 @@ var IO = Module("io", { } rtItems.ftdetect.template = // {{{ -<![CDATA[" Vim filetype detection file +literal(/*" Vim filetype detection file <header> au BufNewFile,BufRead *<name>rc*,*.<fileext> set filetype=<name> -]]>;//}}} +*/);//}}} rtItems.ftplugin.template = // {{{ -<![CDATA[" Vim filetype plugin file +literal(/*" Vim filetype plugin file <header> if exists("b:did_ftplugin") @@ -707,9 +707,9 @@ endif let &cpo = s:cpo_save unlet s:cpo_save -]]>;//}}} +*/);//}}} rtItems.syntax.template = // {{{ -<![CDATA[" Vim syntax file +literal(/*" Vim syntax file <header> if exists("b:current_syntax") @@ -788,7 +788,7 @@ let &cpo = s:cpo_save unlet s:cpo_save " vim: tw=130 et ts=8 sts=4 sw=4: -]]>;//}}} +*/);//}}} const { options } = modules; @@ -1041,7 +1041,7 @@ unlet s:cpo_save }; completion.addUrlCompleter("file", "Local files", function (context, full) { - let match = util.regexp(<![CDATA[ + let match = util.regexp(literal(/* ^ (?P<prefix> (?P<proto> @@ -1052,7 +1052,7 @@ unlet s:cpo_save ) (?P<path> \/[^\/]* )? $ - ]]>, "x").exec(context.filter); + */), "x").exec(context.filter); if (match) { if (!match.path) { context.key = match.proto; diff --git a/common/modules/prefs.jsm b/common/modules/prefs.jsm index 0caa8047..6467de59 100644 --- a/common/modules/prefs.jsm +++ b/common/modules/prefs.jsm @@ -4,7 +4,7 @@ // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; try { @@ -14,7 +14,7 @@ defineModule("prefs", { }); lazyRequire("messages", ["_"]); -lazyRequire("template", ["template"]); +lazyRequire("template", ["template", "template_"]); var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), { ORIGINAL: "extensions.dactyl.original.", @@ -404,7 +404,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]) let option = { isDefault: !userValue, default: this.defaults.get(pref, null), - value: <>={template.highlight(value, true, 100)}</>, + value: ["", "=", template.highlight(value, true, 100)], name: pref, pre: "\u00a0\u00a0" // Unicode nonbreaking space. }; @@ -413,7 +413,7 @@ var Prefs = Module("prefs", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]) } }; - return template.options(_("pref.hostPreferences", config.host), prefs.call(this)); + return template_.options(_("pref.hostPreferences", config.host), prefs.call(this)); }, }, { }, { diff --git a/common/modules/protocol.jsm b/common/modules/protocol.jsm index ab99a8d9..cc261f4f 100644 --- a/common/modules/protocol.jsm +++ b/common/modules/protocol.jsm @@ -186,7 +186,7 @@ function XMLChannel(uri, contentType, noErrorChannel, unprivileged) { let type = this.channel.contentType; if (/^text\/|[\/+]xml$/.test(type)) { let stream = services.InputStream(channelStream); - let [, pre, doctype, url, extra, open, post] = util.regexp(<![CDATA[ + let [, pre, doctype, url, extra, open, post] = util.regexp(literal(/* ^ ([^]*?) (?: (<!DOCTYPE \s+ \S+ \s+) (?:SYSTEM \s+ "([^"]*)" | ((?:[^[>\s]|\s[^[])*)) @@ -194,7 +194,7 @@ function XMLChannel(uri, contentType, noErrorChannel, unprivileged) { ([^]*) )? $ - ]]>, "x").exec(stream.read(4096)); + */), "x").exec(stream.read(4096)); this.writes.push(pre); if (doctype) { this.writes.push(doctype + (extra || "") + " [\n"); diff --git a/common/modules/services.jsm b/common/modules/services.jsm index 926f728e..6f7e3c47 100644 --- a/common/modules/services.jsm +++ b/common/modules/services.jsm @@ -2,7 +2,7 @@ // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; try { diff --git a/common/modules/storage.jsm b/common/modules/storage.jsm index 6a324edd..2b20ada7 100644 --- a/common/modules/storage.jsm +++ b/common/modules/storage.jsm @@ -2,7 +2,7 @@ // // This work is licensed for reuse under an MIT license. Details are // given in the LICENSE.txt file included with this file. -/* use strict */ +"use strict"; defineModule("storage", { exports: ["File", "Storage", "storage"], diff --git a/common/modules/styles.jsm b/common/modules/styles.jsm index 4cd87eb8..741e729e 100644 --- a/common/modules/styles.jsm +++ b/common/modules/styles.jsm @@ -461,7 +461,7 @@ var Styles = Module("Styles", { } }, - propertyPattern: util.regexp(<![CDATA[ + propertyPattern: util.regexp(literal(/* (?: (?P<preSpace> <space>*) (?P<name> [-a-z]*) @@ -483,14 +483,14 @@ var Styles = Module("Styles", { )? ) (?P<postSpace> <space>* (?: ; | $) ) - ]]>, "gix", + */), "gix", { space: /(?: \s | \/\* .*? \*\/ )/, string: /(?:" (?:[^\\"]|\\.)* (?:"|$) | '(?:[^\\']|\\.)* (?:'|$) )/ }), patterns: memoize({ - get property() util.regexp(<![CDATA[ + get property() util.regexp(literal(/* (?: (?P<preSpace> <space>*) (?P<name> [-a-z]*) @@ -501,26 +501,26 @@ var Styles = Module("Styles", { )? ) (?P<postSpace> <space>* (?: ; | $) ) - ]]>, "gix", this), + */), "gix", this), - get function() util.regexp(<![CDATA[ + get function() util.regexp(literal(/* (?P<function> \s* \( \s* (?: <string> | [^)]* ) \s* (?: \) | $) ) - ]]>, "gx", this), + */), "gx", this), space: /(?: \s | \/\* .*? \*\/ )/, - get string() util.regexp(<![CDATA[ + get string() util.regexp(literal(/* (?P<string> " (?:[^\\"]|\\.)* (?:"|$) | ' (?:[^\\']|\\.)* (?:'|$) ) - ]]>, "gx", this), + */), "gx", this), - get token() util.regexp(<![CDATA[ + get token() util.regexp(literal(/* (?P<token> (?P<word> [-\w]+) <function>? @@ -530,7 +530,7 @@ var Styles = Module("Styles", { | <space>+ | [^;}\s]+ ) - ]]>, "gix", this) + */), "gix", this) }), /** diff --git a/common/modules/template.jsm b/common/modules/template.jsm index 0b3917fc..e2045438 100644 --- a/common/modules/template.jsm +++ b/common/modules/template.jsm @@ -202,17 +202,15 @@ var Template = Module("Template", { var desc = this.processor[1].call(this, item, item.description); } - XML.ignoreWhitespace = XML.prettyPrinting = false; - // <e4x> - return <div highlight={highlightGroup || "CompItem"} style="white-space: nowrap"> - <!-- The non-breaking spaces prevent empty elements - - from pushing the baseline down and enlarging - - the row. - --> - <li highlight={"CompResult " + item.highlight}>{text} </li> - <li highlight="CompDesc">{desc} </li> - </div>; - // </e4x> + return ["div", { highlight: highlightGroup || "CompItem", style: "white-space: nowrap" }, + /* The non-breaking spaces prevent empty elements + * from pushing the baseline down and enlarging + * the row. + */ + ["li", { highlight: "CompResult " + item.highlight }, + text, "\u00a0"], + ["li", { highlight: "CompDesc" }, + desc, "\u00a0"]]; }, helpLink: function (token, text, type) { @@ -257,11 +255,11 @@ var Template = Module("Template", { return <{tag} xmlns={NS}>{topic}</{tag}>; }, linkifyHelp: function linkifyHelp(str, help) { - let re = util.regexp(<![CDATA[ + let re = util.regexp(literal(/* (?P<pre> [/\s]|^) (?P<tag> '[\w-]+' | :(?:[\w-]+!?|!) | (?:._)?<[\w-]+>\w* | \b[a-zA-Z]_(?:[\w[\]]+|.) | \[[\w-;]+\] | E\d{3} ) (?= [[\)!,:;./\s]|$) - ]]>, "gx"); + */), "gx"); return this.highlightSubstrings(str, (function () { for (let res in re.iterate(str)) yield [res.index + res.pre.length, res.tag.length]; @@ -623,6 +621,23 @@ var Template_ = Module("Template_", { return s; }, + options: function options(title, opts, verbose) { + return ["table", {}, + ["tr", { highlight: "Title", align: "left" }, + ["th", {}, "--- " + title + " ---"]], + this.map(opts, function (opt) + ["tr", {}, + ["td", {}, + ["div", { highlight: "Message" }, + ["span", { style: opt.isDefault ? "" : "font-weight: bold" }, + opt.pre, opt.name], + ["span", {}, opt.value], + opt.isDefault || opt.default == null ? "" : ["span", { class: "extra-info" }, " (default: ", opt.default, ")"]], + verbose && opt.setFrom ? ["div", { highlight: "Message" }, + " Last set from ", + template.sourceLink(opt.setFrom)] : ""]])]; + }, + table: function table(title, data, indent) { let table = ["table", {}, ["tr", { highlight: "Title", align: "left" }, diff --git a/common/modules/util.jsm b/common/modules/util.jsm index 5981ac02..285bdd66 100644 --- a/common/modules/util.jsm +++ b/common/modules/util.jsm @@ -341,14 +341,14 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), let defaults = { lt: "<", gt: ">" }; - let re = util.regexp(<![CDATA[ + let re = util.regexp(literal(/* ([^]*?) // 1 (?: (<\{) | // 2 (< ((?:[a-z]-)?[a-z-]+?) (?:\[([0-9]+)\])? >) | // 3 4 5 (\}>) // 6 ) - ]]>, "gixy"); + */), "gixy"); macro = String(macro); let end = 0; for (let match in re.iterate(macro)) { @@ -864,7 +864,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), }, // ripped from Firefox; modified - unsafeURI: Class.Memoize(function () util.regexp(String.replace(<![CDATA[ + unsafeURI: Class.Memoize(function () util.regexp(String.replace(literal(/* [ \s // Invisible characters (bug 452979) @@ -878,7 +878,7 @@ var Util = Module("Util", XPCOM([Ci.nsIObserver, Ci.nsISupportsWeakReference]), // Bidi formatting characters. (RFC 3987 sections 3.2 and 4.1 paragraph 6) U200E U200F U202A U202B U202C U202D U202E ] - ]]>, /U/g, "\\u"), + */), /U/g, "\\u"), "gx")), losslessDecodeURI: function losslessDecodeURI(url) { return url.split("%25").map(function (url) { |