From 6f6ce33377d1c8f8323ee6088159f34ab761c421 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Sat, 8 Oct 2016 19:15:49 -0400 Subject: [PATCH] Remove obsolete code for old Firefox versions --- chrome/content/zotero/bindings/itembox.xml | 3 - chrome/content/zotero/bindings/tagsbox.xml | 3 - chrome/content/zotero/browser.js | 15 +-- chrome/content/zotero/charsetMenu.js | 73 +++-------- chrome/content/zotero/xpcom/openurl.js | 2 +- .../zotero/xpcom/translation/translate.js | 2 +- .../xpcom/translation/translate_firefox.js | 122 ++++++++---------- chrome/content/zotero/xpcom/utilities.js | 2 +- chrome/content/zotero/xpcom/zotero.js | 9 -- components/zotero-service.js | 10 +- 10 files changed, 82 insertions(+), 159 deletions(-) diff --git a/chrome/content/zotero/bindings/itembox.xml b/chrome/content/zotero/bindings/itembox.xml index 66ad49263..cd89c7fa2 100644 --- a/chrome/content/zotero/bindings/itembox.xml +++ b/chrome/content/zotero/bindings/itembox.xml @@ -1071,9 +1071,6 @@ diff --git a/chrome/content/zotero/bindings/tagsbox.xml b/chrome/content/zotero/bindings/tagsbox.xml index f94520355..f474e6958 100644 --- a/chrome/content/zotero/bindings/tagsbox.xml +++ b/chrome/content/zotero/bindings/tagsbox.xml @@ -1019,9 +1019,6 @@ diff --git a/chrome/content/zotero/browser.js b/chrome/content/zotero/browser.js index d449e5bd9..600086d19 100644 --- a/chrome/content/zotero/browser.js +++ b/chrome/content/zotero/browser.js @@ -268,18 +268,9 @@ var Zotero_Browser = new function() { function(e) { Zotero_Browser.resize(e) }, false); // Resize on text zoom changes - // Fx2 - var reduce = document.getElementById('cmd_textZoomReduce'); - if (reduce) { - var enlarge = document.getElementById('cmd_textZoomEnlarge'); - var reset = document.getElementById('cmd_textZoomReset'); - } - // Fx3 - else { - var reduce = document.getElementById('cmd_fullZoomReduce'); - var enlarge = document.getElementById('cmd_fullZoomEnlarge'); - var reset = document.getElementById('cmd_fullZoomReset'); - } + var reduce = document.getElementById('cmd_fullZoomReduce'); + var enlarge = document.getElementById('cmd_fullZoomEnlarge'); + var reset = document.getElementById('cmd_fullZoomReset'); if(reduce) reduce.addEventListener("command", function(e) { Zotero_Browser.resize(e) }, false); diff --git a/chrome/content/zotero/charsetMenu.js b/chrome/content/zotero/charsetMenu.js index 413d85f2a..bd30fea32 100644 --- a/chrome/content/zotero/charsetMenu.js +++ b/chrome/content/zotero/charsetMenu.js @@ -44,62 +44,29 @@ var Zotero_Charset_Menu = new function() { var charsets = []; - if(Zotero.platformMajorVersion >= 32) { - Components.utils.import("resource://gre/modules/CharsetMenu.jsm"); - var cmData = CharsetMenu.getData(); - for (let charsetList of [cmData.pinnedCharsets, cmData.otherCharsets]) { - for each(var charsetInfo in charsetList) { - if(charsetInfo.value == "UTF-8") { - charsets.push({ - "label":"Unicode (UTF-8)", - "value":"UTF-8" - }); - } else { - charsets.push({ - "label":charsetInfo.label, - "value":charsetInfo.value - }); - } + Components.utils.import("resource://gre/modules/CharsetMenu.jsm"); + var cmData = CharsetMenu.getData(); + for (let charsetList of [cmData.pinnedCharsets, cmData.otherCharsets]) { + for each(var charsetInfo in charsetList) { + if(charsetInfo.value == "UTF-8") { + charsets.push({ + "label":"Unicode (UTF-8)", + "value":"UTF-8" + }); + } else { + charsets.push({ + "label":charsetInfo.label, + "value":charsetInfo.value + }); } } - charsets = charsets.concat([ - {"label":"UTF-16LE", "value":"UTF-16LE"}, - {"label":"UTF-16BE", "value":"UTF-16BE"}, - {"label":"Western (IBM-850)", "value":"IBM850"}, - {"label":"Western (MacRoman)", "value":"macintosh"} - ]); - } else { - var charsetConverter = Components.classes["@mozilla.org/charset-converter-manager;1"]. - getService(Components.interfaces.nsICharsetConverterManager); - var ccCharsets = charsetConverter.getEncoderList(); - // add charsets to popup in order - while(ccCharsets.hasMore()) { - var charset = ccCharsets.getNext(); - try { - var label = charsetConverter.getCharsetTitle(charset); - } catch(e) { - continue; - } - - var isUTF16 = charset.length >= 6 && charset.substr(0, 6) == "UTF-16"; - - // Show UTF-16 element appropriately depending on exportMenu - if(isUTF16 && exportMenu == (charset == "UTF-16") || - (!exportMenu && charset == "UTF-32LE")) { - continue; - } else if(charset == "x-mac-roman") { - // use the IANA name - charset = "macintosh"; - } else if(!exportMenu && charset == "UTF-32BE") { - label = "Unicode (UTF-32)"; - charset = "UTF-32"; - } - charsets.push({ - "label":label, - "value":charset - }); - } } + charsets = charsets.concat([ + {"label":"UTF-16LE", "value":"UTF-16LE"}, + {"label":"UTF-16BE", "value":"UTF-16BE"}, + {"label":"Western (IBM-850)", "value":"IBM850"}, + {"label":"Western (MacRoman)", "value":"macintosh"} + ]); for(var i=0; i= 32) { + if (Zotero.isFx && !Zotero.isBookmarklet) { return Components.utils.cloneInto(obj1, obj2); } return obj1; diff --git a/chrome/content/zotero/xpcom/translation/translate.js b/chrome/content/zotero/xpcom/translation/translate.js index 0766677a5..635d5d8e7 100644 --- a/chrome/content/zotero/xpcom/translation/translate.js +++ b/chrome/content/zotero/xpcom/translation/translate.js @@ -429,7 +429,7 @@ Zotero.Translate.Sandbox = { }); }; - if(Zotero.isFx && Zotero.platformMajorVersion >= 33) { + if (Zotero.isFx) { for(var i in safeTranslator) { if (typeof(safeTranslator[i]) === "function") { safeTranslator[i] = translate._sandboxManager._makeContentForwarder(function(func) { diff --git a/chrome/content/zotero/xpcom/translation/translate_firefox.js b/chrome/content/zotero/xpcom/translation/translate_firefox.js index 0f75ae5b7..a310f1946 100644 --- a/chrome/content/zotero/xpcom/translation/translate_firefox.js +++ b/chrome/content/zotero/xpcom/translation/translate_firefox.js @@ -407,56 +407,52 @@ Zotero.Translate.SandboxManager = function(sandboxLocation) { var expr = "(function(x) { return function() { this.args = arguments; return Function.prototype.apply.call(x, this); }.bind({}); })"; this._makeContentForwarder = Components.utils.evalInSandbox(expr, sandbox); - if (Zotero.platformMajorVersion >= 35) { - var _proxy = Components.utils.evalInSandbox('(function (target, x, overrides) {'+ - ' return new Proxy(x, ProxyHandler(target, overrides));'+ - '})', sandbox); - var wrap = this.wrap = function(target, x, overrides) { - if (target === null || (typeof target !== "object" && typeof target !== "function")) return target; - if (!x) x = new sandbox.Object(); - return _proxy(target, x, overrides); + var _proxy = Components.utils.evalInSandbox('(function (target, x, overrides) {'+ + ' return new Proxy(x, ProxyHandler(target, overrides));'+ + '})', sandbox); + var wrap = this.wrap = function(target, x, overrides) { + if (target === null || (typeof target !== "object" && typeof target !== "function")) return target; + if (!x) x = new sandbox.Object(); + return _proxy(target, x, overrides); + }; + var me = this; + sandbox.ProxyHandler = this._makeContentForwarder(function() { + var target = (this.args.wrappedJSObject || this.args)[0]; + var overrides = (this.args.wrappedJSObject || this.args)[1] || {}; + if(target instanceof Components.interfaces.nsISupports) { + target = new XPCNativeWrapper(target); + } + var ret = new sandbox.Object(); + var wrappedRet = ret.wrappedJSObject || ret; + wrappedRet.has = function(x, prop) { + return overrides.hasOwnProperty(prop) || prop in target; }; - var me = this; - sandbox.ProxyHandler = this._makeContentForwarder(function() { - var target = (this.args.wrappedJSObject || this.args)[0]; - var overrides = (this.args.wrappedJSObject || this.args)[1] || {}; - if(target instanceof Components.interfaces.nsISupports) { - target = new XPCNativeWrapper(target); - } - var ret = new sandbox.Object(); - var wrappedRet = ret.wrappedJSObject || ret; - wrappedRet.has = function(x, prop) { - return overrides.hasOwnProperty(prop) || prop in target; - }; - wrappedRet.get = function(x, prop, receiver) { - if (prop === "__wrappedObject") return target; - if (prop === "__wrapperOverrides") return overrides; - if (prop === "__wrappingManager") return me; - var y = overrides.hasOwnProperty(prop) ? overrides[prop] : target[prop]; - if (y === null || (typeof y !== "object" && typeof y !== "function")) return y; - return wrap(y, typeof y === "function" ? function() { - var args = Array.prototype.slice.apply(arguments); - for (var i = 0; i < args.length; i++) { - if (typeof args[i] === "object" && args[i] !== null && - args[i].wrappedJSObject && args[i].wrappedJSObject.__wrappedObject) - args[i] = new XPCNativeWrapper(args[i].wrappedJSObject.__wrappedObject); - } - return wrap(y.apply(target, args)); - } : new sandbox.Object()); - }; - wrappedRet.ownKeys = function(x) { - return Components.utils.cloneInto(target.getOwnPropertyNames(), sandbox); - }; - wrappedRet.enumerate = function(x) { - var y = new sandbox.Array(); - for (var i in target) y.wrappedJSObject.push(i); - return y; - }; - return ret; - }); - } else { - this.wrap = Zotero.Translate.DOMWrapper.wrap; - } + wrappedRet.get = function(x, prop, receiver) { + if (prop === "__wrappedObject") return target; + if (prop === "__wrapperOverrides") return overrides; + if (prop === "__wrappingManager") return me; + var y = overrides.hasOwnProperty(prop) ? overrides[prop] : target[prop]; + if (y === null || (typeof y !== "object" && typeof y !== "function")) return y; + return wrap(y, typeof y === "function" ? function() { + var args = Array.prototype.slice.apply(arguments); + for (var i = 0; i < args.length; i++) { + if (typeof args[i] === "object" && args[i] !== null && + args[i].wrappedJSObject && args[i].wrappedJSObject.__wrappedObject) + args[i] = new XPCNativeWrapper(args[i].wrappedJSObject.__wrappedObject); + } + return wrap(y.apply(target, args)); + } : new sandbox.Object()); + }; + wrappedRet.ownKeys = function(x) { + return Components.utils.cloneInto(target.getOwnPropertyNames(), sandbox); + }; + wrappedRet.enumerate = function(x) { + var y = new sandbox.Array(); + for (var i in target) y.wrappedJSObject.push(i); + return y; + }; + return ret; + }); } Zotero.Translate.SandboxManager.prototype = { @@ -490,25 +486,17 @@ Zotero.Translate.SandboxManager.prototype = { var isObject = typeof object[localKey] === "object"; if(isFunction || isObject) { if(isFunction) { - if (Zotero.platformMajorVersion >= 33) { - attachTo[localKey] = this._makeContentForwarder(function() { - var args = Array.prototype.slice.apply(this.args.wrappedJSObject || this.args); - for(var i = 0; i= 32) { + if (Zotero.isFx && !Zotero.isBookmarklet) { creator = Components.utils.cloneInto(creator, item); } item.creators.push(creator); diff --git a/chrome/content/zotero/xpcom/zotero.js b/chrome/content/zotero/xpcom/zotero.js index 7a346ce87..1d0a63c86 100644 --- a/chrome/content/zotero/xpcom/zotero.js +++ b/chrome/content/zotero/xpcom/zotero.js @@ -1618,15 +1618,6 @@ Components.utils.import("resource://gre/modules/osfile.jsm"); .getService(Components.interfaces.nsILocaleService); var appLocale = localeService.getApplicationLocale(); - // Use nsICollation before Fx30 - if (Zotero.platformMajorVersion < 30) { - var localeService = Components.classes["@mozilla.org/intl/nslocaleservice;1"] - .getService(Components.interfaces.nsILocaleService); - var collationFactory = Components.classes["@mozilla.org/intl/collation-factory;1"] - .getService(Components.interfaces.nsICollationFactory); - return this.collation = collationFactory.CreateCollation(appLocale); - } - try { var locale = appLocale.getCategory('NSILOCALE_COLLATE'); // Extract a valid language tag diff --git a/components/zotero-service.js b/components/zotero-service.js index 535ff705a..73bdab6e7 100644 --- a/components/zotero-service.js +++ b/components/zotero-service.js @@ -505,12 +505,4 @@ ZoteroCommandLineHandler.prototype.__defineGetter__("Zotero", function() { return zContext.Zotero; }); -/** -* XPCOMUtils.generateNSGetFactory was introduced in Mozilla 2 (Firefox 4). -* XPCOMUtils.generateNSGetModule is for Mozilla 1.9.2 (Firefox 3.6). -*/ -if (XPCOMUtils.generateNSGetFactory) { - var NSGetFactory = XPCOMUtils.generateNSGetFactory([ZoteroService, ZoteroCommandLineHandler]); -} else { - var NSGetModule = XPCOMUtils.generateNSGetModule([ZoteroService, ZoteroCommandLineHandler]); -} +var NSGetFactory = XPCOMUtils.generateNSGetFactory([ZoteroService, ZoteroCommandLineHandler]);