mshtml: Better QueryInterface implementation.

This commit is contained in:
Jacek Caban 2006-03-18 19:43:05 +01:00 committed by Alexandre Julliard
parent ad05be7395
commit 3d9d384486
7 changed files with 83 additions and 73 deletions

View File

@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
REFIID riid, void **ppv)
{
HTMLBodyElement *This = HTMLBODY_THIS(iface);
HRESULT hres;
*ppv = NULL;
@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
}else if(IsEqualGUID(&IID_IHTMLBodyElement, riid)) {
TRACE("(%p)->(IID_IHTMLBodyElement %p)\n", This, ppv);
*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) {
@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLBodyElement_QueryInterface(IHTMLBodyElement *iface,
return S_OK;
}
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
hres = HTMLElement_QI(This->element, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
}
static ULONG WINAPI HTMLBodyElement_AddRef(IHTMLBodyElement *iface)

View File

@ -44,33 +44,16 @@ 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);
*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)) {
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;
return hres;
}
static ULONG WINAPI HTMLElement_AddRef(IHTMLElement *iface)
@ -939,6 +922,29 @@ static const IHTMLElementVtbl HTMLElementVtbl = {
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)
{
HTMLElement *ret;

View File

@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLInputElement_QueryInterface(IHTMLInputElement *iface,
REFIID riid, void **ppv)
{
HTMLInputElement *This = HTMLINPUT_THIS(iface);
HRESULT hres;
*ppv = NULL;
@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLInputElement_QueryInterface(IHTMLInputElement *iface,
}else if(IsEqualGUID(&IID_IHTMLInputElement, riid)) {
TRACE("(%p)->(IID_IHTMLInputElement %p)\n", This, ppv);
*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) {
@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLInputElement_QueryInterface(IHTMLInputElement *iface,
return S_OK;
}
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
hres = HTMLElement_QI(This->element, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
}
static ULONG WINAPI HTMLInputElement_AddRef(IHTMLInputElement *iface)

View File

@ -43,30 +43,16 @@ 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);
*ppv = NULL;
hres = HTMLDOMNode_QI(This, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
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;
}
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
return hres;
}
static ULONG WINAPI HTMLDOMNode_AddRef(IHTMLDOMNode *iface)
@ -304,6 +290,29 @@ static const IHTMLDOMNodeVtbl HTMLDOMNodeVtbl = {
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
* List looks really ugly here. We should use a better data structure or

View File

@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface
REFIID riid, void **ppv)
{
HTMLSelectElement *This = HTMLSELECT_THIS(iface);
HRESULT hres;
*ppv = NULL;
@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface
}else if(IsEqualGUID(&IID_IHTMLSelectElement, riid)) {
TRACE("(%p)->(IID_IHTMLSelectElement %p)\n", This, ppv);
*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) {
@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLSelectElement_QueryInterface(IHTMLSelectElement *iface
return S_OK;
}
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
hres = HTMLElement_QI(This->element, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
}
static ULONG WINAPI HTMLSelectElement_AddRef(IHTMLSelectElement *iface)

View File

@ -50,6 +50,7 @@ static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *i
REFIID riid, void **ppv)
{
HTMLTextAreaElement *This = HTMLTXTAREA_THIS(iface);
HRESULT hres;
*ppv = NULL;
@ -62,12 +63,6 @@ static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *i
}else if(IsEqualGUID(&IID_IHTMLTextAreaElement, riid)) {
TRACE("(%p)->(IID_IHTMLTextAreaElement %p)\n", This, ppv);
*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) {
@ -75,8 +70,11 @@ static HRESULT WINAPI HTMLTextAreaElement_QueryInterface(IHTMLTextAreaElement *i
return S_OK;
}
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return E_NOINTERFACE;
hres = HTMLElement_QI(This->element, riid, ppv);
if(FAILED(hres))
WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
return hres;
}
static ULONG WINAPI HTMLTextAreaElement_AddRef(IHTMLTextAreaElement *iface)

View File

@ -217,6 +217,9 @@ void HTMLInputElement_Create(HTMLElement*);
void HTMLSelectElement_Create(HTMLElement*);
void HTMLTextAreaElement_Create(HTMLElement*);
HRESULT HTMLDOMNode_QI(HTMLDOMNode*,REFIID,void**);
HRESULT HTMLElement_QI(HTMLElement*,REFIID,void**);
HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
void release_nodes(HTMLDocument*);