Jacek Caban : mshtml: Added support for flag 2 in getAttribute.

Alexandre Julliard julliard at wine.codeweavers.com
Mon Dec 1 14:53:05 CST 2014


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Mon Dec  1 12:55:51 2014 +0100

mshtml: Added support for flag 2 in getAttribute.

---

 dlls/mshtml/htmlelem.c        | 35 +++++++++++++++++++++++++++++++----
 dlls/mshtml/tests/jstest.html | 12 ++++++++++++
 2 files changed, 43 insertions(+), 4 deletions(-)

diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index 48fff3f..f81ccee 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -606,6 +606,10 @@ static HRESULT WINAPI HTMLElement_Invoke(IHTMLElement *iface, DISPID dispIdMembe
             wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
 }
 
+#define ATTRFLAG_CASESENSITIVE  0x0001
+#define ATTRFLAG_ASSTRING       0x0002
+#define ATTRFLAG_EXPANDURL      0x0004
+
 static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttributeName,
                                                VARIANT AttributeValue, LONG lFlags)
 {
@@ -618,7 +622,7 @@ static HRESULT WINAPI HTMLElement_setAttribute(IHTMLElement *iface, BSTR strAttr
     TRACE("(%p)->(%s %s %08x)\n", This, debugstr_w(strAttributeName), debugstr_variant(&AttributeValue), lFlags);
 
     hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
-            (lFlags&1 ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
+            (lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive) | fdexNameEnsure, &dispid);
     if(FAILED(hres))
         return hres;
 
@@ -647,8 +651,11 @@ static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttr
 
     TRACE("(%p)->(%s %08x %p)\n", This, debugstr_w(strAttributeName), lFlags, AttributeValue);
 
+    if(lFlags & ~(ATTRFLAG_CASESENSITIVE|ATTRFLAG_ASSTRING))
+        FIXME("Unsuported flags %x\n", lFlags);
+
     hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
-            lFlags&1 ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
+            lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &dispid);
     if(hres == DISP_E_UNKNOWNNAME) {
         V_VT(AttributeValue) = VT_NULL;
         return S_OK;
@@ -659,8 +666,28 @@ static HRESULT WINAPI HTMLElement_getAttribute(IHTMLElement *iface, BSTR strAttr
         return hres;
     }
 
-    return IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
+    hres = IDispatchEx_InvokeEx(&This->node.dispex.IDispatchEx_iface, dispid, LOCALE_SYSTEM_DEFAULT,
             DISPATCH_PROPERTYGET, &dispParams, AttributeValue, &excep, NULL);
+    if(FAILED(hres))
+        return hres;
+
+    if(lFlags & ATTRFLAG_ASSTRING) {
+        switch(V_VT(AttributeValue)) {
+        case VT_BSTR:
+            break;
+        case VT_DISPATCH:
+            IDispatch_Release(V_DISPATCH(AttributeValue));
+            V_VT(AttributeValue) = VT_BSTR;
+            V_BSTR(AttributeValue) = SysAllocString(NULL);
+            break;
+        default:
+            hres = VariantChangeType(AttributeValue, AttributeValue, 0, VT_BSTR);
+            if(FAILED(hres))
+                return hres;
+        }
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strAttributeName,
@@ -673,7 +700,7 @@ static HRESULT WINAPI HTMLElement_removeAttribute(IHTMLElement *iface, BSTR strA
     TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(strAttributeName), lFlags, pfSuccess);
 
     hres = IDispatchEx_GetDispID(&This->node.dispex.IDispatchEx_iface, strAttributeName,
-            lFlags&1 ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
+            lFlags&ATTRFLAG_CASESENSITIVE ? fdexNameCaseSensitive : fdexNameCaseInsensitive, &id);
     if(hres == DISP_E_UNKNOWNNAME) {
         *pfSuccess = VARIANT_FALSE;
         return S_OK;
diff --git a/dlls/mshtml/tests/jstest.html b/dlls/mshtml/tests/jstest.html
index 39cdae5..2b3634e 100644
--- a/dlls/mshtml/tests/jstest.html
+++ b/dlls/mshtml/tests/jstest.html
@@ -148,12 +148,16 @@ function test_attrs() {
     x = input.getAttribute("style");
     ok(x === s, "getAttribute('style') = " + x);
     ok(s.cssText === "", "s.cssText = " + s.cssText);
+    x = input.getAttribute("style", 2);
+    ok(x === "", "getAttribute('style') = " + x);
 
     input.setAttribute("style", "display: none");
     x = input.getAttribute("style");
     ok(x === s, "getAttribute('style') = " + x);
     ok(s.cssText === "", "s.cssText = " + s.cssText);
     ok(s.display === "", "s.display = " + s.display);
+    x = input.getAttribute("style", 2);
+    ok(x === "", "getAttribute('style') = " + x);
 
     s.display = "none";
     ok(s.cssText != "", "s.cssText = " + s.cssText);
@@ -163,6 +167,8 @@ function test_attrs() {
     ok(x === s, "getAttribute('style') = " + x);
     ok(s.cssText != "", "s.cssText = " + s.cssText);
     ok(s.display === "none", "s.display = " + s.display);
+    x = input.getAttribute("style", 2);
+    ok(x === "", "getAttribute('style') = " + x);
 
     input.setAttribute("style", null);
     x = input.getAttribute("style");
@@ -173,11 +179,15 @@ function test_attrs() {
 
     x = input.getAttribute("fireEvent");
     ok(x === input.fireEvent, "input.getAttribute('fireEvent') = " + x);
+    x = input.getAttribute("fireEvent", 2);
+    ok(x === "", "getAttribute('fireEvent') = " + x);
 
     input.setAttribute("fireEvent", 3);
     ok(input.fireEvent === 3, "input.fireEvent = " + input.fireEvent);
     x = input.getAttribute("fireEvent");
     ok(x === 3, "input.getAttribute('fireEvent') = " + x);
+    x = input.getAttribute("fireEvent", 2);
+    ok(x === "3", "getAttribute('fireEvent') = " + x);
 
     b = input.removeAttribute("style");
     ok(b === true, "removeAttribute('style') failed");
@@ -186,6 +196,8 @@ function test_attrs() {
     ok(x === s, "getAttribute('style') = " + x);
     ok(s.display === "", "s.display = " + s.display);
     ok(s.cssText === "", "s.cssText = " + s.cssText);
+    x = input.getAttribute("style", 2);
+    ok(x === "", "getAttribute('style') = " + x);
     b = input.removeAttribute("style");
     ok(b === true, "removeAttribute('style') failed");
 




More information about the wine-cvs mailing list