зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 79f299fc10d6
This commit is contained in:
Родитель
fe8fdd5f03
Коммит
616b7eed72
|
@ -422,7 +422,7 @@ var gSanitizePromptDialog = {
|
|||
|
||||
var view = gContiguousSelectionTreeHelper.setTree(this.placesTree,
|
||||
new PlacesTreeView());
|
||||
result.addObserver(view, false);
|
||||
result.viewer = view;
|
||||
this.initDurationDropdown();
|
||||
},
|
||||
|
||||
|
@ -529,8 +529,8 @@ var gSanitizePromptDialog = {
|
|||
*/
|
||||
unload: function ()
|
||||
{
|
||||
let result = this.placesTree.getResult();
|
||||
result.removeObserver(this.placesTree.view);
|
||||
var view = this.placesTree.view;
|
||||
view.QueryInterface(Ci.nsINavHistoryResultViewer).result.viewer = null;
|
||||
this.placesTree.view = null;
|
||||
},
|
||||
|
||||
|
|
|
@ -1109,21 +1109,20 @@ PlacesController.prototype = {
|
|||
* The dragstart event.
|
||||
*/
|
||||
setDataTransfer: function PC_setDataTransfer(aEvent) {
|
||||
let dt = aEvent.dataTransfer;
|
||||
let doCopy = ["copyLink", "copy", "link"].indexOf(dt.effectAllowed) != -1;
|
||||
|
||||
let result = this._view.getResult();
|
||||
let suppressNotificationsOld = result.suppressNotifications;
|
||||
if (!suppressNotificationsOld)
|
||||
result.suppressNotifications = true;
|
||||
var dt = aEvent.dataTransfer;
|
||||
var doCopy = ["copyLink", "copy", "link"].indexOf(dt.effectAllowed) != -1;
|
||||
|
||||
var result = this._view.getResult();
|
||||
var oldViewer = result.viewer;
|
||||
try {
|
||||
let nodes = this._view.getDraggableSelection();
|
||||
for (let i = 0; i < nodes.length; ++i) {
|
||||
result.viewer = null;
|
||||
var nodes = this._view.getDraggableSelection();
|
||||
|
||||
for (var i = 0; i < nodes.length; ++i) {
|
||||
var node = nodes[i];
|
||||
|
||||
function addData(type, index, overrideURI) {
|
||||
let wrapNode = PlacesUtils.wrapNode(node, type, overrideURI, doCopy);
|
||||
var wrapNode = PlacesUtils.wrapNode(node, type, overrideURI, doCopy);
|
||||
dt.mozSetDataAt(type, wrapNode, index);
|
||||
}
|
||||
|
||||
|
@ -1145,8 +1144,8 @@ PlacesController.prototype = {
|
|||
}
|
||||
}
|
||||
finally {
|
||||
if (!suppressNotificationsOld)
|
||||
result.suppressNotifications = false;
|
||||
if (oldViewer)
|
||||
result.viewer = oldViewer;
|
||||
}
|
||||
},
|
||||
|
||||
|
@ -1154,32 +1153,29 @@ PlacesController.prototype = {
|
|||
* Copy Bookmarks and Folders to the clipboard
|
||||
*/
|
||||
copy: function PC_copy() {
|
||||
let result = this._view.getResult();
|
||||
|
||||
let suppressNotificationsOld = result.suppressNotifications;
|
||||
if (!suppressNotificationsOld)
|
||||
result.suppressNotifications = true;
|
||||
|
||||
var result = this._view.getResult();
|
||||
var oldViewer = result.viewer;
|
||||
try {
|
||||
let nodes = this._view.getSelectionNodes();
|
||||
result.viewer = null;
|
||||
var nodes = this._view.getSelectionNodes();
|
||||
|
||||
let xferable = Cc["@mozilla.org/widget/transferable;1"].
|
||||
var xferable = Cc["@mozilla.org/widget/transferable;1"].
|
||||
createInstance(Ci.nsITransferable);
|
||||
let foundFolder = false, foundLink = false;
|
||||
let copiedFolders = [];
|
||||
let placeString, mozURLString, htmlString, unicodeString;
|
||||
var foundFolder = false, foundLink = false;
|
||||
var copiedFolders = [];
|
||||
var placeString, mozURLString, htmlString, unicodeString;
|
||||
placeString = mozURLString = htmlString = unicodeString = "";
|
||||
|
||||
for (let i = 0; i < nodes.length; ++i) {
|
||||
let node = nodes[i];
|
||||
for (var i = 0; i < nodes.length; ++i) {
|
||||
var node = nodes[i];
|
||||
if (this._shouldSkipNode(node, copiedFolders))
|
||||
continue;
|
||||
if (PlacesUtils.nodeIsFolder(node))
|
||||
copiedFolders.push(node);
|
||||
|
||||
function generateChunk(type, overrideURI) {
|
||||
let suffix = i < (nodes.length - 1) ? NEWLINE : "";
|
||||
let uri = overrideURI;
|
||||
var suffix = i < (nodes.length - 1) ? NEWLINE : "";
|
||||
var uri = overrideURI;
|
||||
|
||||
if (PlacesUtils.nodeIsLivemarkContainer(node))
|
||||
uri = PlacesUtils.livemarks.getFeedURI(node.itemId).spec
|
||||
|
@ -1220,8 +1216,8 @@ PlacesController.prototype = {
|
|||
}
|
||||
}
|
||||
finally {
|
||||
if (!suppressNotificationsOld)
|
||||
result.suppressNotifications = false;
|
||||
if (oldViewer)
|
||||
result.viewer = oldViewer;
|
||||
}
|
||||
},
|
||||
|
||||
|
|
|
@ -525,7 +525,7 @@
|
|||
if (this._result) {
|
||||
this._resultNode.containerOpen = false;
|
||||
this._resultNode = null;
|
||||
this._result.removeObserver(this._resultObserver);
|
||||
this._result.viewer = null;
|
||||
this._result = null;
|
||||
}
|
||||
]]></destructor>
|
||||
|
@ -692,8 +692,8 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsINavHistoryResultObserver -->
|
||||
<field name="_resultObserver"><![CDATA[({
|
||||
<!-- nsINavHistoryResultViewer -->
|
||||
<field name="_viewer"><![CDATA[({
|
||||
_self: this,
|
||||
|
||||
get result() {
|
||||
|
@ -701,19 +701,24 @@
|
|||
},
|
||||
|
||||
set result(val) {
|
||||
if (this._self._result)
|
||||
this._self._resultNode.containerOpen = false;
|
||||
// some methods (e.g. getURLsFromContainer) temporarily null out the
|
||||
// viewer when they do temporary changes to the view, this does _not_
|
||||
// call setResult(null), but then, we're called again with the result
|
||||
// object which is already set for this viewer. At that point,
|
||||
// we should do nothing.
|
||||
if (this._self._result != val) {
|
||||
if (this._self._result)
|
||||
this._self._resultNode.containerOpen = false;
|
||||
|
||||
this._self.parentNode._built = false;
|
||||
this._self._result = val;
|
||||
if (val) {
|
||||
this._self._resultNode = val.root;
|
||||
this._self._resultNode._DOMElement = this._self.parentNode;
|
||||
this._self.parentNode._built = false;
|
||||
this._self._result = val;
|
||||
if (val) {
|
||||
this._self._resultNode = val.root;
|
||||
this._self._resultNode._DOMElement = this._self.parentNode;
|
||||
}
|
||||
else
|
||||
this._self._resultNode = null;
|
||||
}
|
||||
else {
|
||||
this._self._resultNode = null;
|
||||
}
|
||||
|
||||
return val;
|
||||
},
|
||||
|
||||
|
@ -909,7 +914,7 @@
|
|||
queries.value.length,
|
||||
options.value);
|
||||
|
||||
result.addObserver(this._resultObserver, false);
|
||||
result.viewer = this._viewer;
|
||||
return val;
|
||||
]]></setter>
|
||||
</property>
|
||||
|
|
|
@ -102,7 +102,7 @@
|
|||
if (this._result) {
|
||||
this._resultNode.containerOpen = false;
|
||||
this._resultNode = null;
|
||||
this._result.removeObserver(this._resultObserver);
|
||||
this._result.viewer = null;
|
||||
this._result = null;
|
||||
}
|
||||
]]></destructor>
|
||||
|
@ -402,7 +402,7 @@
|
|||
var result =
|
||||
history.executeQueries(queries.value, queries.value.length,
|
||||
options.value);
|
||||
result.addObserver(this._resultObserver, false);
|
||||
result.viewer = this._viewer;
|
||||
}
|
||||
catch(ex) {
|
||||
// Invalid query, or had no results.
|
||||
|
@ -509,8 +509,8 @@
|
|||
]]></body>
|
||||
</method>
|
||||
|
||||
<!-- nsINavHistoryResultObserver -->
|
||||
<field name="_resultObserver"><![CDATA[({
|
||||
<!-- nsINavHistoryResultViewer -->
|
||||
<field name="_viewer"><![CDATA[({
|
||||
_self: this,
|
||||
|
||||
get result() {
|
||||
|
@ -518,20 +518,25 @@
|
|||
},
|
||||
|
||||
set result(val) {
|
||||
if (this._self._result)
|
||||
this._self._resultNode.containerOpen = false;
|
||||
// some methods (e.g. getURLsFromContainer) temporarily null out the
|
||||
// viewer when they do temporary changes to the view, this does _not_
|
||||
// call setResult(null), but then, we're called again with the result
|
||||
// object which is already set for this viewer. At that point,
|
||||
// we should do nothing.
|
||||
if (this._self._result != val) {
|
||||
if (this._self._result)
|
||||
this._self._resultNode.containerOpen = false;
|
||||
|
||||
this._self._result = val;
|
||||
if (val) {
|
||||
this._self._resultNode = val.root;
|
||||
this._self._resultNode._DOMElement = this._self;
|
||||
// This calls _rebuild through invalidateContainer.
|
||||
this._self._resultNode.containerOpen = true;
|
||||
this._self._result = val;
|
||||
if (val) {
|
||||
this._self._resultNode = val.root;
|
||||
this._self._resultNode._DOMElement = this._self;
|
||||
// This calls _rebuild through invalidateContainer.
|
||||
this._self._resultNode.containerOpen = true;
|
||||
}
|
||||
else
|
||||
this._self._resultNode = null;
|
||||
}
|
||||
else {
|
||||
this._self._resultNode = null;
|
||||
}
|
||||
|
||||
return val;
|
||||
},
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
// the viewer's reference to our treeBoxObject.
|
||||
var result = this.getResult();
|
||||
if (result) {
|
||||
result.removeObserver(this.view);
|
||||
result.viewer = null;
|
||||
result.root.containerOpen = false;
|
||||
}
|
||||
this.view = null;
|
||||
|
@ -122,22 +122,22 @@
|
|||
<parameter name="options"/>
|
||||
<body><![CDATA[
|
||||
// Cleanup old result if exists.
|
||||
let oldResult = this.getResult();
|
||||
var oldResult = this.getResult();
|
||||
if (oldResult)
|
||||
oldResult.root.containerOpen = false;
|
||||
|
||||
let result = PlacesUtils.history
|
||||
var result = PlacesUtils.history
|
||||
.executeQueries(queries, queries.length,
|
||||
options);
|
||||
var callback;
|
||||
if (this.flatList) {
|
||||
let onOpenFlatContainer = this.onOpenFlatContainer;
|
||||
var onOpenFlatContainer = this.onOpenFlatContainer;
|
||||
if (onOpenFlatContainer)
|
||||
callback = new Function("aContainer", onOpenFlatContainer);
|
||||
}
|
||||
|
||||
let treeView = new PlacesTreeView(this.flatList, callback);
|
||||
result.addObserver(treeView, false);
|
||||
var treeView = new PlacesTreeView(this.flatList, callback);
|
||||
result.viewer = treeView;
|
||||
this.view = treeView;
|
||||
if (!this._controller) {
|
||||
this._controller = new PlacesController(this);
|
||||
|
@ -278,7 +278,7 @@
|
|||
<method name="getResult">
|
||||
<body><![CDATA[
|
||||
try {
|
||||
return this.view.QueryInterface(Ci.nsINavHistoryResultObserver).result;
|
||||
return this.view.QueryInterface(Ci.nsINavHistoryResultViewer).result;
|
||||
}
|
||||
catch (e) {
|
||||
return null;
|
||||
|
@ -640,18 +640,12 @@
|
|||
return foundOne;
|
||||
}
|
||||
|
||||
// Disable notifications while looking for nodes.
|
||||
let result = this.getResult();
|
||||
let suppressNotificationsOld = result.suppressNotifications;
|
||||
if (!suppressNotificationsOld)
|
||||
result.suppressNotifications = true
|
||||
try {
|
||||
findNodes(this.getResultNode());
|
||||
}
|
||||
finally {
|
||||
if (!suppressNotificationsOld)
|
||||
result.suppressNotifications = false;
|
||||
}
|
||||
// Null the viewer while looking for nodes
|
||||
var result = this.getResult();
|
||||
var oldViewer = result.viewer;
|
||||
result.viewer = null;
|
||||
findNodes(this.getResultNode());
|
||||
result.viewer = oldViewer;
|
||||
|
||||
// For all the nodes we've found, highlight the corresponding
|
||||
// index in the tree.
|
||||
|
|
|
@ -63,7 +63,7 @@ PlacesTreeView.prototype = {
|
|||
|
||||
QueryInterface: function PTV_QueryInterface(aIID) {
|
||||
if (aIID.equals(Ci.nsITreeView) ||
|
||||
aIID.equals(Ci.nsINavHistoryResultObserver) ||
|
||||
aIID.equals(Ci.nsINavHistoryResultViewer) ||
|
||||
aIID.equals(Ci.nsINavHistoryResultTreeViewer) ||
|
||||
aIID.equals(Ci.nsISupports))
|
||||
return this;
|
||||
|
@ -591,7 +591,7 @@ PlacesTreeView.prototype = {
|
|||
return [this.COLUMN_TYPE_UNKNOWN, false];
|
||||
},
|
||||
|
||||
// nsINavHistoryResultObserver
|
||||
// nsINavHistoryResultViewer
|
||||
nodeInserted: function PTV_nodeInserted(aParentNode, aNode, aNewIndex) {
|
||||
NS_ASSERT(this._result, "Got a notification but have no result!");
|
||||
if (!this._tree || !this._result)
|
||||
|
@ -995,16 +995,22 @@ PlacesTreeView.prototype = {
|
|||
|
||||
get result() this._result,
|
||||
set result(val) {
|
||||
if (this._result)
|
||||
this._rootNode.containerOpen = false;
|
||||
// Some methods (e.g. getURLsFromContainer) temporarily null out the
|
||||
// viewer when they do temporary changes to the view, this does _not_
|
||||
// call setResult(null), but then, we're called again with the result
|
||||
// object which is already set for this viewer. At that point,
|
||||
// we should do nothing.
|
||||
if (this._result != val) {
|
||||
if (this._result)
|
||||
this._rootNode.containerOpen = false;
|
||||
|
||||
this._result = val;
|
||||
this._rootNode = val ? val.root : null;
|
||||
|
||||
// If the tree is not set yet, setTree will call finishInit.
|
||||
if (this._tree && val)
|
||||
this._finishInit();
|
||||
this._result = val;
|
||||
this._rootNode = val ? val.root : null;
|
||||
|
||||
// If the tree is not set yet, setTree will call finishInit.
|
||||
if (this._tree && val)
|
||||
this._finishInit();
|
||||
}
|
||||
return val;
|
||||
},
|
||||
|
||||
|
@ -1358,7 +1364,7 @@ PlacesTreeView.prototype = {
|
|||
// detach from result when we are detaching from the tree.
|
||||
// This breaks the reference cycle between us and the result.
|
||||
if (!aTree)
|
||||
this._result.removeObserver(this);
|
||||
this._result.viewer = null;
|
||||
}
|
||||
if (aTree)
|
||||
this._finishInit();
|
||||
|
|
|
@ -447,10 +447,12 @@ interface nsINavHistoryQueryResultNode : nsINavHistoryContainerResultNode
|
|||
/**
|
||||
* Allows clients to observe what is happening to a result as it updates itself
|
||||
* according to history and bookmark system events. Register this observer on a
|
||||
* result using nsINavHistoryResult::addObserver.
|
||||
* result using registerView
|
||||
*
|
||||
* @see nsINavHistoryResult for where this fits in
|
||||
*/
|
||||
[scriptable, uuid(9a229620-1faf-11df-8a39-0800200c9a66)]
|
||||
interface nsINavHistoryResultObserver : nsISupports
|
||||
[scriptable, uuid(af4ac418-a687-4775-8ffa-97c160196432)]
|
||||
interface nsINavHistoryResultViewer : nsISupports
|
||||
{
|
||||
/**
|
||||
* Called when 'aItem' is inserted into 'aParent' at index 'aNewIndex'.
|
||||
|
@ -648,7 +650,9 @@ interface nsINavHistoryResultObserver : nsISupports
|
|||
void sortingChanged(in unsigned short sortingMode);
|
||||
|
||||
/**
|
||||
* Called by the result when this observer is added.
|
||||
* Called by the result when this object is set using
|
||||
* nsINavHistoryResult.viewer. This will be set to NULL when the result
|
||||
* is being deallocated. This should not be set by other code.
|
||||
*/
|
||||
attribute nsINavHistoryResult result;
|
||||
};
|
||||
|
@ -665,8 +669,8 @@ interface nsINavHistoryResultObserver : nsISupports
|
|||
* object, attach it to a result, never attach it to a tree, and forget about
|
||||
* it, it will leak!
|
||||
*/
|
||||
[scriptable, uuid(f8b518c0-1faf-11df-8a39-0800200c9a66)]
|
||||
interface nsINavHistoryResultTreeViewer : nsINavHistoryResultObserver
|
||||
[scriptable, uuid(fa77e4e9-9fc8-45d2-9507-0fe4f0602505)]
|
||||
interface nsINavHistoryResultTreeViewer : nsINavHistoryResultViewer
|
||||
{
|
||||
/**
|
||||
* This allows you to get at the real node for a given row index. This is
|
||||
|
@ -693,8 +697,23 @@ interface nsINavHistoryResultTreeViewer : nsINavHistoryResultObserver
|
|||
|
||||
/**
|
||||
* The result of a history/bookmark query.
|
||||
*
|
||||
* Use the "root" element to access the children of this query.
|
||||
*
|
||||
* The basic design of the system is a model-view-controller. This result object
|
||||
* represents the model where the data is stored. External components
|
||||
* provide the view and controller which define how the data looks and how
|
||||
* interaction happens.
|
||||
* [RESULT]----->[viewer]----->[controller]
|
||||
* |
|
||||
* +-- nsINavHistoryResultViewer
|
||||
*
|
||||
* The result indicates to the view when something changes through the
|
||||
* nsINavHistoryResultViewer interface. The viewer is set through
|
||||
* the nsINavHistoryResult.viewer property.
|
||||
*/
|
||||
[scriptable, uuid(c2229ce3-2159-4001-859c-7013c52f7619)]
|
||||
|
||||
[scriptable, uuid(d1562f6f-8d5a-4042-8524-72f747a51b18)]
|
||||
interface nsINavHistoryResult : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -712,37 +731,13 @@ interface nsINavHistoryResult : nsISupports
|
|||
attribute AUTF8String sortingAnnotation;
|
||||
|
||||
/**
|
||||
* Whether or not notifications on result changes are suppressed.
|
||||
* Initially set to false.
|
||||
*
|
||||
* Use this to avoid flickering and to improve performance when you
|
||||
* do temporary changes to the result structure (e.g. when searching for a
|
||||
* node recursively).
|
||||
* The viewer for this result (see comment for the class for how these
|
||||
* objects are related). This may be null, in which case you can still
|
||||
* manually walk the tree using the root node. When this is non-null, you
|
||||
* can access the flattened list of items (flatItemCount, nodeForFlatIndex,
|
||||
* flatIndexForNode).
|
||||
*/
|
||||
attribute boolean suppressNotifications;
|
||||
|
||||
/**
|
||||
* Adds an observer for changes done in the result.
|
||||
*
|
||||
* @param aObserver
|
||||
* a result observer.
|
||||
* @param aOwnsWeak
|
||||
* If false, the result will keep an owning reference to the observer,
|
||||
* which must be removed using removeObserver.
|
||||
* If true, the result will keep a weak reference to the observer, which
|
||||
* must implement nsISupportsWeakReference.
|
||||
*
|
||||
* @see nsINavHistoryResultObserver
|
||||
*/
|
||||
void addObserver(in nsINavHistoryResultObserver aObserver, in boolean aOwnsWeak);
|
||||
|
||||
/**
|
||||
* Removes an observer that was added by addObserver.
|
||||
*
|
||||
* @param aObserver
|
||||
* a result observer that was added by addObserver.
|
||||
*/
|
||||
void removeObserver(in nsINavHistoryResultObserver aObserver);
|
||||
attribute nsINavHistoryResultViewer viewer;
|
||||
|
||||
/**
|
||||
* This is the root of the results. Remember that you need to open all
|
||||
|
|
Разница между файлами не показана из-за своего большого размера
Загрузить разницу
|
@ -110,6 +110,10 @@ private:
|
|||
// nsNavHistory creates this object and fills in mChildren (by getting
|
||||
// it through GetTopLevel()). Then FilledAllResults() is called to finish
|
||||
// object initialization.
|
||||
//
|
||||
// This object implements nsITreeView so you can just set it to a tree
|
||||
// view and it will work. This object also observes the necessary history
|
||||
// and bookmark events to keep itself up-to-date.
|
||||
|
||||
#define NS_NAVHISTORYRESULT_IID \
|
||||
{ 0x455d1d40, 0x1b9b, 0x40e6, { 0xa6, 0x41, 0x8b, 0xb7, 0xe8, 0x82, 0x23, 0x87 } }
|
||||
|
@ -126,6 +130,9 @@ public:
|
|||
nsNavHistoryContainerResultNode* aRoot,
|
||||
nsNavHistoryResult** result);
|
||||
|
||||
// the tree viewer can go faster if it can bypass XPCOM
|
||||
friend class nsNavHistoryResultTreeViewer;
|
||||
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_NAVHISTORYRESULT_IID)
|
||||
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
|
@ -141,6 +148,10 @@ public:
|
|||
void RemoveAllBookmarksObserver(nsNavHistoryQueryResultNode* aNode);
|
||||
void StopObserving();
|
||||
|
||||
// returns the view. NOT-ADDREFED. May be NULL if there is no view
|
||||
nsINavHistoryResultViewer* GetView() const
|
||||
{ return mView; }
|
||||
|
||||
public:
|
||||
// two-stage init, use NewHistoryResult to construct
|
||||
nsNavHistoryResult(nsNavHistoryContainerResultNode* mRoot);
|
||||
|
@ -165,6 +176,8 @@ public:
|
|||
// The sorting annotation to be used for in SORT_BY_ANNOTATION_* modes
|
||||
nsCString mSortingAnnotation;
|
||||
|
||||
nsCOMPtr<nsINavHistoryResultViewer> mView;
|
||||
|
||||
// node observers
|
||||
PRBool mIsHistoryObserver;
|
||||
PRBool mIsBookmarkFolderObserver;
|
||||
|
@ -184,9 +197,6 @@ public:
|
|||
void InvalidateTree();
|
||||
|
||||
PRBool mBatchInProgress;
|
||||
|
||||
nsMaybeWeakPtrArray<nsINavHistoryResultObserver> mObservers;
|
||||
PRBool mSuppressNotifications;
|
||||
};
|
||||
|
||||
NS_DEFINE_STATIC_IID_ACCESSOR(nsNavHistoryResult, NS_NAVHISTORYRESULT_IID)
|
||||
|
@ -528,25 +538,25 @@ public:
|
|||
|
||||
PRBool AreChildrenVisible();
|
||||
|
||||
// Overridded by descendents to populate.
|
||||
// overridded by descendents to populate
|
||||
virtual nsresult OpenContainer();
|
||||
nsresult CloseContainer(PRBool aSuppressNotifications = PR_FALSE);
|
||||
nsresult CloseContainer(PRBool aUpdateView = PR_TRUE);
|
||||
|
||||
// This points to the result that owns this container. All containers have
|
||||
// this points to the result that owns this container. All containers have
|
||||
// their result pointer set so we can quickly get to the result without having
|
||||
// to walk the tree. Yet, this also saves us from storing a million pointers
|
||||
// for every leaf node to the result.
|
||||
nsRefPtr<nsNavHistoryResult> mResult;
|
||||
|
||||
// For example, RESULT_TYPE_QUERY. Query and Folder results override GetType
|
||||
// for example, RESULT_TYPE_QUERY. Query and Folder results override GetType
|
||||
// so this is not used, but is still kept in sync.
|
||||
PRUint32 mContainerType;
|
||||
|
||||
// When there are children, this stores the open state in the tree
|
||||
// this is set to the default in the constructor.
|
||||
// when there are children, this stores the open state in the tree
|
||||
// this is set to the default in the constructor
|
||||
PRBool mExpanded;
|
||||
|
||||
// Filled in by the result type generator in nsNavHistory.
|
||||
// Filled in by the result type generator in nsNavHistory
|
||||
nsCOMArray<nsNavHistoryResultNode> mChildren;
|
||||
|
||||
PRBool mChildrenReadOnly;
|
||||
|
@ -557,9 +567,9 @@ public:
|
|||
nsCString mDynamicContainerType;
|
||||
|
||||
void FillStats();
|
||||
nsresult ReverseUpdateStats(PRInt32 aAccessCountChange);
|
||||
void ReverseUpdateStats(PRInt32 aAccessCountChange);
|
||||
|
||||
// Sorting methods.
|
||||
// sorting
|
||||
typedef nsCOMArray<nsNavHistoryResultNode>::nsCOMArrayComparatorFunc SortComparator;
|
||||
virtual PRUint16 GetSortType();
|
||||
virtual void GetSortingAnnotation(nsACString& aSortingAnnotation);
|
||||
|
@ -643,10 +653,10 @@ public:
|
|||
nsNavHistoryContainerResultNode* aContainer,
|
||||
const nsCString& aSpec,
|
||||
nsCOMArray<nsNavHistoryResultNode>* aMatches);
|
||||
nsresult UpdateURIs(PRBool aRecursive, PRBool aOnlyOne, PRBool aUpdateSort,
|
||||
const nsCString& aSpec,
|
||||
nsresult (*aCallback)(nsNavHistoryResultNode*,void*, nsNavHistoryResult*),
|
||||
void* aClosure);
|
||||
void UpdateURIs(PRBool aRecursive, PRBool aOnlyOne, PRBool aUpdateSort,
|
||||
const nsCString& aSpec,
|
||||
void (*aCallback)(nsNavHistoryResultNode*,void*, nsNavHistoryResult*),
|
||||
void* aClosure);
|
||||
nsresult ChangeTitles(nsIURI* aURI, const nsACString& aNewTitle,
|
||||
PRBool aRecursive, PRBool aOnlyOne);
|
||||
};
|
||||
|
|
|
@ -1097,29 +1097,24 @@ var PlacesUtils = {
|
|||
if (!this.nodeIsContainer(aNode))
|
||||
return false;
|
||||
|
||||
let root = this.getContainerNodeWithOptions(aNode, false, true);
|
||||
let result = root.parentResult;
|
||||
let suppressNotificationsOld = false;
|
||||
let wasOpen = root.containerOpen;
|
||||
var root = this.getContainerNodeWithOptions(aNode, false, true);
|
||||
var oldViewer = root.parentResult.viewer;
|
||||
var wasOpen = root.containerOpen;
|
||||
if (!wasOpen) {
|
||||
suppressNotificationsOld = result.suppressNotifications;
|
||||
if (!suppressNotificationsOld)
|
||||
result.suppressNotifications = true;
|
||||
|
||||
root.parentResult.viewer = null;
|
||||
root.containerOpen = true;
|
||||
}
|
||||
|
||||
let found = false;
|
||||
for (let i = 0; i < root.childCount && !found; i++) {
|
||||
let child = root.getChild(i);
|
||||
var found = false;
|
||||
for (var i = 0; i < root.childCount && !found; i++) {
|
||||
var child = root.getChild(i);
|
||||
if (this.nodeIsURI(child))
|
||||
found = true;
|
||||
}
|
||||
|
||||
if (!wasOpen) {
|
||||
root.containerOpen = false;
|
||||
if (!suppressNotificationsOld)
|
||||
result.suppressNotifications = false;
|
||||
root.parentResult.viewer = oldViewer;
|
||||
}
|
||||
return found;
|
||||
},
|
||||
|
@ -1133,31 +1128,27 @@ var PlacesUtils = {
|
|||
* @returns array of uris in the first level of the container.
|
||||
*/
|
||||
getURLsForContainerNode: function PU_getURLsForContainerNode(aNode) {
|
||||
let urls = [];
|
||||
var urls = [];
|
||||
if (!this.nodeIsContainer(aNode))
|
||||
return urls;
|
||||
|
||||
let root = this.getContainerNodeWithOptions(aNode, false, true);
|
||||
let wasOpen = root.containerOpen;
|
||||
let suppressNotificationsOld = false;
|
||||
var root = this.getContainerNodeWithOptions(aNode, false, true);
|
||||
var oldViewer = root.parentResult.viewer;
|
||||
var wasOpen = root.containerOpen;
|
||||
if (!wasOpen) {
|
||||
suppressNotificationsOld = result.suppressNotifications;
|
||||
if (!suppressNotificationsOld)
|
||||
result.suppressNotifications = true;
|
||||
|
||||
root.parentResult.viewer = null;
|
||||
root.containerOpen = true;
|
||||
}
|
||||
|
||||
for (let i = 0; i < root.childCount; ++i) {
|
||||
let child = root.getChild(i);
|
||||
for (var i = 0; i < root.childCount; ++i) {
|
||||
var child = root.getChild(i);
|
||||
if (this.nodeIsURI(child))
|
||||
urls.push({uri: child.uri, isBookmark: this.nodeIsBookmark(child)});
|
||||
}
|
||||
|
||||
if (!wasOpen) {
|
||||
root.containerOpen = false;
|
||||
if (!suppressNotificationsOld)
|
||||
result.suppressNotifications = false;
|
||||
root.parentResult.viewer = oldViewer;
|
||||
}
|
||||
return urls;
|
||||
},
|
||||
|
|
|
@ -105,17 +105,15 @@ function run_test() {
|
|||
options.excludeQueries = 1;
|
||||
options.sortingMode = options.SORT_BY_DATE_DESCENDING;
|
||||
result = histsvc.executeQuery(query, options);
|
||||
|
||||
let resultObserver = {
|
||||
itemChanged: function(item) {
|
||||
// The favicon should not be set on the containing query.
|
||||
if (item.uri.substr(0,5) == "place")
|
||||
print("Testing itemChanged on: " + item.uri);
|
||||
do_check_eq(item.icon.spec, null);
|
||||
}
|
||||
};
|
||||
result.addObserver(resultObserver, false);
|
||||
|
||||
// Associate a viewer to our result
|
||||
result.viewer = {
|
||||
itemChanged: function(item) {
|
||||
// The favicon should not be set on the containing query.
|
||||
if (item.uri.substr(0,5) == "place")
|
||||
dump("\nTesting itemChanged on: \n " + item.uri + "\n\n");
|
||||
do_check_eq(item.icon.spec, null);
|
||||
}
|
||||
};
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
|
||||
|
@ -127,8 +125,6 @@ function run_test() {
|
|||
do_test_pending();
|
||||
// lazy timeout is 3s and favicons are lazy added
|
||||
do_timeout(3500, end_test);
|
||||
|
||||
result.removeObserver(resultObserver);
|
||||
}
|
||||
|
||||
function end_test() {
|
||||
|
|
|
@ -64,7 +64,7 @@ function add_visit(aURI, aDate) {
|
|||
return placeID;
|
||||
}
|
||||
|
||||
var resultObserver = {
|
||||
var viewer = {
|
||||
insertedNode: null,
|
||||
nodeInserted: function(parent, node, newIndex) {
|
||||
this.insertedNode = node;
|
||||
|
@ -117,6 +117,9 @@ var resultObserver = {
|
|||
this.sortingMode = sortingMode;
|
||||
},
|
||||
result: null,
|
||||
ignoreInvalidateContainer: false,
|
||||
addViewObserver: function(observer, ownsWeak) {},
|
||||
removeViewObserver: function(observer) {},
|
||||
reset: function() {
|
||||
this.insertedNode = null;
|
||||
this.removedNode = null;
|
||||
|
@ -140,55 +143,55 @@ function run_test() {
|
|||
options.resultType = options.RESULTS_AS_VISIT;
|
||||
var query = histsvc.getNewQuery();
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
result.addObserver(resultObserver, false);
|
||||
result.viewer = viewer;
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
|
||||
// nsINavHistoryResultObserver.containerOpened
|
||||
do_check_neq(resultObserver.openedContainer, null);
|
||||
// nsINavHistoryResultViewer.containerOpened
|
||||
do_check_neq(viewer.openedContainer, null);
|
||||
|
||||
// nsINavHistoryResultObserver.nodeInserted
|
||||
// nsINavHistoryResultViewer.nodeInserted
|
||||
// add a visit
|
||||
var testURI = uri("http://mozilla.com");
|
||||
add_visit(testURI);
|
||||
do_check_eq(testURI.spec, resultObserver.insertedNode.uri);
|
||||
do_check_eq(testURI.spec, viewer.insertedNode.uri);
|
||||
|
||||
// nsINavHistoryResultObserver.nodeHistoryDetailsChanged
|
||||
// nsINavHistoryResultViewer.nodeHistoryDetailsChanged
|
||||
// adding a visit causes nodeHistoryDetailsChanged for the folder
|
||||
do_check_eq(root.uri, resultObserver.nodeChangedByHistoryDetails.uri);
|
||||
do_check_eq(root.uri, viewer.nodeChangedByHistoryDetails.uri);
|
||||
|
||||
// nsINavHistoryResultObserver.itemTitleChanged for a leaf node
|
||||
// nsINavHistoryResultViewer.itemTitleChanged for a leaf node
|
||||
bhist.addPageWithDetails(testURI, "baz", Date.now() * 1000);
|
||||
do_check_eq(resultObserver.nodeChangedByTitle.title, "baz");
|
||||
do_check_eq(viewer.nodeChangedByTitle.title, "baz");
|
||||
|
||||
// nsINavHistoryResultObserver.nodeRemoved
|
||||
// nsINavHistoryResultViewer.nodeRemoved
|
||||
var removedURI = uri("http://google.com");
|
||||
add_visit(removedURI);
|
||||
bhist.removePage(removedURI);
|
||||
do_check_eq(removedURI.spec, resultObserver.removedNode.uri);
|
||||
do_check_eq(removedURI.spec, viewer.removedNode.uri);
|
||||
|
||||
// XXX nsINavHistoryResultObserver.nodeReplaced
|
||||
// XXX nsINavHistoryResultViewer.nodeReplaced
|
||||
// NHQRN.onVisit()->NHCRN.MergeResults()->NHCRN.ReplaceChildURIAt()->NHRV.NodeReplaced()
|
||||
|
||||
// nsINavHistoryResultObserver.invalidateContainer
|
||||
// nsINavHistoryResultViewer.invalidateContainer
|
||||
bhist.removePagesFromHost("mozilla.com", false);
|
||||
do_check_eq(root.uri, resultObserver.invalidatedContainer.uri);
|
||||
do_check_eq(root.uri, viewer.invalidatedContainer.uri);
|
||||
|
||||
// nsINavHistoryResultObserver.sortingChanged
|
||||
resultObserver.invalidatedContainer = null;
|
||||
// nsINavHistoryResultViewer.sortingChanged
|
||||
viewer.invalidatedContainer = null;
|
||||
result.sortingMode = options.SORT_BY_TITLE_ASCENDING;
|
||||
do_check_eq(resultObserver.sortingMode, options.SORT_BY_TITLE_ASCENDING);
|
||||
do_check_eq(resultObserver.invalidatedContainer, result.root);
|
||||
do_check_eq(viewer.sortingMode, options.SORT_BY_TITLE_ASCENDING);
|
||||
do_check_eq(viewer.invalidatedContainer, result.root);
|
||||
|
||||
// nsINavHistoryResultObserver.containerClosed
|
||||
// nsINavHistoryResultViewer.containerClosed
|
||||
root.containerOpen = false;
|
||||
do_check_eq(resultObserver.closedContainer, resultObserver.openedContainer);
|
||||
result.removeObserver(resultObserver);
|
||||
do_check_eq(viewer.closedContainer, viewer.openedContainer);
|
||||
result.viewer = null;
|
||||
|
||||
// bookmarks query
|
||||
|
||||
// Reset the result observer.
|
||||
resultObserver.reset();
|
||||
// reset the viewer
|
||||
viewer.reset();
|
||||
|
||||
try {
|
||||
var bmsvc = Cc["@mozilla.org/browser/nav-bookmarks-service;1"].getService(Ci.nsINavBookmarksService);
|
||||
|
@ -200,49 +203,49 @@ function run_test() {
|
|||
var query = histsvc.getNewQuery();
|
||||
query.setFolders([bmsvc.bookmarksMenuFolder], 1);
|
||||
var result = histsvc.executeQuery(query, options);
|
||||
result.addObserver(resultObserver, false);
|
||||
result.viewer = viewer;
|
||||
var root = result.root;
|
||||
root.containerOpen = true;
|
||||
|
||||
// nsINavHistoryResultObserver.containerOpened
|
||||
do_check_neq(resultObserver.openedContainer, null);
|
||||
// nsINavHistoryResultViewer.containerOpened
|
||||
do_check_neq(viewer.openedContainer, null);
|
||||
|
||||
// nsINavHistoryResultObserver.nodeInserted
|
||||
// nsINavHistoryResultViewer.nodeInserted
|
||||
// add a bookmark
|
||||
var testBookmark = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, testURI, bmsvc.DEFAULT_INDEX, "foo");
|
||||
do_check_eq("foo", resultObserver.insertedNode.title);
|
||||
do_check_eq(testURI.spec, resultObserver.insertedNode.uri);
|
||||
do_check_eq("foo", viewer.insertedNode.title);
|
||||
do_check_eq(testURI.spec, viewer.insertedNode.uri);
|
||||
|
||||
// nsINavHistoryResultObserver.nodeHistoryDetailsChanged
|
||||
// nsINavHistoryResultViewer.nodeHistoryDetailsChanged
|
||||
// adding a visit causes nodeHistoryDetailsChanged for the folder
|
||||
do_check_eq(root.uri, resultObserver.nodeChangedByHistoryDetails.uri);
|
||||
do_check_eq(root.uri, viewer.nodeChangedByHistoryDetails.uri);
|
||||
|
||||
// nsINavHistoryResultObserver.nodeTitleChanged for a leaf node
|
||||
// nsINavHistoryResultViewer.nodeTitleChanged for a leaf node
|
||||
bmsvc.setItemTitle(testBookmark, "baz");
|
||||
do_check_eq(resultObserver.nodeChangedByTitle.title, "baz");
|
||||
do_check_eq(resultObserver.newTitle, "baz");
|
||||
do_check_eq(viewer.nodeChangedByTitle.title, "baz");
|
||||
do_check_eq(viewer.newTitle, "baz");
|
||||
|
||||
var testBookmark2 = bmsvc.insertBookmark(bmsvc.bookmarksMenuFolder, uri("http://google.com"), bmsvc.DEFAULT_INDEX, "foo");
|
||||
bmsvc.moveItem(testBookmark2, bmsvc.bookmarksMenuFolder, 0);
|
||||
do_check_eq(resultObserver.movedNode.itemId, testBookmark2);
|
||||
do_check_eq(viewer.movedNode.itemId, testBookmark2);
|
||||
|
||||
// nsINavHistoryResultObserver.nodeRemoved
|
||||
// nsINavHistoryResultViewer.nodeRemoved
|
||||
bmsvc.removeItem(testBookmark2);
|
||||
do_check_eq(testBookmark2, resultObserver.removedNode.itemId);
|
||||
do_check_eq(testBookmark2, viewer.removedNode.itemId);
|
||||
|
||||
// XXX nsINavHistoryResultObserver.nodeReplaced
|
||||
// XXX nsINavHistoryResultViewer.nodeReplaced
|
||||
// NHQRN.onVisit()->NHCRN.MergeResults()->NHCRN.ReplaceChildURIAt()->NHRV.NodeReplaced()
|
||||
|
||||
// XXX nsINavHistoryResultObserver.invalidateContainer
|
||||
// XXX nsINavHistoryResultViewer.invalidateContainer
|
||||
|
||||
// nsINavHistoryResultObserver.sortingChanged
|
||||
resultObserver.invalidatedContainer = null;
|
||||
// nsINavHistoryResultViewer.sortingChanged
|
||||
viewer.invalidatedContainer = null;
|
||||
result.sortingMode = options.SORT_BY_TITLE_ASCENDING;
|
||||
do_check_eq(resultObserver.sortingMode, options.SORT_BY_TITLE_ASCENDING);
|
||||
do_check_eq(resultObserver.invalidatedContainer, result.root);
|
||||
do_check_eq(viewer.sortingMode, options.SORT_BY_TITLE_ASCENDING);
|
||||
do_check_eq(viewer.invalidatedContainer, result.root);
|
||||
|
||||
// nsINavHistoryResultObserver.containerClosed
|
||||
// nsINavHistoryResultViewer.containerClosed
|
||||
root.containerOpen = false;
|
||||
do_check_eq(resultObserver.closedContainer, resultObserver.openedContainer);
|
||||
result.removeObserver(resultObserver);
|
||||
do_check_eq(viewer.closedContainer, viewer.openedContainer);
|
||||
result.viewer = null;
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче