Jacek Caban : mshtml: Get rid of no longer needed unk_ref from HTMLElementCollection.

Alexandre Julliard julliard at winehq.org
Wed Jun 27 19:13:59 CDT 2012


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

Author: Jacek Caban <jacek at codeweavers.com>
Date:   Wed Jun 27 10:55:48 2012 +0200

mshtml: Get rid of no longer needed unk_ref from HTMLElementCollection.

---

 dlls/mshtml/htmldoc.c        |   10 +++++-----
 dlls/mshtml/htmldoc3.c       |    3 +--
 dlls/mshtml/htmlelem.c       |    3 +--
 dlls/mshtml/htmlelem2.c      |    3 +--
 dlls/mshtml/htmlelemcol.c    |   28 +++++++++++-----------------
 dlls/mshtml/htmltable.c      |    3 +--
 dlls/mshtml/htmltablerow.c   |    2 +-
 dlls/mshtml/mshtml_private.h |    4 ++--
 8 files changed, 23 insertions(+), 33 deletions(-)

diff --git a/dlls/mshtml/htmldoc.c b/dlls/mshtml/htmldoc.c
index 19b73e5..6016630 100644
--- a/dlls/mshtml/htmldoc.c
+++ b/dlls/mshtml/htmldoc.c
@@ -213,7 +213,7 @@ static HRESULT WINAPI HTMLDocument_get_images(IHTMLDocument2 *iface, IHTMLElemen
     }
 
     if(nscoll) {
-        *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)&This->IHTMLDocument2_iface, nscoll);
+        *p = create_collection_from_htmlcol(This->doc_node, nscoll);
         nsIDOMElement_Release(nscoll);
     }
 
@@ -245,7 +245,7 @@ static HRESULT WINAPI HTMLDocument_get_applets(IHTMLDocument2 *iface, IHTMLEleme
     }
 
     if(nscoll) {
-        *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)&This->IHTMLDocument2_iface, nscoll);
+        *p = create_collection_from_htmlcol(This->doc_node, nscoll);
         nsIDOMElement_Release(nscoll);
     }
 
@@ -277,7 +277,7 @@ static HRESULT WINAPI HTMLDocument_get_links(IHTMLDocument2 *iface, IHTMLElement
     }
 
     if(nscoll) {
-        *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)&This->IHTMLDocument2_iface, nscoll);
+        *p = create_collection_from_htmlcol(This->doc_node, nscoll);
         nsIDOMElement_Release(nscoll);
     }
 
@@ -309,7 +309,7 @@ static HRESULT WINAPI HTMLDocument_get_forms(IHTMLDocument2 *iface, IHTMLElement
     }
 
     if(nscoll) {
-        *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)&This->IHTMLDocument2_iface, nscoll);
+        *p = create_collection_from_htmlcol(This->doc_node, nscoll);
         nsIDOMElement_Release(nscoll);
     }
 
@@ -341,7 +341,7 @@ static HRESULT WINAPI HTMLDocument_get_anchors(IHTMLDocument2 *iface, IHTMLEleme
     }
 
     if(nscoll) {
-        *p = create_collection_from_htmlcol(This->doc_node, (IUnknown*)&This->IHTMLDocument2_iface, nscoll);
+        *p = create_collection_from_htmlcol(This->doc_node, nscoll);
         nsIDOMElement_Release(nscoll);
     }
 
diff --git a/dlls/mshtml/htmldoc3.c b/dlls/mshtml/htmldoc3.c
index eb19f8c..f930bcd 100644
--- a/dlls/mshtml/htmldoc3.c
+++ b/dlls/mshtml/htmldoc3.c
@@ -572,8 +572,7 @@ static HRESULT WINAPI HTMLDocument3_getElementsByTagName(IHTMLDocument3 *iface,
         return E_FAIL;
     }
 
-    *pelColl = create_collection_from_nodelist(This->doc_node,
-                                               (IUnknown*)&This->IHTMLDocument3_iface, nslist);
+    *pelColl = create_collection_from_nodelist(This->doc_node, nslist);
     nsIDOMNodeList_Release(nslist);
 
     return S_OK;
diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c
index 5f59385..1556cc7 100644
--- a/dlls/mshtml/htmlelem.c
+++ b/dlls/mshtml/htmlelem.c
@@ -1412,8 +1412,7 @@ static HRESULT WINAPI HTMLElement_get_children(IHTMLElement *iface, IDispatch **
         return E_FAIL;
     }
 
-    *p = (IDispatch*)create_collection_from_nodelist(This->node.doc,
-            (IUnknown*)&This->IHTMLElement_iface, nsnode_list);
+    *p = (IDispatch*)create_collection_from_nodelist(This->node.doc, nsnode_list);
 
     nsIDOMNodeList_Release(nsnode_list);
     return S_OK;
diff --git a/dlls/mshtml/htmlelem2.c b/dlls/mshtml/htmlelem2.c
index 9362805..4550681 100644
--- a/dlls/mshtml/htmlelem2.c
+++ b/dlls/mshtml/htmlelem2.c
@@ -1252,8 +1252,7 @@ static HRESULT WINAPI HTMLElement2_getElementsByTagName(IHTMLElement2 *iface, BS
         return E_FAIL;
     }
 
-    *pelColl = create_collection_from_nodelist(This->node.doc,
-            (IUnknown*)&This->IHTMLElement_iface, nslist);
+    *pelColl = create_collection_from_nodelist(This->node.doc, nslist);
     nsIDOMNodeList_Release(nslist);
     return S_OK;
 }
diff --git a/dlls/mshtml/htmlelemcol.c b/dlls/mshtml/htmlelemcol.c
index 76da651..27811f7 100644
--- a/dlls/mshtml/htmlelemcol.c
+++ b/dlls/mshtml/htmlelemcol.c
@@ -35,7 +35,6 @@ typedef struct {
     DispatchEx dispex;
     IHTMLElementCollection IHTMLElementCollection_iface;
 
-    IUnknown *ref_unk;
     HTMLElement **elems;
     DWORD len;
 
@@ -54,8 +53,7 @@ static inline HTMLElement *elem_from_HTMLDOMNode(HTMLDOMNode *iface)
     return CONTAINING_RECORD(iface, HTMLElement, node);
 }
 
-static IHTMLElementCollection *HTMLElementCollection_Create(IUnknown *ref_unk,
-                                                            HTMLElement **elems, DWORD len);
+static IHTMLElementCollection *HTMLElementCollection_Create(HTMLElement **elems, DWORD len);
 
 static void elem_vector_add(elem_vector_t *buf, HTMLElement *elem)
 {
@@ -141,9 +139,9 @@ static ULONG WINAPI HTMLElementCollection_Release(IHTMLElementCollection *iface)
 
         for(i=0; i < This->len; i++)
             node_release(&This->elems[i]->node);
-        IUnknown_Release(This->ref_unk);
-        release_dispex(&This->dispex);
         heap_free(This->elems);
+
+        release_dispex(&This->dispex);
         heap_free(This);
     }
 
@@ -331,7 +329,7 @@ static HRESULT WINAPI HTMLElementCollection_item(IHTMLElementCollection *iface,
 
             if(buf.len > 1) {
                 elem_vector_normalize(&buf);
-                *pdisp = (IDispatch*)HTMLElementCollection_Create(This->ref_unk, buf.buf, buf.len);
+                *pdisp = (IDispatch*)HTMLElementCollection_Create(buf.buf, buf.len);
             }else {
                 if(buf.len == 1) {
                     /* Already AddRef-ed */
@@ -393,7 +391,7 @@ static HRESULT WINAPI HTMLElementCollection_tags(IHTMLElementCollection *iface,
 
     TRACE("fount %d tags\n", buf.len);
 
-    *pdisp = (IDispatch*)HTMLElementCollection_Create(This->ref_unk, buf.buf, buf.len);
+    *pdisp = (IDispatch*)HTMLElementCollection_Create(buf.buf, buf.len);
     return S_OK;
 }
 
@@ -547,10 +545,10 @@ IHTMLElementCollection *create_all_collection(HTMLDOMNode *node, BOOL include_ro
     create_all_list(node->doc, node, &buf);
     elem_vector_normalize(&buf);
 
-    return HTMLElementCollection_Create((IUnknown*)&node->IHTMLDOMNode_iface, buf.buf, buf.len);
+    return HTMLElementCollection_Create(buf.buf, buf.len);
 }
 
-IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode *doc, IUnknown *unk, nsIDOMNodeList *nslist)
+IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode *doc, nsIDOMNodeList *nslist)
 {
     PRUint32 length = 0, i;
     HTMLDOMNode *node;
@@ -582,10 +580,10 @@ IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode *doc, I
         buf.buf = NULL;
     }
 
-    return HTMLElementCollection_Create(unk, buf.buf, buf.len);
+    return HTMLElementCollection_Create(buf.buf, buf.len);
 }
 
-IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode *doc, IUnknown *unk, nsIDOMHTMLCollection *nscol)
+IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode *doc, nsIDOMHTMLCollection *nscol)
 {
     PRUint32 length = 0, i;
     elem_vector_t buf;
@@ -617,11 +615,10 @@ IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode *doc, IU
         return NULL;
     }
 
-    return HTMLElementCollection_Create(unk, buf.buf, buf.len);
+    return HTMLElementCollection_Create(buf.buf, buf.len);
 }
 
-static IHTMLElementCollection *HTMLElementCollection_Create(IUnknown *ref_unk,
-            HTMLElement **elems, DWORD len)
+static IHTMLElementCollection *HTMLElementCollection_Create(HTMLElement **elems, DWORD len)
 {
     HTMLElementCollection *ret = heap_alloc_zero(sizeof(HTMLElementCollection));
 
@@ -633,9 +630,6 @@ static IHTMLElementCollection *HTMLElementCollection_Create(IUnknown *ref_unk,
     init_dispex(&ret->dispex, (IUnknown*)&ret->IHTMLElementCollection_iface,
             &HTMLElementCollection_dispex);
 
-    IUnknown_AddRef(ref_unk);
-    ret->ref_unk = ref_unk;
-
     TRACE("ret=%p len=%d\n", ret, len);
 
     return &ret->IHTMLElementCollection_iface;
diff --git a/dlls/mshtml/htmltable.c b/dlls/mshtml/htmltable.c
index 975e53c..79223be 100644
--- a/dlls/mshtml/htmltable.c
+++ b/dlls/mshtml/htmltable.c
@@ -300,8 +300,7 @@ static HRESULT WINAPI HTMLTable_get_rows(IHTMLTable *iface, IHTMLElementCollecti
         return E_FAIL;
     }
 
-    *p = create_collection_from_htmlcol(This->element.node.doc, (IUnknown*)&This->IHTMLTable_iface,
-            nscol);
+    *p = create_collection_from_htmlcol(This->element.node.doc, nscol);
 
     nsIDOMHTMLCollection_Release(nscol);
     return S_OK;
diff --git a/dlls/mshtml/htmltablerow.c b/dlls/mshtml/htmltablerow.c
index c9b21ec..db5c7f2 100644
--- a/dlls/mshtml/htmltablerow.c
+++ b/dlls/mshtml/htmltablerow.c
@@ -210,7 +210,7 @@ static HRESULT WINAPI HTMLTableRow_get_cells(IHTMLTableRow *iface, IHTMLElementC
         return E_FAIL;
     }
 
-    *p = create_collection_from_htmlcol(This->element.node.doc, (IUnknown*)&This->IHTMLTableRow_iface, nscol);
+    *p = create_collection_from_htmlcol(This->element.node.doc, nscol);
 
     nsIDOMHTMLCollection_Release(nscol);
     return S_OK;
diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 7d0fef1..f050411 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -862,8 +862,8 @@ HRESULT search_window_props(HTMLInnerWindow*,BSTR,DWORD,DISPID*) DECLSPEC_HIDDEN
 HRESULT wrap_iface(IUnknown*,IUnknown*,IUnknown**) DECLSPEC_HIDDEN;
 
 IHTMLElementCollection *create_all_collection(HTMLDOMNode*,BOOL) DECLSPEC_HIDDEN;
-IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,IUnknown*,nsIDOMNodeList*) DECLSPEC_HIDDEN;
-IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,IUnknown*,nsIDOMHTMLCollection*) DECLSPEC_HIDDEN;
+IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode*,nsIDOMNodeList*) DECLSPEC_HIDDEN;
+IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode*,nsIDOMHTMLCollection*) DECLSPEC_HIDDEN;
 
 /* commands */
 typedef struct {




More information about the wine-cvs mailing list