msxml3: Revert "Simplify IXMLDOMNode::removeChild".

The simplification was bad, native msxml works if interface pointers
to the wrong interface are passed in. Tests included.
This commit is contained in:
Michael Karcher 2008-10-07 11:56:06 +02:00 committed by Alexandre Julliard
parent 91513caa16
commit 57ee10ff12
2 changed files with 16 additions and 3 deletions

View File

@ -671,6 +671,8 @@ static HRESULT WINAPI xmlnode_removeChild(
{
xmlnode *This = impl_from_IXMLDOMNode( iface );
xmlNode *child_node_ptr;
HRESULT hr;
IXMLDOMNode *child;
TRACE("%p->(%p, %p)\n", This, childNode, oldChild);
@ -679,15 +681,22 @@ static HRESULT WINAPI xmlnode_removeChild(
if(oldChild)
*oldChild = NULL;
child_node_ptr = impl_from_IXMLDOMNode(childNode)->node;
hr = IXMLDOMNode_QueryInterface(childNode, &IID_IXMLDOMNode, (LPVOID)&child);
if(FAILED(hr))
return hr;
child_node_ptr = impl_from_IXMLDOMNode(child)->node;
if(child_node_ptr->parent != This->node)
{
WARN("childNode %p is not a child of %p\n", childNode, iface);
IXMLDOMNode_Release(child);
return E_INVALIDARG;
}
xmlUnlinkNode(child_node_ptr);
IXMLDOMNode_Release(child);
if(oldChild)
{
IXMLDOMNode_AddRef(childNode);

View File

@ -1791,7 +1791,7 @@ static void test_removeChild(void)
BSTR str;
VARIANT_BOOL b;
IXMLDOMDocument *doc;
IXMLDOMElement *element;
IXMLDOMElement *element, *lc_element;
IXMLDOMNode *fo_node, *ba_node, *removed_node, *temp_node, *lc_node;
IXMLDOMNodeList *root_list, *fo_list;
@ -1855,7 +1855,11 @@ static void test_removeChild(void)
r = IXMLDOMNodeList_get_item( root_list, 0, &lc_node );
ok( r == S_OK, "ret %08x\n", r);
r = IXMLDOMElement_removeChild( element, lc_node, NULL );
r = IXMLDOMElement_QueryInterface( lc_node, &IID_IXMLDOMElement, (LPVOID*)&lc_element );
ok( r == S_OK, "ret %08x\n", r);
/* MS quirk: passing wrong interface pointer works, too */
r = IXMLDOMElement_removeChild( element, (IXMLDOMNode*)lc_element, NULL );
ok( r == S_OK, "ret %08x\n", r);
r = IXMLDOMNode_get_parentNode( lc_node, &temp_node );