Jacek Caban : mshtml: Added IHTMLInputElement::maxLength implementation.

Alexandre Julliard julliard at winehq.org
Fri Jul 13 14:11:19 CDT 2012


Module: wine
Branch: master
Commit: 4c96957fc6768ef1fbb8801b4a17682dc59db34c
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4c96957fc6768ef1fbb8801b4a17682dc59db34c

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Jul 13 14:45:46 2012 +0200

mshtml: Added IHTMLInputElement::maxLength implementation.

---

 dlls/mshtml/htmlinput.c |   28 ++++++++++++++++++++++++----
 dlls/mshtml/tests/dom.c |   27 ++++++++++++++++++++++++++-
 2 files changed, 50 insertions(+), 5 deletions(-)

diff --git a/dlls/mshtml/htmlinput.c b/dlls/mshtml/htmlinput.c
index f4f513c..ba6e98f 100644
--- a/dlls/mshtml/htmlinput.c
+++ b/dlls/mshtml/htmlinput.c
@@ -18,6 +18,7 @@
 
 #include <stdarg.h>
 #include <assert.h>
+#include <limits.h>
 
 #define COBJMACROS
 
@@ -273,15 +274,34 @@ static HRESULT WINAPI HTMLInputElement_get_size(IHTMLInputElement *iface, LONG *
 static HRESULT WINAPI HTMLInputElement_put_maxLength(IHTMLInputElement *iface, LONG v)
 {
     HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
-    FIXME("(%p)->(%d)\n", This, v);
-    return E_NOTIMPL;
+    nsresult nsres;
+
+    TRACE("(%p)->(%d)\n", This, v);
+
+    nsres = nsIDOMHTMLInputElement_SetMaxLength(This->nsinput, v);
+    if(NS_FAILED(nsres)) {
+        /* FIXME: Gecko throws an error on negative values, while MSHTML should accept them */
+        FIXME("SetMaxLength failed\n");
+        return E_FAIL;
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLInputElement_get_maxLength(IHTMLInputElement *iface, LONG *p)
 {
     HTMLInputElement *This = impl_from_IHTMLInputElement(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    PRInt32 max_length;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    nsres = nsIDOMHTMLInputElement_GetMaxLength(This->nsinput, &max_length);
+    assert(nsres == NS_OK);
+
+    /* Gecko reports -1 as default value, while MSHTML uses INT_MAX */
+    *p = max_length == -1 ? INT_MAX : max_length;
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLInputElement_select(IHTMLInputElement *iface)
diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c
index b40fe5d..8940627 100644
--- a/dlls/mshtml/tests/dom.c
+++ b/dlls/mshtml/tests/dom.c
@@ -2704,11 +2704,33 @@ static void _test_input_set_checked(unsigned line, IHTMLInputElement *input, VAR
     HRESULT hres;
 
     hres = IHTMLInputElement_put_checked(input, b);
-    ok_(__FILE__,line) (hres == S_OK, "get_checked failed: %08x\n", hres);
+    ok_(__FILE__,line) (hres == S_OK, "put_checked failed: %08x\n", hres);
 
     _test_input_get_checked(line, input, b);
 }
 
+#define test_input_maxlength(i,b) _test_input_maxlength(__LINE__,i,b)
+static void _test_input_maxlength(unsigned line, IHTMLInputElement *input, LONG exl)
+{
+    LONG maxlength = 0xdeadbeef;
+    HRESULT hres;
+
+    hres = IHTMLInputElement_get_maxLength(input, &maxlength);
+    ok_(__FILE__,line) (hres == S_OK, "get_maxLength failed: %08x\n", hres);
+    ok_(__FILE__,line) (maxlength == exl, "maxLength=%x, expected %d\n", maxlength, exl);
+}
+
+#define test_input_set_maxlength(i,b) _test_input_set_maxlength(__LINE__,i,b)
+static void _test_input_set_maxlength(unsigned line, IHTMLInputElement *input, LONG l)
+{
+    HRESULT hres;
+
+    hres = IHTMLInputElement_put_maxLength(input, l);
+    ok_(__FILE__,line) (hres == S_OK, "put_maxLength failed: %08x\n", hres);
+
+    _test_input_maxlength(line, input, l);
+}
+
 #define test_input_value(o,t) _test_input_value(__LINE__,o,t)
 static void _test_input_value(unsigned line, IUnknown *unk, const char *exval)
 {
@@ -5295,6 +5317,9 @@ static void test_elems(IHTMLDocument2 *doc)
         test_input_set_checked(input, VARIANT_TRUE);
         test_input_set_checked(input, VARIANT_FALSE);
 
+        test_input_maxlength(input, 0x7fffffff);
+        test_input_set_maxlength(input, 30);
+
         test_input_name(input, NULL);
         test_input_set_name(input, "test");
 




More information about the wine-cvs mailing list