mshtml/tests: Skip some tests if native XMLHTTP support is missing or disabled.
[wine.git] / dlls / mshtml / htmlhead.c
blob7b77cb032d0589ac8d622cbe4fa74e468901ca31
1 /*
2 * Copyright 2011 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
27 #include "mshtmdid.h"
29 #include "wine/debug.h"
31 #include "mshtml_private.h"
33 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
35 struct HTMLTitleElement {
36 HTMLElement element;
38 IHTMLTitleElement IHTMLTitleElement_iface;
41 static inline HTMLTitleElement *impl_from_IHTMLTitleElement(IHTMLTitleElement *iface)
43 return CONTAINING_RECORD(iface, HTMLTitleElement, IHTMLTitleElement_iface);
46 static HRESULT WINAPI HTMLTitleElement_QueryInterface(IHTMLTitleElement *iface,
47 REFIID riid, void **ppv)
49 HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
51 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
54 static ULONG WINAPI HTMLTitleElement_AddRef(IHTMLTitleElement *iface)
56 HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
58 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
61 static ULONG WINAPI HTMLTitleElement_Release(IHTMLTitleElement *iface)
63 HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
65 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
68 static HRESULT WINAPI HTMLTitleElement_GetTypeInfoCount(IHTMLTitleElement *iface, UINT *pctinfo)
70 HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
72 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
75 static HRESULT WINAPI HTMLTitleElement_GetTypeInfo(IHTMLTitleElement *iface, UINT iTInfo,
76 LCID lcid, ITypeInfo **ppTInfo)
78 HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
80 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
81 ppTInfo);
84 static HRESULT WINAPI HTMLTitleElement_GetIDsOfNames(IHTMLTitleElement *iface, REFIID riid,
85 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
87 HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
89 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
90 cNames, lcid, rgDispId);
93 static HRESULT WINAPI HTMLTitleElement_Invoke(IHTMLTitleElement *iface, DISPID dispIdMember,
94 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
95 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
97 HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
99 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
100 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
103 static HRESULT WINAPI HTMLTitleElement_put_text(IHTMLTitleElement *iface, BSTR v)
105 HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
106 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
107 return E_NOTIMPL;
110 static HRESULT WINAPI HTMLTitleElement_get_text(IHTMLTitleElement *iface, BSTR *p)
112 HTMLTitleElement *This = impl_from_IHTMLTitleElement(iface);
113 FIXME("(%p)->(%p)\n", This, p);
114 return E_NOTIMPL;
117 static const IHTMLTitleElementVtbl HTMLTitleElementVtbl = {
118 HTMLTitleElement_QueryInterface,
119 HTMLTitleElement_AddRef,
120 HTMLTitleElement_Release,
121 HTMLTitleElement_GetTypeInfoCount,
122 HTMLTitleElement_GetTypeInfo,
123 HTMLTitleElement_GetIDsOfNames,
124 HTMLTitleElement_Invoke,
125 HTMLTitleElement_put_text,
126 HTMLTitleElement_get_text
129 static inline HTMLTitleElement *HTMLTitleElement_from_HTMLDOMNode(HTMLDOMNode *iface)
131 return CONTAINING_RECORD(iface, HTMLTitleElement, element.node);
134 static HRESULT HTMLTitleElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
136 HTMLTitleElement *This = HTMLTitleElement_from_HTMLDOMNode(iface);
138 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
140 if(IsEqualGUID(&IID_IHTMLTitleElement, riid))
141 *ppv = &This->IHTMLTitleElement_iface;
142 else
143 return HTMLElement_QI(&This->element.node, riid, ppv);
145 IUnknown_AddRef((IUnknown*)*ppv);
146 return S_OK;
149 static void HTMLTitleElement_destructor(HTMLDOMNode *iface)
151 HTMLTitleElement *This = HTMLTitleElement_from_HTMLDOMNode(iface);
153 HTMLElement_destructor(&This->element.node);
156 static const NodeImplVtbl HTMLTitleElementImplVtbl = {
157 &CLSID_HTMLTitleElement,
158 HTMLTitleElement_QI,
159 HTMLTitleElement_destructor,
160 HTMLElement_cpc,
161 HTMLElement_clone,
162 HTMLElement_handle_event,
163 HTMLElement_get_attr_col
166 static const tid_t HTMLTitleElement_iface_tids[] = {
167 HTMLELEMENT_TIDS,
168 IHTMLTitleElement_tid,
171 static dispex_static_data_t HTMLTitleElement_dispex = {
172 NULL,
173 DispHTMLTitleElement_tid,
174 HTMLTitleElement_iface_tids,
175 HTMLElement_init_dispex_info
178 HRESULT HTMLTitleElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
180 HTMLTitleElement *ret;
182 ret = heap_alloc_zero(sizeof(*ret));
183 if(!ret)
184 return E_OUTOFMEMORY;
186 ret->IHTMLTitleElement_iface.lpVtbl = &HTMLTitleElementVtbl;
187 ret->element.node.vtbl = &HTMLTitleElementImplVtbl;
189 HTMLElement_Init(&ret->element, doc, nselem, &HTMLTitleElement_dispex);
191 *elem = &ret->element;
192 return S_OK;
195 struct HTMLHtmlElement {
196 HTMLElement element;
198 IHTMLHtmlElement IHTMLHtmlElement_iface;
201 static inline HTMLHtmlElement *impl_from_IHTMLHtmlElement(IHTMLHtmlElement *iface)
203 return CONTAINING_RECORD(iface, HTMLHtmlElement, IHTMLHtmlElement_iface);
206 static HRESULT WINAPI HTMLHtmlElement_QueryInterface(IHTMLHtmlElement *iface,
207 REFIID riid, void **ppv)
209 HTMLHtmlElement *This = impl_from_IHTMLHtmlElement(iface);
211 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
214 static ULONG WINAPI HTMLHtmlElement_AddRef(IHTMLHtmlElement *iface)
216 HTMLHtmlElement *This = impl_from_IHTMLHtmlElement(iface);
218 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
221 static ULONG WINAPI HTMLHtmlElement_Release(IHTMLHtmlElement *iface)
223 HTMLHtmlElement *This = impl_from_IHTMLHtmlElement(iface);
225 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
228 static HRESULT WINAPI HTMLHtmlElement_GetTypeInfoCount(IHTMLHtmlElement *iface, UINT *pctinfo)
230 HTMLHtmlElement *This = impl_from_IHTMLHtmlElement(iface);
232 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
235 static HRESULT WINAPI HTMLHtmlElement_GetTypeInfo(IHTMLHtmlElement *iface, UINT iTInfo,
236 LCID lcid, ITypeInfo **ppTInfo)
238 HTMLHtmlElement *This = impl_from_IHTMLHtmlElement(iface);
240 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
241 ppTInfo);
244 static HRESULT WINAPI HTMLHtmlElement_GetIDsOfNames(IHTMLHtmlElement *iface, REFIID riid,
245 LPOLESTR *rgszNames, UINT cNames,
246 LCID lcid, DISPID *rgDispId)
248 HTMLHtmlElement *This = impl_from_IHTMLHtmlElement(iface);
250 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
251 cNames, lcid, rgDispId);
254 static HRESULT WINAPI HTMLHtmlElement_Invoke(IHTMLHtmlElement *iface, DISPID dispIdMember,
255 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
256 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
258 HTMLHtmlElement *This = impl_from_IHTMLHtmlElement(iface);
260 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
261 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
264 static HRESULT WINAPI HTMLHtmlElement_put_version(IHTMLHtmlElement *iface, BSTR v)
266 HTMLHtmlElement *This = impl_from_IHTMLHtmlElement(iface);
267 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
268 return E_NOTIMPL;
271 static HRESULT WINAPI HTMLHtmlElement_get_version(IHTMLHtmlElement *iface, BSTR *p)
273 HTMLHtmlElement *This = impl_from_IHTMLHtmlElement(iface);
274 FIXME("(%p)->(%p)\n", This, p);
275 return E_NOTIMPL;
278 static const IHTMLHtmlElementVtbl HTMLHtmlElementVtbl = {
279 HTMLHtmlElement_QueryInterface,
280 HTMLHtmlElement_AddRef,
281 HTMLHtmlElement_Release,
282 HTMLHtmlElement_GetTypeInfoCount,
283 HTMLHtmlElement_GetTypeInfo,
284 HTMLHtmlElement_GetIDsOfNames,
285 HTMLHtmlElement_Invoke,
286 HTMLHtmlElement_put_version,
287 HTMLHtmlElement_get_version
290 static inline HTMLHtmlElement *HTMLHtmlElement_from_HTMLDOMNode(HTMLDOMNode *iface)
292 return CONTAINING_RECORD(iface, HTMLHtmlElement, element.node);
295 static HRESULT HTMLHtmlElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
297 HTMLHtmlElement *This = HTMLHtmlElement_from_HTMLDOMNode(iface);
299 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
301 if(IsEqualGUID(&IID_IHTMLHtmlElement, riid))
302 *ppv = &This->IHTMLHtmlElement_iface;
303 else
304 return HTMLElement_QI(&This->element.node, riid, ppv);
306 IUnknown_AddRef((IUnknown*)*ppv);
307 return S_OK;
310 static void HTMLHtmlElement_destructor(HTMLDOMNode *iface)
312 HTMLHtmlElement *This = HTMLHtmlElement_from_HTMLDOMNode(iface);
314 HTMLElement_destructor(&This->element.node);
317 static BOOL HTMLHtmlElement_is_settable(HTMLDOMNode *iface, DISPID dispid)
319 switch(dispid) {
320 case DISPID_IHTMLELEMENT_OUTERTEXT:
321 return FALSE;
322 default:
323 return TRUE;
327 static const NodeImplVtbl HTMLHtmlElementImplVtbl = {
328 &CLSID_HTMLHtmlElement,
329 HTMLHtmlElement_QI,
330 HTMLHtmlElement_destructor,
331 HTMLElement_cpc,
332 HTMLElement_clone,
333 HTMLElement_handle_event,
334 HTMLElement_get_attr_col,
335 NULL,
336 NULL,
337 NULL,
338 NULL,
339 NULL,
340 NULL,
341 NULL,
342 NULL,
343 NULL,
344 NULL,
345 NULL,
346 HTMLHtmlElement_is_settable
349 static const tid_t HTMLHtmlElement_iface_tids[] = {
350 HTMLELEMENT_TIDS,
351 IHTMLHtmlElement_tid,
354 static dispex_static_data_t HTMLHtmlElement_dispex = {
355 NULL,
356 DispHTMLHtmlElement_tid,
357 HTMLHtmlElement_iface_tids,
358 HTMLElement_init_dispex_info
361 HRESULT HTMLHtmlElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
363 HTMLHtmlElement *ret;
365 ret = heap_alloc_zero(sizeof(*ret));
366 if(!ret)
367 return E_OUTOFMEMORY;
369 ret->IHTMLHtmlElement_iface.lpVtbl = &HTMLHtmlElementVtbl;
370 ret->element.node.vtbl = &HTMLHtmlElementImplVtbl;
372 HTMLElement_Init(&ret->element, doc, nselem, &HTMLHtmlElement_dispex);
374 *elem = &ret->element;
375 return S_OK;
378 struct HTMLHeadElement {
379 HTMLElement element;
381 IHTMLHeadElement IHTMLHeadElement_iface;
384 static inline HTMLHeadElement *impl_from_IHTMLHeadElement(IHTMLHeadElement *iface)
386 return CONTAINING_RECORD(iface, HTMLHeadElement, IHTMLHeadElement_iface);
389 static HRESULT WINAPI HTMLHeadElement_QueryInterface(IHTMLHeadElement *iface,
390 REFIID riid, void **ppv)
392 HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
394 return IHTMLDOMNode_QueryInterface(&This->element.node.IHTMLDOMNode_iface, riid, ppv);
397 static ULONG WINAPI HTMLHeadElement_AddRef(IHTMLHeadElement *iface)
399 HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
401 return IHTMLDOMNode_AddRef(&This->element.node.IHTMLDOMNode_iface);
404 static ULONG WINAPI HTMLHeadElement_Release(IHTMLHeadElement *iface)
406 HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
408 return IHTMLDOMNode_Release(&This->element.node.IHTMLDOMNode_iface);
411 static HRESULT WINAPI HTMLHeadElement_GetTypeInfoCount(IHTMLHeadElement *iface, UINT *pctinfo)
413 HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
415 return IDispatchEx_GetTypeInfoCount(&This->element.node.event_target.dispex.IDispatchEx_iface, pctinfo);
418 static HRESULT WINAPI HTMLHeadElement_GetTypeInfo(IHTMLHeadElement *iface, UINT iTInfo,
419 LCID lcid, ITypeInfo **ppTInfo)
421 HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
423 return IDispatchEx_GetTypeInfo(&This->element.node.event_target.dispex.IDispatchEx_iface, iTInfo, lcid,
424 ppTInfo);
427 static HRESULT WINAPI HTMLHeadElement_GetIDsOfNames(IHTMLHeadElement *iface, REFIID riid,
428 LPOLESTR *rgszNames, UINT cNames,
429 LCID lcid, DISPID *rgDispId)
431 HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
433 return IDispatchEx_GetIDsOfNames(&This->element.node.event_target.dispex.IDispatchEx_iface, riid, rgszNames,
434 cNames, lcid, rgDispId);
437 static HRESULT WINAPI HTMLHeadElement_Invoke(IHTMLHeadElement *iface, DISPID dispIdMember,
438 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
439 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
441 HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
443 return IDispatchEx_Invoke(&This->element.node.event_target.dispex.IDispatchEx_iface, dispIdMember, riid,
444 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
447 static HRESULT WINAPI HTMLHeadElement_put_profile(IHTMLHeadElement *iface, BSTR v)
449 HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
450 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
451 return E_NOTIMPL;
454 static HRESULT WINAPI HTMLHeadElement_get_profile(IHTMLHeadElement *iface, BSTR *p)
456 HTMLHeadElement *This = impl_from_IHTMLHeadElement(iface);
457 FIXME("(%p)->(%p)\n", This, p);
458 return E_NOTIMPL;
461 static const IHTMLHeadElementVtbl HTMLHeadElementVtbl = {
462 HTMLHeadElement_QueryInterface,
463 HTMLHeadElement_AddRef,
464 HTMLHeadElement_Release,
465 HTMLHeadElement_GetTypeInfoCount,
466 HTMLHeadElement_GetTypeInfo,
467 HTMLHeadElement_GetIDsOfNames,
468 HTMLHeadElement_Invoke,
469 HTMLHeadElement_put_profile,
470 HTMLHeadElement_get_profile
473 static inline HTMLHeadElement *impl_from_HTMLDOMNode(HTMLDOMNode *iface)
475 return CONTAINING_RECORD(iface, HTMLHeadElement, element.node);
478 static HRESULT HTMLHeadElement_QI(HTMLDOMNode *iface, REFIID riid, void **ppv)
480 HTMLHeadElement *This = impl_from_HTMLDOMNode(iface);
482 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
484 if(IsEqualGUID(&IID_IHTMLHeadElement, riid))
485 *ppv = &This->IHTMLHeadElement_iface;
486 else
487 return HTMLElement_QI(&This->element.node, riid, ppv);
489 IUnknown_AddRef((IUnknown*)*ppv);
490 return S_OK;
493 static void HTMLHeadElement_destructor(HTMLDOMNode *iface)
495 HTMLHeadElement *This = impl_from_HTMLDOMNode(iface);
497 HTMLElement_destructor(&This->element.node);
500 static const NodeImplVtbl HTMLHeadElementImplVtbl = {
501 &CLSID_HTMLHeadElement,
502 HTMLHeadElement_QI,
503 HTMLHeadElement_destructor,
504 HTMLElement_cpc,
505 HTMLElement_clone,
506 HTMLElement_handle_event,
507 HTMLElement_get_attr_col
510 static const tid_t HTMLHeadElement_iface_tids[] = {
511 HTMLELEMENT_TIDS,
512 IHTMLHeadElement_tid,
515 static dispex_static_data_t HTMLHeadElement_dispex = {
516 NULL,
517 DispHTMLHeadElement_tid,
518 HTMLHeadElement_iface_tids,
519 HTMLElement_init_dispex_info
522 HRESULT HTMLHeadElement_Create(HTMLDocumentNode *doc, nsIDOMHTMLElement *nselem, HTMLElement **elem)
524 HTMLHeadElement *ret;
526 ret = heap_alloc_zero(sizeof(*ret));
527 if(!ret)
528 return E_OUTOFMEMORY;
530 ret->IHTMLHeadElement_iface.lpVtbl = &HTMLHeadElementVtbl;
531 ret->element.node.vtbl = &HTMLHeadElementImplVtbl;
533 HTMLElement_Init(&ret->element, doc, nselem, &HTMLHeadElement_dispex);
535 *elem = &ret->element;
536 return S_OK;