diff --git a/common/content/buffer.js b/common/content/buffer.js index 18b9e39c..e6a15cd7 100644 --- a/common/content/buffer.js +++ b/common/content/buffer.js @@ -576,8 +576,8 @@ function Buffer() //{{{ try { var contentDisposition = window.content - .QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIDOMWindowUtils) + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIDOMWindowUtils) .getDocumentMetadata("content-disposition"); } catch (e) {} @@ -690,7 +690,7 @@ function Buffer() //{{{ try { window.urlSecurityCheck(data.href, principal, - Components.interfaces.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL); + Ci.nsIScriptSecurityManager.DISALLOW_INHERIT_PRINCIPAL); } catch (e) { @@ -735,9 +735,8 @@ function Buffer() //{{{ let doc = window.content.document; // get file size - const ACCESS_READ = Components.interfaces.nsICache.ACCESS_READ; - const cacheService = Components.classes["@mozilla.org/network/cache-service;1"] - .getService(Components.interfaces.nsICacheService); + const ACCESS_READ = Ci.nsICache.ACCESS_READ; + const cacheService = Cc["@mozilla.org/network/cache-service;1"].getService(Ci.nsICacheService); let cacheKey = doc.location.toString().replace(/#.*$/, ""); for (let proto in util.Array.iterator(["HTTP", "FTP"])) @@ -1067,9 +1066,9 @@ function Buffer() //{{{ }, get selectionController() getBrowser().docShell - .QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsISelectionDisplay) - .QueryInterface(Components.interfaces.nsISelectionController), + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsISelectionDisplay) + .QueryInterface(Ci.nsISelectionController), saveLink: function (elem, skipPrompt) { diff --git a/common/content/completion.js b/common/content/completion.js index 71b1ea9f..84122b06 100644 --- a/common/content/completion.js +++ b/common/content/completion.js @@ -439,7 +439,7 @@ CompletionContext.prototype = { try // Firefox <3.1 doesn't have repaintSelection { this.selectionTypes[type] = null; - const selType = Components.interfaces.nsISelectionController["SELECTION_" + type]; + const selType = Ci.nsISelectionController["SELECTION_" + type]; const editor = this.editor; let sel = editor.selectionController.getSelection(selType); if (length == 0) @@ -528,8 +528,7 @@ function Completion() //{{{ try { - var completionService = Components.classes["@mozilla.org/browser/global-history;2"] - .getService(Components.interfaces.nsIAutoCompleteSearch); + var completionService = Cc["@mozilla.org/browser/global-history;2"].getService(Ci.nsIAutoCompleteSearch); } catch (e) {} @@ -537,8 +536,7 @@ function Completion() //{{{ function Javascript() { - let json = Components.classes["@mozilla.org/dom/json;1"] - .createInstance(Components.interfaces.nsIJSON); + let json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON); const OFFSET = 0, CHAR = 1, STATEMENTS = 2, DOTS = 3, FULL_STATEMENTS = 4, COMMA = 5, FUNCTIONS = 6; let stack = []; let functions = []; @@ -1501,8 +1499,7 @@ function Completion() //{{{ preference: function preference(context) { - let prefs = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch); + let prefs = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); context.anchored = false; context.title = ["Firefox Preference", "Value"]; context.keys = { text: function (item) item, description: function (item) options.getPref(item) }; @@ -1553,8 +1550,7 @@ function Completion() //{{{ if (!context.filter) return; - let ss = Components.classes["@mozilla.org/browser/search-service;1"] - .getService(Components.interfaces.nsIBrowserSearchService); + let ss = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService); let engineList = (engineAliases || options["suggestengines"] || "google").split(","); let completions = []; @@ -1582,8 +1578,7 @@ function Completion() //{{{ context.title = ["Shell Command", "Path"]; context.generate = function () { - const environmentService = Components.classes["@mozilla.org/process/environment;1"] - .getService(Components.interfaces.nsIEnvironment); + const environmentService = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment); let dirNames = environmentService.get("PATH").split(RegExp(liberator.has("Win32") ? ";" : ":")); let commands = []; diff --git a/common/content/editor.js b/common/content/editor.js index 1252efed..78375171 100644 --- a/common/content/editor.js +++ b/common/content/editor.js @@ -874,7 +874,7 @@ function Editor() //{{{ //document.getElementById("content-frame").contentDocument.designMode = "on"; let editor = GetCurrentEditor(); let wholeDocRange = editor.document.createRange(); - let rootNode = editor.rootElement.QueryInterface(Components.interfaces.nsIDOMNode); + let rootNode = editor.rootElement.QueryInterface(Ci.nsIDOMNode); wholeDocRange.selectNodeContents(rootNode); editor.selection.addRange(wholeDocRange); editor.selection.deleteFromDocument(); diff --git a/common/content/events.js b/common/content/events.js index 06417a2f..0b66593b 100644 --- a/common/content/events.js +++ b/common/content/events.js @@ -1534,21 +1534,21 @@ function Events() //{{{ // TODO: move to buffer.js? progressListener: { QueryInterface: XPCOMUtils.generateQI([ - Components.interfaces.nsIWebProgressListener, - Components.interfaces.nsIXULBrowserWindow + Ci.nsIWebProgressListener, + Ci.nsIXULBrowserWindow ]), // XXX: function may later be needed to detect a canceled synchronous openURL() 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 // receive statechange events for loading images and other parts of the web page if (flags & (nsIWebProgressListener.STATE_IS_DOCUMENT | nsIWebProgressListener.STATE_IS_WINDOW)) { // This fires when the load event is initiated // 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; statusline.updateProgress(0); @@ -1563,7 +1563,7 @@ function Events() //{{{ 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); statusline.updateUrl(); @@ -1573,7 +1573,7 @@ function Events() //{{{ // for notifying the user about secure web pages onSecurityChange: function (webProgress, aRequest, aState) { - const nsIWebProgressListener = Components.interfaces.nsIWebProgressListener; + const nsIWebProgressListener = Ci.nsIWebProgressListener; if (aState & nsIWebProgressListener.STATE_IS_INSECURE) statusline.setClass("insecure"); else if (aState & nsIWebProgressListener.STATE_IS_BROKEN) @@ -1638,10 +1638,9 @@ function Events() //{{{ prefObserver: { register: function () { - const prefService = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefService); + const prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService); 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); }, @@ -1670,15 +1669,15 @@ function Events() //{{{ }; //}}} window.XULBrowserWindow = eventManager.progressListener; - window.QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIWebNavigation) - .QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner - .QueryInterface(Components.interfaces.nsIInterfaceRequestor) - .getInterface(Components.interfaces.nsIXULWindow) + window.QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIWebNavigation) + .QueryInterface(Ci.nsIDocShellTreeItem).treeOwner + .QueryInterface(Ci.nsIInterfaceRequestor) + .getInterface(Ci.nsIXULWindow) .XULBrowserWindow = window.XULBrowserWindow; try { - getBrowser().addProgressListener(eventManager.progressListener, Components.interfaces.nsIWebProgress.NOTIFY_ALL); + getBrowser().addProgressListener(eventManager.progressListener, Ci.nsIWebProgress.NOTIFY_ALL); } catch (e) {} diff --git a/common/content/find.js b/common/content/find.js index 02468f5f..b7f9869c 100644 --- a/common/content/find.js +++ b/common/content/find.js @@ -133,9 +133,9 @@ function Search() //{{{ var highlightObj = { search: function (aWord, matchCase) { - var finder = Components.classes["@mozilla.org/embedcomp/rangefind;1"] + var finder = Cc["@mozilla.org/embedcomp/rangefind;1"] .createInstance() - .QueryInterface(Components.interfaces.nsIFind); + .QueryInterface(Ci.nsIFind); if (matchCase !== undefined) finder.caseSensitive = matchCase; @@ -342,7 +342,7 @@ function Search() //{{{ processUserPattern(str); fastFind.caseSensitive = caseSensitive; - found = fastFind.find(searchString, linksOnly) != Components.interfaces.nsITypeAheadFind.FIND_NOTFOUND; + found = fastFind.find(searchString, linksOnly) != Ci.nsITypeAheadFind.FIND_NOTFOUND; if (!found) 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 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); } - 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 // our command line diff --git a/common/content/io.js b/common/content/io.js index adc8f46e..d6bf284a 100644 --- a/common/content/io.js +++ b/common/content/io.js @@ -61,16 +61,12 @@ function IO() //{{{ const WINDOWS = liberator.has("Win32"); const EXTENSION_NAME = config.name.toLowerCase(); // "vimperator" or "muttator" - const ioService = Components.classes['@mozilla.org/network/io-service;1'] - .getService(Components.interfaces.nsIIOService); - const environmentService = Components.classes["@mozilla.org/process/environment;1"] - .getService(Components.interfaces.nsIEnvironment); - 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); + const ioService = Cc['@mozilla.org/network/io-service;1'].getService(Ci.nsIIOService); + const environmentService = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment); + const directoryService = Cc["@mozilla.org/file/directory_service;1"].getService(Ci.nsIProperties); + const downloadManager = Cc["@mozilla.org/download-manager;1"].createInstance(Ci.nsIDownloadManager); - var processDir = directoryService.get("CurWorkD", Components.interfaces.nsIFile); + var processDir = directoryService.get("CurWorkD", Ci.nsIFile); var cwd = processDir; var oldcwd = null; @@ -135,8 +131,7 @@ function IO() //{{{ { try { - Components.classes["@mozilla.org/file/local;1"] - .createInstance(Components.interfaces.nsILocalFile) + Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile) .initWithPath(path); return true; } @@ -524,13 +519,11 @@ function IO() //{{{ // also expands relative paths getFile: function (path, noCheckPWD) { - let file = Components.classes["@mozilla.org/file/local;1"] - .createInstance(Components.interfaces.nsILocalFile); + let file = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); if (/file:\/\//.test(path)) { - file = Components.classes["@mozilla.org/network/protocol;1?name=file"] - .createInstance(Components.interfaces.nsIFileProtocolHandler) + file = Cc["@mozilla.org/network/protocol;1?name=file"].createInstance(Ci.nsIFileProtocolHandler) .getFileFromURLSpec(path); } else @@ -567,9 +560,9 @@ function IO() //{{{ break; } - let file = directoryService.get("TmpD", Components.interfaces.nsIFile); + let file = directoryService.get("TmpD", Ci.nsIFile); file.append(tmpName); - file.createUnique(Components.interfaces.nsIFile.NORMAL_FILE_TYPE, 0600); + file.createUnique(Ci.nsIFile.NORMAL_FILE_TYPE, 0600); if (file.exists()) return file; @@ -583,8 +576,8 @@ function IO() //{{{ { if (typeof file == "string") file = ioManager.getFile(file); - else if (!(file instanceof Components.interfaces.nsILocalFile)) - throw Components.results.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined + else if (!(file instanceof Ci.nsILocalFile)) + throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined if (file.isDirectory()) { @@ -593,7 +586,7 @@ function IO() //{{{ while (entries.hasMoreElements()) { let entry = entries.getNext(); - entry.QueryInterface(Components.interfaces.nsIFile); + entry.QueryInterface(Ci.nsIFile); array.push(entry); } if (sort) @@ -608,19 +601,17 @@ function IO() //{{{ // reads a file in "text" mode and returns the string readFile: function (file) { - let ifstream = Components.classes["@mozilla.org/network/file-input-stream;1"] - .createInstance(Components.interfaces.nsIFileInputStream); - let icstream = Components.classes["@mozilla.org/intl/converter-input-stream;1"] - .createInstance(Components.interfaces.nsIConverterInputStream); + let ifstream = Cc["@mozilla.org/network/file-input-stream;1"].createInstance(Ci.nsIFileInputStream); + let icstream = Cc["@mozilla.org/intl/converter-input-stream;1"].createInstance(Ci.nsIConverterInputStream); let charset = "UTF-8"; if (typeof file == "string") file = ioManager.getFile(file); - else if (!(file instanceof Components.interfaces.nsILocalFile)) - throw Components.results.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined + else if (!(file instanceof Ci.nsILocalFile)) + throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined 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 let buffer = ""; @@ -639,16 +630,14 @@ function IO() //{{{ // mode can be ">" or ">>" in addition to the normal MODE_* flags writeFile: function (file, buf, mode, perms) { - let ofstream = Components.classes["@mozilla.org/network/file-output-stream;1"] - .createInstance(Components.interfaces.nsIFileOutputStream); - let ocstream = Components.classes["@mozilla.org/intl/converter-output-stream;1"] - .createInstance(Components.interfaces.nsIConverterOutputStream); + let ofstream = Cc["@mozilla.org/network/file-output-stream;1"].createInstance(Ci.nsIFileOutputStream); + let ocstream = Cc["@mozilla.org/intl/converter-output-stream;1"].createInstance(Ci.nsIConverterOutputStream); let charset = "UTF-8"; // Can be any character encoding name that Mozilla supports if (typeof file == "string") file = ioManager.getFile(file); - else if (!(file instanceof Components.interfaces.nsILocalFile)) - throw Components.results.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined + else if (!(file instanceof Ci.nsILocalFile)) + throw Cr.NS_ERROR_INVALID_ARG; // FIXME: does not work as expected, just shows undefined: undefined if (mode == ">>") mode = ioManager.MODE_WRONLY | ioManager.MODE_CREATE | ioManager.MODE_APPEND; @@ -716,8 +705,7 @@ lookup: return -1; } - let process = Components.classes["@mozilla.org/process/util;1"] - .createInstance(Components.interfaces.nsIProcess); + let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess); process.init(file); process.run(blocking, args, args.length); diff --git a/common/content/liberator-overlay.js b/common/content/liberator-overlay.js index 5175b75b..a2ec2d73 100644 --- a/common/content/liberator-overlay.js +++ b/common/content/liberator-overlay.js @@ -5,8 +5,7 @@ modules.modules = modules; - const loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Components.interfaces.mozIJSSubScriptLoader); + const loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader); function load(script) { for (let [i, base] in Iterator(prefix)) @@ -20,14 +19,14 @@ { if (i + 1 < prefix.length) continue; - if (Components.utils.reportError) - Components.utils.reportError(e); + if (Cu.reportError) + Cu.reportError(e); 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]; diff --git a/common/content/liberator.js b/common/content/liberator.js index 1975bd17..0d88cfc8 100644 --- a/common/content/liberator.js +++ b/common/content/liberator.js @@ -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. }}} ***** 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 = {}; plugins.__proto__ = modules; @@ -44,8 +49,7 @@ const liberator = (function () //{{{ ////////////////////// PRIVATE SECTION ///////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////{{{ - const threadManager = Components.classes["@mozilla.org/thread-manager;1"] - .getService(Components.interfaces.nsIThreadManager); + const threadManager = Cc["@mozilla.org/thread-manager;1"].getService(Ci.nsIThreadManager); function Runnable(self, func, args) { this.self = self; @@ -53,7 +57,7 @@ const liberator = (function () //{{{ this.args = args; } Runnable.prototype = { - QueryInterface: XPCOMUtils.generateQI([Components.interfaces.nsIRunnable]), + QueryInterface: XPCOMUtils.generateQI([Ci.nsIRunnable]), run: function () { this.func.apply(this.self, this.args); } }; @@ -668,8 +672,7 @@ const liberator = (function () //{{{ } else { - let soundService = Components.classes["@mozilla.org/sound;1"] - .getService(Components.interfaces.nsISound); + let soundService = Cc["@mozilla.org/sound;1"].getService(Ci.nsISound); soundService.beep(); } return false; // so you can do: if (...) return liberator.beep(); @@ -748,8 +751,7 @@ const liberator = (function () //{{{ loadScript: function (uri, context) { - let loader = Components.classes["@mozilla.org/moz/jssubscript-loader;1"] - .getService(Components.interfaces.mozIJSSubScriptLoader); + let loader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader); loader.loadSubScript(uri, context); }, @@ -876,8 +878,7 @@ const liberator = (function () //{{{ // if clearFocusedElement, also blur a focused link focusContent: function (clearFocusedElement) { - let ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"] - .getService(Components.interfaces.nsIWindowWatcher); + let ww = Cc["@mozilla.org/embedcomp/window-watcher;1"].getService(Ci.nsIWindowWatcher); if (window != ww.activeWindow) return; @@ -911,9 +912,8 @@ const liberator = (function () //{{{ hasExtension: function (name) { - let manager = Components.classes["@mozilla.org/extensions/manager;1"] - .getService(Components.interfaces.nsIExtensionManager); - let extensions = manager.getItemList(Components.interfaces.nsIUpdateItem.TYPE_EXTENSION, {}); + let manager = Cc["@mozilla.org/extensions/manager;1"].getService(Ci.nsIExtensionManager); + let extensions = manager.getItemList(Ci.nsIUpdateItem.TYPE_EXTENSION, {}); return extensions.some(function (e) e.name == name); }, @@ -1037,8 +1037,7 @@ const liberator = (function () //{{{ if (typeof msg == "object") msg = util.objectToString(msg, false); - var consoleService = Components.classes["@mozilla.org/consoleservice;1"] - .getService(Components.interfaces.nsIConsoleService); + var consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService); consoleService.logStringMessage(config.name.toLowerCase() + ": " + msg); }, @@ -1096,8 +1095,7 @@ const liberator = (function () //{{{ break; case liberator.NEW_WINDOW: - const wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); + const wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); window.open(); whichwindow = wm.getMostRecentWindow("navigator:browser"); whichwindow.loadURI(url, null, postdata); @@ -1142,9 +1140,9 @@ const liberator = (function () //{{{ else options.setPref("browser.startup.page", 1); // start with default homepage session - const nsIAppStartup = Components.interfaces.nsIAppStartup; + const nsIAppStartup = Ci.nsIAppStartup; if (force) - Components.classes["@mozilla.org/toolkit/app-startup;1"] + Cc["@mozilla.org/toolkit/app-startup;1"] .getService(nsIAppStartup) .quit(nsIAppStartup.eForceQuit); else @@ -1153,8 +1151,8 @@ const liberator = (function () //{{{ reportError: function (error) { - if (Components.utils.reportError) - Components.utils.reportError(error); + if (Cu.reportError) + Cu.reportError(error); try { let obj = { @@ -1174,13 +1172,11 @@ const liberator = (function () //{{{ restart: function () { - const nsIAppStartup = Components.interfaces.nsIAppStartup; + const nsIAppStartup = Ci.nsIAppStartup; // notify all windows that an application quit has been requested. - var os = Components.classes["@mozilla.org/observer-service;1"] - .getService(Components.interfaces.nsIObserverService); - var cancelQuit = Components.classes["@mozilla.org/supports-PRBool;1"] - .createInstance(Components.interfaces.nsISupportsPRBool); + var os = Cc["@mozilla.org/observer-service;1"].getService(Ci.nsIObserverService); + var cancelQuit = Cc["@mozilla.org/supports-PRBool;1"].createInstance(Ci.nsISupportsPRBool); os.notifyObservers(cancelQuit, "quit-application-requested", null); // something aborted the quit process. @@ -1191,8 +1187,7 @@ const liberator = (function () //{{{ os.notifyObservers(null, "quit-application-granted", null); // enumerate all windows and call shutdown handlers - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); + var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); var windows = wm.getEnumerator(null); while (windows.hasMoreElements()) { @@ -1200,7 +1195,7 @@ const liberator = (function () //{{{ if (("tryToClose" in win) && !win.tryToClose()) return; } - Components.classes["@mozilla.org/toolkit/app-startup;1"] + Cc["@mozilla.org/toolkit/app-startup;1"] .getService(nsIAppStartup) .quit(nsIAppStartup.eRestart | nsIAppStartup.eAttemptQuit); }, @@ -1377,8 +1372,7 @@ const liberator = (function () //{{{ get windows() { - var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); + var wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); var wa = []; var enumerator = wm.getEnumerator("navigator:browser"); while (enumerator.hasMoreElements()) diff --git a/common/content/options.js b/common/content/options.js index 353bf5bf..34828e18 100644 --- a/common/content/options.js +++ b/common/content/options.js @@ -301,8 +301,7 @@ function Options() //{{{ const SAVED = "liberator.saved."; - const prefService = Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch); + const prefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch); var optionHash = {}; function optionObserver(key, event, option) @@ -364,11 +363,11 @@ function Options() //{{{ switch (type) { 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) if (!prefService.prefIsLocked(name) && !prefService.prefHasUserValue(name) && /^chrome:\/\/.+\/locale\/.+\.properties/.test(value)) - value = branch.getComplexValue(name, Components.interfaces.nsIPrefLocalizedString).data; + value = branch.getComplexValue(name, Ci.nsIPrefLocalizedString).data; return value; case prefService.PREF_INT: 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.getPref, options.safeSetPref, options.setPref, options.resetPref, options.invertPref], - [function () Components.classes["@mozilla.org/preferences-service;1"] - .getService(Components.interfaces.nsIPrefBranch) + [function () Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefBranch) .getChildList("", { value: 0 }) .map(function (pref) [pref, ""])]); }); diff --git a/common/content/style.js b/common/content/style.js index a662cd48..ea4b5533 100644 --- a/common/content/style.js +++ b/common/content/style.js @@ -212,12 +212,9 @@ function Styles(name, store, serial) const util = modules.util; const sleep = liberator.sleep; const storage = modules.storage; - const consoleService = Components.classes["@mozilla.org/consoleservice;1"] - .getService(Components.interfaces.nsIConsoleService); - const ios = Components.classes["@mozilla.org/network/io-service;1"] - .getService(Components.interfaces.nsIIOService); - const sss = Components.classes["@mozilla.org/content/style-sheet-service;1"] - .getService(Components.interfaces.nsIStyleSheetService); + const consoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService); + const ios = Cc["@mozilla.org/network/io-service;1"].getService(Ci.nsIIOService); + const sss = Cc["@mozilla.org/content/style-sheet-service;1"].getService(Ci.nsIStyleSheetService); const namespace = '@namespace html "' + XHTML + '";\n' + '@namespace xul "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";\n' + '@namespace liberator "' + NS.uri + '";\n'; @@ -377,7 +374,7 @@ function Styles(name, store, serial) 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? */ let testDoc = document.implementation.createDocument(XHTML, "doc", null); function checkSyntax(uri) @@ -389,7 +386,7 @@ function Styles(name, store, serial) { try { - message = message.QueryInterface(Components.interfaces.nsIScriptError); + message = message.QueryInterface(Ci.nsIScriptError); if (message.sourceName == uri) errors.push(message); } diff --git a/common/content/tabs.js b/common/content/tabs.js index 7bbcd293..4af2ca2b 100644 --- a/common/content/tabs.js +++ b/common/content/tabs.js @@ -97,8 +97,7 @@ function Tabs() //{{{ function copyTab(to, from) { - const ss = Components.classes["@mozilla.org/browser/sessionstore;1"] - .getService(Components.interfaces.nsISessionStore); + const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); if (!from) from = getBrowser().mTabContainer.selectedItem; @@ -738,10 +737,8 @@ function Tabs() //{{{ get closedTabs() { - const json = Components.classes["@mozilla.org/dom/json;1"] - .createInstance(Components.interfaces.nsIJSON); - const ss = Components.classes["@mozilla.org/browser/sessionstore;1"] - .getService(Components.interfaces.nsISessionStore); + const json = Cc["@mozilla.org/dom/json;1"].createInstance(Ci.nsIJSON); + const ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore); return json.decode(ss.getClosedTabData(window)); }, @@ -845,7 +842,7 @@ function Tabs() //{{{ { if (bypassCache) { - const nsIWebNavigation = Components.interfaces.nsIWebNavigation; + const nsIWebNavigation = Ci.nsIWebNavigation; const flags = nsIWebNavigation.LOAD_FLAGS_BYPASS_PROXY | nsIWebNavigation.LOAD_FLAGS_BYPASS_CACHE; getBrowser().getBrowserForTab(tab).reloadWithFlags(flags); } @@ -970,8 +967,7 @@ function Tabs() //{{{ tab = getBrowser().mTabContainer.selectedItem; window.open(); - const wm = Components.classes["@mozilla.org/appshell/window-mediator;1"] - .getService(Components.interfaces.nsIWindowMediator); + const wm = Cc["@mozilla.org/appshell/window-mediator;1"].getService(Ci.nsIWindowMediator); let win = wm.getMostRecentWindow("navigator:browser"); copyTab(win.getBrowser().mCurrentTab, tab); diff --git a/common/content/ui.js b/common/content/ui.js index bfe6263f..374d72c7 100644 --- a/common/content/ui.js +++ b/common/content/ui.js @@ -484,8 +484,8 @@ function CommandLine() //{{{ const messageBox = document.getElementById("liberator-message"); - commandWidget.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement); - messageBox.inputField.QueryInterface(Components.interfaces.nsIDOMNSEditableElement); + commandWidget.inputField.QueryInterface(Ci.nsIDOMNSEditableElement); + messageBox.inputField.QueryInterface(Ci.nsIDOMNSEditableElement); // the widget used for multiline output const multilineOutputWidget = document.getElementById("liberator-multiline-output"); @@ -659,8 +659,7 @@ function CommandLine() //{{{ { completer: function completer(value) { - let ss = Components.classes["@mozilla.org/browser/search-service;1"] - .getService(Components.interfaces.nsIBrowserSearchService); + let ss = Cc["@mozilla.org/browser/search-service;1"].getService(Ci.nsIBrowserSearchService); let engines = ss.getEngines({}) .filter(function (engine) engine.supportsResponseType("application/x-suggestions+json")); diff --git a/common/content/util.js b/common/content/util.js index 24456594..d6499e57 100644 --- a/common/content/util.js +++ b/common/content/util.js @@ -84,8 +84,7 @@ const util = { //{{{ // TODO: class could have better variable names/documentation Timer: function Timer(minInterval, maxInterval, callback) { - let timer = Components.classes["@mozilla.org/timer;1"] - .createInstance(Components.interfaces.nsITimer); + let timer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); this.doneAt = 0; this.latest = 0; this.notify = function (aTimer) @@ -162,8 +161,7 @@ const util = { //{{{ copyToClipboard: function copyToClipboard(str, verbose) { - const clipboardHelper = Components.classes["@mozilla.org/widget/clipboardhelper;1"] - .getService(Components.interfaces.nsIClipboardHelper); + const clipboardHelper = Cc["@mozilla.org/widget/clipboardhelper;1"].getService(Ci.nsIClipboardHelper); clipboardHelper.copyString(str); if (verbose) @@ -172,8 +170,7 @@ const util = { //{{{ createURI: function createURI(str) { - const fixup = Components.classes["@mozilla.org/docshell/urifixup;1"] - .getService(Components.interfaces.nsIURIFixup); + const fixup = Cc["@mozilla.org/docshell/urifixup;1"].getService(Ci.nsIURIFixup); return fixup.createFixupURI(str, fixup.FIXUP_FLAG_ALLOW_KEYWORD_LOOKUP); }, @@ -430,10 +427,8 @@ const util = { //{{{ try { - const clipboard = Components.classes['@mozilla.org/widget/clipboard;1'] - .getService(Components.interfaces.nsIClipboard); - const transferable = Components.classes['@mozilla.org/widget/transferable;1'] - .createInstance(Components.interfaces.nsITransferable); + const clipboard = Cc['@mozilla.org/widget/clipboard;1'].getService(Ci.nsIClipboard); + const transferable = Cc['@mozilla.org/widget/transferable;1'].createInstance(Ci.nsITransferable); transferable.addDataFlavor("text/unicode"); @@ -449,7 +444,7 @@ const util = { //{{{ if (data) { - data = data.value.QueryInterface(Components.interfaces.nsISupportsString); + data = data.value.QueryInterface(Ci.nsISupportsString); url = data.data.substring(0, dataLen.value / 2); } } @@ -479,7 +474,7 @@ const util = { //{{{ // Look for a valid protocol 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. return url.replace(/\s+/g, "");