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
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);
return S_OK;
......@@ -331,7 +331,7 @@ static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement
return S_OK;
}
node = get_node(This, (nsIDOMNode*)nsbody);
node = get_node(This, (nsIDOMNode*)nsbody, TRUE);
nsIDOMHTMLElement_Release(nsbody);
IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
......
......@@ -137,7 +137,7 @@ static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, I
ERR("GetDocumentElement failed: %08x\n", nsres);
}
if(nselem) {
node = get_node(This, (nsIDOMNode *)nselem);
node = get_node(This, (nsIDOMNode *)nselem, TRUE);
nsIDOMDocument_Release(nsdoc);
IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
......
......@@ -1067,7 +1067,7 @@ static void create_child_list(HTMLDocument *doc, HTMLElement *elem, elem_vector
nsres = nsIDOMNode_GetNodeType(iter, &node_type);
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
nsres = nsIDOMNode_GetNodeType(iter, &node_type);
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));
create_all_list(doc, node, buf);
......
......@@ -370,7 +370,7 @@ static HTMLDOMNode *create_node(HTMLDocument *doc, nsIDOMNode *nsnode)
* (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;
......@@ -380,7 +380,7 @@ HTMLDOMNode *get_node(HTMLDocument *This, nsIDOMNode *nsnode)
iter = iter->next;
}
if(iter)
if(iter || !create)
return iter;
ret = create_node(This, nsnode);
......
......@@ -469,7 +469,7 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory
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);
nsIDOMElement_Release(nselem);
......
......@@ -464,7 +464,7 @@ void HTMLDOMNode_destructor(HTMLDOMNode*);
HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
void HTMLElement_destructor(HTMLDOMNode*);
HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*,BOOL);
void release_nodes(HTMLDocument*);
void release_script_hosts(HTMLDocument*);
......
......@@ -1073,7 +1073,7 @@ static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuList
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;
}
......
......@@ -1183,7 +1183,7 @@ static HRESULT WINAPI HTMLTxtRange_parentElement(IHTMLTxtRange *iface, IHTMLElem
return S_OK;
}
node = get_node(This->doc, nsnode);
node = get_node(This->doc, nsnode, TRUE);
nsIDOMNode_Release(nsnode);
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