зеркало из https://github.com/mozilla/pjs.git
Bug 3285: Update impl files to add item method to proprietary interface.
This commit is contained in:
Родитель
abb2b151b4
Коммит
5cf7c7ff36
|
@ -240,9 +240,26 @@ GetHTMLFormElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
break;
|
||||
}
|
||||
default:
|
||||
checkNamedItem = PR_TRUE;
|
||||
{
|
||||
nsIDOMElement* prop;
|
||||
nsIDOMNSHTMLFormElement* b;
|
||||
if (NS_OK == a->QueryInterface(kINSHTMLFormElementIID, (void **)&b)) {
|
||||
if (NS_OK == b->Item(JSVAL_TO_INT(id), &prop)) {
|
||||
// get the js object
|
||||
nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp);
|
||||
NS_RELEASE(b);
|
||||
}
|
||||
else {
|
||||
NS_RELEASE(b);
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
JS_ReportError(cx, "Object must be of type NSHTMLFormElement");
|
||||
return JS_FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
NS_RELEASE(secMan);
|
||||
}
|
||||
|
||||
if (checkNamedItem) {
|
||||
|
@ -580,6 +597,66 @@ NSHTMLFormElementNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv
|
|||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method Item
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NSHTMLFormElementItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMHTMLFormElement *privateThis = (nsIDOMHTMLFormElement*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsIDOMNSHTMLFormElement *nativeThis = nsnull;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSHTMLFormElementIID, (void **)&nativeThis)) {
|
||||
JS_ReportError(cx, "Object must be of type NSHTMLFormElement");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsIDOMElement* nativeRet;
|
||||
PRUint32 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, "nshtmlformelement.item", &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 item requires 1 parameter");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (!JS_ValueToInt32(cx, argv[0], (int32 *)&b0)) {
|
||||
JS_ReportError(cx, "Parameter must be a number");
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
if (NS_OK != nativeThis->Item(b0, &nativeRet)) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, rval);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for HTMLFormElement
|
||||
|
@ -624,6 +701,7 @@ static JSFunctionSpec HTMLFormElementMethods[] =
|
|||
{"submit", HTMLFormElementSubmit, 0},
|
||||
{"reset", HTMLFormElementReset, 0},
|
||||
{"namedItem", NSHTMLFormElementNamedItem, 1},
|
||||
{"item", NSHTMLFormElementItem, 1},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIDOMHTMLSelectElement.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMHTMLElement.h"
|
||||
#include "nsIDOMHTMLFormElement.h"
|
||||
#include "nsIDOMNode.h"
|
||||
#include "nsIDOMNSHTMLSelectElement.h"
|
||||
#include "nsIDOMHTMLCollection.h"
|
||||
|
||||
|
@ -39,16 +39,16 @@ 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(kIHTMLSelectElementIID, NS_IDOMHTMLSELECTELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLElementIID, NS_IDOMHTMLELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeIID, NS_IDOMNODE_IID);
|
||||
static NS_DEFINE_IID(kINSHTMLSelectElementIID, NS_IDOMNSHTMLSELECTELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIHTMLCollectionIID, NS_IDOMHTMLCOLLECTION_IID);
|
||||
|
||||
NS_DEF_PTR(nsIDOMHTMLSelectElement);
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMHTMLElement);
|
||||
NS_DEF_PTR(nsIDOMHTMLFormElement);
|
||||
NS_DEF_PTR(nsIDOMNode);
|
||||
NS_DEF_PTR(nsIDOMNSHTMLSelectElement);
|
||||
NS_DEF_PTR(nsIDOMHTMLCollection);
|
||||
|
||||
|
@ -271,7 +271,7 @@ GetHTMLSelectElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
}
|
||||
default:
|
||||
{
|
||||
nsIDOMNode* prop;
|
||||
nsIDOMElement* prop;
|
||||
nsIDOMNSHTMLSelectElement* b;
|
||||
if (NS_OK == a->QueryInterface(kINSHTMLSelectElementIID, (void **)&b)) {
|
||||
if (NS_OK == b->Item(JSVAL_TO_INT(id), &prop)) {
|
||||
|
@ -702,7 +702,7 @@ NSHTMLSelectElementItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, j
|
|||
return JS_FALSE;
|
||||
}
|
||||
|
||||
nsIDOMNode* nativeRet;
|
||||
nsIDOMElement* nativeRet;
|
||||
PRUint32 b0;
|
||||
|
||||
*rval = JSVAL_NULL;
|
||||
|
|
Загрузка…
Ссылка в новой задаче