msxml: Implement cloneNode and correct insertBefore

James Hawkins truiken at gmail.com
Tue Nov 13 19:04:28 CST 2007


On 11/12/07, Alistair Leslie-Hughes <leslie_alistair at hotmail.com> wrote:
> Hi,
>
> Changelog:
>         InsertBefore is allowed to have outNewChild as NULL
>         Implement cloneNode
>

One fix per patch please.  Also, please add tests for these fixes.

> Best Regards
>   Alistair Leslie-Hughes
>
> diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c
> index 61d5ab2..86d7614 100644
> --- a/dlls/msxml3/node.c
> +++ b/dlls/msxml3/node.c
> @@ -373,7 +373,7 @@ static HRESULT WINAPI xmlnode_insertBefore(
>
>      TRACE("(%p)->(%p,var,%p)\n",This,newChild,outNewChild);
>
> -    if (!(newChild && outNewChild))
> +    if (!newChild)
>          return E_INVALIDARG;
>
>      switch(V_VT(&refChild))
> @@ -412,9 +412,13 @@ static HRESULT WINAPI xmlnode_insertBefore(
>          xmlAddChild(This->node, new_child_node);
>      }
>
> -    IXMLDOMNode_Release(new);
>      IXMLDOMNode_AddRef(newChild);
> -    *outNewChild = newChild;
> +    IXMLDOMNode_Release(new);
> +    if(outNewChild)
> +    {
> +        *outNewChild = newChild;
> +    }
> +
>      TRACE("ret S_OK\n");
>      return S_OK;
>  }
> @@ -517,8 +521,36 @@ static HRESULT WINAPI xmlnode_cloneNode(
>      VARIANT_BOOL deep,
>      IXMLDOMNode** cloneRoot)
>  {
> -    FIXME("\n");
> -    return E_NOTIMPL;
> +    xmlnode *This = impl_from_IXMLDOMNode( iface );
> +    xmlNodePtr pClone = NULL;
> +    IXMLDOMNode *pNode = NULL;
> +
> +    TRACE("%p (%d)\n", This, deep);
> +
> +    if(!cloneRoot)
> +        return E_INVALIDARG;
> +
> +    pClone = xmlCopyNode(This->node, deep ? 1 : 0);
> +    if(pClone)
> +    {
> +        pClone->doc = This->node->doc;
> +
> +        pNode = create_node(pClone);
> +        if(!pNode)
> +        {
> +            ERR("Copy failed\n");
> +            return E_FAIL;
> +        }
> +
> +        *cloneRoot = pNode;
> +    }
> +    else
> +    {
> +        ERR("Copy failed\n");
> +        return E_FAIL;
> +    }
> +
> +    return S_OK;
>  }
>
>  static HRESULT WINAPI xmlnode_get_nodeTypeString(
> @@ -832,7 +864,7 @@ static ULONG WINAPI Internal_Release(
>      if ( ref == 0 )
>      {
>          if( This->node )
> -           xmldoc_release( This->node->doc );
> +               xmldoc_release( This->node->doc );
>

Please don't make random whitespace changes.

-- 
James Hawkins



More information about the wine-devel mailing list