Jacek Caban : mshtml: Added IHTMLStyleSheet:: cssText property partial implementation.

Alexandre Julliard julliard at wine.codeweavers.com
Tue Nov 18 10:25:19 CST 2014


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Tue Nov 18 15:03:01 2014 +0100

mshtml: Added IHTMLStyleSheet::cssText property partial implementation.

---

 dlls/mshtml/htmlstylesheet.c | 64 +++++++++++++++++++++++++++++++++++++++++---
 1 file changed, 60 insertions(+), 4 deletions(-)

diff --git a/dlls/mshtml/htmlstylesheet.c b/dlls/mshtml/htmlstylesheet.c
index 6480975..d2960d2 100644
--- a/dlls/mshtml/htmlstylesheet.c
+++ b/dlls/mshtml/htmlstylesheet.c
@@ -17,6 +17,7 @@
  */
 
 #include <stdarg.h>
+#include <assert.h>
 
 #define COBJMACROS
 
@@ -629,15 +630,70 @@ static HRESULT WINAPI HTMLStyleSheet_get_media(IHTMLStyleSheet *iface, BSTR *p)
 static HRESULT WINAPI HTMLStyleSheet_put_cssText(IHTMLStyleSheet *iface, BSTR v)
 {
     HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
-    FIXME("(%p)->(%s)\n", This, debugstr_w(v));
-    return E_NOTIMPL;
+    nsresult nsres;
+
+    TRACE("(%p)->(%s)\n", This, debugstr_w(v));
+
+    do {
+        nsres = nsIDOMCSSStyleSheet_DeleteRule(This->nsstylesheet, 0);
+    }while(NS_SUCCEEDED(nsres));
+
+    if(v && *v) {
+        nsAString nsstr;
+        UINT32 idx;
+
+        /* FIXME: This won't work for multiple rules in the string. */
+        nsAString_InitDepend(&nsstr, v);
+        nsres = nsIDOMCSSStyleSheet_InsertRule(This->nsstylesheet, &nsstr, 0, &idx);
+        nsAString_Finish(&nsstr);
+        if(NS_FAILED(nsres)) {
+            FIXME("InsertRule failed for string %s. Probably multiple rules passed.\n", debugstr_w(v));
+            return E_FAIL;
+        }
+    }
+
+    return S_OK;
 }
 
 static HRESULT WINAPI HTMLStyleSheet_get_cssText(IHTMLStyleSheet *iface, BSTR *p)
 {
     HTMLStyleSheet *This = impl_from_IHTMLStyleSheet(iface);
-    FIXME("(%p)->(%p)\n", This, p);
-    return E_NOTIMPL;
+    nsIDOMCSSRuleList *nslist = NULL;
+    nsIDOMCSSRule *nsrule;
+    nsAString nsstr;
+    UINT32 len;
+    nsresult nsres;
+
+    TRACE("(%p)->(%p)\n", This, p);
+
+    nsres = nsIDOMCSSStyleSheet_GetCssRules(This->nsstylesheet, &nslist);
+    if(NS_FAILED(nsres)) {
+        ERR("GetCssRules failed: %08x\n", nsres);
+        return E_FAIL;
+    }
+
+    nsres = nsIDOMCSSRuleList_GetLength(nslist, &len);
+    assert(nsres == NS_OK);
+
+    if(len) {
+        nsres = nsIDOMCSSRuleList_Item(nslist, 0, &nsrule);
+        if(NS_FAILED(nsres))
+            ERR("Item failed: %08x\n", nsres);
+    }
+
+    nsIDOMCSSRuleList_Release(nslist);
+    if(NS_FAILED(nsres))
+        return E_FAIL;
+
+    if(!len) {
+        *p = NULL;
+        return S_OK;
+    }
+
+    nsAString_Init(&nsstr, NULL);
+    nsres = nsIDOMCSSRule_GetCssText(nsrule, &nsstr);
+    nsIDOMCSSRule_Release(nsrule);
+    return return_nsstr(nsres, &nsstr, p);
 }
 
 static HRESULT WINAPI HTMLStyleSheet_get_rules(IHTMLStyleSheet *iface,




More information about the wine-cvs mailing list