mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-25 00:27:29 +09:00
Add an option to process favicons.
This optimizes the size for UI display and strips animations. Default disabled. This resolves #899.
This commit is contained in:
parent
f295b5c91b
commit
9afb4d52f2
2 changed files with 31 additions and 1 deletions
|
|
@ -264,6 +264,9 @@ pref("browser.slowStartup.maxSamples", 5);
|
||||||
pref("browser.enable_automatic_image_resizing", true);
|
pref("browser.enable_automatic_image_resizing", true);
|
||||||
pref("browser.chrome.site_icons", true);
|
pref("browser.chrome.site_icons", true);
|
||||||
pref("browser.chrome.favicons", 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
|
// browser.warnOnQuit == false will override all other possible prompts when quitting or restarting
|
||||||
pref("browser.warnOnQuit", true);
|
pref("browser.warnOnQuit", true);
|
||||||
// browser.showQuitWarning specifically controls the quit warning dialog. We
|
// browser.showQuitWarning specifically controls the quit warning dialog. We
|
||||||
|
|
|
||||||
|
|
@ -831,13 +831,40 @@
|
||||||
"-moz-resolution=" + size + "," + size;
|
"-moz-resolution=" + size + "," + size;
|
||||||
}
|
}
|
||||||
if (sizedIconUrl != aTab.getAttribute("image")) {
|
if (sizedIconUrl != aTab.getAttribute("image")) {
|
||||||
if (browser.mIconURL) //PMed
|
if (browser.mIconURL)
|
||||||
aTab.setAttribute("image", sizedIconUrl);
|
aTab.setAttribute("image", sizedIconUrl);
|
||||||
else
|
else
|
||||||
aTab.removeAttribute("image");
|
aTab.removeAttribute("image");
|
||||||
this._tabAttrModified(aTab, ["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]);
|
this._callProgressListeners(browser, "onLinkIconAvailable", [browser.mIconURL]);
|
||||||
]]>
|
]]>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue