Patched nsDOMFactory to obey XBL forms pref. Added support for box objects to
documents and tweaked DocumentXBL methods. r=jst@netscape.com, a=ben@netscape.com git-svn-id: svn://10.0.0.236/trunk@83468 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -43,6 +43,8 @@ public:
|
||||
|
||||
NS_IMETHOD GetAnonymousNodes(nsIDOMElement* aElt, nsIDOMNodeList** aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetAnonymousElementByAttribute(const nsAReadableString& aAttrName, const nsAReadableString& aAttrValue, nsIDOMElement** aReturn)=0;
|
||||
|
||||
NS_IMETHOD AddBinding(nsIDOMElement* aElt, const nsAReadableString& aBindingURL)=0;
|
||||
|
||||
NS_IMETHOD RemoveBinding(nsIDOMElement* aElt, const nsAReadableString& aBindingURL)=0;
|
||||
@@ -55,6 +57,7 @@ public:
|
||||
|
||||
#define NS_DECL_IDOMDOCUMENTXBL \
|
||||
NS_IMETHOD GetAnonymousNodes(nsIDOMElement* aElt, nsIDOMNodeList** aReturn); \
|
||||
NS_IMETHOD GetAnonymousElementByAttribute(const nsAReadableString& aAttrName, const nsAReadableString& aAttrValue, nsIDOMElement** aReturn); \
|
||||
NS_IMETHOD AddBinding(nsIDOMElement* aElt, const nsAReadableString& aBindingURL); \
|
||||
NS_IMETHOD RemoveBinding(nsIDOMElement* aElt, const nsAReadableString& aBindingURL); \
|
||||
NS_IMETHOD GetBindingParent(nsIDOMNode* aNode, nsIDOMElement** aReturn); \
|
||||
@@ -64,6 +67,7 @@ public:
|
||||
|
||||
#define NS_FORWARD_IDOMDOCUMENTXBL(_to) \
|
||||
NS_IMETHOD GetAnonymousNodes(nsIDOMElement* aElt, nsIDOMNodeList** aReturn) { return _to GetAnonymousNodes(aElt, aReturn); } \
|
||||
NS_IMETHOD GetAnonymousElementByAttribute(const nsAReadableString& aAttrName, const nsAReadableString& aAttrValue, nsIDOMElement** aReturn) { return _to GetAnonymousElementByAttribute(aAttrName, aAttrValue, aReturn); } \
|
||||
NS_IMETHOD AddBinding(nsIDOMElement* aElt, const nsAReadableString& aBindingURL) { return _to AddBinding(aElt, aBindingURL); } \
|
||||
NS_IMETHOD RemoveBinding(nsIDOMElement* aElt, const nsAReadableString& aBindingURL) { return _to RemoveBinding(aElt, aBindingURL); } \
|
||||
NS_IMETHOD GetBindingParent(nsIDOMNode* aNode, nsIDOMElement** aReturn) { return _to GetBindingParent(aNode, aReturn); } \
|
||||
|
||||
@@ -29,7 +29,9 @@
|
||||
#include "nsIScriptContext.h"
|
||||
#include "jsapi.h"
|
||||
|
||||
class nsIDOMElement;
|
||||
class nsIDOMPluginArray;
|
||||
class nsIBoxObject;
|
||||
class nsIDOMRange;
|
||||
|
||||
#define NS_IDOMNSDOCUMENT_IID \
|
||||
@@ -50,6 +52,10 @@ public:
|
||||
NS_IMETHOD CreateRange(nsIDOMRange** aReturn)=0;
|
||||
|
||||
NS_IMETHOD Load(const nsAReadableString& aUrl)=0;
|
||||
|
||||
NS_IMETHOD GetBoxObjectFor(nsIDOMElement* aElt, nsIBoxObject** aReturn)=0;
|
||||
|
||||
NS_IMETHOD SetBoxObjectFor(nsIDOMElement* aElt, nsIBoxObject* aBoxObject)=0;
|
||||
};
|
||||
|
||||
|
||||
@@ -60,6 +66,8 @@ public:
|
||||
NS_IMETHOD SetLocation(jsval aLocation); \
|
||||
NS_IMETHOD CreateRange(nsIDOMRange** aReturn); \
|
||||
NS_IMETHOD Load(const nsAReadableString& aUrl); \
|
||||
NS_IMETHOD GetBoxObjectFor(nsIDOMElement* aElt, nsIBoxObject** aReturn); \
|
||||
NS_IMETHOD SetBoxObjectFor(nsIDOMElement* aElt, nsIBoxObject* aBoxObject); \
|
||||
|
||||
|
||||
|
||||
@@ -70,6 +78,8 @@ public:
|
||||
NS_IMETHOD SetLocation(jsval aLocation) { return _to SetLocation(aLocation); } \
|
||||
NS_IMETHOD CreateRange(nsIDOMRange** aReturn) { return _to CreateRange(aReturn); } \
|
||||
NS_IMETHOD Load(const nsAReadableString& aUrl) { return _to Load(aUrl); } \
|
||||
NS_IMETHOD GetBoxObjectFor(nsIDOMElement* aElt, nsIBoxObject** aReturn) { return _to GetBoxObjectFor(aElt, aReturn); } \
|
||||
NS_IMETHOD SetBoxObjectFor(nsIDOMElement* aElt, nsIBoxObject* aBoxObject) { return _to SetBoxObjectFor(aElt, aBoxObject); } \
|
||||
|
||||
|
||||
#endif // nsIDOMNSDocument_h__
|
||||
|
||||
@@ -77,6 +77,8 @@ interface DocumentXBL {
|
||||
{ 0x9f, 0x2c, 0xc1, 0x8d, 0xeb, 0x62, 0xee, 0x8b } } */
|
||||
|
||||
NodeList getAnonymousNodes(in Element elt);
|
||||
Element getAnonymousElementByAttribute(in DOMString attrName, in DOMString attrValue);
|
||||
|
||||
void addBinding(in Element elt, in DOMString bindingURL);
|
||||
void removeBinding(in Element elt, in DOMString bindingURL);
|
||||
|
||||
@@ -88,12 +90,16 @@ interface NSDocument {
|
||||
/* IID: { 0xa6cf90cd, 0x15b3, 0x11d2, \
|
||||
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32} } */
|
||||
|
||||
readonly attribute DOMString characterSet;
|
||||
readonly attribute PluginArray plugins;
|
||||
readonly attribute DOMString characterSet;
|
||||
readonly attribute PluginArray plugins;
|
||||
|
||||
attribute jsval location;
|
||||
attribute jsval location;
|
||||
|
||||
Range createRange();
|
||||
void load(in DOMString url);
|
||||
|
||||
xpidl nsIBoxObject getBoxObjectFor(in Element elt);
|
||||
void setBoxObjectFor(in Element elt, in xpidl nsIBoxObject boxObject);
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -259,6 +259,7 @@ enum nsDOMProp {
|
||||
NS_DOM_PROP_DOCUMENTTYPE_SYSTEMID,
|
||||
NS_DOM_PROP_DOCUMENTVIEW_DEFAULTVIEW,
|
||||
NS_DOM_PROP_DOCUMENTXBL_ADDBINDING,
|
||||
NS_DOM_PROP_DOCUMENTXBL_GETANONYMOUSELEMENTBYATTRIBUTE,
|
||||
NS_DOM_PROP_DOCUMENTXBL_GETANONYMOUSNODES,
|
||||
NS_DOM_PROP_DOCUMENTXBL_GETBINDINGPARENT,
|
||||
NS_DOM_PROP_DOCUMENTXBL_LOADBINDINGDOCUMENT,
|
||||
@@ -767,9 +768,11 @@ enum nsDOMProp {
|
||||
NS_DOM_PROP_NOTATION_SYSTEMID,
|
||||
NS_DOM_PROP_NSDOCUMENT_CHARACTERSET,
|
||||
NS_DOM_PROP_NSDOCUMENT_CREATERANGE,
|
||||
NS_DOM_PROP_NSDOCUMENT_GETBOXOBJECTFOR,
|
||||
NS_DOM_PROP_NSDOCUMENT_LOAD,
|
||||
NS_DOM_PROP_NSDOCUMENT_LOCATION,
|
||||
NS_DOM_PROP_NSDOCUMENT_PLUGINS,
|
||||
NS_DOM_PROP_NSDOCUMENT_SETBOXOBJECTFOR,
|
||||
NS_DOM_PROP_NSHTMLANCHORELEMENT_HASH,
|
||||
NS_DOM_PROP_NSHTMLANCHORELEMENT_HOST,
|
||||
NS_DOM_PROP_NSHTMLANCHORELEMENT_HOSTNAME,
|
||||
|
||||
@@ -257,6 +257,7 @@
|
||||
"documenttype.systemid", \
|
||||
"documentview.defaultview", \
|
||||
"documentxbl.addbinding", \
|
||||
"documentxbl.getanonymouselementbyattribute", \
|
||||
"documentxbl.getanonymousnodes", \
|
||||
"documentxbl.getbindingparent", \
|
||||
"documentxbl.loadbindingdocument", \
|
||||
@@ -765,9 +766,11 @@
|
||||
"notation.systemid", \
|
||||
"nsdocument.characterset", \
|
||||
"nsdocument.createrange", \
|
||||
"nsdocument.getboxobjectfor", \
|
||||
"nsdocument.load", \
|
||||
"nsdocument.location", \
|
||||
"nsdocument.plugins", \
|
||||
"nsdocument.setboxobjectfor", \
|
||||
"nshtmlanchorelement.hash", \
|
||||
"nshtmlanchorelement.host", \
|
||||
"nshtmlanchorelement.hostname", \
|
||||
|
||||
@@ -138,8 +138,10 @@
|
||||
#include "nsIDOMPkcs11.h"
|
||||
#include "nsIDOMCSSPrimitiveValue.h"
|
||||
#include "plhash.h"
|
||||
#include "nsIPref.h"
|
||||
|
||||
static NS_DEFINE_IID(kIDOMNativeObjectRegistry, NS_IDOM_NATIVE_OBJECT_REGISTRY_IID);
|
||||
static NS_DEFINE_CID(kPrefServiceCID, NS_PREF_CID);
|
||||
|
||||
class nsDOMNativeObjectRegistry : public nsIDOMNativeObjectRegistry {
|
||||
public:
|
||||
@@ -320,12 +322,19 @@ public:
|
||||
nsISupports *aPI,
|
||||
nsISupports *aParent,
|
||||
void** aReturn);
|
||||
|
||||
|
||||
PRBool mUseXBLForms;
|
||||
};
|
||||
|
||||
nsDOMScriptObjectFactory::nsDOMScriptObjectFactory()
|
||||
{
|
||||
NS_INIT_REFCNT();
|
||||
|
||||
nsCOMPtr<nsIPref> prefService(do_GetService(kPrefServiceCID));
|
||||
if (prefService)
|
||||
prefService->GetBoolPref("nglayout.debug.enable_xbl_forms", &mUseXBLForms);
|
||||
else
|
||||
mUseXBLForms = PR_FALSE;
|
||||
}
|
||||
|
||||
nsDOMScriptObjectFactory::~nsDOMScriptObjectFactory()
|
||||
@@ -440,7 +449,9 @@ nsDOMScriptObjectFactory::NewScriptElement(const nsString &aTagName,
|
||||
case DOMHTMLTag_body:
|
||||
return NS_NewScriptHTMLBodyElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_button:
|
||||
return NS_NewScriptHTMLButtonElement(aContext, aElement, aParent, aReturn);
|
||||
if (mUseXBLForms)
|
||||
return NS_NewScriptHTMLElement(aContext, aElement, aParent, aReturn);
|
||||
else return NS_NewScriptHTMLButtonElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_dl:
|
||||
return NS_NewScriptHTMLDListElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_dir:
|
||||
@@ -479,9 +490,13 @@ nsDOMScriptObjectFactory::NewScriptElement(const nsString &aTagName,
|
||||
case DOMHTMLTag_li:
|
||||
return NS_NewScriptHTMLLIElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_label:
|
||||
return NS_NewScriptHTMLLabelElement(aContext, aElement, aParent, aReturn);
|
||||
if (mUseXBLForms)
|
||||
return NS_NewScriptHTMLElement(aContext, aElement, aParent, aReturn);
|
||||
else return NS_NewScriptHTMLLabelElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_legend:
|
||||
return NS_NewScriptHTMLLegendElement(aContext, aElement, aParent, aReturn);
|
||||
if (mUseXBLForms)
|
||||
return NS_NewScriptHTMLElement(aContext, aElement, aParent, aReturn);
|
||||
else return NS_NewScriptHTMLLegendElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_link:
|
||||
return NS_NewScriptHTMLLinkElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_map:
|
||||
@@ -500,9 +515,13 @@ nsDOMScriptObjectFactory::NewScriptElement(const nsString &aTagName,
|
||||
case DOMHTMLTag_embed:
|
||||
return NS_NewScriptHTMLEmbedElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_optgroup:
|
||||
return NS_NewScriptHTMLOptGroupElement(aContext, aElement, aParent, aReturn);
|
||||
if (mUseXBLForms)
|
||||
return NS_NewScriptHTMLElement(aContext, aElement, aParent, aReturn);
|
||||
else return NS_NewScriptHTMLOptGroupElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_option:
|
||||
return NS_NewScriptHTMLOptionElement(aContext, aElement, aParent, aReturn);
|
||||
if (mUseXBLForms)
|
||||
return NS_NewScriptHTMLElement(aContext, aElement, aParent, aReturn);
|
||||
else return NS_NewScriptHTMLOptionElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_p:
|
||||
return NS_NewScriptHTMLParagraphElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_param:
|
||||
@@ -515,7 +534,9 @@ nsDOMScriptObjectFactory::NewScriptElement(const nsString &aTagName,
|
||||
case DOMHTMLTag_script:
|
||||
return NS_NewScriptHTMLScriptElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_select:
|
||||
return NS_NewScriptHTMLSelectElement(aContext, aElement, aParent, aReturn);
|
||||
if (mUseXBLForms)
|
||||
return NS_NewScriptHTMLElement(aContext, aElement, aParent, aReturn);
|
||||
else return NS_NewScriptHTMLSelectElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_style:
|
||||
return NS_NewScriptHTMLStyleElement(aContext, aElement, aParent, aReturn);
|
||||
case DOMHTMLTag_caption:
|
||||
|
||||
@@ -54,6 +54,7 @@
|
||||
#include "nsIDOMStyleSheetList.h"
|
||||
#include "nsIDOMEntityReference.h"
|
||||
#include "nsIDOMNSDocument.h"
|
||||
#include "nsIBoxObject.h"
|
||||
#include "nsIDOMDocumentStyle.h"
|
||||
#include "nsIDOMComment.h"
|
||||
#include "nsIDOMDocumentFragment.h"
|
||||
@@ -84,6 +85,7 @@ static NS_DEFINE_IID(kIDocumentTypeIID, NS_IDOMDOCUMENTTYPE_IID);
|
||||
static NS_DEFINE_IID(kIStyleSheetListIID, NS_IDOMSTYLESHEETLIST_IID);
|
||||
static NS_DEFINE_IID(kIEntityReferenceIID, NS_IDOMENTITYREFERENCE_IID);
|
||||
static NS_DEFINE_IID(kINSDocumentIID, NS_IDOMNSDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kIBoxObjectIID, NS_IBOXOBJECT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentStyleIID, NS_IDOMDOCUMENTSTYLE_IID);
|
||||
static NS_DEFINE_IID(kICommentIID, NS_IDOMCOMMENT_IID);
|
||||
static NS_DEFINE_IID(kIDocumentFragmentIID, NS_IDOMDOCUMENTFRAGMENT_IID);
|
||||
@@ -1126,6 +1128,55 @@ DocumentXBLGetAnonymousNodes(JSContext *cx, JSObject *obj, uintN argc, jsval *ar
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetAnonymousElementByAttribute
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
DocumentXBLGetAnonymousElementByAttribute(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMDocument *privateThis = (nsIDOMDocument*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsCOMPtr<nsIDOMDocumentXBL> nativeThis;
|
||||
nsresult result = NS_OK;
|
||||
if (NS_OK != privateThis->QueryInterface(kIDocumentXBLIID, getter_AddRefs(nativeThis))) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_WRONG_TYPE_ERR);
|
||||
}
|
||||
|
||||
nsIDOMElement* nativeRet;
|
||||
nsAutoString b0;
|
||||
nsAutoString b1;
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (!nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
*rval = JSVAL_NULL;
|
||||
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
|
||||
if (!secMan)
|
||||
return PR_FALSE;
|
||||
result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_DOCUMENTXBL_GETANONYMOUSELEMENTBYATTRIBUTE, PR_FALSE);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
if (argc < 2) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR);
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertJSValToString(b0, cx, argv[0]);
|
||||
nsJSUtils::nsConvertJSValToString(b1, cx, argv[1]);
|
||||
|
||||
result = nativeThis->GetAnonymousElementByAttribute(b0, b1, &nativeRet);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
|
||||
nsJSUtils::nsConvertObjectToJSVal(nativeRet, cx, obj, rval);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method AddBinding
|
||||
//
|
||||
@@ -1421,6 +1472,117 @@ NSDocumentLoad(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rva
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method GetBoxObjectFor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NSDocumentGetBoxObjectFor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMDocument *privateThis = (nsIDOMDocument*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsCOMPtr<nsIDOMNSDocument> nativeThis;
|
||||
nsresult result = NS_OK;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSDocumentIID, getter_AddRefs(nativeThis))) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_WRONG_TYPE_ERR);
|
||||
}
|
||||
|
||||
nsIBoxObject* nativeRet;
|
||||
nsCOMPtr<nsIDOMElement> b0;
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (!nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
*rval = JSVAL_NULL;
|
||||
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
|
||||
if (!secMan)
|
||||
return PR_FALSE;
|
||||
result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NSDOCUMENT_GETBOXOBJECTFOR, PR_FALSE);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
if (argc < 1) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR);
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0),
|
||||
kIElementIID,
|
||||
NS_ConvertASCIItoUCS2("Element"),
|
||||
cx,
|
||||
argv[0])) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR);
|
||||
}
|
||||
|
||||
result = nativeThis->GetBoxObjectFor(b0, &nativeRet);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
|
||||
// n.b., this will release nativeRet
|
||||
nsJSUtils::nsConvertXPCObjectToJSVal(nativeRet, NS_GET_IID(nsIBoxObject), cx, obj, rval);
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// Native method SetBoxObjectFor
|
||||
//
|
||||
PR_STATIC_CALLBACK(JSBool)
|
||||
NSDocumentSetBoxObjectFor(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
|
||||
{
|
||||
nsIDOMDocument *privateThis = (nsIDOMDocument*)nsJSUtils::nsGetNativeThis(cx, obj);
|
||||
nsCOMPtr<nsIDOMNSDocument> nativeThis;
|
||||
nsresult result = NS_OK;
|
||||
if (NS_OK != privateThis->QueryInterface(kINSDocumentIID, getter_AddRefs(nativeThis))) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_WRONG_TYPE_ERR);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDOMElement> b0;
|
||||
nsCOMPtr<nsIBoxObject> b1;
|
||||
// If there's no private data, this must be the prototype, so ignore
|
||||
if (!nativeThis) {
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
{
|
||||
*rval = JSVAL_NULL;
|
||||
nsIScriptSecurityManager *secMan = nsJSUtils::nsGetSecurityManager(cx, obj);
|
||||
if (!secMan)
|
||||
return PR_FALSE;
|
||||
result = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_NSDOCUMENT_SETBOXOBJECTFOR, PR_FALSE);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
if (argc < 2) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_TOO_FEW_PARAMETERS_ERR);
|
||||
}
|
||||
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToObject((nsISupports **)(void**)getter_AddRefs(b0),
|
||||
kIElementIID,
|
||||
NS_ConvertASCIItoUCS2("Element"),
|
||||
cx,
|
||||
argv[0])) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_OBJECT_ERR);
|
||||
}
|
||||
if (JS_FALSE == nsJSUtils::nsConvertJSValToXPCObject(getter_AddRefs(b1),
|
||||
kIBoxObjectIID, cx, argv[1])) {
|
||||
return nsJSUtils::nsReportError(cx, obj, NS_ERROR_DOM_NOT_XPC_OBJECT_ERR);
|
||||
}
|
||||
|
||||
result = nativeThis->SetBoxObjectFor(b0, b1);
|
||||
if (NS_FAILED(result)) {
|
||||
return nsJSUtils::nsReportError(cx, obj, result);
|
||||
}
|
||||
|
||||
*rval = JSVAL_VOID;
|
||||
}
|
||||
|
||||
return JS_TRUE;
|
||||
}
|
||||
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
// class for Document
|
||||
@@ -1463,12 +1625,15 @@ static JSFunctionSpec DocumentMethods[] =
|
||||
{"getOverrideStyle", DocumentCSSGetOverrideStyle, 2},
|
||||
{"createEvent", DocumentEventCreateEvent, 1},
|
||||
{"getAnonymousNodes", DocumentXBLGetAnonymousNodes, 1},
|
||||
{"getAnonymousElementByAttribute", DocumentXBLGetAnonymousElementByAttribute, 2},
|
||||
{"addBinding", DocumentXBLAddBinding, 2},
|
||||
{"removeBinding", DocumentXBLRemoveBinding, 2},
|
||||
{"getBindingParent", DocumentXBLGetBindingParent, 1},
|
||||
{"loadBindingDocument", DocumentXBLLoadBindingDocument, 1},
|
||||
{"createRange", NSDocumentCreateRange, 0},
|
||||
{"load", NSDocumentLoad, 1},
|
||||
{"getBoxObjectFor", NSDocumentGetBoxObjectFor, 1},
|
||||
{"setBoxObjectFor", NSDocumentSetBoxObjectFor, 2},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user