diff --git a/dom/public/coreEvents/nsIDOMEvent.h b/dom/public/coreEvents/nsIDOMEvent.h index 13ad9c83ddf..2eada6117dc 100644 --- a/dom/public/coreEvents/nsIDOMEvent.h +++ b/dom/public/coreEvents/nsIDOMEvent.h @@ -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 { diff --git a/dom/public/coreEvents/nsIDOMNSEvent.h b/dom/public/coreEvents/nsIDOMNSEvent.h index 0d4e517e817..a93ef4cf0fb 100644 --- a/dom/public/coreEvents/nsIDOMNSEvent.h +++ b/dom/public/coreEvents/nsIDOMNSEvent.h @@ -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 { diff --git a/dom/public/html/MANIFEST b/dom/public/html/MANIFEST index 26be242eaa2..228f6996d99 100644 --- a/dom/public/html/MANIFEST +++ b/dom/public/html/MANIFEST @@ -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 diff --git a/dom/public/html/Makefile b/dom/public/html/Makefile index 2808ba5c071..432600ec691 100644 --- a/dom/public/html/Makefile +++ b/dom/public/html/Makefile @@ -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 diff --git a/dom/public/html/makefile.win b/dom/public/html/makefile.win index 40ef1e34d95..5912d42fba1 100644 --- a/dom/public/html/makefile.win +++ b/dom/public/html/makefile.win @@ -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 diff --git a/dom/public/html/nsIDOMHTMLFormElement.h b/dom/public/html/nsIDOMHTMLFormElement.h index 97493cfb90a..9658f99aa3b 100644 --- a/dom/public/html/nsIDOMHTMLFormElement.h +++ b/dom/public/html/nsIDOMHTMLFormElement.h @@ -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); diff --git a/dom/public/html/nsIDOMHTMLInputElement.h b/dom/public/html/nsIDOMHTMLInputElement.h index 203dbdfac6a..f8b82cc0af4 100644 --- a/dom/public/html/nsIDOMHTMLInputElement.h +++ b/dom/public/html/nsIDOMHTMLInputElement.h @@ -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); } \ diff --git a/dom/public/html/nsIDOMNSHTMLDocument.h b/dom/public/html/nsIDOMNSHTMLDocument.h new file mode 100644 index 00000000000..6d21612fce3 --- /dev/null +++ b/dom/public/html/nsIDOMNSHTMLDocument.h @@ -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__ diff --git a/dom/public/html/nsIDOMNSHTMLFormElement.h b/dom/public/html/nsIDOMNSHTMLFormElement.h new file mode 100644 index 00000000000..1af53dc2494 --- /dev/null +++ b/dom/public/html/nsIDOMNSHTMLFormElement.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__ diff --git a/dom/public/idl/html/HTMLDocument.idl b/dom/public/idl/html/HTMLDocument.idl index 901e27cbeb6..4e5dfcd2291 100644 --- a/dom/public/idl/html/HTMLDocument.idl +++ b/dom/public/idl/html/HTMLDocument.idl @@ -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); + }; \ No newline at end of file diff --git a/dom/public/idl/html/HTMLFormElement.idl b/dom/public/idl/html/HTMLFormElement.idl index 2a1113a0def..55c8d03bcb0 100644 --- a/dom/public/idl/html/HTMLFormElement.idl +++ b/dom/public/idl/html/HTMLFormElement.idl @@ -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); + }; \ No newline at end of file diff --git a/dom/public/idl/html/HTMLInputElement.idl b/dom/public/idl/html/HTMLInputElement.idl index 0dc18dec301..cc2bea3401e 100644 --- a/dom/public/idl/html/HTMLInputElement.idl +++ b/dom/public/idl/html/HTMLInputElement.idl @@ -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(); diff --git a/dom/public/nsIDOMNavigator.h b/dom/public/nsIDOMNavigator.h index efd91f794b3..16dcc5607ed 100644 --- a/dom/public/nsIDOMNavigator.h +++ b/dom/public/nsIDOMNavigator.h @@ -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 { diff --git a/dom/public/nsIDOMWindow.h b/dom/public/nsIDOMWindow.h index 9a30361b502..42c3e5408cf 100644 --- a/dom/public/nsIDOMWindow.h +++ b/dom/public/nsIDOMWindow.h @@ -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 { diff --git a/dom/src/build/dlldeps.cpp b/dom/src/build/dlldeps.cpp index a024503e786..f36419d59b6 100644 --- a/dom/src/build/dlldeps.cpp +++ b/dom/src/build/dlldeps.cpp @@ -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); } diff --git a/dom/src/html/nsJSHTMLCollection.cpp b/dom/src/html/nsJSHTMLCollection.cpp index 81433c3c3f5..4bc3dc52d9d 100644 --- a/dom/src/html/nsJSHTMLCollection.cpp +++ b/dom/src/html/nsJSHTMLCollection.cpp @@ -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; diff --git a/dom/src/html/nsJSHTMLDocument.cpp b/dom/src/html/nsJSHTMLDocument.cpp index 594198166aa..156b86cc9b0 100644 --- a/dom/src/html/nsJSHTMLDocument.cpp +++ b/dom/src/html/nsJSHTMLDocument.cpp @@ -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} }; diff --git a/dom/src/html/nsJSHTMLFormElement.cpp b/dom/src/html/nsJSHTMLFormElement.cpp index ac41508bbbd..7cd21c538b1 100644 --- a/dom/src/html/nsJSHTMLFormElement.cpp +++ b/dom/src/html/nsJSHTMLFormElement.cpp @@ -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} }; diff --git a/dom/src/html/nsJSHTMLInputElement.cpp b/dom/src/html/nsJSHTMLInputElement.cpp index bcf30ebd2ca..9362f5ed0ed 100644 --- a/dom/src/html/nsJSHTMLInputElement.cpp +++ b/dom/src/html/nsJSHTMLInputElement.cpp @@ -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} diff --git a/dom/tests/js/lists.html b/dom/tests/js/lists.html index c639cef23fe..eecb345f954 100644 --- a/dom/tests/js/lists.html +++ b/dom/tests/js/lists.html @@ -5,7 +5,7 @@