1 /* coded by Ketmar // Invisible Vector (psyc://ketmar.no-ip.org/~Ketmar)
2 * Understanding is not required. Only obedience.
4 * This program is free software. It comes without any warranty, to
5 * the extent permitted by applicable law. You can redistribute it
6 * and/or modify it under the terms of the Do What The Fuck You Want
7 * To Public License, Version 2, as published by Sam Hocevar. See
8 * http://www.wtfpl.net/txt/copying/ for more details.
11 let EXPORTED_SYMBOLS
= [
16 const {utils
:Cu
, classes
:Cc
, interfaces
:Ci
, results
:Cr
} = Components
;
19 //////////////////////////////////////////////////////////////////////////////
20 Cu
.import("chrome://k8-imago-code/content/modules/utils.js");
21 Cu
.import(MODULE_PATH
+"debuglog.js");
22 Cu
.import(MODULE_PATH
+"prefs.js");
25 //////////////////////////////////////////////////////////////////////////////
26 function expungeImageCache (el
, url
) {
27 if (!el
|| typeof(el
.tagName
) !== "string" || el
.tagName
!== "IMG") return;
29 let tools
= Cc
["@mozilla.org/image/tools;1"].getService(Ci
.imgITools
);
30 let cache
= tools
.getImgCacheForDocument(el
.ownerDocument
);
32 if (url
=== undefined) url
= el
.getAttribute("src");
33 if (typeof(url
) === "string") url
= url2uri(url
);
34 conlog("got cache object for image with url ", url
.spec
);
36 cache
.removeEntry(url
);
38 conlog(" error clearing cache for image with url ", el
.src
);
39 if (PREFS
.debugLog
) logException("cache error", e
);
46 //////////////////////////////////////////////////////////////////////////////
47 let reloadUrlList
= {};
50 function reloadImage (el
) {
51 if (el
instanceof Ci
.nsIImageLoadingContent
) {
52 conlog("forcing reload!");
53 let src
= el
.getAttribute("src");
54 expungeImageCache(el
);
55 reloadUrlList
[src
] = true;
56 oneShotTimer(function () { delete reloadUrlList
[src
]; }, 500);
57 // and for all images in document
58 for (let img
of el
.ownerDocument
.querySelectorAll("img[src]")) {
59 if (img
.getAttribute("src") === src
) {
60 if (img
instanceof Ci
.nsIImageLoadingContent
) {
64 logException("reload error", e
);