зеркало из https://github.com/mozilla/gecko-dev.git
Backed out changeset 2c60006b6c1f (bug 520659) because of resulting orange.
This commit is contained in:
Родитель
9373a85130
Коммит
4ef6775f0a
|
@ -1020,8 +1020,8 @@
|
||||||
else {
|
else {
|
||||||
// In all other cases the insertion point is before that node.
|
// In all other cases the insertion point is before that node.
|
||||||
container = selectedNode.parent;
|
container = selectedNode.parent;
|
||||||
index = container.getChildIndex(selectedNode);
|
index = PlacesUtils.getIndexOfNode(selectedNode);
|
||||||
isTag = PlacesUtils.nodeIsTagQuery(container);
|
isTag = PlacesUtils.nodeIsTagQuery(selectedNode.parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -483,8 +483,8 @@
|
||||||
else {
|
else {
|
||||||
// In all other cases the insertion point is before that node.
|
// In all other cases the insertion point is before that node.
|
||||||
container = selectedNode.parent;
|
container = selectedNode.parent;
|
||||||
index = container.getChildIndex(selectedNode);
|
index = PlacesUtils.getIndexOfNode(selectedNode);
|
||||||
isTag = PlacesUtils.nodeIsTagQuery(container);
|
isTag = PlacesUtils.nodeIsTagQuery(selectedNode.parent);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -449,7 +449,7 @@
|
||||||
// you must not, since the tree is nested and as your tree
|
// you must not, since the tree is nested and as your tree
|
||||||
// index may change when folders before you are opened and
|
// index may change when folders before you are opened and
|
||||||
// closed. You must convert your tree index to a node, 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.
|
// the parent container instead.
|
||||||
//
|
//
|
||||||
var resultView = this.view;
|
var resultView = this.view;
|
||||||
|
@ -481,7 +481,7 @@
|
||||||
<method name="_getInsertionPoint">
|
<method name="_getInsertionPoint">
|
||||||
<parameter name="index"/>
|
<parameter name="index"/>
|
||||||
<parameter name="orientation"/>
|
<parameter name="orientation"/>
|
||||||
<body><![CDATA[
|
<body><![CDATA[
|
||||||
var result = this.getResult();
|
var result = this.getResult();
|
||||||
var resultview = this.view;
|
var resultview = this.view;
|
||||||
var container = result.root;
|
var container = result.root;
|
||||||
|
@ -507,14 +507,12 @@
|
||||||
index = 0;
|
index = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// Use the last-selected node's container.
|
// Use the last-selected node's container unless the root node
|
||||||
container = lastSelected.parent;
|
// 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
|
// avoid the potentially expensive call to getIndexOfNode()
|
||||||
if (!container || !container.containerOpen)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
// Avoid the potentially expensive call to getChildIndex
|
|
||||||
// if we know this container doesn't allow insertion
|
// if we know this container doesn't allow insertion
|
||||||
if (PlacesControllerDragHelper.disallowInsertion(container))
|
if (PlacesControllerDragHelper.disallowInsertion(container))
|
||||||
return null;
|
return null;
|
||||||
|
@ -535,7 +533,7 @@
|
||||||
dropNearItemId = lastSelected.itemId;
|
dropNearItemId = lastSelected.itemId;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
var lsi = container.getChildIndex(lastSelected);
|
var lsi = PlacesUtils.getIndexOfNode(lastSelected);
|
||||||
index = orientation == Ci.nsITreeView.DROP_BEFORE ? lsi : lsi + 1;
|
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
|
* Bookmark folders and places queries will be QueryResultNodes which extends
|
||||||
* these items.
|
* these items.
|
||||||
*/
|
*/
|
||||||
[scriptable, uuid(9e3f2f78-53ae-469a-9fb3-b0ef74b24a31)]
|
[scriptable, uuid(f9c8e1c1-e701-44ad-893c-8504c3956929)]
|
||||||
interface nsINavHistoryContainerResultNode : nsINavHistoryResultNode
|
interface nsINavHistoryContainerResultNode : nsINavHistoryResultNode
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -268,41 +268,6 @@ interface nsINavHistoryContainerResultNode : nsINavHistoryResultNode
|
||||||
readonly attribute unsigned long childCount;
|
readonly attribute unsigned long childCount;
|
||||||
nsINavHistoryResultNode getChild(in unsigned long aIndex);
|
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
|
* Returns false if this node's list of children can be modified
|
||||||
* (adding or removing children, or reordering children), or true if
|
* (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
|
// nsNavHistoryContainerResultNode::GetChildrenReadOnly
|
||||||
//
|
//
|
||||||
// Overridden for folders to query the bookmarks service directly.
|
// Overridden for folders to query the bookmarks service directly.
|
||||||
|
|
|
@ -474,13 +474,6 @@ public:
|
||||||
{ return nsNavHistoryContainerResultNode::GetChildCount(aChildCount); } \
|
{ return nsNavHistoryContainerResultNode::GetChildCount(aChildCount); } \
|
||||||
NS_IMETHOD GetChild(PRUint32 index, nsINavHistoryResultNode **_retval) \
|
NS_IMETHOD GetChild(PRUint32 index, nsINavHistoryResultNode **_retval) \
|
||||||
{ return nsNavHistoryContainerResultNode::GetChild(index, _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) \
|
NS_IMETHOD GetDynamicContainerType(nsACString& aDynamicContainerType) \
|
||||||
{ return nsNavHistoryContainerResultNode::GetDynamicContainerType(aDynamicContainerType); } \
|
{ return nsNavHistoryContainerResultNode::GetDynamicContainerType(aDynamicContainerType); } \
|
||||||
NS_IMETHOD AppendURINode(const nsACString& aURI, const nsACString& aTitle, PRUint32 aAccessCount, PRTime aTime, const nsACString& aIconURI, nsINavHistoryResultNode **_retval) \
|
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;
|
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
|
* String-wraps a result node according to the rules of the specified
|
||||||
* content type.
|
* content type.
|
||||||
|
@ -501,44 +529,40 @@ var PlacesUtils = {
|
||||||
* @returns A string serialization of the node
|
* @returns A string serialization of the node
|
||||||
*/
|
*/
|
||||||
wrapNode: function PU_wrapNode(aNode, aType, aOverrideURI, aForceCopy) {
|
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
|
// when wrapping a node, we want all the items, even if the original
|
||||||
// query options are excluding them.
|
// query options are excluding them.
|
||||||
// this can happen when copying from the left hand pane of the bookmarks
|
// this can happen when copying from the left hand pane of the bookmarks
|
||||||
// organizer
|
// organizer
|
||||||
// @return [node, shouldClose]
|
|
||||||
function convertNode(cNode) {
|
function convertNode(cNode) {
|
||||||
if (self.nodeIsFolder(cNode) && asQuery(cNode).queryOptions.excludeItems) {
|
if (self.nodeIsFolder(cNode) && asQuery(cNode).queryOptions.excludeItems) {
|
||||||
let concreteId = self.getConcreteItemId(cNode);
|
var concreteId = self.getConcreteItemId(cNode);
|
||||||
return [self.getFolderContents(concreteId, false, true).root, true];
|
return self.getFolderContents(concreteId, false, true).root;
|
||||||
}
|
}
|
||||||
|
return cNode;
|
||||||
// If we didn't create our own query, do not alter the node's open state.
|
|
||||||
return [cNode, false];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (aType) {
|
switch (aType) {
|
||||||
case this.TYPE_X_MOZ_PLACE:
|
case this.TYPE_X_MOZ_PLACE:
|
||||||
case this.TYPE_X_MOZ_PLACE_SEPARATOR:
|
case this.TYPE_X_MOZ_PLACE_SEPARATOR:
|
||||||
case this.TYPE_X_MOZ_PLACE_CONTAINER:
|
case this.TYPE_X_MOZ_PLACE_CONTAINER:
|
||||||
let writer = {
|
var writer = {
|
||||||
value: "",
|
value: "",
|
||||||
write: function PU_wrapNode__write(aStr, aLen) {
|
write: function PU_wrapNode__write(aStr, aLen) {
|
||||||
this.value += aStr;
|
this.value += aStr;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
var node = convertNode(aNode);
|
||||||
let [node, shouldClose] = convertNode(aNode);
|
|
||||||
self.serializeNodeAsJSONToOutputStream(node, writer, true, aForceCopy);
|
self.serializeNodeAsJSONToOutputStream(node, writer, true, aForceCopy);
|
||||||
if (shouldClose)
|
// Convert node could pass an open container node.
|
||||||
|
if (self.nodeIsContainer(node))
|
||||||
node.containerOpen = false;
|
node.containerOpen = false;
|
||||||
|
|
||||||
return writer.value;
|
return writer.value;
|
||||||
case this.TYPE_X_MOZ_URL:
|
case this.TYPE_X_MOZ_URL:
|
||||||
function gatherDataUrl(bNode) {
|
function gatherDataUrl(bNode) {
|
||||||
if (self.nodeIsLivemarkContainer(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;
|
return siteURI + NEWLINE + bNode.title;
|
||||||
}
|
}
|
||||||
if (self.nodeIsURI(bNode))
|
if (self.nodeIsURI(bNode))
|
||||||
|
@ -546,13 +570,14 @@ var PlacesUtils = {
|
||||||
// ignore containers and separators - items without valid URIs
|
// ignore containers and separators - items without valid URIs
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
var node = convertNode(aNode);
|
||||||
let [node, shouldClose] = convertNode(aNode);
|
var dataUrl = gatherDataUrl(node);
|
||||||
let dataUrl = gatherDataUrl(node);
|
// Convert node could pass an open container node.
|
||||||
if (shouldClose)
|
if (self.nodeIsContainer(node))
|
||||||
node.containerOpen = false;
|
node.containerOpen = false;
|
||||||
|
|
||||||
return dataUrl;
|
return dataUrl;
|
||||||
|
|
||||||
|
|
||||||
case this.TYPE_HTML:
|
case this.TYPE_HTML:
|
||||||
function gatherDataHtml(bNode) {
|
function gatherDataHtml(bNode) {
|
||||||
function htmlEscape(s) {
|
function htmlEscape(s) {
|
||||||
|
@ -564,20 +589,20 @@ var PlacesUtils = {
|
||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
// escape out potential HTML in the title
|
// 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)) {
|
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;
|
return "<A HREF=\"" + siteURI + "\">" + escapedTitle + "</A>" + NEWLINE;
|
||||||
}
|
}
|
||||||
if (self.nodeIsContainer(bNode)) {
|
if (self.nodeIsContainer(bNode)) {
|
||||||
asContainer(bNode);
|
asContainer(bNode);
|
||||||
let wasOpen = bNode.containerOpen;
|
var wasOpen = bNode.containerOpen;
|
||||||
if (!wasOpen)
|
if (!wasOpen)
|
||||||
bNode.containerOpen = true;
|
bNode.containerOpen = true;
|
||||||
|
|
||||||
let childString = "<DL><DT>" + escapedTitle + "</DT>" + NEWLINE;
|
var childString = "<DL><DT>" + escapedTitle + "</DT>" + NEWLINE;
|
||||||
let cc = bNode.childCount;
|
var cc = bNode.childCount;
|
||||||
for (let i = 0; i < cc; ++i)
|
for (var i = 0; i < cc; ++i)
|
||||||
childString += "<DD>"
|
childString += "<DD>"
|
||||||
+ NEWLINE
|
+ NEWLINE
|
||||||
+ gatherDataHtml(bNode.getChild(i))
|
+ gatherDataHtml(bNode.getChild(i))
|
||||||
|
@ -592,30 +617,28 @@ var PlacesUtils = {
|
||||||
return "<HR>" + NEWLINE;
|
return "<HR>" + NEWLINE;
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
var node = convertNode(aNode);
|
||||||
let [node, shouldClose] = convertNode(aNode);
|
var dataHtml = gatherDataHtml(node);
|
||||||
let dataHtml = gatherDataHtml(node);
|
// Convert node could pass an open container node.
|
||||||
if (shouldClose)
|
if (self.nodeIsContainer(node))
|
||||||
node.containerOpen = false;
|
node.containerOpen = false;
|
||||||
|
|
||||||
return dataHtml;
|
return dataHtml;
|
||||||
}
|
}
|
||||||
|
// case this.TYPE_UNICODE:
|
||||||
// Otherwise, we wrap as TYPE_UNICODE.
|
|
||||||
function gatherDataText(bNode) {
|
function gatherDataText(bNode) {
|
||||||
if (self.nodeIsLivemarkContainer(bNode))
|
if (self.nodeIsLivemarkContainer(bNode))
|
||||||
return self.livemarks.getSiteURI(bNode.itemId).spec;
|
return self.livemarks.getSiteURI(bNode.itemId).spec;
|
||||||
if (self.nodeIsContainer(bNode)) {
|
if (self.nodeIsContainer(bNode)) {
|
||||||
asContainer(bNode);
|
asContainer(bNode);
|
||||||
let wasOpen = bNode.containerOpen;
|
var wasOpen = bNode.containerOpen;
|
||||||
if (!wasOpen)
|
if (!wasOpen)
|
||||||
bNode.containerOpen = true;
|
bNode.containerOpen = true;
|
||||||
|
|
||||||
let childString = bNode.title + NEWLINE;
|
var childString = bNode.title + NEWLINE;
|
||||||
let cc = bNode.childCount;
|
var cc = bNode.childCount;
|
||||||
for (let i = 0; i < cc; ++i) {
|
for (var i = 0; i < cc; ++i) {
|
||||||
let child = bNode.getChild(i);
|
var child = bNode.getChild(i);
|
||||||
let suffix = i < (cc - 1) ? NEWLINE : "";
|
var suffix = i < (cc - 1) ? NEWLINE : "";
|
||||||
childString += gatherDataText(child) + suffix;
|
childString += gatherDataText(child) + suffix;
|
||||||
}
|
}
|
||||||
bNode.containerOpen = wasOpen;
|
bNode.containerOpen = wasOpen;
|
||||||
|
@ -628,12 +651,11 @@ var PlacesUtils = {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
let [node, shouldClose] = convertNode(aNode);
|
var node = convertNode(aNode);
|
||||||
let dataText = gatherDataText(node);
|
var dataText = gatherDataText(node);
|
||||||
// Convert node could pass an open container node.
|
// Convert node could pass an open container node.
|
||||||
if (shouldClose)
|
if (self.nodeIsContainer(node))
|
||||||
node.containerOpen = false;
|
node.containerOpen = false;
|
||||||
|
|
||||||
return dataText;
|
return dataText;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче