зеркало из https://github.com/mozilla/gecko-dev.git
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
This commit is contained in:
Родитель
4fa97cae2b
Коммит
0b49219fad
|
@ -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
|
||||
|
|
Загрузка…
Ссылка в новой задаче