Defining the selection API for the tree widget. Stubbed all of the functions.

Now I just have to implement them all.
This commit is contained in:
hyatt%netscape.com 1999-08-22 06:01:52 +00:00
Родитель a22520cfca
Коммит c28227eb81
13 изменённых файлов: 1652 добавлений и 114 удалений

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

@ -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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIContent> current;
GetParent(*getter_AddRefs(current));
while (current) {
nsCOMPtr<nsIAtom> tag;
current->GetTag(*getter_AddRefs(tag));
if (tag && (tag.get() == kTreeAtom)) {
nsCOMPtr<nsIDOMXULTreeElement> element = do_QueryInterface(current);
*aTreeElement = element;
NS_IF_ADDREF(*aTreeElement);
return NS_OK;
}
nsCOMPtr<nsIContent> parent;
current->GetParent(*getter_AddRefs(parent));
current = parent.get();
}
return NS_OK;
}

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

@ -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;
}

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

@ -53,7 +53,6 @@ public:
protected:
nsIDOMNodeList* mSelectedItems;
nsIDOMNodeList* mSelectedRows;
nsIDOMNodeList* mSelectedCells;
};

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

@ -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();
};

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

@ -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);

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

@ -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}
};

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

@ -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();
};

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

@ -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);

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

@ -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}
};

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

@ -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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIContent> current;
GetParent(*getter_AddRefs(current));
while (current) {
nsCOMPtr<nsIAtom> tag;
current->GetTag(*getter_AddRefs(tag));
if (tag && (tag.get() == kTreeAtom)) {
nsCOMPtr<nsIDOMXULTreeElement> element = do_QueryInterface(current);
*aTreeElement = element;
NS_IF_ADDREF(*aTreeElement);
return NS_OK;
}
nsCOMPtr<nsIContent> parent;
current->GetParent(*getter_AddRefs(parent));
current = parent.get();
}
return NS_OK;
}

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

@ -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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIDOMXULTreeElement> treeElement;
GetParentTree(getter_AddRefs(treeElement));
if (treeElement) {
nsCOMPtr<nsIDOMNodeList> 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<nsIContent> current;
GetParent(*getter_AddRefs(current));
while (current) {
nsCOMPtr<nsIAtom> tag;
current->GetTag(*getter_AddRefs(tag));
if (tag && (tag.get() == kTreeAtom)) {
nsCOMPtr<nsIDOMXULTreeElement> element = do_QueryInterface(current);
*aTreeElement = element;
NS_IF_ADDREF(*aTreeElement);
return NS_OK;
}
nsCOMPtr<nsIContent> parent;
current->GetParent(*getter_AddRefs(parent));
current = parent.get();
}
return NS_OK;
}

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

@ -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;
}

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

@ -53,7 +53,6 @@ public:
protected:
nsIDOMNodeList* mSelectedItems;
nsIDOMNodeList* mSelectedRows;
nsIDOMNodeList* mSelectedCells;
};