зеркало из https://github.com/mozilla/gecko-dev.git
Checking in the selection implementation (with more functions added).
This commit is contained in:
Родитель
b8cf1c5a5d
Коммит
46340eebe5
|
@ -170,6 +170,30 @@ nsXULTreeElement::RemoveCellFromSelection(nsIDOMXULElement* aTreeCell)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeElement::ToggleItemSelection(nsIDOMXULElement* aTreeItem)
|
||||
{
|
||||
nsAutoString isSelected;
|
||||
aTreeItem->GetAttribute("selected", isSelected);
|
||||
if (isSelected == "true")
|
||||
RemoveItemFromSelection(aTreeItem);
|
||||
else AddItemToSelection(aTreeItem);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeElement::ToggleCellSelection(nsIDOMXULElement* aTreeCell)
|
||||
{
|
||||
nsAutoString isSelected;
|
||||
aTreeCell->GetAttribute("selected", isSelected);
|
||||
if (isSelected == "true")
|
||||
RemoveItemFromSelection(aTreeCell);
|
||||
else AddItemToSelection(aTreeCell);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem)
|
||||
|
|
|
@ -15,6 +15,9 @@ interface XULTreeElement : XULElement {
|
|||
void addCellToSelection(in XULElement treeCell);
|
||||
void removeCellFromSelection(in XULElement treeCell);
|
||||
|
||||
void toggleItemSelection(in XULElement treeItem);
|
||||
void toggleCellSelection(in XULElement treeCell);
|
||||
|
||||
void selectItemRange(in XULElement startItem, in XULElement endItem);
|
||||
void selectCellRange(in XULElement startItem, in XULElement endItem);
|
||||
|
||||
|
|
|
@ -54,6 +54,10 @@ public:
|
|||
|
||||
NS_IMETHOD RemoveCellFromSelection(nsIDOMXULElement* aTreeCell)=0;
|
||||
|
||||
NS_IMETHOD ToggleItemSelection(nsIDOMXULElement* aTreeItem)=0;
|
||||
|
||||
NS_IMETHOD ToggleCellSelection(nsIDOMXULElement* aTreeCell)=0;
|
||||
|
||||
NS_IMETHOD SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem)=0;
|
||||
|
||||
NS_IMETHOD SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem)=0;
|
||||
|
@ -74,6 +78,8 @@ public:
|
|||
NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem); \
|
||||
NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell); \
|
||||
NS_IMETHOD RemoveCellFromSelection(nsIDOMXULElement* aTreeCell); \
|
||||
NS_IMETHOD ToggleItemSelection(nsIDOMXULElement* aTreeItem); \
|
||||
NS_IMETHOD ToggleCellSelection(nsIDOMXULElement* aTreeCell); \
|
||||
NS_IMETHOD SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem); \
|
||||
NS_IMETHOD SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem); \
|
||||
NS_IMETHOD SelectAll(); \
|
||||
|
@ -91,6 +97,8 @@ public:
|
|||
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 ToggleItemSelection(nsIDOMXULElement* aTreeItem) { return _to ToggleItemSelection(aTreeItem); } \
|
||||
NS_IMETHOD ToggleCellSelection(nsIDOMXULElement* aTreeCell) { return _to ToggleCellSelection(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(); } \
|
||||
|
|
|
@ -564,6 +564,118 @@ XULTreeElementRemoveCellFromSelection(JSContext *cx, JSObject *obj, uintN argc,
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToggleItemSelection
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULTreeElementToggleItemSelection(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.toggleitemselection", &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 toggleItemSelection 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->ToggleItemSelection(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToggleCellSelection
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULTreeElementToggleCellSelection(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.togglecellselection", &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 toggleCellSelection 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->ToggleCellSelection(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method SelectItemRange
|
||||
//
|
||||
|
@ -819,6 +931,8 @@ static JSFunctionSpec XULTreeElementMethods[] =
|
|||
{"removeItemFromSelection", XULTreeElementRemoveItemFromSelection, 1},
|
||||
{"addCellToSelection", XULTreeElementAddCellToSelection, 1},
|
||||
{"removeCellFromSelection", XULTreeElementRemoveCellFromSelection, 1},
|
||||
{"toggleItemSelection", XULTreeElementToggleItemSelection, 1},
|
||||
{"toggleCellSelection", XULTreeElementToggleCellSelection, 1},
|
||||
{"selectItemRange", XULTreeElementSelectItemRange, 2},
|
||||
{"selectCellRange", XULTreeElementSelectCellRange, 2},
|
||||
{"selectAll", XULTreeElementSelectAll, 0},
|
||||
|
|
|
@ -15,6 +15,9 @@ interface XULTreeElement : XULElement {
|
|||
void addCellToSelection(in XULElement treeCell);
|
||||
void removeCellFromSelection(in XULElement treeCell);
|
||||
|
||||
void toggleItemSelection(in XULElement treeItem);
|
||||
void toggleCellSelection(in XULElement treeCell);
|
||||
|
||||
void selectItemRange(in XULElement startItem, in XULElement endItem);
|
||||
void selectCellRange(in XULElement startItem, in XULElement endItem);
|
||||
|
||||
|
|
|
@ -54,6 +54,10 @@ public:
|
|||
|
||||
NS_IMETHOD RemoveCellFromSelection(nsIDOMXULElement* aTreeCell)=0;
|
||||
|
||||
NS_IMETHOD ToggleItemSelection(nsIDOMXULElement* aTreeItem)=0;
|
||||
|
||||
NS_IMETHOD ToggleCellSelection(nsIDOMXULElement* aTreeCell)=0;
|
||||
|
||||
NS_IMETHOD SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem)=0;
|
||||
|
||||
NS_IMETHOD SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem)=0;
|
||||
|
@ -74,6 +78,8 @@ public:
|
|||
NS_IMETHOD RemoveItemFromSelection(nsIDOMXULElement* aTreeItem); \
|
||||
NS_IMETHOD AddCellToSelection(nsIDOMXULElement* aTreeCell); \
|
||||
NS_IMETHOD RemoveCellFromSelection(nsIDOMXULElement* aTreeCell); \
|
||||
NS_IMETHOD ToggleItemSelection(nsIDOMXULElement* aTreeItem); \
|
||||
NS_IMETHOD ToggleCellSelection(nsIDOMXULElement* aTreeCell); \
|
||||
NS_IMETHOD SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem); \
|
||||
NS_IMETHOD SelectCellRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem); \
|
||||
NS_IMETHOD SelectAll(); \
|
||||
|
@ -91,6 +97,8 @@ public:
|
|||
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 ToggleItemSelection(nsIDOMXULElement* aTreeItem) { return _to ToggleItemSelection(aTreeItem); } \
|
||||
NS_IMETHOD ToggleCellSelection(nsIDOMXULElement* aTreeCell) { return _to ToggleCellSelection(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(); } \
|
||||
|
|
|
@ -564,6 +564,118 @@ XULTreeElementRemoveCellFromSelection(JSContext *cx, JSObject *obj, uintN argc,
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToggleItemSelection
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULTreeElementToggleItemSelection(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.toggleitemselection", &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 toggleItemSelection 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->ToggleItemSelection(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method ToggleCellSelection
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
XULTreeElementToggleCellSelection(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.togglecellselection", &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 toggleCellSelection 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->ToggleCellSelection(b0)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method SelectItemRange
|
||||
//
|
||||
|
@ -819,6 +931,8 @@ static JSFunctionSpec XULTreeElementMethods[] =
|
|||
{"removeItemFromSelection", XULTreeElementRemoveItemFromSelection, 1},
|
||||
{"addCellToSelection", XULTreeElementAddCellToSelection, 1},
|
||||
{"removeCellFromSelection", XULTreeElementRemoveCellFromSelection, 1},
|
||||
{"toggleItemSelection", XULTreeElementToggleItemSelection, 1},
|
||||
{"toggleCellSelection", XULTreeElementToggleCellSelection, 1},
|
||||
{"selectItemRange", XULTreeElementSelectItemRange, 2},
|
||||
{"selectCellRange", XULTreeElementSelectCellRange, 2},
|
||||
{"selectAll", XULTreeElementSelectAll, 0},
|
||||
|
|
|
@ -170,6 +170,30 @@ nsXULTreeElement::RemoveCellFromSelection(nsIDOMXULElement* aTreeCell)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeElement::ToggleItemSelection(nsIDOMXULElement* aTreeItem)
|
||||
{
|
||||
nsAutoString isSelected;
|
||||
aTreeItem->GetAttribute("selected", isSelected);
|
||||
if (isSelected == "true")
|
||||
RemoveItemFromSelection(aTreeItem);
|
||||
else AddItemToSelection(aTreeItem);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeElement::ToggleCellSelection(nsIDOMXULElement* aTreeCell)
|
||||
{
|
||||
nsAutoString isSelected;
|
||||
aTreeCell->GetAttribute("selected", isSelected);
|
||||
if (isSelected == "true")
|
||||
RemoveItemFromSelection(aTreeCell);
|
||||
else AddItemToSelection(aTreeCell);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULTreeElement::SelectItemRange(nsIDOMXULElement* aStartItem, nsIDOMXULElement* aEndItem)
|
||||
|
|
Загрузка…
Ссылка в новой задаче