From 687d50d4e3856ea0da49224f21f53356f77e4c74 Mon Sep 17 00:00:00 2001 From: "ducarroz%netscape.com" Date: Thu, 19 Aug 1999 22:10:52 +0000 Subject: [PATCH] Add attribute "autocomplete" --- dom/public/html/nsIDOMHTMLInputElement.h | 7 +++++ dom/public/idl/html/HTMLInputElement.idl | 1 + dom/src/html/nsJSHTMLInputElement.cpp | 36 ++++++++++++++++++++++-- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/dom/public/html/nsIDOMHTMLInputElement.h b/dom/public/html/nsIDOMHTMLInputElement.h index c3c5d6ce9488..7b0f702646d4 100644 --- a/dom/public/html/nsIDOMHTMLInputElement.h +++ b/dom/public/html/nsIDOMHTMLInputElement.h @@ -87,6 +87,9 @@ public: NS_IMETHOD GetValue(nsString& aValue)=0; NS_IMETHOD SetValue(const nsString& aValue)=0; + NS_IMETHOD GetAutocomplete(nsString& aAutocomplete)=0; + NS_IMETHOD SetAutocomplete(const nsString& aAutocomplete)=0; + NS_IMETHOD Blur()=0; NS_IMETHOD Focus()=0; @@ -132,6 +135,8 @@ public: NS_IMETHOD SetUseMap(const nsString& aUseMap); \ NS_IMETHOD GetValue(nsString& aValue); \ NS_IMETHOD SetValue(const nsString& aValue); \ + NS_IMETHOD GetAutocomplete(nsString& aAutocomplete); \ + NS_IMETHOD SetAutocomplete(const nsString& aAutocomplete); \ NS_IMETHOD Blur(); \ NS_IMETHOD Focus(); \ NS_IMETHOD Select(); \ @@ -174,6 +179,8 @@ public: NS_IMETHOD SetUseMap(const nsString& aUseMap) { return _to SetUseMap(aUseMap); } \ NS_IMETHOD GetValue(nsString& aValue) { return _to GetValue(aValue); } \ NS_IMETHOD SetValue(const nsString& aValue) { return _to SetValue(aValue); } \ + NS_IMETHOD GetAutocomplete(PRInt32* aAutocomplete) { return _to GetAutocomplete(aAutocomplete); } \ + NS_IMETHOD SetAutocomplete(PRInt32 aAutocomplete) { return _to SetAutocomplete(aAutocomplete); } \ NS_IMETHOD Blur() { return _to Blur(); } \ NS_IMETHOD Focus() { return _to Focus(); } \ NS_IMETHOD Select() { return _to Select(); } \ diff --git a/dom/public/idl/html/HTMLInputElement.idl b/dom/public/idl/html/HTMLInputElement.idl index 4576d43340fa..0f2349b44e83 100644 --- a/dom/public/idl/html/HTMLInputElement.idl +++ b/dom/public/idl/html/HTMLInputElement.idl @@ -20,6 +20,7 @@ readonly attribute DOMString type; attribute DOMString useMap; attribute DOMString value; + attribute DOMString autocomplete; void blur(); void focus(); void select(); diff --git a/dom/src/html/nsJSHTMLInputElement.cpp b/dom/src/html/nsJSHTMLInputElement.cpp index 52413b25ca0b..6e9893e673d2 100644 --- a/dom/src/html/nsJSHTMLInputElement.cpp +++ b/dom/src/html/nsJSHTMLInputElement.cpp @@ -61,7 +61,8 @@ enum HTMLInputElement_slots { HTMLINPUTELEMENT_TABINDEX = -15, HTMLINPUTELEMENT_TYPE = -16, HTMLINPUTELEMENT_USEMAP = -17, - HTMLINPUTELEMENT_VALUE = -18 + HTMLINPUTELEMENT_VALUE = -18, + HTMLINPUTELEMENT_AUTOCOMPLETE = -19 }; /***********************************************************************/ @@ -375,6 +376,22 @@ GetHTMLInputElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) } break; } + case HTMLINPUTELEMENT_AUTOCOMPLETE: + { + secMan->CheckScriptAccess(scriptCX, obj, "htmlinputelement.autocomplete", &ok); + if (!ok) { + //Need to throw error here + return JS_FALSE; + } + nsAutoString prop; + if (NS_OK == a->GetAutocomplete(prop)) { + nsJSUtils::nsConvertStringToJSVal(prop, cx, vp); + } + else { + return JS_FALSE; + } + break; + } default: return nsJSUtils::nsCallJSScriptObjectGetProperty(a, cx, id, vp); } @@ -655,7 +672,21 @@ SetHTMLInputElementProperty(JSContext *cx, JSObject *obj, jsval id, jsval *vp) break; } - default: + case HTMLINPUTELEMENT_AUTOCOMPLETE: + { + secMan->CheckScriptAccess(scriptCX, obj, "htmlinputelement.autocomplete", &ok); + if (!ok) { + //Need to throw error here + return JS_FALSE; + } + nsAutoString prop; + nsJSUtils::nsConvertJSValToString(prop, cx, *vp); + + a->SetAutocomplete(prop); + + break; + } + default: return nsJSUtils::nsCallJSScriptObjectSetProperty(a, cx, id, vp); } NS_RELEASE(secMan); @@ -911,6 +942,7 @@ static JSPropertySpec HTMLInputElementProperties[] = {"type", HTMLINPUTELEMENT_TYPE, JSPROP_ENUMERATE | JSPROP_READONLY}, {"useMap", HTMLINPUTELEMENT_USEMAP, JSPROP_ENUMERATE}, {"value", HTMLINPUTELEMENT_VALUE, JSPROP_ENUMERATE}, + {"autocomplete", HTMLINPUTELEMENT_AUTOCOMPLETE, JSPROP_ENUMERATE}, {0} };