mshtml: Return referenced instances from node constructors.

This commit is contained in:
Jacek Caban 2012-06-26 12:33:35 +02:00 committed by Alexandre Julliard
parent d31176ec03
commit a8d0efc7d6
7 changed files with 8 additions and 26 deletions

View File

@ -1037,7 +1037,6 @@ static HRESULT WINAPI HTMLDocument_createElement(IHTMLDocument2 *iface, BSTR eTa
return hres;
*newElem = &elem->IHTMLElement_iface;
IHTMLElement_AddRef(&elem->IHTMLElement_iface);
return S_OK;
}
@ -2262,7 +2261,6 @@ HRESULT create_document_fragment(nsIDOMNode *nsnode, HTMLDocumentNode *doc_node,
doc_frag->node.vtbl = &HTMLDocumentFragmentImplVtbl;
doc_frag->node.cp_container = &doc_frag->basedoc.cp_container;
htmldoc_addref(&doc_frag->basedoc);
*ret = doc_frag;
return S_OK;
}

View File

@ -135,7 +135,6 @@ static HRESULT WINAPI HTMLDocument3_createTextNode(IHTMLDocument3 *iface, BSTR t
return hres;
*newTextNode = &node->IHTMLDOMNode_iface;
IHTMLDOMNode_AddRef(&node->IHTMLDOMNode_iface);
return S_OK;
}

View File

@ -155,7 +155,6 @@ static HRESULT WINAPI HTMLDocument5_createComment(IHTMLDocument5 *iface, BSTR bs
return hres;
*ppRetNode = &elem->node.IHTMLDOMNode_iface;
IHTMLDOMNode_AddRef(&elem->node.IHTMLDOMNode_iface);
return S_OK;
}

View File

@ -1618,7 +1618,6 @@ HRESULT HTMLElement_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **
}
}
IHTMLElement_AddRef(&new_elem->IHTMLElement_iface);
*ret = &new_elem->node;
return S_OK;
}

View File

@ -841,6 +841,7 @@ static HRESULT WINAPI HTMLImageElementFactory_create(IHTMLImageElementFactory *i
hres = IHTMLElement_QueryInterface(&elem->IHTMLElement_iface, &IID_IHTMLImgElement,
(void**)&img);
IHTMLElement_Release(&elem->IHTMLElement_iface);
if(FAILED(hres)) {
ERR("IHTMLElement_QueryInterface failed: 0x%08x\n", hres);
return hres;

View File

@ -1007,14 +1007,7 @@ void HTMLDOMNode_destructor(HTMLDOMNode *This)
static HRESULT HTMLDOMNode_clone(HTMLDOMNode *This, nsIDOMNode *nsnode, HTMLDOMNode **ret)
{
HRESULT hres;
hres = create_node(This->doc, nsnode, ret);
if(FAILED(hres))
return hres;
IHTMLDOMNode_AddRef(&(*ret)->IHTMLDOMNode_iface);
return S_OK;
return create_node(This->doc, nsnode, ret);
}
static const NodeImplVtbl HTMLDOMNodeImplVtbl = {
@ -1027,9 +1020,12 @@ void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsno
{
node->IHTMLDOMNode_iface.lpVtbl = &HTMLDOMNodeVtbl;
node->IHTMLDOMNode2_iface.lpVtbl = &HTMLDOMNode2Vtbl;
node->ref = 1;
node->ref = 2;
node->doc = doc;
if(&doc->node != node)
node->ref++; /* one extra for list entry reference */
if(nsnode)
nsIDOMNode_AddRef(nsnode);
node->nsnode = nsnode;
@ -1096,7 +1092,6 @@ static HRESULT create_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode, HTMLDOMNod
HRESULT get_node(HTMLDocumentNode *This, nsIDOMNode *nsnode, BOOL create, HTMLDOMNode **ret)
{
HTMLDOMNode *iter = This->nodes;
HRESULT hres;
while(iter) {
if(iter->nsnode == nsnode)
@ -1111,10 +1106,7 @@ HRESULT get_node(HTMLDocumentNode *This, nsIDOMNode *nsnode, BOOL create, HTMLDO
return S_OK;
}
hres = create_node(This, nsnode, ret);
if(SUCCEEDED(hres))
IHTMLDOMNode_AddRef(&(*ret)->IHTMLDOMNode_iface);
return hres;
return create_node(This, nsnode, ret);
}
/*

View File

@ -191,14 +191,8 @@ static void HTMLDOMTextNode_destructor(HTMLDOMNode *iface)
static HRESULT HTMLDOMTextNode_clone(HTMLDOMNode *iface, nsIDOMNode *nsnode, HTMLDOMNode **ret)
{
HTMLDOMTextNode *This = impl_from_HTMLDOMNode(iface);
HRESULT hres;
hres = HTMLDOMTextNode_Create(This->node.doc, nsnode, ret);
if(FAILED(hres))
return hres;
IHTMLDOMNode_AddRef(&(*ret)->IHTMLDOMNode_iface);
return S_OK;
return HTMLDOMTextNode_Create(This->node.doc, nsnode, ret);
}
static const NodeImplVtbl HTMLDOMTextNodeImplVtbl = {