From 74e95a13b302a2c63d73609a546078a0d7a020f5 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Tue, 21 Jun 2011 13:47:09 +0200 Subject: [PATCH] mshtml: Added IHTMLHeadElement stub implementation. --- dlls/mshtml/Makefile.in | 1 + dlls/mshtml/htmlelem.c | 2 + dlls/mshtml/htmlhead.c | 177 +++++++++++++++++++++++++++++++++++ dlls/mshtml/mshtml_private.h | 1 + dlls/mshtml/tests/dom.c | 9 +- 5 files changed, 189 insertions(+), 1 deletion(-) create mode 100644 dlls/mshtml/htmlhead.c diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in index ea716fb2e0c..1732951199f 100644 --- a/dlls/mshtml/Makefile.in +++ b/dlls/mshtml/Makefile.in @@ -27,6 +27,7 @@ C_SRCS = \ htmlframe.c \ htmlframebase.c \ htmlgeneric.c \ + htmlhead.c \ htmliframe.c \ htmlimg.c \ htmlinput.c \ diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 603ae9bd5ad..24d7b088202 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -42,6 +42,7 @@ static const WCHAR bodyW[] = {'B','O','D','Y',0}; static const WCHAR embedW[] = {'E','M','B','E','D',0}; static const WCHAR formW[] = {'F','O','R','M',0}; static const WCHAR frameW[] = {'F','R','A','M','E',0}; +static const WCHAR headW[] = {'H','E','A','D',0}; static const WCHAR iframeW[] = {'I','F','R','A','M','E',0}; static const WCHAR imgW[] = {'I','M','G',0}; static const WCHAR inputW[] = {'I','N','P','U','T',0}; @@ -65,6 +66,7 @@ static const tag_desc_t tag_descs[] = { {embedW, HTMLEmbedElement_Create}, {formW, HTMLFormElement_Create}, {frameW, HTMLFrameElement_Create}, + {headW, HTMLHeadElement_Create}, {iframeW, HTMLIFrame_Create}, {imgW, HTMLImgElement_Create}, {inputW, HTMLInputElement_Create}, diff --git a/dlls/mshtml/htmlhead.c b/dlls/mshtml/htmlhead.c new file mode 100644 index 00000000000..aee21576231 --- /dev/null +++ b/dlls/mshtml/htmlhead.c @@ -0,0 +1,177 @@ + /* + * Copyright 2011 Jacek Caban for CodeWeavers + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA + */ + +#include + +#define COBJMACROS + +#include "windef.h" +#include "winbase.h" +#include "winuser.h" +#include "ole2.h" + +#include "wine/debug.h" + +#include "mshtml_private.h" + +WINE_DEFAULT_DEBUG_CHANNEL(mshtml); + +typedef struct { + HTMLElement element; + + IHTMLHeadElement IHTMLHeadElement_iface; +} HTMLHeadElement; + +static inline HTMLHeadElement *impl_from_IHTMLHeadElement(IHTMLHeadElement *iface) +{ + return CONTAINING_RECORD(iface, HTMLHeadElement, IHTMLHeadElement_iface); +} + +static HRESULT WINAPI HTMLHeadElement_QueryInterface(IHTMLHeadElement *iface, + REFIID riid, void **ppv) +{ + HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface); + + return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv); +} + +static ULONG WINAPI HTMLHeadElement_AddRef(IHTMLHeadElement *iface) +{ + HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface); + + return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface); +} + +static ULONG WINAPI HTMLHeadElement_Release(IHTMLHeadElement *iface) +{ + HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface); + + return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface); +} + +static HRESULT WINAPI HTMLHeadElement_GetTypeInfoCount(IHTMLHeadElement *iface, UINT *pctinfo) +{ + HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface); + + return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo); +} + +static HRESULT WINAPI HTMLHeadElement_GetTypeInfo(IHTMLHeadElement *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface); + + return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid, + ppTInfo); +} + +static HRESULT WINAPI HTMLHeadElement_GetIDsOfNames(IHTMLHeadElement *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface); + + return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames, + cNames, lcid, rgDispId); +} + +static HRESULT WINAPI HTMLHeadElement_Invoke(IHTMLHeadElement *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface); + + return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid, + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI HTMLHeadElement_put_profile(IHTMLHeadElement *iface, BSTR v) +{ + HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLHeadElement_get_profile(IHTMLHeadElement *iface, BSTR *p) +{ + HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static const IHTMLHeadElementVtbl HTMLHeadElementVtbl = { + HTMLHeadElement_QueryInterface, + HTMLHeadElement_AddRef, + HTMLHeadElement_Release, + HTMLHeadElement_GetTypeInfoCount, + HTMLHeadElement_GetTypeInfo, + HTMLHeadElement_GetIDsOfNames, + HTMLHeadElement_Invoke, + HTMLHeadElement_put_profile, + HTMLHeadElement_get_profile +}; + +static inline HTMLHeadElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface) +{ + return CONTAINING_RECORD(iface, HTMLHeadElement, element.node); +} + +static HRESULT HTMLHeadElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) +{ + HTMLHeadElement *This = impl_from_HTMLDOMNode(iface); + + if(IsEqualGUID(&IID_IHTMLHeadElement, riid)) { + TRACE("(%p)->(IID_IHTMLHeadElement %p)\n", This, ppv); + *ppv = &This->IHTMLHeadElement_iface; + }else { + HTMLElement_QI(&This->element.node, riid, ppv); + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static void HTMLHeadElement_destructor(HTMLDOMNode *iface) +{ + HTMLHeadElement *This = impl_from_HTMLDOMNode(iface); + + HTMLElement_destructor(&This->element.node); +} + +static const NodeImplVtbl HTMLHeadElementImplVtbl = { + HTMLHeadElement_QI, + HTMLHeadElement_destructor, + HTMLElement_clone +}; + +HRESULT HTMLHeadElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem) +{ + HTMLHeadElement *ret; + + ret = heap_alloc_zero(sizeof(*ret)); + if(!ret) + return E_OUTOFMEMORY; + + ret->IHTMLHeadElement_iface.lpVtbl = &HTMLHeadElementVtbl; + ret->element.node.vtbl = &HTMLHeadElementImplVtbl; + + HTMLElement_Init(&ret->element, doc, nselem, NULL); + + *elem = &ret->element; + return S_OK; +} diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index cc17a645702..ea62a46de2b 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -779,6 +779,7 @@ HRESULT HTMLBodyElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement* HRESULT HTMLEmbedElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLFormElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLFrameElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; +HRESULT HTMLHeadElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLStyleElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index 414da447105..967294365e8 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -281,6 +281,13 @@ static const IID * const frame_iids[] = { NULL }; +static const IID * const head_iids[] = { + ELEM_IFACES, + &IID_IHTMLHeadElement, + &IID_IConnectionPointContainer, + NULL +}; + static const IID * const object_iids[] = { ELEM_IFACES, &IID_IHTMLObjectElement, @@ -361,7 +368,7 @@ typedef struct { static const elem_type_info_t elem_type_infos[] = { {"", none_iids, NULL}, {"HTML", elem_iids, NULL}, - {"HEAD", elem_iids, NULL}, + {"HEAD", head_iids, NULL}, {"TITLE", elem_iids, NULL}, {"BODY", body_iids, &DIID_DispHTMLBody}, {"A", anchor_iids, &DIID_DispHTMLAnchorElement},