Commit f185dd51 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

xmllite: Store empty element fields separately.

parent a39251b0
...@@ -253,7 +253,8 @@ typedef struct ...@@ -253,7 +253,8 @@ typedef struct
strval strvalues[StringValue_Last]; strval strvalues[StringValue_Last];
UINT depth; UINT depth;
UINT max_depth; UINT max_depth;
BOOL empty_element; BOOL is_empty_element;
struct element empty_element;
UINT resume[XmlReadResume_Last]; /* offsets used to resume reader */ UINT resume[XmlReadResume_Last]; /* offsets used to resume reader */
} xmlreader; } xmlreader;
...@@ -433,7 +434,7 @@ static void reader_clear_elements(xmlreader *reader) ...@@ -433,7 +434,7 @@ static void reader_clear_elements(xmlreader *reader)
reader_free(reader, elem); reader_free(reader, elem);
} }
list_init(&reader->elements); list_init(&reader->elements);
reader->empty_element = FALSE; reader->is_empty_element = FALSE;
} }
static HRESULT reader_inc_depth(xmlreader *reader) static HRESULT reader_inc_depth(xmlreader *reader)
...@@ -479,7 +480,7 @@ static HRESULT reader_push_element(xmlreader *reader, strval *qname, strval *loc ...@@ -479,7 +480,7 @@ static HRESULT reader_push_element(xmlreader *reader, strval *qname, strval *loc
} }
list_add_head(&reader->elements, &elem->entry); list_add_head(&reader->elements, &elem->entry);
reader->empty_element = FALSE; reader->is_empty_element = FALSE;
return hr; return hr;
} }
...@@ -2075,7 +2076,9 @@ static HRESULT reader_parse_stag(xmlreader *reader, strval *prefix, strval *loca ...@@ -2075,7 +2076,9 @@ static HRESULT reader_parse_stag(xmlreader *reader, strval *prefix, strval *loca
{ {
/* skip '/>' */ /* skip '/>' */
reader_skipn(reader, 2); reader_skipn(reader, 2);
reader->empty_element = TRUE; reader->is_empty_element = TRUE;
reader->empty_element.localname = *local;
reader->empty_element.qname = *qname;
return S_OK; return S_OK;
} }
...@@ -2707,7 +2710,6 @@ static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface, ...@@ -2707,7 +2710,6 @@ static HRESULT WINAPI xmlreader_MoveToAttributeByName(IXmlReader* iface,
static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface) static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface)
{ {
xmlreader *This = impl_from_IXmlReader(iface); xmlreader *This = impl_from_IXmlReader(iface);
struct element *elem;
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
...@@ -2715,11 +2717,16 @@ static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface) ...@@ -2715,11 +2717,16 @@ static HRESULT WINAPI xmlreader_MoveToElement(IXmlReader* iface)
This->attr = NULL; This->attr = NULL;
/* FIXME: support other node types with 'attributes' like DTD */ /* FIXME: support other node types with 'attributes' like DTD */
elem = LIST_ENTRY(list_head(&This->elements), struct element, entry); if (This->is_empty_element) {
if (elem) reader_set_strvalue(This, StringValue_LocalName, &This->empty_element.localname);
{ reader_set_strvalue(This, StringValue_QualifiedName, &This->empty_element.qname);
reader_set_strvalue(This, StringValue_QualifiedName, &elem->qname); }
reader_set_strvalue(This, StringValue_LocalName, &elem->localname); else {
struct element *element = LIST_ENTRY(list_head(&This->elements), struct element, entry);
if (element) {
reader_set_strvalue(This, StringValue_LocalName, &element->localname);
reader_set_strvalue(This, StringValue_QualifiedName, &element->qname);
}
} }
return S_OK; return S_OK;
...@@ -2841,7 +2848,7 @@ static BOOL WINAPI xmlreader_IsEmptyElement(IXmlReader* iface) ...@@ -2841,7 +2848,7 @@ static BOOL WINAPI xmlreader_IsEmptyElement(IXmlReader* iface)
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
/* Empty elements are not placed in stack, it's stored as a global reader flag that makes sense /* Empty elements are not placed in stack, it's stored as a global reader flag that makes sense
when current node is start tag of an element */ when current node is start tag of an element */
return (reader_get_nodetype(This) == XmlNodeType_Element) ? This->empty_element : FALSE; return (reader_get_nodetype(This) == XmlNodeType_Element) ? This->is_empty_element : FALSE;
} }
static HRESULT WINAPI xmlreader_GetLineNumber(IXmlReader* iface, UINT *lineNumber) static HRESULT WINAPI xmlreader_GetLineNumber(IXmlReader* iface, UINT *lineNumber)
...@@ -3024,7 +3031,7 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc) ...@@ -3024,7 +3031,7 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc)
list_init(&reader->elements); list_init(&reader->elements);
reader->depth = 0; reader->depth = 0;
reader->max_depth = 256; reader->max_depth = 256;
reader->empty_element = FALSE; reader->is_empty_element = FALSE;
memset(reader->resume, 0, sizeof(reader->resume)); memset(reader->resume, 0, sizeof(reader->resume));
for (i = 0; i < StringValue_Last; i++) for (i = 0; i < StringValue_Last; i++)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment