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

mshtml: Moved whole element initialization to HTMLElement_Init.

parent cc94a1db
......@@ -518,7 +518,7 @@ static dispex_static_data_t HTMLAnchorElement_dispex = {
HTMLAnchorElement_iface_tids
};
HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLAnchorElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLAnchorElement *ret = heap_alloc_zero(sizeof(HTMLAnchorElement));
nsresult nsres;
......@@ -526,7 +526,7 @@ HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement *nselem)
ret->lpHTMLAnchorElementVtbl = &HTMLAnchorElementVtbl;
ret->element.node.vtbl = &HTMLAnchorElementImplVtbl;
HTMLElement_Init(&ret->element, &HTMLAnchorElement_dispex);
HTMLElement_Init(&ret->element, doc, nselem, &HTMLAnchorElement_dispex);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLAnchorElement, (void**)&ret->nsanchor);
if(NS_FAILED(nsres))
......
......@@ -759,7 +759,7 @@ static dispex_static_data_t HTMLBodyElement_dispex = {
HTMLBodyElement_iface_tids
};
HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLBodyElement *ret = heap_alloc_zero(sizeof(HTMLBodyElement));
nsresult nsres;
......@@ -769,7 +769,7 @@ HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement *nselem)
ret->lpHTMLBodyElementVtbl = &HTMLBodyElementVtbl;
ret->textcont.element.node.vtbl = &HTMLBodyElementImplVtbl;
HTMLTextContainer_Init(&ret->textcont, &HTMLBodyElement_dispex);
HTMLTextContainer_Init(&ret->textcont, doc, nselem, &HTMLBodyElement_dispex);
ConnectionPoint_Init(&ret->cp_propnotif, &ret->textcont.element.cp_container, &IID_IPropertyNotifySink);
......
......@@ -193,8 +193,10 @@ HTMLElement *HTMLCommentElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode
ret->element.node.vtbl = &HTMLCommentElementImplVtbl;
ret->lpIHTMLCommentElementVtbl = &HTMLCommentElementVtbl;
HTMLElement_Init(&ret->element, &HTMLCommentElement_dispex);
HTMLDOMNode_Init(doc, &ret->element.node, nsnode);
HTMLElement_Init(&ret->element, doc, NULL, &HTMLCommentElement_dispex);
nsIDOMNode_AddRef(nsnode);
ret->element.node.nsnode = nsnode;
return &ret->element;
}
......@@ -1489,16 +1489,22 @@ static dispex_static_data_t HTMLElement_dispex = {
HTMLElement_iface_tids
};
void HTMLElement_Init(HTMLElement *This, dispex_static_data_t *dispex_data)
void HTMLElement_Init(HTMLElement *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, dispex_static_data_t *dispex_data)
{
This->lpHTMLElementVtbl = &HTMLElementVtbl;
ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)HTMLELEM(This));
HTMLElement2_Init(This);
HTMLElement3_Init(This);
init_dispex(&This->node.dispex, (IUnknown*)HTMLELEM(This), dispex_data ? dispex_data : &HTMLElement_dispex);
if(nselem)
nsIDOMHTMLElement_AddRef(nselem);
This->nselem = nselem;
HTMLDOMNode_Init(doc, &This->node, (nsIDOMNode*)nselem);
ConnectionPointContainer_Init(&This->cp_container, (IUnknown*)HTMLELEM(This));
}
HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL use_generic)
......@@ -1531,42 +1537,40 @@ HTMLElement *HTMLElement_Create(HTMLDocumentNode *doc, nsIDOMNode *nsnode, BOOL
nsAString_GetData(&class_name_str, &class_name);
if(!strcmpW(class_name, wszA))
ret = HTMLAnchorElement_Create(nselem);
ret = HTMLAnchorElement_Create(doc, nselem);
else if(!strcmpW(class_name, wszBODY))
ret = HTMLBodyElement_Create(nselem);
ret = HTMLBodyElement_Create(doc, nselem);
else if(!strcmpW(class_name, wszIFRAME))
ret = HTMLIFrame_Create(nselem);
ret = HTMLIFrame_Create(doc, nselem);
else if(!strcmpW(class_name, wszIMG))
ret = HTMLImgElement_Create(nselem);
ret = HTMLImgElement_Create(doc, nselem);
else if(!strcmpW(class_name, wszINPUT))
ret = HTMLInputElement_Create(nselem);
ret = HTMLInputElement_Create(doc, nselem);
else if(!strcmpW(class_name, wszOPTION))
ret = HTMLOptionElement_Create(nselem);
ret = HTMLOptionElement_Create(doc, nselem);
else if(!strcmpW(class_name, wszSCRIPT))
ret = HTMLScriptElement_Create(nselem);
ret = HTMLScriptElement_Create(doc, nselem);
else if(!strcmpW(class_name, wszSELECT))
ret = HTMLSelectElement_Create(nselem);
ret = HTMLSelectElement_Create(doc, nselem);
else if(!strcmpW(class_name, wszTABLE))
ret = HTMLTable_Create(nselem);
ret = HTMLTable_Create(doc, nselem);
else if(!strcmpW(class_name, wszTR))
ret = HTMLTableRow_Create(nselem);
ret = HTMLTableRow_Create(doc, nselem);
else if(!strcmpW(class_name, wszTEXTAREA))
ret = HTMLTextAreaElement_Create(nselem);
ret = HTMLTextAreaElement_Create(doc, nselem);
else if(use_generic)
ret = HTMLGenericElement_Create(nselem);
ret = HTMLGenericElement_Create(doc, nselem);
if(!ret) {
ret = heap_alloc_zero(sizeof(HTMLElement));
HTMLElement_Init(ret, NULL);
HTMLElement_Init(ret, doc, nselem, NULL);
ret->node.vtbl = &HTMLElementImplVtbl;
}
TRACE("%s ret %p\n", debugstr_w(class_name), ret);
nsIDOMElement_Release(nselem);
nsAString_Finish(&class_name_str);
ret->nselem = nselem;
HTMLDOMNode_Init(doc, &ret->node, (nsIDOMNode*)nselem);
return ret;
}
......@@ -169,7 +169,7 @@ static dispex_static_data_t HTMLGenericElement_dispex = {
HTMLGenericElement_iface_tids
};
HTMLElement *HTMLGenericElement_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLGenericElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLGenericElement *ret;
......@@ -178,7 +178,7 @@ HTMLElement *HTMLGenericElement_Create(nsIDOMHTMLElement *nselem)
ret->lpHTMLGenericElementVtbl = &HTMLGenericElementVtbl;
ret->element.node.vtbl = &HTMLGenericElementImplVtbl;
HTMLElement_Init(&ret->element, &HTMLGenericElement_dispex);
HTMLElement_Init(&ret->element, doc, nselem, &HTMLGenericElement_dispex);
return &ret->element;
}
......@@ -481,7 +481,7 @@ static dispex_static_data_t HTMLIFrame_dispex = {
HTMLIFrame_iface_tids
};
HTMLElement *HTMLIFrame_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLIFrame_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLIFrame *ret;
nsresult nsres;
......@@ -492,7 +492,7 @@ HTMLElement *HTMLIFrame_Create(nsIDOMHTMLElement *nselem)
ret->lpIHTMLFrameBase2Vtbl = &HTMLIFrameBase2Vtbl;
ret->element.node.vtbl = &HTMLIFrameImplVtbl;
HTMLElement_Init(&ret->element, &HTMLIFrame_dispex);
HTMLElement_Init(&ret->element, doc, nselem, &HTMLIFrame_dispex);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLIFrameElement, (void**)&ret->nsiframe);
if(NS_FAILED(nsres))
......
......@@ -595,7 +595,7 @@ static dispex_static_data_t HTMLImgElement_dispex = {
HTMLImgElement_iface_tids
};
HTMLElement *HTMLImgElement_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLImgElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLImgElement *ret = heap_alloc_zero(sizeof(HTMLImgElement));
nsresult nsres;
......@@ -607,7 +607,7 @@ HTMLElement *HTMLImgElement_Create(nsIDOMHTMLElement *nselem)
if(NS_FAILED(nsres))
ERR("Could not get nsIDOMHTMLImageElement: %08x\n", nsres);
HTMLElement_Init(&ret->element, &HTMLImgElement_dispex);
HTMLElement_Init(&ret->element, doc, nselem, &HTMLImgElement_dispex);
return &ret->element;
}
......
......@@ -1188,7 +1188,7 @@ static dispex_static_data_t HTMLInputElement_dispex = {
HTMLInputElement_iface_tids
};
HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLInputElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLInputElement *ret = heap_alloc_zero(sizeof(HTMLInputElement));
nsresult nsres;
......@@ -1197,7 +1197,7 @@ HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement *nselem)
ret->lpHTMLInputTextElementVtbl = &HTMLInputTextElementVtbl;
ret->element.node.vtbl = &HTMLInputElementImplVtbl;
HTMLElement_Init(&ret->element, &HTMLInputElement_dispex);
HTMLElement_Init(&ret->element, doc, nselem, &HTMLInputElement_dispex);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLInputElement,
(void**)&ret->nsinput);
......
......@@ -911,7 +911,8 @@ void HTMLDOMNode_Init(HTMLDocumentNode *doc, HTMLDOMNode *node, nsIDOMNode *nsno
node->ref = 1;
node->doc = doc;
nsIDOMNode_AddRef(nsnode);
if(nsnode)
nsIDOMNode_AddRef(nsnode);
node->nsnode = nsnode;
node->next = doc->nodes;
......
......@@ -339,7 +339,7 @@ static dispex_static_data_t HTMLOptionElement_dispex = {
HTMLOptionElement_iface_tids
};
HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLOptionElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLOptionElement *ret = heap_alloc_zero(sizeof(HTMLOptionElement));
nsresult nsres;
......@@ -347,7 +347,7 @@ HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement *nselem)
ret->lpHTMLOptionElementVtbl = &HTMLOptionElementVtbl;
ret->element.node.vtbl = &HTMLOptionElementImplVtbl;
HTMLElement_Init(&ret->element, &HTMLOptionElement_dispex);
HTMLElement_Init(&ret->element, doc, nselem, &HTMLOptionElement_dispex);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLOptionElement, (void**)&ret->nsoption);
if(NS_FAILED(nsres))
......
......@@ -306,7 +306,7 @@ static const NodeImplVtbl HTMLScriptElementImplVtbl = {
HTMLScriptElement_destructor
};
HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLScriptElement *ret = heap_alloc_zero(sizeof(HTMLScriptElement));
nsresult nsres;
......@@ -314,7 +314,7 @@ HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement *nselem)
ret->lpHTMLScriptElementVtbl = &HTMLScriptElementVtbl;
ret->element.node.vtbl = &HTMLScriptElementImplVtbl;
HTMLElement_Init(&ret->element, NULL);
HTMLElement_Init(&ret->element, doc, nselem, NULL);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLScriptElement, (void**)&ret->nsscript);
if(NS_FAILED(nsres))
......
......@@ -503,7 +503,7 @@ static dispex_static_data_t HTMLSelectElement_dispex = {
HTMLSelectElement_tids
};
HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLSelectElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLSelectElement *ret = heap_alloc_zero(sizeof(HTMLSelectElement));
nsresult nsres;
......@@ -511,7 +511,7 @@ HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement *nselem)
ret->lpHTMLSelectElementVtbl = &HTMLSelectElementVtbl;
ret->element.node.vtbl = &HTMLSelectElementImplVtbl;
HTMLElement_Init(&ret->element, &HTMLSelectElement_dispex);
HTMLElement_Init(&ret->element, doc, nselem, &HTMLSelectElement_dispex);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLSelectElement,
(void**)&ret->nsselect);
......
......@@ -574,7 +574,7 @@ static dispex_static_data_t HTMLTable_dispex = {
HTMLTable_iface_tids
};
HTMLElement *HTMLTable_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLTable_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLTable *ret = heap_alloc_zero(sizeof(HTMLTable));
nsresult nsres;
......@@ -582,7 +582,7 @@ HTMLElement *HTMLTable_Create(nsIDOMHTMLElement *nselem)
ret->element.node.vtbl = &HTMLTableImplVtbl;
ret->lpHTMLTableVtbl = &HTMLTableVtbl;
HTMLElement_Init(&ret->element, &HTMLTable_dispex);
HTMLElement_Init(&ret->element, doc, nselem, &HTMLTable_dispex);
ConnectionPoint_Init(&ret->cp, &ret->element.cp_container, &DIID_HTMLTableEvents);
......
......@@ -317,7 +317,7 @@ static dispex_static_data_t HTMLTableRow_dispex = {
HTMLTableRow_iface_tids
};
HTMLElement *HTMLTableRow_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLTableRow_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLTableRow *ret = heap_alloc_zero(sizeof(HTMLTableRow));
nsresult nsres;
......@@ -325,7 +325,7 @@ HTMLElement *HTMLTableRow_Create(nsIDOMHTMLElement *nselem)
ret->lpHTMLTableRowVtbl = &HTMLTableRowVtbl;
ret->element.node.vtbl = &HTMLTableRowImplVtbl;
HTMLElement_Init(&ret->element, &HTMLTableRow_dispex);
HTMLElement_Init(&ret->element, doc, nselem, &HTMLTableRow_dispex);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTableRowElement, (void**)&ret->nsrow);
if(NS_FAILED(nsres))
......
......@@ -411,7 +411,7 @@ static const NodeImplVtbl HTMLTextAreaElementImplVtbl = {
HTMLTextAreaElementImpl_get_disabled
};
HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement *nselem)
HTMLElement *HTMLTextAreaElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem)
{
HTMLTextAreaElement *ret = heap_alloc_zero(sizeof(HTMLTextAreaElement));
nsresult nsres;
......@@ -419,7 +419,7 @@ HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement *nselem)
ret->lpHTMLTextAreaElementVtbl = &HTMLTextAreaElementVtbl;
ret->element.node.vtbl = &HTMLTextAreaElementImplVtbl;
HTMLElement_Init(&ret->element, NULL);
HTMLElement_Init(&ret->element, doc, nselem, NULL);
nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLTextAreaElement,
(void**)&ret->nstextarea);
......
......@@ -182,11 +182,12 @@ static const IHTMLTextContainerVtbl HTMLTextContainerVtbl = {
HTMLTextContainer_get_onscroll
};
void HTMLTextContainer_Init(HTMLTextContainer *This, dispex_static_data_t *dispex_data)
void HTMLTextContainer_Init(HTMLTextContainer *This, HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem,
dispex_static_data_t *dispex_data)
{
This->lpHTMLTextContainerVtbl = &HTMLTextContainerVtbl;
HTMLElement_Init(&This->element, dispex_data);
HTMLElement_Init(&This->element, doc, nselem, dispex_data);
ConnectionPoint_Init(&This->cp, &This->element.cp_container, &DIID_HTMLTextContainerEvents);
}
......@@ -684,24 +684,24 @@ HTMLDOMNode *HTMLDOMTextNode_Create(HTMLDocumentNode*,nsIDOMNode*);
HTMLElement *HTMLElement_Create(HTMLDocumentNode*,nsIDOMNode*,BOOL);
HTMLElement *HTMLCommentElement_Create(HTMLDocumentNode*,nsIDOMNode*);
HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLIFrame_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLImgElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLOptionElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLScriptElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLTable_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLTableRow_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLGenericElement_Create(nsIDOMHTMLElement*);
HTMLElement *HTMLAnchorElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
HTMLElement *HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
HTMLElement *HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
HTMLElement *HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
HTMLElement *HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
HTMLElement *HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
HTMLElement *HTMLScriptElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
HTMLElement *HTMLSelectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
HTMLElement *HTMLTable_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
HTMLElement *HTMLTableRow_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
HTMLElement *HTMLTextAreaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
HTMLElement *HTMLGenericElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*);
void HTMLDOMNode_Init(HTMLDocumentNode*,HTMLDOMNode*,nsIDOMNode*);
void HTMLElement_Init(HTMLElement*,dispex_static_data_t*);
void HTMLElement_Init(HTMLElement*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
void HTMLElement2_Init(HTMLElement*);
void HTMLElement3_Init(HTMLElement*);
void HTMLTextContainer_Init(HTMLTextContainer*,dispex_static_data_t*);
void HTMLTextContainer_Init(HTMLTextContainer*,HTMLDocumentNode*,nsIDOMHTMLElement*,dispex_static_data_t*);
HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
void HTMLDOMNode_destructor(HTMLDOMNode*);
......
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