Fixes #496, Snapshot doesn't complete on some web pages

I'm not entirely sure this won't break attachment saving in other cases, so people should keep an eye out for failed snapshots.
This commit is contained in:
Dan Stillman 2007-01-12 08:40:09 +00:00
parent 28a6b5f7cb
commit 7a0a6f75a2
2 changed files with 24 additions and 5 deletions

View File

@ -451,7 +451,7 @@ Zotero.Attachments = new function(){
Zotero.DB.commitTransaction();
if (mimeType == 'text/html') {
Zotero.debug('Saving with saveDocument()');
Zotero.debug('Saving with saveDocument() to ' + destDir.path);
wbp.saveDocument(document, file, destDir, mimeType, encodingFlags, false);
}
else {

View File

@ -1284,16 +1284,35 @@ Zotero.Browser = new function() {
* Implements nsIWebProgressListener
*/
Zotero.WebProgressFinishListener = function(onFinish) {
var _finished = false;
this.onStateChange = function(wp, req, stateFlags, status) {
//Zotero.debug('onStageChange: ' + stateFlags);
if ((stateFlags & Components.interfaces.nsIWebProgressListener.STATE_STOP)
&& (stateFlags & Components.interfaces.nsIWebProgressListener.STATE_IS_NETWORK)) {
if (_finished) {
//Zotero.debug('onFinish() called before STATE_STOP in WebProgressFinishListener.onStateChange()');
return;
}
onFinish();
}
}
this.onLocationChange = function() {}
this.onProgressChange = function() {}
this.onSecurityChange = function() {}
this.onStatusChange = function() {}
this.onProgressChange = function(wp, req, curSelfProgress, maxSelfProgress, curTotalProgress, maxTotalProgress) {
//Zotero.debug('onProgressChange');
//Zotero.debug('Current: ' + curTotalProgress);
//Zotero.debug('Max: ' + maxTotalProgress);
// STATE_STOP alone (in onStateChange) doesn't always do the trick,
// so we check for max progress too
if (curTotalProgress == maxTotalProgress) {
_finished = true;
onFinish();
}
}
this.onLocationChange = function(wp, req, location) {}
this.onSecurityChange = function(wp, req, stateFlags, status) {}
this.onStatusChange = function(wp, req, status, msg) {}
}