expose the form controls in a XUL document in the "controls" DOM attribute
this will make prefs and wizards much faster r=hyatt git-svn-id: svn://10.0.0.236/trunk@57613 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
parent
f92a42d3a2
commit
abb8b4f61a
@ -2604,6 +2604,19 @@ nsXULDocument::GetCommandDispatcher(nsIDOMXULCommandDispatcher** aTracker)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::GetControls(nsIDOMHTMLCollection ** aResult) {
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
// for now, just return the elements in the HTML form...
|
||||
// eventually we could return other XUL elements
|
||||
if (mHiddenForm)
|
||||
return mHiddenForm->GetElements(aResult);
|
||||
else
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::GetElementById(const nsString& aId, nsIDOMElement** aReturn)
|
||||
{
|
||||
|
||||
@ -12,4 +12,5 @@ interface XULDocument : Document {
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
|
||||
void persist(in DOMString id, in DOMString attr);
|
||||
readonly attribute HTMLCollection controls;
|
||||
};
|
||||
|
||||
@ -876,6 +876,7 @@ enum nsDOMProp {
|
||||
NS_DOM_PROP_XULCOMMANDDISPATCHER_REMOVECOMMANDUPDATER,
|
||||
NS_DOM_PROP_XULCOMMANDDISPATCHER_UPDATECOMMANDS,
|
||||
NS_DOM_PROP_XULDOCUMENT_COMMANDDISPATCHER,
|
||||
NS_DOM_PROP_XULDOCUMENT_CONTROLS,
|
||||
NS_DOM_PROP_XULDOCUMENT_GETELEMENTBYID,
|
||||
NS_DOM_PROP_XULDOCUMENT_GETELEMENTSBYATTRIBUTE,
|
||||
NS_DOM_PROP_XULDOCUMENT_PERSIST,
|
||||
|
||||
@ -875,6 +875,7 @@
|
||||
"xulcommanddispatcher.removecommandupdater", \
|
||||
"xulcommanddispatcher.updatecommands", \
|
||||
"xuldocument.commanddispatcher", \
|
||||
"xuldocument.controls", \
|
||||
"xuldocument.getelementbyid", \
|
||||
"xuldocument.getelementsbyattribute", \
|
||||
"xuldocument.persist", \
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
@ -32,6 +30,7 @@
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNode;
|
||||
class nsIDOMXULCommandDispatcher;
|
||||
class nsIDOMHTMLCollection;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
#define NS_IDOMXULDOCUMENT_IID \
|
||||
@ -50,6 +49,8 @@ public:
|
||||
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher)=0;
|
||||
|
||||
NS_IMETHOD GetControls(nsIDOMHTMLCollection** aControls)=0;
|
||||
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn)=0;
|
||||
@ -64,6 +65,7 @@ public:
|
||||
NS_IMETHOD GetTooltipNode(nsIDOMNode** aTooltipNode); \
|
||||
NS_IMETHOD SetTooltipNode(nsIDOMNode* aTooltipNode); \
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher); \
|
||||
NS_IMETHOD GetControls(nsIDOMHTMLCollection** aControls); \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
NS_IMETHOD Persist(const nsString& aId, const nsString& aAttr); \
|
||||
@ -76,6 +78,7 @@ public:
|
||||
NS_IMETHOD GetTooltipNode(nsIDOMNode** aTooltipNode) { return _to GetTooltipNode(aTooltipNode); } \
|
||||
NS_IMETHOD SetTooltipNode(nsIDOMNode* aTooltipNode) { return _to SetTooltipNode(aTooltipNode); } \
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher) { return _to GetCommandDispatcher(aCommandDispatcher); } \
|
||||
NS_IMETHOD GetControls(nsIDOMHTMLCollection** aControls) { return _to GetControls(aControls); } \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn) { return _to GetElementById(aId, aReturn); } \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn) { return _to GetElementsByAttribute(aName, aValue, aReturn); } \
|
||||
NS_IMETHOD Persist(const nsString& aId, const nsString& aAttr) { return _to Persist(aId, aAttr); } \
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
@ -38,6 +36,7 @@
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
|
||||
@ -48,6 +47,7 @@ static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIXULCommandDispatcherIID, NS_IDOMXULCOMMANDDISPATCHER_IID);
|
||||
static NS_DEFINE_IID(kIXULDocumentIID, NS_IDOMXULDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLCollectionIID, NS_IDOMHTMLCOLLECTION_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
//
|
||||
@ -56,7 +56,8 @@ static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
enum XULDocument_slots {
|
||||
XULDOCUMENT_POPUPNODE = -1,
|
||||
XULDOCUMENT_TOOLTIPNODE = -2,
|
||||
XULDOCUMENT_COMMANDDISPATCHER = -3
|
||||
XULDOCUMENT_COMMANDDISPATCHER = -3,
|
||||
XULDOCUMENT_CONTROLS = -4
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
@ -138,6 +139,25 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XULDOCUMENT_CONTROLS:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULDOCUMENT_CONTROLS, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
nsIDOMHTMLCollection* prop;
|
||||
nsresult result = NS_OK;
|
||||
result = a->GetControls(&prop);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp);
|
||||
}
|
||||
@ -431,6 +451,7 @@ static JSPropertySpec XULDocumentProperties[] =
|
||||
{"popupNode", XULDOCUMENT_POPUPNODE, JSPROP_ENUMERATE},
|
||||
{"tooltipNode", XULDOCUMENT_TOOLTIPNODE, JSPROP_ENUMERATE},
|
||||
{"commandDispatcher", XULDOCUMENT_COMMANDDISPATCHER, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"controls", XULDOCUMENT_CONTROLS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
@ -12,4 +12,5 @@ interface XULDocument : Document {
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
|
||||
void persist(in DOMString id, in DOMString attr);
|
||||
readonly attribute HTMLCollection controls;
|
||||
};
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
@ -32,6 +30,7 @@
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNode;
|
||||
class nsIDOMXULCommandDispatcher;
|
||||
class nsIDOMHTMLCollection;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
#define NS_IDOMXULDOCUMENT_IID \
|
||||
@ -50,6 +49,8 @@ public:
|
||||
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher)=0;
|
||||
|
||||
NS_IMETHOD GetControls(nsIDOMHTMLCollection** aControls)=0;
|
||||
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn)=0;
|
||||
@ -64,6 +65,7 @@ public:
|
||||
NS_IMETHOD GetTooltipNode(nsIDOMNode** aTooltipNode); \
|
||||
NS_IMETHOD SetTooltipNode(nsIDOMNode* aTooltipNode); \
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher); \
|
||||
NS_IMETHOD GetControls(nsIDOMHTMLCollection** aControls); \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
NS_IMETHOD Persist(const nsString& aId, const nsString& aAttr); \
|
||||
@ -76,6 +78,7 @@ public:
|
||||
NS_IMETHOD GetTooltipNode(nsIDOMNode** aTooltipNode) { return _to GetTooltipNode(aTooltipNode); } \
|
||||
NS_IMETHOD SetTooltipNode(nsIDOMNode* aTooltipNode) { return _to SetTooltipNode(aTooltipNode); } \
|
||||
NS_IMETHOD GetCommandDispatcher(nsIDOMXULCommandDispatcher** aCommandDispatcher) { return _to GetCommandDispatcher(aCommandDispatcher); } \
|
||||
NS_IMETHOD GetControls(nsIDOMHTMLCollection** aControls) { return _to GetControls(aControls); } \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn) { return _to GetElementById(aId, aReturn); } \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn) { return _to GetElementsByAttribute(aName, aValue, aReturn); } \
|
||||
NS_IMETHOD Persist(const nsString& aId, const nsString& aAttr) { return _to Persist(aId, aAttr); } \
|
||||
|
||||
@ -16,8 +16,6 @@
|
||||
* Communications Corporation. Portions created by Netscape are
|
||||
* Copyright (C) 1998 Netscape Communications Corporation. All
|
||||
* Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*/
|
||||
/* AUTO-GENERATED. DO NOT EDIT!!! */
|
||||
|
||||
@ -38,6 +36,7 @@
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMXULCommandDispatcher.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
||||
|
||||
@ -48,6 +47,7 @@ static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kIXULCommandDispatcherIID, NS_IDOMXULCOMMANDDISPATCHER_IID);
|
||||
static NS_DEFINE_IID(kIXULDocumentIID, NS_IDOMXULDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLCollectionIID, NS_IDOMHTMLCOLLECTION_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
//
|
||||
@ -56,7 +56,8 @@ static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
enum XULDocument_slots {
|
||||
XULDOCUMENT_POPUPNODE = -1,
|
||||
XULDOCUMENT_TOOLTIPNODE = -2,
|
||||
XULDOCUMENT_COMMANDDISPATCHER = -3
|
||||
XULDOCUMENT_COMMANDDISPATCHER = -3,
|
||||
XULDOCUMENT_CONTROLS = -4
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
@ -138,6 +139,25 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
||||
}
|
||||
break;
|
||||
}
|
||||
case XULDOCUMENT_CONTROLS:
|
||||
{
|
||||
PRBool ok = PR_FALSE;
|
||||
secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_XULDOCUMENT_CONTROLS, PR_FALSE, &ok);
|
||||
if (!ok) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_SECURITY_ERR);
|
||||
}
|
||||
nsIDOMHTMLCollection* prop;
|
||||
nsresult result = NS_OK;
|
||||
result = a->GetControls(&prop);
|
||||
if (NS_SUCCEEDED(result)) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, obj, vp);
|
||||
}
|
||||
else {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, obj, id, vp);
|
||||
}
|
||||
@ -431,6 +451,7 @@ static JSPropertySpec XULDocumentProperties[] =
|
||||
{"popupNode", XULDOCUMENT_POPUPNODE, JSPROP_ENUMERATE},
|
||||
{"tooltipNode", XULDOCUMENT_TOOLTIPNODE, JSPROP_ENUMERATE},
|
||||
{"commandDispatcher", XULDOCUMENT_COMMANDDISPATCHER, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{"controls", XULDOCUMENT_CONTROLS, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
@ -2604,6 +2604,19 @@ nsXULDocument::GetCommandDispatcher(nsIDOMXULCommandDispatcher** aTracker)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::GetControls(nsIDOMHTMLCollection ** aResult) {
|
||||
NS_ENSURE_ARG_POINTER(aResult);
|
||||
|
||||
// for now, just return the elements in the HTML form...
|
||||
// eventually we could return other XUL elements
|
||||
if (mHiddenForm)
|
||||
return mHiddenForm->GetElements(aResult);
|
||||
else
|
||||
*aResult = nsnull;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsXULDocument::GetElementById(const nsString& aId, nsIDOMElement** aReturn)
|
||||
{
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user