Commit 625ed3d0 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Added possibility to get node object from nsIDOMNode only if available.

parent 97577438
...@@ -289,7 +289,7 @@ static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCo ...@@ -289,7 +289,7 @@ static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCo
return S_OK; return S_OK;
} }
*p = create_all_collection(get_node(This, (nsIDOMNode*)nselem)); *p = create_all_collection(get_node(This, (nsIDOMNode*)nselem, TRUE));
nsIDOMElement_Release(nselem); nsIDOMElement_Release(nselem);
return S_OK; return S_OK;
...@@ -331,7 +331,7 @@ static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement ...@@ -331,7 +331,7 @@ static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement
return S_OK; return S_OK;
} }
node = get_node(This, (nsIDOMNode*)nsbody); node = get_node(This, (nsIDOMNode*)nsbody, TRUE);
nsIDOMHTMLElement_Release(nsbody); nsIDOMHTMLElement_Release(nsbody);
IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p); IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
......
...@@ -137,7 +137,7 @@ static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, I ...@@ -137,7 +137,7 @@ static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, I
ERR("GetDocumentElement failed: %08x\n", nsres); ERR("GetDocumentElement failed: %08x\n", nsres);
} }
if(nselem) { if(nselem) {
node = get_node(This, (nsIDOMNode *)nselem); node = get_node(This, (nsIDOMNode *)nselem, TRUE);
nsIDOMDocument_Release(nsdoc); nsIDOMDocument_Release(nsdoc);
IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p); IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
......
...@@ -1067,7 +1067,7 @@ static void create_child_list(HTMLDocument *doc, HTMLElement *elem, elem_vector ...@@ -1067,7 +1067,7 @@ static void create_child_list(HTMLDocument *doc, HTMLElement *elem, elem_vector
nsres = nsIDOMNode_GetNodeType(iter, &node_type); nsres = nsIDOMNode_GetNodeType(iter, &node_type);
if(NS_SUCCEEDED(nsres) && node_type == ELEMENT_NODE) if(NS_SUCCEEDED(nsres) && node_type == ELEMENT_NODE)
elem_vector_add(buf, HTMLELEM_NODE_THIS(get_node(doc, iter))); elem_vector_add(buf, HTMLELEM_NODE_THIS(get_node(doc, iter, TRUE)));
} }
} }
...@@ -1111,7 +1111,7 @@ static void create_all_list(HTMLDocument *doc, HTMLDOMNode *elem, elem_vector *b ...@@ -1111,7 +1111,7 @@ static void create_all_list(HTMLDocument *doc, HTMLDOMNode *elem, elem_vector *b
nsres = nsIDOMNode_GetNodeType(iter, &node_type); nsres = nsIDOMNode_GetNodeType(iter, &node_type);
if(NS_SUCCEEDED(nsres) && node_type == ELEMENT_NODE) { if(NS_SUCCEEDED(nsres) && node_type == ELEMENT_NODE) {
HTMLDOMNode *node = get_node(doc, iter); HTMLDOMNode *node = get_node(doc, iter, TRUE);
elem_vector_add(buf, HTMLELEM_NODE_THIS(node)); elem_vector_add(buf, HTMLELEM_NODE_THIS(node));
create_all_list(doc, node, buf); create_all_list(doc, node, buf);
......
...@@ -370,7 +370,7 @@ static HTMLDOMNode *create_node(HTMLDocument *doc, nsIDOMNode *nsnode) ...@@ -370,7 +370,7 @@ static HTMLDOMNode *create_node(HTMLDocument *doc, nsIDOMNode *nsnode)
* (better) find a way to store HTMLDOMelement pointer in nsIDOMNode. * (better) find a way to store HTMLDOMelement pointer in nsIDOMNode.
*/ */
HTMLDOMNode *get_node(HTMLDocument *This, nsIDOMNode *nsnode) HTMLDOMNode *get_node(HTMLDocument *This, nsIDOMNode *nsnode, BOOL create)
{ {
HTMLDOMNode *iter = This->nodes, *ret; HTMLDOMNode *iter = This->nodes, *ret;
...@@ -380,7 +380,7 @@ HTMLDOMNode *get_node(HTMLDocument *This, nsIDOMNode *nsnode) ...@@ -380,7 +380,7 @@ HTMLDOMNode *get_node(HTMLDocument *This, nsIDOMNode *nsnode)
iter = iter->next; iter = iter->next;
} }
if(iter) if(iter || !create)
return iter; return iter;
ret = create_node(This, nsnode); ret = create_node(This, nsnode);
......
...@@ -469,7 +469,7 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory ...@@ -469,7 +469,7 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory
return E_FAIL; return E_FAIL;
} }
hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(get_node(This->doc, (nsIDOMNode*)nselem)), hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(get_node(This->doc, (nsIDOMNode*)nselem, TRUE)),
&IID_IHTMLOptionElement, (void**)optelem); &IID_IHTMLOptionElement, (void**)optelem);
nsIDOMElement_Release(nselem); nsIDOMElement_Release(nselem);
......
...@@ -464,7 +464,7 @@ void HTMLDOMNode_destructor(HTMLDOMNode*); ...@@ -464,7 +464,7 @@ void HTMLDOMNode_destructor(HTMLDOMNode*);
HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**); HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
void HTMLElement_destructor(HTMLDOMNode*); void HTMLElement_destructor(HTMLDOMNode*);
HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*); HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*,BOOL);
void release_nodes(HTMLDocument*); void release_nodes(HTMLDocument*);
void release_script_hosts(HTMLDocument*); void release_script_hosts(HTMLDocument*);
......
...@@ -1073,7 +1073,7 @@ static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuList ...@@ -1073,7 +1073,7 @@ static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuList
FIXME("aContextFlags=%08x\n", aContextFlags); FIXME("aContextFlags=%08x\n", aContextFlags);
}; };
show_context_menu(This->doc, dwID, &pt, (IDispatch*)HTMLDOMNODE(get_node(This->doc, aNode))); show_context_menu(This->doc, dwID, &pt, (IDispatch*)HTMLDOMNODE(get_node(This->doc, aNode, TRUE)));
return NS_OK; return NS_OK;
} }
......
...@@ -1183,7 +1183,7 @@ static HRESULT WINAPI HTMLTxtRange_parentElement(IHTMLTxtRange *iface, IHTMLElem ...@@ -1183,7 +1183,7 @@ static HRESULT WINAPI HTMLTxtRange_parentElement(IHTMLTxtRange *iface, IHTMLElem
return S_OK; return S_OK;
} }
node = get_node(This->doc, nsnode); node = get_node(This->doc, nsnode, TRUE);
nsIDOMNode_Release(nsnode); nsIDOMNode_Release(nsnode);
return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)parent); return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)parent);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment