diff options
author | wolfbeast <mcwerewolf@gmail.com> | 2018-12-06 22:23:58 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@gmail.com> | 2018-12-06 22:23:58 +0100 |
commit | 3411dd5723fdcd7d2b5a8b08a9c2b6bea310b3c3 (patch) | |
tree | fc9e3a553cb97faa2941b46a6d614ce2cc418e1b /application/palemoon | |
parent | 93705a7d00b2b09ee9b5d036b71c5be79b8d10a1 (diff) | |
download | UXP-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')
-rw-r--r-- | application/palemoon/app/profile/palemoon.js | 3 | ||||
-rw-r--r-- | application/palemoon/base/content/tabbrowser.xml | 29 |
2 files changed, 31 insertions, 1 deletions
diff --git a/application/palemoon/app/profile/palemoon.js b/application/palemoon/app/profile/palemoon.js index 907ac1fbf..1c6016f0f 100644 --- a/application/palemoon/app/profile/palemoon.js +++ b/application/palemoon/app/profile/palemoon.js @@ -264,6 +264,9 @@ pref("browser.slowStartup.maxSamples", 5); pref("browser.enable_automatic_image_resizing", true); pref("browser.chrome.site_icons", true); pref("browser.chrome.favicons", true); +// If enabled, will process favicons by drawing them on a canvas, +// optimizing display size for the UI. This also strips animations. +pref("browser.chrome.favicons.process", false); // browser.warnOnQuit == false will override all other possible prompts when quitting or restarting pref("browser.warnOnQuit", true); // browser.showQuitWarning specifically controls the quit warning dialog. We 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> |