Better support for interface families in the IDL (named elements). Netscape interfaces for HTMLDocument and HTMLFormElement (for backwards compatibility.

This commit is contained in:
vidur%netscape.com 1998-08-07 23:01:52 +00:00
Родитель 4d3903759d
Коммит 6e1e87c9b9
22 изменённых файлов: 1110 добавлений и 72 удалений

Просмотреть файл

@ -27,7 +27,7 @@
class nsIDOMNode;
#define NS_IDOMEVENT_IID \
{ 0x6f765329, 0xee43, 0x11d1, \
{ 0x6f76532b, 0xee43, 0x11d1, \
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
class nsIDOMEvent : public nsISupports {

Просмотреть файл

@ -26,7 +26,7 @@
#define NS_IDOMNSEVENT_IID \
{ 0x6f76532a, 0xee43, 0x11d1, \
{ 0x6f76532c, 0xee43, 0x11d1, \
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
class nsIDOMNSEvent : public nsISupports {

Просмотреть файл

@ -19,6 +19,7 @@ nsIDOMHTMLDocument.h
nsIDOMHTMLElement.h
nsIDOMHTMLFontElement.h
nsIDOMHTMLFormElement.h
nsIDOMNSHTMLFormElement.h
nsIDOMHTMLFrameElement.h
nsIDOMHTMLFrameSetElement.h
nsIDOMHTMLHRElement.h
@ -60,3 +61,4 @@ nsIDOMHTMLTfootElement.h
nsIDOMHTMLTheadElement.h
nsIDOMHTMLTitleElement.h
nsIDOMHTMLUListElement.h
nsIDOMNSHTMLDocument.h

Просмотреть файл

@ -38,6 +38,7 @@ EXPORTS = \
nsIDOMHTMLElement.h \
nsIDOMHTMLFontElement.h \
nsIDOMHTMLFormElement.h \
nsIDOMNSHTMLFormElement.h \
nsIDOMHTMLFrameElement.h \
nsIDOMHTMLFrameSetElement.h \
nsIDOMHTMLHRElement.h \
@ -79,6 +80,7 @@ EXPORTS = \
nsIDOMHTMLTheadElement.h \
nsIDOMHTMLTitleElement.h \
nsIDOMHTMLUListElement.h \
nsIDOMNSHTMLDocument.h \
$(NULL)
MODULE = dom

Просмотреть файл

@ -38,6 +38,7 @@ EXPORTS= \
nsIDOMHTMLElement.h \
nsIDOMHTMLFontElement.h \
nsIDOMHTMLFormElement.h \
nsIDOMNSHTMLFormElement.h \
nsIDOMHTMLFrameElement.h \
nsIDOMHTMLFrameSetElement.h \
nsIDOMHTMLHRElement.h \
@ -81,7 +82,8 @@ EXPORTS2= \
nsIDOMHTMLTfootElement.h \
nsIDOMHTMLTheadElement.h \
nsIDOMHTMLTitleElement.h \
nsIDOMHTMLUListElement.h
nsIDOMHTMLUListElement.h \
nsIDOMNSHTMLDocument.h
MODULE=dom

Просмотреть файл

@ -52,6 +52,10 @@ public:
NS_IMETHOD GetTarget(nsString& aTarget)=0;
NS_IMETHOD SetTarget(const nsString& aTarget)=0;
NS_IMETHOD Reset()=0;
NS_IMETHOD Submit()=0;
};
@ -68,6 +72,8 @@ public:
NS_IMETHOD SetMethod(const nsString& aMethod); \
NS_IMETHOD GetTarget(nsString& aTarget); \
NS_IMETHOD SetTarget(const nsString& aTarget); \
NS_IMETHOD Reset(); \
NS_IMETHOD Submit(); \
@ -84,6 +90,8 @@ public:
NS_IMETHOD SetMethod(const nsString& aMethod) { return superClass::SetMethod(aMethod); } \
NS_IMETHOD GetTarget(nsString& aTarget) { return superClass::GetTarget(aTarget); } \
NS_IMETHOD SetTarget(const nsString& aTarget) { return superClass::SetTarget(aTarget); } \
NS_IMETHOD Reset() { return superClass::Reset(); } \
NS_IMETHOD Submit() { return superClass::Submit(); } \
extern nsresult NS_InitHTMLFormElementClass(nsIScriptContext *aContext, void **aPrototype);

Просмотреть файл

@ -41,7 +41,6 @@ public:
NS_IMETHOD SetDefaultChecked(PRBool aDefaultChecked)=0;
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm)=0;
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm)=0;
NS_IMETHOD GetAccept(nsString& aAccept)=0;
NS_IMETHOD SetAccept(const nsString& aAccept)=0;
@ -80,7 +79,6 @@ public:
NS_IMETHOD SetTabIndex(PRInt32 aTabIndex)=0;
NS_IMETHOD GetType(nsString& aType)=0;
NS_IMETHOD SetType(const nsString& aType)=0;
NS_IMETHOD GetUseMap(nsString& aUseMap)=0;
NS_IMETHOD SetUseMap(const nsString& aUseMap)=0;
@ -104,7 +102,6 @@ public:
NS_IMETHOD GetDefaultChecked(PRBool* aDefaultChecked); \
NS_IMETHOD SetDefaultChecked(PRBool aDefaultChecked); \
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm); \
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm); \
NS_IMETHOD GetAccept(nsString& aAccept); \
NS_IMETHOD SetAccept(const nsString& aAccept); \
NS_IMETHOD GetAccessKey(nsString& aAccessKey); \
@ -130,7 +127,6 @@ public:
NS_IMETHOD GetTabIndex(PRInt32* aTabIndex); \
NS_IMETHOD SetTabIndex(PRInt32 aTabIndex); \
NS_IMETHOD GetType(nsString& aType); \
NS_IMETHOD SetType(const nsString& aType); \
NS_IMETHOD GetUseMap(nsString& aUseMap); \
NS_IMETHOD SetUseMap(const nsString& aUseMap); \
NS_IMETHOD GetValue(nsString& aValue); \
@ -148,7 +144,6 @@ public:
NS_IMETHOD GetDefaultChecked(PRBool* aDefaultChecked) { return superClass::GetDefaultChecked(aDefaultChecked); } \
NS_IMETHOD SetDefaultChecked(PRBool aDefaultChecked) { return superClass::SetDefaultChecked(aDefaultChecked); } \
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm) { return superClass::GetForm(aForm); } \
NS_IMETHOD SetForm(nsIDOMHTMLFormElement* aForm) { return superClass::SetForm(aForm); } \
NS_IMETHOD GetAccept(nsString& aAccept) { return superClass::GetAccept(aAccept); } \
NS_IMETHOD SetAccept(const nsString& aAccept) { return superClass::SetAccept(aAccept); } \
NS_IMETHOD GetAccessKey(nsString& aAccessKey) { return superClass::GetAccessKey(aAccessKey); } \
@ -174,7 +169,6 @@ public:
NS_IMETHOD GetTabIndex(PRInt32* aTabIndex) { return superClass::GetTabIndex(aTabIndex); } \
NS_IMETHOD SetTabIndex(PRInt32 aTabIndex) { return superClass::SetTabIndex(aTabIndex); } \
NS_IMETHOD GetType(nsString& aType) { return superClass::GetType(aType); } \
NS_IMETHOD SetType(const nsString& aType) { return superClass::SetType(aType); } \
NS_IMETHOD GetUseMap(nsString& aUseMap) { return superClass::GetUseMap(aUseMap); } \
NS_IMETHOD SetUseMap(const nsString& aUseMap) { return superClass::SetUseMap(aUseMap); } \
NS_IMETHOD GetValue(nsString& aValue) { return superClass::GetValue(aValue); } \

Просмотреть файл

@ -0,0 +1,105 @@
/* -*- 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 nsIDOMNSHTMLDocument_h__
#define nsIDOMNSHTMLDocument_h__
#include "nsISupports.h"
#include "nsString.h"
#include "nsIScriptContext.h"
class nsIDOMElement;
class nsIDOMHTMLCollection;
#define NS_IDOMNSHTMLDOCUMENT_IID \
{ 0x6f765329, 0xee43, 0x11d1, \
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
class nsIDOMNSHTMLDocument : public nsISupports {
public:
NS_IMETHOD GetAlinkColor(nsString& aAlinkColor)=0;
NS_IMETHOD SetAlinkColor(const nsString& aAlinkColor)=0;
NS_IMETHOD GetLinkColor(nsString& aLinkColor)=0;
NS_IMETHOD SetLinkColor(const nsString& aLinkColor)=0;
NS_IMETHOD GetVlinkColor(nsString& aVlinkColor)=0;
NS_IMETHOD SetVlinkColor(const nsString& aVlinkColor)=0;
NS_IMETHOD GetBgColor(nsString& aBgColor)=0;
NS_IMETHOD SetBgColor(const nsString& aBgColor)=0;
NS_IMETHOD GetFgColor(nsString& aFgColor)=0;
NS_IMETHOD SetFgColor(const nsString& aFgColor)=0;
NS_IMETHOD GetLastModified(nsString& aLastModified)=0;
NS_IMETHOD GetEmbeds(nsIDOMHTMLCollection** aEmbeds)=0;
NS_IMETHOD GetLayers(nsIDOMHTMLCollection** aLayers)=0;
NS_IMETHOD GetPlugins(nsIDOMHTMLCollection** aPlugins)=0;
NS_IMETHOD GetSelection(nsString& aReturn)=0;
NS_IMETHOD NamedItem(const nsString& aName, nsIDOMElement** aReturn)=0;
};
#define NS_DECL_IDOMNSHTMLDOCUMENT \
NS_IMETHOD GetAlinkColor(nsString& aAlinkColor); \
NS_IMETHOD SetAlinkColor(const nsString& aAlinkColor); \
NS_IMETHOD GetLinkColor(nsString& aLinkColor); \
NS_IMETHOD SetLinkColor(const nsString& aLinkColor); \
NS_IMETHOD GetVlinkColor(nsString& aVlinkColor); \
NS_IMETHOD SetVlinkColor(const nsString& aVlinkColor); \
NS_IMETHOD GetBgColor(nsString& aBgColor); \
NS_IMETHOD SetBgColor(const nsString& aBgColor); \
NS_IMETHOD GetFgColor(nsString& aFgColor); \
NS_IMETHOD SetFgColor(const nsString& aFgColor); \
NS_IMETHOD GetLastModified(nsString& aLastModified); \
NS_IMETHOD GetEmbeds(nsIDOMHTMLCollection** aEmbeds); \
NS_IMETHOD GetLayers(nsIDOMHTMLCollection** aLayers); \
NS_IMETHOD GetPlugins(nsIDOMHTMLCollection** aPlugins); \
NS_IMETHOD GetSelection(nsString& aReturn); \
NS_IMETHOD NamedItem(const nsString& aName, nsIDOMElement** aReturn); \
#define NS_FORWARD_IDOMNSHTMLDOCUMENT(superClass) \
NS_IMETHOD GetAlinkColor(nsString& aAlinkColor) { return superClass::GetAlinkColor(aAlinkColor); } \
NS_IMETHOD SetAlinkColor(const nsString& aAlinkColor) { return superClass::SetAlinkColor(aAlinkColor); } \
NS_IMETHOD GetLinkColor(nsString& aLinkColor) { return superClass::GetLinkColor(aLinkColor); } \
NS_IMETHOD SetLinkColor(const nsString& aLinkColor) { return superClass::SetLinkColor(aLinkColor); } \
NS_IMETHOD GetVlinkColor(nsString& aVlinkColor) { return superClass::GetVlinkColor(aVlinkColor); } \
NS_IMETHOD SetVlinkColor(const nsString& aVlinkColor) { return superClass::SetVlinkColor(aVlinkColor); } \
NS_IMETHOD GetBgColor(nsString& aBgColor) { return superClass::GetBgColor(aBgColor); } \
NS_IMETHOD SetBgColor(const nsString& aBgColor) { return superClass::SetBgColor(aBgColor); } \
NS_IMETHOD GetFgColor(nsString& aFgColor) { return superClass::GetFgColor(aFgColor); } \
NS_IMETHOD SetFgColor(const nsString& aFgColor) { return superClass::SetFgColor(aFgColor); } \
NS_IMETHOD GetLastModified(nsString& aLastModified) { return superClass::GetLastModified(aLastModified); } \
NS_IMETHOD GetEmbeds(nsIDOMHTMLCollection** aEmbeds) { return superClass::GetEmbeds(aEmbeds); } \
NS_IMETHOD GetLayers(nsIDOMHTMLCollection** aLayers) { return superClass::GetLayers(aLayers); } \
NS_IMETHOD GetPlugins(nsIDOMHTMLCollection** aPlugins) { return superClass::GetPlugins(aPlugins); } \
NS_IMETHOD GetSelection(nsString& aReturn) { return superClass::GetSelection(aReturn); } \
NS_IMETHOD NamedItem(const nsString& aName, nsIDOMElement** aReturn) { return superClass::NamedItem(aName, aReturn); } \
#endif // nsIDOMNSHTMLDocument_h__

Просмотреть файл

@ -0,0 +1,57 @@
/* -*- 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 nsIDOMNSHTMLFormElement_h__
#define nsIDOMNSHTMLFormElement_h__
#include "nsISupports.h"
#include "nsString.h"
#include "nsIScriptContext.h"
class nsIDOMElement;
#define NS_IDOMNSHTMLFORMELEMENT_IID \
{ 0x6f76532a, 0xee43, 0x11d1, \
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
class nsIDOMNSHTMLFormElement : public nsISupports {
public:
NS_IMETHOD GetEncoding(nsString& aEncoding)=0;
NS_IMETHOD GetLength(PRUint32* aLength)=0;
NS_IMETHOD NamedItem(const nsString& aName, nsIDOMElement** aReturn)=0;
};
#define NS_DECL_IDOMNSHTMLFORMELEMENT \
NS_IMETHOD GetEncoding(nsString& aEncoding); \
NS_IMETHOD GetLength(PRUint32* aLength); \
NS_IMETHOD NamedItem(const nsString& aName, nsIDOMElement** aReturn); \
#define NS_FORWARD_IDOMNSHTMLFORMELEMENT(superClass) \
NS_IMETHOD GetEncoding(nsString& aEncoding) { return superClass::GetEncoding(aEncoding); } \
NS_IMETHOD GetLength(PRUint32* aLength) { return superClass::GetLength(aLength); } \
NS_IMETHOD NamedItem(const nsString& aName, nsIDOMElement** aReturn) { return superClass::NamedItem(aName, aReturn); } \
#endif // nsIDOMNSHTMLFormElement_h__

Просмотреть файл

@ -21,3 +21,19 @@
Element getElementById(in wstring elementId);
NodeList getElementsByName(in wstring elementName);
};
interface NSHTMLDocument {
attribute wstring alinkColor;
attribute wstring linkColor;
attribute wstring vlinkColor;
attribute wstring bgColor;
attribute wstring fgColor;
readonly attribute wstring lastModified;
readonly attribute HTMLCollection embeds;
readonly attribute HTMLCollection layers;
readonly attribute HTMLCollection plugins;
wstring getSelection();
Element namedItem(in wstring name);
};

Просмотреть файл

@ -6,4 +6,14 @@
attribute wstring enctype;
attribute wstring method;
attribute wstring target;
void reset();
void submit();
};
interface NSHTMLFormElement {
readonly attribute wstring encoding;
readonly attribute unsigned long length;
Element namedItem(in wstring name);
};

Просмотреть файл

@ -1,7 +1,7 @@
interface HTMLInputElement : HTMLElement {
attribute wstring defaultValue;
attribute boolean defaultChecked;
attribute HTMLFormElement form;
readonly attribute HTMLFormElement form;
attribute wstring accept;
attribute wstring accessKey;
attribute wstring align;
@ -14,7 +14,7 @@
attribute wstring size;
attribute wstring src;
attribute long tabIndex;
attribute wstring type;
readonly attribute wstring type;
attribute wstring useMap;
attribute wstring value;
void blur();

Просмотреть файл

@ -26,7 +26,7 @@
#define NS_IDOMNAVIGATOR_IID \
{ 0x6f76532b, 0xee43, 0x11d1, \
{ 0x6f76532d, 0xee43, 0x11d1, \
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
class nsIDOMNavigator : public nsISupports {

Просмотреть файл

@ -30,7 +30,7 @@ class nsIDOMDocument;
class nsIDOMWindow;
#define NS_IDOMWINDOW_IID \
{ 0x6f76532c, 0xee43, 0x11d1, \
{ 0x6f76532e, 0xee43, 0x11d1, \
{ 0x9b, 0xc3, 0x00, 0x60, 0x08, 0x8c, 0xa6, 0xb3 } }
class nsIDOMWindow : public nsISupports {

Просмотреть файл

@ -22,6 +22,7 @@
#include "nsIDOMHTMLCollection.h"
#include "nsIDOMHTMLImageElement.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMHTMLInputElement.h"
#include "nsIScriptEventListener.h"
// Force references to all of the symbols that we want exported from
@ -37,4 +38,5 @@ void XXXDomNeverCalled()
NS_NewScriptEventListener(0, 0, 0);
NS_NewScriptHTMLImageElement(0, 0, 0, 0);
NS_NewScriptHTMLFormElement(0, 0, 0, 0);
NS_NewScriptHTMLInputElement(0, 0, 0, 0);
}

Просмотреть файл

@ -113,6 +113,7 @@ GetHTMLCollectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
if (NS_OK == a->NamedItem(name, &prop)) {
if (NULL != prop) {
// get the js object
if (prop != nsnull) {
nsIScriptObjectOwner *owner = nsnull;
@ -130,6 +131,7 @@ GetHTMLCollectionProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
else {
*vp = JSVAL_NULL;
}
}
}
else {
return JS_FALSE;

Просмотреть файл

@ -28,6 +28,7 @@
#include "nsIDOMElement.h"
#include "nsIDOMHTMLElement.h"
#include "nsIDOMHTMLDocument.h"
#include "nsIDOMNSHTMLDocument.h"
#include "nsIDOMHTMLCollection.h"
#include "nsIDOMNodeList.h"
@ -38,12 +39,14 @@ static NS_DEFINE_IID(kIScriptGlobalObjectIID, NS_ISCRIPTGLOBALOBJECT_IID);
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
static NS_DEFINE_IID(kIHTMLElementIID, NS_IDOMHTMLELEMENT_IID);
static NS_DEFINE_IID(kIHTMLDocumentIID, NS_IDOMHTMLDOCUMENT_IID);
static NS_DEFINE_IID(kINSHTMLDocumentIID, NS_IDOMNSHTMLDOCUMENT_IID);
static NS_DEFINE_IID(kIHTMLCollectionIID, NS_IDOMHTMLCOLLECTION_IID);
static NS_DEFINE_IID(kINodeListIID, NS_IDOMNODELIST_IID);
NS_DEF_PTR(nsIDOMElement);
NS_DEF_PTR(nsIDOMHTMLElement);
NS_DEF_PTR(nsIDOMHTMLDocument);
NS_DEF_PTR(nsIDOMNSHTMLDocument);
NS_DEF_PTR(nsIDOMHTMLCollection);
NS_DEF_PTR(nsIDOMNodeList);
@ -65,7 +68,16 @@ enum HTMLDocument_slots {
HTMLDOCUMENT_LINKS = -112,
HTMLDOCUMENT_FORMS = -113,
HTMLDOCUMENT_ANCHORS = -114,
HTMLDOCUMENT_COOKIE = -115
HTMLDOCUMENT_COOKIE = -115,
NSHTMLDOCUMENT_ALINKCOLOR = -21,
NSHTMLDOCUMENT_LINKCOLOR = -22,
NSHTMLDOCUMENT_VLINKCOLOR = -23,
NSHTMLDOCUMENT_BGCOLOR = -24,
NSHTMLDOCUMENT_FGCOLOR = -25,
NSHTMLDOCUMENT_LASTMODIFIED = -26,
NSHTMLDOCUMENT_EMBEDS = -27,
NSHTMLDOCUMENT_LAYERS = -28,
NSHTMLDOCUMENT_PLUGINS = -29
};
/***********************************************************************/
@ -363,6 +375,246 @@ GetHTMLDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
break;
}
case NSHTMLDOCUMENT_ALINKCOLOR:
{
nsAutoString prop;
nsIDOMNSHTMLDocument* b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
if(NS_OK == b->GetAlinkColor(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_LINKCOLOR:
{
nsAutoString prop;
nsIDOMNSHTMLDocument* b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
if(NS_OK == b->GetLinkColor(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_VLINKCOLOR:
{
nsAutoString prop;
nsIDOMNSHTMLDocument* b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
if(NS_OK == b->GetVlinkColor(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_BGCOLOR:
{
nsAutoString prop;
nsIDOMNSHTMLDocument* b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
if(NS_OK == b->GetBgColor(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_FGCOLOR:
{
nsAutoString prop;
nsIDOMNSHTMLDocument* b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
if(NS_OK == b->GetFgColor(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_LASTMODIFIED:
{
nsAutoString prop;
nsIDOMNSHTMLDocument* b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
if(NS_OK == b->GetLastModified(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_EMBEDS:
{
nsIDOMHTMLCollection* prop;
nsIDOMNSHTMLDocument* b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
if(NS_OK == b->GetEmbeds(&prop)) {
// get the js object
if (prop != nsnull) {
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == prop->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
JSObject *object = nsnull;
nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);
if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {
// set the return value
*vp = OBJECT_TO_JSVAL(object);
}
NS_RELEASE(owner);
}
NS_RELEASE(prop);
}
else {
*vp = JSVAL_NULL;
}
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_LAYERS:
{
nsIDOMHTMLCollection* prop;
nsIDOMNSHTMLDocument* b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
if(NS_OK == b->GetLayers(&prop)) {
// get the js object
if (prop != nsnull) {
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == prop->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
JSObject *object = nsnull;
nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);
if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {
// set the return value
*vp = OBJECT_TO_JSVAL(object);
}
NS_RELEASE(owner);
}
NS_RELEASE(prop);
}
else {
*vp = JSVAL_NULL;
}
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_PLUGINS:
{
nsIDOMHTMLCollection* prop;
nsIDOMNSHTMLDocument* b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
if(NS_OK == b->GetPlugins(&prop)) {
// get the js object
if (prop != nsnull) {
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == prop->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
JSObject *object = nsnull;
nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);
if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {
// set the return value
*vp = OBJECT_TO_JSVAL(object);
}
NS_RELEASE(owner);
}
NS_RELEASE(prop);
}
else {
*vp = JSVAL_NULL;
}
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
default:
{
nsIJSScriptObject *object;
@ -375,6 +627,52 @@ GetHTMLDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
}
}
else if (JSVAL_IS_STRING(id)) {
nsIDOMElement* prop;
nsIDOMNSHTMLDocument* b;
nsAutoString name;
JSString *jsstring = JS_ValueToString(cx, id);
if (nsnull != jsstring) {
name.SetString(JS_GetStringChars(jsstring));
}
else {
name.SetString("");
}
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
if (NS_OK == b->NamedItem(name, &prop)) {
if (NULL != prop) {
// get the js object
if (prop != nsnull) {
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == prop->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
JSObject *object = nsnull;
nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);
if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {
// set the return value
*vp = OBJECT_TO_JSVAL(object);
}
NS_RELEASE(owner);
}
NS_RELEASE(prop);
}
else {
*vp = JSVAL_NULL;
}
}
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
}
else {
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
@ -457,6 +755,126 @@ SetHTMLDocumentProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
break;
}
case NSHTMLDOCUMENT_ALINKCOLOR:
{
nsAutoString prop;
JSString *jsstring;
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
prop.SetString(JS_GetStringChars(jsstring));
}
else {
prop.SetString((const char *)nsnull);
}
nsIDOMNSHTMLDocument *b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
b->SetAlinkColor(prop);
NS_RELEASE(b);
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_LINKCOLOR:
{
nsAutoString prop;
JSString *jsstring;
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
prop.SetString(JS_GetStringChars(jsstring));
}
else {
prop.SetString((const char *)nsnull);
}
nsIDOMNSHTMLDocument *b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
b->SetLinkColor(prop);
NS_RELEASE(b);
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_VLINKCOLOR:
{
nsAutoString prop;
JSString *jsstring;
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
prop.SetString(JS_GetStringChars(jsstring));
}
else {
prop.SetString((const char *)nsnull);
}
nsIDOMNSHTMLDocument *b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
b->SetVlinkColor(prop);
NS_RELEASE(b);
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_BGCOLOR:
{
nsAutoString prop;
JSString *jsstring;
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
prop.SetString(JS_GetStringChars(jsstring));
}
else {
prop.SetString((const char *)nsnull);
}
nsIDOMNSHTMLDocument *b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
b->SetBgColor(prop);
NS_RELEASE(b);
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
case NSHTMLDOCUMENT_FGCOLOR:
{
nsAutoString prop;
JSString *jsstring;
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
prop.SetString(JS_GetStringChars(jsstring));
}
else {
prop.SetString((const char *)nsnull);
}
nsIDOMNSHTMLDocument *b;
if (NS_OK == a->QueryInterface(kINSHTMLDocumentIID, (void **)&b)) {
b->SetFgColor(prop);
NS_RELEASE(b);
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
break;
}
default:
{
nsIJSScriptObject *object;
@ -792,6 +1210,112 @@ HTMLDocumentGetElementsByName(JSContext *cx, JSObject *obj, uintN argc, jsval *a
}
//
// Native method GetSelection
//
PR_STATIC_CALLBACK(JSBool)
NSHTMLDocumentGetSelection(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMHTMLDocument *privateThis = (nsIDOMHTMLDocument*)JS_GetPrivate(cx, obj);
nsIDOMNSHTMLDocument *nativeThis;
if (NS_OK != privateThis->QueryInterface(kINSHTMLDocumentIID, (void **)nativeThis)) {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
JSBool rBool = JS_FALSE;
nsAutoString nativeRet;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->GetSelection(nativeRet)) {
return JS_FALSE;
}
JSString *jsstring = JS_NewUCStringCopyN(cx, nativeRet, nativeRet.Length());
// set the return value
*rval = STRING_TO_JSVAL(jsstring);
}
else {
JS_ReportError(cx, "Function getSelection requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method NamedItem
//
PR_STATIC_CALLBACK(JSBool)
NSHTMLDocumentNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMHTMLDocument *privateThis = (nsIDOMHTMLDocument*)JS_GetPrivate(cx, obj);
nsIDOMNSHTMLDocument *nativeThis;
if (NS_OK != privateThis->QueryInterface(kINSHTMLDocumentIID, (void **)nativeThis)) {
JS_ReportError(cx, "Object must be of type NSHTMLDocument");
return JS_FALSE;
}
JSBool rBool = JS_FALSE;
nsIDOMElement* nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->NamedItem(b0, &nativeRet)) {
return JS_FALSE;
}
if (nativeRet != nsnull) {
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == nativeRet->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
JSObject *object = nsnull;
nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);
if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {
// set the return value
*rval = OBJECT_TO_JSVAL(object);
}
NS_RELEASE(owner);
}
NS_RELEASE(nativeRet);
}
else {
*rval = JSVAL_NULL;
}
}
else {
JS_ReportError(cx, "Function namedItem requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for HTMLDocument
@ -830,6 +1354,15 @@ static JSPropertySpec HTMLDocumentProperties[] =
{"forms", HTMLDOCUMENT_FORMS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"anchors", HTMLDOCUMENT_ANCHORS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"cookie", HTMLDOCUMENT_COOKIE, JSPROP_ENUMERATE},
{"alinkColor", NSHTMLDOCUMENT_ALINKCOLOR, JSPROP_ENUMERATE},
{"linkColor", NSHTMLDOCUMENT_LINKCOLOR, JSPROP_ENUMERATE},
{"vlinkColor", NSHTMLDOCUMENT_VLINKCOLOR, JSPROP_ENUMERATE},
{"bgColor", NSHTMLDOCUMENT_BGCOLOR, JSPROP_ENUMERATE},
{"fgColor", NSHTMLDOCUMENT_FGCOLOR, JSPROP_ENUMERATE},
{"lastModified", NSHTMLDOCUMENT_LASTMODIFIED, JSPROP_ENUMERATE | JSPROP_READONLY},
{"embeds", NSHTMLDOCUMENT_EMBEDS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"layers", NSHTMLDOCUMENT_LAYERS, JSPROP_ENUMERATE | JSPROP_READONLY},
{"plugins", NSHTMLDOCUMENT_PLUGINS, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
@ -845,6 +1378,8 @@ static JSFunctionSpec HTMLDocumentMethods[] =
{"writeln", HTMLDocumentWriteln, 0},
{"getElementById", HTMLDocumentGetElementById, 1},
{"getElementsByName", HTMLDocumentGetElementsByName, 1},
{"getSelection", NSHTMLDocumentGetSelection, 0},
{"namedItem", NSHTMLDocumentNamedItem, 1},
{0}
};

Просмотреть файл

@ -25,6 +25,8 @@
#include "nsIScriptGlobalObject.h"
#include "nsIPtr.h"
#include "nsString.h"
#include "nsIDOMNSHTMLFormElement.h"
#include "nsIDOMElement.h"
#include "nsIDOMHTMLFormElement.h"
#include "nsIDOMHTMLCollection.h"
@ -32,9 +34,13 @@
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(kINSHTMLFormElementIID, NS_IDOMNSHTMLFORMELEMENT_IID);
static NS_DEFINE_IID(kIElementIID, NS_IDOMELEMENT_IID);
static NS_DEFINE_IID(kIHTMLFormElementIID, NS_IDOMHTMLFORMELEMENT_IID);
static NS_DEFINE_IID(kIHTMLCollectionIID, NS_IDOMHTMLCOLLECTION_IID);
NS_DEF_PTR(nsIDOMNSHTMLFormElement);
NS_DEF_PTR(nsIDOMElement);
NS_DEF_PTR(nsIDOMHTMLFormElement);
NS_DEF_PTR(nsIDOMHTMLCollection);
@ -48,7 +54,9 @@ enum HTMLFormElement_slots {
HTMLFORMELEMENT_ACTION = -14,
HTMLFORMELEMENT_ENCTYPE = -15,
HTMLFORMELEMENT_METHOD = -16,
HTMLFORMELEMENT_TARGET = -17
HTMLFORMELEMENT_TARGET = -17,
NSHTMLFORMELEMENT_ENCODING = -21,
NSHTMLFORMELEMENT_LENGTH = -22
};
/***********************************************************************/
@ -172,6 +180,48 @@ GetHTMLFormElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
break;
}
case NSHTMLFORMELEMENT_ENCODING:
{
nsAutoString prop;
nsIDOMNSHTMLFormElement* b;
if (NS_OK == a->QueryInterface(kINSHTMLFormElementIID, (void **)&b)) {
if(NS_OK == b->GetEncoding(prop)) {
JSString *jsstring = JS_NewUCStringCopyN(cx, prop, prop.Length());
// set the return value
*vp = STRING_TO_JSVAL(jsstring);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLFormElement");
return JS_FALSE;
}
break;
}
case NSHTMLFORMELEMENT_LENGTH:
{
PRUint32 prop;
nsIDOMNSHTMLFormElement* b;
if (NS_OK == a->QueryInterface(kINSHTMLFormElementIID, (void **)&b)) {
if(NS_OK == b->GetLength(&prop)) {
*vp = INT_TO_JSVAL(prop);
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLFormElement");
return JS_FALSE;
}
break;
}
default:
{
nsIJSScriptObject *object;
@ -184,6 +234,52 @@ GetHTMLFormElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
}
}
else if (JSVAL_IS_STRING(id)) {
nsIDOMElement* prop;
nsIDOMNSHTMLFormElement* b;
nsAutoString name;
JSString *jsstring = JS_ValueToString(cx, id);
if (nsnull != jsstring) {
name.SetString(JS_GetStringChars(jsstring));
}
else {
name.SetString("");
}
if (NS_OK == a->QueryInterface(kINSHTMLFormElementIID, (void **)&b)) {
if (NS_OK == b->NamedItem(name, &prop)) {
if (NULL != prop) {
// get the js object
if (prop != nsnull) {
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == prop->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
JSObject *object = nsnull;
nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);
if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {
// set the return value
*vp = OBJECT_TO_JSVAL(object);
}
NS_RELEASE(owner);
}
NS_RELEASE(prop);
}
else {
*vp = JSVAL_NULL;
}
}
NS_RELEASE(b);
}
else {
NS_RELEASE(b);
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Object must be of type NSHTMLFormElement");
return JS_FALSE;
}
}
else {
nsIJSScriptObject *object;
if (NS_OK == a->QueryInterface(kIJSScriptObjectIID, (void**)&object)) {
@ -375,6 +471,136 @@ ResolveHTMLFormElement(JSContext *cx, JSObject *obj, jsval id)
}
//
// Native method Reset
//
PR_STATIC_CALLBACK(JSBool)
HTMLFormElementReset(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMHTMLFormElement *nativeThis = (nsIDOMHTMLFormElement*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->Reset()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function reset requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method Submit
//
PR_STATIC_CALLBACK(JSBool)
HTMLFormElementSubmit(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMHTMLFormElement *nativeThis = (nsIDOMHTMLFormElement*)JS_GetPrivate(cx, obj);
JSBool rBool = JS_FALSE;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 0) {
if (NS_OK != nativeThis->Submit()) {
return JS_FALSE;
}
*rval = JSVAL_VOID;
}
else {
JS_ReportError(cx, "Function submit requires 0 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
//
// Native method NamedItem
//
PR_STATIC_CALLBACK(JSBool)
NSHTMLFormElementNamedItem(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)
{
nsIDOMHTMLFormElement *privateThis = (nsIDOMHTMLFormElement*)JS_GetPrivate(cx, obj);
nsIDOMNSHTMLFormElement *nativeThis;
if (NS_OK != privateThis->QueryInterface(kINSHTMLFormElementIID, (void **)nativeThis)) {
JS_ReportError(cx, "Object must be of type NSHTMLFormElement");
return JS_FALSE;
}
JSBool rBool = JS_FALSE;
nsIDOMElement* nativeRet;
nsAutoString b0;
*rval = JSVAL_NULL;
// If there's no private data, this must be the prototype, so ignore
if (nsnull == nativeThis) {
return JS_TRUE;
}
if (argc >= 1) {
JSString *jsstring0 = JS_ValueToString(cx, argv[0]);
if (nsnull != jsstring0) {
b0.SetString(JS_GetStringChars(jsstring0));
}
else {
b0.SetString(""); // Should this really be null??
}
if (NS_OK != nativeThis->NamedItem(b0, &nativeRet)) {
return JS_FALSE;
}
if (nativeRet != nsnull) {
nsIScriptObjectOwner *owner = nsnull;
if (NS_OK == nativeRet->QueryInterface(kIScriptObjectOwnerIID, (void**)&owner)) {
JSObject *object = nsnull;
nsIScriptContext *script_cx = (nsIScriptContext *)JS_GetContextPrivate(cx);
if (NS_OK == owner->GetScriptObject(script_cx, (void**)&object)) {
// set the return value
*rval = OBJECT_TO_JSVAL(object);
}
NS_RELEASE(owner);
}
NS_RELEASE(nativeRet);
}
else {
*rval = JSVAL_NULL;
}
}
else {
JS_ReportError(cx, "Function namedItem requires 1 parameters");
return JS_FALSE;
}
return JS_TRUE;
}
/***********************************************************************/
//
// class for HTMLFormElement
@ -405,6 +631,8 @@ static JSPropertySpec HTMLFormElementProperties[] =
{"enctype", HTMLFORMELEMENT_ENCTYPE, JSPROP_ENUMERATE},
{"method", HTMLFORMELEMENT_METHOD, JSPROP_ENUMERATE},
{"target", HTMLFORMELEMENT_TARGET, JSPROP_ENUMERATE},
{"encoding", NSHTMLFORMELEMENT_ENCODING, JSPROP_ENUMERATE | JSPROP_READONLY},
{"length", NSHTMLFORMELEMENT_LENGTH, JSPROP_ENUMERATE | JSPROP_READONLY},
{0}
};
@ -414,6 +642,9 @@ static JSPropertySpec HTMLFormElementProperties[] =
//
static JSFunctionSpec HTMLFormElementMethods[] =
{
{"reset", HTMLFormElementReset, 0},
{"submit", HTMLFormElementSubmit, 0},
{"namedItem", NSHTMLFormElementNamedItem, 1},
{0}
};

Просмотреть файл

@ -386,29 +386,6 @@ SetHTMLInputElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
break;
}
case HTMLINPUTELEMENT_FORM:
{
nsIDOMHTMLFormElement* prop;
if (JSVAL_IS_NULL(*vp)) {
prop = nsnull;
}
else if (JSVAL_IS_OBJECT(*vp)) {
JSObject *jsobj = JSVAL_TO_OBJECT(*vp);
nsISupports *supports = (nsISupports *)JS_GetPrivate(cx, jsobj);
if (NS_OK != supports->QueryInterface(kIHTMLFormElementIID, (void **)&prop)) {
JS_ReportError(cx, "Parameter must be of type HTMLFormElement");
return JS_FALSE;
}
}
else {
JS_ReportError(cx, "Parameter must be an object");
return JS_FALSE;
}
a->SetForm(prop);
if (prop) NS_RELEASE(prop);
break;
}
case HTMLINPUTELEMENT_ACCEPT:
{
nsAutoString prop;
@ -594,21 +571,6 @@ SetHTMLInputElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
break;
}
case HTMLINPUTELEMENT_TYPE:
{
nsAutoString prop;
JSString *jsstring;
if ((jsstring = JS_ValueToString(cx, *vp)) != nsnull) {
prop.SetString(JS_GetStringChars(jsstring));
}
else {
prop.SetString((const char *)nsnull);
}
a->SetType(prop);
break;
}
case HTMLINPUTELEMENT_USEMAP:
{
nsAutoString prop;
@ -883,7 +845,7 @@ static JSPropertySpec HTMLInputElementProperties[] =
{
{"defaultValue", HTMLINPUTELEMENT_DEFAULTVALUE, JSPROP_ENUMERATE},
{"defaultChecked", HTMLINPUTELEMENT_DEFAULTCHECKED, JSPROP_ENUMERATE},
{"form", HTMLINPUTELEMENT_FORM, JSPROP_ENUMERATE},
{"form", HTMLINPUTELEMENT_FORM, JSPROP_ENUMERATE | JSPROP_READONLY},
{"accept", HTMLINPUTELEMENT_ACCEPT, JSPROP_ENUMERATE},
{"accessKey", HTMLINPUTELEMENT_ACCESSKEY, JSPROP_ENUMERATE},
{"align", HTMLINPUTELEMENT_ALIGN, JSPROP_ENUMERATE},
@ -896,7 +858,7 @@ static JSPropertySpec HTMLInputElementProperties[] =
{"size", HTMLINPUTELEMENT_SIZE, JSPROP_ENUMERATE},
{"src", HTMLINPUTELEMENT_SRC, JSPROP_ENUMERATE},
{"tabIndex", HTMLINPUTELEMENT_TABINDEX, JSPROP_ENUMERATE},
{"type", HTMLINPUTELEMENT_TYPE, JSPROP_ENUMERATE},
{"type", HTMLINPUTELEMENT_TYPE, JSPROP_ENUMERATE | JSPROP_READONLY},
{"useMap", HTMLINPUTELEMENT_USEMAP, JSPROP_ENUMERATE},
{"value", HTMLINPUTELEMENT_VALUE, JSPROP_ENUMERATE},
{0}

Просмотреть файл

@ -5,7 +5,7 @@
<li>It has a couple of:
<ul>
<li>Images: <IMG SRC="http://zabadubop/layers/tests/mzcolor.gif" ID="foo"> and
<IMG SRC="http://peoplestage.netscape.com/kipp/nerdly_int.gif">.
<IMG SRC="http://peoplestage.netscape.com/kipp/nerdly_int.gif" NAME="kipp">.
<li>Links to <a href="http://home.netscape.com">Netscape</a> and
<A HREF="http://peoplestage.netscape.com/kipp">Kippy's Home Page</A>.
<li>and Anchors to <a NAME="anchor1">here</A> and
@ -60,6 +60,8 @@ for (x=0; x < lis.length; x++) {
dump(lis[x].tagName + "\n");
}
dump("Named elements:\n");
dump(document.kipp.tagName + " with NAME=" + document.kipp.getDOMAttribute("NAME") + "\n");
</script>
</body>

Просмотреть файл

@ -261,6 +261,29 @@ static const char *kPropFuncDefaultItemStr =
" }\n"
" }\n";
static const char *kPropFuncDefaultItemNonPrimaryStr =
" default:\n"
" {\n"
" %s prop;\n"
" nsIDOM%s* b;\n"
" if (NS_OK == a->QueryInterface(kI%sIID, (void **)&b)) {\n"
" if (NS_OK == b->Item(JSVAL_TO_INT(id), %sprop)) {\n"
"%s"
" NS_RELEASE(b);\n"
" }\n"
" else {\n"
" NS_RELEASE(b);\n"
" return JS_FALSE;\n"
" }\n"
" }\n"
" else {\n"
" JS_ReportError(cx, \"Object must be of type %s\");\n"
" return JS_FALSE;\n"
" }\n"
" }\n"
" }\n"
" }\n";
static const char *kPropFuncEndStr =
" else {\n"
" nsIJSScriptObject *object;\n"
@ -289,13 +312,47 @@ static const char *kPropFuncNamedItemStr =
" }\n"
"\n"
" if (NS_OK == a->NamedItem(name, %sprop)) {\n"
" if (NULL != prop) {\n"
"%s"
" }\n"
" }\n"
" else {\n"
" return JS_FALSE;\n"
" }\n"
" }\n";
static const char *kPropFuncNamedItemNonPrimaryStr =
" else if (JSVAL_IS_STRING(id)) {\n"
" %s prop;\n"
" nsIDOM%s* b;\n"
" nsAutoString name;\n"
"\n"
" JSString *jsstring = JS_ValueToString(cx, id);\n"
" if (nsnull != jsstring) {\n"
" name.SetString(JS_GetStringChars(jsstring));\n"
" }\n"
" else {\n"
" name.SetString(\"\");\n"
" }\n"
"\n"
" if (NS_OK == a->QueryInterface(kI%sIID, (void **)&b)) {\n"
" if (NS_OK == b->NamedItem(name, %sprop)) {\n"
" if (NULL != prop) {\n"
"%s"
" }\n"
" NS_RELEASE(b);\n"
" }\n"
" else {\n"
" NS_RELEASE(b);\n"
" return JS_FALSE;\n"
" }\n"
" }\n"
" else {\n"
" JS_ReportError(cx, \"Object must be of type %s\");\n"
" return JS_FALSE;\n"
" }\n"
" }\n";
#define JSGEN_GENERATE_PROPFUNCBEGIN(buffer, op, className) \
sprintf(buffer, kPropFuncBeginStr, className, op, op, className, className, className)
@ -371,22 +428,33 @@ JSStubGen::GeneratePropertyFunc(IdlSpecification &aSpec, PRBool aIsGetter)
IdlFunction *item_func = NULL;
IdlFunction *named_item_func = NULL;
int m, mcount = primary_iface->FunctionCount();
for (m = 0; m < mcount; m++) {
IdlFunction *func = primary_iface->GetFunctionAt(m);
if (strcmp(func->GetName(), "item") == 0) {
item_func = func;
}
else if (strcmp(func->GetName(), "namedItem") == 0) {
named_item_func = func;
IdlInterface *item_iface = NULL;
IdlInterface *named_item_iface = NULL;
for (i = 0; i < icount; i++) {
IdlInterface *iface = aSpec.GetInterfaceAt(i);
int m, mcount = iface->FunctionCount();
for (m = 0; m < mcount; m++) {
IdlFunction *func = iface->GetFunctionAt(m);
if (strcmp(func->GetName(), "item") == 0) {
item_func = func;
item_iface = iface;
}
else if (strcmp(func->GetName(), "namedItem") == 0) {
named_item_func = func;
named_item_iface = iface;
}
}
}
if (aIsGetter) {
if (NULL != item_func) {
IdlVariable *rval = item_func->GetReturnValue();
GeneratePropGetter(file, *primary_iface, *rval, JSSTUBGEN_DEFAULT);
GeneratePropGetter(file, *item_iface, *rval,
item_iface == primary_iface ?
JSSTUBGEN_DEFAULT : JSSTUBGEN_DEFAULT_NONPRIMARY);
}
else {
JSGEN_GENERATE_PROPFUNCDEFAULT(buf, aIsGetter ? "Get" : "Set");
@ -400,7 +468,9 @@ JSStubGen::GeneratePropertyFunc(IdlSpecification &aSpec, PRBool aIsGetter)
if (aIsGetter && (NULL != named_item_func)) {
IdlVariable *rval = named_item_func->GetReturnValue();
GeneratePropGetter(file, *primary_iface, *rval, JSSTUBGEN_NAMED_ITEM);
GeneratePropGetter(file, *named_item_iface, *rval,
named_item_iface == primary_iface ?
JSSTUBGEN_NAMED_ITEM : JSSTUBGEN_NAMED_ITEM_NONPRIMARY);
}
JSGEN_GENERATE_PROPFUNCEND(buf, aIsGetter ? "Get" : "Set");
@ -471,7 +541,7 @@ JSStubGen::GeneratePropGetter(ofstream *file,
IdlVariable &aAttribute,
PRInt32 aType)
{
char buf[1024];
char buf[2048];
char attr_type[128];
char attr_name[128];
const char *case_str;
@ -522,11 +592,23 @@ JSStubGen::GeneratePropGetter(ofstream *file,
aAttribute.GetType() == TYPE_STRING ? "" : "&",
case_str);
}
else {
else if (JSSTUBGEN_DEFAULT_NONPRIMARY == aType) {
sprintf(buf, kPropFuncDefaultItemStr, attr_type,
aInterface.GetName(), aInterface.GetName(),
aAttribute.GetType() == TYPE_STRING ? "" : "&",
case_str, aInterface.GetName());
}
else if (JSSTUBGEN_NAMED_ITEM == aType) {
sprintf(buf, kPropFuncNamedItemStr, attr_type,
aAttribute.GetType() == TYPE_STRING ? "" : "&",
case_str);
}
else if (JSSTUBGEN_NAMED_ITEM_NONPRIMARY == aType) {
sprintf(buf, kPropFuncNamedItemNonPrimaryStr, attr_type,
aInterface.GetName(), aInterface.GetName(),
aAttribute.GetType() == TYPE_STRING ? "" : "&",
case_str, aInterface.GetName());
}
*file << buf;
}
@ -784,6 +866,22 @@ static const char *kMethodBeginStr = "\n\n"
" nsIDOM%s *nativeThis = (nsIDOM%s*)JS_GetPrivate(cx, obj);\n"
" JSBool rBool = JS_FALSE;\n";
static const char *kMethodBeginNonPrimaryStr = "\n\n"
"//\n"
"// Native method %s\n"
"//\n"
"PR_STATIC_CALLBACK(JSBool)\n"
"%s%s(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval)\n"
"{\n"
" nsIDOM%s *privateThis = (nsIDOM%s*)JS_GetPrivate(cx, obj);\n"
" nsIDOM%s *nativeThis;\n"
" if (NS_OK != privateThis->QueryInterface(kI%sIID, (void **)nativeThis)) {\n"
" JS_ReportError(cx, \"Object must be of type %s\");\n"
" return JS_FALSE;\n"
" }\n"
"\n"
" JSBool rBool = JS_FALSE;\n";
static const char *kMethodReturnStr =
" %s nativeRet;\n";
@ -921,6 +1019,7 @@ JSStubGen::GenerateMethods(IdlSpecification &aSpec)
{
char buf[1024];
ofstream *file = GetFile();
IdlInterface *primary_iface = aSpec.GetInterfaceAt(0);
int i, icount = aSpec.InterfaceCount();
for (i = 0; i < icount; i++) {
@ -936,8 +1035,15 @@ JSStubGen::GenerateMethods(IdlSpecification &aSpec)
GetCapitalizedName(method_name, *func);
GetVariableTypeForLocal(return_type, *rval);
sprintf(buf, kMethodBeginStr, method_name, iface->GetName(),
method_name, iface->GetName(), iface->GetName());
if (i == 0) {
sprintf(buf, kMethodBeginStr, method_name, iface->GetName(),
method_name, iface->GetName(), iface->GetName());
}
else {
sprintf(buf, kMethodBeginNonPrimaryStr, method_name, iface->GetName(),
method_name, primary_iface->GetName(), primary_iface->GetName(),
iface->GetName(), iface->GetName(), iface->GetName());
}
*file << buf;
if (rval->GetType() != TYPE_VOID) {
sprintf(buf, kMethodReturnStr, return_type);

Просмотреть файл

@ -48,7 +48,9 @@ protected:
JSSTUBGEN_PRIMARY,
JSSTUBGEN_NONPRIMARY,
JSSTUBGEN_DEFAULT,
JSSTUBGEN_NAMED_ITEM
JSSTUBGEN_DEFAULT_NONPRIMARY,
JSSTUBGEN_NAMED_ITEM,
JSSTUBGEN_NAMED_ITEM_NONPRIMARY
};
void GenerateIncludes(IdlSpecification &aSpec);