瀏覽代碼

fix `load deferred frames` option

Gildas 2 年之前
父節點
當前提交
884d73bc94
共有 1 個文件被更改,包括 16 次插入14 次删除
  1. 16 14
      src/core/content/content.js

+ 16 - 14
src/core/content/content.js

@@ -159,10 +159,23 @@ async function processPage(options) {
 	};
 	const cancelProcessor = processor.cancel.bind(processor);
 	if (!options.saveRawPage) {
+		let lazyLoadPromise;
+		if (options.loadDeferredImages) {
+			lazyLoadPromise = singlefile.processors.lazy.process(options);
+			ui.onLoadingDeferResources(options);
+			lazyLoadPromise.then(() => {
+				if (!processor.cancelled) {
+					ui.onLoadDeferResources(options);
+				}
+			});
+			if (options.loadDeferredImagesBeforeFrames) {
+				await lazyLoadPromise;
+			}
+		}
 		if (!options.removeFrames && frames && globalThis.frames) {
 			let frameTreePromise;
 			if (options.loadDeferredImages) {
-				frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesBeforeFrames ? 0 : options.loadDeferredImagesMaxIdleTime * .75));
+				frameTreePromise = new Promise(resolve => globalThis.setTimeout(() => resolve(frames.getAsync(options)), options.loadDeferredImagesBeforeFrames ? 0 : options.loadDeferredImagesMaxIdleTime));
 			} else {
 				frameTreePromise = frames.getAsync(options);
 			}
@@ -184,19 +197,8 @@ async function processPage(options) {
 				preInitializationPromises.push(frameTreePromise);
 			}
 		}
-		if (options.loadDeferredImages) {
-			const lazyLoadPromise = singlefile.processors.lazy.process(options);
-			ui.onLoadingDeferResources(options);
-			lazyLoadPromise.then(() => {
-				if (!processor.cancelled) {
-					ui.onLoadDeferResources(options);
-				}
-			});
-			if (options.loadDeferredImagesBeforeFrames) {
-				await lazyLoadPromise;
-			} else {
-				preInitializationPromises.push(lazyLoadPromise);
-			}
+		if (options.loadDeferredImages && !options.loadDeferredImagesBeforeFrames) {
+			preInitializationPromises.push(lazyLoadPromise);
 		}
 	}
 	if (!options.loadDeferredImagesBeforeFrames) {