https://git.reactos.org/?p=reactos.git;a=commitdiff;h=9f0f6adfb04f5f987217de85703a2ab741e23166
commit 9f0f6adfb04f5f987217de85703a2ab741e23166 Author: Amine Khaldi <[email protected]> AuthorDate: Tue Jan 29 13:11:02 2019 +0100 Commit: Amine Khaldi <[email protected]> CommitDate: Tue Jan 29 13:11:02 2019 +0100 [MSXML3] Sync with Wine Staging 4.0. CORE-15682 --- dll/win32/msxml3/attribute.c | 18 +++++++++-- dll/win32/msxml3/domdoc.c | 19 ++++++++--- dll/win32/msxml3/element.c | 70 ++++++++++++++++++++++++++++++---------- dll/win32/msxml3/msxml_private.h | 3 +- dll/win32/msxml3/node.c | 2 +- media/doc/README.WINE | 2 +- 6 files changed, 88 insertions(+), 26 deletions(-) diff --git a/dll/win32/msxml3/attribute.c b/dll/win32/msxml3/attribute.c index 637615b341..c303969bc3 100644 --- a/dll/win32/msxml3/attribute.c +++ b/dll/win32/msxml3/attribute.c @@ -50,6 +50,7 @@ typedef struct _domattr xmlnode node; IXMLDOMAttribute IXMLDOMAttribute_iface; LONG ref; + BOOL floating; } domattr; static const tid_t domattr_se_tids[] = { @@ -116,6 +117,11 @@ static ULONG WINAPI domattr_Release( if ( ref == 0 ) { destroy_xmlnode(&This->node); + if ( This->floating ) + { + xmlFreeNs( This->node.node->ns ); + xmlFreeNode( This->node.node ); + } heap_free( This ); } @@ -543,6 +549,8 @@ static HRESULT WINAPI domattr_get_namespaceURI( IXMLDOMAttribute *iface, BSTR* p) { + static const WCHAR w3xmlns[] = { 'h','t','t','p',':','/','/', 'w','w','w','.','w','3','.', + 'o','r','g','/','2','0','0','0','/','x','m','l','n','s','/',0 }; domattr *This = impl_from_IXMLDOMAttribute( iface ); xmlNsPtr ns = This->node.node->ns; @@ -559,7 +567,12 @@ static HRESULT WINAPI domattr_get_namespaceURI( if (xmlStrEqual(This->node.node->name, xmlns)) *p = bstr_from_xmlChar(xmlns); else if (xmlStrEqual(ns->prefix, xmlns)) - *p = SysAllocStringLen(NULL, 0); + { + if (xmldoc_version(This->node.node->doc) == MSXML6) + *p = SysAllocString(w3xmlns); + else + *p = SysAllocStringLen(NULL, 0); + } else if (ns->href) *p = bstr_from_xmlChar(ns->href); } @@ -709,7 +722,7 @@ static dispex_static_data_t domattr_dispex = { domattr_iface_tids }; -IUnknown* create_attribute( xmlNodePtr attribute ) +IUnknown* create_attribute( xmlNodePtr attribute, BOOL floating ) { domattr *This; @@ -719,6 +732,7 @@ IUnknown* create_attribute( xmlNodePtr attribute ) This->IXMLDOMAttribute_iface.lpVtbl = &domattr_vtbl; This->ref = 1; + This->floating = floating; init_xmlnode(&This->node, attribute, (IXMLDOMNode*)&This->IXMLDOMAttribute_iface, &domattr_dispex); diff --git a/dll/win32/msxml3/domdoc.c b/dll/win32/msxml3/domdoc.c index ddd756582b..76d3fdb601 100644 --- a/dll/win32/msxml3/domdoc.c +++ b/dll/win32/msxml3/domdoc.c @@ -73,6 +73,7 @@ static const WCHAR PropValueXSLPatternW[] = {'X','S','L','P','a','t','t','e','r' static const WCHAR PropertyResolveExternalsW[] = {'R','e','s','o','l','v','e','E','x','t','e','r','n','a','l','s',0}; static const WCHAR PropertyAllowXsltScriptW[] = {'A','l','l','o','w','X','s','l','t','S','c','r','i','p','t',0}; static const WCHAR PropertyAllowDocumentFunctionW[] = {'A','l','l','o','w','D','o','c','u','m','e','n','t','F','u','n','c','t','i','o','n',0}; +static const WCHAR PropertyNormalizeAttributeValuesW[] = {'N','o','r','m','a','l','i','z','e','A','t','t','r','i','b','u','t','e','V','a','l','u','e','s',0}; /* Anything that passes the test_get_ownerDocument() * tests can go here (data shared between all instances). @@ -395,6 +396,11 @@ xmlNodePtr xmldoc_unlink_xmldecl(xmlDocPtr doc) return node; } +MSXML_VERSION xmldoc_version(xmlDocPtr doc) +{ + return properties_from_xmlDocPtr(doc)->version; +} + BOOL is_preserving_whitespace(xmlNodePtr node) { domdoc_properties* properties = NULL; @@ -2286,8 +2292,8 @@ static HRESULT WINAPI domdoc_load( if ( filename ) { + IUri *uri = NULL; IMoniker *mon; - IUri *uri; if (This->properties->uri) { @@ -2304,15 +2310,19 @@ static HRESULT WINAPI domdoc_load( IMoniker_Release(mon); } - if ( FAILED(hr) ) - This->error = E_FAIL; - else + if (SUCCEEDED(hr)) { get_doc(This)->name = (char *)xmlchar_from_wcharn(filename, -1, TRUE); This->properties->uri = uri; hr = This->error = S_OK; *isSuccessful = VARIANT_TRUE; } + else + { + if (uri) + IUri_Release(uri); + This->error = E_FAIL; + } } if(!filename || FAILED(hr)) { @@ -3108,6 +3118,7 @@ static HRESULT WINAPI domdoc_setProperty( lstrcmpiW(p, PropertyNewParserW) == 0 || lstrcmpiW(p, PropertyResolveExternalsW) == 0 || lstrcmpiW(p, PropertyAllowXsltScriptW) == 0 || + lstrcmpiW(p, PropertyNormalizeAttributeValuesW) == 0 || lstrcmpiW(p, PropertyAllowDocumentFunctionW) == 0) { /* Ignore */ diff --git a/dll/win32/msxml3/element.c b/dll/win32/msxml3/element.c index 6e00aa0116..0ff26e4fb7 100644 --- a/dll/win32/msxml3/element.c +++ b/dll/win32/msxml3/element.c @@ -1398,7 +1398,7 @@ static HRESULT WINAPI domelem_getAttributeNode( if (attr) { - IUnknown *unk = create_attribute((xmlNodePtr)attr); + IUnknown *unk = create_attribute((xmlNodePtr)attr, FALSE); hr = IUnknown_QueryInterface(unk, &IID_IXMLDOMAttribute, (void**)attributeNode); IUnknown_Release(unk); } @@ -1754,8 +1754,11 @@ static HRESULT domelem_remove_named_item(xmlNodePtr node, BSTR name, IXMLDOMNode static HRESULT domelem_get_item(const xmlNodePtr node, LONG index, IXMLDOMNode **item) { + xmlNsPtr ns, xmlns; xmlAttrPtr curr; LONG attrIndex; + IUnknown *unk; + HRESULT hr; TRACE("(%p)->(%d %p)\n", node, index, item); @@ -1764,42 +1767,75 @@ static HRESULT domelem_get_item(const xmlNodePtr node, LONG index, IXMLDOMNode * if (index < 0) return S_FALSE; + attrIndex = 0; curr = node->properties; - - for (attrIndex = 0; attrIndex < index; attrIndex++) { - if (curr->next == NULL) - return S_FALSE; - else + if (curr) { + for (; attrIndex < index && curr->next != NULL; attrIndex++) curr = curr->next; + + if (attrIndex == index) { + *item = create_node( (xmlNodePtr) curr ); + return S_OK; + } } - *item = create_node( (xmlNodePtr) curr ); + if (!node->nsDef) + return S_FALSE; - return S_OK; + attrIndex++; + ns = node->nsDef; + for (; attrIndex < index && ns->next != NULL; attrIndex++) + ns = ns->next; + + if (attrIndex < index) + return S_FALSE; + + xmlns = xmlNewNs(NULL, BAD_CAST "http://www.w3.org/2000/xmlns/", BAD_CAST "xmlns"); + if (!xmlns) + return E_OUTOFMEMORY; + + curr = xmlNewNsProp(NULL, xmlns, ns->prefix, ns->href); + if (!curr) { + xmlFreeNs(xmlns); + return E_OUTOFMEMORY; + } + curr->doc = node->doc; + + unk = create_attribute((xmlNodePtr)curr, TRUE); + if (!unk) { + xmlFreeNs(xmlns); + xmlFreeProp(curr); + return E_OUTOFMEMORY; + } + + hr = IUnknown_QueryInterface(unk, &IID_IXMLDOMNode, (void**)item); + IUnknown_Release(unk); + + return hr; } static HRESULT domelem_get_length(const xmlNodePtr node, LONG *length) { - xmlAttrPtr first; xmlAttrPtr curr; LONG attrCount; + xmlNsPtr ns; TRACE("(%p)->(%p)\n", node, length); if( !length ) return E_INVALIDARG; - first = node->properties; - if (first == NULL) { - *length = 0; - return S_OK; + attrCount = 0; + curr = node->properties; + while (curr) { + attrCount++; + curr = curr->next; } - curr = first; - attrCount = 1; - while (curr->next) { + ns = node->nsDef; + while (ns) { attrCount++; - curr = curr->next; + ns = ns->next; } *length = attrCount; diff --git a/dll/win32/msxml3/msxml_private.h b/dll/win32/msxml3/msxml_private.h index 94ef66b23d..08f944ab1b 100644 --- a/dll/win32/msxml3/msxml_private.h +++ b/dll/win32/msxml3/msxml_private.h @@ -252,7 +252,7 @@ extern IUnknown *create_domdoc( xmlNodePtr ) DECLSPEC_HIDDEN; extern IUnknown *create_xmldoc( void ) DECLSPEC_HIDDEN; extern IXMLDOMNode *create_node( xmlNodePtr ) DECLSPEC_HIDDEN; extern IUnknown *create_element( xmlNodePtr ) DECLSPEC_HIDDEN; -extern IUnknown *create_attribute( xmlNodePtr ) DECLSPEC_HIDDEN; +extern IUnknown *create_attribute( xmlNodePtr, BOOL ) DECLSPEC_HIDDEN; extern IUnknown *create_text( xmlNodePtr ) DECLSPEC_HIDDEN; extern IUnknown *create_pi( xmlNodePtr ) DECLSPEC_HIDDEN; extern IUnknown *create_comment( xmlNodePtr ) DECLSPEC_HIDDEN; @@ -284,6 +284,7 @@ extern HRESULT xmldoc_add_orphan( xmlDocPtr doc, xmlNodePtr node ) DECLSPEC_HIDD extern HRESULT xmldoc_remove_orphan( xmlDocPtr doc, xmlNodePtr node ) DECLSPEC_HIDDEN; extern void xmldoc_link_xmldecl(xmlDocPtr doc, xmlNodePtr node) DECLSPEC_HIDDEN; extern xmlNodePtr xmldoc_unlink_xmldecl(xmlDocPtr doc) DECLSPEC_HIDDEN; +extern MSXML_VERSION xmldoc_version( xmlDocPtr doc ) DECLSPEC_HIDDEN; extern HRESULT XMLElement_create( xmlNodePtr node, LPVOID *ppObj, BOOL own ) DECLSPEC_HIDDEN; diff --git a/dll/win32/msxml3/node.c b/dll/win32/msxml3/node.c index bcb4181374..fc18935b69 100644 --- a/dll/win32/msxml3/node.c +++ b/dll/win32/msxml3/node.c @@ -2271,7 +2271,7 @@ IXMLDOMNode *create_node( xmlNodePtr node ) pUnk = create_element( node ); break; case XML_ATTRIBUTE_NODE: - pUnk = create_attribute( node ); + pUnk = create_attribute( node, FALSE ); break; case XML_TEXT_NODE: pUnk = create_text( node ); diff --git a/media/doc/README.WINE b/media/doc/README.WINE index 2946ca0ac1..0fb8d24785 100644 --- a/media/doc/README.WINE +++ b/media/doc/README.WINE @@ -129,7 +129,7 @@ reactos/dll/win32/msvfw32 # Synced to WineStaging-4.0 reactos/dll/win32/msvidc32 # Synced to WineStaging-4.0 reactos/dll/win32/msxml # Synced to WineStaging-3.3 reactos/dll/win32/msxml2 # Synced to WineStaging-3.3 -reactos/dll/win32/msxml3 # Synced to WineStaging-3.3 +reactos/dll/win32/msxml3 # Synced to WineStaging-4.0 reactos/dll/win32/msxml4 # Synced to WineStaging-3.3 reactos/dll/win32/msxml6 # Synced to WineStaging-3.3 reactos/dll/win32/nddeapi # Synced to WineStaging-3.3
