Updating the DOM interfaces HTMLFormElement and HTMLOptionElement to DOM Level 2.

This commit is contained in:
jst%netscape.com 2000-04-18 23:00:58 +00:00
parent 5c031a4d21
commit b28d0d6298
10 changed files with 15 additions and 109 deletions

View File

@ -78,22 +78,7 @@ public:
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
// nsIDOMHTMLFormElement
NS_IMETHOD GetElements(nsIDOMHTMLCollection** aElements);
NS_IMETHOD GetName(nsString& aName);
NS_IMETHOD SetName(const nsString& aName);
NS_IMETHOD GetAcceptCharset(nsString& aAcceptCharset);
NS_IMETHOD SetAcceptCharset(const nsString& aAcceptCharset);
NS_IMETHOD GetAction(nsString& aAction);
NS_IMETHOD SetAction(const nsString& aAction);
NS_IMETHOD GetEnctype(nsString& aEnctype);
NS_IMETHOD SetEnctype(const nsString& aEnctype);
NS_IMETHOD GetMethod(nsString& aMethod);
NS_IMETHOD SetMethod(const nsString& aMethod);
NS_IMETHOD GetTarget(nsString& aTarget);
NS_IMETHOD SetTarget(const nsString& aTarget);
NS_IMETHOD GetLength(PRUint32* aLength);
NS_IMETHOD Reset();
NS_IMETHOD Submit();
NS_DECL_IDOMHTMLFORMELEMENT
// nsIDOMNSHTMLFormElement
NS_IMETHOD GetEncoding(nsString& aEncoding);
@ -509,7 +494,7 @@ nsHTMLFormElement::GetEncoding(nsString& aEncoding)
}
NS_IMETHODIMP
nsHTMLFormElement::GetLength(PRUint32* aLength)
nsHTMLFormElement::GetLength(PRInt32* aLength)
{
*aLength = mControls->mElements.Count();

View File

@ -89,21 +89,7 @@ public:
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
// nsIDOMHTMLOptionElement
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm);
NS_IMETHOD GetDefaultSelected(PRBool* aDefaultSelected);
NS_IMETHOD SetDefaultSelected(PRBool aDefaultSelected);
NS_IMETHOD GetText(nsString& aText);
NS_IMETHOD SetText(const nsString& aText);
NS_IMETHOD GetIndex(PRInt32* aIndex);
NS_IMETHOD SetIndex(PRInt32 aIndex);
NS_IMETHOD GetDisabled(PRBool* aDisabled);
NS_IMETHOD SetDisabled(PRBool aDisabled);
NS_IMETHOD GetLabel(nsString& aLabel);
NS_IMETHOD SetLabel(const nsString& aLabel);
NS_IMETHOD GetSelected(PRBool* aSelected);
NS_IMETHOD SetSelected(PRBool aValue);
NS_IMETHOD GetValue(nsString& aValue);
NS_IMETHOD SetValue(const nsString& aValue);
NS_DECL_IDOMHTMLOPTIONELEMENT
// nsIJSScriptObject
NS_IMPL_IJSSCRIPTOBJECT_USING_GENERIC(mInner)
@ -383,14 +369,6 @@ nsHTMLOptionElement::GetIndex(PRInt32* aIndex)
return res;
}
// This method does nothing for now as Index is supposed to be a read-only property
// (See the DOM Errata)
NS_IMETHODIMP
nsHTMLOptionElement::SetIndex(PRInt32 aIndex)
{
return NS_OK;
}
NS_IMETHODIMP
nsHTMLOptionElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,

View File

@ -41,7 +41,7 @@ public:
NS_IMETHOD GetElements(nsIDOMHTMLCollection** aElements)=0;
NS_IMETHOD GetLength(PRUint32* aLength)=0;
NS_IMETHOD GetLength(PRInt32* aLength)=0;
NS_IMETHOD GetName(nsString& aName)=0;
NS_IMETHOD SetName(const nsString& aName)=0;
@ -69,7 +69,7 @@ public:
#define NS_DECL_IDOMHTMLFORMELEMENT \
NS_IMETHOD GetElements(nsIDOMHTMLCollection** aElements); \
NS_IMETHOD GetLength(PRUint32* aLength); \
NS_IMETHOD GetLength(PRInt32* aLength); \
NS_IMETHOD GetName(nsString& aName); \
NS_IMETHOD SetName(const nsString& aName); \
NS_IMETHOD GetAcceptCharset(nsString& aAcceptCharset); \
@ -89,7 +89,7 @@ public:
#define NS_FORWARD_IDOMHTMLFORMELEMENT(_to) \
NS_IMETHOD GetElements(nsIDOMHTMLCollection** aElements) { return _to GetElements(aElements); } \
NS_IMETHOD GetLength(PRUint32* aLength) { return _to GetLength(aLength); } \
NS_IMETHOD GetLength(PRInt32* aLength) { return _to GetLength(aLength); } \
NS_IMETHOD GetName(nsString& aName) { return _to GetName(aName); } \
NS_IMETHOD SetName(const nsString& aName) { return _to SetName(aName); } \
NS_IMETHOD GetAcceptCharset(nsString& aAcceptCharset) { return _to GetAcceptCharset(aAcceptCharset); } \

View File

@ -48,7 +48,6 @@ public:
NS_IMETHOD SetText(const nsString& aText)=0;
NS_IMETHOD GetIndex(PRInt32* aIndex)=0;
NS_IMETHOD SetIndex(PRInt32 aIndex)=0;
NS_IMETHOD GetDisabled(PRBool* aDisabled)=0;
NS_IMETHOD SetDisabled(PRBool aDisabled)=0;
@ -71,7 +70,6 @@ public:
NS_IMETHOD GetText(nsString& aText); \
NS_IMETHOD SetText(const nsString& aText); \
NS_IMETHOD GetIndex(PRInt32* aIndex); \
NS_IMETHOD SetIndex(PRInt32 aIndex); \
NS_IMETHOD GetDisabled(PRBool* aDisabled); \
NS_IMETHOD SetDisabled(PRBool aDisabled); \
NS_IMETHOD GetLabel(nsString& aLabel); \
@ -90,7 +88,6 @@ public:
NS_IMETHOD GetText(nsString& aText) { return _to GetText(aText); } \
NS_IMETHOD SetText(const nsString& aText) { return _to SetText(aText); } \
NS_IMETHOD GetIndex(PRInt32* aIndex) { return _to GetIndex(aIndex); } \
NS_IMETHOD SetIndex(PRInt32 aIndex) { return _to SetIndex(aIndex); } \
NS_IMETHOD GetDisabled(PRBool* aDisabled) { return _to GetDisabled(aDisabled); } \
NS_IMETHOD SetDisabled(PRBool aDisabled) { return _to SetDisabled(aDisabled); } \
NS_IMETHOD GetLabel(nsString& aLabel) { return _to GetLabel(aLabel); } \

View File

@ -3,7 +3,7 @@
{ 0x93, 0x2e, 0x00, 0x80, 0x5f, 0x8a, 0xdd, 0x32 } } */
readonly attribute HTMLCollection elements;
readonly attribute unsigned long length;
readonly attribute long length;
attribute DOMString name;
attribute DOMString acceptCharset;
attribute DOMString action;

View File

@ -7,7 +7,7 @@
readonly attribute HTMLFormElement form;
attribute boolean defaultSelected;
attribute DOMString text;
attribute long index;
readonly attribute long index;
attribute boolean disabled;
attribute DOMString label;
attribute boolean selected;

View File

@ -102,7 +102,7 @@ GetHTMLFormElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLFORMELEMENT_LENGTH, PR_FALSE);
if (NS_SUCCEEDED(rv)) {
PRUint32 prop;
PRInt32 prop;
rv = a->GetLength(&prop);
if (NS_SUCCEEDED(rv)) {
*vp = INT_TO_JSVAL(prop);
@ -206,6 +206,7 @@ GetHTMLFormElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
nsIDOMElement* prop;
nsIDOMNSHTMLFormElement* b;
if (NS_OK == a->QueryInterface(kINSHTMLFormElementIID, (void **)&b)) {
nsresult result = NS_OK;
rv = b->Item(JSVAL_TO_INT(id), &prop);
if (NS_SUCCEEDED(rv)) {
// get the js object

View File

@ -240,24 +240,6 @@ SetHTMLOptionElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp)
}
break;
}
case HTMLOPTIONELEMENT_INDEX:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLOPTIONELEMENT_INDEX, PR_TRUE);
if (NS_SUCCEEDED(rv)) {
PRInt32 prop;
int32 temp;
if (JSVAL_IS_NUMBER(*vp) && JS_ValueToInt32(cx, *vp, &temp)) {
prop = (PRInt32)temp;
}
else {
rv = NS_ERROR_DOM_NOT_NUMBER_ERR;
}
rv = a->SetIndex(prop);
}
break;
}
case HTMLOPTIONELEMENT_DISABLED:
{
rv = secMan->CheckScriptAccess(cx, obj, NS_DOM_PROP_HTMLOPTIONELEMENT_DISABLED, PR_TRUE);
@ -382,7 +364,7 @@ static JSPropertySpec HTMLOptionElementProperties[] =
{"form", HTMLOPTIONELEMENT_FORM, JSPROP_ENUMERATE | JSPROP_READONLY},
{"defaultSelected", HTMLOPTIONELEMENT_DEFAULTSELECTED, JSPROP_ENUMERATE},
{"text", HTMLOPTIONELEMENT_TEXT, JSPROP_ENUMERATE},
{"index", HTMLOPTIONELEMENT_INDEX, JSPROP_ENUMERATE},
{"index", HTMLOPTIONELEMENT_INDEX, JSPROP_ENUMERATE | JSPROP_READONLY},
{"disabled", HTMLOPTIONELEMENT_DISABLED, JSPROP_ENUMERATE},
{"label", HTMLOPTIONELEMENT_LABEL, JSPROP_ENUMERATE},
{"selected", HTMLOPTIONELEMENT_SELECTED, JSPROP_ENUMERATE},
@ -427,7 +409,7 @@ HTMLOptionElement(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *
return JS_FALSE;
}
result = manager->LookupName(NS_ConvertToString("HTMLOptionElement"), PR_TRUE, classID);
result = manager->LookupName("HTMLOptionElement", PR_TRUE, classID);
if (NS_OK != result) {
return JS_FALSE;
}

View File

@ -78,22 +78,7 @@ public:
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
// nsIDOMHTMLFormElement
NS_IMETHOD GetElements(nsIDOMHTMLCollection** aElements);
NS_IMETHOD GetName(nsString& aName);
NS_IMETHOD SetName(const nsString& aName);
NS_IMETHOD GetAcceptCharset(nsString& aAcceptCharset);
NS_IMETHOD SetAcceptCharset(const nsString& aAcceptCharset);
NS_IMETHOD GetAction(nsString& aAction);
NS_IMETHOD SetAction(const nsString& aAction);
NS_IMETHOD GetEnctype(nsString& aEnctype);
NS_IMETHOD SetEnctype(const nsString& aEnctype);
NS_IMETHOD GetMethod(nsString& aMethod);
NS_IMETHOD SetMethod(const nsString& aMethod);
NS_IMETHOD GetTarget(nsString& aTarget);
NS_IMETHOD SetTarget(const nsString& aTarget);
NS_IMETHOD GetLength(PRUint32* aLength);
NS_IMETHOD Reset();
NS_IMETHOD Submit();
NS_DECL_IDOMHTMLFORMELEMENT
// nsIDOMNSHTMLFormElement
NS_IMETHOD GetEncoding(nsString& aEncoding);
@ -509,7 +494,7 @@ nsHTMLFormElement::GetEncoding(nsString& aEncoding)
}
NS_IMETHODIMP
nsHTMLFormElement::GetLength(PRUint32* aLength)
nsHTMLFormElement::GetLength(PRInt32* aLength)
{
*aLength = mControls->mElements.Count();

View File

@ -89,21 +89,7 @@ public:
NS_IMPL_IDOMHTMLELEMENT_USING_GENERIC(mInner)
// nsIDOMHTMLOptionElement
NS_IMETHOD GetForm(nsIDOMHTMLFormElement** aForm);
NS_IMETHOD GetDefaultSelected(PRBool* aDefaultSelected);
NS_IMETHOD SetDefaultSelected(PRBool aDefaultSelected);
NS_IMETHOD GetText(nsString& aText);
NS_IMETHOD SetText(const nsString& aText);
NS_IMETHOD GetIndex(PRInt32* aIndex);
NS_IMETHOD SetIndex(PRInt32 aIndex);
NS_IMETHOD GetDisabled(PRBool* aDisabled);
NS_IMETHOD SetDisabled(PRBool aDisabled);
NS_IMETHOD GetLabel(nsString& aLabel);
NS_IMETHOD SetLabel(const nsString& aLabel);
NS_IMETHOD GetSelected(PRBool* aSelected);
NS_IMETHOD SetSelected(PRBool aValue);
NS_IMETHOD GetValue(nsString& aValue);
NS_IMETHOD SetValue(const nsString& aValue);
NS_DECL_IDOMHTMLOPTIONELEMENT
// nsIJSScriptObject
NS_IMPL_IJSSCRIPTOBJECT_USING_GENERIC(mInner)
@ -383,14 +369,6 @@ nsHTMLOptionElement::GetIndex(PRInt32* aIndex)
return res;
}
// This method does nothing for now as Index is supposed to be a read-only property
// (See the DOM Errata)
NS_IMETHODIMP
nsHTMLOptionElement::SetIndex(PRInt32 aIndex)
{
return NS_OK;
}
NS_IMETHODIMP
nsHTMLOptionElement::StringToAttribute(nsIAtom* aAttribute,
const nsString& aValue,