This commit is contained in:
hyatt%netscape.com 1999-08-22 06:53:01 +00:00
Родитель d4e0a79380
Коммит 7513b7afc1
8 изменённых файлов: 196 добавлений и 40 удалений

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

@ -87,8 +87,20 @@ nsXULTreeElement::GetSelectedCells(nsIDOMNodeList** aSelectedCells)
NS_IMETHODIMP NS_IMETHODIMP
nsXULTreeElement::SelectItem(nsIDOMXULElement* aTreeItem) nsXULTreeElement::SelectItem(nsIDOMXULElement* aTreeItem)
{ {
// Sanity check. If we're the only item, just bail.
PRUint32 length;
mSelectedItems->GetLength(&length);
if (length == 1) {
// See if the single item already selected is us.
nsCOMPtr<nsIDOMNode> domNode;
mSelectedItems->Item(0, getter_AddRefs(domNode));
nsCOMPtr<nsIDOMXULElement> treeItem = do_QueryInterface(domNode);
if (treeItem.get() == aTreeItem)
return NS_OK;
}
// First clear our selection. // First clear our selection.
ClearSelection(); ClearItemSelection();
// Now add ourselves to the selection by setting our selected attribute. // Now add ourselves to the selection by setting our selected attribute.
AddItemToSelection(aTreeItem); AddItemToSelection(aTreeItem);
@ -99,8 +111,20 @@ nsXULTreeElement::SelectItem(nsIDOMXULElement* aTreeItem)
NS_IMETHODIMP NS_IMETHODIMP
nsXULTreeElement::SelectCell(nsIDOMXULElement* aTreeCell) nsXULTreeElement::SelectCell(nsIDOMXULElement* aTreeCell)
{ {
// Sanity check. If we're the only item, just bail.
PRUint32 length;
mSelectedCells->GetLength(&length);
if (length == 1) {
// See if the single item already selected is us.
nsCOMPtr<nsIDOMNode> domNode;
mSelectedCells->Item(0, getter_AddRefs(domNode));
nsCOMPtr<nsIDOMXULElement> treeCell = do_QueryInterface(domNode);
if (treeCell.get() == aTreeCell)
return NS_OK;
}
// First clear our selection. // First clear our selection.
ClearSelection(); ClearCellSelection();
// Now add ourselves to the selection by setting our selected attribute. // Now add ourselves to the selection by setting our selected attribute.
AddCellToSelection(aTreeCell); AddCellToSelection(aTreeCell);
@ -109,21 +133,26 @@ nsXULTreeElement::SelectCell(nsIDOMXULElement* aTreeCell)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsXULTreeElement::ClearSelection() nsXULTreeElement::ClearItemSelection()
{ {
// Enumerate the elements and remove them from the selection. // Enumerate the elements and remove them from the selection.
PRUint32 length; PRUint32 length;
mSelectedItems->GetLength(&length); mSelectedItems->GetLength(&length);
PRUint32 i; for (PRUint32 i = 0; i < length; i++) {
for (i = 0; i < length; i++) {
nsCOMPtr<nsIDOMNode> node; nsCOMPtr<nsIDOMNode> node;
mSelectedItems->Item(0, getter_AddRefs(node)); mSelectedItems->Item(0, getter_AddRefs(node));
nsCOMPtr<nsIContent> content = do_QueryInterface(node); nsCOMPtr<nsIContent> content = do_QueryInterface(node);
content->UnsetAttribute(kNameSpaceID_None, kSelectedAtom, PR_TRUE); content->UnsetAttribute(kNameSpaceID_None, kSelectedAtom, PR_TRUE);
} }
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeElement::ClearCellSelection()
{
PRUint32 length;
mSelectedCells->GetLength(&length); mSelectedCells->GetLength(&length);
for (i = 0; i < length; i++) { for (PRUint32 i = 0; i < length; i++) {
nsCOMPtr<nsIDOMNode> node; nsCOMPtr<nsIDOMNode> node;
mSelectedCells->Item(0, getter_AddRefs(node)); mSelectedCells->Item(0, getter_AddRefs(node));
nsCOMPtr<nsIContent> content = do_QueryInterface(node); nsCOMPtr<nsIContent> content = do_QueryInterface(node);
@ -188,8 +217,8 @@ nsXULTreeElement::ToggleCellSelection(nsIDOMXULElement* aTreeCell)
nsAutoString isSelected; nsAutoString isSelected;
aTreeCell->GetAttribute("selected", isSelected); aTreeCell->GetAttribute("selected", isSelected);
if (isSelected == "true") if (isSelected == "true")
RemoveItemFromSelection(aTreeCell); RemoveCellFromSelection(aTreeCell);
else AddItemToSelection(aTreeCell); else AddCellToSelection(aTreeCell);
return NS_OK; return NS_OK;
} }
@ -213,7 +242,8 @@ NS_IMETHODIMP
nsXULTreeElement::SelectAll() nsXULTreeElement::SelectAll()
{ {
// Do a clear. // Do a clear.
ClearSelection(); ClearItemSelection();
ClearCellSelection();
// Now do an invert. That will select everything. // Now do an invert. That will select everything.
InvertSelection(); InvertSelection();

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

@ -7,7 +7,8 @@ interface XULTreeElement : XULElement {
void selectItem(in XULElement treeItem); void selectItem(in XULElement treeItem);
void selectCell(in XULElement treeCell); void selectCell(in XULElement treeCell);
void clearSelection(); void clearItemSelection();
void clearCellSelection();
void addItemToSelection(in XULElement treeItem); void addItemToSelection(in XULElement treeItem);
void removeItemFromSelection(in XULElement treeItem); void removeItemFromSelection(in XULElement treeItem);
@ -22,6 +23,5 @@ interface XULTreeElement : XULElement {
void selectCellRange(in XULElement startItem, in XULElement endItem); void selectCellRange(in XULElement startItem, in XULElement endItem);
void selectAll(); void selectAll();
void invertSelection(); void invertSelection();
}; };

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

@ -44,7 +44,9 @@ public:
NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell)=0; NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell)=0;
NS_IMETHOD ClearSelection()=0; NS_IMETHOD ClearItemSelection()=0;
NS_IMETHOD ClearCellSelection()=0;
NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem)=0; NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem)=0;
@ -73,7 +75,8 @@ public:
NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells); \ NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells); \
NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem); \ NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem); \
NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell); \ NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell); \
NS_IMETHOD ClearSelection(); \ NS_IMETHOD ClearItemSelection(); \
NS_IMETHOD ClearCellSelection(); \
NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem); \ NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem); \
NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem); \ NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem); \
NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell); \ NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell); \
@ -92,7 +95,8 @@ public:
NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells) { return _to GetSelectedCells(aSelectedCells); } \ NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells) { return _to GetSelectedCells(aSelectedCells); } \
NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem) { return _to SelectItem(aTreeItem); } \ NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem) { return _to SelectItem(aTreeItem); } \
NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell) { return _to SelectCell(aTreeCell); } \ NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell) { return _to SelectCell(aTreeCell); } \
NS_IMETHOD ClearSelection() { return _to ClearSelection(); } \ NS_IMETHOD ClearItemSelection() { return _to ClearItemSelection(); } \
NS_IMETHOD ClearCellSelection() { return _to ClearCellSelection(); } \
NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem) { return _to AddItemToSelection(aTreeItem); } \ NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem) { return _to AddItemToSelection(aTreeItem); } \
NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem) { return _to RemoveItemFromSelection(aTreeItem); } \ NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem) { return _to RemoveItemFromSelection(aTreeItem); } \
NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell) { return _to AddCellToSelection(aTreeCell); } \ NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell) { return _to AddCellToSelection(aTreeCell); } \

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

@ -298,10 +298,10 @@ XULTreeElementSelectCell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
// //
// Native method ClearSelection // Native method ClearItemSelection
// //
PR_STATIC_CALLBACK(JSBool) PR_STATIC_CALLBACK(JSBool)
XULTreeElementClearSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) XULTreeElementClearItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{ {
nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj);
@ -314,7 +314,7 @@ XULTreeElementClearSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
} }
{ {
PRBool ok; PRBool ok;
secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.clearselection", &ok); secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.clearitemselection", &ok);
if (!ok) { if (!ok) {
//Need to throw error here //Need to throw error here
return JS_FALSE; return JS_FALSE;
@ -329,7 +329,50 @@ XULTreeElementClearSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
{ {
if (NS_OK != nativeThis->ClearSelection()) { if (NS_OK != nativeThis->ClearItemSelection()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
return JS_TRUE;
}
//
// Native method ClearCellSelection
//
PR_STATIC_CALLBACK(JSBool)
XULTreeElementClearCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj);
*rval = JSVAL_NULL;
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
nsIScriptSecurityManager *secMan;
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
return JS_FALSE;
}
{
PRBool ok;
secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.clearcellselection", &ok);
if (!ok) {
//Need to throw error here
return JS_FALSE;
}
NS_RELEASE(secMan);
}
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
{
if (NS_OK != nativeThis->ClearCellSelection()) {
return JS_FALSE; return JS_FALSE;
} }
@ -926,7 +969,8 @@ static JSFunctionSpec XULTreeElementMethods[] =
{ {
{"selectItem", XULTreeElementSelectItem, 1}, {"selectItem", XULTreeElementSelectItem, 1},
{"selectCell", XULTreeElementSelectCell, 1}, {"selectCell", XULTreeElementSelectCell, 1},
{"clearSelection", XULTreeElementClearSelection, 0}, {"clearItemSelection", XULTreeElementClearItemSelection, 0},
{"clearCellSelection", XULTreeElementClearCellSelection, 0},
{"addItemToSelection", XULTreeElementAddItemToSelection, 1}, {"addItemToSelection", XULTreeElementAddItemToSelection, 1},
{"removeItemFromSelection", XULTreeElementRemoveItemFromSelection, 1}, {"removeItemFromSelection", XULTreeElementRemoveItemFromSelection, 1},
{"addCellToSelection", XULTreeElementAddCellToSelection, 1}, {"addCellToSelection", XULTreeElementAddCellToSelection, 1},

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

@ -7,7 +7,8 @@ interface XULTreeElement : XULElement {
void selectItem(in XULElement treeItem); void selectItem(in XULElement treeItem);
void selectCell(in XULElement treeCell); void selectCell(in XULElement treeCell);
void clearSelection(); void clearItemSelection();
void clearCellSelection();
void addItemToSelection(in XULElement treeItem); void addItemToSelection(in XULElement treeItem);
void removeItemFromSelection(in XULElement treeItem); void removeItemFromSelection(in XULElement treeItem);
@ -22,6 +23,5 @@ interface XULTreeElement : XULElement {
void selectCellRange(in XULElement startItem, in XULElement endItem); void selectCellRange(in XULElement startItem, in XULElement endItem);
void selectAll(); void selectAll();
void invertSelection(); void invertSelection();
}; };

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

@ -44,7 +44,9 @@ public:
NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell)=0; NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell)=0;
NS_IMETHOD ClearSelection()=0; NS_IMETHOD ClearItemSelection()=0;
NS_IMETHOD ClearCellSelection()=0;
NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem)=0; NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem)=0;
@ -73,7 +75,8 @@ public:
NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells); \ NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells); \
NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem); \ NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem); \
NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell); \ NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell); \
NS_IMETHOD ClearSelection(); \ NS_IMETHOD ClearItemSelection(); \
NS_IMETHOD ClearCellSelection(); \
NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem); \ NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem); \
NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem); \ NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem); \
NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell); \ NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell); \
@ -92,7 +95,8 @@ public:
NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells) { return _to GetSelectedCells(aSelectedCells); } \ NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells) { return _to GetSelectedCells(aSelectedCells); } \
NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem) { return _to SelectItem(aTreeItem); } \ NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem) { return _to SelectItem(aTreeItem); } \
NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell) { return _to SelectCell(aTreeCell); } \ NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell) { return _to SelectCell(aTreeCell); } \
NS_IMETHOD ClearSelection() { return _to ClearSelection(); } \ NS_IMETHOD ClearItemSelection() { return _to ClearItemSelection(); } \
NS_IMETHOD ClearCellSelection() { return _to ClearCellSelection(); } \
NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem) { return _to AddItemToSelection(aTreeItem); } \ NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem) { return _to AddItemToSelection(aTreeItem); } \
NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem) { return _to RemoveItemFromSelection(aTreeItem); } \ NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem) { return _to RemoveItemFromSelection(aTreeItem); } \
NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell) { return _to AddCellToSelection(aTreeCell); } \ NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell) { return _to AddCellToSelection(aTreeCell); } \

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

@ -298,10 +298,10 @@ XULTreeElementSelectCell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
// //
// Native method ClearSelection // Native method ClearItemSelection
// //
PR_STATIC_CALLBACK(JSBool) PR_STATIC_CALLBACK(JSBool)
XULTreeElementClearSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) XULTreeElementClearItemSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{ {
nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj);
@ -314,7 +314,7 @@ XULTreeElementClearSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
} }
{ {
PRBool ok; PRBool ok;
secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.clearselection", &ok); secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.clearitemselection", &ok);
if (!ok) { if (!ok) {
//Need to throw error here //Need to throw error here
return JS_FALSE; return JS_FALSE;
@ -329,7 +329,50 @@ XULTreeElementClearSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
{ {
if (NS_OK != nativeThis->ClearSelection()) { if (NS_OK != nativeThis->ClearItemSelection()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
return JS_TRUE;
}
//
// Native method ClearCellSelection
//
PR_STATIC_CALLBACK(JSBool)
XULTreeElementClearCellSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj);
*rval = JSVAL_NULL;
nsIScriptContext *scriptCX = (nsIScriptContext *)JS_GetContextPrivate(cx);
nsIScriptSecurityManager *secMan;
if (NS_OK != scriptCX->GetSecurityManager(&secMan)) {
return JS_FALSE;
}
{
PRBool ok;
secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.clearcellselection", &ok);
if (!ok) {
//Need to throw error here
return JS_FALSE;
}
NS_RELEASE(secMan);
}
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
{
if (NS_OK != nativeThis->ClearCellSelection()) {
return JS_FALSE; return JS_FALSE;
} }
@ -926,7 +969,8 @@ static JSFunctionSpec XULTreeElementMethods[] =
{ {
{"selectItem", XULTreeElementSelectItem, 1}, {"selectItem", XULTreeElementSelectItem, 1},
{"selectCell", XULTreeElementSelectCell, 1}, {"selectCell", XULTreeElementSelectCell, 1},
{"clearSelection", XULTreeElementClearSelection, 0}, {"clearItemSelection", XULTreeElementClearItemSelection, 0},
{"clearCellSelection", XULTreeElementClearCellSelection, 0},
{"addItemToSelection", XULTreeElementAddItemToSelection, 1}, {"addItemToSelection", XULTreeElementAddItemToSelection, 1},
{"removeItemFromSelection", XULTreeElementRemoveItemFromSelection, 1}, {"removeItemFromSelection", XULTreeElementRemoveItemFromSelection, 1},
{"addCellToSelection", XULTreeElementAddCellToSelection, 1}, {"addCellToSelection", XULTreeElementAddCellToSelection, 1},

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

@ -87,8 +87,20 @@ nsXULTreeElement::GetSelectedCells(nsIDOMNodeList** aSelectedCells)
NS_IMETHODIMP NS_IMETHODIMP
nsXULTreeElement::SelectItem(nsIDOMXULElement* aTreeItem) nsXULTreeElement::SelectItem(nsIDOMXULElement* aTreeItem)
{ {
// Sanity check. If we're the only item, just bail.
PRUint32 length;
mSelectedItems->GetLength(&length);
if (length == 1) {
// See if the single item already selected is us.
nsCOMPtr<nsIDOMNode> domNode;
mSelectedItems->Item(0, getter_AddRefs(domNode));
nsCOMPtr<nsIDOMXULElement> treeItem = do_QueryInterface(domNode);
if (treeItem.get() == aTreeItem)
return NS_OK;
}
// First clear our selection. // First clear our selection.
ClearSelection(); ClearItemSelection();
// Now add ourselves to the selection by setting our selected attribute. // Now add ourselves to the selection by setting our selected attribute.
AddItemToSelection(aTreeItem); AddItemToSelection(aTreeItem);
@ -99,8 +111,20 @@ nsXULTreeElement::SelectItem(nsIDOMXULElement* aTreeItem)
NS_IMETHODIMP NS_IMETHODIMP
nsXULTreeElement::SelectCell(nsIDOMXULElement* aTreeCell) nsXULTreeElement::SelectCell(nsIDOMXULElement* aTreeCell)
{ {
// Sanity check. If we're the only item, just bail.
PRUint32 length;
mSelectedCells->GetLength(&length);
if (length == 1) {
// See if the single item already selected is us.
nsCOMPtr<nsIDOMNode> domNode;
mSelectedCells->Item(0, getter_AddRefs(domNode));
nsCOMPtr<nsIDOMXULElement> treeCell = do_QueryInterface(domNode);
if (treeCell.get() == aTreeCell)
return NS_OK;
}
// First clear our selection. // First clear our selection.
ClearSelection(); ClearCellSelection();
// Now add ourselves to the selection by setting our selected attribute. // Now add ourselves to the selection by setting our selected attribute.
AddCellToSelection(aTreeCell); AddCellToSelection(aTreeCell);
@ -109,21 +133,26 @@ nsXULTreeElement::SelectCell(nsIDOMXULElement* aTreeCell)
} }
NS_IMETHODIMP NS_IMETHODIMP
nsXULTreeElement::ClearSelection() nsXULTreeElement::ClearItemSelection()
{ {
// Enumerate the elements and remove them from the selection. // Enumerate the elements and remove them from the selection.
PRUint32 length; PRUint32 length;
mSelectedItems->GetLength(&length); mSelectedItems->GetLength(&length);
PRUint32 i; for (PRUint32 i = 0; i < length; i++) {
for (i = 0; i < length; i++) {
nsCOMPtr<nsIDOMNode> node; nsCOMPtr<nsIDOMNode> node;
mSelectedItems->Item(0, getter_AddRefs(node)); mSelectedItems->Item(0, getter_AddRefs(node));
nsCOMPtr<nsIContent> content = do_QueryInterface(node); nsCOMPtr<nsIContent> content = do_QueryInterface(node);
content->UnsetAttribute(kNameSpaceID_None, kSelectedAtom, PR_TRUE); content->UnsetAttribute(kNameSpaceID_None, kSelectedAtom, PR_TRUE);
} }
return NS_OK;
}
NS_IMETHODIMP
nsXULTreeElement::ClearCellSelection()
{
PRUint32 length;
mSelectedCells->GetLength(&length); mSelectedCells->GetLength(&length);
for (i = 0; i < length; i++) { for (PRUint32 i = 0; i < length; i++) {
nsCOMPtr<nsIDOMNode> node; nsCOMPtr<nsIDOMNode> node;
mSelectedCells->Item(0, getter_AddRefs(node)); mSelectedCells->Item(0, getter_AddRefs(node));
nsCOMPtr<nsIContent> content = do_QueryInterface(node); nsCOMPtr<nsIContent> content = do_QueryInterface(node);
@ -188,8 +217,8 @@ nsXULTreeElement::ToggleCellSelection(nsIDOMXULElement* aTreeCell)
nsAutoString isSelected; nsAutoString isSelected;
aTreeCell->GetAttribute("selected", isSelected); aTreeCell->GetAttribute("selected", isSelected);
if (isSelected == "true") if (isSelected == "true")
RemoveItemFromSelection(aTreeCell); RemoveCellFromSelection(aTreeCell);
else AddItemToSelection(aTreeCell); else AddCellToSelection(aTreeCell);
return NS_OK; return NS_OK;
} }
@ -213,7 +242,8 @@ NS_IMETHODIMP
nsXULTreeElement::SelectAll() nsXULTreeElement::SelectAll()
{ {
// Do a clear. // Do a clear.
ClearSelection(); ClearItemSelection();
ClearCellSelection();
// Now do an invert. That will select everything. // Now do an invert. That will select everything.
InvertSelection(); InvertSelection();