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

mshtml: Store HTMLElement struct instead of pointer in HTMLBodyElement.

parent f68e24a6
...@@ -36,6 +36,8 @@ ...@@ -36,6 +36,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(mshtml); WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
typedef struct { typedef struct {
HTMLElement element;
const IHTMLBodyElementVtbl *lpHTMLBodyElementVtbl; const IHTMLBodyElementVtbl *lpHTMLBodyElementVtbl;
HTMLTextContainer text_container; HTMLTextContainer text_container;
...@@ -44,7 +46,6 @@ typedef struct { ...@@ -44,7 +46,6 @@ typedef struct {
ConnectionPoint cp_propnotif; ConnectionPoint cp_propnotif;
ConnectionPoint cp_txtcontevents; ConnectionPoint cp_txtcontevents;
HTMLElement *element;
nsIDOMHTMLBodyElement *nsbody; nsIDOMHTMLBodyElement *nsbody;
} HTMLBodyElement; } HTMLBodyElement;
...@@ -82,7 +83,7 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface, ...@@ -82,7 +83,7 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
return S_OK; return S_OK;
} }
hres = HTMLElement_QI(This->element, riid, ppv); hres = HTMLElement_QI(&This->element, riid, ppv);
if(FAILED(hres)) if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
...@@ -95,7 +96,7 @@ static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface) ...@@ -95,7 +96,7 @@ static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
return IHTMLDocument2_AddRef(HTMLDOC(This->element->node.doc)); return IHTMLDocument2_AddRef(HTMLDOC(This->element.node.doc));
} }
static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface) static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
...@@ -104,7 +105,7 @@ static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface) ...@@ -104,7 +105,7 @@ static ULONG WINAPI HTMLBodyElement_Release(IHTMLBodyElement *iface)
TRACE("(%p)\n", This); TRACE("(%p)\n", This);
return IHTMLDocument2_Release(HTMLDOC(This->element->node.doc)); return IHTMLDocument2_Release(HTMLDOC(This->element.node.doc));
} }
static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo) static HRESULT WINAPI HTMLBodyElement_GetTypeInfoCount(IHTMLBodyElement *iface, UINT *pctinfo)
...@@ -406,18 +407,18 @@ static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, I ...@@ -406,18 +407,18 @@ static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, I
TRACE("(%p)->(%p)\n", This, range); TRACE("(%p)->(%p)\n", This, range);
if(This->element->node.doc->nscontainer) { if(This->element.node.doc->nscontainer) {
nsIDOMDocument *nsdoc; nsIDOMDocument *nsdoc;
nsIDOMDocumentRange *nsdocrange; nsIDOMDocumentRange *nsdocrange;
nsresult nsres; nsresult nsres;
nsIWebNavigation_GetDocument(This->element->node.doc->nscontainer->navigation, &nsdoc); nsIWebNavigation_GetDocument(This->element.node.doc->nscontainer->navigation, &nsdoc);
nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange); nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMDocumentRange, (void**)&nsdocrange);
nsIDOMDocument_Release(nsdoc); nsIDOMDocument_Release(nsdoc);
nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &nsrange); nsres = nsIDOMDocumentRange_CreateRange(nsdocrange, &nsrange);
if(NS_SUCCEEDED(nsres)) { if(NS_SUCCEEDED(nsres)) {
nsres = nsIDOMRange_SelectNodeContents(nsrange, This->element->node.nsnode); nsres = nsIDOMRange_SelectNodeContents(nsrange, This->element.node.nsnode);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres))
ERR("SelectNodeContents failed: %08x\n", nsres); ERR("SelectNodeContents failed: %08x\n", nsres);
}else { }else {
...@@ -427,7 +428,7 @@ static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, I ...@@ -427,7 +428,7 @@ static HRESULT WINAPI HTMLBodyElement_createTextRange(IHTMLBodyElement *iface, I
nsIDOMDocumentRange_Release(nsdocrange); nsIDOMDocumentRange_Release(nsdocrange);
} }
*range = HTMLTxtRange_Create(This->element->node.doc, nsrange); *range = HTMLTxtRange_Create(This->element.node.doc, nsrange);
return S_OK; return S_OK;
} }
...@@ -485,15 +486,14 @@ static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = { ...@@ -485,15 +486,14 @@ static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
HTMLBodyElement_createTextRange HTMLBodyElement_createTextRange
}; };
void HTMLBodyElement_Create(HTMLElement *element) HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement *nselem)
{ {
HTMLBodyElement *ret = mshtml_alloc(sizeof(HTMLBodyElement)); HTMLBodyElement *ret = mshtml_alloc(sizeof(HTMLBodyElement));
nsresult nsres; nsresult nsres;
ret->lpHTMLBodyElementVtbl = &HTMLBodyElementVtbl; ret->lpHTMLBodyElementVtbl = &HTMLBodyElementVtbl;
ret->element = element;
HTMLTextContainer_Init(&ret->text_container, element); HTMLTextContainer_Init(&ret->text_container, &ret->element);
ConnectionPoint_Init(&ret->cp_propnotif, CONPTCONT(&ret->cp_container), ConnectionPoint_Init(&ret->cp_propnotif, CONPTCONT(&ret->cp_container),
&IID_IPropertyNotifySink, NULL); &IID_IPropertyNotifySink, NULL);
...@@ -501,11 +501,13 @@ void HTMLBodyElement_Create(HTMLElement *element) ...@@ -501,11 +501,13 @@ void HTMLBodyElement_Create(HTMLElement *element)
&DIID_HTMLTextContainerEvents, &ret->cp_propnotif); &DIID_HTMLTextContainerEvents, &ret->cp_propnotif);
ConnectionPointContainer_Init(&ret->cp_container, &ret->cp_propnotif, (IUnknown*)HTMLBODY(ret)); ConnectionPointContainer_Init(&ret->cp_container, &ret->cp_propnotif, (IUnknown*)HTMLBODY(ret));
nsres = nsIDOMHTMLElement_QueryInterface(element->nselem, &IID_nsIDOMHTMLBodyElement, nsres = nsIDOMHTMLElement_QueryInterface(nselem, &IID_nsIDOMHTMLBodyElement,
(void**)&ret->nsbody); (void**)&ret->nsbody);
if(NS_FAILED(nsres)) if(NS_FAILED(nsres))
ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres); ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
element->impl = (IUnknown*)HTMLBODY(ret); ret->element.impl = (IUnknown*)HTMLBODY(ret);
element->destructor = HTMLBodyElement_destructor; ret->element.destructor = HTMLBodyElement_destructor;
return &ret->element;
} }
...@@ -1296,6 +1296,8 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode) ...@@ -1296,6 +1296,8 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode)
if(!strcmpW(class_name, wszA)) if(!strcmpW(class_name, wszA))
ret = HTMLAnchorElement_Create(nselem); ret = HTMLAnchorElement_Create(nselem);
else if(!strcmpW(class_name, wszBODY))
ret = HTMLBodyElement_Create(nselem);
else { else {
ret = mshtml_alloc(sizeof(HTMLElement)); ret = mshtml_alloc(sizeof(HTMLElement));
...@@ -1303,9 +1305,7 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode) ...@@ -1303,9 +1305,7 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode)
ret->destructor = NULL; ret->destructor = NULL;
ret->nselem = nselem; ret->nselem = nselem;
if(!strcmpW(class_name, wszBODY)) if(!strcmpW(class_name, wszINPUT))
HTMLBodyElement_Create(ret);
else if(!strcmpW(class_name, wszINPUT))
HTMLInputElement_Create(ret); HTMLInputElement_Create(ret);
else if(!strcmpW(class_name, wszSELECT)) else if(!strcmpW(class_name, wszSELECT))
HTMLSelectElement_Create(ret); HTMLSelectElement_Create(ret);
......
...@@ -417,7 +417,7 @@ void detach_ranges(HTMLDocument*); ...@@ -417,7 +417,7 @@ void detach_ranges(HTMLDocument*);
HTMLElement *HTMLElement_Create(nsIDOMNode*); HTMLElement *HTMLElement_Create(nsIDOMNode*);
HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*); HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement*);
void HTMLBodyElement_Create(HTMLElement*); HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement*);
void HTMLInputElement_Create(HTMLElement*); void HTMLInputElement_Create(HTMLElement*);
void HTMLSelectElement_Create(HTMLElement*); void HTMLSelectElement_Create(HTMLElement*);
void HTMLTextAreaElement_Create(HTMLElement*); void HTMLTextAreaElement_Create(HTMLElement*);
......
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