Commit 3d9d3844 authored by Jacek Caban's avatar Jacek Caban Committed by Alexandre Julliard

mshtml: Better QueryInterface implementation.

parent ad05be73
...@@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface, ...@@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
HTMLBodyElement *This = HTMLBODY_THIS(iface); HTMLBodyElement *This = HTMLBODY_THIS(iface);
HRESULT hres;
*ppv = NULL; *ppv = NULL;
...@@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface, ...@@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
}else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) { }else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv); TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
*ppv = HTMLBODY(This); *ppv = HTMLBODY(This);
}else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
*ppv = HTMLELEM(This->element);
}else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
*ppv = HTMLDOMNODE(This->element->node);
} }
if(*ppv) { if(*ppv) {
...@@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface, ...@@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
return S_OK; return S_OK;
} }
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); hres = HTMLElement_QI(This->element, riid, ppv);
return E_NOINTERFACE; if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
} }
static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface) static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)
......
...@@ -44,33 +44,16 @@ static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface, ...@@ -44,33 +44,16 @@ static HRESULT WINAPI HTMLElement_QueryInterface(IHTMLElement *iface,
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
HTMLElement *This = HTMLELEM_THIS(iface); HTMLElement *This = HTMLELEM_THIS(iface);
HRESULT hres;
if(This->impl) if(This->impl)
return IUnknown_QueryInterface(This->impl, riid, ppv); return IUnknown_QueryInterface(This->impl, riid, ppv);
*ppv = NULL; hres = HTMLElement_QI(This, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
if(IsEqualGUID(&IID_IUnknown, riid)) { return hres;
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLELEM(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLELEM(This);
}else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
*ppv = HTMLDOMNODE(This->node);
}else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
*ppv = HTMLELEM(This);
}
if(*ppv) {
IHTMLElement_AddRef(HTMLELEM(This));
return S_OK;
}
FIXME("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
} }
static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface) static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
...@@ -939,6 +922,29 @@ static const IHTMLElementVtbl HTMLElementVtbl = { ...@@ -939,6 +922,29 @@ static const IHTMLElementVtbl HTMLElementVtbl = {
HTMLElement_get_all HTMLElement_get_all
}; };
HRESULT HTMLElement_QI(HTMLElement *This, REFIID riid, void **ppv)
{
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLELEM(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLELEM(This);
}else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
*ppv = HTMLELEM(This);
}
if(*ppv) {
IHTMLElement_AddRef(HTMLELEM(This));
return S_OK;
}
return HTMLDOMNode_QI(This->node, riid, ppv);
}
void HTMLElement_Create(HTMLDOMNode *node) void HTMLElement_Create(HTMLDOMNode *node)
{ {
HTMLElement *ret; HTMLElement *ret;
......
...@@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLInputElement_QueryInterface(IHTMLInputElement *iface, ...@@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLInputElement_QueryInterface(IHTMLInputElement *iface,
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
HTMLInputElement *This = HTMLINPUT_THIS(iface); HTMLInputElement *This = HTMLINPUT_THIS(iface);
HRESULT hres;
*ppv = NULL; *ppv = NULL;
...@@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLInputElement_QueryInterface(IHTMLInputElement *iface, ...@@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLInputElement_QueryInterface(IHTMLInputElement *iface,
}else if(IsEqualGUID(&IID_IHTMLInputElement, riid)) { }else if(IsEqualGUID(&IID_IHTMLInputElement, riid)) {
TRACE("(%p)->(IID_IHTMLInputElement %p)\n", This, ppv); TRACE("(%p)->(IID_IHTMLInputElement %p)\n", This, ppv);
*ppv = HTMLINPUT(This); *ppv = HTMLINPUT(This);
}else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
*ppv = HTMLELEM(This->element);
}else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
*ppv = HTMLDOMNODE(This->element->node);
} }
if(*ppv) { if(*ppv) {
...@@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLInputElement_QueryInterface(IHTMLInputElement *iface, ...@@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLInputElement_QueryInterface(IHTMLInputElement *iface,
return S_OK; return S_OK;
} }
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); hres = HTMLElement_QI(This->element, riid, ppv);
return E_NOINTERFACE; if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
} }
static ULONG WINAPI HTMLInputElement_AddRef(IHTMLInputElement *iface) static ULONG WINAPI HTMLInputElement_AddRef(IHTMLInputElement *iface)
......
...@@ -43,30 +43,16 @@ static HRESULT WINAPI HTMLDOMNode_QueryInterface(IHTMLDOMNode *iface, ...@@ -43,30 +43,16 @@ static HRESULT WINAPI HTMLDOMNode_QueryInterface(IHTMLDOMNode *iface,
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
HTMLDOMNode *This = HTMLDOMNODE_THIS(iface); HTMLDOMNode *This = HTMLDOMNODE_THIS(iface);
HRESULT hres;
if(This->impl.unk) if(This->impl.unk)
return IUnknown_QueryInterface(This->impl.unk, riid, ppv); return IUnknown_QueryInterface(This->impl.unk, riid, ppv);
*ppv = NULL; hres = HTMLDOMNode_QI(This, riid, ppv);
if(FAILED(hres))
if(IsEqualGUID(&IID_IUnknown, riid)) { WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLDOMNODE(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLDOMNODE(This);
}else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
*ppv = HTMLDOMNODE(This);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); return hres;
return E_NOINTERFACE;
} }
static ULONG WINAPI HTMLDOMNode_AddRef(IHTMLDOMNode *iface) static ULONG WINAPI HTMLDOMNode_AddRef(IHTMLDOMNode *iface)
...@@ -304,6 +290,29 @@ static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl = { ...@@ -304,6 +290,29 @@ static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl = {
HTMLDOMNode_get_nextSibling HTMLDOMNode_get_nextSibling
}; };
HRESULT HTMLDOMNode_QI(HTMLDOMNode *This, REFIID riid, void **ppv)
{
*ppv = NULL;
if(IsEqualGUID(&IID_IUnknown, riid)) {
TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
*ppv = HTMLDOMNODE(This);
}else if(IsEqualGUID(&IID_IDispatch, riid)) {
TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
*ppv = HTMLDOMNODE(This);
}else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
*ppv = HTMLDOMNODE(This);
}
if(*ppv) {
IUnknown_AddRef((IUnknown*)*ppv);
return S_OK;
}
return E_NOINTERFACE;
}
/* /*
* FIXME * FIXME
* List looks really ugly here. We should use a better data structure or * List looks really ugly here. We should use a better data structure or
......
...@@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface ...@@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
HTMLSelectElement *This = HTMLSELECT_THIS(iface); HTMLSelectElement *This = HTMLSELECT_THIS(iface);
HRESULT hres;
*ppv = NULL; *ppv = NULL;
...@@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface ...@@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface
}else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) { }else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv); TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
*ppv = HTMLSELECT(This); *ppv = HTMLSELECT(This);
}else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
*ppv = HTMLELEM(This->element);
}else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
*ppv = HTMLDOMNODE(This->element->node);
} }
if(*ppv) { if(*ppv) {
...@@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface ...@@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface
return S_OK; return S_OK;
} }
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); hres = HTMLElement_QI(This->element, riid, ppv);
return E_NOINTERFACE; if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
} }
static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface) static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface)
......
...@@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *i ...@@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *i
REFIID riid, void **ppv) REFIID riid, void **ppv)
{ {
HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface); HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
HRESULT hres;
*ppv = NULL; *ppv = NULL;
...@@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *i ...@@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *i
}else if(IsEqualGUID(&IID_IHTMLTextAreaElement, riid)) { }else if(IsEqualGUID(&IID_IHTMLTextAreaElement, riid)) {
TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This, ppv); TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This, ppv);
*ppv = HTMLTXTAREA(This); *ppv = HTMLTXTAREA(This);
}else if(IsEqualGUID(&IID_IHTMLElement, riid)) {
TRACE("(%p)->(IID_IHTMLElement %p)\n", This, ppv);
*ppv = HTMLELEM(This->element);
}else if(IsEqualGUID(&IID_IHTMLDOMNode, riid)) {
TRACE("(%p)->(IID_IHTMLDOMNode %p)\n", This, ppv);
*ppv = HTMLDOMNODE(This->element->node);
} }
if(*ppv) { if(*ppv) {
...@@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *i ...@@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *i
return S_OK; return S_OK;
} }
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv); hres = HTMLElement_QI(This->element, riid, ppv);
return E_NOINTERFACE; if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
} }
static ULONG WINAPI HTMLTextAreaElement_AddRef(IHTMLTextAreaElement *iface) static ULONG WINAPI HTMLTextAreaElement_AddRef(IHTMLTextAreaElement *iface)
......
...@@ -217,6 +217,9 @@ void HTMLInputElement_Create(HTMLElement*); ...@@ -217,6 +217,9 @@ void HTMLInputElement_Create(HTMLElement*);
void HTMLSelectElement_Create(HTMLElement*); void HTMLSelectElement_Create(HTMLElement*);
void HTMLTextAreaElement_Create(HTMLElement*); void HTMLTextAreaElement_Create(HTMLElement*);
HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
HRESULT HTMLElement_QI(HTMLElement*,REFIID,void**);
HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*); HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
void release_nodes(HTMLDocument*); void release_nodes(HTMLDocument*);
......
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