From b75e2c4ddefd0842146d62f7addfe84d30f57f03 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 15 Oct 2012 11:16:30 +0200 Subject: [PATCH] mshtml: Added IHTMLLinkElement stub implementation. --- dlls/mshtml/Makefile.in | 1 + dlls/mshtml/htmlelem.c | 2 + dlls/mshtml/htmllink.c | 334 +++++++++++++++++++++++++++++++++++ dlls/mshtml/mshtml_private.h | 3 + dlls/mshtml/tests/dom.c | 15 +- 5 files changed, 353 insertions(+), 2 deletions(-) create mode 100644 dlls/mshtml/htmllink.c diff --git a/dlls/mshtml/Makefile.in b/dlls/mshtml/Makefile.in index 26311af3136..e479bf881b3 100644 --- a/dlls/mshtml/Makefile.in +++ b/dlls/mshtml/Makefile.in @@ -31,6 +31,7 @@ C_SRCS = \ htmliframe.c \ htmlimg.c \ htmlinput.c \ + htmllink.c \ htmllocation.c \ htmlmeta.c \ htmlnode.c \ diff --git a/dlls/mshtml/htmlelem.c b/dlls/mshtml/htmlelem.c index 157d7aff13f..d11ebbc1afd 100644 --- a/dlls/mshtml/htmlelem.c +++ b/dlls/mshtml/htmlelem.c @@ -45,6 +45,7 @@ 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}; +static const WCHAR linkW[] = {'L','I','N','K',0}; static const WCHAR metaW[] = {'M','E','T','A',0}; static const WCHAR objectW[] = {'O','B','J','E','C','T',0}; static const WCHAR optionW[] = {'O','P','T','I','O','N',0}; @@ -72,6 +73,7 @@ static const tag_desc_t tag_descs[] = { {iframeW, HTMLIFrame_Create}, {imgW, HTMLImgElement_Create}, {inputW, HTMLInputElement_Create}, + {linkW, HTMLLinkElement_Create}, {metaW, HTMLMetaElement_Create}, {objectW, HTMLObjectElement_Create}, {optionW, HTMLOptionElement_Create}, diff --git a/dlls/mshtml/htmllink.c b/dlls/mshtml/htmllink.c new file mode 100644 index 00000000000..837538e84b4 --- /dev/null +++ b/dlls/mshtml/htmllink.c @@ -0,0 +1,334 @@ + /* + * Copyright 2012 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; + IHTMLLinkElement IHTMLLinkElement_iface; +} HTMLLinkElement; + +static inline HTMLLinkElement *impl_from_IHTMLLinkElement(IHTMLLinkElement *iface) +{ + return CONTAINING_RECORD(iface, HTMLLinkElement, IHTMLLinkElement_iface); +} + +static HRESULT WINAPI HTMLLinkElement_QueryInterface(IHTMLLinkElement *iface, + REFIID riid, void **ppv) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + + return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv); +} + +static ULONG WINAPI HTMLLinkElement_AddRef(IHTMLLinkElement *iface) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + + return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface); +} + +static ULONG WINAPI HTMLLinkElement_Release(IHTMLLinkElement *iface) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + + return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface); +} + +static HRESULT WINAPI HTMLLinkElement_GetTypeInfoCount(IHTMLLinkElement *iface, UINT *pctinfo) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + + return IDispatchEx_GetTypeInfoCount(&This->element.node.dispex.IDispatchEx_iface, pctinfo); +} + +static HRESULT WINAPI HTMLLinkElement_GetTypeInfo(IHTMLLinkElement *iface, UINT iTInfo, + LCID lcid, ITypeInfo **ppTInfo) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + + return IDispatchEx_GetTypeInfo(&This->element.node.dispex.IDispatchEx_iface, iTInfo, lcid, + ppTInfo); +} + +static HRESULT WINAPI HTMLLinkElement_GetIDsOfNames(IHTMLLinkElement *iface, REFIID riid, + LPOLESTR *rgszNames, UINT cNames, + LCID lcid, DISPID *rgDispId) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + + return IDispatchEx_GetIDsOfNames(&This->element.node.dispex.IDispatchEx_iface, riid, rgszNames, + cNames, lcid, rgDispId); +} + +static HRESULT WINAPI HTMLLinkElement_Invoke(IHTMLLinkElement *iface, DISPID dispIdMember, + REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, + VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + + return IDispatchEx_Invoke(&This->element.node.dispex.IDispatchEx_iface, dispIdMember, riid, + lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr); +} + +static HRESULT WINAPI HTMLLinkElement_put_href(IHTMLLinkElement *iface, BSTR v) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_get_href(IHTMLLinkElement *iface, BSTR *p) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_put_rel(IHTMLLinkElement *iface, BSTR v) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_get_rel(IHTMLLinkElement *iface, BSTR *p) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_put_rev(IHTMLLinkElement *iface, BSTR v) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_get_rev(IHTMLLinkElement *iface, BSTR *p) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_put_type(IHTMLLinkElement *iface, BSTR v) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_get_type(IHTMLLinkElement *iface, BSTR *p) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_get_readyState(IHTMLLinkElement *iface, BSTR *p) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_put_onreadystatechange(IHTMLLinkElement *iface, VARIANT v) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_get_onreadystatechange(IHTMLLinkElement *iface, VARIANT *p) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_put_onload(IHTMLLinkElement *iface, VARIANT v) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_get_onload(IHTMLLinkElement *iface, VARIANT *p) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_put_onerror(IHTMLLinkElement *iface, VARIANT v) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_variant(&v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_get_onerror(IHTMLLinkElement *iface, VARIANT *p) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_get_styleSheet(IHTMLLinkElement *iface, IHTMLStyleSheet **p) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_put_disabled(IHTMLLinkElement *iface, VARIANT_BOOL v) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%x)\n", This, v); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_get_disabled(IHTMLLinkElement *iface, VARIANT_BOOL *p) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_put_media(IHTMLLinkElement *iface, BSTR v) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%s)\n", This, debugstr_w(v)); + return E_NOTIMPL; +} + +static HRESULT WINAPI HTMLLinkElement_get_media(IHTMLLinkElement *iface, BSTR *p) +{ + HTMLLinkElement *This = impl_from_IHTMLLinkElement(iface); + FIXME("(%p)->(%p)\n", This, p); + return E_NOTIMPL; +} + +static const IHTMLLinkElementVtbl HTMLLinkElementVtbl = { + HTMLLinkElement_QueryInterface, + HTMLLinkElement_AddRef, + HTMLLinkElement_Release, + HTMLLinkElement_GetTypeInfoCount, + HTMLLinkElement_GetTypeInfo, + HTMLLinkElement_GetIDsOfNames, + HTMLLinkElement_Invoke, + HTMLLinkElement_put_href, + HTMLLinkElement_get_href, + HTMLLinkElement_put_rel, + HTMLLinkElement_get_rel, + HTMLLinkElement_put_rev, + HTMLLinkElement_get_rev, + HTMLLinkElement_put_type, + HTMLLinkElement_get_type, + HTMLLinkElement_get_readyState, + HTMLLinkElement_put_onreadystatechange, + HTMLLinkElement_get_onreadystatechange, + HTMLLinkElement_put_onload, + HTMLLinkElement_get_onload, + HTMLLinkElement_put_onerror, + HTMLLinkElement_get_onerror, + HTMLLinkElement_get_styleSheet, + HTMLLinkElement_put_disabled, + HTMLLinkElement_get_disabled, + HTMLLinkElement_put_media, + HTMLLinkElement_get_media +}; + +static inline HTMLLinkElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface) +{ + return CONTAINING_RECORD(iface, HTMLLinkElement, element.node); +} + +static HRESULT HTMLLinkElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv) +{ + HTMLLinkElement *This = impl_from_HTMLDOMNode(iface); + + if(IsEqualGUID(&IID_IHTMLLinkElement, riid)) { + TRACE("(%p)->(IID_IHTMLLinkElement %p)\n", This, ppv); + *ppv = &This->IHTMLLinkElement_iface; + }else { + return HTMLElement_QI(&This->element.node, riid, ppv); + } + + IUnknown_AddRef((IUnknown*)*ppv); + return S_OK; +} + +static void HTMLLinkElement_destructor(HTMLDOMNode *iface) +{ + HTMLLinkElement *This = impl_from_HTMLDOMNode(iface); + + HTMLElement_destructor(&This->element.node); +} + +static const NodeImplVtbl HTMLLinkElementImplVtbl = { + HTMLLinkElement_QI, + HTMLLinkElement_destructor, + HTMLElement_clone, + HTMLElement_handle_event, + HTMLElement_get_attr_col +}; + +static const tid_t HTMLLinkElement_iface_tids[] = { + HTMLELEMENT_TIDS, + IHTMLLinkElement_tid, + 0 +}; +static dispex_static_data_t HTMLLinkElement_dispex = { + NULL, + DispHTMLLinkElement_tid, + NULL, + HTMLLinkElement_iface_tids +}; + +HRESULT HTMLLinkElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem) +{ + HTMLLinkElement *ret; + + ret = heap_alloc_zero(sizeof(*ret)); + if(!ret) + return E_OUTOFMEMORY; + + ret->IHTMLLinkElement_iface.lpVtbl = &HTMLLinkElementVtbl; + ret->element.node.vtbl = &HTMLLinkElementImplVtbl; + + HTMLElement_Init(&ret->element, doc, nselem, &HTMLLinkElement_dispex); + + *elem = &ret->element; + return S_OK; +} diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h index d199d21cf51..dc51565a570 100644 --- a/dlls/mshtml/mshtml_private.h +++ b/dlls/mshtml/mshtml_private.h @@ -92,6 +92,7 @@ typedef struct event_target_t event_target_t; XDIID(DispHTMLIFrame) \ XDIID(DispHTMLImg) \ XDIID(DispHTMLInputElement) \ + XDIID(DispHTMLLinkElement) \ XDIID(DispHTMLLocation) \ XDIID(DispHTMLMetaElement) \ XDIID(DispHTMLNavigator) \ @@ -151,6 +152,7 @@ typedef struct event_target_t event_target_t; XIID(IHTMLImageElementFactory) \ XIID(IHTMLImgElement) \ XIID(IHTMLInputElement) \ + XIID(IHTMLLinkElement) \ XIID(IHTMLLocation) \ XIID(IHTMLMetaElement) \ XIID(IHTMLMimeTypesCollection) \ @@ -879,6 +881,7 @@ HRESULT HTMLIFrame_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DE HRESULT HTMLStyleElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLImgElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLInputElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; +HRESULT HTMLLinkElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLMetaElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLObjectElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; HRESULT HTMLOptionElement_Create(HTMLDocumentNode*,nsIDOMHTMLElement*,HTMLElement**) DECLSPEC_HIDDEN; diff --git a/dlls/mshtml/tests/dom.c b/dlls/mshtml/tests/dom.c index d55c3d76964..7c84d0ce869 100644 --- a/dlls/mshtml/tests/dom.c +++ b/dlls/mshtml/tests/dom.c @@ -48,6 +48,7 @@ static const char range_test2_str[] = static const char elem_test_str[] = "test" "" + "" "text test" "link" "" @@ -119,7 +120,8 @@ typedef enum { ET_EMBED, ET_DIV, ET_META, - ET_NOSCRIPT + ET_NOSCRIPT, + ET_LINK } elem_type_t; static const IID * const none_iids[] = { @@ -320,6 +322,13 @@ static const IID * const meta_iids[] = { NULL }; +static const IID * const link_iids[] = { + ELEM_IFACES, + &IID_IHTMLLinkElement, + &IID_IConnectionPointContainer, + NULL +}; + static const IID * const object_iids[] = { ELEM_IFACES, &IID_IHTMLObjectElement, @@ -432,7 +441,8 @@ static const elem_type_info_t elem_type_infos[] = { {"EMBED", embed_iids, &DIID_DispHTMLEmbed}, {"DIV", elem_iids, NULL}, {"META", meta_iids, &DIID_DispHTMLMetaElement}, - {"NOSCRIPT", elem_iids, NULL /*&DIID_DispHTMLNoShowElement*/} + {"NOSCRIPT", elem_iids, NULL /*&DIID_DispHTMLNoShowElement*/}, + {"LINK", link_iids, &DIID_DispHTMLLinkElement} }; static const char *dbgstr_guid(REFIID riid) @@ -5277,6 +5287,7 @@ static void test_elems(IHTMLDocument2 *doc) ET_TITLE, ET_STYLE, ET_META, + ET_LINK, ET_BODY, ET_COMMENT, ET_A,