Bug 369222 - Javascript error when opening the context menu for the empty area (i.e. root node) in the places toolbar. r=sspitzer.

This commit is contained in:
mozilla.mano%sent.com 2007-02-04 19:23:00 +00:00
parent 30e2748426
commit c16ce0cd79
2 changed files with 24 additions and 6 deletions

View File

@ -257,13 +257,17 @@ PlacesController.prototype = {
this._canInsert() &&
this._view.peerDropTypes.indexOf(TYPE_X_MOZ_PLACE_SEPARATOR) != -1;
case "placesCmd_show:info":
var selectedNode = this._view.selectedNode;
if (this._view.hasSingleSelection &&
!PlacesUtils.nodeIsLivemarkContainer(selectedNode.parent) &&
!this._selectionOverlapsSystemArea()) {
if (PlacesUtils.nodeIsBookmark(selectedNode) ||
PlacesUtils.nodeIsFolder(selectedNode))
if (this._view.hasSingleSelection) {
var selectedNode = this._view.selectedNode;
if (PlacesUtils.nodeIsBookmark(selectedNode))
return true;
if (PlacesUtils.nodeIsFolder(selectedNode)) {
if (!this._selectionOverlapsSystemArea()) {
var parent = selectedNode.parent;
if (!parent || !PlacesUtils.nodeIsLivemarkContainer(parent))
return true;
}
}
}
return false;
#endif

View File

@ -204,6 +204,7 @@ var PlacesUtils = {
*/
nodeIsSeparator: function PU_nodeIsSeparator(aNode) {
NS_ASSERT(aNode, "null node");
return (aNode.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_SEPARATOR);
},
@ -215,6 +216,7 @@ var PlacesUtils = {
*/
nodeIsURI: function PU_nodeIsURI(aNode) {
NS_ASSERT(aNode, "null node");
const NHRN = Ci.nsINavHistoryResultNode;
return aNode.type == NHRN.RESULT_TYPE_URI ||
aNode.type == NHRN.RESULT_TYPE_VISIT ||
@ -229,6 +231,7 @@ var PlacesUtils = {
*/
nodeIsQuery: function PU_nodeIsQuery(aNode) {
NS_ASSERT(aNode, "null node");
return aNode.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_QUERY;
},
@ -241,6 +244,7 @@ var PlacesUtils = {
*/
nodeIsReadOnly: function PU_nodeIsReadOnly(aNode) {
NS_ASSERT(aNode, "null node");
if (this.nodeIsFolder(aNode))
return this.bookmarks.getFolderReadonly(asFolder(aNode).folderId);
if (this.nodeIsQuery(aNode))
@ -255,6 +259,8 @@ var PlacesUtils = {
* @returns true if the node is a host item, false otherwise
*/
nodeIsHost: function PU_nodeIsHost(aNode) {
NS_ASSERT(aNode, "null node");
return aNode.type == Ci.nsINavHistoryResultNode.RESULT_TYPE_HOST;
},
@ -265,6 +271,8 @@ var PlacesUtils = {
* @returns true if the node is a container item, false otherwise
*/
nodeIsContainer: function PU_nodeIsContainer(aNode) {
NS_ASSERT(aNode, "null node");
const NHRN = Ci.nsINavHistoryResultNode;
return aNode.type == NHRN.RESULT_TYPE_HOST ||
aNode.type == NHRN.RESULT_TYPE_QUERY ||
@ -287,6 +295,8 @@ var PlacesUtils = {
* @returns true if the node is a container item, false otherwise
*/
nodeIsRemoteContainer: function PU_nodeIsRemoteContainer(aNode) {
NS_ASSERT(aNode, "null node");
const NHRN = Ci.nsINavHistoryResultNode;
if (aNode.type == NHRN.RESULT_TYPE_REMOTE_CONTAINER)
return true;
@ -315,6 +325,8 @@ var PlacesUtils = {
* @returns true if the node is a readonly folder.
*/
folderIsReadonly: function(aNode) {
NS_ASSERT(aNode, "null node");
return this.nodeIsFolder(aNode) &&
this.bookmarks.getFolderReadonly(asFolder(aNode).folderId);
},
@ -327,6 +339,8 @@ var PlacesUtils = {
* node was not found or the node specified has no parent.
*/
getIndexOfNode: function PU_getIndexOfNode(aNode) {
NS_ASSERT(aNode, "null node");
var parent = aNode.parent;
if (!parent || !PlacesUtils.nodeIsContainer(parent))
return -1;