Jacek Caban : mshtml: Store filter in HTMLElement object.

Alexandre Julliard julliard at winehq.org
Fri Mar 16 11:27:50 CDT 2012


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Fri Mar 16 12:17:50 2012 +0100

mshtml: Store filter in HTMLElement object.

---

 dlls/mshtml/htmlelem.c       |    8 ++++++--
 dlls/mshtml/htmlstyle.c      |   24 +++++++++++++++++-------
 dlls/mshtml/htmlstyle.h      |    2 +-
 dlls/mshtml/mshtml_private.h |    3 ++-
 4 files changed, 26 insertions(+), 11 deletions(-)

diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index 7084105..1eab2cd 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -507,7 +507,7 @@ static HRESULT WINAPI HTMLElement_get_style(IHTMLElement *iface, IHTMLStyle **p)
             return E_FAIL;
         }
 
-        hres = HTMLStyle_Create(nsstyle, &This->style);
+        hres = HTMLStyle_Create(This, nsstyle, &This->style);
         nsIDOMCSSStyleDeclaration_Release(nsstyle);
         if(FAILED(hres))
             return hres;
@@ -1648,8 +1648,10 @@ void HTMLElement_destructor(HTMLDOMNode *iface)
 
     if(This->nselem)
         nsIDOMHTMLElement_Release(This->nselem);
-    if(This->style)
+    if(This->style) {
+        This->style->elem = NULL;
         IHTMLStyle_Release(&This->style->IHTMLStyle_iface);
+    }
     if(This->attrs) {
         HTMLDOMAttribute *attr;
 
@@ -1660,6 +1662,8 @@ void HTMLElement_destructor(HTMLDOMNode *iface)
         IHTMLAttributeCollection_Release(&This->attrs->IHTMLAttributeCollection_iface);
     }
 
+    heap_free(This->filter);
+
     HTMLDOMNode_destructor(&This->node);
 }
 
diff --git a/dlls/mshtml/htmlstyle.c b/dlls/mshtml/htmlstyle.c
index 0487992..06a9a53 100644
--- a/dlls/mshtml/htmlstyle.c
+++ b/dlls/mshtml/htmlstyle.c
@@ -694,7 +694,6 @@ static ULONG WINAPI HTMLStyle_Release(IHTMLStyle *iface)
     if(!ref) {
         if(This->nsstyle)
             nsIDOMCSSStyleDeclaration_Release(This->nsstyle);
-        heap_free(This->filter);
         release_dispex(&This->dispex);
         heap_free(This);
     }
@@ -2597,7 +2596,7 @@ static void set_opacity(HTMLStyle *This, const WCHAR *val)
 
 static void update_filter(HTMLStyle *This)
 {
-    const WCHAR *ptr = This->filter, *ptr2;
+    const WCHAR *ptr = This->elem->filter, *ptr2;
 
     static const WCHAR alphaW[] = {'a','l','p','h','a'};
 
@@ -2683,14 +2682,19 @@ static HRESULT WINAPI HTMLStyle_put_filter(IHTMLStyle *iface, BSTR v)
 
     TRACE("(%p)->(%s)\n", This, debugstr_w(v));
 
+    if(!This->elem) {
+        FIXME("Element already destroyed\n");
+        return E_UNEXPECTED;
+    }
+
     if(v) {
         new_filter = heap_strdupW(v);
         if(!new_filter)
             return E_OUTOFMEMORY;
     }
 
-    heap_free(This->filter);
-    This->filter = new_filter;
+    heap_free(This->elem->filter);
+    This->elem->filter = new_filter;
 
     update_filter(This);
     return S_OK;
@@ -2702,8 +2706,13 @@ static HRESULT WINAPI HTMLStyle_get_filter(IHTMLStyle *iface, BSTR *p)
 
     TRACE("(%p)->(%p)\n", This, p);
 
-    if(This->filter) {
-        *p = SysAllocString(This->filter);
+    if(!This->elem) {
+        FIXME("Element already destroyed\n");
+        return E_UNEXPECTED;
+    }
+
+    if(This->elem->filter) {
+        *p = SysAllocString(This->elem->filter);
         if(!*p)
             return E_OUTOFMEMORY;
     }else {
@@ -3038,7 +3047,7 @@ static dispex_static_data_t HTMLStyle_dispex = {
     HTMLStyle_iface_tids
 };
 
-HRESULT HTMLStyle_Create(nsIDOMCSSStyleDeclaration *nsstyle, HTMLStyle **ret)
+HRESULT HTMLStyle_Create(HTMLElement *elem, nsIDOMCSSStyleDeclaration *nsstyle, HTMLStyle **ret)
 {
     HTMLStyle *style;
 
@@ -3049,6 +3058,7 @@ HRESULT HTMLStyle_Create(nsIDOMCSSStyleDeclaration *nsstyle, HTMLStyle **ret)
     style->IHTMLStyle_iface.lpVtbl = &HTMLStyleVtbl;
     style->ref = 1;
     style->nsstyle = nsstyle;
+    style->elem = elem;
     HTMLStyle2_Init(style);
     HTMLStyle3_Init(style);
 
diff --git a/dlls/mshtml/htmlstyle.h b/dlls/mshtml/htmlstyle.h
index a11161e..ef4f2a2 100644
--- a/dlls/mshtml/htmlstyle.h
+++ b/dlls/mshtml/htmlstyle.h
@@ -28,7 +28,7 @@ struct HTMLStyle {
     LONG ref;
 
     nsIDOMCSSStyleDeclaration *nsstyle;
-    WCHAR *filter;
+    HTMLElement *elem;
 };
 
 /* NOTE: Make sure to keep in sync with style_tbl in htmlstyle.c */
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 75591f2..9e30464 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -556,6 +556,7 @@ typedef struct {
     nsIDOMHTMLElement *nselem;
     HTMLStyle *style;
     HTMLAttributeCollection *attrs;
+    WCHAR *filter;
 } HTMLElement;
 
 #define HTMLELEMENT_TIDS    \
@@ -722,7 +723,7 @@ void set_ready_state(HTMLWindow*,READYSTATE) DECLSPEC_HIDDEN;
 
 HRESULT HTMLSelectionObject_Create(HTMLDocumentNode*,nsISelection*,IHTMLSelectionObject**) DECLSPEC_HIDDEN;
 HRESULT HTMLTxtRange_Create(HTMLDocumentNode*,nsIDOMRange*,IHTMLTxtRange**) DECLSPEC_HIDDEN;
-HRESULT HTMLStyle_Create(nsIDOMCSSStyleDeclaration*,HTMLStyle**) DECLSPEC_HIDDEN;
+HRESULT HTMLStyle_Create(HTMLElement*,nsIDOMCSSStyleDeclaration*,HTMLStyle**) DECLSPEC_HIDDEN;
 IHTMLStyleSheet *HTMLStyleSheet_Create(nsIDOMStyleSheet*) DECLSPEC_HIDDEN;
 IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetList*) DECLSPEC_HIDDEN;
 




More information about the wine-cvs mailing list