From c28227eb816a4424cc8917de5e17cd917b28bbfe Mon Sep 17 00:00:00 2001 From: "hyatt%netscape.com" Date: Sun, 22 Aug 1999 06:01:52 +0000 Subject: [PATCH] Defining the selection API for the tree widget. Stubbed all of the functions. Now I just have to implement them all. --- content/xul/content/src/nsXULElement.cpp | 68 +- content/xul/content/src/nsXULTreeElement.cpp | 84 ++- content/xul/content/src/nsXULTreeElement.h | 1 - dom/public/idl/xul/XULTreeElement.idl | 19 +- dom/public/xul/nsIDOMXULTreeElement.h | 49 +- dom/src/xul/nsJSXULTreeElement.cpp | 628 ++++++++++++++++++- rdf/content/public/idl/XULTreeElement.idl | 19 +- rdf/content/public/nsIDOMXULTreeElement.h | 49 +- rdf/content/src/nsJSXULTreeElement.cpp | 628 ++++++++++++++++++- rdf/content/src/nsRDFElement.cpp | 68 +- rdf/content/src/nsXULElement.cpp | 68 +- rdf/content/src/nsXULTreeElement.cpp | 84 ++- rdf/content/src/nsXULTreeElement.h | 1 - 13 files changed, 1652 insertions(+), 114 deletions(-) diff --git a/content/xul/content/src/nsXULElement.cpp b/content/xul/content/src/nsXULElement.cpp index 35519d10c7d..17707311b09 100644 --- a/content/xul/content/src/nsXULElement.cpp +++ b/content/xul/content/src/nsXULElement.cpp @@ -360,6 +360,9 @@ public: const nsString& aAttributeValue, nsRDFDOMNodeList* aElements); + // Helper routine that crawls a parent chain looking for a tree element. + NS_IMETHOD GetParentTree(nsIDOMXULTreeElement** aTreeElement); + private: // pseudo-constants static nsrefcnt gRefCnt; @@ -2040,13 +2043,22 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID, // See if we're a treeitem atom. nsRDFDOMNodeList* nodeList = nsnull; if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) { - - } - else if (tag && (tag.get() == kTreeRowAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedItems(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedCells(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } if (nodeList) { // Append this node to the list. @@ -2321,15 +2333,28 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot GetTag(*getter_AddRefs(tag)); if (mDocument && (aNameSpaceID == kNameSpaceID_None)) { // See if we're a treeitem atom. + // XXX Forgive me father, for I know exactly what I do, and I'm + // doing it anyway. Need to make an nsIRDFNodeList interface that + // I can QI to for additions and removals of nodes. For now + // do an evil cast. nsRDFDOMNodeList* nodeList = nsnull; if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) { - - } - else if (tag && (tag.get() == kTreeRowAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedItems(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedCells(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } if (nodeList) { // Remove this node from the list. @@ -3260,3 +3285,26 @@ RDFElementImpl::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) NS_NOTYETIMPLEMENTED("write me!"); return NS_ERROR_NOT_IMPLEMENTED; } + +NS_IMETHODIMP +RDFElementImpl::GetParentTree(nsIDOMXULTreeElement** aTreeElement) +{ + nsCOMPtr current; + GetParent(*getter_AddRefs(current)); + while (current) { + nsCOMPtr tag; + current->GetTag(*getter_AddRefs(tag)); + if (tag && (tag.get() == kTreeAtom)) { + nsCOMPtr element = do_QueryInterface(current); + *aTreeElement = element; + NS_IF_ADDREF(*aTreeElement); + return NS_OK; + } + + nsCOMPtr parent; + current->GetParent(*getter_AddRefs(parent)); + current = parent.get(); + } + return NS_OK; +} + diff --git a/content/xul/content/src/nsXULTreeElement.cpp b/content/xul/content/src/nsXULTreeElement.cpp index e95d2469bcc..0b19377074c 100644 --- a/content/xul/content/src/nsXULTreeElement.cpp +++ b/content/xul/content/src/nsXULTreeElement.cpp @@ -46,20 +46,12 @@ nsXULTreeElement::nsXULTreeElement(nsIDOMXULElement* aOuter) NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create DOM node list"); if (NS_FAILED(rv)) return; - mSelectedRows = children; - - children = nsnull; - rv = nsRDFDOMNodeList::Create(&children); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create DOM node list"); - if (NS_FAILED(rv)) return; - mSelectedCells = children; } nsXULTreeElement::~nsXULTreeElement() { NS_IF_RELEASE(mSelectedItems); - NS_IF_RELEASE(mSelectedRows); NS_IF_RELEASE(mSelectedCells); } @@ -71,14 +63,6 @@ nsXULTreeElement::GetSelectedItems(nsIDOMNodeList** aSelectedItems) return NS_OK; } -NS_IMETHODIMP -nsXULTreeElement::GetSelectedRows(nsIDOMNodeList** aSelectedRows) -{ - NS_IF_ADDREF(mSelectedRows); - *aSelectedRows = mSelectedRows; - return NS_OK; -} - NS_IMETHODIMP nsXULTreeElement::GetSelectedCells(nsIDOMNodeList** aSelectedCells) { @@ -86,3 +70,71 @@ nsXULTreeElement::GetSelectedCells(nsIDOMNodeList** aSelectedCells) *aSelectedCells = mSelectedCells; return NS_OK; } + +NS_IMETHODIMP +nsXULTreeElement::SelectItem(nsIDOMXULElement* aTreeItem) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::SelectCell(nsIDOMXULElement* aTreeCell) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::ClearSelection() +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::AddItemToSelection(nsIDOMXULElement* aTreeItem) +{ + return NS_OK; +} + + +NS_IMETHODIMP +nsXULTreeElement::RemoveItemFromSelection(nsIDOMXULElement* aTreeItem) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::AddCellToSelection(nsIDOMXULElement* aTreeCell) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::RemoveCellFromSelection(nsIDOMXULElement* aTreeCell) +{ + return NS_OK; +} + + +NS_IMETHODIMP +nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::SelectAll() +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::InvertSelection() +{ + return NS_OK; +} diff --git a/content/xul/content/src/nsXULTreeElement.h b/content/xul/content/src/nsXULTreeElement.h index 5e2da78f6a0..c953bbf2d00 100644 --- a/content/xul/content/src/nsXULTreeElement.h +++ b/content/xul/content/src/nsXULTreeElement.h @@ -53,7 +53,6 @@ public: protected: nsIDOMNodeList* mSelectedItems; - nsIDOMNodeList* mSelectedRows; nsIDOMNodeList* mSelectedCells; }; diff --git a/dom/public/idl/xul/XULTreeElement.idl b/dom/public/idl/xul/XULTreeElement.idl index 036a124d7a6..794184b7b4c 100644 --- a/dom/public/idl/xul/XULTreeElement.idl +++ b/dom/public/idl/xul/XULTreeElement.idl @@ -2,6 +2,23 @@ interface XULTreeElement : XULElement { /* IID: { 0xa6cf90ec, 0x15b3, 0x11d2, \ {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } */ readonly attribute NodeList selectedItems; - readonly attribute NodeList selectedRows; readonly attribute NodeList selectedCells; + + void selectItem(in XULElement treeItem); + void selectCell(in XULElement treeCell); + + void clearSelection(); + + void addItemToSelection(in XULElement treeItem); + void removeItemFromSelection(in XULElement treeItem); + + void addCellToSelection(in XULElement treeCell); + void removeCellFromSelection(in XULElement treeCell); + + void selectItemRange(in XULElement startItem, in XULElement endItem); + void selectCellRange(in XULElement startItem, in XULElement endItem); + + void selectAll(); + + void invertSelection(); }; diff --git a/dom/public/xul/nsIDOMXULTreeElement.h b/dom/public/xul/nsIDOMXULTreeElement.h index 59c1152f3ac..5af923cb02c 100644 --- a/dom/public/xul/nsIDOMXULTreeElement.h +++ b/dom/public/xul/nsIDOMXULTreeElement.h @@ -25,6 +25,7 @@ #include "nsIScriptContext.h" #include "nsIDOMXULElement.h" +class nsIDOMXULElement; class nsIDOMNodeList; #define NS_IDOMXULTREEELEMENT_IID \ @@ -37,23 +38,63 @@ public: NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems)=0; - NS_IMETHOD GetSelectedRows(nsIDOMNodeList** aSelectedRows)=0; - NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells)=0; + + NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem)=0; + + NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell)=0; + + NS_IMETHOD ClearSelection()=0; + + NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem)=0; + + NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem)=0; + + NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell)=0; + + NS_IMETHOD RemoveCellFromSelection(nsIDOMXULElement* aTreeCell)=0; + + NS_IMETHOD SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem)=0; + + NS_IMETHOD SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem)=0; + + NS_IMETHOD SelectAll()=0; + + NS_IMETHOD InvertSelection()=0; }; #define NS_DECL_IDOMXULTREEELEMENT \ NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems); \ - NS_IMETHOD GetSelectedRows(nsIDOMNodeList** aSelectedRows); \ NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells); \ + NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem); \ + NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell); \ + NS_IMETHOD ClearSelection(); \ + NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem); \ + NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem); \ + NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell); \ + NS_IMETHOD RemoveCellFromSelection(nsIDOMXULElement* aTreeCell); \ + NS_IMETHOD SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem); \ + NS_IMETHOD SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem); \ + NS_IMETHOD SelectAll(); \ + NS_IMETHOD InvertSelection(); \ #define NS_FORWARD_IDOMXULTREEELEMENT(_to) \ NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems) { return _to GetSelectedItems(aSelectedItems); } \ - NS_IMETHOD GetSelectedRows(nsIDOMNodeList** aSelectedRows) { return _to GetSelectedRows(aSelectedRows); } \ NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells) { return _to GetSelectedCells(aSelectedCells); } \ + NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem) { return _to SelectItem(aTreeItem); } \ + NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell) { return _to SelectCell(aTreeCell); } \ + NS_IMETHOD ClearSelection() { return _to ClearSelection(); } \ + NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem) { return _to AddItemToSelection(aTreeItem); } \ + NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem) { return _to RemoveItemFromSelection(aTreeItem); } \ + NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell) { return _to AddCellToSelection(aTreeCell); } \ + NS_IMETHOD RemoveCellFromSelection(nsIDOMXULElement* aTreeCell) { return _to RemoveCellFromSelection(aTreeCell); } \ + NS_IMETHOD SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem) { return _to SelectItemRange(aStartItem, aEndItem); } \ + NS_IMETHOD SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem) { return _to SelectCellRange(aStartItem, aEndItem); } \ + NS_IMETHOD SelectAll() { return _to SelectAll(); } \ + NS_IMETHOD InvertSelection() { return _to InvertSelection(); } \ extern "C" NS_DOM nsresult NS_InitXULTreeElementClass(nsIScriptContext *aContext, void **aPrototype); diff --git a/dom/src/xul/nsJSXULTreeElement.cpp b/dom/src/xul/nsJSXULTreeElement.cpp index decd3b7e6be..87f0e262536 100644 --- a/dom/src/xul/nsJSXULTreeElement.cpp +++ b/dom/src/xul/nsJSXULTreeElement.cpp @@ -27,6 +27,7 @@ #include "nsIScriptGlobalObject.h" #include "nsIPtr.h" #include "nsString.h" +#include "nsIDOMXULElement.h" #include "nsIDOMXULTreeElement.h" #include "nsIDOMNodeList.h" @@ -34,9 +35,11 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); +static NS_DEFINE_IID(kIXULElementIID, NS_IDOMXULELEMENT_IID); static NS_DEFINE_IID(kIXULTreeElementIID, NS_IDOMXULTREEELEMENT_IID); static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID); +NS_DEF_PTR(nsIDOMXULElement); NS_DEF_PTR(nsIDOMXULTreeElement); NS_DEF_PTR(nsIDOMNodeList); @@ -45,8 +48,7 @@ NS_DEF_PTR(nsIDOMNodeList); // enum XULTreeElement_slots { XULTREEELEMENT_SELECTEDITEMS = -1, - XULTREEELEMENT_SELECTEDROWS = -2, - XULTREEELEMENT_SELECTEDCELLS = -3 + XULTREEELEMENT_SELECTEDCELLS = -2 }; /***********************************************************************/ @@ -88,23 +90,6 @@ GetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } - case XULTREEELEMENT_SELECTEDROWS: - { - secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.selectedrows", &ok); - if (!ok) { - //Need to throw error here - return JS_FALSE; - } - nsIDOMNodeList* prop; - if (NS_SUCCEEDED(a->GetSelectedRows(&prop))) { - // get the js object - nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp); - } - else { - return JS_FALSE; - } - break; - } case XULTREEELEMENT_SELECTEDCELLS: { secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.selectedcells", &ok); @@ -200,6 +185,599 @@ ResolveXULTreeElement(JSContext *cx, JSObject *obj, jsval id) } +// +// Native method SelectItem +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementSelectItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.selectitem", &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 (argc < 1) { + JS_ReportError(cx, "Function selectItem requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->SelectItem(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method SelectCell +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementSelectCell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.selectcell", &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 (argc < 1) { + JS_ReportError(cx, "Function selectCell requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->SelectCell(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method ClearSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementClearSelection(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.clearselection", &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->ClearSelection()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method AddItemToSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementAddItemToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.additemtoselection", &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 (argc < 1) { + JS_ReportError(cx, "Function addItemToSelection requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->AddItemToSelection(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method RemoveItemFromSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementRemoveItemFromSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.removeitemfromselection", &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 (argc < 1) { + JS_ReportError(cx, "Function removeItemFromSelection requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->RemoveItemFromSelection(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method AddCellToSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementAddCellToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.addcelltoselection", &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 (argc < 1) { + JS_ReportError(cx, "Function addCellToSelection requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->AddCellToSelection(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method RemoveCellFromSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementRemoveCellFromSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.removecellfromselection", &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 (argc < 1) { + JS_ReportError(cx, "Function removeCellFromSelection requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->RemoveCellFromSelection(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method SelectItemRange +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementSelectItemRange(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + nsIDOMXULElementPtr b1; + + *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.selectitemrange", &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 (argc < 2) { + JS_ReportError(cx, "Function selectItemRange requires 2 parameters"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1, + kIXULElementIID, + "XULElement", + cx, + argv[1])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->SelectItemRange(b0, b1)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method SelectCellRange +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementSelectCellRange(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + nsIDOMXULElementPtr b1; + + *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.selectcellrange", &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 (argc < 2) { + JS_ReportError(cx, "Function selectCellRange requires 2 parameters"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1, + kIXULElementIID, + "XULElement", + cx, + argv[1])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->SelectCellRange(b0, b1)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method SelectAll +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementSelectAll(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.selectall", &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->SelectAll()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method InvertSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementInvertSelection(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.invertselection", &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->InvertSelection()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + /***********************************************************************/ // // class for XULTreeElement @@ -224,7 +802,6 @@ JSClass XULTreeElementClass = { static JSPropertySpec XULTreeElementProperties[] = { {"selectedItems", XULTREEELEMENT_SELECTEDITEMS, JSPROP_ENUMERATE | JSPROP_READONLY}, - {"selectedRows", XULTREEELEMENT_SELECTEDROWS, JSPROP_ENUMERATE | JSPROP_READONLY}, {"selectedCells", XULTREEELEMENT_SELECTEDCELLS, JSPROP_ENUMERATE | JSPROP_READONLY}, {0} }; @@ -235,6 +812,17 @@ static JSPropertySpec XULTreeElementProperties[] = // static JSFunctionSpec XULTreeElementMethods[] = { + {"selectItem", XULTreeElementSelectItem, 1}, + {"selectCell", XULTreeElementSelectCell, 1}, + {"clearSelection", XULTreeElementClearSelection, 0}, + {"addItemToSelection", XULTreeElementAddItemToSelection, 1}, + {"removeItemFromSelection", XULTreeElementRemoveItemFromSelection, 1}, + {"addCellToSelection", XULTreeElementAddCellToSelection, 1}, + {"removeCellFromSelection", XULTreeElementRemoveCellFromSelection, 1}, + {"selectItemRange", XULTreeElementSelectItemRange, 2}, + {"selectCellRange", XULTreeElementSelectCellRange, 2}, + {"selectAll", XULTreeElementSelectAll, 0}, + {"invertSelection", XULTreeElementInvertSelection, 0}, {0} }; diff --git a/rdf/content/public/idl/XULTreeElement.idl b/rdf/content/public/idl/XULTreeElement.idl index 036a124d7a6..794184b7b4c 100644 --- a/rdf/content/public/idl/XULTreeElement.idl +++ b/rdf/content/public/idl/XULTreeElement.idl @@ -2,6 +2,23 @@ interface XULTreeElement : XULElement { /* IID: { 0xa6cf90ec, 0x15b3, 0x11d2, \ {0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } */ readonly attribute NodeList selectedItems; - readonly attribute NodeList selectedRows; readonly attribute NodeList selectedCells; + + void selectItem(in XULElement treeItem); + void selectCell(in XULElement treeCell); + + void clearSelection(); + + void addItemToSelection(in XULElement treeItem); + void removeItemFromSelection(in XULElement treeItem); + + void addCellToSelection(in XULElement treeCell); + void removeCellFromSelection(in XULElement treeCell); + + void selectItemRange(in XULElement startItem, in XULElement endItem); + void selectCellRange(in XULElement startItem, in XULElement endItem); + + void selectAll(); + + void invertSelection(); }; diff --git a/rdf/content/public/nsIDOMXULTreeElement.h b/rdf/content/public/nsIDOMXULTreeElement.h index 59c1152f3ac..5af923cb02c 100644 --- a/rdf/content/public/nsIDOMXULTreeElement.h +++ b/rdf/content/public/nsIDOMXULTreeElement.h @@ -25,6 +25,7 @@ #include "nsIScriptContext.h" #include "nsIDOMXULElement.h" +class nsIDOMXULElement; class nsIDOMNodeList; #define NS_IDOMXULTREEELEMENT_IID \ @@ -37,23 +38,63 @@ public: NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems)=0; - NS_IMETHOD GetSelectedRows(nsIDOMNodeList** aSelectedRows)=0; - NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells)=0; + + NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem)=0; + + NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell)=0; + + NS_IMETHOD ClearSelection()=0; + + NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem)=0; + + NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem)=0; + + NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell)=0; + + NS_IMETHOD RemoveCellFromSelection(nsIDOMXULElement* aTreeCell)=0; + + NS_IMETHOD SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem)=0; + + NS_IMETHOD SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem)=0; + + NS_IMETHOD SelectAll()=0; + + NS_IMETHOD InvertSelection()=0; }; #define NS_DECL_IDOMXULTREEELEMENT \ NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems); \ - NS_IMETHOD GetSelectedRows(nsIDOMNodeList** aSelectedRows); \ NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells); \ + NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem); \ + NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell); \ + NS_IMETHOD ClearSelection(); \ + NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem); \ + NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem); \ + NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell); \ + NS_IMETHOD RemoveCellFromSelection(nsIDOMXULElement* aTreeCell); \ + NS_IMETHOD SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem); \ + NS_IMETHOD SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem); \ + NS_IMETHOD SelectAll(); \ + NS_IMETHOD InvertSelection(); \ #define NS_FORWARD_IDOMXULTREEELEMENT(_to) \ NS_IMETHOD GetSelectedItems(nsIDOMNodeList** aSelectedItems) { return _to GetSelectedItems(aSelectedItems); } \ - NS_IMETHOD GetSelectedRows(nsIDOMNodeList** aSelectedRows) { return _to GetSelectedRows(aSelectedRows); } \ NS_IMETHOD GetSelectedCells(nsIDOMNodeList** aSelectedCells) { return _to GetSelectedCells(aSelectedCells); } \ + NS_IMETHOD SelectItem(nsIDOMXULElement* aTreeItem) { return _to SelectItem(aTreeItem); } \ + NS_IMETHOD SelectCell(nsIDOMXULElement* aTreeCell) { return _to SelectCell(aTreeCell); } \ + NS_IMETHOD ClearSelection() { return _to ClearSelection(); } \ + NS_IMETHOD AddItemToSelection(nsIDOMXULElement* aTreeItem) { return _to AddItemToSelection(aTreeItem); } \ + NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem) { return _to RemoveItemFromSelection(aTreeItem); } \ + NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell) { return _to AddCellToSelection(aTreeCell); } \ + NS_IMETHOD RemoveCellFromSelection(nsIDOMXULElement* aTreeCell) { return _to RemoveCellFromSelection(aTreeCell); } \ + NS_IMETHOD SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem) { return _to SelectItemRange(aStartItem, aEndItem); } \ + NS_IMETHOD SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem) { return _to SelectCellRange(aStartItem, aEndItem); } \ + NS_IMETHOD SelectAll() { return _to SelectAll(); } \ + NS_IMETHOD InvertSelection() { return _to InvertSelection(); } \ extern "C" NS_DOM nsresult NS_InitXULTreeElementClass(nsIScriptContext *aContext, void **aPrototype); diff --git a/rdf/content/src/nsJSXULTreeElement.cpp b/rdf/content/src/nsJSXULTreeElement.cpp index decd3b7e6be..87f0e262536 100644 --- a/rdf/content/src/nsJSXULTreeElement.cpp +++ b/rdf/content/src/nsJSXULTreeElement.cpp @@ -27,6 +27,7 @@ #include "nsIScriptGlobalObject.h" #include "nsIPtr.h" #include "nsString.h" +#include "nsIDOMXULElement.h" #include "nsIDOMXULTreeElement.h" #include "nsIDOMNodeList.h" @@ -34,9 +35,11 @@ static NS_DEFINE_IID(kIScriptObjectOwnerIID, NS_ISCRIPTOBJECTOWNER_IID); static NS_DEFINE_IID(kIJSScriptObjectIID, NS_IJSSCRIPTOBJECT_IID); static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID); +static NS_DEFINE_IID(kIXULElementIID, NS_IDOMXULELEMENT_IID); static NS_DEFINE_IID(kIXULTreeElementIID, NS_IDOMXULTREEELEMENT_IID); static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID); +NS_DEF_PTR(nsIDOMXULElement); NS_DEF_PTR(nsIDOMXULTreeElement); NS_DEF_PTR(nsIDOMNodeList); @@ -45,8 +48,7 @@ NS_DEF_PTR(nsIDOMNodeList); // enum XULTreeElement_slots { XULTREEELEMENT_SELECTEDITEMS = -1, - XULTREEELEMENT_SELECTEDROWS = -2, - XULTREEELEMENT_SELECTEDCELLS = -3 + XULTREEELEMENT_SELECTEDCELLS = -2 }; /***********************************************************************/ @@ -88,23 +90,6 @@ GetXULTreeElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } - case XULTREEELEMENT_SELECTEDROWS: - { - secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.selectedrows", &ok); - if (!ok) { - //Need to throw error here - return JS_FALSE; - } - nsIDOMNodeList* prop; - if (NS_SUCCEEDED(a->GetSelectedRows(&prop))) { - // get the js object - nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp); - } - else { - return JS_FALSE; - } - break; - } case XULTREEELEMENT_SELECTEDCELLS: { secMan->CheckScriptAccess(scriptCX, obj, "xultreeelement.selectedcells", &ok); @@ -200,6 +185,599 @@ ResolveXULTreeElement(JSContext *cx, JSObject *obj, jsval id) } +// +// Native method SelectItem +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementSelectItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.selectitem", &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 (argc < 1) { + JS_ReportError(cx, "Function selectItem requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->SelectItem(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method SelectCell +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementSelectCell(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.selectcell", &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 (argc < 1) { + JS_ReportError(cx, "Function selectCell requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->SelectCell(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method ClearSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementClearSelection(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.clearselection", &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->ClearSelection()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method AddItemToSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementAddItemToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.additemtoselection", &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 (argc < 1) { + JS_ReportError(cx, "Function addItemToSelection requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->AddItemToSelection(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method RemoveItemFromSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementRemoveItemFromSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.removeitemfromselection", &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 (argc < 1) { + JS_ReportError(cx, "Function removeItemFromSelection requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->RemoveItemFromSelection(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method AddCellToSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementAddCellToSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.addcelltoselection", &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 (argc < 1) { + JS_ReportError(cx, "Function addCellToSelection requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->AddCellToSelection(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method RemoveCellFromSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementRemoveCellFromSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + + *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.removecellfromselection", &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 (argc < 1) { + JS_ReportError(cx, "Function removeCellFromSelection requires 1 parameter"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->RemoveCellFromSelection(b0)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method SelectItemRange +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementSelectItemRange(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + nsIDOMXULElementPtr b1; + + *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.selectitemrange", &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 (argc < 2) { + JS_ReportError(cx, "Function selectItemRange requires 2 parameters"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1, + kIXULElementIID, + "XULElement", + cx, + argv[1])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->SelectItemRange(b0, b1)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method SelectCellRange +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementSelectCellRange(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + nsIDOMXULTreeElement *nativeThis = (nsIDOMXULTreeElement*)nsJSUtils::nsGetNativeThis(cx, obj); + nsIDOMXULElementPtr b0; + nsIDOMXULElementPtr b1; + + *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.selectcellrange", &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 (argc < 2) { + JS_ReportError(cx, "Function selectCellRange requires 2 parameters"); + return JS_FALSE; + } + + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b0, + kIXULElementIID, + "XULElement", + cx, + argv[0])) { + return JS_FALSE; + } + if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)&b1, + kIXULElementIID, + "XULElement", + cx, + argv[1])) { + return JS_FALSE; + } + + if (NS_OK != nativeThis->SelectCellRange(b0, b1)) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method SelectAll +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementSelectAll(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.selectall", &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->SelectAll()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + +// +// Native method InvertSelection +// +PR_STATIC_CALLBACK(JSBool) +XULTreeElementInvertSelection(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.invertselection", &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->InvertSelection()) { + return JS_FALSE; + } + + *rval = JSVAL_VOID; + } + + return JS_TRUE; +} + + /***********************************************************************/ // // class for XULTreeElement @@ -224,7 +802,6 @@ JSClass XULTreeElementClass = { static JSPropertySpec XULTreeElementProperties[] = { {"selectedItems", XULTREEELEMENT_SELECTEDITEMS, JSPROP_ENUMERATE | JSPROP_READONLY}, - {"selectedRows", XULTREEELEMENT_SELECTEDROWS, JSPROP_ENUMERATE | JSPROP_READONLY}, {"selectedCells", XULTREEELEMENT_SELECTEDCELLS, JSPROP_ENUMERATE | JSPROP_READONLY}, {0} }; @@ -235,6 +812,17 @@ static JSPropertySpec XULTreeElementProperties[] = // static JSFunctionSpec XULTreeElementMethods[] = { + {"selectItem", XULTreeElementSelectItem, 1}, + {"selectCell", XULTreeElementSelectCell, 1}, + {"clearSelection", XULTreeElementClearSelection, 0}, + {"addItemToSelection", XULTreeElementAddItemToSelection, 1}, + {"removeItemFromSelection", XULTreeElementRemoveItemFromSelection, 1}, + {"addCellToSelection", XULTreeElementAddCellToSelection, 1}, + {"removeCellFromSelection", XULTreeElementRemoveCellFromSelection, 1}, + {"selectItemRange", XULTreeElementSelectItemRange, 2}, + {"selectCellRange", XULTreeElementSelectCellRange, 2}, + {"selectAll", XULTreeElementSelectAll, 0}, + {"invertSelection", XULTreeElementInvertSelection, 0}, {0} }; diff --git a/rdf/content/src/nsRDFElement.cpp b/rdf/content/src/nsRDFElement.cpp index 35519d10c7d..17707311b09 100644 --- a/rdf/content/src/nsRDFElement.cpp +++ b/rdf/content/src/nsRDFElement.cpp @@ -360,6 +360,9 @@ public: const nsString& aAttributeValue, nsRDFDOMNodeList* aElements); + // Helper routine that crawls a parent chain looking for a tree element. + NS_IMETHOD GetParentTree(nsIDOMXULTreeElement** aTreeElement); + private: // pseudo-constants static nsrefcnt gRefCnt; @@ -2040,13 +2043,22 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID, // See if we're a treeitem atom. nsRDFDOMNodeList* nodeList = nsnull; if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) { - - } - else if (tag && (tag.get() == kTreeRowAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedItems(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedCells(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } if (nodeList) { // Append this node to the list. @@ -2321,15 +2333,28 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot GetTag(*getter_AddRefs(tag)); if (mDocument && (aNameSpaceID == kNameSpaceID_None)) { // See if we're a treeitem atom. + // XXX Forgive me father, for I know exactly what I do, and I'm + // doing it anyway. Need to make an nsIRDFNodeList interface that + // I can QI to for additions and removals of nodes. For now + // do an evil cast. nsRDFDOMNodeList* nodeList = nsnull; if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) { - - } - else if (tag && (tag.get() == kTreeRowAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedItems(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedCells(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } if (nodeList) { // Remove this node from the list. @@ -3260,3 +3285,26 @@ RDFElementImpl::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) NS_NOTYETIMPLEMENTED("write me!"); return NS_ERROR_NOT_IMPLEMENTED; } + +NS_IMETHODIMP +RDFElementImpl::GetParentTree(nsIDOMXULTreeElement** aTreeElement) +{ + nsCOMPtr current; + GetParent(*getter_AddRefs(current)); + while (current) { + nsCOMPtr tag; + current->GetTag(*getter_AddRefs(tag)); + if (tag && (tag.get() == kTreeAtom)) { + nsCOMPtr element = do_QueryInterface(current); + *aTreeElement = element; + NS_IF_ADDREF(*aTreeElement); + return NS_OK; + } + + nsCOMPtr parent; + current->GetParent(*getter_AddRefs(parent)); + current = parent.get(); + } + return NS_OK; +} + diff --git a/rdf/content/src/nsXULElement.cpp b/rdf/content/src/nsXULElement.cpp index 35519d10c7d..17707311b09 100644 --- a/rdf/content/src/nsXULElement.cpp +++ b/rdf/content/src/nsXULElement.cpp @@ -360,6 +360,9 @@ public: const nsString& aAttributeValue, nsRDFDOMNodeList* aElements); + // Helper routine that crawls a parent chain looking for a tree element. + NS_IMETHOD GetParentTree(nsIDOMXULTreeElement** aTreeElement); + private: // pseudo-constants static nsrefcnt gRefCnt; @@ -2040,13 +2043,22 @@ RDFElementImpl::SetAttribute(PRInt32 aNameSpaceID, // See if we're a treeitem atom. nsRDFDOMNodeList* nodeList = nsnull; if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) { - - } - else if (tag && (tag.get() == kTreeRowAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedItems(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedCells(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } if (nodeList) { // Append this node to the list. @@ -2321,15 +2333,28 @@ RDFElementImpl::UnsetAttribute(PRInt32 aNameSpaceID, nsIAtom* aName, PRBool aNot GetTag(*getter_AddRefs(tag)); if (mDocument && (aNameSpaceID == kNameSpaceID_None)) { // See if we're a treeitem atom. + // XXX Forgive me father, for I know exactly what I do, and I'm + // doing it anyway. Need to make an nsIRDFNodeList interface that + // I can QI to for additions and removals of nodes. For now + // do an evil cast. nsRDFDOMNodeList* nodeList = nsnull; if (tag && (tag.get() == kTreeItemAtom) && (aName == kSelectedAtom)) { - - } - else if (tag && (tag.get() == kTreeRowAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedItems(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } else if (tag && (tag.get() == kTreeCellAtom) && (aName == kSelectedAtom)) { - + nsCOMPtr treeElement; + GetParentTree(getter_AddRefs(treeElement)); + if (treeElement) { + nsCOMPtr nodes; + treeElement->GetSelectedCells(getter_AddRefs(nodes)); + nodeList = (nsRDFDOMNodeList*)(nodes.get()); // XXX I am evil. Hear me roar. + } } if (nodeList) { // Remove this node from the list. @@ -3260,3 +3285,26 @@ RDFElementImpl::GetStyle(nsIDOMCSSStyleDeclaration** aStyle) NS_NOTYETIMPLEMENTED("write me!"); return NS_ERROR_NOT_IMPLEMENTED; } + +NS_IMETHODIMP +RDFElementImpl::GetParentTree(nsIDOMXULTreeElement** aTreeElement) +{ + nsCOMPtr current; + GetParent(*getter_AddRefs(current)); + while (current) { + nsCOMPtr tag; + current->GetTag(*getter_AddRefs(tag)); + if (tag && (tag.get() == kTreeAtom)) { + nsCOMPtr element = do_QueryInterface(current); + *aTreeElement = element; + NS_IF_ADDREF(*aTreeElement); + return NS_OK; + } + + nsCOMPtr parent; + current->GetParent(*getter_AddRefs(parent)); + current = parent.get(); + } + return NS_OK; +} + diff --git a/rdf/content/src/nsXULTreeElement.cpp b/rdf/content/src/nsXULTreeElement.cpp index e95d2469bcc..0b19377074c 100644 --- a/rdf/content/src/nsXULTreeElement.cpp +++ b/rdf/content/src/nsXULTreeElement.cpp @@ -46,20 +46,12 @@ nsXULTreeElement::nsXULTreeElement(nsIDOMXULElement* aOuter) NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create DOM node list"); if (NS_FAILED(rv)) return; - mSelectedRows = children; - - children = nsnull; - rv = nsRDFDOMNodeList::Create(&children); - NS_ASSERTION(NS_SUCCEEDED(rv), "unable to create DOM node list"); - if (NS_FAILED(rv)) return; - mSelectedCells = children; } nsXULTreeElement::~nsXULTreeElement() { NS_IF_RELEASE(mSelectedItems); - NS_IF_RELEASE(mSelectedRows); NS_IF_RELEASE(mSelectedCells); } @@ -71,14 +63,6 @@ nsXULTreeElement::GetSelectedItems(nsIDOMNodeList** aSelectedItems) return NS_OK; } -NS_IMETHODIMP -nsXULTreeElement::GetSelectedRows(nsIDOMNodeList** aSelectedRows) -{ - NS_IF_ADDREF(mSelectedRows); - *aSelectedRows = mSelectedRows; - return NS_OK; -} - NS_IMETHODIMP nsXULTreeElement::GetSelectedCells(nsIDOMNodeList** aSelectedCells) { @@ -86,3 +70,71 @@ nsXULTreeElement::GetSelectedCells(nsIDOMNodeList** aSelectedCells) *aSelectedCells = mSelectedCells; return NS_OK; } + +NS_IMETHODIMP +nsXULTreeElement::SelectItem(nsIDOMXULElement* aTreeItem) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::SelectCell(nsIDOMXULElement* aTreeCell) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::ClearSelection() +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::AddItemToSelection(nsIDOMXULElement* aTreeItem) +{ + return NS_OK; +} + + +NS_IMETHODIMP +nsXULTreeElement::RemoveItemFromSelection(nsIDOMXULElement* aTreeItem) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::AddCellToSelection(nsIDOMXULElement* aTreeCell) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::RemoveCellFromSelection(nsIDOMXULElement* aTreeCell) +{ + return NS_OK; +} + + +NS_IMETHODIMP +nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem) +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::SelectAll() +{ + return NS_OK; +} + +NS_IMETHODIMP +nsXULTreeElement::InvertSelection() +{ + return NS_OK; +} diff --git a/rdf/content/src/nsXULTreeElement.h b/rdf/content/src/nsXULTreeElement.h index 5e2da78f6a0..c953bbf2d00 100644 --- a/rdf/content/src/nsXULTreeElement.h +++ b/rdf/content/src/nsXULTreeElement.h @@ -53,7 +53,6 @@ public: protected: nsIDOMNodeList* mSelectedItems; - nsIDOMNodeList* mSelectedRows; nsIDOMNodeList* mSelectedCells; };