From 8d48b1de5413c06b6b9e0e25f8d0bd0f0d5c7b40 Mon Sep 17 00:00:00 2001 From: Simon Kornblith Date: Thu, 9 Feb 2012 03:56:30 -0500 Subject: [PATCH] Drop a lot of Fx 3.6-specific code --- .../content/zotero/integration/quickFormat.js | 13 +-- chrome/content/zotero/lookup.js | 4 +- .../content/zotero/preferences/preferences.js | 5 -- chrome/content/zotero/tab.js | 4 +- chrome/content/zotero/xpcom/integration.js | 15 ++-- chrome/content/zotero/xpcom/ipc.js | 29 +----- .../content/zotero/xpcom/mimeTypeHandler.js | 22 ++--- chrome/content/zotero/xpcom/schema.js | 9 +- .../zotero/xpcom/translation/translate.js | 2 +- .../xpcom/translation/translate_firefox.js | 90 ++----------------- chrome/content/zotero/xpcom/zotero.js | 39 +++----- translators | 2 +- 12 files changed, 42 insertions(+), 192 deletions(-) diff --git a/chrome/content/zotero/integration/quickFormat.js b/chrome/content/zotero/integration/quickFormat.js index d25bd2c22b..24208b7fa7 100644 --- a/chrome/content/zotero/integration/quickFormat.js +++ b/chrome/content/zotero/integration/quickFormat.js @@ -130,7 +130,7 @@ var Zotero_QuickFormat = new function () { if(event.target !== document) return; // make sure we are visible window.setTimeout(function() { - if(!Zotero.isFx4) window.sizeToContent(); + window.sizeToContent(); var screenX = window.screenX; var screenY = window.screenY; var xRange = [window.screen.availLeft, window.screen.width-window.outerWidth]; @@ -744,16 +744,7 @@ var Zotero_QuickFormat = new function () { if(((!referenceHeight && firstReference) || (!separatorHeight && firstSeparator) || !panelFrameHeight) && !panelShowing) { _openReferencePanel(); - if(!Zotero.isFx4) { - referencePanel.addEventListener("popupshown", function() { - referencePanel.removeEventListener("popupshown", arguments.callee, false); - panelShowing = true; - _resize(); - }, false); - return; - } else { - panelShowing = true; - } + panelShowing = true; } if(!referenceHeight && firstReference) { diff --git a/chrome/content/zotero/lookup.js b/chrome/content/zotero/lookup.js index 99984dfea0..0767282811 100644 --- a/chrome/content/zotero/lookup.js +++ b/chrome/content/zotero/lookup.js @@ -106,9 +106,7 @@ const Zotero_Lookup = new function () { * Focuses the field */ this.onShowing = function() { - if(!Zotero.isFx4) { - document.getElementById("zotero-lookup-panel").style.padding = "10px"; - } + document.getElementById("zotero-lookup-panel").style.padding = "10px"; document.getElementById("zotero-lookup-progress").hidden = false; var identifierElement = document.getElementById("zotero-lookup-textbox"); diff --git a/chrome/content/zotero/preferences/preferences.js b/chrome/content/zotero/preferences/preferences.js index 91ba393b33..4217e7fec8 100644 --- a/chrome/content/zotero/preferences/preferences.js +++ b/chrome/content/zotero/preferences/preferences.js @@ -119,11 +119,6 @@ function init() } else if(document.location.hash == "#cite") { document.getElementById('zotero-prefs').showPane(document.getElementById("zotero-prefpane-cite")); } - - var showInAppTab; - if(!Zotero.isFx4 && (showInAppTab = document.getElementById("zotero-prefpane-general-showIn-appTab"))) { - showInAppTab.setAttribute("hidden", "true"); - } } diff --git a/chrome/content/zotero/tab.js b/chrome/content/zotero/tab.js index 644698e1ec..7f7e5fba4f 100644 --- a/chrome/content/zotero/tab.js +++ b/chrome/content/zotero/tab.js @@ -83,7 +83,7 @@ var ZoteroTab = new function() this.containerWindow.gBrowser.tabContainer.addEventListener("TabSelect", listener, false); } - if(Zotero && Zotero.isFx4 && Zotero.Prefs.get("showIn") != 2) { + if(Zotero && Zotero.Prefs.get("showIn") != 2) { // on Fx 4, add an event listener so the pinned tab isn't restored on close var pinnedTabCloser = function() { try { @@ -104,7 +104,7 @@ var ZoteroTab = new function() if(tabs.length > 1) { window.close(); } else { - if(Zotero.isFx4 && tabs[0].pinned) this.containerWindow.gBrowser.unpinTab(tabs[0]); + if(tabs[0].pinned) this.containerWindow.gBrowser.unpinTab(tabs[0]); document.location.replace(this.containerWindow.gHomeButton.getHomePage()); } return; diff --git a/chrome/content/zotero/xpcom/integration.js b/chrome/content/zotero/xpcom/integration.js index 50c070ebaa..52a2c58877 100644 --- a/chrome/content/zotero/xpcom/integration.js +++ b/chrome/content/zotero/xpcom/integration.js @@ -193,14 +193,9 @@ Zotero.Integration = new function() { if(callback) callback(_integrationVersionsOK); } - if(Zotero.isFx4) { - Components.utils.import("resource://gre/modules/AddonManager.jsm"); - AddonManager.getAddonsByIDs(INTEGRATION_PLUGINS, _checkAddons); - } else { - var extMan = Components.classes['@mozilla.org/extensions/manager;1']. - getService(Components.interfaces.nsIExtensionManager); - _checkAddons([extMan.getItemForID(id) for each(id in INTEGRATION_PLUGINS)]); - } + var extMan = Components.classes['@mozilla.org/extensions/manager;1']. + getService(Components.interfaces.nsIExtensionManager); + _checkAddons([extMan.getItemForID(id) for each(id in INTEGRATION_PLUGINS)]); } /** @@ -289,7 +284,7 @@ Zotero.Integration = new function() { "Minefield":"org.mozilla.minefield" }; - if(Zotero.isFx4 && win) { + if(win) { Components.utils.import("resource://gre/modules/ctypes.jsm"); if(!_carbon) { @@ -333,7 +328,7 @@ Zotero.Integration = new function() { _executeAppleScript('tell application id "'+BUNDLE_IDS[Zotero.appName]+'" to activate'); } } - } else if(!Zotero.isWin && Zotero.isFx4 && win) { + } else if(!Zotero.isWin && win) { Components.utils.import("resource://gre/modules/ctypes.jsm"); if(_x11 === false) return; diff --git a/chrome/content/zotero/xpcom/ipc.js b/chrome/content/zotero/xpcom/ipc.js index d69241eff2..6e9be6274c 100755 --- a/chrome/content/zotero/xpcom/ipc.js +++ b/chrome/content/zotero/xpcom/ipc.js @@ -107,23 +107,11 @@ Zotero.IPC = new function() { if(!lib) return false; // int open(const char *path, int oflag); - if(Zotero.isFx36) { - open = lib.declare("open", ctypes.default_abi, ctypes.int32_t, ctypes.string, ctypes.int32_t); - } else { - open = lib.declare("open", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.int); - } + open = lib.declare("open", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.int); // ssize_t write(int fildes, const void *buf, size_t nbyte); - if(Zotero.isFx36) { - write = lib.declare("write", ctypes.default_abi, ctypes.int32_t, ctypes.int32_t, ctypes.string, ctypes.uint32_t); - } else { - write = lib.declare("write", ctypes.default_abi, ctypes.ssize_t, ctypes.int, ctypes.char.ptr, ctypes.size_t); - } + write = lib.declare("write", ctypes.default_abi, ctypes.ssize_t, ctypes.int, ctypes.char.ptr, ctypes.size_t); // int close(int filedes); - if(Zotero.isFx36) { - close = lib.declare("close", ctypes.default_abi, ctypes.int32_t, ctypes.int32_t); - } else { - close = lib.declare("close", ctypes.default_abi, ctypes.int, ctypes.int); - } + close = lib.declare("close", ctypes.default_abi, ctypes.int, ctypes.int); } // On OS X, O_NONBLOCK = 0x0004 @@ -144,11 +132,6 @@ Zotero.IPC = new function() { */ this.broadcast = function(msg) { if(Zotero.isWin) { // communicate via WM_COPYDATA method - // there is no ctypes struct support in Fx 3.6 - // while we could mimic it, it's easier just to require users to upgrade if they - // want connector sharing - if(!Zotero.isFx4) return false; - Components.utils.import("resource://gre/modules/ctypes.jsm"); // communicate via message window @@ -386,11 +369,7 @@ Zotero.IPC.Pipe = new function() { if(!_mkfifo) { var libc = Zotero.IPC.getLibc(); if(!libc) return false; - if(Zotero.isFx36) { - _mkfifo = libc.declare("mkfifo", ctypes.default_abi, ctypes.int32_t, ctypes.string, ctypes.uint32_t); - } else { - _mkfifo = libc.declare("mkfifo", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.unsigned_int); - } + _mkfifo = libc.declare("mkfifo", ctypes.default_abi, ctypes.int, ctypes.char.ptr, ctypes.unsigned_int); } // make pipe diff --git a/chrome/content/zotero/xpcom/mimeTypeHandler.js b/chrome/content/zotero/xpcom/mimeTypeHandler.js index d5467e6a6d..16e94e7283 100644 --- a/chrome/content/zotero/xpcom/mimeTypeHandler.js +++ b/chrome/content/zotero/xpcom/mimeTypeHandler.js @@ -112,22 +112,14 @@ Zotero.MIMETypeHandler = new function () { var checkValue = {"value":false}; // make tab-modal dialog (https://developer.mozilla.org/en/Using_tab-modal_prompts) - if(Zotero.isFx4) { - var prompt = Components.classes["@mozilla.org/prompter;1"] - .getService(Components.interfaces.nsIPromptFactory) - .getPrompt(win, Components.interfaces.nsIPrompt); - - var bag = prompt.QueryInterface(Components.interfaces.nsIWritablePropertyBag2); - bag.setPropertyAsBool("allowTabModal", true); - - var continueDownload = prompt.confirmCheck(title, text, checkMsg, checkValue); - } else { - var ps = Components.classes["@mozilla.org/embedcomp/prompt-service;1"] - .getService(Components.interfaces.nsIPromptService); - - var continueDownload = ps.confirmCheck(win, title, text, checkMsg, checkValue); - } + var prompt = Components.classes["@mozilla.org/prompter;1"] + .getService(Components.interfaces.nsIPromptFactory) + .getPrompt(win, Components.interfaces.nsIPrompt); + var bag = prompt.QueryInterface(Components.interfaces.nsIWritablePropertyBag2); + bag.setPropertyAsBool("allowTabModal", true); + + var continueDownload = prompt.confirmCheck(title, text, checkMsg, checkValue); if(!continueDownload) return; if(checkValue.value) { // add to allowed sites if desired diff --git a/chrome/content/zotero/xpcom/schema.js b/chrome/content/zotero/xpcom/schema.js index 390bedae65..6996b8bce1 100644 --- a/chrome/content/zotero/xpcom/schema.js +++ b/chrome/content/zotero/xpcom/schema.js @@ -446,7 +446,7 @@ Zotero.Schema = new function(){ .get("AChrom", Components.interfaces.nsIFile); _updateBundledFilesCallback(appChrome.parent, mode, skipDeleteUpdate, runRemoteUpdateWhenComplete); - } else if(Zotero.isFx4) { + } else { Components.utils.import("resource://gre/modules/AddonManager.jsm"); AddonManager.getAddonByID(ZOTERO_CONFIG['GUID'], function(addon) { @@ -454,13 +454,6 @@ Zotero.Schema = new function(){ addon.getResourceURI().QueryInterface(Components.interfaces.nsIFileURL).file, mode, skipDeleteUpdate, runRemoteUpdateWhenComplete); }); - } else { - var gExtensionManager = Components.classes["@mozilla.org/extensions/manager;1"] - .getService(Components.interfaces.nsIExtensionManager); - var itemLocation = gExtensionManager.getInstallLocation(ZOTERO_CONFIG['GUID']) - .getItemLocation(ZOTERO_CONFIG['GUID']); - _updateBundledFilesCallback(itemLocation, mode, skipDeleteUpdate, - runRemoteUpdateWhenComplete); } } diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index deb6e1859a..783c94a510 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -215,7 +215,7 @@ Zotero.Translate.Sandbox = { "getTranslatorObject":"r" }; safeTranslator.setSearch = function(arg) { - if(Zotero.isFx4 && !Zotero.isBookmarklet) arg = JSON.parse(JSON.stringify(arg)); + if(!Zotero.isBookmarklet) arg = JSON.parse(JSON.stringify(arg)); return translation.setSearch(arg); }; safeTranslator.setDocument = function(arg) { return translation.setDocument(arg) }; diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js index 92706600f3..9ee2133894 100644 --- a/chrome/content/zotero/xpcom/translation/translate_firefox.js +++ b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -318,13 +318,9 @@ Zotero.Translate.DOMWrapper = new function() { * @return {Object} An obj that is no longer Xrayed */ this.wrap = function(obj) { - if(Zotero.isFx4) { - Zotero.debug(obj.toString()); - var newObj = wrapPrivileged(obj); - return newObj; - } else { - return _wrapFx36(obj); - } + Zotero.debug(obj.toString()); + var newObj = wrapPrivileged(obj); + return newObj; } /** @@ -348,53 +344,6 @@ Zotero.Translate.DOMWrapper = new function() { this.isWrapped = function(obj) { return "__wrappedDOMObject" in obj || isWrapper(obj); } - - /** - * A really ugly way of making a DOM object not look like a DOM object, so we can pass it to the - * sandbox under Firefox 3.6 - * @param {XPCCrossOriginWrapper} obj - * @param {Object} parent A parent to use as |this| when applying functions - * @return {Object} An obj that is no longer Xrayed - */ - function _wrapFx36(obj, parent) { - if(obj === null) { - return null; - } - - var wrapFx36 = arguments.callee; - var type = typeof obj; - if(type === "function") { - var val = function() { - var nArgs = arguments.length; - var args = new Array(nArgs); - for(var i=0; i= 0; - this.isFx5 = versionComparator.compare(platformVersion, "5.0a1") >= 0; + this.isFx3 = false; + this.isFx35 = false; + this.isFx31 = false; + this.isFx36 = false; + this.isFx4 = true; + this.isFx5 = true; this.isStandalone = appInfo.ID == ZOTERO_CONFIG['GUID']; if(this.isStandalone) { this.version = appInfo.version; - } else if(this.isFx4) { + } else { // Use until we collect version from extension manager this.version = ZOTERO_CONFIG['VERSION']; Components.utils.import("resource://gre/modules/AddonManager.jsm"); AddonManager.getAddonByID(ZOTERO_CONFIG['GUID'], function(addon) { Zotero.version = addon.version; }); - } else { - var gExtensionManager = - Components.classes["@mozilla.org/extensions/manager;1"] - .getService(Components.interfaces.nsIExtensionManager); - this.version - = gExtensionManager.getItemForID(ZOTERO_CONFIG['GUID']).version; } // OS platform @@ -380,11 +374,7 @@ const ZOTERO_CONFIG = { // evaluate Components.utils.evalInSandbox(prefsJs, sandbox); - if(Zotero.isFx4) { - var prefs = sandbox.prefs; - } else { - var prefs = new XPCSafeJSObjectWrapper(sandbox.prefs); - } + var prefs = sandbox.prefs; for(var key in prefs) { if(key.substr(0, ZOTERO_CONFIG.PREF_BRANCH.length) === ZOTERO_CONFIG.PREF_BRANCH && key !== "extensions.zotero.firstRun2") { @@ -1278,17 +1268,8 @@ const ZOTERO_CONFIG = { callback(addons); } - if(this.isFx4) { - Components.utils.import("resource://gre/modules/AddonManager.jsm"); - AddonManager.getAllAddons(onHaveInstalledAddons); - } else { - var em = Components.classes["@mozilla.org/extensions/manager;1"]. - getService(Components.interfaces.nsIExtensionManager); - var installed = em.getItemList( - Components.interfaces.nsIUpdateItem.TYPE_ANY, {} - ); - onHaveInstalledAddons(installed); - } + Components.utils.import("resource://gre/modules/AddonManager.jsm"); + AddonManager.getAllAddons(onHaveInstalledAddons); } diff --git a/translators b/translators index 3daf3bdf2c..c436aebdd0 160000 --- a/translators +++ b/translators @@ -1 +1 @@ -Subproject commit 3daf3bdf2ce13d7e1a329f5648f18937d8251dee +Subproject commit c436aebdd02c4c75fbd0bb79d43d29bd4eb3cf72