From 0b49219fadb58310109944591b88d49839a81833 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 29 Mar 2018 17:01:06 -0700 Subject: [PATCH] Bug 1449200: Return icon URL for all sizes when processing an icon string. r=Gijs The CSS for page action icons doesn't handle fallback when only one variable is defined, so for widgets that don't define their icons using CSS, we always need to provide both. MozReview-Commit-ID: 7UgMSVS3W6K --HG-- extra : rebase_source : d8e38c256b45efecf04f1e20b5fcc6024e839f25 --- browser/modules/PageActions.jsm | 42 +++++++++++++-------------------- 1 file changed, 16 insertions(+), 26 deletions(-) diff --git a/browser/modules/PageActions.jsm b/browser/modules/PageActions.jsm index 65c54a2bfc0a..fbe27d998299 100644 --- a/browser/modules/PageActions.jsm +++ b/browser/modules/PageActions.jsm @@ -692,9 +692,10 @@ Action.prototype = { return props; } + let cssURL = urls ? escapeCSSURL(urls) : null; return Object.freeze({ - "--pageAction-image-16px": null, - "--pageAction-image-32px": urls ? escapeCSSURL(urls) : null, + "--pageAction-image-16px": cssURL, + "--pageAction-image-32px": cssURL, }); }, @@ -806,32 +807,21 @@ Action.prototype = { return this._labelForHistogram || this._id; }, - /** - * Returns the URL of the best icon to use given a preferred size. The best - * icon is the one with the smallest size that's equal to or bigger than the - * preferred size. Returns null if the action has no icon URL. - * - * @param peferredSize (number, required) - * The icon size you prefer. - * @return The URL of the best icon, or null. - */ - iconURLForSize(preferredSize, browserWindow) { - let iconURL = this.getIconURL(browserWindow); - if (!iconURL) { - return null; - } - if (typeof(iconURL) == "string") { - return iconURL; - } - if (typeof(iconURL) == "object") { - return this._iconURLForSize(iconURL, preferredSize); - } - return null; - }, - /** * Selects the best matching icon from the given URLs object for the - * given preferred size, as described in {@see iconURLForSize}. + * given preferred size. + * + * @param {object} urls + * An object containing square icons of various sizes. The name + * of each property is its width, and the value is its image URL. + * @param {integer} peferredSize + * The preferred icon width. The most appropriate icon in the + * urls object will be chosen to match that size. An exact + * match will be preferred, followed by an icon exactly double + * the size, followed by the smallest icon larger than the + * preferred size, followed by the largest available icon. + * @returns {string} + * The chosen icon URL. */ _iconURLForSize(urls, preferredSize) { // This case is copied from ExtensionParent.jsm so that our image logic is