1
0
mirror of https://github.com/gryf/pentadactyl-pm.git synced 2025-12-20 09:48:00 +01:00

Cc/Ci/Cr/Cu

This commit is contained in:
Kris Maglione
2008-12-16 19:06:26 -05:00
parent 59ab76cead
commit 18d4f74b6e
13 changed files with 110 additions and 151 deletions

View File

@@ -576,8 +576,8 @@ function Buffer() //{{{
try try
{ {
var contentDisposition = window.content var contentDisposition = window.content
.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIDOMWindowUtils) .getInterface(Ci.nsIDOMWindowUtils)
.getDocumentMetadata("content-disposition"); .getDocumentMetadata("content-disposition");
} catch (e) {} } catch (e) {}
@@ -690,7 +690,7 @@ function Buffer() //{{{
try try
{ {
window.urlSecurityCheck(data.href, principal, window.urlSecurityCheck(data.href, principal,
Components.interfaces.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL); Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL);
} }
catch (e) catch (e)
{ {
@@ -735,9 +735,8 @@ function Buffer() //{{{
let doc = window.content.document; let doc = window.content.document;
// get file size // get file size
const ACCESS_READ = Components.interfaces.nsICache.ACCESS_READ; const ACCESS_READ = Ci.nsICache.ACCESS_READ;
const cacheService = Components.classes["@mozilla.org/network/cache-service;1"] const cacheService = Cc["@mozilla.org/network/cache-service;1"].getService(Ci.nsICacheService);
.getService(Components.interfaces.nsICacheService);
let cacheKey = doc.location.toString().replace(/#.*$/, ""); let cacheKey = doc.location.toString().replace(/#.*$/, "");
for (let proto in util.Array.iterator(["HTTP", "FTP"])) for (let proto in util.Array.iterator(["HTTP", "FTP"]))
@@ -1067,9 +1066,9 @@ function Buffer() //{{{
}, },
get selectionController() getBrowser().docShell get selectionController() getBrowser().docShell
.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsISelectionDisplay) .getInterface(Ci.nsISelectionDisplay)
.QueryInterface(Components.interfaces.nsISelectionController), .QueryInterface(Ci.nsISelectionController),
saveLink: function (elem, skipPrompt) saveLink: function (elem, skipPrompt)
{ {

View File

@@ -439,7 +439,7 @@ CompletionContext.prototype = {
try // Firefox <3.1 doesn't have repaintSelection try // Firefox <3.1 doesn't have repaintSelection
{ {
this.selectionTypes[type] = null; this.selectionTypes[type] = null;
const selType = Components.interfaces.nsISelectionController["SELECTION_" + type]; const selType = Ci.nsISelectionController["SELECTION_" + type];
const editor = this.editor; const editor = this.editor;
let sel = editor.selectionController.getSelection(selType); let sel = editor.selectionController.getSelection(selType);
if (length == 0) if (length == 0)
@@ -528,8 +528,7 @@ function Completion() //{{{
try try
{ {
var completionService = Components.classes["@mozilla.org/browser/global-history;2"] var completionService = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIAutoCompleteSearch);
.getService(Components.interfaces.nsIAutoCompleteSearch);
} }
catch (e) {} catch (e) {}
@@ -537,8 +536,7 @@ function Completion() //{{{
function Javascript() function Javascript()
{ {
let json = Components.classes["@mozilla.org/dom/json;1"] let json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
.createInstance(Components.interfaces.nsIJSON);
const OFFSET = 0, CHAR = 1, STATEMENTS = 2, DOTS = 3, FULL_STATEMENTS = 4, COMMA = 5, FUNCTIONS = 6; const OFFSET = 0, CHAR = 1, STATEMENTS = 2, DOTS = 3, FULL_STATEMENTS = 4, COMMA = 5, FUNCTIONS = 6;
let stack = []; let stack = [];
let functions = []; let functions = [];
@@ -1501,8 +1499,7 @@ function Completion() //{{{
preference: function preference(context) preference: function preference(context)
{ {
let prefs = Components.classes["@mozilla.org/preferences-service;1"] let prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
.getService(Components.interfaces.nsIPrefBranch);
context.anchored = false; context.anchored = false;
context.title = ["Firefox Preference", "Value"]; context.title = ["Firefox Preference", "Value"];
context.keys = { text: function (item) item, description: function (item) options.getPref(item) }; context.keys = { text: function (item) item, description: function (item) options.getPref(item) };
@@ -1553,8 +1550,7 @@ function Completion() //{{{
if (!context.filter) if (!context.filter)
return; return;
let ss = Components.classes["@mozilla.org/browser/search-service;1"] let ss = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService);
.getService(Components.interfaces.nsIBrowserSearchService);
let engineList = (engineAliases || options["suggestengines"] || "google").split(","); let engineList = (engineAliases || options["suggestengines"] || "google").split(",");
let completions = []; let completions = [];
@@ -1582,8 +1578,7 @@ function Completion() //{{{
context.title = ["Shell Command", "Path"]; context.title = ["Shell Command", "Path"];
context.generate = function () context.generate = function ()
{ {
const environmentService = Components.classes["@mozilla.org/process/environment;1"] const environmentService = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
.getService(Components.interfaces.nsIEnvironment);
let dirNames = environmentService.get("PATH").split(RegExp(liberator.has("Win32") ? ";" : ":")); let dirNames = environmentService.get("PATH").split(RegExp(liberator.has("Win32") ? ";" : ":"));
let commands = []; let commands = [];

View File

@@ -874,7 +874,7 @@ function Editor() //{{{
//document.getElementById("content-frame").contentDocument.designMode = "on"; //document.getElementById("content-frame").contentDocument.designMode = "on";
let editor = GetCurrentEditor(); let editor = GetCurrentEditor();
let wholeDocRange = editor.document.createRange(); let wholeDocRange = editor.document.createRange();
let rootNode = editor.rootElement.QueryInterface(Components.interfaces.nsIDOMNode); let rootNode = editor.rootElement.QueryInterface(Ci.nsIDOMNode);
wholeDocRange.selectNodeContents(rootNode); wholeDocRange.selectNodeContents(rootNode);
editor.selection.addRange(wholeDocRange); editor.selection.addRange(wholeDocRange);
editor.selection.deleteFromDocument(); editor.selection.deleteFromDocument();

View File

@@ -1534,21 +1534,21 @@ function Events() //{{{
// TODO: move to buffer.js? // TODO: move to buffer.js?
progressListener: { progressListener: {
QueryInterface: XPCOMUtils.generateQI([ QueryInterface: XPCOMUtils.generateQI([
Components.interfaces.nsIWebProgressListener, Ci.nsIWebProgressListener,
Components.interfaces.nsIXULBrowserWindow Ci.nsIXULBrowserWindow
]), ]),
// XXX: function may later be needed to detect a canceled synchronous openURL() // XXX: function may later be needed to detect a canceled synchronous openURL()
onStateChange: function (webProgress, request, flags, status) onStateChange: function (webProgress, request, flags, status)
{ {
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; const nsIWebProgressListener = Ci.nsIWebProgressListener;
// STATE_IS_DOCUMENT | STATE_IS_WINDOW is important, because we also // STATE_IS_DOCUMENT | STATE_IS_WINDOW is important, because we also
// receive statechange events for loading images and other parts of the web page // receive statechange events for loading images and other parts of the web page
if (flags & (nsIWebProgressListener.STATE_IS_DOCUMENT | nsIWebProgressListener.STATE_IS_WINDOW)) if (flags & (nsIWebProgressListener.STATE_IS_DOCUMENT | nsIWebProgressListener.STATE_IS_WINDOW))
{ {
// This fires when the load event is initiated // This fires when the load event is initiated
// only thrown for the current tab, not when another tab changes // only thrown for the current tab, not when another tab changes
if (flags & Components.interfaces.nsIWebProgressListener.STATE_START) if (flags & Ci.nsIWebProgressListener.STATE_START)
{ {
buffer.loaded = 0; buffer.loaded = 0;
statusline.updateProgress(0); statusline.updateProgress(0);
@@ -1563,7 +1563,7 @@ function Events() //{{{
liberator.mode == modes.HINTS ? 500 : 0); liberator.mode == modes.HINTS ? 500 : 0);
} }
} }
else if (flags & Components.interfaces.nsIWebProgressListener.STATE_STOP) else if (flags & Ci.nsIWebProgressListener.STATE_STOP)
{ {
buffer.loaded = (status == 0 ? 1 : 2); buffer.loaded = (status == 0 ? 1 : 2);
statusline.updateUrl(); statusline.updateUrl();
@@ -1573,7 +1573,7 @@ function Events() //{{{
// for notifying the user about secure web pages // for notifying the user about secure web pages
onSecurityChange: function (webProgress, aRequest, aState) onSecurityChange: function (webProgress, aRequest, aState)
{ {
const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; const nsIWebProgressListener = Ci.nsIWebProgressListener;
if (aState & nsIWebProgressListener.STATE_IS_INSECURE) if (aState & nsIWebProgressListener.STATE_IS_INSECURE)
statusline.setClass("insecure"); statusline.setClass("insecure");
else if (aState & nsIWebProgressListener.STATE_IS_BROKEN) else if (aState & nsIWebProgressListener.STATE_IS_BROKEN)
@@ -1638,10 +1638,9 @@ function Events() //{{{
prefObserver: { prefObserver: {
register: function () register: function ()
{ {
const prefService = Components.classes["@mozilla.org/preferences-service;1"] const prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
.getService(Components.interfaces.nsIPrefService);
this._branch = prefService.getBranch(""); // better way to monitor all changes? this._branch = prefService.getBranch(""); // better way to monitor all changes?
this._branch.QueryInterface(Components.interfaces.nsIPrefBranch2); this._branch.QueryInterface(Ci.nsIPrefBranch2);
this._branch.addObserver("", this, false); this._branch.addObserver("", this, false);
}, },
@@ -1670,15 +1669,15 @@ function Events() //{{{
}; //}}} }; //}}}
window.XULBrowserWindow = eventManager.progressListener; window.XULBrowserWindow = eventManager.progressListener;
window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation) .getInterface(Ci.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner .QueryInterface(Ci.nsIDocShellTreeItem).treeOwner
.QueryInterface(Components.interfaces.nsIInterfaceRequestor) .QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIXULWindow) .getInterface(Ci.nsIXULWindow)
.XULBrowserWindow = window.XULBrowserWindow; .XULBrowserWindow = window.XULBrowserWindow;
try try
{ {
getBrowser().addProgressListener(eventManager.progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL); getBrowser().addProgressListener(eventManager.progressListener, Ci.nsIWebProgress.NOTIFY_ALL);
} }
catch (e) {} catch (e) {}

View File

@@ -133,9 +133,9 @@ function Search() //{{{
var highlightObj = { var highlightObj = {
search: function (aWord, matchCase) search: function (aWord, matchCase)
{ {
var finder = Components.classes["@mozilla.org/embedcomp/rangefind;1"] var finder = Cc["@mozilla.org/embedcomp/rangefind;1"]
.createInstance() .createInstance()
.QueryInterface(Components.interfaces.nsIFind); .QueryInterface(Ci.nsIFind);
if (matchCase !== undefined) if (matchCase !== undefined)
finder.caseSensitive = matchCase; finder.caseSensitive = matchCase;
@@ -342,7 +342,7 @@ function Search() //{{{
processUserPattern(str); processUserPattern(str);
fastFind.caseSensitive = caseSensitive; fastFind.caseSensitive = caseSensitive;
found = fastFind.find(searchString, linksOnly) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND; found = fastFind.find(searchString, linksOnly) != Ci.nsITypeAheadFind.FIND_NOTFOUND;
if (!found) if (!found)
setTimeout(function () liberator.echoerr("E486: Pattern not found: " + searchPattern, commandline.FORCE_SINGLELINE), 0); setTimeout(function () liberator.echoerr("E486: Pattern not found: " + searchPattern, commandline.FORCE_SINGLELINE), 0);
@@ -362,11 +362,11 @@ function Search() //{{{
let up = reverse ? !lastSearchBackwards : lastSearchBackwards; let up = reverse ? !lastSearchBackwards : lastSearchBackwards;
let result = getBrowser().fastFind.findAgain(up, linksOnly); let result = getBrowser().fastFind.findAgain(up, linksOnly);
if (result == Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND) if (result == Ci.nsITypeAheadFind.FIND_NOTFOUND)
{ {
liberator.echoerr("E486: Pattern not found: " + lastSearchPattern, commandline.FORCE_SINGLELINE); liberator.echoerr("E486: Pattern not found: " + lastSearchPattern, commandline.FORCE_SINGLELINE);
} }
else if (result == Components.interfaces.nsITypeAheadFind.FIND_WRAPPED) else if (result == Ci.nsITypeAheadFind.FIND_WRAPPED)
{ {
// hack needed, because wrapping causes a "scroll" event which clears // hack needed, because wrapping causes a "scroll" event which clears
// our command line // our command line

View File

@@ -61,16 +61,12 @@ function IO() //{{{
const WINDOWS = liberator.has("Win32"); const WINDOWS = liberator.has("Win32");
const EXTENSION_NAME = config.name.toLowerCase(); // "vimperator" or "muttator" const EXTENSION_NAME = config.name.toLowerCase(); // "vimperator" or "muttator"
const ioService = Components.classes['@mozilla.org/network/io-service;1'] const ioService = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService);
.getService(Components.interfaces.nsIIOService); const environmentService = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
const environmentService = Components.classes["@mozilla.org/process/environment;1"] const directoryService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties);
.getService(Components.interfaces.nsIEnvironment); const downloadManager = Cc["@mozilla.org/download-manager;1"].createInstance(Ci.nsIDownloadManager);
const directoryService = Components.classes["@mozilla.org/file/directory_service;1"]
.getService(Components.interfaces.nsIProperties);
const downloadManager = Components.classes["@mozilla.org/download-manager;1"]
.createInstance(Components.interfaces.nsIDownloadManager);
var processDir = directoryService.get("CurWorkD", Components.interfaces.nsIFile); var processDir = directoryService.get("CurWorkD", Ci.nsIFile);
var cwd = processDir; var cwd = processDir;
var oldcwd = null; var oldcwd = null;
@@ -135,8 +131,7 @@ function IO() //{{{
{ {
try try
{ {
Components.classes["@mozilla.org/file/local;1"] Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile)
.createInstance(Components.interfaces.nsILocalFile)
.initWithPath(path); .initWithPath(path);
return true; return true;
} }
@@ -524,13 +519,11 @@ function IO() //{{{
// also expands relative paths // also expands relative paths
getFile: function (path, noCheckPWD) getFile: function (path, noCheckPWD)
{ {
let file = Components.classes["@mozilla.org/file/local;1"] let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
.createInstance(Components.interfaces.nsILocalFile);
if (/file:\/\//.test(path)) if (/file:\/\//.test(path))
{ {
file = Components.classes["@mozilla.org/network/protocol;1?name=file"] file = Cc["@mozilla.org/network/protocol;1?name=file"].createInstance(Ci.nsIFileProtocolHandler)
.createInstance(Components.interfaces.nsIFileProtocolHandler)
.getFileFromURLSpec(path); .getFileFromURLSpec(path);
} }
else else
@@ -567,9 +560,9 @@ function IO() //{{{
break; break;
} }
let file = directoryService.get("TmpD", Components.interfaces.nsIFile); let file = directoryService.get("TmpD", Ci.nsIFile);
file.append(tmpName); file.append(tmpName);
file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600); file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600);
if (file.exists()) if (file.exists())
return file; return file;
@@ -583,8 +576,8 @@ function IO() //{{{
{ {
if (typeof file == "string") if (typeof file == "string")
file = ioManager.getFile(file); file = ioManager.getFile(file);
else if (!(file instanceof Components.interfaces.nsILocalFile)) else if (!(file instanceof Ci.nsILocalFile))
throw Components.results.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
if (file.isDirectory()) if (file.isDirectory())
{ {
@@ -593,7 +586,7 @@ function IO() //{{{
while (entries.hasMoreElements()) while (entries.hasMoreElements())
{ {
let entry = entries.getNext(); let entry = entries.getNext();
entry.QueryInterface(Components.interfaces.nsIFile); entry.QueryInterface(Ci.nsIFile);
array.push(entry); array.push(entry);
} }
if (sort) if (sort)
@@ -608,19 +601,17 @@ function IO() //{{{
// reads a file in "text" mode and returns the string // reads a file in "text" mode and returns the string
readFile: function (file) readFile: function (file)
{ {
let ifstream = Components.classes["@mozilla.org/network/file-input-stream;1"] let ifstream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream);
.createInstance(Components.interfaces.nsIFileInputStream); let icstream = Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream);
let icstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"]
.createInstance(Components.interfaces.nsIConverterInputStream);
let charset = "UTF-8"; let charset = "UTF-8";
if (typeof file == "string") if (typeof file == "string")
file = ioManager.getFile(file); file = ioManager.getFile(file);
else if (!(file instanceof Components.interfaces.nsILocalFile)) else if (!(file instanceof Ci.nsILocalFile))
throw Components.results.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
ifstream.init(file, -1, 0, 0); ifstream.init(file, -1, 0, 0);
const replacementChar = Components.interfaces.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER; const replacementChar = Ci.nsIConverterInputStream.DEFAULT_REPLACEMENT_CHARACTER;
icstream.init(ifstream, charset, 4096, replacementChar); // 4096 bytes buffering icstream.init(ifstream, charset, 4096, replacementChar); // 4096 bytes buffering
let buffer = ""; let buffer = "";
@@ -639,16 +630,14 @@ function IO() //{{{
// mode can be ">" or ">>" in addition to the normal MODE_* flags // mode can be ">" or ">>" in addition to the normal MODE_* flags
writeFile: function (file, buf, mode, perms) writeFile: function (file, buf, mode, perms)
{ {
let ofstream = Components.classes["@mozilla.org/network/file-output-stream;1"] let ofstream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream);
.createInstance(Components.interfaces.nsIFileOutputStream); let ocstream = Cc["@mozilla.org/intl/converter-output-stream;1"].createInstance(Ci.nsIConverterOutputStream);
let ocstream = Components.classes["@mozilla.org/intl/converter-output-stream;1"]
.createInstance(Components.interfaces.nsIConverterOutputStream);
let charset = "UTF-8"; // Can be any character encoding name that Mozilla supports let charset = "UTF-8"; // Can be any character encoding name that Mozilla supports
if (typeof file == "string") if (typeof file == "string")
file = ioManager.getFile(file); file = ioManager.getFile(file);
else if (!(file instanceof Components.interfaces.nsILocalFile)) else if (!(file instanceof Ci.nsILocalFile))
throw Components.results.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined
if (mode == ">>") if (mode == ">>")
mode = ioManager.MODE_WRONLY | ioManager.MODE_CREATE | ioManager.MODE_APPEND; mode = ioManager.MODE_WRONLY | ioManager.MODE_CREATE | ioManager.MODE_APPEND;
@@ -716,8 +705,7 @@ lookup:
return -1; return -1;
} }
let process = Components.classes["@mozilla.org/process/util;1"] let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
.createInstance(Components.interfaces.nsIProcess);
process.init(file); process.init(file);
process.run(blocking, args, args.length); process.run(blocking, args, args.length);

View File

@@ -5,8 +5,7 @@
modules.modules = modules; modules.modules = modules;
const loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] const loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
.getService(Components.interfaces.mozIJSSubScriptLoader);
function load(script) function load(script)
{ {
for (let [i, base] in Iterator(prefix)) for (let [i, base] in Iterator(prefix))
@@ -20,14 +19,14 @@
{ {
if (i + 1 < prefix.length) if (i + 1 < prefix.length)
continue; continue;
if (Components.utils.reportError) if (Cu.reportError)
Components.utils.reportError(e); Cu.reportError(e);
dump("liberator: Loading script " + script + ": " + e + "\n"); dump("liberator: Loading script " + script + ": " + e + "\n");
} }
} }
} }
Components.utils.import("resource://liberator/storage.jsm", modules); Cu.import("resource://liberator/storage.jsm", modules);
let prefix = [BASE]; let prefix = [BASE];

View File

@@ -26,7 +26,12 @@ the provisions above, a recipient may use your version of this file under
the terms of any one of the MPL, the GPL or the LGPL. the terms of any one of the MPL, the GPL or the LGPL.
}}} ***** END LICENSE BLOCK *****/ }}} ***** END LICENSE BLOCK *****/
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm"); const Cc = Components.classes;
const Ci = Components.interfaces;
const Cr = Components.results;
const Cu = Components.utils;
Cu.import("resource://gre/modules/XPCOMUtils.jsm");
const plugins = {}; const plugins = {};
plugins.__proto__ = modules; plugins.__proto__ = modules;
@@ -44,8 +49,7 @@ const liberator = (function () //{{{
////////////////////// PRIVATE SECTION ///////////////////////////////////////// ////////////////////// PRIVATE SECTION /////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////{{{ /////////////////////////////////////////////////////////////////////////////{{{
const threadManager = Components.classes["@mozilla.org/thread-manager;1"] const threadManager = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager);
.getService(Components.interfaces.nsIThreadManager);
function Runnable(self, func, args) function Runnable(self, func, args)
{ {
this.self = self; this.self = self;
@@ -53,7 +57,7 @@ const liberator = (function () //{{{
this.args = args; this.args = args;
} }
Runnable.prototype = { Runnable.prototype = {
QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIRunnable]), QueryInterface: XPCOMUtils.generateQI([Ci.nsIRunnable]),
run: function () { this.func.apply(this.self, this.args); } run: function () { this.func.apply(this.self, this.args); }
}; };
@@ -668,8 +672,7 @@ const liberator = (function () //{{{
} }
else else
{ {
let soundService = Components.classes["@mozilla.org/sound;1"] let soundService = Cc["@mozilla.org/sound;1"].getService(Ci.nsISound);
.getService(Components.interfaces.nsISound);
soundService.beep(); soundService.beep();
} }
return false; // so you can do: if (...) return liberator.beep(); return false; // so you can do: if (...) return liberator.beep();
@@ -748,8 +751,7 @@ const liberator = (function () //{{{
loadScript: function (uri, context) loadScript: function (uri, context)
{ {
let loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
.getService(Components.interfaces.mozIJSSubScriptLoader);
loader.loadSubScript(uri, context); loader.loadSubScript(uri, context);
}, },
@@ -876,8 +878,7 @@ const liberator = (function () //{{{
// if clearFocusedElement, also blur a focused link // if clearFocusedElement, also blur a focused link
focusContent: function (clearFocusedElement) focusContent: function (clearFocusedElement)
{ {
let ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci.nsIWindowWatcher);
.getService(Components.interfaces.nsIWindowWatcher);
if (window != ww.activeWindow) if (window != ww.activeWindow)
return; return;
@@ -911,9 +912,8 @@ const liberator = (function () //{{{
hasExtension: function (name) hasExtension: function (name)
{ {
let manager = Components.classes["@mozilla.org/extensions/manager;1"] let manager = Cc["@mozilla.org/extensions/manager;1"].getService(Ci.nsIExtensionManager);
.getService(Components.interfaces.nsIExtensionManager); let extensions = manager.getItemList(Ci.nsIUpdateItem.TYPE_EXTENSION, {});
let extensions = manager.getItemList(Components.interfaces.nsIUpdateItem.TYPE_EXTENSION, {});
return extensions.some(function (e) e.name == name); return extensions.some(function (e) e.name == name);
}, },
@@ -1037,8 +1037,7 @@ const liberator = (function () //{{{
if (typeof msg == "object") if (typeof msg == "object")
msg = util.objectToString(msg, false); msg = util.objectToString(msg, false);
var consoleService = Components.classes["@mozilla.org/consoleservice;1"] var consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
.getService(Components.interfaces.nsIConsoleService);
consoleService.logStringMessage(config.name.toLowerCase() + ": " + msg); consoleService.logStringMessage(config.name.toLowerCase() + ": " + msg);
}, },
@@ -1096,8 +1095,7 @@ const liberator = (function () //{{{
break; break;
case liberator.NEW_WINDOW: case liberator.NEW_WINDOW:
const wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] const wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
.getService(Components.interfaces.nsIWindowMediator);
window.open(); window.open();
whichwindow = wm.getMostRecentWindow("navigator:browser"); whichwindow = wm.getMostRecentWindow("navigator:browser");
whichwindow.loadURI(url, null, postdata); whichwindow.loadURI(url, null, postdata);
@@ -1142,9 +1140,9 @@ const liberator = (function () //{{{
else else
options.setPref("browser.startup.page", 1); // start with default homepage session options.setPref("browser.startup.page", 1); // start with default homepage session
const nsIAppStartup = Components.interfaces.nsIAppStartup; const nsIAppStartup = Ci.nsIAppStartup;
if (force) if (force)
Components.classes["@mozilla.org/toolkit/app-startup;1"] Cc["@mozilla.org/toolkit/app-startup;1"]
.getService(nsIAppStartup) .getService(nsIAppStartup)
.quit(nsIAppStartup.eForceQuit); .quit(nsIAppStartup.eForceQuit);
else else
@@ -1153,8 +1151,8 @@ const liberator = (function () //{{{
reportError: function (error) reportError: function (error)
{ {
if (Components.utils.reportError) if (Cu.reportError)
Components.utils.reportError(error); Cu.reportError(error);
try try
{ {
let obj = { let obj = {
@@ -1174,13 +1172,11 @@ const liberator = (function () //{{{
restart: function () restart: function ()
{ {
const nsIAppStartup = Components.interfaces.nsIAppStartup; const nsIAppStartup = Ci.nsIAppStartup;
// notify all windows that an application quit has been requested. // notify all windows that an application quit has been requested.
var os = Components.classes["@mozilla.org/observer-service;1"] var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService);
.getService(Components.interfaces.nsIObserverService); var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool);
var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"]
.createInstance(Components.interfaces.nsISupportsPRBool);
os.notifyObservers(cancelQuit, "quit-application-requested", null); os.notifyObservers(cancelQuit, "quit-application-requested", null);
// something aborted the quit process. // something aborted the quit process.
@@ -1191,8 +1187,7 @@ const liberator = (function () //{{{
os.notifyObservers(null, "quit-application-granted", null); os.notifyObservers(null, "quit-application-granted", null);
// enumerate all windows and call shutdown handlers // enumerate all windows and call shutdown handlers
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
.getService(Components.interfaces.nsIWindowMediator);
var windows = wm.getEnumerator(null); var windows = wm.getEnumerator(null);
while (windows.hasMoreElements()) while (windows.hasMoreElements())
{ {
@@ -1200,7 +1195,7 @@ const liberator = (function () //{{{
if (("tryToClose" in win) && !win.tryToClose()) if (("tryToClose" in win) && !win.tryToClose())
return; return;
} }
Components.classes["@mozilla.org/toolkit/app-startup;1"] Cc["@mozilla.org/toolkit/app-startup;1"]
.getService(nsIAppStartup) .getService(nsIAppStartup)
.quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit); .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit);
}, },
@@ -1377,8 +1372,7 @@ const liberator = (function () //{{{
get windows() get windows()
{ {
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
.getService(Components.interfaces.nsIWindowMediator);
var wa = []; var wa = [];
var enumerator = wm.getEnumerator("navigator:browser"); var enumerator = wm.getEnumerator("navigator:browser");
while (enumerator.hasMoreElements()) while (enumerator.hasMoreElements())

View File

@@ -301,8 +301,7 @@ function Options() //{{{
const SAVED = "liberator.saved."; const SAVED = "liberator.saved.";
const prefService = Components.classes["@mozilla.org/preferences-service;1"] const prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch);
.getService(Components.interfaces.nsIPrefBranch);
var optionHash = {}; var optionHash = {};
function optionObserver(key, event, option) function optionObserver(key, event, option)
@@ -364,11 +363,11 @@ function Options() //{{{
switch (type) switch (type)
{ {
case prefService.PREF_STRING: case prefService.PREF_STRING:
let value = branch.getComplexValue(name, Components.interfaces.nsISupportsString).data; let value = branch.getComplexValue(name, Ci.nsISupportsString).data;
// try in case it's a localized string (will throw an exception if not) // try in case it's a localized string (will throw an exception if not)
if (!prefService.prefIsLocked(name) && !prefService.prefHasUserValue(name) && if (!prefService.prefIsLocked(name) && !prefService.prefHasUserValue(name) &&
/^chrome:\/\/.+\/locale\/.+\.properties/.test(value)) /^chrome:\/\/.+\/locale\/.+\.properties/.test(value))
value = branch.getComplexValue(name, Components.interfaces.nsIPrefLocalizedString).data; value = branch.getComplexValue(name, Ci.nsIPrefLocalizedString).data;
return value; return value;
case prefService.PREF_INT: case prefService.PREF_INT:
return branch.getIntPref(name); return branch.getIntPref(name);
@@ -778,8 +777,7 @@ function Options() //{{{
{ {
completion.setFunctionCompleter(options.get, [function () ([o.name, o.description] for (o in options))]); completion.setFunctionCompleter(options.get, [function () ([o.name, o.description] for (o in options))]);
completion.setFunctionCompleter([options.getPref, options.safeSetPref, options.setPref, options.resetPref, options.invertPref], completion.setFunctionCompleter([options.getPref, options.safeSetPref, options.setPref, options.resetPref, options.invertPref],
[function () Components.classes["@mozilla.org/preferences-service;1"] [function () Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch)
.getService(Components.interfaces.nsIPrefBranch)
.getChildList("", { value: 0 }) .getChildList("", { value: 0 })
.map(function (pref) [pref, ""])]); .map(function (pref) [pref, ""])]);
}); });

View File

@@ -212,12 +212,9 @@ function Styles(name, store, serial)
const util = modules.util; const util = modules.util;
const sleep = liberator.sleep; const sleep = liberator.sleep;
const storage = modules.storage; const storage = modules.storage;
const consoleService = Components.classes["@mozilla.org/consoleservice;1"] const consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);
.getService(Components.interfaces.nsIConsoleService); const ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService);
const ios = Components.classes["@mozilla.org/network/io-service;1"] const sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService);
.getService(Components.interfaces.nsIIOService);
const sss = Components.classes["@mozilla.org/content/style-sheet-service;1"]
.getService(Components.interfaces.nsIStyleSheetService);
const namespace = '@namespace html "' + XHTML + '";\n' + const namespace = '@namespace html "' + XHTML + '";\n' +
'@namespace xul "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";\n' + '@namespace xul "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";\n' +
'@namespace liberator "' + NS.uri + '";\n'; '@namespace liberator "' + NS.uri + '";\n';
@@ -377,7 +374,7 @@ function Styles(name, store, serial)
return namespace + "@-moz-document " + selectors + "{\n" + css + "\n}\n"; return namespace + "@-moz-document " + selectors + "{\n" + css + "\n}\n";
} }
let queryinterface = XPCOMUtils.generateQI([Components.interfaces.nsIConsoleListener]); let queryinterface = XPCOMUtils.generateQI([Ci.nsIConsoleListener]);
/* What happens if more than one thread tries to use this? */ /* What happens if more than one thread tries to use this? */
let testDoc = document.implementation.createDocument(XHTML, "doc", null); let testDoc = document.implementation.createDocument(XHTML, "doc", null);
function checkSyntax(uri) function checkSyntax(uri)
@@ -389,7 +386,7 @@ function Styles(name, store, serial)
{ {
try try
{ {
message = message.QueryInterface(Components.interfaces.nsIScriptError); message = message.QueryInterface(Ci.nsIScriptError);
if (message.sourceName == uri) if (message.sourceName == uri)
errors.push(message); errors.push(message);
} }

View File

@@ -97,8 +97,7 @@ function Tabs() //{{{
function copyTab(to, from) function copyTab(to, from)
{ {
const ss = Components.classes["@mozilla.org/browser/sessionstore;1"] const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
.getService(Components.interfaces.nsISessionStore);
if (!from) if (!from)
from = getBrowser().mTabContainer.selectedItem; from = getBrowser().mTabContainer.selectedItem;
@@ -738,10 +737,8 @@ function Tabs() //{{{
get closedTabs() get closedTabs()
{ {
const json = Components.classes["@mozilla.org/dom/json;1"] const json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON);
.createInstance(Components.interfaces.nsIJSON); const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
const ss = Components.classes["@mozilla.org/browser/sessionstore;1"]
.getService(Components.interfaces.nsISessionStore);
return json.decode(ss.getClosedTabData(window)); return json.decode(ss.getClosedTabData(window));
}, },
@@ -845,7 +842,7 @@ function Tabs() //{{{
{ {
if (bypassCache) if (bypassCache)
{ {
const nsIWebNavigation = Components.interfaces.nsIWebNavigation; const nsIWebNavigation = Ci.nsIWebNavigation;
const flags = nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE; const flags = nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE;
getBrowser().getBrowserForTab(tab).reloadWithFlags(flags); getBrowser().getBrowserForTab(tab).reloadWithFlags(flags);
} }
@@ -970,8 +967,7 @@ function Tabs() //{{{
tab = getBrowser().mTabContainer.selectedItem; tab = getBrowser().mTabContainer.selectedItem;
window.open(); window.open();
const wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] const wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator);
.getService(Components.interfaces.nsIWindowMediator);
let win = wm.getMostRecentWindow("navigator:browser"); let win = wm.getMostRecentWindow("navigator:browser");
copyTab(win.getBrowser().mCurrentTab, tab); copyTab(win.getBrowser().mCurrentTab, tab);

View File

@@ -484,8 +484,8 @@ function CommandLine() //{{{
const messageBox = document.getElementById("liberator-message"); const messageBox = document.getElementById("liberator-message");
commandWidget.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement); commandWidget.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
messageBox.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement); messageBox.inputField.QueryInterface(Ci.nsIDOMNSEditableElement);
// the widget used for multiline output // the widget used for multiline output
const multilineOutputWidget = document.getElementById("liberator-multiline-output"); const multilineOutputWidget = document.getElementById("liberator-multiline-output");
@@ -659,8 +659,7 @@ function CommandLine() //{{{
{ {
completer: function completer(value) completer: function completer(value)
{ {
let ss = Components.classes["@mozilla.org/browser/search-service;1"] let ss = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService);
.getService(Components.interfaces.nsIBrowserSearchService);
let engines = ss.getEngines({}) let engines = ss.getEngines({})
.filter(function (engine) engine.supportsResponseType("application/x-suggestions+json")); .filter(function (engine) engine.supportsResponseType("application/x-suggestions+json"));

View File

@@ -84,8 +84,7 @@ const util = { //{{{
// TODO: class could have better variable names/documentation // TODO: class could have better variable names/documentation
Timer: function Timer(minInterval, maxInterval, callback) Timer: function Timer(minInterval, maxInterval, callback)
{ {
let timer = Components.classes["@mozilla.org/timer;1"] let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer);
.createInstance(Components.interfaces.nsITimer);
this.doneAt = 0; this.doneAt = 0;
this.latest = 0; this.latest = 0;
this.notify = function (aTimer) this.notify = function (aTimer)
@@ -162,8 +161,7 @@ const util = { //{{{
copyToClipboard: function copyToClipboard(str, verbose) copyToClipboard: function copyToClipboard(str, verbose)
{ {
const clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] const clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper);
.getService(Components.interfaces.nsIClipboardHelper);
clipboardHelper.copyString(str); clipboardHelper.copyString(str);
if (verbose) if (verbose)
@@ -172,8 +170,7 @@ const util = { //{{{
createURI: function createURI(str) createURI: function createURI(str)
{ {
const fixup = Components.classes["@mozilla.org/docshell/urifixup;1"] const fixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup);
.getService(Components.interfaces.nsIURIFixup);
return fixup.createFixupURI(str, fixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP); return fixup.createFixupURI(str, fixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP);
}, },
@@ -430,10 +427,8 @@ const util = { //{{{
try try
{ {
const clipboard = Components.classes['@mozilla.org/widget/clipboard;1'] const clipboard = Cc['@mozilla.org/widget/clipboard;1'].getService(Ci.nsIClipboard);
.getService(Components.interfaces.nsIClipboard); const transferable = Cc['@mozilla.org/widget/transferable;1'].createInstance(Ci.nsITransferable);
const transferable = Components.classes['@mozilla.org/widget/transferable;1']
.createInstance(Components.interfaces.nsITransferable);
transferable.addDataFlavor("text/unicode"); transferable.addDataFlavor("text/unicode");
@@ -449,7 +444,7 @@ const util = { //{{{
if (data) if (data)
{ {
data = data.value.QueryInterface(Components.interfaces.nsISupportsString); data = data.value.QueryInterface(Ci.nsISupportsString);
url = data.data.substring(0, dataLen.value / 2); url = data.data.substring(0, dataLen.value / 2);
} }
} }
@@ -479,7 +474,7 @@ const util = { //{{{
// Look for a valid protocol // Look for a valid protocol
let proto = url.match(/^([-\w]+):/); let proto = url.match(/^([-\w]+):/);
if (proto && Components.classes["@mozilla.org/network/protocol;1?name=" + proto[1]]) if (proto && Cc["@mozilla.org/network/protocol;1?name=" + proto[1]])
// Handle as URL, but remove spaces. Useful for copied/'p'asted URLs. // Handle as URL, but remove spaces. Useful for copied/'p'asted URLs.
return url.replace(/\s+/g, ""); return url.replace(/\s+/g, "");