Commit fdf676ac authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Initialize node object from child node's constructors.

parent bb1190a8
......@@ -190,7 +190,7 @@ static dispex_static_data_t HTMLCommentElement_dispex = {
HTMLCommentElement_iface_tids
};
HTMLElement *HTMLCommentElement_Create(nsIDOMNode *nsnode)
HTMLElement *HTMLCommentElement_Create(HTMLDocument *doc, nsIDOMNode *nsnode)
{
HTMLCommentElement *ret = heap_alloc_zero(sizeof(*ret));
......@@ -199,6 +199,7 @@ HTMLElement *HTMLCommentElement_Create(nsIDOMNode *nsnode)
init_dispex(&ret->element.node.dispex, (IUnknown*)HTMLCOMMENT(ret), &HTMLCommentElement_dispex);
HTMLElement_Init(&ret->element);
HTMLDOMNode_Init(doc, &ret->element.node, nsnode);
return &ret->element;
}
......@@ -1388,7 +1388,7 @@ void HTMLElement_Init(HTMLElement *This)
init_dispex(&This->node.dispex, (IUnknown*)HTMLELEM(This), &HTMLElement_dispex);
}
HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode)
HTMLElement *HTMLElement_Create(HTMLDocument *doc, nsIDOMNode *nsnode)
{
nsIDOMHTMLElement *nselem;
HTMLElement *ret = NULL;
......@@ -1438,11 +1438,14 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode)
ret = heap_alloc_zero(sizeof(HTMLElement));
HTMLElement_Init(ret);
ret->node.vtbl = &HTMLElementImplVtbl;
}
}
TRACE("%s ret %p\n", debugstr_w(class_name), ret);
nsAString_Finish(&class_name_str);
ret->nselem = nselem;
HTMLDOMNode_Init(doc, &ret->node, (nsIDOMNode*)nselem);
return ret;
}
......
......@@ -705,6 +705,20 @@ static const NodeImplVtbl HTMLDOMNodeImplVtbl = {
HTMLDOMNode_destructor
};
void HTMLDOMNode_Init(HTMLDocument *doc, HTMLDOMNode *node, nsIDOMNode *nsnode)
{
node->lpHTMLDOMNodeVtbl = &HTMLDOMNodeVtbl;
node->lpHTMLDOMNode2Vtbl = &HTMLDOMNode2Vtbl;
node->ref = 1;
node->doc = doc;
nsIDOMNode_AddRef(nsnode);
node->nsnode = nsnode;
node->next = doc->nodes;
doc->nodes = node;
}
static HTMLDOMNode *create_node(HTMLDocument *doc, nsIDOMNode *nsnode)
{
HTMLDOMNode *ret;
......@@ -714,27 +728,20 @@ static HTMLDOMNode *create_node(HTMLDocument *doc, nsIDOMNode *nsnode)
switch(node_type) {
case ELEMENT_NODE:
ret = &HTMLElement_Create(nsnode)->node;
ret = &HTMLElement_Create(doc, nsnode)->node;
break;
case TEXT_NODE:
ret = HTMLDOMTextNode_Create(nsnode);
ret = HTMLDOMTextNode_Create(doc, nsnode);
break;
case COMMENT_NODE:
ret = &HTMLCommentElement_Create(nsnode)->node;
ret = &HTMLCommentElement_Create(doc, nsnode)->node;
break;
default:
ret = heap_alloc_zero(sizeof(HTMLDOMNode));
ret->vtbl = &HTMLDOMNodeImplVtbl;
HTMLDOMNode_Init(doc, ret, nsnode);
}
ret->lpHTMLDOMNodeVtbl = &HTMLDOMNodeVtbl;
ret->lpHTMLDOMNode2Vtbl = &HTMLDOMNode2Vtbl;
ret->ref = 1;
ret->doc = doc;
nsIDOMNode_AddRef(nsnode);
ret->nsnode = nsnode;
TRACE("type %d ret %p\n", node_type, ret);
return ret;
......@@ -748,7 +755,7 @@ static HTMLDOMNode *create_node(HTMLDocument *doc, nsIDOMNode *nsnode)
HTMLDOMNode *get_node(HTMLDocument *This, nsIDOMNode *nsnode, BOOL create)
{
HTMLDOMNode *iter = This->nodes, *ret;
HTMLDOMNode *iter = This->nodes;
while(iter) {
if(iter->nsnode == nsnode)
......@@ -759,12 +766,7 @@ HTMLDOMNode *get_node(HTMLDocument *This, nsIDOMNode *nsnode, BOOL create)
if(iter || !create)
return iter;
ret = create_node(This, nsnode);
ret->next = This->nodes;
This->nodes = ret;
return ret;
return create_node(This, nsnode);
}
void release_nodes(HTMLDocument *This)
......
......@@ -198,7 +198,7 @@ static dispex_static_data_t HTMLDOMTextNode_dispex = {
HTMLDOMTextNode_iface_tids
};
HTMLDOMNode *HTMLDOMTextNode_Create(nsIDOMNode *nsnode)
HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocument *doc, nsIDOMNode *nsnode)
{
HTMLDOMTextNode *ret ;
......@@ -207,6 +207,7 @@ HTMLDOMNode *HTMLDOMTextNode_Create(nsIDOMNode *nsnode)
ret->lpIHTMLDOMTextNodeVtbl = &HTMLDOMTextNodeVtbl;
init_dispex(&ret->node.dispex, (IUnknown*)HTMLTEXT(ret), &HTMLDOMTextNode_dispex);
HTMLDOMNode_Init(doc, &ret->node, nsnode);
return &ret->node;
}
......@@ -519,10 +519,10 @@ IHTMLStyleSheetsCollection *HTMLStyleSheetsCollection_Create(nsIDOMStyleSheetLis
void detach_selection(HTMLDocument*);
void detach_ranges(HTMLDocument*);
HTMLDOMNode *HTMLDOMTextNode_Create(nsIDOMNode*);
HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocument*,nsIDOMNode*);
HTMLElement *HTMLElement_Create(nsIDOMNode*);
HTMLElement *HTMLCommentElement_Create(nsIDOMNode*);
HTMLElement *HTMLElement_Create(HTMLDocument*,nsIDOMNode*);
HTMLElement *HTMLCommentElement_Create(HTMLDocument*,nsIDOMNode*);
HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLImgElement_Create(nsIDOMHTMLElement*);
......@@ -533,6 +533,7 @@ HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
void HTMLDOMNode_Init(HTMLDocument*,HTMLDOMNode*,nsIDOMNode*);
void HTMLElement_Init(HTMLElement*);
void HTMLElement2_Init(HTMLElement*);
void HTMLTextContainer_Init(HTMLTextContainer*);
......
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