mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-23 21:17:52 +00:00
bug=325169 r=brettw@gmail.com keywords=fixed1.8.1 Fix Livemark icons
This commit is contained in:
parent
ad3cd7df06
commit
ec83762d22
@ -519,7 +519,12 @@ var PlacesController = {
|
||||
*/
|
||||
nodeIsRemoteContainer: function PC_nodeIsRemoteContainer(node) {
|
||||
const NHRN = Ci.nsINavHistoryResultNode;
|
||||
return node.type == NHRN.RESULT_TYPE_REMOTE_CONTAINER;
|
||||
if (node.type == NHRN.RESULT_TYPE_REMOTE_CONTAINER)
|
||||
return true;
|
||||
if (node.type == NHRN.RESULT_TYPE_FOLDER)
|
||||
return asFolder(node).folderType != "";
|
||||
|
||||
return false;
|
||||
},
|
||||
|
||||
/**
|
||||
|
@ -92,7 +92,6 @@
|
||||
element.setAttribute("label", child.title);
|
||||
element.setAttribute("url", child.QueryInterface(Ci.nsINavHistoryURIResultNode).uri);
|
||||
element.setAttribute("statustext", child.url);
|
||||
element.setAttribute("image", child.icon.spec);
|
||||
element.className = "menuitem-iconic bookmark-item";
|
||||
}
|
||||
else if (PlacesController.nodeIsContainer(child)) {
|
||||
@ -115,6 +114,8 @@
|
||||
element.node = child;
|
||||
this.appendChild(element);
|
||||
}
|
||||
if (child.icon)
|
||||
element.setAttribute("image", child.icon.spec);
|
||||
}
|
||||
} else {
|
||||
var bundle = document.getElementById("placeBundle");
|
||||
@ -202,7 +203,7 @@
|
||||
|
||||
<property name="browserWindow" onget="return window;"/>
|
||||
|
||||
<property name="filterTransactions">false</property>
|
||||
<field name="filterTransactions">false</field>
|
||||
|
||||
<field name="supportedDropTypes">
|
||||
[TYPE_X_MOZ_PLACE_CONTAINER, TYPE_X_MOZ_PLACE, TYPE_X_MOZ_URL]
|
||||
|
@ -54,7 +54,7 @@
|
||||
|
||||
<field name="_chevron">null</field>
|
||||
<method name="_rebuild">
|
||||
<body><![CDATA[
|
||||
<body><![CDATA[
|
||||
while (this.hasChildNodes())
|
||||
this.removeChild(this.firstChild);
|
||||
const XULNS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
|
||||
@ -66,7 +66,6 @@
|
||||
if (PlacesController.nodeIsURI(child)) {
|
||||
child = child.QueryInterface(Ci.nsINavHistoryURIResultNode);
|
||||
button.setAttribute("url", child.uri);
|
||||
button.setAttribute("image", child.icon.spec);
|
||||
} else if (PlacesController.nodeIsContainer(child)) {
|
||||
button.setAttribute("type", "menu");
|
||||
button.setAttribute("container", "true");
|
||||
@ -79,6 +78,8 @@
|
||||
popup._result = this._result;
|
||||
popup._resultNode = child;
|
||||
}
|
||||
if (child.icon)
|
||||
button.setAttribute("image", child.icon.spec);
|
||||
button.className = "menuitem-iconic bookmark-item";
|
||||
button.node = child;
|
||||
this.appendChild(button);
|
||||
@ -231,23 +232,20 @@
|
||||
if(PlacesController.nodeIsFolder(this.selectedNode)) {
|
||||
// If there is a folder selected, the insertion point is the
|
||||
// end of the folder.
|
||||
dump("Selected node is folder. ");
|
||||
folderId = this.selectedNode.QueryInterface(Ci.nsINavHistoryFolderResultNode).folderId;
|
||||
} else {
|
||||
// If there is another type of node selected, the insertion point
|
||||
// is after that node.
|
||||
dump("Selected node is node. ");
|
||||
index = PlacesController.getIndexOfNode(this.selectedNode)
|
||||
}
|
||||
}
|
||||
dump("setting insertion point to index " + index + " folderId " + folderId + "\n");
|
||||
return new InsertionPoint(folderId, index);
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<property name="browserWindow" onget="return window;"/>
|
||||
|
||||
<property name="filterTransactions">false</property>
|
||||
<field name="filterTransactions">false</field>
|
||||
|
||||
<field name="supportedDropTypes">
|
||||
[TYPE_X_MOZ_PLACE_CONTAINER, TYPE_X_MOZ_PLACE, TYPE_X_MOZ_URL]
|
||||
@ -267,50 +265,57 @@
|
||||
<field name="_observer"><![CDATA[({
|
||||
_numBatches: 0,
|
||||
_self: this,
|
||||
_batchedOperation: false,
|
||||
onBeginUpdateBatch: function TB_O_onBeginUpdateBatch() {
|
||||
++this._numBatches;
|
||||
},
|
||||
onEndUpdateBatch: function TB_O_onEndUpdateBatch() {
|
||||
if (!--this._numBatches)
|
||||
this._self.init();
|
||||
if (!--this._numBatches && this._batchedOperation)
|
||||
this.doRebuild();
|
||||
},
|
||||
onItemAdded: function TB_O_onItemAdded(bookmark, folder, index) {
|
||||
if (!this._numBatches)
|
||||
this._self.init();
|
||||
if (folder == this._self._bms.toolbarRoot)
|
||||
this._numBatches ? this._batchedOperation = true : this.doRebuild();
|
||||
},
|
||||
onItemRemoved: function TB_O_onItemRemoved(bookmark, folder, index) {
|
||||
if (!this._numBatches)
|
||||
this._self.init();
|
||||
if (folder == this._self._bms.toolbarRoot)
|
||||
this._numBatches ? this._batchedOperation = true : this.doRebuild();
|
||||
},
|
||||
onItemMoved: function TB_O_onItemMoved(bookmark, folder, oldIndex, newIndex) {
|
||||
if (!this._numBatches)
|
||||
this._self.init();
|
||||
if (folder == this._self._bms.toolbarRoot)
|
||||
this._numBatches ? this._batchedOperation = true : this.doRebuild();
|
||||
},
|
||||
onItemChanged: function TB_O_onItemChanged(bookmark, property, value) {
|
||||
if (!this._numBatches)
|
||||
this._self.init();
|
||||
this._numBatches ? this._batchedOperation = true : this.doRebuild();
|
||||
},
|
||||
onItemVisited: function TB_0_onItemVisited(bookmark, visitId, time) {
|
||||
//this._self.init();
|
||||
},
|
||||
onItemReplaced: function TB_0_onItemReplaced(filder, item, newItem) {
|
||||
// this._self.init();
|
||||
onItemReplaced: function TB_0_onItemReplaced(folder, item, newItem) {
|
||||
if (folder == this._self._bms.toolbarRoot)
|
||||
this._numBatches ? this._batchedOperation = true : this.doRebuild();
|
||||
},
|
||||
onFolderAdded: function TB_O_onFolderAdded(folder, parent, index) {
|
||||
if (!this._numBatches)
|
||||
this._self.init();
|
||||
if (folder == this._self._bms.toolbarRoot)
|
||||
this._numBatches ? this._batchedOperation = true : this.doRebuild();
|
||||
},
|
||||
onFolderRemoved: function TB_O_onFolderRemoved(folder, parent, index) {
|
||||
if (!this._numBatches)
|
||||
this._self.init();
|
||||
if (folder == this._self._bms.toolbarRoot)
|
||||
this._numBatches ? this._batchedOperation = true : this.doRebuild();
|
||||
},
|
||||
onFolderMoved: function TB_O_onFolderMoved(folder, oldParent, oldIndex, newParent, newIndex) {
|
||||
if (!this._numBatches)
|
||||
this._self.init();
|
||||
if (folder == this._self._bms.toolbarRoot)
|
||||
this._numBatches ? this._batchedOperation = true : this.doRebuild();
|
||||
},
|
||||
onFolderChanged: function TB_O_onFolderChanged(folder, property) {
|
||||
if (!this._numBatches)
|
||||
this._self.init();
|
||||
if (folder == this._self._bms.toolbarRoot)
|
||||
this._numBatches ? this._batchedOperation = true : this.doRebuild();
|
||||
},
|
||||
doRebuild: function TB_O_doRebuild() {
|
||||
function hitch(obj, meth) {
|
||||
return function() { meth.apply(obj, arguments); }
|
||||
}
|
||||
setTimeout(hitch(this._self, this._self._rebuild), 1);
|
||||
},
|
||||
})]]></field>
|
||||
<field name="_DNDObserver"><![CDATA[({
|
||||
|
@ -18,6 +18,7 @@ classic.jar:
|
||||
skin/classic/browser/places/query.png (skin-win/query.png)
|
||||
skin/classic/browser/places/bookmarks_menu.png (skin-win/bookmarks_menu.png)
|
||||
skin/classic/browser/places/bookmarks_toolbar.png (skin-win/bookmarks_toolbar.png)
|
||||
skin/classic/browser/places/livemark_item.png (skin-win/livemark_item.png)
|
||||
|
||||
en-US.jar:
|
||||
locale/browser/places/places.dtd (locale/places.dtd)
|
||||
|
@ -237,6 +237,7 @@ nsLivemarkLoadListener::OnStopRequest(nsIRequest *aRequest,
|
||||
//
|
||||
|
||||
// Try parsing as RDF
|
||||
mLivemarkService->BeginUpdateBatch();
|
||||
rv = TryParseAsRDF();
|
||||
|
||||
// Try parsing as Atom/Simple RSS
|
||||
@ -248,6 +249,7 @@ nsLivemarkLoadListener::OnStopRequest(nsIRequest *aRequest,
|
||||
if (!NS_SUCCEEDED(rv)) {
|
||||
rv = mLivemarkService->InsertLivemarkFailedItem(mLivemark->folderId);
|
||||
}
|
||||
mLivemarkService->EndUpdateBatch();
|
||||
|
||||
// Set an expiration on the livemark, for reloading the data
|
||||
PRInt32 ttl;
|
||||
|
@ -41,6 +41,7 @@
|
||||
#include "nsNavBookmarks.h"
|
||||
#include "nsNavHistoryResult.h"
|
||||
#include "nsIAnnotationService.h"
|
||||
#include "nsFaviconService.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "rdf.h"
|
||||
#include "nsIRDFService.h"
|
||||
@ -48,6 +49,7 @@
|
||||
|
||||
#define LIVEMARK_TIMEOUT 15000 // fire every 15 seconds
|
||||
#define PLACES_STRING_BUNDLE_URI "chrome://browser/locale/places/places.properties"
|
||||
#define LIVEMARK_ICON_URI "chrome://browser/skin/places/livemark_item.png"
|
||||
|
||||
// Constants for parsing RDF Livemarks
|
||||
// These are used in nsBookmarksFeedHandler.cpp, but because there is
|
||||
@ -122,6 +124,10 @@ nsLivemarkService::Init()
|
||||
getter_AddRefs(mBundle));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Initialize the folder icon uri.
|
||||
rv = NS_NewURI(getter_AddRefs(mIconURI), NS_LITERAL_STRING(LIVEMARK_ICON_URI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Initialize the localized strings for the names of the dummy
|
||||
// "livemark loading..." and "livemark failed to load" bookmarks
|
||||
rv = mBundle->GetStringFromName(NS_LITERAL_STRING("bookmarksLivemarkLoading").get(),
|
||||
@ -257,6 +263,11 @@ nsLivemarkService::CreateLivemark(PRInt64 aFolder,
|
||||
0,
|
||||
nsIAnnotationService::EXPIRE_NEVER);
|
||||
|
||||
// Set the icon for the livemark
|
||||
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
|
||||
NS_ENSURE_TRUE(faviconService, NS_ERROR_OUT_OF_MEMORY);
|
||||
faviconService->SetFaviconUrlForPage(livemarkURI, mIconURI);
|
||||
|
||||
if (aSiteURI) {
|
||||
// Add an annotation to map the folder URI to the livemark site URI
|
||||
nsCAutoString siteURISpec;
|
||||
@ -495,6 +506,22 @@ nsLivemarkService::DeleteLivemarkChildren(PRInt64 aLivemarkFolderId)
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLivemarkService::BeginUpdateBatch()
|
||||
{
|
||||
nsNavBookmarks *bookmarks = nsNavBookmarks::GetBookmarksService();
|
||||
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
|
||||
return bookmarks->BeginUpdateBatch();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLivemarkService::EndUpdateBatch()
|
||||
{
|
||||
nsNavBookmarks *bookmarks = nsNavBookmarks::GetBookmarksService();
|
||||
NS_ENSURE_TRUE(bookmarks, NS_ERROR_OUT_OF_MEMORY);
|
||||
return bookmarks->EndUpdateBatch();
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsLivemarkService::InsertLivemarkChild(PRInt64 aLivemarkFolderId,
|
||||
nsIURI *aURI,
|
||||
|
@ -61,6 +61,8 @@ public:
|
||||
|
||||
// These functions are called by the livemarks feed loader
|
||||
// to set the livemark children.
|
||||
nsresult BeginUpdateBatch();
|
||||
nsresult EndUpdateBatch();
|
||||
nsresult DeleteLivemarkChildren(PRInt64 aLivemarkFolderId);
|
||||
nsresult InsertLivemarkChild(PRInt64 aLivemarkFolderId,
|
||||
nsIURI *aURI,
|
||||
@ -105,6 +107,8 @@ private:
|
||||
nsXPIDLString mLivemarkLoading;
|
||||
nsXPIDLString mLivemarkFailed;
|
||||
|
||||
nsCOMPtr<nsIURI> mIconURI;
|
||||
|
||||
nsCOMPtr<nsIAnnotationService> mAnnotationService;
|
||||
nsCOMPtr<nsINavBookmarksService> mBookmarksService;
|
||||
|
||||
|
@ -108,6 +108,10 @@ nsNavHistoryResultNode::GetIcon(nsIURI** aURI)
|
||||
{
|
||||
nsFaviconService* faviconService = nsFaviconService::GetFaviconService();
|
||||
NS_ENSURE_TRUE(faviconService, NS_ERROR_NO_INTERFACE);
|
||||
if (mFaviconURI.IsEmpty()) {
|
||||
*aURI = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
return faviconService->GetFaviconLinkForIconString(mFaviconURI, aURI);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user