From 19b35e92511718fb5cfe653df535e072c7ccd748 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Wed, 25 Jul 2018 13:45:48 +0200 Subject: Use a fixed thumbnail placeholder for blank thumbs (failed to capture). --- .../components/thumbnails/BackgroundPageThumbs.jsm | 6 +- toolkit/components/thumbnails/PageThumbs.jsm | 3 + toolkit/components/thumbnails/blankthumb.inc | 87 ++++++++++++++++++++++ toolkit/components/thumbnails/moz.build | 6 +- 4 files changed, 97 insertions(+), 5 deletions(-) create mode 100644 toolkit/components/thumbnails/blankthumb.inc (limited to 'toolkit/components') diff --git a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm index bd52e77e9..b2aa646f7 100644 --- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm +++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm @@ -468,11 +468,9 @@ Capture.prototype = { }; if (!data) { - // If this background attempt failed, cause a dummy file to be saved, so + // If this background attempt failed, cause a placeholder file to be saved, so // that gets loaded instead of attempting again (and again). - // XXX: Perhaps we can create a placeholder image to use instead of "null" - // here, so it has something to show to the user? - PageThumbs._store(this.url, this.url, null, true) + PageThumbs._store(this.url, this.url, atob(BLANKTHUMB), true) .then(done, done); return; } diff --git a/toolkit/components/thumbnails/PageThumbs.jsm b/toolkit/components/thumbnails/PageThumbs.jsm index b0affee92..4b343c605 100644 --- a/toolkit/components/thumbnails/PageThumbs.jsm +++ b/toolkit/components/thumbnails/PageThumbs.jsm @@ -28,6 +28,9 @@ const MAX_THUMBNAIL_AGE_SECS = 172800; // 2 days == 60*60*24*2 == 172800 secs. */ const THUMBNAIL_DIRECTORY = "thumbnails"; +// contains base64 version of a placeholder thumbnail +#include "blankthumb.inc" + Cu.import("resource://gre/modules/XPCOMUtils.jsm", this); Cu.import("resource://gre/modules/PromiseWorker.jsm", this); Cu.import("resource://gre/modules/Promise.jsm", this); diff --git a/toolkit/components/thumbnails/blankthumb.inc b/toolkit/components/thumbnails/blankthumb.inc new file mode 100644 index 000000000..06577c19c --- /dev/null +++ b/toolkit/components/thumbnails/blankthumb.inc @@ -0,0 +1,87 @@ +const BLANKTHUMB = +"iVBORw0KGgoAAAANSUhEUgAAASwAAADsCAAAAADricSpAAASn0lEQVR4XuzQQREAAAwCoPWvaolV" + +"8O1BBC41RrNkyZIlC1myZMmSJQtZsmTJkiULWbJkyZIlC1myZMmSJQtZsmTJkiULWbJkyZIliyfv" + +"7HYbV5Ik/EUWScl2zwL7svvSc7MXp9uWyKrY2W0iUShI/tmLM6I7SJMpCrrw1xFZCZMNTTyQbNum" + +"QSlGVEkSD6MHgWVaq81uNAT8eDL4v9eQFCVC6E+HlX6qW22GolkRAr3MBr+sdnPdTJmKQn86LLda" + +"t4piKaVk6jgFwH+ul2a7uW3bVSVK0R8Mq9W1birLXEpIpHYoCgpgt8W1trqF5n+nv/TPf6Op1mtj" + +"+pcKOykhCXQqALS3igEDdq3NrWqJ+INgpamulHkuRYAQIQlkxbTjuLZcIQ3QtuZWPZXQnwTL67qq" + +"zEuEAP0WCChlR8W2CedI0YDfa2aFufwxsLy9Vc3zHBKgkIR2VDOpWsG5u9n7imA3Tf8Gd5X/4u+W" + +"69ubl/N5DoEiIpJVzBMpooHETlLa0UYBUZG+/2pYrxfmZSoCpJBA+8YsegkALMAIyc2IuWy1eC1F" + +"3zuGbb20aV5CAikEInlpphetgcEYzL41Y6hbo/E3ZzH4W1V/vXJ6Opc9UDulnRWjYtpDKJFbBIKy" + +"zJK26m/rLF8vbZ7nAoKQROcqECUYVNNX3daMoW3VUMp3dJZpr798Oi8BoJAAAULS70NjFPub/UYI" + +"sOY58Lb5G8Ji+3mZzqeiHUCSIktpTFUD0LgRIQRlLlLd/O1gef25zeelKJ0E9BkEQRtZST2t5Eso" + +"R422tm8Gy5dfXs6zoG9UiC6L3JRET0kAiB33tAiv9VvBam+vLOcpf31BYiKxjcCI/WqyTGxIAkQs" + +"AVv9RrDa25tOpwLc+rUh0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suJLV94MlEGiHJYSilAjQR6wUMS+l7F09dmPpb2WF/snfKYNxChtj" + +"XFuzLTOKvZGrgBAZYoWEBOJbwkpcJlntsPpvrSUloZAU6hKctpQQiG8MC7PjoveWAZMFJB4QjLYS" + +"Uj9mfM/RAYQRIGyTuMAC32l0CSv3pPitnZXuwtBba98Z5nnte26CzlXf11mju0CMrDzYqo9jnhLV" + +"93fW+E2+N1BZPa/OTAmZPwXWyAvTH0Zv6Ub1J8FKeeA2agQkgD8V1sjIDNJQ/tGwUuYdiQfQxMNI" + +"N6CJh9L/tEPHBAAAMAiA1r+qJVbBzwcikBrzLFmykCVLlixZspAlS5YsWbKQJUuWLFmykCVLlixZ" + +"spAlS5YsWbKQJUuWLFmyeEoXbr5fYDBbAAAAAElFTkSuQmCC"; + diff --git a/toolkit/components/thumbnails/moz.build b/toolkit/components/thumbnails/moz.build index 9bc218b6a..d4003c635 100644 --- a/toolkit/components/thumbnails/moz.build +++ b/toolkit/components/thumbnails/moz.build @@ -14,9 +14,13 @@ EXTRA_COMPONENTS += [ EXTRA_JS_MODULES += [ 'BackgroundPageThumbs.jsm', - 'PageThumbs.jsm', 'PageThumbsWorker.js', 'PageThumbUtils.jsm', ] +EXTRA_PP_JS_MODULES += [ + 'PageThumbs.jsm', +] + + JAR_MANIFESTS += ['jar.mn'] -- cgit v1.2.3 From 9fc1381e11a0a6adcd3be93b1d0524fd5336282b Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 26 Jul 2018 21:45:34 +0200 Subject: Fix #include and potentially undefined Capture.options object. --- toolkit/components/thumbnails/BackgroundPageThumbs.jsm | 2 +- toolkit/components/thumbnails/PageThumbs.jsm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'toolkit/components') diff --git a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm index b2aa646f7..e743c4dd9 100644 --- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm +++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm @@ -368,7 +368,7 @@ Capture.prototype = { tel("CAPTURE_QUEUE_TIME_MS", this.startDate - this.creationDate); // timeout timer - let timeout = typeof(this.options.timeout) == "number" ? + let timeout = this.options && typeof(this.options.timeout) == "number" ? this.options.timeout : DEFAULT_CAPTURE_TIMEOUT; this._timeoutTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); diff --git a/toolkit/components/thumbnails/PageThumbs.jsm b/toolkit/components/thumbnails/PageThumbs.jsm index 4b343c605..5c7754b31 100644 --- a/toolkit/components/thumbnails/PageThumbs.jsm +++ b/toolkit/components/thumbnails/PageThumbs.jsm @@ -29,7 +29,7 @@ const MAX_THUMBNAIL_AGE_SECS = 172800; // 2 days == 60*60*24*2 == 172800 secs. const THUMBNAIL_DIRECTORY = "thumbnails"; // contains base64 version of a placeholder thumbnail -#include "blankthumb.inc" +#include blankthumb.inc Cu.import("resource://gre/modules/XPCOMUtils.jsm", this); Cu.import("resource://gre/modules/PromiseWorker.jsm", this); -- cgit v1.2.3 From 3555533f7f48582e9d1790489e406946e4f99da3 Mon Sep 17 00:00:00 2001 From: wolfbeast Date: Thu, 26 Jul 2018 23:14:11 +0200 Subject: Convert trinary to more explicit statement. --- toolkit/components/thumbnails/BackgroundPageThumbs.jsm | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'toolkit/components') diff --git a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm index e743c4dd9..7b86fa07c 100644 --- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm +++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm @@ -368,9 +368,12 @@ Capture.prototype = { tel("CAPTURE_QUEUE_TIME_MS", this.startDate - this.creationDate); // timeout timer - let timeout = this.options && typeof(this.options.timeout) == "number" ? - this.options.timeout : - DEFAULT_CAPTURE_TIMEOUT; + let timeout; + if (this.options && typeof(this.options.timeout) == "number") { + timeout = this.options.timeout; + } else { + timeout = DEFAULT_CAPTURE_TIMEOUT; + } this._timeoutTimer = Cc["@mozilla.org/timer;1"].createInstance(Ci.nsITimer); this._timeoutTimer.initWithCallback(this, timeout, Ci.nsITimer.TYPE_ONE_SHOT); -- cgit v1.2.3