Commit 6a1f4eb7 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Improved error handling in get_node calls.

parent 796aca38
......@@ -110,7 +110,9 @@ static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCo
{
HTMLDocument *This = HTMLDOC_THIS(iface);
nsIDOMElement *nselem = NULL;
HTMLDOMNode *node;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
......@@ -125,14 +127,16 @@ static HRESULT WINAPI HTMLDocument_get_all(IHTMLDocument2 *iface, IHTMLElementCo
return E_FAIL;
}
if(nselem) {
*p = create_all_collection(get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE), TRUE);
nsIDOMElement_Release(nselem);
}else {
if(!nselem) {
*p = NULL;
return S_OK;
}
return S_OK;
hres = get_node(This->doc_node, (nsIDOMNode*)nselem, TRUE, &node);
if(SUCCEEDED(hres))
*p = create_all_collection(node, TRUE);
nsIDOMElement_Release(nselem);
return hres;
}
static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement **p)
......@@ -140,6 +144,7 @@ static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement
HTMLDocument *This = HTMLDOC_THIS(iface);
nsIDOMHTMLElement *nsbody = NULL;
HTMLDOMNode *node;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
......@@ -153,17 +158,17 @@ static HRESULT WINAPI HTMLDocument_get_body(IHTMLDocument2 *iface, IHTMLElement
}
}
if(nsbody) {
node = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE);
nsIDOMHTMLElement_Release(nsbody);
IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
}else {
if(!nsbody) {
*p = NULL;
return S_OK;
}
TRACE("*p = %p\n", *p);
return S_OK;
hres = get_node(This->doc_node, (nsIDOMNode*)nsbody, TRUE, &node);
nsIDOMHTMLElement_Release(nsbody);
if(FAILED(hres))
return hres;
return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
}
static HRESULT WINAPI HTMLDocument_get_activeElement(IHTMLDocument2 *iface, IHTMLElement **p)
......
......@@ -138,6 +138,7 @@ static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, I
nsIDOMElement *nselem = NULL;
HTMLDOMNode *node;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
......@@ -157,15 +158,17 @@ static HRESULT WINAPI HTMLDocument3_get_documentElement(IHTMLDocument3 *iface, I
return E_FAIL;
}
if(nselem) {
node = get_node(This->doc_node, (nsIDOMNode *)nselem, TRUE);
nsIDOMElement_Release(nselem);
IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
}else {
if(!nselem) {
*p = NULL;
return S_OK;
}
return S_OK;
hres = get_node(This->doc_node, (nsIDOMNode *)nselem, TRUE, &node);
nsIDOMElement_Release(nselem);
if(FAILED(hres))
return hres;
return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)p);
}
static HRESULT WINAPI HTMLDocument3_uniqueID(IHTMLDocument3 *iface, BSTR *p)
......@@ -464,6 +467,7 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v
nsIDOMNodeList *nsnode_list;
nsAString id_str;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%s %p)\n", This, debugstr_w(v), pel);
......@@ -528,15 +532,17 @@ static HRESULT WINAPI HTMLDocument3_getElementById(IHTMLDocument3 *iface, BSTR v
nsnode = nsnode_by_name ? nsnode_by_name : nsnode_by_id;
if(nsnode) {
node = get_node(This->doc_node, nsnode, TRUE);
hres = get_node(This->doc_node, nsnode, TRUE, &node);
nsIDOMNode_Release(nsnode);
IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)pel);
if(SUCCEEDED(hres))
hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node), &IID_IHTMLElement, (void**)pel);
}else {
*pel = NULL;
hres = S_OK;
}
return S_OK;
return hres;
}
......
......@@ -480,6 +480,7 @@ static void create_all_list(HTMLDocumentNode *doc, HTMLDOMNode *elem, elem_vecto
nsIDOMNode *iter;
PRUint32 list_len = 0, i;
nsresult nsres;
HRESULT hres;
nsres = nsIDOMNode_GetChildNodes(elem->nsnode, &nsnode_list);
if(NS_FAILED(nsres)) {
......@@ -499,7 +500,13 @@ static void create_all_list(HTMLDocumentNode *doc, HTMLDOMNode *elem, elem_vecto
}
if(is_elem_node(iter)) {
HTMLDOMNode *node = get_node(doc, iter, TRUE);
HTMLDOMNode *node;
hres = get_node(doc, iter, TRUE, &node);
if(FAILED(hres)) {
FIXME("get_node failed: %08x\n", hres);
continue;
}
elem_vector_add(buf, HTMLELEM_NODE_THIS(node));
create_all_list(doc, node, buf);
......@@ -524,7 +531,9 @@ IHTMLElementCollection *create_all_collection(HTMLDOMNode *node, BOOL include_ro
IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode *doc, IUnknown *unk, nsIDOMNodeList *nslist)
{
PRUint32 length = 0, i;
HTMLDOMNode *node;
elem_vector_t buf;
HRESULT hres;
nsIDOMNodeList_GetLength(nslist, &length);
......@@ -537,8 +546,12 @@ IHTMLElementCollection *create_collection_from_nodelist(HTMLDocumentNode *doc, I
for(i=0; i<length; i++) {
nsIDOMNodeList_Item(nslist, i, &nsnode);
if(is_elem_node(nsnode))
buf.buf[buf.len++] = HTMLELEM_NODE_THIS(get_node(doc, nsnode, TRUE));
if(is_elem_node(nsnode)) {
hres = get_node(doc, nsnode, TRUE, &node);
if(FAILED(hres))
continue;
buf.buf[buf.len++] = HTMLELEM_NODE_THIS(node);
}
nsIDOMNode_Release(nsnode);
}
......@@ -554,6 +567,8 @@ IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode *doc, IU
{
PRUint32 length = 0, i;
elem_vector_t buf;
HTMLDOMNode *node;
HRESULT hres = S_OK;
nsIDOMHTMLCollection_GetLength(nscol, &length);
......@@ -565,13 +580,21 @@ IHTMLElementCollection *create_collection_from_htmlcol(HTMLDocumentNode *doc, IU
for(i=0; i<length; i++) {
nsIDOMHTMLCollection_Item(nscol, i, &nsnode);
buf.buf[i] = HTMLELEM_NODE_THIS(get_node(doc, nsnode, TRUE));
hres = get_node(doc, nsnode, TRUE, &node);
nsIDOMNode_Release(nsnode);
if(FAILED(hres))
break;
buf.buf[i] = HTMLELEM_NODE_THIS(node);
}
}else {
buf.buf = NULL;
}
if(FAILED(hres)) {
heap_free(buf.buf);
return NULL;
}
return HTMLElementCollection_Create(unk, buf.buf, buf.len);
}
......
......@@ -905,12 +905,18 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, nsIDOMNode
nsIDOMNode *parent, *nsnode;
HTMLDOMNode *node;
PRUint16 node_type;
HRESULT hres;
TRACE("(%p) %s\n", doc, debugstr_w(event_info[eid].name));
prev_event = doc->basedoc.window->event;
if(set_event)
event_obj = create_event(get_node(doc, target, TRUE), eid, nsevent);
if(set_event) {
hres = get_node(doc, target, TRUE, &node);
if(FAILED(hres))
return;
event_obj = create_event(node, eid, nsevent);
}
doc->basedoc.window->event = event_obj;
nsIDOMNode_GetNodeType(target, &node_type);
......@@ -920,8 +926,8 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, nsIDOMNode
switch(node_type) {
case ELEMENT_NODE:
do {
node = get_node(doc, nsnode, FALSE);
if(node)
hres = get_node(doc, nsnode, FALSE, &node);
if(SUCCEEDED(hres) && node)
call_event_handlers(doc, event_obj, *get_node_event_target(node), node->cp_container, eid,
(IDispatch*)HTMLDOMNODE(node));
......@@ -947,8 +953,8 @@ void fire_event(HTMLDocumentNode *doc, eventid_t eid, BOOL set_event, nsIDOMNode
nsres = nsIDOMHTMLDocument_GetBody(doc->nsdoc, &nsbody);
if(NS_SUCCEEDED(nsres) && nsbody) {
node = get_node(doc, (nsIDOMNode*)nsbody, FALSE);
if(node)
hres = get_node(doc, (nsIDOMNode*)nsbody, FALSE, &node);
if(SUCCEEDED(hres) && node)
call_event_handlers(doc, event_obj, *get_node_event_target(node), node->cp_container,
eid, (IDispatch*)HTMLDOMNODE(node));
nsIDOMHTMLElement_Release(nsbody);
......@@ -1225,6 +1231,7 @@ void check_event_attr(HTMLDocumentNode *doc, nsIDOMElement *nselem)
HTMLDOMNode *node;
int i;
nsresult nsres;
HRESULT hres;
nsAString_Init(&attr_value_str, NULL);
nsAString_Init(&attr_name_str, NULL);
......@@ -1241,8 +1248,9 @@ void check_event_attr(HTMLDocumentNode *doc, nsIDOMElement *nselem)
disp = script_parse_event(doc->basedoc.window, attr_value);
if(disp) {
node = get_node(doc, (nsIDOMNode*)nselem, TRUE);
set_event_handler_disp(get_node_event_target(node), node->nsnode, node->doc, i, disp);
hres = get_node(doc, (nsIDOMNode*)nselem, TRUE, &node);
if(SUCCEEDED(hres))
set_event_handler_disp(get_node_event_target(node), node->nsnode, node->doc, i, disp);
IDispatch_Release(disp);
}
}
......
......@@ -47,6 +47,7 @@ static HRESULT htmlform_item(HTMLFormElement *This, int i, IDispatch **ret)
nsIDOMNode *item;
HTMLDOMNode *node;
nsresult nsres;
HRESULT hres;
nsres = nsIDOMHTMLFormElement_GetElements(This->nsform, &elements);
if(NS_FAILED(nsres)) {
......@@ -62,9 +63,9 @@ static HRESULT htmlform_item(HTMLFormElement *This, int i, IDispatch **ret)
}
if(item) {
node = get_node(This->element.node.doc, item, TRUE);
if(!node)
return E_OUTOFMEMORY;
hres = get_node(This->element.node.doc, item, TRUE, &node);
if(FAILED(hres))
return hres;
IHTMLDOMNode_AddRef(HTMLDOMNODE(node));
nsIDOMNode_Release(item);
......
......@@ -153,8 +153,10 @@ static HRESULT WINAPI HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection
{
HTMLDOMChildrenCollection *This = HTMLCHILDCOL_THIS(iface);
nsIDOMNode *nsnode = NULL;
HTMLDOMNode *node;
PRUint32 length=0;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%d %p)\n", This, index, ppItem);
......@@ -173,7 +175,11 @@ static HRESULT WINAPI HTMLDOMChildrenCollection_item(IHTMLDOMChildrenCollection
return E_FAIL;
}
*ppItem = (IDispatch*)get_node(This->doc, nsnode, TRUE);
hres = get_node(This->doc, nsnode, TRUE, &node);
if(FAILED(hres))
return hres;
*ppItem = (IDispatch*)HTMLDOMNODE(node);
IDispatch_AddRef(*ppItem);
return S_OK;
}
......@@ -390,6 +396,7 @@ static HRESULT WINAPI HTMLDOMNode_get_parentNode(IHTMLDOMNode *iface, IHTMLDOMNo
HTMLDOMNode *node;
nsIDOMNode *nsnode;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
......@@ -404,7 +411,11 @@ static HRESULT WINAPI HTMLDOMNode_get_parentNode(IHTMLDOMNode *iface, IHTMLDOMNo
return S_OK;
}
node = get_node(This->doc, nsnode, TRUE);
hres = get_node(This->doc, nsnode, TRUE, &node);
nsIDOMNode_Release(nsnode);
if(FAILED(hres))
return hres;
*p = HTMLDOMNODE(node);
IHTMLDOMNode_AddRef(*p);
return S_OK;
......@@ -459,7 +470,9 @@ static HRESULT WINAPI HTMLDOMNode_insertBefore(IHTMLDOMNode *iface, IHTMLDOMNode
HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
nsIDOMNode *nsnode, *nsref = NULL;
HTMLDOMNode *new_child;
HTMLDOMNode *node_obj;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p %s %p)\n", This, newChild, debugstr_variant(&refChild), node);
......@@ -495,8 +508,12 @@ static HRESULT WINAPI HTMLDOMNode_insertBefore(IHTMLDOMNode *iface, IHTMLDOMNode
return E_FAIL;
}
*node = HTMLDOMNODE(get_node(This->doc, nsnode, TRUE));
hres = get_node(This->doc, nsnode, TRUE, &node_obj);
nsIDOMNode_Release(nsnode);
if(FAILED(hres))
return hres;
*node = HTMLDOMNODE(node_obj);
IHTMLDOMNode_AddRef(*node);
return S_OK;
}
......@@ -508,6 +525,7 @@ static HRESULT WINAPI HTMLDOMNode_removeChild(IHTMLDOMNode *iface, IHTMLDOMNode
HTMLDOMNode *node_obj;
nsIDOMNode *nsnode;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p %p)\n", This, oldChild, node);
......@@ -521,9 +539,13 @@ static HRESULT WINAPI HTMLDOMNode_removeChild(IHTMLDOMNode *iface, IHTMLDOMNode
return E_FAIL;
}
/* FIXME: Make sure that node != newChild */
*node = HTMLDOMNODE(get_node(This->doc, nsnode, TRUE));
hres = get_node(This->doc, nsnode, TRUE, &node_obj);
nsIDOMNode_Release(nsnode);
if(FAILED(hres))
return hres;
/* FIXME: Make sure that node != newChild */
*node = HTMLDOMNODE(node_obj);
IHTMLDOMNode_AddRef(*node);
return S_OK;
}
......@@ -592,6 +614,7 @@ static HRESULT WINAPI HTMLDOMNode_appendChild(IHTMLDOMNode *iface, IHTMLDOMNode
HTMLDOMNode *node_obj;
nsIDOMNode *nsnode;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%p %p)\n", This, newChild, node);
......@@ -605,8 +628,13 @@ static HRESULT WINAPI HTMLDOMNode_appendChild(IHTMLDOMNode *iface, IHTMLDOMNode
nsnode = node_obj->nsnode;
}
hres = get_node(This->doc, nsnode, TRUE, &node_obj);
nsIDOMNode_Release(nsnode);
if(FAILED(hres))
return hres;
/* FIXME: Make sure that node != newChild */
*node = HTMLDOMNODE(get_node(This->doc, nsnode, TRUE));
*node = HTMLDOMNODE(node_obj);
IHTMLDOMNode_AddRef(*node);
return S_OK;
}
......@@ -694,17 +722,24 @@ static HRESULT WINAPI HTMLDOMNode_get_firstChild(IHTMLDOMNode *iface, IHTMLDOMNo
{
HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
nsIDOMNode *nschild = NULL;
HTMLDOMNode *node;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
nsIDOMNode_GetFirstChild(This->nsnode, &nschild);
if(nschild) {
*p = HTMLDOMNODE(get_node(This->doc, nschild, TRUE));
IHTMLDOMNode_AddRef(*p);
}else {
if(!nschild) {
*p = NULL;
return S_OK;
}
hres = get_node(This->doc, nschild, TRUE, &node);
nsIDOMNode_Release(nschild);
if(FAILED(hres))
return hres;
*p = HTMLDOMNODE(node);
IHTMLDOMNode_AddRef(*p);
return S_OK;
}
......@@ -712,17 +747,24 @@ static HRESULT WINAPI HTMLDOMNode_get_lastChild(IHTMLDOMNode *iface, IHTMLDOMNod
{
HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
nsIDOMNode *nschild = NULL;
HTMLDOMNode *node;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
nsIDOMNode_GetLastChild(This->nsnode, &nschild);
if(nschild) {
*p = HTMLDOMNODE(get_node(This->doc, nschild, TRUE));
IHTMLDOMNode_AddRef(*p);
}else {
if(!nschild) {
*p = NULL;
return S_OK;
}
hres = get_node(This->doc, nschild, TRUE, &node);
nsIDOMNode_Release(nschild);
if(FAILED(hres))
return hres;
*p = HTMLDOMNODE(node);
IHTMLDOMNode_AddRef(*p);
return S_OK;
}
......@@ -737,17 +779,24 @@ static HRESULT WINAPI HTMLDOMNode_get_nextSibling(IHTMLDOMNode *iface, IHTMLDOMN
{
HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
nsIDOMNode *nssibling = NULL;
HTMLDOMNode *node;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, p);
nsIDOMNode_GetNextSibling(This->nsnode, &nssibling);
if(nssibling) {
*p = HTMLDOMNODE(get_node(This->doc, nssibling, TRUE));
IHTMLDOMNode_AddRef(*p);
}else {
if(!nssibling) {
*p = NULL;
return S_OK;
}
hres = get_node(This->doc, nssibling, TRUE, &node);
nsIDOMNode_Release(nssibling);
if(FAILED(hres))
return hres;
*p = HTMLDOMNODE(node);
IHTMLDOMNode_AddRef(*p);
return S_OK;
}
......@@ -973,7 +1022,7 @@ static HTMLDOMNode *create_node(HTMLDocumentNode *doc, nsIDOMNode *nsnode)
* (better) find a way to store HTMLDOMelement pointer in nsIDOMNode.
*/
HTMLDOMNode *get_node(HTMLDocumentNode *This, nsIDOMNode *nsnode, BOOL create)
HRESULT get_node(HTMLDocumentNode *This, nsIDOMNode *nsnode, BOOL create, HTMLDOMNode **ret)
{
HTMLDOMNode *iter = This->nodes;
......@@ -983,10 +1032,13 @@ HTMLDOMNode *get_node(HTMLDocumentNode *This, nsIDOMNode *nsnode, BOOL create)
iter = iter->next;
}
if(iter || !create)
return iter;
if(iter || !create) {
*ret = iter;
return S_OK;
}
return create_node(This, nsnode);
*ret = create_node(This, nsnode);
return *ret ? S_OK : E_OUTOFMEMORY;
}
/*
......
......@@ -466,6 +466,7 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory
{
HTMLOptionElementFactory *This = HTMLOPTFACTORY_THIS(iface);
nsIDOMHTMLElement *nselem;
HTMLDOMNode *node;
HRESULT hres;
static const PRUnichar optionW[] = {'O','P','T','I','O','N',0};
......@@ -484,9 +485,13 @@ static HRESULT WINAPI HTMLOptionElementFactory_create(IHTMLOptionElementFactory
if(FAILED(hres))
return hres;
hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(get_node(This->window->doc, (nsIDOMNode*)nselem, TRUE)),
&IID_IHTMLOptionElement, (void**)optelem);
hres = get_node(This->window->doc, (nsIDOMNode*)nselem, TRUE, &node);
nsIDOMHTMLElement_Release(nselem);
if(FAILED(hres))
return hres;
hres = IHTMLDOMNode_QueryInterface(HTMLDOMNODE(node),
&IID_IHTMLOptionElement, (void**)optelem);
if(V_VT(&text) == VT_BSTR)
IHTMLOptionElement_put_text(*optelem, V_BSTR(&text));
......
......@@ -47,6 +47,7 @@ static HRESULT htmlselect_item(HTMLSelectElement *This, int i, IDispatch **ret)
nsIDOMHTMLOptionsCollection *nscol;
nsIDOMNode *nsnode;
nsresult nsres;
HRESULT hres;
nsres = nsIDOMHTMLSelectElement_GetOptions(This->nsselect, &nscol);
if(NS_FAILED(nsres)) {
......@@ -64,12 +65,10 @@ static HRESULT htmlselect_item(HTMLSelectElement *This, int i, IDispatch **ret)
if(nsnode) {
HTMLDOMNode *node;
node = get_node(This->element.node.doc, nsnode, TRUE);
hres = get_node(This->element.node.doc, nsnode, TRUE, &node);
nsIDOMNode_Release(nsnode);
if(!node) {
ERR("Could not find node\n");
return E_FAIL;
}
if(FAILED(hres))
return hres;
IHTMLDOMNode_AddRef(HTMLDOMNODE(node));
*ret = (IDispatch*)HTMLDOMNODE(node);
......
......@@ -857,7 +857,7 @@ HRESULT HTMLElement_clone(HTMLDOMNode*,nsIDOMNode*,HTMLDOMNode**);
HRESULT HTMLFrameBase_QI(HTMLFrameBase*,REFIID,void**);
void HTMLFrameBase_destructor(HTMLFrameBase*);
HTMLDOMNode *get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL);
HRESULT get_node(HTMLDocumentNode*,nsIDOMNode*,BOOL,HTMLDOMNode**);
void release_nodes(HTMLDocumentNode*);
void release_script_hosts(HTMLWindow*);
......
......@@ -275,14 +275,15 @@ static void bind_to_tree(HTMLDocumentNode *doc, nsISupports *nsiface)
nsIDOMNode *nsnode;
HTMLDOMNode *node;
nsresult nsres;
HRESULT hres;
nsres = nsISupports_QueryInterface(nsiface, &IID_nsIDOMNode, (void**)&nsnode);
if(NS_FAILED(nsres))
return;
node = get_node(doc, nsnode, TRUE);
hres = get_node(doc, nsnode, TRUE, &node);
nsIDOMNode_Release(nsnode);
if(!node) {
if(FAILED(hres)) {
ERR("Could not get node\n");
return;
}
......
......@@ -1128,9 +1128,11 @@ static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuList
{
NSContainer *This = NSCML_THIS(iface);
nsIDOMMouseEvent *event;
HTMLDOMNode *node;
POINT pt;
DWORD dwID = CONTEXT_MENU_DEFAULT;
nsresult nsres;
HRESULT hres;
TRACE("(%p)->(%08x %p %p)\n", This, aContextFlags, aEvent, aNode);
......@@ -1166,8 +1168,11 @@ static nsresult NSAPI nsContextMenuListener_OnShowContextMenu(nsIContextMenuList
FIXME("aContextFlags=%08x\n", aContextFlags);
};
show_context_menu(This->doc, dwID, &pt, (IDispatch*)HTMLDOMNODE(get_node(This->doc->basedoc.doc_node, aNode, TRUE)));
hres = get_node(This->doc->basedoc.doc_node, aNode, TRUE, &node);
if(FAILED(hres))
return NS_ERROR_FAILURE;
show_context_menu(This->doc, dwID, &pt, (IDispatch*)HTMLDOMNODE(node));
return NS_OK;
}
......
......@@ -1190,6 +1190,7 @@ static HRESULT WINAPI HTMLTxtRange_parentElement(IHTMLTxtRange *iface, IHTMLElem
HTMLTxtRange *This = HTMLTXTRANGE_THIS(iface);
nsIDOMNode *nsnode, *tmp;
HTMLDOMNode *node;
HRESULT hres;
TRACE("(%p)->(%p)\n", This, parent);
......@@ -1205,8 +1206,10 @@ static HRESULT WINAPI HTMLTxtRange_parentElement(IHTMLTxtRange *iface, IHTMLElem
return S_OK;
}
node = get_node(This->doc, nsnode, TRUE);
hres = get_node(This->doc, nsnode, TRUE, &node);
nsIDOMNode_Release(nsnode);
if(FAILED(hres))
return hres;
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