From 4f210e21a5b112c3f733bb5c084cdb4a116574ce Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Wed, 8 Sep 2010 15:12:14 +0200 Subject: [PATCH] msxml3: Don't use xmlnode's IXMLDOMNode iface in get_[first|last]Node implementations. --- dlls/msxml3/attribute.c | 10 ++++++-- dlls/msxml3/cdata.c | 10 ++++++-- dlls/msxml3/comment.c | 10 ++++++-- dlls/msxml3/docfrag.c | 10 ++++++-- dlls/msxml3/domdoc.c | 10 ++++++-- dlls/msxml3/element.c | 10 ++++++-- dlls/msxml3/entityref.c | 10 ++++++-- dlls/msxml3/msxml_private.h | 10 ++++++++ dlls/msxml3/node.c | 46 ++++++++++++++++++------------------- dlls/msxml3/pi.c | 10 ++++++-- dlls/msxml3/text.c | 10 ++++++-- 11 files changed, 104 insertions(+), 42 deletions(-) diff --git a/dlls/msxml3/attribute.c b/dlls/msxml3/attribute.c index 9a0394dad8d..e96cb6e179d 100644 --- a/dlls/msxml3/attribute.c +++ b/dlls/msxml3/attribute.c @@ -249,7 +249,10 @@ static HRESULT WINAPI domattr_get_firstChild( IXMLDOMNode** domNode) { domattr *This = impl_from_IXMLDOMAttribute( iface ); - return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return node_get_first_child(&This->node, domNode); } static HRESULT WINAPI domattr_get_lastChild( @@ -257,7 +260,10 @@ static HRESULT WINAPI domattr_get_lastChild( IXMLDOMNode** domNode) { domattr *This = impl_from_IXMLDOMAttribute( iface ); - return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return node_get_first_child(&This->node, domNode); } static HRESULT WINAPI domattr_get_previousSibling( diff --git a/dlls/msxml3/cdata.c b/dlls/msxml3/cdata.c index 902fe260484..36787d554ce 100644 --- a/dlls/msxml3/cdata.c +++ b/dlls/msxml3/cdata.c @@ -260,7 +260,10 @@ static HRESULT WINAPI domcdata_get_firstChild( IXMLDOMNode** domNode) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return return_null_node(domNode); } static HRESULT WINAPI domcdata_get_lastChild( @@ -268,7 +271,10 @@ static HRESULT WINAPI domcdata_get_lastChild( IXMLDOMNode** domNode) { domcdata *This = impl_from_IXMLDOMCDATASection( iface ); - return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return return_null_node(domNode); } static HRESULT WINAPI domcdata_get_previousSibling( diff --git a/dlls/msxml3/comment.c b/dlls/msxml3/comment.c index 8763864b5d2..e1477d76d3d 100644 --- a/dlls/msxml3/comment.c +++ b/dlls/msxml3/comment.c @@ -253,7 +253,10 @@ static HRESULT WINAPI domcomment_get_firstChild( IXMLDOMNode** domNode) { domcomment *This = impl_from_IXMLDOMComment( iface ); - return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return return_null_node(domNode); } static HRESULT WINAPI domcomment_get_lastChild( @@ -261,7 +264,10 @@ static HRESULT WINAPI domcomment_get_lastChild( IXMLDOMNode** domNode) { domcomment *This = impl_from_IXMLDOMComment( iface ); - return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return return_null_node(domNode); } static HRESULT WINAPI domcomment_get_previousSibling( diff --git a/dlls/msxml3/docfrag.c b/dlls/msxml3/docfrag.c index ed8b6c5f772..801d2a94268 100644 --- a/dlls/msxml3/docfrag.c +++ b/dlls/msxml3/docfrag.c @@ -255,7 +255,10 @@ static HRESULT WINAPI domfrag_get_firstChild( IXMLDOMNode** domNode) { domfrag *This = impl_from_IXMLDOMDocumentFragment( iface ); - return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return node_get_first_child(&This->node, domNode); } static HRESULT WINAPI domfrag_get_lastChild( @@ -263,7 +266,10 @@ static HRESULT WINAPI domfrag_get_lastChild( IXMLDOMNode** domNode) { domfrag *This = impl_from_IXMLDOMDocumentFragment( iface ); - return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return node_get_first_child(&This->node, domNode); } static HRESULT WINAPI domfrag_get_previousSibling( diff --git a/dlls/msxml3/domdoc.c b/dlls/msxml3/domdoc.c index f7400f48625..35a8f7c4443 100644 --- a/dlls/msxml3/domdoc.c +++ b/dlls/msxml3/domdoc.c @@ -764,7 +764,10 @@ static HRESULT WINAPI domdoc_get_firstChild( IXMLDOMNode** firstChild ) { domdoc *This = impl_from_IXMLDOMDocument3( iface ); - return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), firstChild ); + + TRACE("(%p)->(%p)\n", This, firstChild); + + return node_get_first_child(&This->node, firstChild); } @@ -773,7 +776,10 @@ static HRESULT WINAPI domdoc_get_lastChild( IXMLDOMNode** lastChild ) { domdoc *This = impl_from_IXMLDOMDocument3( iface ); - return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), lastChild ); + + TRACE("(%p)->(%p)\n", This, lastChild); + + return node_get_first_child(&This->node, lastChild); } diff --git a/dlls/msxml3/element.c b/dlls/msxml3/element.c index c7c8d45565e..fa9b18d8293 100644 --- a/dlls/msxml3/element.c +++ b/dlls/msxml3/element.c @@ -264,7 +264,10 @@ static HRESULT WINAPI domelem_get_firstChild( IXMLDOMNode** domNode) { domelem *This = impl_from_IXMLDOMElement( iface ); - return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return node_get_first_child(&This->node, domNode); } static HRESULT WINAPI domelem_get_lastChild( @@ -272,7 +275,10 @@ static HRESULT WINAPI domelem_get_lastChild( IXMLDOMNode** domNode) { domelem *This = impl_from_IXMLDOMElement( iface ); - return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return node_get_first_child(&This->node, domNode); } static HRESULT WINAPI domelem_get_previousSibling( diff --git a/dlls/msxml3/entityref.c b/dlls/msxml3/entityref.c index 3b8ae533fec..b1217b2ce79 100644 --- a/dlls/msxml3/entityref.c +++ b/dlls/msxml3/entityref.c @@ -251,7 +251,10 @@ static HRESULT WINAPI entityref_get_firstChild( IXMLDOMNode** domNode) { entityref *This = impl_from_IXMLDOMEntityReference( iface ); - return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return node_get_first_child(&This->node, domNode); } static HRESULT WINAPI entityref_get_lastChild( @@ -259,7 +262,10 @@ static HRESULT WINAPI entityref_get_lastChild( IXMLDOMNode** domNode) { entityref *This = impl_from_IXMLDOMEntityReference( iface ); - return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return node_get_first_child(&This->node, domNode); } static HRESULT WINAPI entityref_get_previousSibling( diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h index 8964818e462..e8b3799a4a7 100644 --- a/dlls/msxml3/msxml_private.h +++ b/dlls/msxml3/msxml_private.h @@ -164,6 +164,8 @@ extern HRESULT node_get_content(xmlnode*,VARIANT*); extern HRESULT node_put_value(xmlnode*,VARIANT*); extern HRESULT node_get_parent(xmlnode*,IXMLDOMNode**); extern HRESULT node_get_child_nodes(xmlnode*,IXMLDOMNodeList**); +extern HRESULT node_get_first_child(xmlnode*,IXMLDOMNode**); +extern HRESULT node_get_last_child(xmlnode*,IXMLDOMNode**); extern HRESULT DOMDocument_create_from_xmldoc(xmlDocPtr xmldoc, IXMLDOMDocument3 **document); @@ -200,6 +202,14 @@ static inline HRESULT return_bstr(const WCHAR *value, BSTR *p) return S_OK; } +static inline HRESULT return_null_node(IXMLDOMNode **p) +{ + if(!p) + return E_INVALIDARG; + *p = NULL; + return S_FALSE; +} + #endif void* libxslt_handle; diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index aa494c4e742..f37b0818135 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -313,38 +313,30 @@ static HRESULT WINAPI xmlnode_get_childNodes( return E_NOTIMPL; } +HRESULT node_get_first_child(xmlnode *This, IXMLDOMNode **ret) +{ + return get_node(This, "firstChild", This->node->children, ret); +} + static HRESULT WINAPI xmlnode_get_firstChild( IXMLDOMNode *iface, IXMLDOMNode** firstChild) { - xmlnode *This = impl_from_IXMLDOMNode( iface ); - TRACE("(%p)->(%p)\n", This, firstChild); - return get_node( This, "firstChild", This->node->children, firstChild ); + ERR("Should not be called\n"); + return E_NOTIMPL; +} + +HRESULT node_get_last_child(xmlnode *This, IXMLDOMNode **ret) +{ + return get_node(This, "lastChild", This->node->last, ret); } static HRESULT WINAPI xmlnode_get_lastChild( IXMLDOMNode *iface, IXMLDOMNode** lastChild) { - xmlnode *This = impl_from_IXMLDOMNode( iface ); - - TRACE("(%p)->(%p)\n", This, lastChild ); - - if (!lastChild) - return E_INVALIDARG; - - switch( This->node->type ) - { - /* CDATASection, Comment, PI and Text Nodes do not support lastChild */ - case XML_TEXT_NODE: - case XML_CDATA_SECTION_NODE: - case XML_PI_NODE: - case XML_COMMENT_NODE: - *lastChild = NULL; - return S_FALSE; - default: - return get_node( This, "lastChild", This->node->last, lastChild ); - } + ERR("Should not be called\n"); + return E_NOTIMPL; } static HRESULT WINAPI xmlnode_get_previousSibling( @@ -1838,7 +1830,10 @@ static HRESULT WINAPI unknode_get_firstChild( IXMLDOMNode** domNode) { unknode *This = impl_from_unkIXMLDOMNode( iface ); - return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return node_get_first_child(&This->node, domNode); } static HRESULT WINAPI unknode_get_lastChild( @@ -1846,7 +1841,10 @@ static HRESULT WINAPI unknode_get_lastChild( IXMLDOMNode** domNode) { unknode *This = impl_from_unkIXMLDOMNode( iface ); - return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return node_get_first_child(&This->node, domNode); } static HRESULT WINAPI unknode_get_previousSibling( diff --git a/dlls/msxml3/pi.c b/dlls/msxml3/pi.c index 20e6bd6af98..017573a9e88 100644 --- a/dlls/msxml3/pi.c +++ b/dlls/msxml3/pi.c @@ -266,7 +266,10 @@ static HRESULT WINAPI dom_pi_get_firstChild( IXMLDOMNode** domNode) { dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface ); - return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return return_null_node(domNode); } static HRESULT WINAPI dom_pi_get_lastChild( @@ -274,7 +277,10 @@ static HRESULT WINAPI dom_pi_get_lastChild( IXMLDOMNode** domNode) { dom_pi *This = impl_from_IXMLDOMProcessingInstruction( iface ); - return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return return_null_node(domNode); } static HRESULT WINAPI dom_pi_get_previousSibling( diff --git a/dlls/msxml3/text.c b/dlls/msxml3/text.c index 5891814c409..1528b154262 100644 --- a/dlls/msxml3/text.c +++ b/dlls/msxml3/text.c @@ -266,7 +266,10 @@ static HRESULT WINAPI domtext_get_firstChild( IXMLDOMNode** domNode) { domtext *This = impl_from_IXMLDOMText( iface ); - return IXMLDOMNode_get_firstChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return return_null_node(domNode); } static HRESULT WINAPI domtext_get_lastChild( @@ -274,7 +277,10 @@ static HRESULT WINAPI domtext_get_lastChild( IXMLDOMNode** domNode) { domtext *This = impl_from_IXMLDOMText( iface ); - return IXMLDOMNode_get_lastChild( IXMLDOMNode_from_impl(&This->node), domNode ); + + TRACE("(%p)->(%p)\n", This, domNode); + + return return_null_node(domNode); } static HRESULT WINAPI domtext_get_previousSibling(