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