- bug 172113: rewrite the way we handle the bookmarks toolbar folder. Now, there is no more 2 ways to characterize the BTF: by an arc to the resource "...#BookmarksToolbarFolder" that points to the literal "true". As a consequence, the resource NC:PersonalToolbarFolder and "...#folderType" are dead.

- remove unused functions. Note that RDF commands were already broken, so deleteBookmarkItem and insertBookmarkItem (that were not used) may come back, but in another form.
- remove the "New Bookmark Folder" and "New Search Folder"
- refactor the "html" serializer to avoid some duplicated code.
- remove the use of the profile name for the bookmarks root.
- enforce synthax "aArgument" in some random places.
This commit is contained in:
chanial%noos.fr 2003-10-03 20:30:14 +00:00
parent 7cbbfcd12f
commit a8253ec478
12 changed files with 343 additions and 832 deletions

View File

@ -7,7 +7,7 @@ Do Not Edit! -->
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 PERSONAL_TOOLBAR_FOLDER="true" ID="NC:PersonalToolbarFolder">Bookmarks Toolbar Folder</H3>
<DT><H3 PERSONAL_TOOLBAR_FOLDER="true">Bookmarks Toolbar Folder</H3>
<DD>Add bookmarks to this folder to see them displayed on the Bookmarks Toolbar
<DL><p>
<DT><A HREF="http://texturizer.net/firebird/index.html">Mozilla Firebird Help</A>

View File

@ -409,12 +409,13 @@ function delayedStartup()
}
#endif
// now load bookmarks after a delay
var hasRead = BMSVC.readBookmarks();
// now load bookmarks
BMSVC.readBookmarks();
var bt = document.getElementById("bookmarks-ptf");
if (bt) {
if (hasRead)
bt.builder.rebuild();
var btf = BMSVC.getBookmarksToolbarFolder().Value
bt.ref = btf;
document.getElementById("bookmarks-chevron").ref = btf;
bt.database.AddObserver(BookmarksToolbarRDFObserver);
}
window.addEventListener("resize", BookmarksToolbar.resizeFunc, false);

View File

@ -424,8 +424,7 @@
<hbox id="bookmarks-ptf" class="bookmarks-toolbar-items" contextmenu="bookmarks-context-menu"
flex="1" style="min-width:0px; width:0px;margin-left: 3px;"
datasources="rdf:bookmarks rdf:files rdf:localsearch"
template="bookmarks-template"
ref="NC:PersonalToolbarFolder" flags="dont-test-empty"
template="bookmarks-template" flags="dont-test-empty"
rdf:type="http://home.netscape.com/NC-rdf#Folder"
onpopupshowing="BookmarksMenu.showOpenInTabsMenuItem(event.target)"
onpopuphidden="BookmarksMenu.hideOpenInTabsMenuItem(event.target)"
@ -442,8 +441,7 @@
<toolbarbutton id="bookmarks-chevron" type="menu" class="chevron"
mousethrough="never" collapsed="true"
datasources="rdf:bookmarks rdf:files rdf:localsearch"
template="bookmarks-template"
ref="NC:PersonalToolbarFolder" flags="dont-test-empty"
template="bookmarks-template" flags="dont-test-empty"
onpopupshowing="BookmarksMenu.showOpenInTabsMenuItem(event.target)"
onpopuphidden="BookmarksMenu.hideOpenInTabsMenuItem(event.target)"
oncommand="BookmarksMenu.loadBookmark(event, event.target, this.database)"

View File

@ -879,21 +879,11 @@ var BookmarksController = {
case "cmd_bm_properties":
case "cmd_bm_rename":
return length == 1;
case "cmd_bm_setnewbookmarkfolder":
if (length != 1)
return false;
return item0 != "NC:NewBookmarkFolder" &&
(type0 == "Folder" || type0 == "PersonalToolbarFolder");
case "cmd_bm_setpersonaltoolbarfolder":
if (length != 1)
return false;
return item0 != "NC:PersonalToolbarFolder" &&
return item0 != "NC:PersonalToolbarFolder" &&
item0 != "NC:BookmarksRoot" && type0 == "Folder";
case "cmd_bm_setnewsearchfolder":
if (length != 1)
return false;
return item0 != "NC:NewSearchFolder" &&
(type0 == "Folder" || type0 == "PersonalToolbarFolder");
case "cmd_bm_movebookmark":
return length > 0 && !aSelection.containsImmutable;
default:
@ -1099,46 +1089,12 @@ var BookmarksUtils = {
if (type != "")
type = type.split("#")[1];
if (type == "Folder") {
if (this.isPersonalToolbarFolder(aResource))
if (aResource == BMSVC.getBookmarksToolbarFolder())
type = "PersonalToolbarFolder";
}
return type;
},
/////////////////////////////////////////////////////////////////////////////
// Returns true if aResource is the Personal Toolbar Folder
isPersonalToolbarFolder: function (aResource) {
return this.getProperty(aResource, NC_NS+"FolderType") == "NC:PersonalToolbarFolder";
},
/////////////////////////////////////////////////////////////////////////////
// Returns the folder which 'FolderType' is aProperty
getSpecialFolder: function (aProperty)
{
var sources = BMDS.GetSources(RDF.GetResource(NC_NS+"FolderType"),
RDF.GetResource(aProperty), true);
var folder = null;
if (sources.hasMoreElements())
folder = sources.getNext();
else
folder = RDF.GetResource("NC:BookmarksRoot");
return folder;
},
/////////////////////////////////////////////////////////////////////////////
// Returns the New Bookmark Folder
getNewBookmarkFolder: function()
{
return this.getSpecialFolder("NC:NewBookmarkFolder");
},
/////////////////////////////////////////////////////////////////////////////
// Returns the New Search Folder
getNewSearchFolder: function()
{
return this.getSpecialFolder("NC:NewSearchFolder");
},
/////////////////////////////////////////////////////////////////////////////
// Returns the container of a given container
getParentOfContainer: function(aChild)

View File

@ -151,7 +151,7 @@ var BookmarksMenu = {
var item;
switch (aNode.id) {
case "bookmarks-ptf":
item = "NC:PersonalToolbarFolder";
item = BMSVC.getBookmarksToolbarFolder().Value;
break;
case "bookmarks-menu":
item = "NC:BookmarksRoot";
@ -179,14 +179,14 @@ var BookmarksMenu = {
var item, parent, index;
switch (aNode.id) {
case "bookmarks-ptf":
parent = "NC:PersonalToolbarFolder";
parent = BMSVC.getBookmarksToolbarFolder().Value;
item = BookmarksToolbar.getLastVisibleBookmark();
break;
case "bookmarks-menu":
parent = "NC:BookmarksRoot";
break;
case "bookmarks-chevron":
parent = "NC:PersonalToolbarFolder";
parent = BMSVC.getBookmarksToolbarFolder().Value;
break;
default:
if (aOrientation == BookmarksUtils.DROP_ON)
@ -226,7 +226,7 @@ var BookmarksMenu = {
case "bookmarks-chevron":
case "bookmarks-stack":
case "bookmarks-toolbar":
return "NC:PersonalToolbarFolder";
return BMSVC.getBookmarksToolbarFolder().Value;
case "bookmarks-menu":
return "NC:BookmarksRoot";
default:
@ -880,6 +880,13 @@ var BookmarksToolbarRDFObserver =
{
onAssert: function (aDataSource, aSource, aProperty, aTarget)
{
if (aProperty.Value == NC_NS+"BookmarksToolbarFolder") {
var bt = document.getElementById("bookmarks-ptf");
if (bt) {
bt.ref = aSource.Value;
document.getElementById("bookmarks-chevron").ref = aSource.Value;
}
}
this.setOverflowTimeout(aSource, aProperty);
},
onUnassert: function (aDataSource, aSource, aProperty, aTarget)
@ -896,7 +903,8 @@ var BookmarksToolbarRDFObserver =
{
if (this._overflowTimerInEffect)
return;
if (aSource.Value != "NC:PersonalToolbarFolder" || aProperty.Value == NC_NS+"LastModifiedDate")
if (aSource != BMSVC.getBookmarksToolbarFolder()
|| aProperty.Value == NC_NS+"LastModifiedDate")
return;
this._overflowTimerInEffect = true;
setTimeout(BookmarksToolbar.resizeFunc, 0);

View File

@ -50,7 +50,7 @@ function showDescription()
gResource = RDF.GetResource(window.arguments[0]);
if (BookmarksUtils.isPersonalToolbarFolder(gResource)) {
if (gResource == BMSVC.getBookmarksToolbarFolder()) {
var description = BookmarksUtils.getLocaleString("description_PersonalToolbarFolder");
var box = document.getElementById("description-box");
box.hidden = false;

View File

@ -528,7 +528,6 @@
return;
}
}
var browserTarget = BookmarksUtils.getBrowserTargetFromEvent(aEvent);
BookmarksCommand.openBookmark(selection, browserTarget, this.db);
]]></body>
@ -819,7 +818,7 @@
onkeypress="event.preventBubble();"/>
<vbox flex="1">
<tree anonid="bookmarks-tree" flex="1" class="plain" enableColumnDrag="true"
datasources="rdf:bookmarks rdf:internetsearch rdf:localsearch" ref="NC:BookmarksTopRoot" flags="dont-build-content"
datasources="rdf:bookmarks rdf:files rdf:localsearch" ref="NC:BookmarksTopRoot" flags="dont-build-content"
onkeypress="if (event.keyCode == 13) this.parentNode.parentNode.openItemKey();"
onclick="this.parentNode.parentNode.openItemClick(event, 1);"
ondblclick="this.parentNode.parentNode.openItemClick(event, 2);"
@ -918,7 +917,7 @@
onclick="event.preventBubble();"
onkeypress="event.preventBubble();"/>
<tree anonid="bookmarks-tree" flex="1" class="plain" hidecolumnpicker="true"
datasources="rdf:bookmarks rdf:internetsearch rdf:localsearch" ref="NC:BookmarksRoot" flags="dont-build-content"
datasources="rdf:bookmarks rdf:files rdf:localsearch" ref="NC:BookmarksRoot" flags="dont-build-content"
onselect="this.parentNode.treeBoxObject.view.selectionChanged();" seltype="single">
<template xmlns:nc="http://home.netscape.com/NC-rdf#">
<rule rdf:type="http://home.netscape.com/NC-rdf#BookmarkSeparator">
@ -958,7 +957,7 @@
<xbl:content xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul" xmlns:xbl="http://www.mozilla.org/xbl">
<tree anonid="bookmarks-tree" flex="1" hidecolumnpicker="true"
xbl:inherits="rows,seltype"
datasources="rdf:bookmarks rdf:internetsearch rdf:localsearch" ref="NC:BookmarksTopRoot" flags="dont-build-content"
datasources="rdf:bookmarks rdf:files rdf:localsearch" ref="NC:BookmarksTopRoot" flags="dont-build-content"
onselect="this.parentNode.treeBoxObject.view.selectionChanged();">
<template>
<rule iscontainer="true">

View File

@ -76,7 +76,8 @@ bookmarks_title = Bookmarks Manager
file_in = File in "%S"
bookmarks_root = Bookmarks for %S
BookmarksRoot = Bookmarks
BookmarksToolbarFolder = Bookmarks Toolbar Folder
status_foldercount = %S object(s)
WebPageUpdated = The following web page has been updated:
@ -97,7 +98,6 @@ FindTitle = Find: %S %S '%S' in %S
ImportedIEFavorites = Imported IE Favorites
ImportedIEStaticFavorites = Imported IE Favorites
ImportedNetPositiveBookmarks = Imported NetPositive Bookmarks
DefaultPersonalToolbarFolder = Personal Toolbar Folder
SelectImport = Import bookmark file:
EnterExport = Export bookmark file:

View File

@ -77,6 +77,9 @@ interface nsIBookmarksService : nsISupports
nsIRDFResource cloneResource(in nsIRDFResource aSource);
nsIRDFResource getBookmarksToolbarFolder();
void setBookmarksToolbarFolder(in nsIRDFResource aSource);
void updateBookmarkIcon(in string aURL, in wstring aIconURL);
void removeBookmarkIcon(in string aURL, in wstring aIconURL);

View File

@ -38,7 +38,6 @@ REQUIRES = xpcom \
nkcache \
uconv \
pref \
profile \
dom \
intl \
webshell \

File diff suppressed because it is too large Load Diff

View File

@ -88,7 +88,6 @@ protected:
PRUint32 htmlSize;
PRInt32 mUpdateBatchNest;
nsXPIDLString mPersonalToolbarName;
nsXPIDLString mBookmarksRootName;
PRBool mBookmarksAvailable;
PRBool mDirty;
PRBool mBrowserIcons;
@ -128,6 +127,17 @@ protected:
PRInt32 level,
nsCOMArray<nsIRDFResource>& parentArray);
nsresult WriteBookmarkIdAndName(nsIRDFDataSource *aDs,
nsIOutputStream* aStrm,
nsIRDFResource *aNode);
nsresult WriteBookmarkProperties(nsIRDFDataSource *aDs,
nsIOutputStream* aStrm,
nsIRDFResource *aNode,
nsIRDFResource *aProperty,
const char *aHtmlAttrib,
PRBool aIsFirst);
nsresult SerializeBookmarks(nsIURI* aURI);
nsresult GetTextForNode(nsIRDFNode* aNode, nsString& aResult);
@ -136,26 +146,11 @@ protected:
nsresult UpdateBookmarkLastModifiedDate(nsIRDFResource *aSource);
nsresult WriteBookmarkProperties(nsIRDFDataSource *ds,
nsIOutputStream* strm,
nsIRDFResource *node,
nsIRDFResource *property,
const char *htmlAttrib,
PRBool isFirst);
PRBool CanAccept(nsIRDFResource* aSource, nsIRDFResource* aProperty, nsIRDFNode* aTarget);
nsresult getArgumentN(nsISupportsArray *arguments, nsIRDFResource *res,
PRInt32 offset, nsIRDFNode **argValue);
nsresult insertBookmarkItem(nsIRDFResource *src,
nsISupportsArray *aArguments,
nsIRDFResource *objType);
nsresult deleteBookmarkItem(nsIRDFResource *src,
nsISupportsArray *aArguments,
PRInt32 parentArgIndex);
nsresult setFolderHint(nsIRDFResource *src, nsIRDFResource *objType);
nsresult getFolderViaHint(nsIRDFResource *src, PRBool fallbackFlag,