From: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> --- dlls/msxml3/msxml_private.h | 2 ++ dlls/msxml3/node.c | 47 ++++++++++++++++++++++--------------- 2 files changed, 30 insertions(+), 19 deletions(-) diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h index c22362795dc..499c5d76404 100644 --- a/dlls/msxml3/msxml_private.h +++ b/dlls/msxml3/msxml_private.h @@ -193,6 +193,7 @@ enum domnode_flags DOMNODE_IGNORED_WS_AFTER_STARTTAG = 0x2, DOMNODE_IGNORED_WS = 0x4, DOMNODE_PARSED_VALUE = 0x8, + DOMNODE_NS_DECL = 0x10, }; typedef struct _select_ns_entry @@ -265,6 +266,7 @@ extern struct domnode *domnode_get_last_child(struct domnode *node); extern struct domnode *domnode_get_next_sibling(struct domnode *node); extern struct domnode *domnode_get_previous_sibling(struct domnode *node); extern HRESULT domnode_get_attribute(const struct domnode *node, const WCHAR *name, struct domnode **attr); +extern bool domnode_is_namespace_declaration(const struct domnode *node); extern HRESULT node_clone_domnode(struct domnode *, bool, struct domnode **); extern HRESULT parse_stream(ISequentialStream *stream, bool utf16, const struct domdoc_properties *properties, struct domnode **tree); diff --git a/dlls/msxml3/node.c b/dlls/msxml3/node.c index 31af086cfb8..81eaa35e3e8 100644 --- a/dlls/msxml3/node.c +++ b/dlls/msxml3/node.c @@ -1059,6 +1059,23 @@ HRESULT node_remove_attribute(struct domnode *node, const WCHAR *name, IXMLDOMNo return hr; } +static bool is_same_namespace_prefix(const struct domnode *node, const WCHAR *prefix) +{ + if (node->prefix) + return prefix && !wcscmp(node->prefix, prefix); + + return !prefix; +} + +static bool domnode_has_namespace_declaration_name(const struct domnode *node) +{ + if (!wcscmp(node->qname, L"xmlns")) + return true; + if (is_same_namespace_prefix(node, L"xmlns")) + return true; + return false; +} + HRESULT domnode_create(DOMNodeType type, const WCHAR *name, int name_len, const WCHAR *uri, int uri_len, struct domnode *owner, struct domnode **node) { @@ -1120,6 +1137,10 @@ HRESULT domnode_create(DOMNodeType type, const WCHAR *name, int name_len, const if (!wcscmp(object->name, L"xml")) object->flags |= DOMNODE_READONLY_VALUE; break; + case NODE_ATTRIBUTE: + if (domnode_has_namespace_declaration_name(object)) + object->flags |= DOMNODE_NS_DECL; + break; default: ; } @@ -1905,21 +1926,9 @@ static void node_dump_qualified_name(struct node_dump_context *context, struct d node_dump_append(context, node->qname, SysStringLen(node->qname)); } -static bool is_same_namespace_prefix(const struct domnode *node, const WCHAR *prefix) +bool domnode_is_namespace_declaration(const struct domnode *node) { - if (node->prefix) - return prefix && !wcscmp(node->prefix, prefix); - - return !prefix; -} - -static bool is_namespace_definition(struct domnode *node) -{ - if (!wcscmp(node->qname, L"xmlns")) - return true; - if (is_same_namespace_prefix(node, L"xmlns")) - return true; - return false; + return node->flags & DOMNODE_NS_DECL; } static bool is_namespace_defined(struct node_dump_context *context, struct domnode *node) @@ -1969,7 +1978,7 @@ static void node_dump_element_attributes(struct node_dump_context *context, stru /* Collect explicitly defined namespaces */ LIST_FOR_EACH_ENTRY(attr, &node->attributes, struct domnode, entry) { - if (is_namespace_definition(attr)) + if (domnode_is_namespace_declaration(attr)) { node_get_text(attr, &text); node_dump_push_namespace(context, node_dump_get_namespace_prefix(attr), text, true); @@ -1984,7 +1993,7 @@ static void node_dump_element_attributes(struct node_dump_context *context, stru LIST_FOR_EACH_ENTRY(attr, &node->attributes, struct domnode, entry) { - if (is_namespace_definition(attr)) + if (domnode_is_namespace_declaration(attr)) continue; if (!is_namespace_defined(context, attr)) @@ -3541,8 +3550,8 @@ HRESULT node_set_attribute_value(struct domnode *node, const WCHAR *name, const hr = node_put_data(attr, attr_value); VariantClear(&v); - /* Allow setting namespace definition node once. */ - if (attr && is_namespace_definition(attr)) + /* Allow setting namespace declaration node once. */ + if (attr && domnode_is_namespace_declaration(attr)) attr->flags |= DOMNODE_READONLY_VALUE; return hr; @@ -3839,7 +3848,7 @@ static HRESULT WINAPI parse_content_handler_startElement(ISAXContentHandler *ifa if (attr) { attr->flags |= DOMNODE_PARSED_VALUE; - if (is_namespace_definition(attr)) + if (domnode_is_namespace_declaration(attr)) attr->flags |= DOMNODE_READONLY_VALUE; } } -- GitLab https://gitlab.winehq.org/wine/wine/-/merge_requests/10938