Backed out changeset 2c60006b6c1f (bug 520659) because of resulting orange.

This commit is contained in:
Paul O’Shannessy 2010-02-22 14:58:09 -08:00
Родитель 9373a85130
Коммит 4ef6775f0a
8 изменённых файлов: 535 добавлений и 833 удалений

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

@ -1020,8 +1020,8 @@
else {
// In all other cases the insertion point is before that node.
container = selectedNode.parent;
index = container.getChildIndex(selectedNode);
isTag = PlacesUtils.nodeIsTagQuery(container);
index = PlacesUtils.getIndexOfNode(selectedNode);
isTag = PlacesUtils.nodeIsTagQuery(selectedNode.parent);
}
}

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

@ -483,8 +483,8 @@
else {
// In all other cases the insertion point is before that node.
container = selectedNode.parent;
index = container.getChildIndex(selectedNode);
isTag = PlacesUtils.nodeIsTagQuery(container);
index = PlacesUtils.getIndexOfNode(selectedNode);
isTag = PlacesUtils.nodeIsTagQuery(selectedNode.parent);
}
}

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

@ -449,7 +449,7 @@
// you must not, since the tree is nested and as your tree
// index may change when folders before you are opened and
// closed. You must convert your tree index to a node, and
// then use getChildIndex to find your absolute index in
// then use getIndexOfNode to find your absolute index in
// the parent container instead.
//
var resultView = this.view;
@ -481,7 +481,7 @@
<method name="_getInsertionPoint">
<parameter name="index"/>
<parameter name="orientation"/>
<body><![CDATA[
<body><![CDATA[
var result = this.getResult();
var resultview = this.view;
var container = result.root;
@ -507,14 +507,12 @@
index = 0;
}
else {
// Use the last-selected node's container.
container = lastSelected.parent;
// Use the last-selected node's container unless the root node
// is selected, in which case we use the root node itself as the
// insertion point.
container = lastSelected.parent || container;
// See comment in the treeView.js's copy of this method
if (!container || !container.containerOpen)
return null;
// Avoid the potentially expensive call to getChildIndex
// avoid the potentially expensive call to getIndexOfNode()
// if we know this container doesn't allow insertion
if (PlacesControllerDragHelper.disallowInsertion(container))
return null;
@ -535,7 +533,7 @@
dropNearItemId = lastSelected.itemId;
}
else {
var lsi = container.getChildIndex(lastSelected);
var lsi = PlacesUtils.getIndexOfNode(lastSelected);
index = orientation == Ci.nsITreeView.DROP_BEFORE ? lsi : lsi + 1;
}
}

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -231,7 +231,7 @@ interface nsINavHistoryFullVisitResultNode : nsINavHistoryVisitResultNode
* Bookmark folders and places queries will be QueryResultNodes which extends
* these items.
*/
[scriptable, uuid(9e3f2f78-53ae-469a-9fb3-b0ef74b24a31)]
[scriptable, uuid(f9c8e1c1-e701-44ad-893c-8504c3956929)]
interface nsINavHistoryContainerResultNode : nsINavHistoryResultNode
{
@ -268,41 +268,6 @@ interface nsINavHistoryContainerResultNode : nsINavHistoryResultNode
readonly attribute unsigned long childCount;
nsINavHistoryResultNode getChild(in unsigned long aIndex);
/**
* Get the index of a direct child in this container.
*
* @param aNode
* a result node.
*
* @return aNode's index in this container.
* @throws NS_ERROR_NOT_AVAILABLE if containerOpen is false.
* @throws NS_ERROR_INVALID_ARG if aNode isn't a direct child of this
* container.
*/
unsigned long getChildIndex(in nsINavHistoryResultNode aNode);
/**
* Look for a node in the container by some of its details. Does not search
* closed containers.
*
* @param aURI
* the node's uri attribute value
* @param aTime
* the node's time attribute value.
* @param aItemId
* the node's itemId attribute value.
* @param aRecursive
* whether or not to search recursively.
*
* @throws NS_ERROR_NOT_AVAILABLE if this container is closed.
* @return a result node that matches the given details if any, null
* otherwise.
*/
nsINavHistoryResultNode findNodeByDetails(in AUTF8String aURIString,
in PRTime aTime,
in long long aItemId,
in boolean aRecursive);
/**
* Returns false if this node's list of children can be modified
* (adding or removing children, or reordering children), or true if

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

@ -1866,57 +1866,6 @@ nsNavHistoryContainerResultNode::GetChild(PRUint32 aIndex,
}
NS_IMETHODIMP
nsNavHistoryContainerResultNode::GetChildIndex(nsINavHistoryResultNode* aNode,
PRUint32* _retval)
{
if (!mExpanded)
return NS_ERROR_NOT_AVAILABLE;
*_retval = FindChild(static_cast<nsNavHistoryResultNode*>(aNode));
if (*_retval == -1)
return NS_ERROR_INVALID_ARG;
return NS_OK;
}
NS_IMETHODIMP
nsNavHistoryContainerResultNode::FindNodeByDetails(const nsACString& aURIString,
PRTime aTime,
PRInt64 aItemId,
PRBool aRecursive,
nsINavHistoryResultNode** _retval) {
if (!mExpanded)
return NS_ERROR_NOT_AVAILABLE;
*_retval = nsnull;
for (PRInt32 i = 0; i < mChildren.Count(); i++) {
if (mChildren[i]->mURI.Equals(aURIString) &&
mChildren[i]->mTime == aTime &&
mChildren[i]->mItemId == aItemId) {
*_retval = mChildren[i];
break;
}
if (aRecursive && mChildren[i]->IsContainer()) {
nsNavHistoryContainerResultNode* asContainer =
mChildren[i]->GetAsContainer();
if (asContainer->mExpanded) {
nsresult rv = asContainer->FindNodeByDetails(aURIString, aTime,
aItemId,
aRecursive,
_retval);
if (NS_SUCCEEDED(rv) && _retval)
break;
}
}
}
return NS_OK;
}
// nsNavHistoryContainerResultNode::GetChildrenReadOnly
//
// Overridden for folders to query the bookmarks service directly.

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

@ -474,13 +474,6 @@ public:
{ return nsNavHistoryContainerResultNode::GetChildCount(aChildCount); } \
NS_IMETHOD GetChild(PRUint32 index, nsINavHistoryResultNode **_retval) \
{ return nsNavHistoryContainerResultNode::GetChild(index, _retval); } \
NS_IMETHOD GetChildIndex(nsINavHistoryResultNode* aNode, PRUint32* _retval) \
{ return nsNavHistoryContainerResultNode::GetChildIndex(aNode, _retval); } \
NS_IMETHOD FindNodeByDetails(const nsACString& aURIString, PRTime aTime, \
PRInt64 aItemId, PRBool aRecursive, \
nsINavHistoryResultNode** _retval) \
{ return nsNavHistoryContainerResultNode::FindNodeByDetails(aURIString, aTime, aItemId, \
aRecursive, _retval); } \
NS_IMETHOD GetDynamicContainerType(nsACString& aDynamicContainerType) \
{ return nsNavHistoryContainerResultNode::GetDynamicContainerType(aDynamicContainerType); } \
NS_IMETHOD AppendURINode(const nsACString& aURI, const nsACString& aTitle, PRUint32 aAccessCount, PRTime aTime, const nsACString& aIconURI, nsINavHistoryResultNode **_retval) \

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

@ -485,6 +485,34 @@ var PlacesUtils = {
return aNode.itemId;
},
/**
* Gets the index of a node within its parent container
* @param aNode
* The node to look up
* @returns The index of the node within its parent container, or -1 if the
* node was not found or the node specified has no parent.
*/
getIndexOfNode: function PU_getIndexOfNode(aNode) {
var parent = aNode.parent;
if (!parent)
return -1;
var wasOpen = parent.containerOpen;
var result, oldViewer;
if (!wasOpen) {
result = parent.parentResult;
oldViewer = result.viewer;
result.viewer = null;
parent.containerOpen = true;
}
var cc = parent.childCount;
for (var i = 0; i < cc && parent.getChild(i) != aNode; ++i);
if (!wasOpen) {
parent.containerOpen = false;
result.viewer = oldViewer;
}
return i < cc ? i : -1;
},
/**
* String-wraps a result node according to the rules of the specified
* content type.
@ -501,44 +529,40 @@ var PlacesUtils = {
* @returns A string serialization of the node
*/
wrapNode: function PU_wrapNode(aNode, aType, aOverrideURI, aForceCopy) {
let self = this;
var self = this;
// when wrapping a node, we want all the items, even if the original
// query options are excluding them.
// this can happen when copying from the left hand pane of the bookmarks
// organizer
// @return [node, shouldClose]
function convertNode(cNode) {
if (self.nodeIsFolder(cNode) && asQuery(cNode).queryOptions.excludeItems) {
let concreteId = self.getConcreteItemId(cNode);
return [self.getFolderContents(concreteId, false, true).root, true];
var concreteId = self.getConcreteItemId(cNode);
return self.getFolderContents(concreteId, false, true).root;
}
// If we didn't create our own query, do not alter the node's open state.
return [cNode, false];
return cNode;
}
switch (aType) {
case this.TYPE_X_MOZ_PLACE:
case this.TYPE_X_MOZ_PLACE_SEPARATOR:
case this.TYPE_X_MOZ_PLACE_CONTAINER:
let writer = {
var writer = {
value: "",
write: function PU_wrapNode__write(aStr, aLen) {
this.value += aStr;
}
};
let [node, shouldClose] = convertNode(aNode);
var node = convertNode(aNode);
self.serializeNodeAsJSONToOutputStream(node, writer, true, aForceCopy);
if (shouldClose)
// Convert node could pass an open container node.
if (self.nodeIsContainer(node))
node.containerOpen = false;
return writer.value;
case this.TYPE_X_MOZ_URL:
function gatherDataUrl(bNode) {
if (self.nodeIsLivemarkContainer(bNode)) {
let siteURI = self.livemarks.getSiteURI(bNode.itemId).spec;
var siteURI = self.livemarks.getSiteURI(bNode.itemId).spec;
return siteURI + NEWLINE + bNode.title;
}
if (self.nodeIsURI(bNode))
@ -546,13 +570,14 @@ var PlacesUtils = {
// ignore containers and separators - items without valid URIs
return "";
}
let [node, shouldClose] = convertNode(aNode);
let dataUrl = gatherDataUrl(node);
if (shouldClose)
var node = convertNode(aNode);
var dataUrl = gatherDataUrl(node);
// Convert node could pass an open container node.
if (self.nodeIsContainer(node))
node.containerOpen = false;
return dataUrl;
case this.TYPE_HTML:
function gatherDataHtml(bNode) {
function htmlEscape(s) {
@ -564,20 +589,20 @@ var PlacesUtils = {
return s;
}
// escape out potential HTML in the title
let escapedTitle = bNode.title ? htmlEscape(bNode.title) : "";
var escapedTitle = bNode.title ? htmlEscape(bNode.title) : "";
if (self.nodeIsLivemarkContainer(bNode)) {
let siteURI = self.livemarks.getSiteURI(bNode.itemId).spec;
var siteURI = self.livemarks.getSiteURI(bNode.itemId).spec;
return "<A HREF=\"" + siteURI + "\">" + escapedTitle + "</A>" + NEWLINE;
}
if (self.nodeIsContainer(bNode)) {
asContainer(bNode);
let wasOpen = bNode.containerOpen;
var wasOpen = bNode.containerOpen;
if (!wasOpen)
bNode.containerOpen = true;
let childString = "<DL><DT>" + escapedTitle + "</DT>" + NEWLINE;
let cc = bNode.childCount;
for (let i = 0; i < cc; ++i)
var childString = "<DL><DT>" + escapedTitle + "</DT>" + NEWLINE;
var cc = bNode.childCount;
for (var i = 0; i < cc; ++i)
childString += "<DD>"
+ NEWLINE
+ gatherDataHtml(bNode.getChild(i))
@ -592,30 +617,28 @@ var PlacesUtils = {
return "<HR>" + NEWLINE;
return "";
}
let [node, shouldClose] = convertNode(aNode);
let dataHtml = gatherDataHtml(node);
if (shouldClose)
var node = convertNode(aNode);
var dataHtml = gatherDataHtml(node);
// Convert node could pass an open container node.
if (self.nodeIsContainer(node))
node.containerOpen = false;
return dataHtml;
}
// Otherwise, we wrap as TYPE_UNICODE.
// case this.TYPE_UNICODE:
function gatherDataText(bNode) {
if (self.nodeIsLivemarkContainer(bNode))
return self.livemarks.getSiteURI(bNode.itemId).spec;
if (self.nodeIsContainer(bNode)) {
asContainer(bNode);
let wasOpen = bNode.containerOpen;
var wasOpen = bNode.containerOpen;
if (!wasOpen)
bNode.containerOpen = true;
let childString = bNode.title + NEWLINE;
let cc = bNode.childCount;
for (let i = 0; i < cc; ++i) {
let child = bNode.getChild(i);
let suffix = i < (cc - 1) ? NEWLINE : "";
var childString = bNode.title + NEWLINE;
var cc = bNode.childCount;
for (var i = 0; i < cc; ++i) {
var child = bNode.getChild(i);
var suffix = i < (cc - 1) ? NEWLINE : "";
childString += gatherDataText(child) + suffix;
}
bNode.containerOpen = wasOpen;
@ -628,12 +651,11 @@ var PlacesUtils = {
return "";
}
let [node, shouldClose] = convertNode(aNode);
let dataText = gatherDataText(node);
var node = convertNode(aNode);
var dataText = gatherDataText(node);
// Convert node could pass an open container node.
if (shouldClose)
if (self.nodeIsContainer(node))
node.containerOpen = false;
return dataText;
},