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

mshtml: Move nodes' QueryInterface implementation to vtbl.

parent f9036c89
......@@ -49,31 +49,8 @@ static HRESULT WINAPI HTMLAnchorElement_QueryInterface(IHTMLAnchorElement *iface
REFIID riid, void **ppv)
{
HTMLAnchorElement *This = HTMLANCHOR_THIS(iface);
HRESULT hres;
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLANCHOR(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLANCHOR(This);
}else if(IsEqualGUID(&IID_IHTMLAnchorElement, riid)) {
TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This, ppv);
*ppv = HTMLANCHOR(This);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
hres = HTMLElement_QI(&This->element, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
}
static ULONG WINAPI HTMLAnchorElement_AddRef(IHTMLAnchorElement *iface)
......@@ -412,6 +389,8 @@ static HRESULT WINAPI HTMLAnchorElement_blur(IHTMLAnchorElement *iface)
return E_NOTIMPL;
}
#undef HTMLANCHOR_THIS
static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl = {
HTMLAnchorElement_QueryInterface,
HTMLAnchorElement_AddRef,
......@@ -465,6 +444,31 @@ static const IHTMLAnchorElementVtbl HTMLAnchorElementVtbl = {
#define HTMLANCHOR_NODE_THIS(iface) DEFINE_THIS2(HTMLAnchorElement, element.node, iface)
static HRESULT HTMLAnchorElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
HTMLAnchorElement *This = HTMLANCHOR_NODE_THIS(iface);
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLANCHOR(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLANCHOR(This);
}else if(IsEqualGUID(&IID_IHTMLAnchorElement, riid)) {
TRACE("(%p)->(IID_IHTMLAnchorElement %p)\n", This, ppv);
*ppv = HTMLANCHOR(This);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
return HTMLElement_QI(&This->element.node, riid, ppv);
}
static void HTMLAnchorElement_destructor(HTMLDOMNode *iface)
{
HTMLAnchorElement *This = HTMLANCHOR_NODE_THIS(iface);
......@@ -474,6 +478,7 @@ static void HTMLAnchorElement_destructor(HTMLDOMNode *iface)
#undef HTMLANCHOR_NODE_THIS
static const NodeImplVtbl HTMLAnchorElementImplVtbl = {
HTMLAnchorElement_QI,
HTMLAnchorElement_destructor
};
......@@ -484,7 +489,5 @@ HTMLElement *HTMLAnchorElement_Create(nsIDOMHTMLElement *nselem)
ret->lpHTMLAnchorElementVtbl = &HTMLAnchorElementVtbl;
ret->element.node.vtbl = &HTMLAnchorElementImplVtbl;
ret->element.impl = (IUnknown*)HTMLANCHOR(ret);
return &ret->element;
}
......@@ -55,37 +55,8 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
REFIID riid, void **ppv)
{
HTMLBodyElement *This = HTMLBODY_THIS(iface);
HRESULT hres;
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLBODY(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLBODY(This);
}else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
*ppv = HTMLBODY(This);
}else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This->textcont, ppv);
*ppv = HTMLTEXTCONT(&This->textcont);
}else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
*ppv = CONPTCONT(&This->cp_container);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
hres = HTMLElement_QI(&This->textcont.element, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->textcont.element.node), riid, ppv);
}
static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
......@@ -475,6 +446,37 @@ static const IHTMLBodyElementVtbl HTMLBodyElementVtbl = {
#define HTMLBODY_NODE_THIS(iface) DEFINE_THIS2(HTMLBodyElement, textcont.element.node, iface)
static HRESULT HTMLBodyElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLBODY(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLBODY(This);
}else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
*ppv = HTMLBODY(This);
}else if(IsEqualGUID(&IID_IHTMLTextContainer, riid)) {
TRACE("(%p)->(IID_IHTMLTextContainer %p)\n", &This->textcont, ppv);
*ppv = HTMLTEXTCONT(&This->textcont);
}else if(IsEqualGUID(&IID_IConnectionPointContainer, riid)) {
TRACE("(%p)->(IID_IConnectionPointContainer %p)\n", This, ppv);
*ppv = CONPTCONT(&This->cp_container);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
return HTMLElement_QI(&This->textcont.element.node, riid, ppv);
}
static void HTMLBodyElement_destructor(HTMLDOMNode *iface)
{
HTMLBodyElement *This = HTMLBODY_NODE_THIS(iface);
......@@ -488,6 +490,7 @@ static void HTMLBodyElement_destructor(HTMLDOMNode *iface)
#undef HTMLBODY_NODE_THIS
static const NodeImplVtbl HTMLBodyElementImplVtbl = {
HTMLBodyElement_QI,
HTMLBodyElement_destructor
};
......@@ -514,7 +517,5 @@ HTMLElement *HTMLBodyElement_Create(nsIDOMHTMLElement *nselem)
if(NS_FAILED(nsres))
ERR("Could not get nsDOMHTMLBodyElement: %08x\n", nsres);
ret->textcont.element.impl = (IUnknown*)HTMLBODY(ret);
return &ret->textcont.element;
}
......@@ -64,16 +64,8 @@ static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
REFIID riid, void **ppv)
{
HTMLElement *This = HTMLELEM_THIS(iface);
HRESULT hres;
if(This->impl)
return IUnknown_QueryInterface(This->impl, riid, ppv);
hres = HTMLElement_QI(This, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->node), riid, ppv);
}
static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
......@@ -1239,8 +1231,10 @@ static const IHTMLElementVtbl HTMLElementVtbl = {
HTMLElement_get_all
};
HRESULT HTMLElement_QI(HTMLElement *This, REFIID riid, void **ppv)
HRESULT HTMLElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
HTMLElement *This = HTMLELEM_NODE_THIS(iface);
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
......@@ -1276,6 +1270,7 @@ void HTMLElement_destructor(HTMLDOMNode *iface)
}
static const NodeImplVtbl HTMLElementImplVtbl = {
HTMLElement_QI,
HTMLElement_destructor
};
......@@ -1316,8 +1311,6 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode)
if(!ret) {
ret = mshtml_alloc(sizeof(HTMLElement));
ret->node.vtbl = &HTMLElementImplVtbl;
ret->impl = NULL;
}
nsAString_Finish(&class_name_str);
......@@ -1327,8 +1320,6 @@ HTMLElement *HTMLElement_Create(nsIDOMNode *nsnode)
HTMLElement2_Init(ret);
ret->node.impl.elem = HTMLELEM(ret);
return ret;
}
......
......@@ -51,31 +51,8 @@ static HRESULT WINAPI HTMLInputElement_QueryInterface(IHTMLInputElement *iface,
REFIID riid, void **ppv)
{
HTMLInputElement *This = HTMLINPUT_THIS(iface);
HRESULT hres;
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLINPUT(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLINPUT(This);
}else if(IsEqualGUID(&IID_IHTMLInputElement, riid)) {
TRACE("(%p)->(IID_IHTMLInputElement %p)\n", This, ppv);
*ppv = HTMLINPUT(This);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
hres = HTMLElement_QI(&This->element, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
}
static ULONG WINAPI HTMLInputElement_AddRef(IHTMLInputElement *iface)
......@@ -728,6 +705,31 @@ static const IHTMLInputElementVtbl HTMLInputElementVtbl = {
#define HTMLINPUT_NODE_THIS(iface) DEFINE_THIS2(HTMLInputElement, element.node, iface)
static HRESULT HTMLInputElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
HTMLInputElement *This = HTMLINPUT_NODE_THIS(iface);
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLINPUT(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLINPUT(This);
}else if(IsEqualGUID(&IID_IHTMLInputElement, riid)) {
TRACE("(%p)->(IID_IHTMLInputElement %p)\n", This, ppv);
*ppv = HTMLINPUT(This);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
return HTMLElement_QI(&This->element.node, riid, ppv);
}
static void HTMLInputElement_destructor(HTMLDOMNode *iface)
{
HTMLInputElement *This = HTMLINPUT_NODE_THIS(iface);
......@@ -740,6 +742,7 @@ static void HTMLInputElement_destructor(HTMLDOMNode *iface)
#undef HTMLINPUT_NODE_THIS
static const NodeImplVtbl HTMLInputElementImplVtbl = {
HTMLInputElement_QI,
HTMLInputElement_destructor
};
......@@ -756,7 +759,5 @@ HTMLElement *HTMLInputElement_Create(nsIDOMHTMLElement *nselem)
if(NS_FAILED(nsres))
ERR("Could not get nsIDOMHTMLInputElement interface: %08x\n", nsres);
ret->element.impl = (IUnknown*)HTMLINPUT(ret);
return &ret->element;
}
......@@ -43,16 +43,8 @@ static HRESULT WINAPI HTMLDOMNode_QueryInterface(IHTMLDOMNode *iface,
REFIID riid, void **ppv)
{
HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
HRESULT hres;
if(This->impl.unk)
return IUnknown_QueryInterface(This->impl.unk, riid, ppv);
hres = HTMLDOMNode_QI(This, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
return This->vtbl->qi(This, riid, ppv);
}
static ULONG WINAPI HTMLDOMNode_AddRef(IHTMLDOMNode *iface)
......@@ -328,6 +320,7 @@ HRESULT HTMLDOMNode_QI(HTMLDOMNode *This, REFIID riid, void **ppv)
return S_OK;
}
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
}
......@@ -338,6 +331,7 @@ void HTMLDOMNode_destructor(HTMLDOMNode *This)
}
static const NodeImplVtbl HTMLDOMNodeImplVtbl = {
HTMLDOMNode_QI,
HTMLDOMNode_destructor
};
......@@ -355,7 +349,6 @@ static HTMLDOMNode *create_node(HTMLDocument *doc, nsIDOMNode *nsnode)
default:
ret = mshtml_alloc(sizeof(HTMLDOMNode));
ret->vtbl = &HTMLDOMNodeImplVtbl;
ret->impl.unk = NULL;
}
ret->lpHTMLDOMNodeVtbl = &HTMLDOMNodeVtbl;
......
......@@ -51,31 +51,8 @@ static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface
REFIID riid, void **ppv)
{
HTMLSelectElement *This = HTMLSELECT_THIS(iface);
HRESULT hres;
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLSELECT(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLSELECT(This);
}else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
*ppv = HTMLSELECT(This);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
hres = HTMLElement_QI(&This->element, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
}
static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface)
......@@ -379,6 +356,31 @@ static const IHTMLSelectElementVtbl HTMLSelectElementVtbl = {
#define HTMLSELECT_NODE_THIS(iface) DEFINE_THIS2(HTMLSelectElement, element.node, iface)
static HRESULT HTMLSelectElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLSELECT(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLSELECT(This);
}else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
*ppv = HTMLSELECT(This);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
return HTMLElement_QI(&This->element.node, riid, ppv);
}
static void HTMLSelectElement_destructor(HTMLDOMNode *iface)
{
HTMLSelectElement *This = HTMLSELECT_NODE_THIS(iface);
......@@ -391,6 +393,7 @@ static void HTMLSelectElement_destructor(HTMLDOMNode *iface)
#undef HTMLSELECT_NODE_THIS
static const NodeImplVtbl HTMLSelectElementImplVtbl = {
HTMLSelectElement_QI,
HTMLSelectElement_destructor
};
......@@ -407,7 +410,5 @@ HTMLElement *HTMLSelectElement_Create(nsIDOMHTMLElement *nselem)
if(NS_FAILED(nsres))
ERR("Could not get nsIDOMHTMLSelectElement interfce: %08x\n", nsres);
ret->element.impl = (IUnknown*)HTMLSELECT(ret);
return &ret->element;
}
......@@ -51,31 +51,8 @@ static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *i
REFIID riid, void **ppv)
{
HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
HRESULT hres;
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLTXTAREA(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLTXTAREA(This);
}else if(IsEqualGUID(&IID_IHTMLTextAreaElement, riid)) {
TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This, ppv);
*ppv = HTMLTXTAREA(This);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
hres = HTMLElement_QI(&This->element, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
return IHTMLDOMNode_QueryInterface(HTMLDOMNODE(&This->element.node), riid, ppv);
}
static ULONG WINAPI HTMLTextAreaElement_AddRef(IHTMLTextAreaElement *iface)
......@@ -386,6 +363,31 @@ static const IHTMLTextAreaElementVtbl HTMLTextAreaElementVtbl = {
#define HTMLTXTAREA_NODE_THIS(iface) DEFINE_THIS2(HTMLTextAreaElement, element.node, iface)
static HRESULT HTMLTextAreaElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
{
HTMLTextAreaElement *This = HTMLTXTAREA_NODE_THIS(iface);
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLTXTAREA(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLTXTAREA(This);
}else if(IsEqualGUID(&IID_IHTMLTextAreaElement, riid)) {
TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This, ppv);
*ppv = HTMLTXTAREA(This);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
return HTMLElement_QI(&This->element.node, riid, ppv);
}
static void HTMLTextAreaElement_destructor(HTMLDOMNode *iface)
{
HTMLTextAreaElement *This = HTMLTXTAREA_NODE_THIS(iface);
......@@ -398,6 +400,7 @@ static void HTMLTextAreaElement_destructor(HTMLDOMNode *iface)
#undef HTMLTXTAREA_NODE_THIS
static const NodeImplVtbl HTMLTextAreaElementImplVtbl = {
HTMLTextAreaElement_QI,
HTMLTextAreaElement_destructor
};
......@@ -414,7 +417,5 @@ HTMLElement *HTMLTextAreaElement_Create(nsIDOMHTMLElement *nselem)
if(NS_FAILED(nsres))
ERR("Could not get nsDOMHTMLInputElement: %08x\n", nsres);
ret->element.impl = (IUnknown*)HTMLTXTAREA(ret);
return &ret->element;
}
......@@ -251,6 +251,7 @@ struct BSCallback {
};
typedef struct {
HRESULT (*qi)(HTMLDOMNode*,REFIID,void**);
void (*destructor)(HTMLDOMNode*);
} NodeImplVtbl;
......@@ -258,11 +259,6 @@ struct HTMLDOMNode {
const IHTMLDOMNodeVtbl *lpHTMLDOMNodeVtbl;
const NodeImplVtbl *vtbl;
union {
IUnknown *unk;
IHTMLElement *elem;
} impl;
nsIDOMNode *nsnode;
HTMLDocument *doc;
......@@ -276,8 +272,6 @@ typedef struct {
const IHTMLElement2Vtbl *lpHTMLElement2Vtbl;
nsIDOMHTMLElement *nselem;
IUnknown *impl;
} HTMLElement;
typedef struct {
......@@ -430,7 +424,7 @@ void HTMLTextContainer_Init(HTMLTextContainer*);
HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
void HTMLDOMNode_destructor(HTMLDOMNode*);
HRESULT HTMLElement_QI(HTMLElement*,REFIID,void**);
HRESULT HTMLElement_QI(HTMLDOMNode*,REFIID,void**);
void HTMLElement_destructor(HTMLDOMNode*);
HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
......
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