summaryrefslogtreecommitdiffstats
path: root/application/palemoon/base/content
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@gmail.com>2018-12-06 22:23:58 +0100
committerwolfbeast <mcwerewolf@gmail.com>2018-12-06 22:23:58 +0100
commit3411dd5723fdcd7d2b5a8b08a9c2b6bea310b3c3 (patch)
treefc9e3a553cb97faa2941b46a6d614ce2cc418e1b /application/palemoon/base/content
parent93705a7d00b2b09ee9b5d036b71c5be79b8d10a1 (diff)
downloadUXP-3411dd5723fdcd7d2b5a8b08a9c2b6bea310b3c3.tar
UXP-3411dd5723fdcd7d2b5a8b08a9c2b6bea310b3c3.tar.gz
UXP-3411dd5723fdcd7d2b5a8b08a9c2b6bea310b3c3.tar.lz
UXP-3411dd5723fdcd7d2b5a8b08a9c2b6bea310b3c3.tar.xz
UXP-3411dd5723fdcd7d2b5a8b08a9c2b6bea310b3c3.zip
Add an option to process favicons.
This optimizes the size for UI display and strips animations. Default disabled. This resolves #899.
Diffstat (limited to 'application/palemoon/base/content')
-rw-r--r--application/palemoon/base/content/tabbrowser.xml29
1 files changed, 28 insertions, 1 deletions
diff --git a/application/palemoon/base/content/tabbrowser.xml b/application/palemoon/base/content/tabbrowser.xml
index 929afd057..988cae55c 100644
--- a/application/palemoon/base/content/tabbrowser.xml
+++ b/application/palemoon/base/content/tabbrowser.xml
@@ -831,13 +831,40 @@
"-moz-resolution=" + size + "," + size;
}
if (sizedIconUrl != aTab.getAttribute("image")) {
- if (browser.mIconURL) //PMed
+ if (browser.mIconURL)
aTab.setAttribute("image", sizedIconUrl);
else
aTab.removeAttribute("image");
this._tabAttrModified(aTab, ["image"]);
}
+ if (Services.prefs.getBoolPref("browser.chrome.favicons.process")) {
+ let favImage = new Image;
+ favImage.src = browser.mIconURL;
+ var tabBrowser = this;
+ favImage.onload = function () {
+ try {
+ // Draw the icon on a hidden canvas
+ var canvas = document.createElementNS("http://www.w3.org/1999/xhtml", "canvas");
+ var tabImg = document.getAnonymousElementByAttribute(aTab, "anonid", "tab-icon");
+ var w = tabImg.boxObject.width;
+ var h = tabImg.boxObject.height;
+ canvas.width = w;
+ canvas.height = h;
+ var ctx = canvas.getContext('2d');
+ ctx.drawImage(favImage, 0, 0, w, h);
+ icon = canvas.toDataURL();
+ browser.mIconURL = icon;
+ aTab.setAttribute("image", icon);
+ }
+ catch (e) {
+ console.warn("Processing of favicon failed.");
+ // Canvas failed: icon remains as it was
+ }
+ tabBrowser._callProgressListeners(browser, "onLinkIconAvailable", [browser.mIconURL]);
+ }
+ }
+
this._callProgressListeners(browser, "onLinkIconAvailable", [browser.mIconURL]);
]]>
</body>