From b45891b37943f87bee3ee178fcc4f84820a7b557 Mon Sep 17 00:00:00 2001 From: "vidur%netscape.com" Date: Mon, 17 May 1999 21:15:06 +0000 Subject: [PATCH] Added layers interface. git-svn-id: svn://10.0.0.236/trunk@31924 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/dom/public/html/MANIFEST | 1 + mozilla/dom/public/html/Makefile.in | 1 + mozilla/dom/public/html/makefile.win | 1 + .../dom/public/html/nsIDOMHTMLLayerElement.h | 104 ++++ .../dom/public/idl/html/HTMLLayerElement.idl | 14 + mozilla/dom/public/idl/html/makefile.win | 1 + mozilla/dom/src/build/nsDOMFactory.cpp | 4 +- mozilla/dom/src/html/Makefile.in | 1 + mozilla/dom/src/html/makefile.win | 2 + mozilla/dom/src/html/nsJSHTMLLayerElement.cpp | 466 ++++++++++++++++++ 10 files changed, 594 insertions(+), 1 deletion(-) create mode 100644 mozilla/dom/public/html/nsIDOMHTMLLayerElement.h create mode 100644 mozilla/dom/public/idl/html/HTMLLayerElement.idl create mode 100644 mozilla/dom/src/html/nsJSHTMLLayerElement.cpp diff --git a/mozilla/dom/public/html/MANIFEST b/mozilla/dom/public/html/MANIFEST index fefd07f911b..08102acf7d0 100644 --- a/mozilla/dom/public/html/MANIFEST +++ b/mozilla/dom/public/html/MANIFEST @@ -32,6 +32,7 @@ nsIDOMHTMLInputElement.h nsIDOMHTMLIsIndexElement.h nsIDOMHTMLLIElement.h nsIDOMHTMLLabelElement.h +nsIDOMHTMLLayerElement.h nsIDOMHTMLLegendElement.h nsIDOMHTMLLinkElement.h nsIDOMHTMLMapElement.h diff --git a/mozilla/dom/public/html/Makefile.in b/mozilla/dom/public/html/Makefile.in index ffff963964f..92a7afee457 100644 --- a/mozilla/dom/public/html/Makefile.in +++ b/mozilla/dom/public/html/Makefile.in @@ -56,6 +56,7 @@ EXPORTS = \ nsIDOMHTMLIsIndexElement.h \ nsIDOMHTMLLIElement.h \ nsIDOMHTMLLabelElement.h \ + nsIDOMHTMLLayerElement.h \ nsIDOMHTMLLegendElement.h \ nsIDOMHTMLLinkElement.h \ nsIDOMHTMLMapElement.h \ diff --git a/mozilla/dom/public/html/makefile.win b/mozilla/dom/public/html/makefile.win index c373f66570c..54aadb53398 100644 --- a/mozilla/dom/public/html/makefile.win +++ b/mozilla/dom/public/html/makefile.win @@ -54,6 +54,7 @@ EXPORTS= \ EXPORTS2= \ nsIDOMHTMLLabelElement.h \ + nsIDOMHTMLLayerElement.h \ nsIDOMHTMLLegendElement.h \ nsIDOMHTMLLinkElement.h \ nsIDOMHTMLMapElement.h \ diff --git a/mozilla/dom/public/html/nsIDOMHTMLLayerElement.h b/mozilla/dom/public/html/nsIDOMHTMLLayerElement.h new file mode 100644 index 00000000000..9fb09adca16 --- /dev/null +++ b/mozilla/dom/public/html/nsIDOMHTMLLayerElement.h @@ -0,0 +1,104 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#ifndef nsIDOMHTMLLayerElement_h__ +#define nsIDOMHTMLLayerElement_h__ + +#include "nsISupports.h" +#include "nsString.h" +#include "nsIScriptContext.h" +#include "nsIDOMHTMLElement.h" + +class nsIDOMDocument; + +#define NS_IDOMHTMLLAYERELEMENT_IID \ + { 0xa6cf9100, 0x15b3, 0x11d2, \ + { 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } + +class nsIDOMHTMLLayerElement : public nsIDOMHTMLElement { +public: + static const nsIID& GetIID() { static nsIID iid = NS_IDOMHTMLLAYERELEMENT_IID; return iid; } + + NS_IMETHOD GetTop(PRInt32* aTop)=0; + NS_IMETHOD SetTop(PRInt32 aTop)=0; + + NS_IMETHOD GetLeft(PRInt32* aLeft)=0; + NS_IMETHOD SetLeft(PRInt32 aLeft)=0; + + NS_IMETHOD GetVisibility(nsString& aVisibility)=0; + NS_IMETHOD SetVisibility(const nsString& aVisibility)=0; + + NS_IMETHOD GetBackground(nsString& aBackground)=0; + NS_IMETHOD SetBackground(const nsString& aBackground)=0; + + NS_IMETHOD GetBgColor(nsString& aBgColor)=0; + NS_IMETHOD SetBgColor(const nsString& aBgColor)=0; + + NS_IMETHOD GetName(nsString& aName)=0; + NS_IMETHOD SetName(const nsString& aName)=0; + + NS_IMETHOD GetZIndex(PRInt32* aZIndex)=0; + NS_IMETHOD SetZIndex(PRInt32 aZIndex)=0; + + NS_IMETHOD GetDocument(nsIDOMDocument** aDocument)=0; +}; + + +#define NS_DECL_IDOMHTMLLAYERELEMENT \ + NS_IMETHOD GetTop(PRInt32* aTop); \ + NS_IMETHOD SetTop(PRInt32 aTop); \ + NS_IMETHOD GetLeft(PRInt32* aLeft); \ + NS_IMETHOD SetLeft(PRInt32 aLeft); \ + NS_IMETHOD GetVisibility(nsString& aVisibility); \ + NS_IMETHOD SetVisibility(const nsString& aVisibility); \ + NS_IMETHOD GetBackground(nsString& aBackground); \ + NS_IMETHOD SetBackground(const nsString& aBackground); \ + NS_IMETHOD GetBgColor(nsString& aBgColor); \ + NS_IMETHOD SetBgColor(const nsString& aBgColor); \ + NS_IMETHOD GetName(nsString& aName); \ + NS_IMETHOD SetName(const nsString& aName); \ + NS_IMETHOD GetZIndex(PRInt32* aZIndex); \ + NS_IMETHOD SetZIndex(PRInt32 aZIndex); \ + NS_IMETHOD GetDocument(nsIDOMDocument** aDocument); \ + + + +#define NS_FORWARD_IDOMHTMLLAYERELEMENT(_to) \ + NS_IMETHOD GetTop(PRInt32* aTop) { return _to GetTop(aTop); } \ + NS_IMETHOD SetTop(PRInt32 aTop) { return _to SetTop(aTop); } \ + NS_IMETHOD GetLeft(PRInt32* aLeft) { return _to GetLeft(aLeft); } \ + NS_IMETHOD SetLeft(PRInt32 aLeft) { return _to SetLeft(aLeft); } \ + NS_IMETHOD GetVisibility(nsString& aVisibility) { return _to GetVisibility(aVisibility); } \ + NS_IMETHOD SetVisibility(const nsString& aVisibility) { return _to SetVisibility(aVisibility); } \ + NS_IMETHOD GetBackground(nsString& aBackground) { return _to GetBackground(aBackground); } \ + NS_IMETHOD SetBackground(const nsString& aBackground) { return _to SetBackground(aBackground); } \ + NS_IMETHOD GetBgColor(nsString& aBgColor) { return _to GetBgColor(aBgColor); } \ + NS_IMETHOD SetBgColor(const nsString& aBgColor) { return _to SetBgColor(aBgColor); } \ + NS_IMETHOD GetName(nsString& aName) { return _to GetName(aName); } \ + NS_IMETHOD SetName(const nsString& aName) { return _to SetName(aName); } \ + NS_IMETHOD GetZIndex(PRInt32* aZIndex) { return _to GetZIndex(aZIndex); } \ + NS_IMETHOD SetZIndex(PRInt32 aZIndex) { return _to SetZIndex(aZIndex); } \ + NS_IMETHOD GetDocument(nsIDOMDocument** aDocument) { return _to GetDocument(aDocument); } \ + + +extern "C" NS_DOM nsresult NS_InitHTMLLayerElementClass(nsIScriptContext *aContext, void **aPrototype); + +extern "C" NS_DOM nsresult NS_NewScriptHTMLLayerElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn); + +#endif // nsIDOMHTMLLayerElement_h__ diff --git a/mozilla/dom/public/idl/html/HTMLLayerElement.idl b/mozilla/dom/public/idl/html/HTMLLayerElement.idl new file mode 100644 index 00000000000..d8ffb73871b --- /dev/null +++ b/mozilla/dom/public/idl/html/HTMLLayerElement.idl @@ -0,0 +1,14 @@ + +interface HTMLLayerElement : HTMLElement { + /* IID: { 0xa6cf9100, 0x15b3, 0x11d2, \ + { 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */ + + attribute long top; + attribute long left; + attribute DOMString visibility; + attribute DOMString background; + attribute DOMString bgColor; + attribute DOMString name; + attribute long zIndex; + readonly attribute Document document; +}; diff --git a/mozilla/dom/public/idl/html/makefile.win b/mozilla/dom/public/idl/html/makefile.win index 1ab3b6bacb1..5d74ea15980 100644 --- a/mozilla/dom/public/idl/html/makefile.win +++ b/mozilla/dom/public/idl/html/makefile.win @@ -51,6 +51,7 @@ IDLSRCS = \ HTMLIsIndexElement.idl \ HTMLLIElement.idl \ HTMLLabelElement.idl \ + HTMLLayerElement.idl \ HTMLLegendElement.idl \ HTMLLinkElement.idl \ HTMLMapElement.idl \ diff --git a/mozilla/dom/src/build/nsDOMFactory.cpp b/mozilla/dom/src/build/nsDOMFactory.cpp index a09e69bd0cd..a18dfd7117d 100644 --- a/mozilla/dom/src/build/nsDOMFactory.cpp +++ b/mozilla/dom/src/build/nsDOMFactory.cpp @@ -71,6 +71,7 @@ #include "nsIDOMHTMLIsIndexElement.h" #include "nsIDOMHTMLLIElement.h" #include "nsIDOMHTMLLabelElement.h" +#include "nsIDOMHTMLLayerElement.h" #include "nsIDOMHTMLLegendElement.h" #include "nsIDOMHTMLLinkElement.h" #include "nsIDOMHTMLMapElement.h" @@ -484,9 +485,10 @@ nsDOMScriptObjectFactory::NewScriptElement(const nsString &aTagName, return NS_NewScriptHTMLTitleElement(aContext, aElement, aParent, aReturn); case DOMHTMLTag_ul: return NS_NewScriptHTMLUListElement(aContext, aElement, aParent, aReturn); - case DOMHTMLTag_fieldset: case DOMHTMLTag_ilayer: case DOMHTMLTag_layer: + return NS_NewScriptHTMLLayerElement(aContext, aElement, aParent, aReturn); + case DOMHTMLTag_fieldset: case DOMHTMLTag_multicol: case DOMHTMLTag_spacer: case DOMHTMLTag_wbr: diff --git a/mozilla/dom/src/html/Makefile.in b/mozilla/dom/src/html/Makefile.in index dbc0c91bd29..32e5ac2d209 100644 --- a/mozilla/dom/src/html/Makefile.in +++ b/mozilla/dom/src/html/Makefile.in @@ -55,6 +55,7 @@ CPPSRCS = \ nsJSHTMLIsIndexElement.cpp \ nsJSHTMLLIElement.cpp \ nsJSHTMLLabelElement.cpp \ + nsJSHTMLLayerElement.cpp \ nsJSHTMLLegendElement.cpp \ nsJSHTMLLinkElement.cpp \ nsJSHTMLMapElement.cpp \ diff --git a/mozilla/dom/src/html/makefile.win b/mozilla/dom/src/html/makefile.win index 33abcb7ef05..75e7e4f1995 100644 --- a/mozilla/dom/src/html/makefile.win +++ b/mozilla/dom/src/html/makefile.win @@ -54,6 +54,7 @@ CPPSRCS = \ nsJSHTMLIsIndexElement.cpp \ nsJSHTMLLIElement.cpp \ nsJSHTMLLabelElement.cpp \ + nsJSHTMLLayerElement.cpp \ nsJSHTMLLegendElement.cpp \ nsJSHTMLLinkElement.cpp \ nsJSHTMLMapElement.cpp \ @@ -113,6 +114,7 @@ CPP_OBJS= \ .\$(OBJDIR)\nsJSHTMLIsIndexElement.obj \ .\$(OBJDIR)\nsJSHTMLLIElement.obj \ .\$(OBJDIR)\nsJSHTMLLabelElement.obj \ + .\$(OBJDIR)\nsJSHTMLLayerElement.obj \ .\$(OBJDIR)\nsJSHTMLLegendElement.obj \ .\$(OBJDIR)\nsJSHTMLLinkElement.obj \ .\$(OBJDIR)\nsJSHTMLMapElement.obj \ diff --git a/mozilla/dom/src/html/nsJSHTMLLayerElement.cpp b/mozilla/dom/src/html/nsJSHTMLLayerElement.cpp new file mode 100644 index 00000000000..e93a92e70c7 --- /dev/null +++ b/mozilla/dom/src/html/nsJSHTMLLayerElement.cpp @@ -0,0 +1,466 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- + * + * The contents of this file are subject to the Netscape Public License + * Version 1.0 (the "NPL"); you may not use this file except in + * compliance with the NPL. You may obtain a copy of the NPL at + * http://www.mozilla.org/NPL/ + * + * Software distributed under the NPL is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL + * for the specific language governing rights and limitations under the + * NPL. + * + * The Initial Developer of this code under the NPL is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All Rights + * Reserved. + */ +/* AUTO-GENERATED. DO NOT EDIT!!! */ + +#include "jsapi.h" +#include "nsJSUtils.h" +#include "nscore.h" +#include "nsIScriptContext.h" +#include "nsIJSScriptObject.h" +#include "nsIScriptObjectOwner.h" +#include "nsIScriptGlobalObject.h" +#include "nsIPtr.h" +#include "nsString.h" +#include "nsIDOMDocument.h" +#include "nsIDOMHTMLLayerElement.h" + + +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(kIDocumentIID, NS_IDOMDOCUMENT_IID); +static NS_DEFINE_IID(kIHTMLLayerElementIID, NS_IDOMHTMLLAYERELEMENT_IID); + +NS_DEF_PTR(nsIDOMDocument); +NS_DEF_PTR(nsIDOMHTMLLayerElement); + +// +// HTMLLayerElement property ids +// +enum HTMLLayerElement_slots { + HTMLLAYERELEMENT_TOP = -1, + HTMLLAYERELEMENT_LEFT = -2, + HTMLLAYERELEMENT_VISIBILITY = -3, + HTMLLAYERELEMENT_BACKGROUND = -4, + HTMLLAYERELEMENT_BGCOLOR = -5, + HTMLLAYERELEMENT_NAME = -6, + HTMLLAYERELEMENT_ZINDEX = -7, + HTMLLAYERELEMENT_DOCUMENT = -8 +}; + +/***********************************************************************/ +// +// HTMLLayerElement Properties Getter +// +PR_STATIC_CALLBACK(JSBool) +GetHTMLLayerElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMHTMLLayerElement *a = (nsIDOMHTMLLayerElement*)JS_GetPrivate(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + switch(JSVAL_TO_INT(id)) { + case HTMLLAYERELEMENT_TOP: + { + PRInt32 prop; + if (NS_OK == a->GetTop(&prop)) { + *vp = INT_TO_JSVAL(prop); + } + else { + return JS_FALSE; + } + break; + } + case HTMLLAYERELEMENT_LEFT: + { + PRInt32 prop; + if (NS_OK == a->GetLeft(&prop)) { + *vp = INT_TO_JSVAL(prop); + } + else { + return JS_FALSE; + } + break; + } + case HTMLLAYERELEMENT_VISIBILITY: + { + nsAutoString prop; + if (NS_OK == a->GetVisibility(prop)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return JS_FALSE; + } + break; + } + case HTMLLAYERELEMENT_BACKGROUND: + { + nsAutoString prop; + if (NS_OK == a->GetBackground(prop)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return JS_FALSE; + } + break; + } + case HTMLLAYERELEMENT_BGCOLOR: + { + nsAutoString prop; + if (NS_OK == a->GetBgColor(prop)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return JS_FALSE; + } + break; + } + case HTMLLAYERELEMENT_NAME: + { + nsAutoString prop; + if (NS_OK == a->GetName(prop)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return JS_FALSE; + } + break; + } + case HTMLLAYERELEMENT_ZINDEX: + { + PRInt32 prop; + if (NS_OK == a->GetZIndex(&prop)) { + *vp = INT_TO_JSVAL(prop); + } + else { + return JS_FALSE; + } + break; + } + case HTMLLAYERELEMENT_DOCUMENT: + { + nsIDOMDocument* prop; + if (NS_OK == a->GetDocument(&prop)) { + // get the js object + nsJSUtils::nsConvertObjectToJSVal((nsISupports *)prop, cx, vp); + } + else { + return JS_FALSE; + } + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); + } + + return PR_TRUE; +} + +/***********************************************************************/ +// +// HTMLLayerElement Properties Setter +// +PR_STATIC_CALLBACK(JSBool) +SetHTMLLayerElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) +{ + nsIDOMHTMLLayerElement *a = (nsIDOMHTMLLayerElement*)JS_GetPrivate(cx, obj); + + // If there's no private data, this must be the prototype, so ignore + if (nsnull == a) { + return JS_TRUE; + } + + if (JSVAL_IS_INT(id)) { + switch(JSVAL_TO_INT(id)) { + case HTMLLAYERELEMENT_TOP: + { + PRInt32 prop; + int32 temp; + if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) { + prop = (PRInt32)temp; + } + else { + JS_ReportError(cx, "Parameter must be a number"); + return JS_FALSE; + } + + a->SetTop(prop); + + break; + } + case HTMLLAYERELEMENT_LEFT: + { + PRInt32 prop; + int32 temp; + if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) { + prop = (PRInt32)temp; + } + else { + JS_ReportError(cx, "Parameter must be a number"); + return JS_FALSE; + } + + a->SetLeft(prop); + + break; + } + case HTMLLAYERELEMENT_VISIBILITY: + { + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetVisibility(prop); + + break; + } + case HTMLLAYERELEMENT_BACKGROUND: + { + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetBackground(prop); + + break; + } + case HTMLLAYERELEMENT_BGCOLOR: + { + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetBgColor(prop); + + break; + } + case HTMLLAYERELEMENT_NAME: + { + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetName(prop); + + break; + } + case HTMLLAYERELEMENT_ZINDEX: + { + PRInt32 prop; + int32 temp; + if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) { + prop = (PRInt32)temp; + } + else { + JS_ReportError(cx, "Parameter must be a number"); + return JS_FALSE; + } + + a->SetZIndex(prop); + + break; + } + default: + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp); + } + } + else { + return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp); + } + + return PR_TRUE; +} + + +// +// HTMLLayerElement finalizer +// +PR_STATIC_CALLBACK(void) +FinalizeHTMLLayerElement(JSContext *cx, JSObject *obj) +{ + nsJSUtils::nsGenericFinalize(cx, obj); +} + + +// +// HTMLLayerElement enumerate +// +PR_STATIC_CALLBACK(JSBool) +EnumerateHTMLLayerElement(JSContext *cx, JSObject *obj) +{ + return nsJSUtils::nsGenericEnumerate(cx, obj); +} + + +// +// HTMLLayerElement resolve +// +PR_STATIC_CALLBACK(JSBool) +ResolveHTMLLayerElement(JSContext *cx, JSObject *obj, jsval id) +{ + return nsJSUtils::nsGenericResolve(cx, obj, id); +} + + +/***********************************************************************/ +// +// class for HTMLLayerElement +// +JSClass HTMLLayerElementClass = { + "HTMLLayerElement", + JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS, + JS_PropertyStub, + JS_PropertyStub, + GetHTMLLayerElementProperty, + SetHTMLLayerElementProperty, + EnumerateHTMLLayerElement, + ResolveHTMLLayerElement, + JS_ConvertStub, + FinalizeHTMLLayerElement +}; + + +// +// HTMLLayerElement class properties +// +static JSPropertySpec HTMLLayerElementProperties[] = +{ + {"top", HTMLLAYERELEMENT_TOP, JSPROP_ENUMERATE}, + {"left", HTMLLAYERELEMENT_LEFT, JSPROP_ENUMERATE}, + {"visibility", HTMLLAYERELEMENT_VISIBILITY, JSPROP_ENUMERATE}, + {"background", HTMLLAYERELEMENT_BACKGROUND, JSPROP_ENUMERATE}, + {"bgColor", HTMLLAYERELEMENT_BGCOLOR, JSPROP_ENUMERATE}, + {"name", HTMLLAYERELEMENT_NAME, JSPROP_ENUMERATE}, + {"zIndex", HTMLLAYERELEMENT_ZINDEX, JSPROP_ENUMERATE}, + {"document", HTMLLAYERELEMENT_DOCUMENT, JSPROP_ENUMERATE | JSPROP_READONLY}, + {0} +}; + + +// +// HTMLLayerElement class methods +// +static JSFunctionSpec HTMLLayerElementMethods[] = +{ + {0} +}; + + +// +// HTMLLayerElement constructor +// +PR_STATIC_CALLBACK(JSBool) +HTMLLayerElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) +{ + return JS_FALSE; +} + + +// +// HTMLLayerElement class initialization +// +extern "C" NS_DOM nsresult NS_InitHTMLLayerElementClass(nsIScriptContext *aContext, void **aPrototype) +{ + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + JSObject *proto = nsnull; + JSObject *constructor = nsnull; + JSObject *parent_proto = nsnull; + JSObject *global = JS_GetGlobalObject(jscontext); + jsval vp; + + if ((PR_TRUE != JS_LookupProperty(jscontext, global, "HTMLLayerElement", &vp)) || + !JSVAL_IS_OBJECT(vp) || + ((constructor = JSVAL_TO_OBJECT(vp)) == nsnull) || + (PR_TRUE != JS_LookupProperty(jscontext, JSVAL_TO_OBJECT(vp), "prototype", &vp)) || + !JSVAL_IS_OBJECT(vp)) { + + if (NS_OK != NS_InitHTMLElementClass(aContext, (void **)&parent_proto)) { + return NS_ERROR_FAILURE; + } + proto = JS_InitClass(jscontext, // context + global, // global object + parent_proto, // parent proto + &HTMLLayerElementClass, // JSClass + HTMLLayerElement, // JSNative ctor + 0, // ctor args + HTMLLayerElementProperties, // proto props + HTMLLayerElementMethods, // proto funcs + nsnull, // ctor props (static) + nsnull); // ctor funcs (static) + if (nsnull == proto) { + return NS_ERROR_FAILURE; + } + + } + else if ((nsnull != constructor) && JSVAL_IS_OBJECT(vp)) { + proto = JSVAL_TO_OBJECT(vp); + } + else { + return NS_ERROR_FAILURE; + } + + if (aPrototype) { + *aPrototype = proto; + } + return NS_OK; +} + + +// +// Method for creating a new HTMLLayerElement JavaScript object +// +extern "C" NS_DOM nsresult NS_NewScriptHTMLLayerElement(nsIScriptContext *aContext, nsISupports *aSupports, nsISupports *aParent, void **aReturn) +{ + NS_PRECONDITION(nsnull != aContext && nsnull != aSupports && nsnull != aReturn, "null argument to NS_NewScriptHTMLLayerElement"); + JSObject *proto; + JSObject *parent; + nsIScriptObjectOwner *owner; + JSContext *jscontext = (JSContext *)aContext->GetNativeContext(); + nsresult result = NS_OK; + nsIDOMHTMLLayerElement *aHTMLLayerElement; + + if (nsnull == aParent) { + parent = nsnull; + } + else if (NS_OK == aParent->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) { + if (NS_OK != owner->GetScriptObject(aContext, (void **)&parent)) { + NS_RELEASE(owner); + return NS_ERROR_FAILURE; + } + NS_RELEASE(owner); + } + else { + return NS_ERROR_FAILURE; + } + + if (NS_OK != NS_InitHTMLLayerElementClass(aContext, (void **)&proto)) { + return NS_ERROR_FAILURE; + } + + result = aSupports->QueryInterface(kIHTMLLayerElementIID, (void **)&aHTMLLayerElement); + if (NS_OK != result) { + return result; + } + + // create a js object for this class + *aReturn = JS_NewObject(jscontext, &HTMLLayerElementClass, proto, parent); + if (nsnull != *aReturn) { + // connect the native object to the js object + JS_SetPrivate(jscontext, (JSObject *)*aReturn, aHTMLLayerElement); + } + else { + NS_RELEASE(aHTMLLayerElement); + return NS_ERROR_FAILURE; + } + + return NS_OK; +}