mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 892632 - Hook up tile ribbon color in History tiles via new shared View module; refactor TopSitesView and BookmarksView to use same. r=mbrubeck
This commit is contained in:
parent
1cb9af0699
commit
88af615fe8
@ -185,7 +185,7 @@ function TopSitesView(aGrid, aMaxSites, aUseThumbnails) {
|
||||
}.bind(this));
|
||||
}
|
||||
|
||||
TopSitesView.prototype = {
|
||||
TopSitesView.prototype = Util.extend(Object.create(View.prototype), {
|
||||
_set:null,
|
||||
_topSitesMax: null,
|
||||
// _lastSelectedSites used to temporarily store blocked/removed sites for undo/restore-ing
|
||||
@ -307,23 +307,7 @@ TopSitesView.prototype = {
|
||||
},
|
||||
|
||||
updateTile: function(aTileNode, aSite, aArrangeGrid) {
|
||||
PlacesUtils.favicons.getFaviconURLForPage(Util.makeURI(aSite.url), function(iconURLfromSiteURL) {
|
||||
if (!iconURLfromSiteURL) {
|
||||
return;
|
||||
}
|
||||
aTileNode.iconSrc = iconURLfromSiteURL.spec;
|
||||
let faviconURL = (PlacesUtils.favicons.getFaviconLinkForIcon(iconURLfromSiteURL)).spec;
|
||||
let xpFaviconURI = Util.makeURI(faviconURL.replace("moz-anno:favicon:",""));
|
||||
let successAction = function(foreground, background) {
|
||||
aTileNode.style.color = foreground; //color text
|
||||
aTileNode.setAttribute("customColor", background);
|
||||
if (aTileNode.refresh) {
|
||||
aTileNode.refresh();
|
||||
}
|
||||
};
|
||||
let failureAction = function() {};
|
||||
ColorUtils.getForegroundAndBackgroundIconColors(xpFaviconURI, successAction, failureAction);
|
||||
});
|
||||
this._updateFavicon(aTileNode, Util.makeURI(aSite.url));
|
||||
|
||||
if (this._useThumbs) {
|
||||
Task.spawn(function() {
|
||||
@ -437,7 +421,7 @@ TopSitesView.prototype = {
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
|
||||
};
|
||||
});
|
||||
|
||||
let TopSitesStartView = {
|
||||
_view: null,
|
||||
|
@ -93,7 +93,7 @@ function BookmarksView(aSet, aLimit, aRoot, aFilterUnpinned) {
|
||||
this.root = aRoot;
|
||||
}
|
||||
|
||||
BookmarksView.prototype = {
|
||||
BookmarksView.prototype = Util.extend(Object.create(View.prototype), {
|
||||
_limit: null,
|
||||
_set: null,
|
||||
_changes: null,
|
||||
@ -216,7 +216,7 @@ BookmarksView.prototype = {
|
||||
let item = this._set.insertItemAt(aPos || index, title, uri.spec, this._inBatch);
|
||||
item.setAttribute("bookmarkId", aBookmarkId);
|
||||
this._setContextActions(item);
|
||||
this._updateFavicon(aBookmarkId, item, uri);
|
||||
this._updateFavicon(item, uri);
|
||||
},
|
||||
|
||||
_setContextActions: function bv__setContextActions(aItem) {
|
||||
@ -225,26 +225,6 @@ BookmarksView.prototype = {
|
||||
if (aItem.refresh) aItem.refresh();
|
||||
},
|
||||
|
||||
_updateFavicon: function bv__updateFavicon(aBookmarkId, aItem, aUri) {
|
||||
PlacesUtils.favicons.getFaviconURLForPage(aUri, this._gotIcon.bind(this, aBookmarkId, aItem));
|
||||
},
|
||||
|
||||
_gotIcon: function bv__gotIcon(aBookmarkId, aItem, aIconUri) {
|
||||
aItem.setAttribute("iconURI", aIconUri ? aIconUri.spec : "");
|
||||
if (!aIconUri) {
|
||||
return;
|
||||
}
|
||||
let successAction = function(foregroundColor, backgroundColor) {
|
||||
aItem.style.color = foregroundColor; //color text
|
||||
aItem.setAttribute("customColor", backgroundColor); //set background
|
||||
if (aItem.refresh) {
|
||||
aItem.refresh();
|
||||
}
|
||||
};
|
||||
let failureAction = function() {};
|
||||
ColorUtils.getForegroundAndBackgroundIconColors(aIconUri, successAction, failureAction);
|
||||
},
|
||||
|
||||
_sendNeedsRefresh: function bv__sendNeedsRefresh(){
|
||||
// Event sent when all view instances need to refresh.
|
||||
let event = document.createEvent("Events");
|
||||
@ -273,7 +253,7 @@ BookmarksView.prototype = {
|
||||
item.setAttribute("value", uri.spec);
|
||||
item.setAttribute("label", title);
|
||||
|
||||
this._updateFavicon(aBookmarkId, item, uri);
|
||||
this._updateFavicon(item, uri);
|
||||
},
|
||||
|
||||
removeBookmark: function bv_removeBookmark(aBookmarkId) {
|
||||
@ -370,7 +350,7 @@ BookmarksView.prototype = {
|
||||
break;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
var BookmarksStartView = {
|
||||
_view: null,
|
||||
|
@ -40,6 +40,9 @@ XPCOMUtils.defineLazyModuleGetter(this, "CrossSlide",
|
||||
XPCOMUtils.defineLazyGetter(this, "OS",
|
||||
"resource://gre/modules/osfile.jsm");
|
||||
|
||||
XPCOMUtils.defineLazyModuleGetter(this, "View",
|
||||
"resource:///modules/View.jsm");
|
||||
|
||||
/*
|
||||
* Services
|
||||
*/
|
||||
|
@ -1,7 +1,7 @@
|
||||
// -*- Mode: js2; tab-width: 2; indent-tabs-mode: nil; js2-basic-offset: 2; js2-skip-preprocessor-directives: t; -*-
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
'use strict';
|
||||
|
||||
function HistoryView(aSet, aLimit, aFilterUnpinned) {
|
||||
@ -20,7 +20,7 @@ function HistoryView(aSet, aLimit, aFilterUnpinned) {
|
||||
window.addEventListener('HistoryNeedsRefresh', this, false);
|
||||
}
|
||||
|
||||
HistoryView.prototype = {
|
||||
HistoryView.prototype = Util.extend(Object.create(View.prototype), {
|
||||
_set: null,
|
||||
_toRemove: null,
|
||||
|
||||
@ -97,8 +97,8 @@ HistoryView.prototype = {
|
||||
|
||||
addItemToSet: function addItemToSet(aURI, aTitle, aIcon, aPos) {
|
||||
let item = this._set.insertItemAt(aPos || 0, aTitle, aURI, this._inBatch);
|
||||
item.setAttribute("iconURI", aIcon);
|
||||
this._setContextActions(item);
|
||||
this._updateFavicon(item, aURI);
|
||||
},
|
||||
|
||||
_setContextActions: function bv__setContextActions(aItem) {
|
||||
@ -273,7 +273,7 @@ HistoryView.prototype = {
|
||||
}
|
||||
throw Cr.NS_ERROR_NO_INTERFACE;
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
let HistoryStartView = {
|
||||
_view: null,
|
||||
|
63
browser/metro/modules/View.jsm
Normal file
63
browser/metro/modules/View.jsm
Normal file
@ -0,0 +1,63 @@
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
"use strict";
|
||||
|
||||
this.EXPORTED_SYMBOLS = ["View"];
|
||||
|
||||
Components.utils.import("resource://gre/modules/PlacesUtils.jsm");
|
||||
Components.utils.import("resource:///modules/colorUtils.jsm");
|
||||
Components.utils.import("resource://gre/modules/Services.jsm");
|
||||
|
||||
// --------------------------------
|
||||
// module helpers
|
||||
//
|
||||
|
||||
function makeURI(aURL, aOriginCharset, aBaseURI) {
|
||||
return Services.io.newURI(aURL, aOriginCharset, aBaseURI);
|
||||
}
|
||||
|
||||
// --------------------------------
|
||||
|
||||
|
||||
// --------------------------------
|
||||
// View prototype for shared functionality
|
||||
|
||||
function View() {
|
||||
}
|
||||
|
||||
View.prototype = {
|
||||
|
||||
_updateFavicon: function pv__updateFavicon(aItem, aUri) {
|
||||
if ("string" == typeof aUri) {
|
||||
aUri = makeURI(aUri);
|
||||
}
|
||||
PlacesUtils.favicons.getFaviconURLForPage(aUri, this._gotIcon.bind(this, aItem));
|
||||
},
|
||||
|
||||
_gotIcon: function pv__gotIcon(aItem, aIconUri) {
|
||||
if (!aIconUri) {
|
||||
aItem.removeAttribute("iconURI");
|
||||
if (aItem.refresh) {
|
||||
aItem.refresh();
|
||||
}
|
||||
return;
|
||||
}
|
||||
if ("string" == typeof aIconUri) {
|
||||
aIconUri = makeURI(aIconUri);
|
||||
}
|
||||
aItem.iconSrc = aIconUri.spec;
|
||||
let faviconURL = (PlacesUtils.favicons.getFaviconLinkForIcon(aIconUri)).spec;
|
||||
let xpFaviconURI = makeURI(faviconURL.replace("moz-anno:favicon:",""));
|
||||
let successAction = function(foreground, background) {
|
||||
aItem.style.color = foreground; //color text
|
||||
aItem.setAttribute("customColor", background);
|
||||
if (aItem.refresh) {
|
||||
aItem.refresh();
|
||||
}
|
||||
};
|
||||
let failureAction = function() {};
|
||||
ColorUtils.getForegroundAndBackgroundIconColors(xpFaviconURI, successAction, failureAction);
|
||||
}
|
||||
|
||||
};
|
@ -6,6 +6,7 @@
|
||||
|
||||
EXTRA_JS_MODULES += [
|
||||
'CrossSlide.jsm',
|
||||
'View.jsm',
|
||||
'colorUtils.jsm',
|
||||
]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user