Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge pull request #7227 from guiora/bug-814460

Bug 814460 - Dark favicon is barely visible on homescreen
  • Loading branch information...
commit a3ce4c048053883becd953d93359bca83b77c225 2 parents 655b8a8 + 1c00cad
@vingtetun vingtetun authored
View
34 apps/homescreen/js/grid.js
@@ -139,7 +139,7 @@ const GridManager = (function() {
window.mozRequestAnimationFrame(function() {
setOverlayPanning(index, deltaX, forward);
});
- }
+ };
}
var container = pages[index].container;
@@ -248,7 +248,7 @@ const GridManager = (function() {
kPageTransitionDuration;
lastGoingPageTimestamp += delay;
var duration = delay < kPageTransitionDuration ?
- delay : kPageTransitionDuration
+ delay : kPageTransitionDuration;
var goToPageCallback = function() {
delete document.body.dataset.transitioning;
@@ -260,7 +260,7 @@ const GridManager = (function() {
newPage.container.dispatchEvent(new CustomEvent('gridpageshowend'));
overlayStyle.MozTransition = '';
togglePagesVisibility(index, index);
- }
+ };
var previousPage = pages[currentPage];
var newPage = pages[index];
@@ -501,7 +501,7 @@ const GridManager = (function() {
if (!iconsForApp)
iconsForApp = appIcons[descriptor.manifestURL] = Object.create(null);
- iconsForApp[descriptor.entry_point || ""] = icon;
+ iconsForApp[descriptor.entry_point || ''] = icon;
}
function forgetIcon(icon) {
@@ -514,7 +514,7 @@ const GridManager = (function() {
if (!iconsForApp)
return;
- delete iconsForApp[descriptor.entry_point || ""];
+ delete iconsForApp[descriptor.entry_point || ''];
}
function getIcon(descriptor) {
@@ -522,7 +522,7 @@ const GridManager = (function() {
return bookmarkIcons[descriptor.bookmarkURL];
var iconsForApp = appIcons[descriptor.manifestURL];
- return iconsForApp && iconsForApp[descriptor.entry_point || ""];
+ return iconsForApp && iconsForApp[descriptor.entry_point || ''];
}
function getIconsForApp(app) {
@@ -684,7 +684,7 @@ const GridManager = (function() {
};
app.ondownloaderror = function ondownloaderror(event) {
createOrUpdateIconForApp(app, entryPoint);
- }
+ };
}
var manifest = app.manifest ? app.manifest : app.updateManifest;
@@ -740,7 +740,7 @@ const GridManager = (function() {
function showRestartDownloadDialog(icon) {
var app = icon.app;
var _ = navigator.mozL10n.get;
- var confirm = {
+ var confirm = {
title: _('download'),
callback: function onAccept() {
app.download();
@@ -751,7 +751,7 @@ const GridManager = (function() {
app.onprogress = function onProgress(evt) {
app.onprogress = null;
icon.updateAppStatus(evt.application);
- }
+ };
icon.showDownloading();
ConfirmDialog.hide();
},
@@ -764,9 +764,9 @@ const GridManager = (function() {
};
var localizedName = icon.descriptor.localizedName || icon.descriptor.name;
- ConfirmDialog.show(_('restart-download-title'),
- _('restart-download-body', {'name': localizedName}),
- cancel,
+ ConfirmDialog.show(_('restart-download-title'),
+ _('restart-download-body', {'name': localizedName}),
+ cancel,
confirm);
return;
}
@@ -778,8 +778,9 @@ const GridManager = (function() {
Icon.prototype.CANCELED_ICON_URL;
}
var icons = manifest.icons;
- if (!icons)
- return Icon.prototype.DEFAULT_ICON_URL;
+ if (!icons) {
+ return getDefaultIcon(app);
+ }
var preferredSize = Number.MAX_VALUE;
var max = 0;
@@ -798,8 +799,9 @@ const GridManager = (function() {
preferredSize = max;
var url = icons[preferredSize];
- if (!url)
- return Icon.prototype.DEFAULT_ICON_URL;
+ if (!url) {
+ return getDefaultIcon(app);
+ }
// If the icon path is not an absolute URL, prepend the app's origin.
if (url.indexOf('data:') == 0 ||
View
56 apps/homescreen/js/page.js
@@ -20,6 +20,8 @@ Icon.prototype = {
MIN_ICON_SIZE: 52,
MAX_ICON_SIZE: 60,
+ DEFAULT_BOOKMARK_ICON_URL: window.location.protocol + '//' + window.location.host +
+ '/style/images/default_favicon.png',
DEFAULT_ICON_URL: window.location.protocol + '//' + window.location.host +
'/style/images/default.png',
DOWNLOAD_ICON_URL: window.location.protocol + '//' + window.location.host +
@@ -186,22 +188,49 @@ Icon.prototype = {
img.onload = function icon_loadSuccess() {
if (blob)
window.URL.revokeObjectURL(img.src);
-
self.renderImage(img);
};
img.onerror = function icon_loadError() {
if (blob)
window.URL.revokeObjectURL(img.src);
-
- img.src = self.DEFAULT_ICON_URL;
+ img.src = getDefaultIcon(self.app);
img.onload = function icon_errorIconLoadSucess() {
self.renderImage(img);
};
};
},
+ renderImageForBookMark: function icon_renderImageForBookmark(img){
+ var self = this;
+ var canvas = document.createElement('canvas');
+ canvas.width = 64;
+ canvas.height = 64;
+ var ctx = canvas.getContext('2d');
+
+ // Draw the background
+ var background = new Image();
+ background.src = 'style/images/default_background.png';
+ background.onload = function icon_loadBackgroundSuccess(){
+ ctx.shadowColor = 'rgba(0,0,0,0.8)';
+ ctx.shadowBlur = 2;
+ ctx.shadowOffsetY = 2;
+ ctx.drawImage(background,2,2);
+ // Disable smoothing on icon resize
+ ctx.shadowBlur = 0;
+ ctx.shadowOffsetY = 0;
+ ctx.mozImageSmoothingEnabled = false;
+ ctx.drawImage(img,16,16,32,32);
+ canvas.toBlob(self.renderBlob.bind(self));
+ };
+ },
+
renderImage: function icon_renderImage(img) {
+ if( this.app && this.app.isBookmark ) {
+ this.renderImageForBookMark(img);
+ return;
+ }
+
var canvas = document.createElement('canvas');
canvas.width = 64;
canvas.height = 64;
@@ -226,12 +255,13 @@ Icon.prototype = {
width, height);
ctx.fill();
- var self = this;
- canvas.toBlob(function canvasAsBlob(blob) {
- self.descriptor.renderedIcon = blob;
- GridManager.markDirtyState();
- self.displayRenderedIcon();
- });
+ canvas.toBlob(this.renderBlob.bind(this));
+ },
+
+ renderBlob: function icon_renderBlob(blob) {
+ this.descriptor.renderedIcon = blob;
+ GridManager.markDirtyState();
+ this.displayRenderedIcon();
},
displayRenderedIcon: function icon_displayRenderedIcon(img, skipRevoke) {
@@ -706,6 +736,14 @@ Page.prototype = {
}
};
+function getDefaultIcon(app){
+ if (app && app.isBookmark) {
+ return Icon.prototype.DEFAULT_BOOKMARK_ICON_URL;
+ } else {
+ return Icon.prototype.DEFAULT_ICON_URL;
+ }
+}
+
function extend(subClass, superClass) {
var F = function() {};
F.prototype = superClass.prototype;
View
BIN  apps/homescreen/style/images/default_background.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  apps/homescreen/style/images/default_favicon.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Please sign in to comment.
Something went wrong with that request. Please try again.