Added code to initialize XPIDL JS stubs, added nsJSXULDocument into the build, temporarily added the rdf service as an attribute on the XUL document.
This commit is contained in:
Родитель
3367bf0671
Коммит
6a9f55ba2d
|
@ -1125,16 +1125,12 @@ RDFElementImpl::GetScriptObject(nsIScriptContext* aContext, void** aScriptObject
|
|||
|
||||
nsresult (*fn)(nsIScriptContext* aContext, nsISupports* aSupports, nsISupports* aParent, void** aReturn);
|
||||
|
||||
#if 0 // put this in once we get XPIDL interfaces
|
||||
if (mTag == kTreeAtom) {
|
||||
fn = NS_NewScriptXULTreeElement;
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
fn = NS_NewScriptXULElement;
|
||||
#if 0 // put this in once we get XPIDL interfaces
|
||||
}
|
||||
#endif
|
||||
|
||||
rv = fn(aContext, (nsIDOMXULElement*) this, global, (void**) &mScriptObject);
|
||||
NS_RELEASE(global);
|
||||
|
|
|
@ -2318,6 +2318,16 @@ XULDocumentImpl::GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets)
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMXULDocument interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetRdf(nsIRDFService** aRDFService)
|
||||
{
|
||||
// XXX this is a temporary hack until the component manager starts
|
||||
// to work.
|
||||
return nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) aRDFService);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetElementById(const nsString& aId, nsIDOMElement** aReturn)
|
||||
{
|
||||
|
@ -2697,6 +2707,25 @@ XULDocumentImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObjec
|
|||
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptXULDocument(aContext, (nsISupports *)(nsIDOMXULDocument *)this, global, (void**)&mScriptObject);
|
||||
|
||||
#if defined(XPIDL_JS_STUBS)
|
||||
JSContext* cx = (JSContext*) aContext->GetNativeContext();
|
||||
nsIRDFNode::InitJSClass(cx);
|
||||
nsIRDFResource::InitJSClass(cx);
|
||||
nsIRDFLiteral::InitJSClass(cx);
|
||||
nsIRDFDate::InitJSClass(cx);
|
||||
nsIRDFInt::InitJSClass(cx);
|
||||
nsIRDFCursor::InitJSClass(cx);
|
||||
nsIRDFAssertionCursor::InitJSClass(cx);
|
||||
nsIRDFArcsInCursor::InitJSClass(cx);
|
||||
nsIRDFArcsOutCursor::InitJSClass(cx);
|
||||
nsIRDFResourceCursor::InitJSClass(cx);
|
||||
nsIRDFObserver::InitJSClass(cx);
|
||||
nsIRDFDataSource::InitJSClass(cx);
|
||||
nsIRDFCompositeDataSource::InitJSClass(cx);
|
||||
nsIRDFService::InitJSClass(cx);
|
||||
#endif
|
||||
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ interface XULDocument : Document {
|
|||
/* IID: { 0x17ddd8c0, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } */
|
||||
|
||||
readonly attribute xpidl nsIRDFService rdf;
|
||||
|
||||
Element getElementById(in DOMString id);
|
||||
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
};
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
||||
class nsIRDFService;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
|
@ -36,6 +37,8 @@ class nsIDOMXULDocument : public nsIDOMDocument {
|
|||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULDOCUMENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetRdf(nsIRDFService** aRdf)=0;
|
||||
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn)=0;
|
||||
|
@ -43,12 +46,14 @@ public:
|
|||
|
||||
|
||||
#define NS_DECL_IDOMXULDOCUMENT \
|
||||
NS_IMETHOD GetRdf(nsIRDFService** aRdf); \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULDOCUMENT(_to) \
|
||||
NS_IMETHOD GetRdf(nsIRDFService** aRdf) { return _to##GetRdf(aRdf); } \
|
||||
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); } \
|
||||
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
@ -34,14 +35,22 @@
|
|||
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(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXULDocumentIID, NS_IDOMXULDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
NS_DEF_PTR(nsIRDFService);
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULDocument);
|
||||
NS_DEF_PTR(nsIDOMNodeList);
|
||||
|
||||
//
|
||||
// XULDocument property ids
|
||||
//
|
||||
enum XULDocument_slots {
|
||||
XULDOCUMENT_RDF = -1
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
|
@ -59,7 +68,18 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
case XULDOCUMENT_RDF:
|
||||
{
|
||||
nsIRDFService* prop;
|
||||
if (NS_OK == a->GetRdf(&prop)) {
|
||||
// get the js object
|
||||
*vp = OBJECT_TO_JSVAL(nsIRDFService::GetJSObject(cx, prop));
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
@ -230,6 +250,7 @@ JSClass XULDocumentClass = {
|
|||
//
|
||||
static JSPropertySpec XULDocumentProperties[] =
|
||||
{
|
||||
{"rdf", XULDOCUMENT_RDF, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
@ -3,7 +3,9 @@ interface XULDocument : Document {
|
|||
/* IID: { 0x17ddd8c0, 0xc5f8, 0x11d2, \
|
||||
{ 0xa6, 0xae, 0x0, 0x10, 0x4b, 0xde, 0x60, 0x48 } } */
|
||||
|
||||
readonly attribute xpidl nsIRDFService rdf;
|
||||
|
||||
Element getElementById(in DOMString id);
|
||||
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
NodeList getElementsByAttribute(in DOMString name, in DOMString value);
|
||||
};
|
||||
|
|
|
@ -25,6 +25,7 @@
|
|||
#include "nsIScriptContext.h"
|
||||
#include "nsIDOMDocument.h"
|
||||
|
||||
class nsIRDFService;
|
||||
class nsIDOMElement;
|
||||
class nsIDOMNodeList;
|
||||
|
||||
|
@ -36,6 +37,8 @@ class nsIDOMXULDocument : public nsIDOMDocument {
|
|||
public:
|
||||
static const nsIID& GetIID() { static nsIID iid = NS_IDOMXULDOCUMENT_IID; return iid; }
|
||||
|
||||
NS_IMETHOD GetRdf(nsIRDFService** aRdf)=0;
|
||||
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn)=0;
|
||||
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn)=0;
|
||||
|
@ -43,12 +46,14 @@ public:
|
|||
|
||||
|
||||
#define NS_DECL_IDOMXULDOCUMENT \
|
||||
NS_IMETHOD GetRdf(nsIRDFService** aRdf); \
|
||||
NS_IMETHOD GetElementById(const nsString& aId, nsIDOMElement** aReturn); \
|
||||
NS_IMETHOD GetElementsByAttribute(const nsString& aName, const nsString& aValue, nsIDOMNodeList** aReturn); \
|
||||
|
||||
|
||||
|
||||
#define NS_FORWARD_IDOMXULDOCUMENT(_to) \
|
||||
NS_IMETHOD GetRdf(nsIRDFService** aRdf) { return _to##GetRdf(aRdf); } \
|
||||
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); } \
|
||||
|
||||
|
|
|
@ -31,6 +31,7 @@ CPPSRCS = \
|
|||
nsJSNodeObserver.cpp \
|
||||
nsJSXULDocument.cpp \
|
||||
nsJSXULElement.cpp \
|
||||
nsJSXULTreeElement.cpp \
|
||||
nsRDFContentUtils.cpp \
|
||||
nsRDFDOMNodeList.cpp \
|
||||
nsRDFElement.cpp \
|
||||
|
|
|
@ -35,6 +35,7 @@ CPP_OBJS=\
|
|||
.\$(OBJDIR)\nsJSNodeObserver.obj \
|
||||
.\$(OBJDIR)\nsJSXULDocument.obj \
|
||||
.\$(OBJDIR)\nsJSXULElement.obj \
|
||||
.\$(OBJDIR)\nsJSXULTreeElement.obj \
|
||||
.\$(OBJDIR)\nsRDFContentUtils.obj \
|
||||
.\$(OBJDIR)\nsRDFDOMNodeList.obj \
|
||||
.\$(OBJDIR)\nsRDFElement.obj \
|
||||
|
@ -42,7 +43,7 @@ CPP_OBJS=\
|
|||
.\$(OBJDIR)\nsRDFTreeBuilder.obj \
|
||||
.\$(OBJDIR)\nsRDFXULBuilder.obj \
|
||||
.\$(OBJDIR)\nsXULDocument.obj \
|
||||
.\$(OBJDIR)\nsXULDocumentInfo.obj \
|
||||
.\$(OBJDIR)\nsXULDocumentInfo.obj \
|
||||
.\$(OBJDIR)\nsXULSortService.obj \
|
||||
.\$(OBJDIR)\nsXULTreeElement.obj \
|
||||
$(NULL)
|
||||
|
|
|
@ -26,6 +26,7 @@
|
|||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIPtr.h"
|
||||
#include "nsString.h"
|
||||
#include "nsIRDFService.h"
|
||||
#include "nsIDOMElement.h"
|
||||
#include "nsIDOMXULDocument.h"
|
||||
#include "nsIDOMNodeList.h"
|
||||
|
@ -34,14 +35,22 @@
|
|||
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(kIRDFServiceIID, NS_IRDFSERVICE_IID);
|
||||
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
|
||||
static NS_DEFINE_IID(kIXULDocumentIID, NS_IDOMXULDOCUMENT_IID);
|
||||
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
|
||||
|
||||
NS_DEF_PTR(nsIRDFService);
|
||||
NS_DEF_PTR(nsIDOMElement);
|
||||
NS_DEF_PTR(nsIDOMXULDocument);
|
||||
NS_DEF_PTR(nsIDOMNodeList);
|
||||
|
||||
//
|
||||
// XULDocument property ids
|
||||
//
|
||||
enum XULDocument_slots {
|
||||
XULDOCUMENT_RDF = -1
|
||||
};
|
||||
|
||||
/***********************************************************************/
|
||||
//
|
||||
|
@ -59,7 +68,18 @@ GetXULDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
|
|||
|
||||
if (JSVAL_IS_INT(id)) {
|
||||
switch(JSVAL_TO_INT(id)) {
|
||||
case 0:
|
||||
case XULDOCUMENT_RDF:
|
||||
{
|
||||
nsIRDFService* prop;
|
||||
if (NS_OK == a->GetRdf(&prop)) {
|
||||
// get the js object
|
||||
*vp = OBJECT_TO_JSVAL(nsIRDFService::GetJSObject(cx, prop));
|
||||
}
|
||||
else {
|
||||
return JS_FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp);
|
||||
}
|
||||
|
@ -230,6 +250,7 @@ JSClass XULDocumentClass = {
|
|||
//
|
||||
static JSPropertySpec XULDocumentProperties[] =
|
||||
{
|
||||
{"rdf", XULDOCUMENT_RDF, JSPROP_ENUMERATE | JSPROP_READONLY},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
@ -1125,16 +1125,12 @@ RDFElementImpl::GetScriptObject(nsIScriptContext* aContext, void** aScriptObject
|
|||
|
||||
nsresult (*fn)(nsIScriptContext* aContext, nsISupports* aSupports, nsISupports* aParent, void** aReturn);
|
||||
|
||||
#if 0 // put this in once we get XPIDL interfaces
|
||||
if (mTag == kTreeAtom) {
|
||||
fn = NS_NewScriptXULTreeElement;
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
fn = NS_NewScriptXULElement;
|
||||
#if 0 // put this in once we get XPIDL interfaces
|
||||
}
|
||||
#endif
|
||||
|
||||
rv = fn(aContext, (nsIDOMXULElement*) this, global, (void**) &mScriptObject);
|
||||
NS_RELEASE(global);
|
||||
|
|
|
@ -2318,6 +2318,16 @@ XULDocumentImpl::GetStyleSheets(nsIDOMStyleSheetCollection** aStyleSheets)
|
|||
////////////////////////////////////////////////////////////////////////
|
||||
// nsIDOMXULDocument interface
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetRdf(nsIRDFService** aRDFService)
|
||||
{
|
||||
// XXX this is a temporary hack until the component manager starts
|
||||
// to work.
|
||||
return nsServiceManager::GetService(kRDFServiceCID,
|
||||
nsIRDFService::GetIID(),
|
||||
(nsISupports**) aRDFService);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
XULDocumentImpl::GetElementById(const nsString& aId, nsIDOMElement** aReturn)
|
||||
{
|
||||
|
@ -2697,6 +2707,25 @@ XULDocumentImpl::GetScriptObject(nsIScriptContext *aContext, void** aScriptObjec
|
|||
|
||||
if (nsnull == mScriptObject) {
|
||||
res = NS_NewScriptXULDocument(aContext, (nsISupports *)(nsIDOMXULDocument *)this, global, (void**)&mScriptObject);
|
||||
|
||||
#if defined(XPIDL_JS_STUBS)
|
||||
JSContext* cx = (JSContext*) aContext->GetNativeContext();
|
||||
nsIRDFNode::InitJSClass(cx);
|
||||
nsIRDFResource::InitJSClass(cx);
|
||||
nsIRDFLiteral::InitJSClass(cx);
|
||||
nsIRDFDate::InitJSClass(cx);
|
||||
nsIRDFInt::InitJSClass(cx);
|
||||
nsIRDFCursor::InitJSClass(cx);
|
||||
nsIRDFAssertionCursor::InitJSClass(cx);
|
||||
nsIRDFArcsInCursor::InitJSClass(cx);
|
||||
nsIRDFArcsOutCursor::InitJSClass(cx);
|
||||
nsIRDFResourceCursor::InitJSClass(cx);
|
||||
nsIRDFObserver::InitJSClass(cx);
|
||||
nsIRDFDataSource::InitJSClass(cx);
|
||||
nsIRDFCompositeDataSource::InitJSClass(cx);
|
||||
nsIRDFService::InitJSClass(cx);
|
||||
#endif
|
||||
|
||||
}
|
||||
*aScriptObject = mScriptObject;
|
||||
|
||||
|
|
|
@ -1125,16 +1125,12 @@ RDFElementImpl::GetScriptObject(nsIScriptContext* aContext, void** aScriptObject
|
|||
|
||||
nsresult (*fn)(nsIScriptContext* aContext, nsISupports* aSupports, nsISupports* aParent, void** aReturn);
|
||||
|
||||
#if 0 // put this in once we get XPIDL interfaces
|
||||
if (mTag == kTreeAtom) {
|
||||
fn = NS_NewScriptXULTreeElement;
|
||||
}
|
||||
else {
|
||||
#endif
|
||||
fn = NS_NewScriptXULElement;
|
||||
#if 0 // put this in once we get XPIDL interfaces
|
||||
}
|
||||
#endif
|
||||
|
||||
rv = fn(aContext, (nsIDOMXULElement*) this, global, (void**) &mScriptObject);
|
||||
NS_RELEASE(global);
|
||||
|
|
Загрузка…
Ссылка в новой задаче