329269 various improvements to view initialization r=annie.sullivan@gmail.com 330736 - bug in query serialization r=brettw@gmail.com

This commit is contained in:
beng%bengoodger.com 2006-03-17 02:01:06 +00:00
Родитель 0fe291771c
Коммит 3618ce030e
18 изменённых файлов: 476 добавлений и 643 удалений

Просмотреть файл

@ -441,7 +441,7 @@
label="&bookmarksMenu.label;" accesskey="&bookmarksMenu.accesskey;"
ondragover="BookmarksEventHandler.onDragOver(event);">
<menupopup id="bookmarksMenuPopup"
type="places"
type="places" asyncinit="true"
place="place:&amp;folder=2&amp;group=3&amp;expandQueries=1"
context="placesContext"
openInTabs="children"

Просмотреть файл

@ -172,8 +172,10 @@
<command id="Tools:Sanitize" oncommand="gBrowserGlue.sanitize(window || null);"/>
#ifdef MOZ_PLACES
#include ../../components/places/content/commands.inc
<command id="Browser:ShowBookmarks" oncommand="PlacesCommandHook.showPlacesOrganizer('bookmarks');"/>
<command id="Browser:ShowHistory" oncommand="PlacesCommandHook.showPlacesOrganizer('history');"/>
<command id="Browser:ShowBookmarks"
oncommand="PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_BOOKMARKS);"/>
<command id="Browser:ShowHistory"
oncommand="PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_HISTORY);"/>
<command id="Browser:SearchHistory" oncommand="HistoryMenu.showPlacesSearch();"/>
<command id="Browser:ClearHistory" oncommand="HistoryMenu.clearHistory();"/>
#endif

Просмотреть файл

@ -865,10 +865,6 @@ function delayedStartup()
document.getElementById("PersonalToolbar")
.controllers.appendController(BookmarksMenuController);
#else
var bookmarksBar = document.getElementById("bookmarksBarContent");
bookmarksBar.init();
var bookmarksMenuPopup = document.getElementById("bookmarksMenuPopup");
bookmarksMenuPopup.init();
window.controllers.appendController(PlacesController);
#endif
@ -6376,13 +6372,24 @@ var PlacesCommandHook = {
/**
* Opens the Places Organizer.
* @param mode
* The mode to display the window with ("bookmarks" or "history").
* @param place
* The place to select in the organizer window (a place: URI)
*/
showPlacesOrganizer: function PCH_showPlacesOrganizer(mode) {
// TODO: check for an existing one and focus it instead.
openDialog("chrome://browser/content/places/places.xul",
"", "dialog=no,resizable", mode);
showPlacesOrganizer: function PCH_showPlacesOrganizer(place) {
var wm =
Cc["@mozilla.org/appshell/window-mediator;1"].
getService(Ci.nsIWindowMediator);
var organizer = wm.getMostRecentWindow("Places:Organizer");
if (!organizer) {
// No currently open places window, so open one with the specified mode.
openDialog("chrome://browser/content/places/places.xul",
"", "dialog=no,resizable", place);
}
else {
// Set the mode on an existing places window.
organizer.selectPlaceURI(place);
organizer.focus();
}
},
/**
@ -6434,7 +6441,7 @@ var HistoryMenu = {
showPlacesSearch: function PHM_showPlacesSearch() {
// XXX The places view needs to be updated before this
// does something different than show history.
PlacesCommandHook.showPlacesOrganizer("history");
PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_HISTORY);
},
/**
@ -6442,8 +6449,9 @@ var HistoryMenu = {
* (XXX This might be changed to show the Clear Private Data menu instead)
*/
clearHistory: function PHM_clearHistory() {
var globalHistory = Components.classes["@mozilla.org/browser/global-history;2"]
.getService(Components.interfaces.nsIBrowserHistory);
var globalHistory =
Cc["@mozilla.org/browser/global-history;2"].
getService(Ci.nsIBrowserHistory);
globalHistory.removeAllPages();
}
};

Просмотреть файл

@ -280,11 +280,11 @@
#ifdef MOZ_PLACES
<toolbarbutton id="bookmarksBarShowPlaces"
oncommand="PlacesCommandHook.showPlacesOrganizer('history');"/>
oncommand="PlacesCommandHook.showPlacesOrganizer(ORGANIZER_ROOT_HISTORY);"/>
<toolbaritem flex="1" id="personal-bookmarks" title="&bookmarksItem.title;">
<hbox id="bookmarksBarContent" flex="1" type="places"
place="place:&amp;folder=3&amp;group=3&amp;expandQueries=1"
context="placesContext"
context="placesContext" asyncinit="true"
onclick="BookmarksEventHandler.onClick(event);"
oncommand="BookmarksEventHandler.onCommand(event);"
onpopupshowing="BookmarksEventHandler.onPopupShowing(event);"/>

Просмотреть файл

@ -248,11 +248,9 @@ var BookmarkPropertiesPanel = {
this._controller = controller;
this.folderTree = this._dialogWindow.document.getElementById("folder-tree");
this.folderTree.controllers.appendController(this._controller);
this.folderTree.init(new ViewConfig([TYPE_X_MOZ_PLACE_CONTAINER],
ViewConfig.GENERIC_DROP_TYPES,
true, false, 4, true));
this.folderTree.loadFolder(this._bms.placesRoot);
this.folderTree.peerDropTypes = [];
this.folderTree.childDropTypes = [];
this.folderTree.excludeItems = true;
this._initAssignableFolderResult();
this._populateProperties();

Просмотреть файл

@ -79,6 +79,7 @@
class="placesTree"
flex="1"
type="places"
place="place:&amp;folder=1&amp;group=3&amp;excludeItems=1"
hidecolumnpicker="true"
seltype="multiple">
<treecols>

Просмотреть файл

@ -53,6 +53,11 @@ const SELECTION_IS_CHANGEABLE = 0x10;
const SELECTION_IS_REMOVABLE = 0x20;
const SELECTION_IS_MOVABLE = 0x40;
// These need to be kept in sync with the meaning of these roots in
// default_places.html!
const ORGANIZER_ROOT_HISTORY = "place:&beginTime=-2592000000000&beginTimeRef=1&endTime=7200000000&endTimeRef=2&sort=4&type=1";
const ORGANIZER_ROOT_BOOKMARKS = "place:&folder=2&group=3&excludeItems=1";
// Place entries that are containers, e.g. bookmark folders or queries.
const TYPE_X_MOZ_PLACE_CONTAINER = "text/x-moz-place-container";
// Place entries that are bookmark separators.
@ -85,8 +90,6 @@ const NEWLINE= "\n";
const NEWLINE = "\r\n";
#endif
const MENU_URI = "chrome://browser/content/places/menu.xml#places-menupopup";
function STACK(args) {
var temp = arguments.callee.caller;
while (temp) {
@ -115,23 +118,6 @@ function InsertionPoint(folderId, index, orientation) {
this.orientation = orientation;
}
/**
* Initialization Configuration for a View
* @constructor
*/
function ViewConfig(dropTypes, dropOnTypes, excludeItems,
expandQueries, firstDropIndex, filterTransactions) {
this.dropTypes = dropTypes;
this.dropOnTypes = dropOnTypes;
this.excludeItems = excludeItems;
this.expandQueries = expandQueries;
this.firstDropIndex = firstDropIndex;
this.filterTransactions = filterTransactions;
}
ViewConfig.GENERIC_DROP_TYPES = [TYPE_X_MOZ_PLACE_CONTAINER,
TYPE_X_MOZ_PLACE_SEPARATOR, TYPE_X_MOZ_PLACE,
TYPE_X_MOZ_URL];
/**
* Manages grouping options for a particular view type.
* @param pref
@ -223,6 +209,64 @@ function asFullVisit(node){ return QI_node(node, Ci.nsINavHistoryFullVisitResult
function asContainer(node){ return QI_node(node, Ci.nsINavHistoryContainerResultNode);}
function asQuery(node) { return QI_node(node, Ci.nsINavHistoryQueryResultNode); }
/**
* A View Configuration
*/
function ViewConfig(peerDropTypes, childDropTypes, excludeItems, expandQueries,
peerDropIndex) {
this.peerDropTypes = peerDropTypes;
this.childDropTypes = childDropTypes;
this.excludeItems = excludeItems;
this.expandQueries = expandQueries;
this.peerDropIndex = peerDropIndex;
}
ViewConfig.GENERIC_DROP_TYPES =
[TYPE_X_MOZ_PLACE_CONTAINER,
TYPE_X_MOZ_PLACE_SEPARATOR,
TYPE_X_MOZ_PLACE,
TYPE_X_MOZ_URL];
/**
* Configures Views, applying some meta-model rules. These rules are model-like,
* e.g. must apply everwhere a model is instantiated, but are not actually stored
* in the data model itself. For example, you can't drag leaf items onto the
* places root. This needs to be enforced automatically everywhere a view of
* that model is instantiated.
*/
var ViewConfigurator = {
rules: {
"folder=1": new ViewConfig([TYPE_X_MOZ_PLACE_CONTAINER],
ViewConfig.GENERIC_DROP_TYPES,
true, false, 4)
},
/**
* Applies rules to a specific view.
*/
configure: function PC_configure(view) {
// Determine what place the view is showing.
var place = view.place;
// Find a ruleset that matches the current place.
var rules = null;
for (var test in this.rules) {
if (place.indexOf(test) != -1) {
rules = this.rules[test];
break;
}
}
// If rules are found, apply them.
if (rules) {
view.peerDropTypes = rules.peerDropTypes;
view.childDropTypes = rules.childDropTypes;
view.excludeItems = rules.excludeItems;
view.expandQueries = rules.expandQueries;
view.peerDropIndex = rules.peerDropIndex;
}
}
};
/**
* The Master Places Controller
*/
@ -292,16 +336,6 @@ var PlacesController = {
return this._annotations;
},
/** UI Text Strings */
__strings: null,
get _strings() {
if (!this.__strings) {
this.__strings = document.getElementById("placeBundle");
}
return this.__strings;
},
/**
* Generates a HistoryResultNode for the contents of a folder.
* @param folderId
@ -328,20 +362,6 @@ var PlacesController = {
return asContainer(result.root);
},
/**
* Gets a place: URI for the given queries and options.
* @param queries
* An array of NavHistoryQueries
* @param options
* A NavHistoryQueryOptions object
* @returns A place: URI encoding the parameters.
*/
getPlaceURI: function PC_getPlaceURI(queries, options) {
var queryString = this.history.queriesToQueryString(queries, queries.length,
options);
return this._uri(queryString);
},
/**
* The currently active Places view.
*/
@ -367,20 +387,6 @@ var PlacesController = {
return this._tm;
},
/**
* The current groupable Places view. This is tracked independently of the
* |activeView| because the activeView may change to something that isn't
* groupable, but clicking the Grouping buttons should still work.
*/
_groupableView: null,
get groupableView() {
return this._groupableView;
},
set groupableView(groupableView) {
this._groupableView = groupableView;
return this._groupableView;
},
isCommandEnabled: function PC_isCommandEnabled(command) {
//LOG("isCommandEnabled: " + command);
if (command == "cmd_undo")
@ -459,7 +465,7 @@ var PlacesController = {
* view, false otherwise.
*/
_hasClipboardData: function PC__hasClipboardData() {
var types = this._activeView.supportedDropTypes;
var types = this._activeView.peerDropTypes;
var flavors =
Cc["@mozilla.org/supports-array;1"].
createInstance(Ci.nsISupportsArray);
@ -977,121 +983,6 @@ var PlacesController = {
}
},
/**
* Loads the contents of a query node into a view with the specified grouping
* and sort options.
* @param view
* The tree view to load the contents of the node into
* @param node
* The node to load the contents of
* @param groupings
* Groupings to be applied to the displayed contents, [] for no
* grouping
* @param sortingMode
* The sorting mode to be applied to the displayed contents.
*/
loadNodeIntoView: function PC_loadQueries(view, node, groupings, sortingMode) {
NS_ASSERT(view, "Must have a view to load node contents into!");
asQuery(node);
var queries = node.getQueries({ });
var newQueries = [];
for (var i = 0; i < queries.length; ++i) {
var query = queries[i].clone();
newQueries.push(query);
}
var newOptions = node.queryOptions.clone();
// Update the grouping mode only after persisting, so that the URI is not
// changed.
var e = new Error();
newOptions.setGroupingMode(groupings, groupings.length);
// Set the sort order of the results
newOptions.sortingMode = sortingMode;
// Reload the view
view.load(newQueries, newOptions);
},
/**
* A hash of groupers that supply grouping options for queries of a given
* type. This is an override of grouping options that might be encoded in
* a saved place: URI
*/
groupers: { },
/**
* Rebuilds the view using a new set of grouping options.
* @param groupings
* An array of grouping options, see nsINavHistoryQueryOptions
* for details.
* @param sortingMode
* The type of sort that should be applied to the results.
*/
setGroupingMode: function PC_setGroupingMode(groupings, sortingMode) {
if (!this._groupableView)
return;
var node = this._groupableView.getResult().root;
this.loadNodeIntoView(this._groupableView, node, groupings, sortingMode);
// Persist this selection
if (this._groupableView.isBookmarks && "bookmark" in this.groupers)
this.groupers.bookmark.value = groupings;
else if ("generic" in this.groupers)
this.groupers.generic.value = groupings;
},
/**
* Group the current content view by domain
*/
groupBySite: function PC_groupBySite() {
var groupings = [Ci.nsINavHistoryQueryOptions.GROUP_BY_DOMAIN];
var sortMode = Ci.nsINavHistoryQueryOptions.SORT_BY_TITLE_ASCENDING;
this.setGroupingMode(groupings, sortMode);
},
/**
* Group the current content view by folder
*/
groupByFolder: function PC_groupByFolder() {
var groupings = [Ci.nsINavHistoryQueryOptions.GROUP_BY_FOLDER];
var sortMode = Ci.nsINavHistoryQueryOptions.SORT_BY_NONE;
this.setGroupingMode(groupings, sortMode);
},
/**
* Ungroup the current content view (i.e. show individual pages)
*/
groupByPage: function PC_groupByPage() {
this.setGroupingMode([],
Ci.nsINavHistoryQueryOptions.SORT_BY_DATE_DESCENDING);
},
/**
* Loads all results matching a certain annotation, grouped and sorted as
* specified.
* @param annotation
* The annotation to match
* @param groupings
* The grouping to apply to the displayed results
* @param sortingMode
* The sorting to apply to the displayed results
*/
groupByAnnotation:
function PC_groupByAnnotation(annotation, groupings, sortingMode) {
NS_ASSERT(this._groupableView, "Need a groupable view to load!");
if (!this._groupableView)
return;
var query = this.history.getNewQuery();
var options = this.history.getNewQueryOptions();
options.setGroupingMode(groupings, groupings.length);
options.sortingMode = sortingMode;
query.annotation = annotation;
this.groupableView.load([query], options);
LOG("CS: " + this.history.queriesToQueryString([query], 1, options));
},
/**
* Create a new Bookmark folder somewhere. Prompts the user for the name
* of the folder.
@ -1647,9 +1538,9 @@ var PlacesControllerDragHelper = {
var session = this.getSession();
if (session) {
if (orientation != NHRVO.DROP_ON)
var types = view.supportedDropTypes;
var types = view.peerDropTypes;
else
types = view.supportedDropOnTypes;
types = view.childDropTypes;
for (var i = 0; i < types.length; ++i) {
if (session.isDataFlavorSupported(types[i]))
return true;
@ -1674,9 +1565,9 @@ var PlacesControllerDragHelper = {
Cc["@mozilla.org/widget/transferable;1"].
createInstance(Ci.nsITransferable);
if (orientation != NHRVO.DROP_ON)
var types = view.supportedDropTypes;
var types = view.peerDropTypes;
else
types = view.supportedDropOnTypes;
types = view.childDropTypes;
for (var j = 0; j < types.length; ++j)
xferable.addDataFlavor(types[j]);
return xferable;
@ -1738,8 +1629,6 @@ PlacesBaseTransaction.prototype = {
throw Cr.NS_ERROR_NOT_IMPLEMENTED;
},
pageTransaction: false,
get isTransient() {
return false;
},
@ -1756,8 +1645,6 @@ function PlacesAggregateTransaction(name, transactions) {
this._transactions = transactions;
this._name = name;
this.redoTransaction = this.doTransaction;
this.pageTransaction = PlacesController.activeView.filterTransactions;
NS_ASSERT(this.pageTransaction !== undefined, "Don't know if this transaction must be filtered");
}
PlacesAggregateTransaction.prototype = {
__proto__: PlacesBaseTransaction.prototype,
@ -1791,8 +1678,6 @@ function PlacesCreateFolderTransaction(name, container, index) {
this._index = index;
this._id = null;
this.redoTransaction = this.doTransaction;
this.pageTransaction = PlacesController.activeView.filterTransactions;
NS_ASSERT(this.pageTransaction !== undefined, "Don't know if this transaction must be filtered");
}
PlacesCreateFolderTransaction.prototype = {
__proto__: PlacesBaseTransaction.prototype,
@ -1816,8 +1701,6 @@ function PlacesCreateItemTransaction(uri, container, index) {
this._container = container;
this._index = index;
this.redoTransaction = this.doTransaction;
this.pageTransaction = PlacesController.activeView.filterTransactions;
NS_ASSERT(this.pageTransaction !== undefined, "Don't know if this transaction must be filtered");
}
PlacesCreateItemTransaction.prototype = {
__proto__: PlacesBaseTransaction.prototype,
@ -1866,8 +1749,6 @@ function PlacesMoveFolderTransaction(id, oldContainer, oldIndex, newContainer, n
this._newContainer = newContainer;
this._newIndex = newIndex;
this.redoTransaction = this.doTransaction;
this.pageTransaction = PlacesController.activeView.filterTransactions;
NS_ASSERT(this.pageTransaction !== undefined, "Don't know if this transaction must be filtered");
}
PlacesMoveFolderTransaction.prototype = {
__proto__: PlacesBaseTransaction.prototype,
@ -1893,8 +1774,6 @@ function PlacesMoveItemTransaction(uri, oldContainer, oldIndex, newContainer, ne
this._newContainer = newContainer;
this._newIndex = newIndex;
this.redoTransaction = this.doTransaction;
this.pageTransaction = PlacesController.activeView.filterTransactions;
NS_ASSERT(this.pageTransaction !== undefined, "Don't know if this transaction must be filtered");
}
PlacesMoveItemTransaction.prototype = {
__proto__: PlacesBaseTransaction.prototype,
@ -1951,8 +1830,6 @@ function PlacesRemoveFolderTransaction(id, oldContainer, oldIndex) {
this._oldFolderTitle = null;
this._contents = null; // The encoded contents of this folder
this.redoTransaction = this.doTransaction;
this.pageTransaction = PlacesController.activeView.filterTransactions;
NS_ASSERT(this.pageTransaction !== undefined, "Don't know if this transaction must be filtered");
}
PlacesRemoveFolderTransaction.prototype = {
__proto__: PlacesBaseTransaction.prototype,
@ -2030,8 +1907,6 @@ function PlacesRemoveItemTransaction(uri, oldContainer, oldIndex) {
this._oldContainer = oldContainer;
this._oldIndex = oldIndex;
this.redoTransaction = this.doTransaction;
this.pageTransaction = PlacesController.activeView.filterTransactions;
NS_ASSERT(this.pageTransaction !== undefined, "Don't know if this transaction must be filtered");
}
PlacesRemoveItemTransaction.prototype = {
__proto__: PlacesBaseTransaction.prototype,
@ -2039,13 +1914,11 @@ PlacesRemoveItemTransaction.prototype = {
doTransaction: function PRIT_doTransaction() {
LOG("Remove Item: " + this._uri.spec + " from: " + this._oldContainer + "," + this._oldIndex);
this.bookmarks.removeItem(this._oldContainer, this._uri);
LOG("DO: PAGETXN: " + this.pageTransaction);
},
undoTransaction: function PRIT_undoTransaction() {
LOG("UNRemove Item: " + this._uri.spec + " from: " + this._oldContainer + "," + this._oldIndex);
this.bookmarks.insertItem(this._oldContainer, this._uri, this._oldIndex);
LOG("UNDO: PAGETXN: " + this.pageTransaction);
}
};
@ -2078,8 +1951,6 @@ function PlacesEditFolderTransaction(id, oldAttributes, newAttributes) {
this._oldAttributes = oldAttributes;
this._newAttributes = newAttributes;
this.redoTransaction = this.doTransaction;
this.pageTransaction = PlacesController.activeView.filterTransactions;
NS_ASSERT(this.pageTransaction !== undefined, "Don't know if this transaction must be filtered");
}
PlacesEditFolderTransaction.prototype = {
__proto__: PlacesBaseTransaction.prototype,
@ -2103,8 +1974,6 @@ function PlacesEditItemTransaction(uri, newAttributes) {
this._newAttributes = newAttributes;
this._oldAttributes = { };
this.redoTransaction = this.doTransaction;
this.pageTransaction = PlacesController.activeView.filterTransactions;
NS_ASSERT(this.pageTransaction !== undefined, "Don't know if this transaction must be filtered");
}
PlacesEditItemTransaction.prototype = {
__proto__: PlacesBaseTransaction.prototype,
@ -2133,31 +2002,4 @@ PlacesEditItemTransaction.prototype = {
}
}
};
/*
AVI rules:
readonly attribute boolean hasSelection;
readonly attribute boolean hasSingleSelection;
readonly attribute boolean selectionIsContainer;
readonly attribute boolean containerIsOpen;
void getSelectedNodes([retval, array, size_is(nodeCount)] out nodes, out nodeCount);
selection flags
flags:
SELECTION_CONTAINS_URI
SELECTION_CONTAINS_CONTAINER_OPEN
SELECTION_CONTAINS_CONTAINER_CLOSED
SELECTION_CONTAINS_CHANGEABLE
SELECTION_CONTAINS_REMOVABLE
SELECTION_CONTAINS_MOVABLE
Given a:
- view, via AVI
- query
- query options
Determine the state of commands!
*/

Просмотреть файл

@ -10,39 +10,42 @@
extends="chrome://global/content/bindings/popup.xml#popup">
<implementation>
<constructor><![CDATA[
// this.init(); -- causes Ts regression on windows
// Support an asyncinit attribute that causes the view to populate
// itself only after the window has been shown. This is to ensure we
// do not regress browser window show time (Ts/Txul)
if (this.hasAttribute("asyncinit")) {
var self = this;
setTimeout(function() { self._init(); }, 0);
}
else
this._init();
this.history = PlacesController.history;
]]></constructor>
<destructor><![CDATA[
]]></destructor>
<method name="init">
<field name="history">null</field>
<method name="_init">
<body><![CDATA[
if (!this.hasAttribute("place"))
return;
// This function should only be called for top-level menus like the bookmarks menu.
// Submenus get their _result and _resultNode from their parents.
var hist =
Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
var queryString = this.getAttribute("place");
var queries = { }, options = { };
hist.queryStringToQueries(queryString, queries, { }, options);
if (!queries.value.length)
queries.value = [hist.getNewQuery()];
this._result = hist.executeQueries(queries.value, queries.value.length, options.value);
this._result.root.containerOpen = true;
this._resultNode = this._result.root;
this._rebuild();
if (this.hasAttribute("place")) {
// Do the initial build.
this.place = this.place;
}
]]></body>
</method>
<method name="onPopupShowing">
<body><![CDATA[
if (!this._resultNode)
this.init();
this._init();
if (PlacesController.nodeIsContainer(this._resultNode)) {
this._resultNode.QueryInterface(Ci.nsINavHistoryContainerResultNode);
this._resultNode.containerOpen = true;
@ -64,6 +67,8 @@
this._rebuild();
]]></body>
</method>
<!-- nsIPlacesView -->
<method name="getResult">
<body><![CDATA[
return this._result;
@ -196,8 +201,10 @@
// If this is a child of the bookmarks menubar, we have to manually attach
// its xbl binding, because it's not a dom node and the style rules don't
// get applied correctly.
if (needsBindingAttachment)
if (needsBindingAttachment) {
const MENU_URI = "chrome://browser/content/places/menu.xml#places-menupopup";
document.addBinding(popup, MENU_URI);
}
#endif
}
// else if (nodeIsQuery) ... add menu to build kids
@ -249,42 +256,63 @@
]]></body>
</method>
<property name="isBookmarks">
<getter><![CDATA[
return PlacesController.nodeIsFolder(this.getResult());
<!-- nsIPlacesView -->
<property name="place">
<getter><![CDATA[
return this.getAttribute("place");
]]></getter>
<setter><![CDATA[
this.setAttribute("place", val);
var queries = { }, options = { };
this.history.queryStringToQueries(val, queries, { }, options);
if (!queries.value.length)
queries.value = [this.history.getNewQuery()];
this._result =
this.history.executeQueries(queries.value, queries.value.length,
options.value);
this._resultNode = this._result.root;
if (this._resultNode.containerOpen)
this._rebuild();
return val;
]]></setter>
</property>
<!-- nsIPlacesView -->
<property name="hasSelection">
<getter><![CDATA[
return this._selection != null;
]]></getter>
</property>
<!-- nsIPlacesView -->
<property name="hasSingleSelection">
<getter><![CDATA[
return this.hasSelection;
]]></getter>
</property>
<!-- nsIPlacesView -->
<method name="getSelectionNodes">
<body><![CDATA[
return this.hasSelection ? [this.selectedNode] : [];
]]></body>
</method>
<!-- nsIPlacesView -->
<method name="getRemovableSelectionRanges">
<body><![CDATA[
return [this.getSelectionNodes()];
]]></body>
</method>
<!-- nsIPlacesView -->
<method name="getCopyableSelection">
<body><![CDATA[
return this.getSelectionNodes();
]]></body>
</method>
<!-- nsIPlacesView -->
<method name="getDragableSelection">
<body><![CDATA[
if (PlacesController.nodeIsReadOnly(this._resultNode))
@ -293,12 +321,14 @@
]]></body>
</method>
<!-- nsIPlacesView -->
<property name="selectedNode">
<getter><![CDATA[
return this.hasSelection ? this._selection : null;
]]></getter>
</property>
<!-- nsIPlacesView -->
<property name="selectedURINode">
<getter><![CDATA[
var node = this.selectedNode;
@ -306,6 +336,7 @@
]]></getter>
</property>
<!-- nsIPlacesView -->
<property name="insertionPoint">
<getter><![CDATA[
// By default, the insertion point is at the top level, at the end.
@ -329,16 +360,22 @@
]]></getter>
</property>
<field name="filterTransactions">false</field>
<!-- nsIPlacesView -->
<field name="peerDropIndex">0</field>
<field name="supportedDropTypes">
[TYPE_X_MOZ_PLACE_CONTAINER, TYPE_X_MOZ_PLACE_SEPARATOR, TYPE_X_MOZ_PLACE, TYPE_X_MOZ_URL]
</field>
<field name="supportedDropOnTypes">
[TYPE_X_MOZ_PLACE_CONTAINER, TYPE_X_MOZ_PLACE_SEPARATOR, TYPE_X_MOZ_PLACE, TYPE_X_MOZ_URL]
</field>
<!-- nsIPlacesView -->
<field name="peerDropTypes">ViewConfig.GENERIC_DROP_TYPES</field>
<!-- nsIPlacesView -->
<field name="childDropTypes">ViewConfig.GENERIC_DROP_TYPES</field>
<!-- nsIPlacesView -->
<field name="excludeItems">false</field>
<!-- nsIPlacesView -->
<field name="expandQueries">false</field>
<!-- nsIPlacesView -->
<method name="selectAll">
<body><![CDATA[
// Nothing

Просмотреть файл

@ -14,3 +14,8 @@ button {
.filterList {
-moz-binding: url("chrome://browser/content/places/places.xml#filter-button");
}
#contentTitle {
width: 0px;
}

Просмотреть файл

@ -12,10 +12,10 @@
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is Mozilla Places System.
* The Original Code is Mozilla Places Organizer.
*
* The Initial Developer of the Original Code is Google Inc.
* Portions created by the Initial Developer are Copyright (C) 2005
* Portions created by the Initial Developer are Copyright (C) 2005-2006
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
@ -35,60 +35,37 @@
*
* ***** END LICENSE BLOCK ***** */
#include ../../../../toolkit/content/debug.js
const PREF_PLACES_GROUPING_GENERIC = "browser.places.grouping.generic";
const PREF_PLACES_GROUPING_BOOKMARK = "browser.places.grouping.bookmark";
const XUL_NS = "http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul";
// Default Search Queries
const INDEX_HISTORY = 0;
const INDEX_BOOKMARKS = 1;
function GroupingConfig(substr, onLabel, onAccesskey, offLabel, offAccesskey,
onOncommand, offOncommand) {
this.substr = substr;
this.onLabel = onLabel;
this.onAccesskey = onAccesskey;
this.offLabel = offLabel;
this.offAccesskey = offAccesskey;
this.onOncommand = onOncommand;
this.offOncommand = offOncommand;
/**
* Selects a place URI in the places list.
* This function is global so it can be easily accessed by openers.
* @param placeURI
* A place: URI string to select
*/
function selectPlaceURI(placeURI) {
PlacesOrganizer._places.selectPlaceURI(placeURI);
}
var PlacesOrganizer = {
_content: null,
_places: null,
_content: null,
init: function PP_init() {
// Attach the Command Controller to the Places Views.
this._places = document.getElementById("placesList");
this._content = document.getElementById("placeContent");
this._places.controllers.appendController(PlacesController);
this._content.controllers.appendController(PlacesController);
this._places.init(new ViewConfig([TYPE_X_MOZ_PLACE_CONTAINER],
ViewConfig.GENERIC_DROP_TYPES,
true, false, 4, true));
this._content.init(new ViewConfig(ViewConfig.GENERIC_DROP_TYPES,
ViewConfig.GENERIC_DROP_TYPES,
false, false, 0, true));
PlacesController.groupableView = this._content;
Groupers.init();
// Attach the Places model to the Place View
// XXXben - move this to an attribute/property on the tree view
this._places.loadFolder(PlacesController.bookmarks.placesRoot);
// Now load the appropriate folder in the Content View, and select the
// corresponding entry in the Places View. This is a little fragile.
var params = "arguments" in window ? window.arguments[0] : "history";
var index = params == "history" ? INDEX_HISTORY : INDEX_BOOKMARKS;
this._places.view.selection.select(index);
// Select the specified place in the places list.
var placeURI = "place:";
if ("arguments" in window)
placeURI = window.arguments[0];
selectPlaceURI(placeURI);
// Set up the search UI.
PlacesSearchBox.init();
@ -96,43 +73,11 @@ var PlacesOrganizer = {
PlacesQueryBuilder.init();
},
/**
* A range has been selected from the calendar picker. Update the view
* to show only those results within the selected range.
*/
rangeSelected: function PP_rangeSelected() {
var result = this._content.getResult();
var queries = this.getCurrentQueries();
var calendar = document.getElementById("historyCalendar");
var begin = calendar.beginrange.getTime();
var end = calendar.endrange.getTime();
// The calendar restuns values in terms of whole days at midnight, inclusive.
// The end time range therefor must be moved to the evening of the end
// include that day in the query.
const DAY_MSEC = 86400000;
end += DAY_MSEC;
var newQueries = [];
for (var i = 0; i < queries.length; ++i) {
var query = queries[i].clone();
query.beginTimeReference = Ci.nsINavHistoryQuery.TIME_RELATIVE_EPOCH;
query.beginTime = begin * 1000;
query.endTimeReference = Ci.nsINavHistoryQuery.TIME_RELATIVE_EPOCH;
query.endTime = end * 1000;
newQueries.push(query);
}
this._content.load(newQueries, this.getCurrentOptions());
return true;
},
/**
* Fill the header with information about what view is being displayed.
*/
_setHeader: function(type, text) {
_setHeader: function PP__setHeader(type, text) {
var bundle = document.getElementById("placeBundle");
var key = null;
var isSearch = false;
@ -187,13 +132,9 @@ var PlacesOrganizer = {
var node = asQuery(this._places.selectedNode);
if (!node)
return;
var sortingMode = node.queryOptions.sortingMode;
var groupings = [Ci.nsINavHistoryQueryOptions.GROUP_BY_DOMAIN];
if (PlacesController.nodeIsFolder(node))
groupings = [Ci.nsINavHistoryQueryOptions.GROUP_BY_FOLDER];
PlacesController.loadNodeIntoView(this._content, node, groupings,
sortingMode);
LOG("NODEURI: " + node.uri);
this._content.place = node.uri;
Groupers.setGroupingOptions(this._content.getResult(), true);
@ -219,92 +160,6 @@ var PlacesOrganizer = {
PlacesController.groupByAnnotation("livemark/bookmarkFeedURI", [], 0);
},
/**
* Updates the calendar widget to show the range of dates selected in the
* current result.
*/
_updateCalendar: function PP__updateCalendar() {
var calendar = document.getElementById("historyCalendar");
var result = this._content.getResult();
if (result.root.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY)
result.root.QueryInterface(Ci.nsINavHistoryQueryResultNode);
else if (result.root.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_FOLDER)
result.root.QueryInterface(Ci.nsINavHistoryFolderResultNode);
else {
calendar.selectNothing = true;
return;
}
var queries = this.getCurrentQueries();
// if there is more than one query, make sure that they all specify the
// same date range. If there isn't a unique date range, don't display
// anything.
if (queries.length < 1) {
calendar.selectNothing = true;
return;
}
var absBegin = queries[0].absoluteBeginTime;
var absEnd = queries[0].absoluteEndTime;
for (var i = 1; i < queries.length; i ++) {
if (queries[i].absoluteBeginTime != absBegin ||
queries[i].absoluteEndTime != absEnd) {
calendar.selectNothing = true;
return;
}
}
var query = queries[0];
// Make sure that by updating the calendar widget we don't fire selection
// events and cause the UI to infinitely reload.
calendar.suppressRangeEvents = true;
// begin
var beginRange = null;
if (query.hasBeginTime)
beginRange = new Date(query.absoluteBeginTime / 1000);
// end
var endRange = null;
if (query.hasEndTime) {
endRange = new Date(query.absoluteEndTime / 1000);
// here, we have to do a little work. Normally a day query will start
// at midnight and end exactly 24 hours later. However, this spans two
// actual days, and will show up as such in the calendar. Therefore, if
// the end day is exactly midnight, we will bump it back a day.
if (endRange.getHours() == 0 && endRange.getMinutes() == 0 &&
endRange.getSeconds() == 0 && endRange.getMilliseconds() == 0) {
// Here, we have to be careful to not set the end range to before the
// beginning. Somebody stupid might set them to be the same, and we
// don't want to suddenly make an invalid range.
if (! beginRange ||
(beginRange && beginRange.getTime() != endRange.getTime()))
endRange.setTime(endRange.getTime() - 1);
}
}
calendar.setRange(beginRange, endRange, true);
// Allow user selection events once again.
calendar.suppressRangeEvents = false;
},
/**
* Update the Places UI when the content of the right tree changes.
*/
onContentChanged: function PP_onContentChanged() {
var isBookmarks = this._content.isBookmarks;
// Hide the Calendar for Bookmark queries.
document.getElementById("historyCalendar").setAttribute("hidden", isBookmarks);
// Update the calendar with the current date range, if applicable.
if (!isBookmarks) {
this._updateCalendar();
}
},
/**
* Returns the query array associated with the query currently loaded in
* the main places pane.
@ -775,7 +630,8 @@ var PlacesQueryBuilder = {
var options = PlacesOrganizer.getCurrentOptions();
options.resultType = options.RESULT_TYPE_URI;
PlacesOrganizer._content.load(queries, options);
// XXXben - find some public way of doing this!
PlacesOrganizer._content._load(queries, options);
}
};
@ -1015,10 +871,27 @@ var ViewMenu = {
}
};
function GroupingConfig(substr, onLabel, onAccesskey, offLabel, offAccesskey,
onOncommand, offOncommand) {
this.substr = substr;
this.onLabel = onLabel;
this.onAccesskey = onAccesskey;
this.offLabel = offLabel;
this.offAccesskey = offAccesskey;
this.onOncommand = onOncommand;
this.offOncommand = offOncommand;
}
/**
* Handles Grouping within the Content View, and the commands that support it.
*/
var Groupers = {
defaultGrouper: null,
annotationGroupers: [],
/**
* Initializes groupings for various vie types.
*/
init: function G_init() {
var placeBundle = document.getElementById("placeBundle");
this.defaultGrouper =
@ -1037,7 +910,14 @@ var Groupers = {
"PlacesOrganizer.groupByPost()");
this.annotationGroupers.push(subscriptionConfig);
},
/**
* Updates the grouping broadcasters for the given result.
* @param result
*
* @param on
*
*/
setGroupingOptions: function G_setGroupingOptions(result, on) {
var node = asQuery(result.root);
@ -1091,3 +971,5 @@ var Groupers = {
}
}
};
#include ../../../../toolkit/content/debug.js

Просмотреть файл

@ -11,7 +11,7 @@
<!DOCTYPE window SYSTEM "chrome://browser/locale/places/places.dtd">
<window id="places" title="&places.title;"
windowtype="Places"
windowtype="Places:Organizer"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
onload="PlacesOrganizer.init();"
width="700" height="500" screenX="10" screenY="10"
@ -30,10 +30,15 @@
<stringbundle id="placeBundle" src="chrome://browser/locale/places/places.properties"/>
<stringbundle id="brandBundle" src="chrome://branding/locale/brand.properties"/>
</stringbundleset>
#include commands.inc
<keyset id="placesKeyset">
<keyset id="placesOrganizerKeyset">
<!-- Instantiation Keys -->
<key id="placesKey_close" key="&cmd.close.key;" modifiers="accel"
oncommand="close();"/>
<!-- Command Keys -->
<key id="placesKey_find" command="placesCmd_find" key="&cmd.find.key;" modifiers="accel"/>
<key id="placesKey_select:all" command="placesCmd_select:all" key="&cmd.select_all.key;" modifiers="accel"/>
<key id="placesKey_edit:cut" command="placesCmd_edit:cut" key="&cmd.edit_cut.key;" modifiers="accel"/>
@ -42,10 +47,10 @@
<key id="placesKey_edit:delete" command="placesCmd_edit:delete" keycode="VK_DELETE"/>
<key id="placesKey_open" command="placesCmd_open" keycode="VK_ENTER"/>
<key id="placesKey_open:window" command="placesCmd_open:window" keycode="VK_ENTER" modifiers="shift"/>
<key id="placesKey_open:tab" oncommand="placesCmd_open:tab" keycode="VK_ENTER" modifiers="accel"/>
<key id="placesKey_show:info" oncommand="placesCmd_show:info" key="&cmd.show_info.key;" modifiers="accel"/>
<key id="placesKey_rename" oncommand="placesCmd_rename" keycode="VK_F2"/>
<key id="placesKey_reload" oncommand="placesCmd_reload" key="&cmd.reload.key;" modifiers="accel"/>
<key id="placesKey_open:tab" command="placesCmd_open:tab" keycode="VK_ENTER" modifiers="accel"/>
<key id="placesKey_show:info" command="placesCmd_show:info" key="&cmd.show_info.key;" modifiers="accel"/>
<key id="placesKey_rename" command="placesCmd_rename" keycode="VK_F2"/>
<key id="placesKey_reload" command="placesCmd_reload" key="&cmd.reload.key;" modifiers="accel"/>
</keyset>
<popupset id="placesPopupset">
@ -157,25 +162,19 @@
</toolbar>
</toolbox>
<hbox flex="1" id="placesView">
<vbox>
<vbox id="placesListContainer" flex="1">
<tree id="placesList" class="placesTree" flex="1" type="places"
hidecolumnpicker="true" context="placesContext"
onselect="PlacesOrganizer.onPlaceSelected(event);"
seltype="single">
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>
</treecols>
<treechildren id="placesListChildren" view="placesList" flex="1"/>
</tree>
</vbox>
<vbox id="historyCalendar"
class="history-calendar"
onselectionchanged="return PlacesOrganizer.rangeSelected()"/>
</vbox>
<tree id="placesList" class="placesTree" flex="1" type="places"
place="place:&amp;folder=1&amp;group=3&amp;excludeItems=1"
hidecolumnpicker="true" context="placesContext"
onselect="PlacesOrganizer.onPlaceSelected(event);"
seltype="single">
<treecols>
<treecol id="title" flex="1" primary="true" hideheader="true"/>
</treecols>
<treechildren id="placesListChildren" view="placesList" flex="1"/>
</tree>
<splitter id="splitter"/>
<vbox flex="4">
<deck id="content" flex="1">
<vbox id="contentView" flex="4">
<deck id="contentDeck" flex="1">
<vbox flex="1">
<hbox id="titlebar" align="center">
<label id="showingPrefix"/>
@ -204,9 +203,8 @@
</hbox>
#include advancedSearch.inc
<tree id="placeContent" class="placesTree" context="placesContext"
flex="1" query="" type="places"
ondblclick="PlacesController.mouseLoadURI(event);"
onplacestreereloaded="PlacesOrganizer.onContentChanged();">
flex="1" type="places"
ondblclick="PlacesController.mouseLoadURI(event);">
<treecols id="placeContentColumns">
<treecol label="&col.title.label;" id="title" flex="5" primary="true"
persist="width hidden ordinal sortActive sortDirection"/>

Просмотреть файл

@ -48,14 +48,22 @@
<implementation>
<constructor><![CDATA[
// this.init(); -- causes Ts regression on windows
// Support an asyncinit attribute that causes the view to populate
// itself only after the window has been shown. This is to ensure we
// do not regress browser window show time (Ts/Txul)
if (this.hasAttribute("asyncinit")) {
var self = this;
setTimeout(function() { self._init(); }, 0);
}
else
this._init();
]]></constructor>
<destructor><![CDATA[
this._bms.removeObserver(this._observer);
]]></destructor>
<method name="init">
<method name="_init">
<body><![CDATA[
this._places =
Cc["@mozilla.org/browser/nav-history-service;1"].
@ -69,15 +77,11 @@
window.addEventListener("resize",
function f(e) { t.updateChevron(e); },
false);
var queryString = this.getAttribute("place");
var queries = { }, options = { };
this._places.queryStringToQueries(queryString, queries, { }, options);
if (!queries.value.length)
queries.value = [this._places.getNewQuery()];
this._result = this._places.executeQueries(queries.value, queries.value.length, options.value);
this._result.root.containerOpen = true;
this._rebuild();
if (this.hasAttribute("place")) {
// Do the initial build.
this.place = this.place;
}
]]></body>
</method>
@ -89,6 +93,8 @@
<field name="_openedMenuButton">null</field>
<field name="_result">null</field>
<!-- nsIPlacesView -->
<method name="getResult">
<body><![CDATA[
return this._result;
@ -207,53 +213,63 @@
]]></body>
</method>
<method name="load">
<parameter name="queries"/>
<parameter name="options"/>
<body><![CDATA[
this._result = this._places.executeQueries(queries, queries.length,
options);
<!-- nsIPlacesView -->
<property name="place">
<getter><![CDATA[
return this.getAttribute("place");
]]></getter>
<setter><![CDATA[
this.setAttribute("place", val);
var queries = { }, options = { };
this._places.queryStringToQueries(val, queries, { }, options);
if (!queries.value.length)
queries.value = [this._places.getNewQuery()];
this._result =
this._places.executeQueries(queries.value, queries.value.length,
options.value);
this._result.root.containerOpen = true;
this._rebuild();
]]></body>
</method>
<property name="isBookmarks">
<getter><![CDATA[
return PlacesController.nodeIsFolder(this.getResult());
]]></getter>
return val;
]]></setter>
</property>
<!-- nsIPlacesView -->
<property name="hasSelection">
<getter><![CDATA[
return this._selection != null;
]]></getter>
</property>
<!-- nsIPlacesView -->
<property name="hasSingleSelection">
<getter><![CDATA[
return this.hasSelection;
]]></getter>
</property>
<!-- nsIPlacesView -->
<method name="getSelectionNodes">
<body><![CDATA[
return this.hasSelection ? [this.selectedNode] : [];
]]></body>
</method>
<!-- nsIPlacesView -->
<method name="getRemovableSelectionRanges">
<body><![CDATA[
return [this.getSelectionNodes()];
]]></body>
</method>
<!-- nsIPlacesView -->
<method name="getCopyableSelection">
<body><![CDATA[
return this.getSelectionNodes();
]]></body>
</method>
<!-- nsIPlacesView -->
<method name="getDragableSelection">
<body><![CDATA[
if (PlacesController.nodeIsReadOnly(this._result.root))
@ -262,12 +278,14 @@
]]></body>
</method>
<!-- nsIPlacesView -->
<property name="selectedNode">
<getter><![CDATA[
return this.hasSelection ? this._selection : null;
]]></getter>
</property>
<!-- nsIPlacesView -->
<property name="selectedURINode">
<getter><![CDATA[
var node = this.selectedNode;
@ -275,6 +293,7 @@
]]></getter>
</property>
<!-- nsIPlacesView -->
<property name="insertionPoint">
<getter><![CDATA[
// By default, the insertion point is at the top level, at the end.
@ -296,16 +315,22 @@
]]></getter>
</property>
<field name="filterTransactions">false</field>
<!-- nsIPlacesView -->
<field name="peerDropIndex">0</field>
<field name="supportedDropTypes">
[TYPE_X_MOZ_PLACE_CONTAINER, TYPE_X_MOZ_PLACE_SEPARATOR, TYPE_X_MOZ_PLACE, TYPE_X_MOZ_URL]
</field>
<field name="supportedDropOnTypes">
[TYPE_X_MOZ_PLACE_CONTAINER, TYPE_X_MOZ_PLACE_SEPARATOR, TYPE_X_MOZ_PLACE, TYPE_X_MOZ_URL]
</field>
<!-- nsIPlacesView -->
<field name="peerDropTypes">ViewConfig.GENERIC_DROP_TYPES</field>
<!-- nsIPlacesView -->
<field name="childDropTypes">ViewConfig.GENERIC_DROP_TYPES</field>
<!-- nsIPlacesView -->
<field name="excludeItems">false</field>
<!-- nsIPlacesView -->
<field name="expandQueries">false</field>
<!-- nsIPlacesView -->
<method name="selectAll">
<body><![CDATA[
// Nothing
@ -340,7 +365,7 @@
this._numBatches ? this._batchedOperation = true : this.doRebuild();
},
onItemVisited: function TB_0_onItemVisited(bookmark, visitId, time) {
//this._self.init();
//this._self._init();
},
onItemReplaced: function TB_0_onItemReplaced(folder, item, newItem) {
if (folder == this._self._bms.toolbarRoot)

Просмотреть файл

@ -9,51 +9,17 @@
<binding id="places-tree" extends="chrome://global/content/bindings/tree.xml#tree">
<implementation implements="nsINavHistoryResultViewObserver">
<constructor><![CDATA[
this._places =
Cc["@mozilla.org/browser/nav-history-service;1"].
getService(Ci.nsINavHistoryService);
// Apply meta-model rules to this view.
ViewConfigurator.configure(this);
this.history = PlacesController.history;
this.controllers.appendController(PlacesController);
// Force an initial build.
this.place = this.place;
]]></constructor>
<method name="init">
<parameter name="viewConfig"/>
<body><![CDATA[
this.supportedDropTypes = viewConfig.dropTypes;
this.supportedDropOnTypes = viewConfig.dropOnTypes;
this.excludeItems = viewConfig.excludeItems;
this.firstDropIndex = viewConfig.firstDropIndex;
this.filterTransactions = viewConfig.filterTransactions;
]]></body>
</method>
<method name="_fireEvent">
<parameter name="name"/>
<body><![CDATA[
var event = document.createEvent("events");
event.initEvent("placestree-" + name, false, true);
var canceled = !this.dispatchEvent(event);
var handler = this.getAttribute("onplacestree" + name);
if (handler != "") {
var fn = new Function("event", handler);
if (!fn(event))
canceled = true;
}
return !canceled;
]]></body>
</method>
<!-- AVI Method -->
<method name="getResult">
<body><![CDATA[
try {
return this.view.QueryInterface(Ci.nsINavHistoryResult);
}
catch (e) {
return null;
}
]]></body>
</method>
<field name="history">null</field>
<!-- overriding -->
<property name="view">
@ -76,7 +42,7 @@
// existing ones or create new ones.
var options = this.getResult().queryOptions;
if (!options)
options = this._places.getNewQueryOptions();
options = this.history.getNewQueryOptions();
return options;
]]></body>
</method>
@ -89,10 +55,10 @@
return null;
]]></getter>
<setter><![CDATA[
var query = this._places.getNewQuery();
var query = this.history.getNewQuery();
query.searchTerms = val;
this.load([query], this.getBestOptions());
this._load([query], this.getBestOptions());
return val;
]]></setter>
</property>
@ -105,90 +71,160 @@
// preserve grouping
var options = this.getResult().queryOptions;
if (!options)
options = this._places.getNewQueryOptions();
options = this.history.getNewQueryOptions();
var query = this._places.getNewQuery();
var query = this.history.getNewQuery();
query.searchTerms = filterString;
query.onlyBookmarked = onlyBookmarks;
//if (onlyBookmarks)
// query.setFolders(folderRestrict, folderRestrict.length);
this.load([query], this.getBestOptions());
this._load([query], this.getBestOptions());
]]></body>
</method>
<property name="queryString">
<getter><![CDATA[
var result = this.getResult();
var queries = result.root.getQueries({ });
var options = result.root.queryOptions;
const NH = Ci.nsINavHistoryService;
return this._places.queriesToQueryString(queries, queries.length,
options);
]]></getter>
<setter><![CDATA[
var queries = { }, options = { };
this._places.queryStringToQueries(val, queries, { }, options);
if (!queries.value.length)
queries.value = [this._places.getNewQuery()];
this.load(queries.value, options.value);
return val;
]]></setter>
</property>
<method name="loadFolder">
<parameter name="folderId"/>
<body><![CDATA[
var query = this._places.getNewQuery();
query.setFolders([folderId], 1);
var options = this._places.getNewQueryOptions();
options.setGroupingMode([Ci.nsINavHistoryQueryOptions.GROUP_BY_FOLDER], 1);
options.excludeItems = this.excludeItems;
options.expandQueries = false;
var result = this._places.executeQuery(query, options);
result.QueryInterface(Ci.nsITreeView);
this.view = result;
this._fireEvent("reloaded");
]]></body>
</method>
<method name="load">
<!-- XXXben I would like to remove this method from the "public" interface -->
<method name="_load">
<parameter name="queries"/>
<parameter name="options"/>
<body><![CDATA[
// override with our local options
options.excludeItems = this.excludeItems;
options.expandQueries = false;
var result = this._places.executeQueries(queries, queries.length,
options.expandQueries = this.expandQueries;
var result = this.history.executeQueries(queries, queries.length,
options);
result.QueryInterface(Ci.nsITreeView);
this.view = result;
this._fireEvent("reloaded");
this.view = result.QueryInterface(Ci.nsITreeView);
]]></body>
</method>
<property name="isBookmarks">
<getter><![CDATA[
return PlacesController.nodeIsFolder(this.getResult().root);
<!--
Causes a particular node represented by the specified placeURI to be
selected in the tree. All containers above the node in the hierarchy
will be opened, so that the node is visible.
-->
<method name="selectPlaceURI">
<parameter name="placeURI"/>
<body><![CDATA[
function findNode(container, placeURI) {
container.containerOpen = true;
for (var i = 0; i < container.childCount; ++i) {
var child = container.getChild(i);
if (child.uri == placeURI)
return child;
else if (PlacesController.nodeIsContainer(child)) {
var nested = findNode(asContainer(child), placeURI);
if (nested)
return nested;
}
}
container.containerOpen = false;
return null;
}
var result = this.getResult();
NS_ASSERT(result, "no result, cannot select place URI!");
if (!result)
return;
var container = asContainer(result.root);
var child = findNode(container, placeURI);
container.containerOpen = true;
if (child)
this.selectNode(child);
else {
// If the specified child could not be located, just select the first
// item in the list.
if (this.view.rowCount)
this.view.selection.select(0);
}
]]></body>
</method>
<!--
Causes a particular node to be selected in the tree, resulting in all
containers above the node in the hierarchy to be opened, so that the
node is visible.
-->
<method name="selectNode">
<parameter name="node"/>
<body><![CDATA[
var parent = node.parent;
// Build a list of all of the nodes that are the parent of this one
// in the result.
var parents = [];
var result = this.getResult();
while (parent && parent != asContainer(result.root)) {
parents.push(parent);
parent = parent.parent;
}
// Walk the list backwards (opening from the root of the hierarchy)
// opening each folder as we go.
var result = this.getResult();
var view = this.view;
for (var i = parents.length - 1; i >= 0; --i) {
var index = result.treeIndexForNode(parents[i]);
if (view.isContainer(index) && !view.isContainerOpen(index))
view.toggleOpenState(index);
}
// Select the specified node...
index = result.treeIndexForNode(node);
view.selection.select(index);
// ... and ensure it's visible, not scrolled off somewhere.
this.treeBoxObject.ensureRowIsVisible(index);
]]></body>
</method>
<!-- nsIPlacesView -->
<method name="getResult">
<body><![CDATA[
try {
return this.view.QueryInterface(Ci.nsINavHistoryResult);
}
catch (e) {
}
return null;
]]></body>
</method>
<!-- nsIPlacesView -->
<property name="place">
<getter><![CDATA[
return this.getAttribute("place");
]]></getter>
<setter><![CDATA[
this.setAttribute("place", val);
var queriesRef = { };
var queryCountRef = { };
var optionsRef = { };
this.history.queryStringToQueries(val, queriesRef, queryCountRef, optionsRef);
if (queryCountRef.value == 0)
queriesRef.value = [this.history.getNewQuery()];
if (!optionsRef.value)
optionsRef.value = this.history.getNewQueryOptions();
this._load(queriesRef.value, optionsRef.value);
return val;
]]></setter>
</property>
<!-- AVI Method -->
<!-- nsIPlacesView -->
<property name="hasSelection">
<getter><![CDATA[
return this.view.selection.count >= 1;
]]></getter>
</property>
<!-- AVI Method -->
<!-- nsIPlacesView -->
<property name="hasSingleSelection">
<getter><![CDATA[
return this.view.selection.count == 1;
]]></getter>
</property>
<!-- AVI Method -->
<!-- nsIPlacesView -->
<method name="getSelectionNodes">
<body><![CDATA[
var selection = this.view.selection;
@ -206,6 +242,7 @@
]]></body>
</method>
<!-- nsIPlacesView -->
<method name="getRemovableSelectionRanges">
<body><![CDATA[
// This function exists in addition to getSelectionNodes because it
@ -257,13 +294,15 @@
]]></body>
</method>
<!-- AVI Method -->
<!-- nsIPlacesView -->
<method name="getCopyableSelection">
<body><![CDATA[
// XXXben implement me!
return this.getSelectionNodes();
]]></body>
</method>
<!-- nsIPlacesView -->
<method name="getDragableSelection">
<body><![CDATA[
var nodes = this.getSelectionNodes();
@ -275,7 +314,7 @@
]]></body>
</method>
<!-- AVI Method -->
<!-- nsIPlacesView -->
<property name="selectedNode">
<getter><![CDATA[
var view = this.view;
@ -290,7 +329,7 @@
]]></getter>
</property>
<!-- AVI Method -->
<!-- nsIPlacesView -->
<property name="selectedURINode">
<getter><![CDATA[
var view = this.view;
@ -309,7 +348,7 @@
]]></getter>
</property>
<!-- AVI Method -->
<!-- nsIPlacesView -->
<property name="insertionPoint">
<getter><![CDATA[
var selection = this.view.selection;
@ -331,8 +370,8 @@
var cc = container.childCount;
for (var i = 0; i < cc; ++i) {
if (container.getChild(i) == node &&
i < this.firstDropIndex) {
max.value = this.firstDropIndex;
i < this.peerDropIndex) {
max.value = this.peerDropIndex;
orientation = NHRVO.DROP_BEFORE;
break;
}
@ -372,25 +411,22 @@
]]></body>
</method>
<!-- AVI Method -->
<property name="filterTransactions">true</property>
<!-- nsIPlacesView -->
<field name="peerDropIndex">0</field>
<!-- AVI Method -->
<field name="firstDropIndex">0</field>
<!-- nsIPlacesView -->
<field name="peerDropTypes">ViewConfig.GENERIC_DROP_TYPES</field>
<!-- AVI Method -->
<field name="supportedDropTypes">null</field>
<!-- nsIPlacesView -->
<field name="childDropTypes">ViewConfig.GENERIC_DROP_TYPES</field>
<!-- AVI Method -->
<field name="supportedDropOnTypes">null</field>
<!-- nsIPlacesView -->
<field name="excludeItems">false</field>
<!-- AVI Method -->
<field name="excludeQueries">null</field>
<!-- AVI Method -->
<field name="dropOnFilterOptions">null</field>
<!-- nsIPlacesView -->
<field name="expandQueries">false</field>
<!-- AVI Method -->
<!-- nsIPlacesView -->
<method name="selectAll">
<body><![CDATA[
this.view.selection.selectAll();
@ -430,7 +466,7 @@
var treeIndex = this.getResult().treeIndexForNode(nodes[i]);
if (this.view.getLevel(treeIndex) == 0) {
var index = PlacesController.getIndexOfNode(nodes[i]);
if (index < this.firstDropIndex)
if (index < this.peerDropIndex)
throw Cr.NS_OK;
}
}
@ -477,8 +513,8 @@
<method name="getSupportedFlavours">
<body><![CDATA[
var flavorSet = new FlavourSet();
for (var i = 0; i < this.supportedDropTypes.length; ++i)
flavorSet.appendFlavour(this.supportedDropTypes[i]);
for (var i = 0; i < this.peerDropTypes.length; ++i)
flavorSet.appendFlavour(this.peerDropTypes[i]);
return flavorSet;
]]></body>
</method>
@ -544,7 +580,7 @@
var node = index != -1 ? result.nodeForTreeIndex(index) : result.root;
// Cannot drop before fixed items in the list.
if (node.parent == result.root &&
PlacesController.getIndexOfNode(node) < this._self.firstDropIndex &&
PlacesController.getIndexOfNode(node) < this._self.peerDropIndex &&
orientation != NHRVO.DROP_ON)
return false;

Просмотреть файл

@ -1234,8 +1234,8 @@ AppendInt64KeyValueIfNonzero(nsACString& aString,
NS_ASSERTION(NS_SUCCEEDED(rv), "Failure getting value");
if (value) {
AppendAmpersandIfNonempty(aString);
nsCAutoString appendMe(aName);
appendMe.Append(aName);
aString += aName;
nsCAutoString appendMe("=");
appendMe.AppendInt(value);
aString.Append(appendMe);
}

Просмотреть файл

@ -6,7 +6,7 @@
<TITLE>Bookmarks and History</TITLE>
<H1 PLACES_ROOT="true">Bookmarks and History</H1>
<DL><p>
<DT><A HREF="place:beginTime=0&beginTimeRef=1&endTime=0&endTimeRef=2&sort=4&type=1">History</A>
<DT><A HREF="place:&beginTime=-2592000000000&beginTimeRef=1&endTime=7200000000&endTimeRef=2&sort=4&type=1">History</A>
<DD>Shows all browsing history
<DT><H3 BOOKMARKS_MENU="true">Bookmarks Menu</H3>
<DD>Add bookmarks to this folder to see them displayed on the Bookmarks Menu

Просмотреть файл

@ -8,6 +8,8 @@
"Close">
<!ENTITY file.close.accesskey
"C">
<!ENTITY cmd.close.key
"w">
<!ENTITY edit.label
"Edit">
<!ENTITY edit.accesskey

Просмотреть файл

@ -6,7 +6,7 @@
<TITLE>Bookmarks and History</TITLE>
<H1 PLACES_ROOT="true">Bookmarks and History</H1>
<DL><p>
<DT><A HREF="place:beginTime=0&beginTimeRef=1&endTime=0&endTimeRef=2&sort=4&type=1">History</A>
<DT><A HREF="place:&beginTime=-2592000000000&beginTimeRef=1&endTime=7200000000&endTimeRef=2&sort=4&type=1">History</A>
<DD>Shows all browsing history
<DT><H3 BOOKMARKS_MENU="true">Bookmarks Menu</H3>
<DL><p>

Просмотреть файл

@ -15,15 +15,9 @@
}
#placesList {
-moz-appearance: none;
width: 160px;
margin: 0px;
border: 0px;
}
#placesListContainer {
-moz-appearance: listbox;
margin: 6px 0px 7px 6px;
width: 160px;
}
#placeContent {
@ -31,14 +25,17 @@
border: 0px;
}
#content {
#contentView {
margin: 6px 6px 7px 0px;
-moz-appearance: listbox;
}
treechildren::-moz-tree-image(title, container) {
treechildren::-moz-tree-image {
padding-right: 2px;
margin: 0px 2px;
}
treechildren::-moz-tree-image(title, container) {
list-style-image: url("chrome://global/skin/icons/folder-item.png") !important;
-moz-image-region: rect(0px, 16px, 16px, 0px);
}