Only use Components.utils.methodjit when supported

As Boris Zbarsky pointed out in
https://bugzilla.mozilla.org/show_bug.cgi?id=878679,
the setTimeout() hack doesn't help in Firefox 23 and later. For now we
use the useMethodjit hack when available, so that performance won't
regress for Firefox 23, and cross our fingers that
https://bugzilla.mozilla.org/show_bug.cgi?id=776798 is fixed for
Firefox 24.
This commit is contained in:
Simon Kornblith 2013-06-06 19:38:48 -04:00
parent 1cee348f51
commit 6ef9a061f3
3 changed files with 24 additions and 12 deletions

View file

@ -249,7 +249,8 @@ Zotero.HTTP = new function() {
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
// XXX Remove when we drop support for Fx <24
if(useMethodjit !== undefined) Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, onDone, responseCharset);
};
@ -337,7 +338,8 @@ Zotero.HTTP = new function() {
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
// XXX Remove when we drop support for Fx <24
if(useMethodjit !== undefined) Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, onDone, responseCharset);
};
@ -401,7 +403,8 @@ Zotero.HTTP = new function() {
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
// XXX Remove when we drop support for Fx <24
if(useMethodjit !== undefined) Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, onDone);
};
@ -440,7 +443,8 @@ Zotero.HTTP = new function() {
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
// XXX Remove when we drop support for Fx <24
if(useMethodjit !== undefined) Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, callback);
};
xmlhttp.send(null);
@ -482,7 +486,8 @@ Zotero.HTTP = new function() {
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
// XXX Remove when we drop support for Fx <24
if(useMethodjit !== undefined) Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, function (xmlhttp) {
Zotero.debug("Proxy auth request completed with status "
+ xmlhttp.status + ": " + xmlhttp.responseText);
@ -561,7 +566,8 @@ Zotero.HTTP = new function() {
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
// XXX Remove when we drop support for Fx <24
if(useMethodjit !== undefined) Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, callback);
};
@ -597,7 +603,8 @@ Zotero.HTTP = new function() {
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
// XXX Remove when we drop support for Fx <24
if(useMethodjit !== undefined) Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, callback);
};
xmlhttp.send(null);
@ -642,7 +649,8 @@ Zotero.HTTP = new function() {
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
// XXX Remove when we drop support for Fx <24
if(useMethodjit !== undefined) Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, callback);
};
xmlhttp.send(body);
@ -681,7 +689,8 @@ Zotero.HTTP = new function() {
var useMethodjit = Components.utils.methodjit;
/** @ignore */
xmlhttp.onreadystatechange = function() {
Components.utils.methodjit = useMethodjit;
// XXX Remove when we drop support for Fx <24
if(useMethodjit !== undefined) Components.utils.methodjit = useMethodjit;
_stateChange(xmlhttp, callback);
};
xmlhttp.send(null);

View file

@ -1545,7 +1545,8 @@ Components.utils.import("resource://gre/modules/Services.jsm");
yielded,
useJIT = Components.utils.methodjit;
var timerCallback = {"notify":function() {
Components.utils.methodjit = useJIT;
// XXX Remove when we drop support for Fx <24
if(useJIT !== undefined) Components.utils.methodjit = useJIT;
var err = false;
_waiting--;
@ -1610,7 +1611,8 @@ Components.utils.import("resource://gre/modules/Services.jsm");
createInstance(Components.interfaces.nsITimer),
useJIT = Components.utils.methodjit;
var timerCallback = {"notify":function() {
Components.utils.methodjit = useJIT;
// XXX Remove when we drop support for Fx <24
if(useJIT !== undefined) Components.utils.methodjit = useJIT;
if(_waiting && !runWhenWaiting) {
// if our callback gets called during Zotero.wait(), queue it to be set again

View file

@ -70,7 +70,8 @@
timer = Components.classes["@mozilla.org/timer;1"].
createInstance(Components.interfaces.nsITimer);
timer.initWithCallback({"notify":function() {
Components.utils.methodjit = useMethodjit;
// XXX Remove when we drop support for Fx <24
if(useMethodjit !== undefined) Components.utils.methodjit = useMethodjit;
// Remove timer from array so it can be garbage collected
_runningTimers.splice(_runningTimers.indexOf(timer), 1);