wrc: Use ARRAY_SIZE instead of open coding it.
[wine.git] / dlls / mshtml / omnavigator.c
blobd3ffc29af4b74c1801f6e8af5af8b62c0e6e0219
1 /*
2 * Copyright 2008,2009 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"
28 #include "wine/debug.h"
30 #include "mshtml_private.h"
32 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
34 typedef struct HTMLPluginsCollection HTMLPluginsCollection;
35 typedef struct HTMLMimeTypesCollection HTMLMimeTypesCollection;
37 typedef struct {
38 DispatchEx dispex;
39 IOmNavigator IOmNavigator_iface;
41 LONG ref;
43 HTMLPluginsCollection *plugins;
44 HTMLMimeTypesCollection *mime_types;
45 } OmNavigator;
47 typedef struct {
48 DispatchEx dispex;
49 IHTMLDOMImplementation IHTMLDOMImplementation_iface;
50 IHTMLDOMImplementation2 IHTMLDOMImplementation2_iface;
52 LONG ref;
54 nsIDOMDOMImplementation *implementation;
55 GeckoBrowser *browser;
56 } HTMLDOMImplementation;
58 static inline HTMLDOMImplementation *impl_from_IHTMLDOMImplementation(IHTMLDOMImplementation *iface)
60 return CONTAINING_RECORD(iface, HTMLDOMImplementation, IHTMLDOMImplementation_iface);
63 static HRESULT WINAPI HTMLDOMImplementation_QueryInterface(IHTMLDOMImplementation *iface, REFIID riid, void **ppv)
65 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
67 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
69 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IHTMLDOMImplementation, riid)) {
70 *ppv = &This->IHTMLDOMImplementation_iface;
71 }else if(IsEqualGUID(&IID_IHTMLDOMImplementation2, riid)) {
72 *ppv = &This->IHTMLDOMImplementation2_iface;
73 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
74 return *ppv ? S_OK : E_NOINTERFACE;
75 }else {
76 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
77 *ppv = NULL;
78 return E_NOINTERFACE;
81 IUnknown_AddRef((IUnknown*)*ppv);
82 return S_OK;
85 static ULONG WINAPI HTMLDOMImplementation_AddRef(IHTMLDOMImplementation *iface)
87 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
88 LONG ref = InterlockedIncrement(&This->ref);
90 TRACE("(%p) ref=%ld\n", This, ref);
92 return ref;
95 static ULONG WINAPI HTMLDOMImplementation_Release(IHTMLDOMImplementation *iface)
97 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
98 LONG ref = InterlockedDecrement(&This->ref);
100 TRACE("(%p) ref=%ld\n", This, ref);
102 if(!ref) {
103 assert(!This->browser);
104 if(This->implementation)
105 nsIDOMDOMImplementation_Release(This->implementation);
106 release_dispex(&This->dispex);
107 heap_free(This);
110 return ref;
113 static HRESULT WINAPI HTMLDOMImplementation_GetTypeInfoCount(IHTMLDOMImplementation *iface, UINT *pctinfo)
115 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
117 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
120 static HRESULT WINAPI HTMLDOMImplementation_GetTypeInfo(IHTMLDOMImplementation *iface, UINT iTInfo,
121 LCID lcid, ITypeInfo **ppTInfo)
123 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
125 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
128 static HRESULT WINAPI HTMLDOMImplementation_GetIDsOfNames(IHTMLDOMImplementation *iface, REFIID riid,
129 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
131 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
133 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames,
134 cNames, lcid, rgDispId);
137 static HRESULT WINAPI HTMLDOMImplementation_Invoke(IHTMLDOMImplementation *iface, DISPID dispIdMember,
138 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
139 EXCEPINFO *pExcepInfo, UINT *puArgErr)
141 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
143 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid,
144 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
147 static HRESULT WINAPI HTMLDOMImplementation_hasFeature(IHTMLDOMImplementation *iface, BSTR feature,
148 VARIANT version, VARIANT_BOOL *pfHasFeature)
150 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation(iface);
152 FIXME("(%p)->(%s %s %p) returning false\n", This, debugstr_w(feature), debugstr_variant(&version), pfHasFeature);
154 *pfHasFeature = VARIANT_FALSE;
155 return S_OK;
158 static const IHTMLDOMImplementationVtbl HTMLDOMImplementationVtbl = {
159 HTMLDOMImplementation_QueryInterface,
160 HTMLDOMImplementation_AddRef,
161 HTMLDOMImplementation_Release,
162 HTMLDOMImplementation_GetTypeInfoCount,
163 HTMLDOMImplementation_GetTypeInfo,
164 HTMLDOMImplementation_GetIDsOfNames,
165 HTMLDOMImplementation_Invoke,
166 HTMLDOMImplementation_hasFeature
169 static inline HTMLDOMImplementation *impl_from_IHTMLDOMImplementation2(IHTMLDOMImplementation2 *iface)
171 return CONTAINING_RECORD(iface, HTMLDOMImplementation, IHTMLDOMImplementation2_iface);
174 static HRESULT WINAPI HTMLDOMImplementation2_QueryInterface(IHTMLDOMImplementation2 *iface, REFIID riid, void **ppv)
176 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
177 return IHTMLDOMImplementation_QueryInterface(&This->IHTMLDOMImplementation_iface, riid, ppv);
180 static ULONG WINAPI HTMLDOMImplementation2_AddRef(IHTMLDOMImplementation2 *iface)
182 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
183 return IHTMLDOMImplementation_AddRef(&This->IHTMLDOMImplementation_iface);
186 static ULONG WINAPI HTMLDOMImplementation2_Release(IHTMLDOMImplementation2 *iface)
188 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
189 return IHTMLDOMImplementation_Release(&This->IHTMLDOMImplementation_iface);
192 static HRESULT WINAPI HTMLDOMImplementation2_GetTypeInfoCount(IHTMLDOMImplementation2 *iface, UINT *pctinfo)
194 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
195 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
198 static HRESULT WINAPI HTMLDOMImplementation2_GetTypeInfo(IHTMLDOMImplementation2 *iface, UINT iTInfo,
199 LCID lcid, ITypeInfo **ppTInfo)
201 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
202 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
205 static HRESULT WINAPI HTMLDOMImplementation2_GetIDsOfNames(IHTMLDOMImplementation2 *iface, REFIID riid,
206 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
208 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
209 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames,
210 cNames, lcid, rgDispId);
213 static HRESULT WINAPI HTMLDOMImplementation2_Invoke(IHTMLDOMImplementation2 *iface, DISPID dispIdMember,
214 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
215 EXCEPINFO *pExcepInfo, UINT *puArgErr)
217 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
218 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid,
219 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
222 static HRESULT WINAPI HTMLDOMImplementation2_createDocumentType(IHTMLDOMImplementation2 *iface, BSTR name,
223 VARIANT *public_id, VARIANT *system_id, IDOMDocumentType **new_type)
225 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
226 FIXME("(%p)->(%s %s %s %p)\n", This, debugstr_w(name), debugstr_variant(public_id),
227 debugstr_variant(system_id), new_type);
228 return E_NOTIMPL;
231 static HRESULT WINAPI HTMLDOMImplementation2_createDocument(IHTMLDOMImplementation2 *iface, VARIANT *ns,
232 VARIANT *tag_name, IDOMDocumentType *document_type, IHTMLDocument7 **new_document)
234 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
235 FIXME("(%p)->(%s %s %p %p)\n", This, debugstr_variant(ns), debugstr_variant(tag_name),
236 document_type, new_document);
237 return E_NOTIMPL;
240 static HRESULT WINAPI HTMLDOMImplementation2_createHTMLDocument(IHTMLDOMImplementation2 *iface, BSTR title,
241 IHTMLDocument7 **new_document)
243 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
244 HTMLDocumentNode *new_document_node;
245 nsIDOMHTMLDocument *html_doc;
246 nsIDOMDocument *doc;
247 nsAString title_str;
248 nsresult nsres;
249 HRESULT hres;
251 FIXME("(%p)->(%s %p)\n", This, debugstr_w(title), new_document);
253 if(!This->browser)
254 return E_UNEXPECTED;
256 nsAString_InitDepend(&title_str, title);
257 nsres = nsIDOMDOMImplementation_CreateHTMLDocument(This->implementation, &title_str, &doc);
258 nsAString_Finish(&title_str);
259 if(NS_FAILED(nsres)) {
260 ERR("CreateHTMLDocument failed: %08lx\n", nsres);
261 return E_FAIL;
264 nsres = nsIDOMDocument_QueryInterface(doc, &IID_nsIDOMHTMLDocument, (void**)&html_doc);
265 nsIDOMDocument_Release(doc);
266 assert(nsres == NS_OK);
268 hres = create_document_node(html_doc, This->browser, NULL, dispex_compat_mode(&This->dispex), &new_document_node);
269 nsIDOMHTMLDocument_Release(html_doc);
270 if(FAILED(hres))
271 return hres;
273 *new_document = &new_document_node->IHTMLDocument7_iface;
274 return S_OK;
277 static HRESULT WINAPI HTMLDOMImplementation2_hasFeature(IHTMLDOMImplementation2 *iface, BSTR feature,
278 VARIANT version, VARIANT_BOOL *pfHasFeature)
280 HTMLDOMImplementation *This = impl_from_IHTMLDOMImplementation2(iface);
282 FIXME("(%p)->(%s %s %p) returning false\n", This, debugstr_w(feature), debugstr_variant(&version), pfHasFeature);
284 *pfHasFeature = VARIANT_FALSE;
285 return S_OK;
288 static const IHTMLDOMImplementation2Vtbl HTMLDOMImplementation2Vtbl = {
289 HTMLDOMImplementation2_QueryInterface,
290 HTMLDOMImplementation2_AddRef,
291 HTMLDOMImplementation2_Release,
292 HTMLDOMImplementation2_GetTypeInfoCount,
293 HTMLDOMImplementation2_GetTypeInfo,
294 HTMLDOMImplementation2_GetIDsOfNames,
295 HTMLDOMImplementation2_Invoke,
296 HTMLDOMImplementation2_createDocumentType,
297 HTMLDOMImplementation2_createDocument,
298 HTMLDOMImplementation2_createHTMLDocument,
299 HTMLDOMImplementation2_hasFeature
302 static void HTMLDOMImplementation_init_dispex_info(dispex_data_t *info, compat_mode_t compat_mode)
304 if(compat_mode >= COMPAT_MODE_IE9)
305 dispex_info_add_interface(info, IHTMLDOMImplementation2_tid, NULL);
308 static const tid_t HTMLDOMImplementation_iface_tids[] = {
309 IHTMLDOMImplementation_tid,
312 static dispex_static_data_t HTMLDOMImplementation_dispex = {
313 L"DOMImplementation",
314 NULL,
315 DispHTMLDOMImplementation_tid,
316 HTMLDOMImplementation_iface_tids,
317 HTMLDOMImplementation_init_dispex_info
320 HRESULT create_dom_implementation(HTMLDocumentNode *doc_node, IHTMLDOMImplementation **ret)
322 HTMLDOMImplementation *dom_implementation;
323 nsresult nsres;
325 if(!doc_node->browser)
326 return E_UNEXPECTED;
328 dom_implementation = heap_alloc_zero(sizeof(*dom_implementation));
329 if(!dom_implementation)
330 return E_OUTOFMEMORY;
332 dom_implementation->IHTMLDOMImplementation_iface.lpVtbl = &HTMLDOMImplementationVtbl;
333 dom_implementation->IHTMLDOMImplementation2_iface.lpVtbl = &HTMLDOMImplementation2Vtbl;
334 dom_implementation->ref = 1;
335 dom_implementation->browser = doc_node->browser;
337 init_dispatch(&dom_implementation->dispex, (IUnknown*)&dom_implementation->IHTMLDOMImplementation_iface,
338 &HTMLDOMImplementation_dispex, doc_node->document_mode);
340 nsres = nsIDOMHTMLDocument_GetImplementation(doc_node->nsdoc, &dom_implementation->implementation);
341 if(NS_FAILED(nsres)) {
342 ERR("GetDOMImplementation failed: %08lx\n", nsres);
343 IHTMLDOMImplementation_Release(&dom_implementation->IHTMLDOMImplementation_iface);
344 return E_FAIL;
347 *ret = &dom_implementation->IHTMLDOMImplementation_iface;
348 return S_OK;
351 void detach_dom_implementation(IHTMLDOMImplementation *iface)
353 HTMLDOMImplementation *dom_implementation = impl_from_IHTMLDOMImplementation(iface);
354 dom_implementation->browser = NULL;
357 typedef struct {
358 DispatchEx dispex;
359 IHTMLScreen IHTMLScreen_iface;
361 LONG ref;
362 } HTMLScreen;
364 static inline HTMLScreen *impl_from_IHTMLScreen(IHTMLScreen *iface)
366 return CONTAINING_RECORD(iface, HTMLScreen, IHTMLScreen_iface);
369 static HRESULT WINAPI HTMLScreen_QueryInterface(IHTMLScreen *iface, REFIID riid, void **ppv)
371 HTMLScreen *This = impl_from_IHTMLScreen(iface);
373 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
375 if(IsEqualGUID(&IID_IUnknown, riid)) {
376 *ppv = &This->IHTMLScreen_iface;
377 }else if(IsEqualGUID(&IID_IHTMLScreen, riid)) {
378 *ppv = &This->IHTMLScreen_iface;
379 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
380 return *ppv ? S_OK : E_NOINTERFACE;
381 }else {
382 *ppv = NULL;
383 WARN("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
384 return E_NOINTERFACE;
387 IUnknown_AddRef((IUnknown*)*ppv);
388 return S_OK;
391 static ULONG WINAPI HTMLScreen_AddRef(IHTMLScreen *iface)
393 HTMLScreen *This = impl_from_IHTMLScreen(iface);
394 LONG ref = InterlockedIncrement(&This->ref);
396 TRACE("(%p) ref=%ld\n", This, ref);
398 return ref;
401 static ULONG WINAPI HTMLScreen_Release(IHTMLScreen *iface)
403 HTMLScreen *This = impl_from_IHTMLScreen(iface);
404 LONG ref = InterlockedDecrement(&This->ref);
406 TRACE("(%p) ref=%ld\n", This, ref);
408 if(!ref) {
409 release_dispex(&This->dispex);
410 heap_free(This);
413 return ref;
416 static HRESULT WINAPI HTMLScreen_GetTypeInfoCount(IHTMLScreen *iface, UINT *pctinfo)
418 HTMLScreen *This = impl_from_IHTMLScreen(iface);
419 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
422 static HRESULT WINAPI HTMLScreen_GetTypeInfo(IHTMLScreen *iface, UINT iTInfo,
423 LCID lcid, ITypeInfo **ppTInfo)
425 HTMLScreen *This = impl_from_IHTMLScreen(iface);
426 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
429 static HRESULT WINAPI HTMLScreen_GetIDsOfNames(IHTMLScreen *iface, REFIID riid,
430 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
432 HTMLScreen *This = impl_from_IHTMLScreen(iface);
433 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
434 lcid, rgDispId);
437 static HRESULT WINAPI HTMLScreen_Invoke(IHTMLScreen *iface, DISPID dispIdMember,
438 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
439 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
441 HTMLScreen *This = impl_from_IHTMLScreen(iface);
442 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
443 pDispParams, pVarResult, pExcepInfo, puArgErr);
446 static HRESULT WINAPI HTMLScreen_get_colorDepth(IHTMLScreen *iface, LONG *p)
448 HTMLScreen *This = impl_from_IHTMLScreen(iface);
449 HDC hdc = GetDC(0);
451 TRACE("(%p)->(%p)\n", This, p);
453 *p = GetDeviceCaps(hdc, BITSPIXEL);
454 ReleaseDC(0, hdc);
455 return S_OK;
458 static HRESULT WINAPI HTMLScreen_put_bufferDepth(IHTMLScreen *iface, LONG v)
460 HTMLScreen *This = impl_from_IHTMLScreen(iface);
461 FIXME("(%p)->(%ld)\n", This, v);
462 return E_NOTIMPL;
465 static HRESULT WINAPI HTMLScreen_get_bufferDepth(IHTMLScreen *iface, LONG *p)
467 HTMLScreen *This = impl_from_IHTMLScreen(iface);
468 FIXME("(%p)->(%p)\n", This, p);
469 return E_NOTIMPL;
472 static HRESULT WINAPI HTMLScreen_get_width(IHTMLScreen *iface, LONG *p)
474 HTMLScreen *This = impl_from_IHTMLScreen(iface);
476 TRACE("(%p)->(%p)\n", This, p);
478 *p = GetSystemMetrics(SM_CXSCREEN);
479 return S_OK;
482 static HRESULT WINAPI HTMLScreen_get_height(IHTMLScreen *iface, LONG *p)
484 HTMLScreen *This = impl_from_IHTMLScreen(iface);
486 TRACE("(%p)->(%p)\n", This, p);
488 *p = GetSystemMetrics(SM_CYSCREEN);
489 return S_OK;
492 static HRESULT WINAPI HTMLScreen_put_updateInterval(IHTMLScreen *iface, LONG v)
494 HTMLScreen *This = impl_from_IHTMLScreen(iface);
495 FIXME("(%p)->(%ld)\n", This, v);
496 return E_NOTIMPL;
499 static HRESULT WINAPI HTMLScreen_get_updateInterval(IHTMLScreen *iface, LONG *p)
501 HTMLScreen *This = impl_from_IHTMLScreen(iface);
502 FIXME("(%p)->(%p)\n", This, p);
503 return E_NOTIMPL;
506 static HRESULT WINAPI HTMLScreen_get_availHeight(IHTMLScreen *iface, LONG *p)
508 HTMLScreen *This = impl_from_IHTMLScreen(iface);
509 RECT work_area;
511 TRACE("(%p)->(%p)\n", This, p);
513 if(!SystemParametersInfoW(SPI_GETWORKAREA, 0, &work_area, 0))
514 return E_FAIL;
516 *p = work_area.bottom-work_area.top;
517 return S_OK;
520 static HRESULT WINAPI HTMLScreen_get_availWidth(IHTMLScreen *iface, LONG *p)
522 HTMLScreen *This = impl_from_IHTMLScreen(iface);
523 RECT work_area;
525 TRACE("(%p)->(%p)\n", This, p);
527 if(!SystemParametersInfoW(SPI_GETWORKAREA, 0, &work_area, 0))
528 return E_FAIL;
530 *p = work_area.right-work_area.left;
531 return S_OK;
534 static HRESULT WINAPI HTMLScreen_get_fontSmoothingEnabled(IHTMLScreen *iface, VARIANT_BOOL *p)
536 HTMLScreen *This = impl_from_IHTMLScreen(iface);
537 FIXME("(%p)->(%p)\n", This, p);
538 return E_NOTIMPL;
541 static const IHTMLScreenVtbl HTMLSreenVtbl = {
542 HTMLScreen_QueryInterface,
543 HTMLScreen_AddRef,
544 HTMLScreen_Release,
545 HTMLScreen_GetTypeInfoCount,
546 HTMLScreen_GetTypeInfo,
547 HTMLScreen_GetIDsOfNames,
548 HTMLScreen_Invoke,
549 HTMLScreen_get_colorDepth,
550 HTMLScreen_put_bufferDepth,
551 HTMLScreen_get_bufferDepth,
552 HTMLScreen_get_width,
553 HTMLScreen_get_height,
554 HTMLScreen_put_updateInterval,
555 HTMLScreen_get_updateInterval,
556 HTMLScreen_get_availHeight,
557 HTMLScreen_get_availWidth,
558 HTMLScreen_get_fontSmoothingEnabled
561 static const tid_t HTMLScreen_iface_tids[] = {
562 IHTMLScreen_tid,
565 static dispex_static_data_t HTMLScreen_dispex = {
566 L"Screen",
567 NULL,
568 DispHTMLScreen_tid,
569 HTMLScreen_iface_tids
572 HRESULT create_html_screen(compat_mode_t compat_mode, IHTMLScreen **ret)
574 HTMLScreen *screen;
576 screen = heap_alloc_zero(sizeof(HTMLScreen));
577 if(!screen)
578 return E_OUTOFMEMORY;
580 screen->IHTMLScreen_iface.lpVtbl = &HTMLSreenVtbl;
581 screen->ref = 1;
583 init_dispatch(&screen->dispex, (IUnknown*)&screen->IHTMLScreen_iface, &HTMLScreen_dispex, compat_mode);
585 *ret = &screen->IHTMLScreen_iface;
586 return S_OK;
589 static inline OmHistory *impl_from_IOmHistory(IOmHistory *iface)
591 return CONTAINING_RECORD(iface, OmHistory, IOmHistory_iface);
594 static HRESULT WINAPI OmHistory_QueryInterface(IOmHistory *iface, REFIID riid, void **ppv)
596 OmHistory *This = impl_from_IOmHistory(iface);
598 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
600 if(IsEqualGUID(&IID_IUnknown, riid)) {
601 *ppv = &This->IOmHistory_iface;
602 }else if(IsEqualGUID(&IID_IOmHistory, riid)) {
603 *ppv = &This->IOmHistory_iface;
604 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
605 return *ppv ? S_OK : E_NOINTERFACE;
606 }else {
607 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
608 *ppv = NULL;
609 return E_NOINTERFACE;
612 IUnknown_AddRef((IUnknown*)*ppv);
613 return S_OK;
616 static ULONG WINAPI OmHistory_AddRef(IOmHistory *iface)
618 OmHistory *This = impl_from_IOmHistory(iface);
619 LONG ref = InterlockedIncrement(&This->ref);
621 TRACE("(%p) ref=%ld\n", This, ref);
623 return ref;
626 static ULONG WINAPI OmHistory_Release(IOmHistory *iface)
628 OmHistory *This = impl_from_IOmHistory(iface);
629 LONG ref = InterlockedDecrement(&This->ref);
631 TRACE("(%p) ref=%ld\n", This, ref);
633 if(!ref) {
634 release_dispex(&This->dispex);
635 heap_free(This);
638 return ref;
641 static HRESULT WINAPI OmHistory_GetTypeInfoCount(IOmHistory *iface, UINT *pctinfo)
643 OmHistory *This = impl_from_IOmHistory(iface);
644 FIXME("(%p)->(%p)\n", This, pctinfo);
645 return E_NOTIMPL;
648 static HRESULT WINAPI OmHistory_GetTypeInfo(IOmHistory *iface, UINT iTInfo,
649 LCID lcid, ITypeInfo **ppTInfo)
651 OmHistory *This = impl_from_IOmHistory(iface);
653 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
656 static HRESULT WINAPI OmHistory_GetIDsOfNames(IOmHistory *iface, REFIID riid, LPOLESTR *rgszNames, UINT cNames,
657 LCID lcid, DISPID *rgDispId)
659 OmHistory *This = impl_from_IOmHistory(iface);
661 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
662 lcid, rgDispId);
665 static HRESULT WINAPI OmHistory_Invoke(IOmHistory *iface, DISPID dispIdMember, REFIID riid, LCID lcid,
666 WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
668 OmHistory *This = impl_from_IOmHistory(iface);
670 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
671 pDispParams, pVarResult, pExcepInfo, puArgErr);
674 static HRESULT WINAPI OmHistory_get_length(IOmHistory *iface, short *p)
676 OmHistory *This = impl_from_IOmHistory(iface);
677 GeckoBrowser *browser = NULL;
679 TRACE("(%p)->(%p)\n", This, p);
681 if(This->window && This->window->base.outer_window)
682 browser = This->window->base.outer_window->browser;
684 *p = browser && browser->doc->travel_log
685 ? ITravelLog_CountEntries(browser->doc->travel_log, browser->doc->browser_service)
686 : 0;
687 return S_OK;
690 static HRESULT WINAPI OmHistory_back(IOmHistory *iface, VARIANT *pvargdistance)
692 OmHistory *This = impl_from_IOmHistory(iface);
693 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
694 return E_NOTIMPL;
697 static HRESULT WINAPI OmHistory_forward(IOmHistory *iface, VARIANT *pvargdistance)
699 OmHistory *This = impl_from_IOmHistory(iface);
700 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
701 return E_NOTIMPL;
704 static HRESULT WINAPI OmHistory_go(IOmHistory *iface, VARIANT *pvargdistance)
706 OmHistory *This = impl_from_IOmHistory(iface);
707 FIXME("(%p)->(%s)\n", This, debugstr_variant(pvargdistance));
708 return E_NOTIMPL;
711 static const IOmHistoryVtbl OmHistoryVtbl = {
712 OmHistory_QueryInterface,
713 OmHistory_AddRef,
714 OmHistory_Release,
715 OmHistory_GetTypeInfoCount,
716 OmHistory_GetTypeInfo,
717 OmHistory_GetIDsOfNames,
718 OmHistory_Invoke,
719 OmHistory_get_length,
720 OmHistory_back,
721 OmHistory_forward,
722 OmHistory_go
725 static const tid_t OmHistory_iface_tids[] = {
726 IOmHistory_tid,
729 static dispex_static_data_t OmHistory_dispex = {
730 L"History",
731 NULL,
732 DispHTMLHistory_tid,
733 OmHistory_iface_tids
737 HRESULT create_history(HTMLInnerWindow *window, OmHistory **ret)
739 OmHistory *history;
741 history = heap_alloc_zero(sizeof(*history));
742 if(!history)
743 return E_OUTOFMEMORY;
745 init_dispatch(&history->dispex, (IUnknown*)&history->IOmHistory_iface, &OmHistory_dispex,
746 dispex_compat_mode(&window->event_target.dispex));
747 history->IOmHistory_iface.lpVtbl = &OmHistoryVtbl;
748 history->ref = 1;
750 history->window = window;
752 *ret = history;
753 return S_OK;
756 struct HTMLPluginsCollection {
757 DispatchEx dispex;
758 IHTMLPluginsCollection IHTMLPluginsCollection_iface;
760 LONG ref;
762 OmNavigator *navigator;
765 static inline HTMLPluginsCollection *impl_from_IHTMLPluginsCollection(IHTMLPluginsCollection *iface)
767 return CONTAINING_RECORD(iface, HTMLPluginsCollection, IHTMLPluginsCollection_iface);
770 static HRESULT WINAPI HTMLPluginsCollection_QueryInterface(IHTMLPluginsCollection *iface, REFIID riid, void **ppv)
772 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
774 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
776 if(IsEqualGUID(&IID_IUnknown, riid)) {
777 *ppv = &This->IHTMLPluginsCollection_iface;
778 }else if(IsEqualGUID(&IID_IHTMLPluginsCollection, riid)) {
779 *ppv = &This->IHTMLPluginsCollection_iface;
780 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
781 return *ppv ? S_OK : E_NOINTERFACE;
782 }else {
783 *ppv = NULL;
784 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
785 return E_NOINTERFACE;
788 IUnknown_AddRef((IUnknown*)*ppv);
789 return S_OK;
792 static ULONG WINAPI HTMLPluginsCollection_AddRef(IHTMLPluginsCollection *iface)
794 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
795 LONG ref = InterlockedIncrement(&This->ref);
797 TRACE("(%p) ref=%ld\n", This, ref);
799 return ref;
802 static ULONG WINAPI HTMLPluginsCollection_Release(IHTMLPluginsCollection *iface)
804 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
805 LONG ref = InterlockedDecrement(&This->ref);
807 TRACE("(%p) ref=%ld\n", This, ref);
809 if(!ref) {
810 if(This->navigator)
811 This->navigator->plugins = NULL;
812 release_dispex(&This->dispex);
813 heap_free(This);
816 return ref;
819 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfoCount(IHTMLPluginsCollection *iface, UINT *pctinfo)
821 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
822 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
825 static HRESULT WINAPI HTMLPluginsCollection_GetTypeInfo(IHTMLPluginsCollection *iface, UINT iTInfo,
826 LCID lcid, ITypeInfo **ppTInfo)
828 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
829 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
832 static HRESULT WINAPI HTMLPluginsCollection_GetIDsOfNames(IHTMLPluginsCollection *iface, REFIID riid,
833 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
835 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
836 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
837 lcid, rgDispId);
840 static HRESULT WINAPI HTMLPluginsCollection_Invoke(IHTMLPluginsCollection *iface, DISPID dispIdMember,
841 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
842 EXCEPINFO *pExcepInfo, UINT *puArgErr)
844 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
845 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
846 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
849 static HRESULT WINAPI HTMLPluginsCollection_get_length(IHTMLPluginsCollection *iface, LONG *p)
851 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
853 TRACE("(%p)->(%p)\n", This, p);
855 /* IE always returns 0 here */
856 *p = 0;
857 return S_OK;
860 static HRESULT WINAPI HTMLPluginsCollection_refresh(IHTMLPluginsCollection *iface, VARIANT_BOOL reload)
862 HTMLPluginsCollection *This = impl_from_IHTMLPluginsCollection(iface);
864 TRACE("(%p)->(%x)\n", This, reload);
866 /* Nothing to do here. */
867 return S_OK;
870 static const IHTMLPluginsCollectionVtbl HTMLPluginsCollectionVtbl = {
871 HTMLPluginsCollection_QueryInterface,
872 HTMLPluginsCollection_AddRef,
873 HTMLPluginsCollection_Release,
874 HTMLPluginsCollection_GetTypeInfoCount,
875 HTMLPluginsCollection_GetTypeInfo,
876 HTMLPluginsCollection_GetIDsOfNames,
877 HTMLPluginsCollection_Invoke,
878 HTMLPluginsCollection_get_length,
879 HTMLPluginsCollection_refresh
882 static const tid_t HTMLPluginsCollection_iface_tids[] = {
883 IHTMLPluginsCollection_tid,
886 static dispex_static_data_t HTMLPluginsCollection_dispex = {
887 L"PluginArray",
888 NULL,
889 DispCPlugins_tid,
890 HTMLPluginsCollection_iface_tids
893 static HRESULT create_plugins_collection(OmNavigator *navigator, HTMLPluginsCollection **ret)
895 HTMLPluginsCollection *col;
897 col = heap_alloc_zero(sizeof(*col));
898 if(!col)
899 return E_OUTOFMEMORY;
901 col->IHTMLPluginsCollection_iface.lpVtbl = &HTMLPluginsCollectionVtbl;
902 col->ref = 1;
903 col->navigator = navigator;
905 init_dispatch(&col->dispex, (IUnknown*)&col->IHTMLPluginsCollection_iface,
906 &HTMLPluginsCollection_dispex, dispex_compat_mode(&navigator->dispex));
908 *ret = col;
909 return S_OK;
912 struct HTMLMimeTypesCollection {
913 DispatchEx dispex;
914 IHTMLMimeTypesCollection IHTMLMimeTypesCollection_iface;
916 LONG ref;
918 OmNavigator *navigator;
921 static inline HTMLMimeTypesCollection *impl_from_IHTMLMimeTypesCollection(IHTMLMimeTypesCollection *iface)
923 return CONTAINING_RECORD(iface, HTMLMimeTypesCollection, IHTMLMimeTypesCollection_iface);
926 static HRESULT WINAPI HTMLMimeTypesCollection_QueryInterface(IHTMLMimeTypesCollection *iface, REFIID riid, void **ppv)
928 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
930 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
932 if(IsEqualGUID(&IID_IUnknown, riid)) {
933 *ppv = &This->IHTMLMimeTypesCollection_iface;
934 }else if(IsEqualGUID(&IID_IHTMLMimeTypesCollection, riid)) {
935 *ppv = &This->IHTMLMimeTypesCollection_iface;
936 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
937 return *ppv ? S_OK : E_NOINTERFACE;
938 }else {
939 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
940 *ppv = NULL;
941 return E_NOINTERFACE;
944 IUnknown_AddRef((IUnknown*)*ppv);
945 return S_OK;
948 static ULONG WINAPI HTMLMimeTypesCollection_AddRef(IHTMLMimeTypesCollection *iface)
950 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
951 LONG ref = InterlockedIncrement(&This->ref);
953 TRACE("(%p) ref=%ld\n", This, ref);
955 return ref;
958 static ULONG WINAPI HTMLMimeTypesCollection_Release(IHTMLMimeTypesCollection *iface)
960 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
961 LONG ref = InterlockedDecrement(&This->ref);
963 TRACE("(%p) ref=%ld\n", This, ref);
965 if(!ref) {
966 if(This->navigator)
967 This->navigator->mime_types = NULL;
968 release_dispex(&This->dispex);
969 heap_free(This);
972 return ref;
975 static HRESULT WINAPI HTMLMimeTypesCollection_GetTypeInfoCount(IHTMLMimeTypesCollection *iface, UINT *pctinfo)
977 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
978 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
981 static HRESULT WINAPI HTMLMimeTypesCollection_GetTypeInfo(IHTMLMimeTypesCollection *iface, UINT iTInfo,
982 LCID lcid, ITypeInfo **ppTInfo)
984 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
985 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
988 static HRESULT WINAPI HTMLMimeTypesCollection_GetIDsOfNames(IHTMLMimeTypesCollection *iface, REFIID riid,
989 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
991 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
992 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
993 lcid, rgDispId);
996 static HRESULT WINAPI HTMLMimeTypesCollection_Invoke(IHTMLMimeTypesCollection *iface, DISPID dispIdMember,
997 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
998 EXCEPINFO *pExcepInfo, UINT *puArgErr)
1000 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
1001 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid,
1002 wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1005 static HRESULT WINAPI HTMLMimeTypesCollection_get_length(IHTMLMimeTypesCollection *iface, LONG *p)
1007 HTMLMimeTypesCollection *This = impl_from_IHTMLMimeTypesCollection(iface);
1009 TRACE("(%p)->(%p)\n", This, p);
1011 /* This is just a stub for compatibility with other browser in IE */
1012 *p = 0;
1013 return S_OK;
1016 static const IHTMLMimeTypesCollectionVtbl HTMLMimeTypesCollectionVtbl = {
1017 HTMLMimeTypesCollection_QueryInterface,
1018 HTMLMimeTypesCollection_AddRef,
1019 HTMLMimeTypesCollection_Release,
1020 HTMLMimeTypesCollection_GetTypeInfoCount,
1021 HTMLMimeTypesCollection_GetTypeInfo,
1022 HTMLMimeTypesCollection_GetIDsOfNames,
1023 HTMLMimeTypesCollection_Invoke,
1024 HTMLMimeTypesCollection_get_length
1027 static const tid_t HTMLMimeTypesCollection_iface_tids[] = {
1028 IHTMLMimeTypesCollection_tid,
1031 static dispex_static_data_t HTMLMimeTypesCollection_dispex = {
1032 L"MimeTypeArray",
1033 NULL,
1034 IHTMLMimeTypesCollection_tid,
1035 HTMLMimeTypesCollection_iface_tids
1038 static HRESULT create_mime_types_collection(OmNavigator *navigator, HTMLMimeTypesCollection **ret)
1040 HTMLMimeTypesCollection *col;
1042 col = heap_alloc_zero(sizeof(*col));
1043 if(!col)
1044 return E_OUTOFMEMORY;
1046 col->IHTMLMimeTypesCollection_iface.lpVtbl = &HTMLMimeTypesCollectionVtbl;
1047 col->ref = 1;
1048 col->navigator = navigator;
1050 init_dispatch(&col->dispex, (IUnknown*)&col->IHTMLMimeTypesCollection_iface,
1051 &HTMLMimeTypesCollection_dispex, dispex_compat_mode(&navigator->dispex));
1053 *ret = col;
1054 return S_OK;
1057 static inline OmNavigator *impl_from_IOmNavigator(IOmNavigator *iface)
1059 return CONTAINING_RECORD(iface, OmNavigator, IOmNavigator_iface);
1062 static HRESULT WINAPI OmNavigator_QueryInterface(IOmNavigator *iface, REFIID riid, void **ppv)
1064 OmNavigator *This = impl_from_IOmNavigator(iface);
1066 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
1068 if(IsEqualGUID(&IID_IUnknown, riid)) {
1069 *ppv = &This->IOmNavigator_iface;
1070 }else if(IsEqualGUID(&IID_IOmNavigator, riid)) {
1071 *ppv = &This->IOmNavigator_iface;
1072 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1073 return *ppv ? S_OK : E_NOINTERFACE;
1074 }else {
1075 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
1076 *ppv = NULL;
1077 return E_NOINTERFACE;
1080 IUnknown_AddRef((IUnknown*)*ppv);
1081 return S_OK;
1084 static ULONG WINAPI OmNavigator_AddRef(IOmNavigator *iface)
1086 OmNavigator *This = impl_from_IOmNavigator(iface);
1087 LONG ref = InterlockedIncrement(&This->ref);
1089 TRACE("(%p) ref=%ld\n", This, ref);
1091 return ref;
1094 static ULONG WINAPI OmNavigator_Release(IOmNavigator *iface)
1096 OmNavigator *This = impl_from_IOmNavigator(iface);
1097 LONG ref = InterlockedDecrement(&This->ref);
1099 TRACE("(%p) ref=%ld\n", This, ref);
1101 if(!ref) {
1102 if(This->plugins)
1103 This->plugins->navigator = NULL;
1104 if(This->mime_types)
1105 This->mime_types->navigator = NULL;
1106 release_dispex(&This->dispex);
1107 heap_free(This);
1110 return ref;
1113 static HRESULT WINAPI OmNavigator_GetTypeInfoCount(IOmNavigator *iface, UINT *pctinfo)
1115 OmNavigator *This = impl_from_IOmNavigator(iface);
1116 FIXME("(%p)->(%p)\n", This, pctinfo);
1117 return E_NOTIMPL;
1120 static HRESULT WINAPI OmNavigator_GetTypeInfo(IOmNavigator *iface, UINT iTInfo,
1121 LCID lcid, ITypeInfo **ppTInfo)
1123 OmNavigator *This = impl_from_IOmNavigator(iface);
1125 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1128 static HRESULT WINAPI OmNavigator_GetIDsOfNames(IOmNavigator *iface, REFIID riid,
1129 LPOLESTR *rgszNames, UINT cNames,
1130 LCID lcid, DISPID *rgDispId)
1132 OmNavigator *This = impl_from_IOmNavigator(iface);
1134 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1135 lcid, rgDispId);
1138 static HRESULT WINAPI OmNavigator_Invoke(IOmNavigator *iface, DISPID dispIdMember,
1139 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1140 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1142 OmNavigator *This = impl_from_IOmNavigator(iface);
1144 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1145 pDispParams, pVarResult, pExcepInfo, puArgErr);
1148 static HRESULT WINAPI OmNavigator_get_appCodeName(IOmNavigator *iface, BSTR *p)
1150 OmNavigator *This = impl_from_IOmNavigator(iface);
1152 TRACE("(%p)->(%p)\n", This, p);
1154 *p = SysAllocString(L"Mozilla");
1155 return S_OK;
1158 static HRESULT WINAPI OmNavigator_get_appName(IOmNavigator *iface, BSTR *p)
1160 OmNavigator *This = impl_from_IOmNavigator(iface);
1162 TRACE("(%p)->(%p)\n", This, p);
1164 *p = SysAllocString(dispex_compat_mode(&This->dispex) == COMPAT_MODE_IE11
1165 ? L"Netscape" : L"Microsoft Internet Explorer");
1166 if(!*p)
1167 return E_OUTOFMEMORY;
1169 return S_OK;
1172 /* undocumented, added in IE8 */
1173 extern HRESULT WINAPI MapBrowserEmulationModeToUserAgent(const void*,WCHAR**);
1175 /* Retrieves allocated user agent via CoTaskMemAlloc */
1176 static HRESULT get_user_agent(OmNavigator *navigator, WCHAR **user_agent)
1178 DWORD version;
1180 switch(dispex_compat_mode(&navigator->dispex)) {
1181 case COMPAT_MODE_QUIRKS:
1182 case COMPAT_MODE_IE5:
1183 case COMPAT_MODE_IE7:
1184 version = 7;
1185 break;
1186 case COMPAT_MODE_IE8:
1187 version = 8;
1188 break;
1189 case COMPAT_MODE_IE9:
1190 version = 9;
1191 break;
1192 case COMPAT_MODE_IE10:
1193 version = 10;
1194 break;
1195 case COMPAT_MODE_IE11:
1196 version = 11;
1197 break;
1198 default:
1199 assert(0);
1200 return E_FAIL;
1202 return MapBrowserEmulationModeToUserAgent(&version, user_agent);
1205 static HRESULT WINAPI OmNavigator_get_appVersion(IOmNavigator *iface, BSTR *p)
1207 OmNavigator *This = impl_from_IOmNavigator(iface);
1208 WCHAR *user_agent;
1209 unsigned len;
1210 HRESULT hres;
1211 const unsigned skip_prefix = 8; /* strlen("Mozilla/") */
1213 TRACE("(%p)->(%p)\n", This, p);
1215 hres = get_user_agent(This, &user_agent);
1216 if(FAILED(hres))
1217 return hres;
1218 len = wcslen(user_agent);
1220 if(len < skip_prefix) {
1221 CoTaskMemFree(user_agent);
1222 *p = NULL;
1223 return S_OK;
1226 *p = SysAllocStringLen(user_agent + skip_prefix, len - skip_prefix);
1227 CoTaskMemFree(user_agent);
1228 return *p ? S_OK : E_OUTOFMEMORY;
1231 static HRESULT WINAPI OmNavigator_get_userAgent(IOmNavigator *iface, BSTR *p)
1233 OmNavigator *This = impl_from_IOmNavigator(iface);
1234 WCHAR *user_agent;
1235 HRESULT hres;
1237 TRACE("(%p)->(%p)\n", This, p);
1239 hres = get_user_agent(This, &user_agent);
1240 if(FAILED(hres))
1241 return hres;
1243 *p = SysAllocString(user_agent);
1244 CoTaskMemFree(user_agent);
1245 return *p ? S_OK : E_OUTOFMEMORY;
1248 static HRESULT WINAPI OmNavigator_javaEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
1250 OmNavigator *This = impl_from_IOmNavigator(iface);
1252 FIXME("(%p)->(%p) semi-stub\n", This, enabled);
1254 *enabled = VARIANT_TRUE;
1255 return S_OK;
1258 static HRESULT WINAPI OmNavigator_taintEnabled(IOmNavigator *iface, VARIANT_BOOL *enabled)
1260 OmNavigator *This = impl_from_IOmNavigator(iface);
1261 FIXME("(%p)->(%p)\n", This, enabled);
1262 return E_NOTIMPL;
1265 static HRESULT WINAPI OmNavigator_get_mimeTypes(IOmNavigator *iface, IHTMLMimeTypesCollection **p)
1267 OmNavigator *This = impl_from_IOmNavigator(iface);
1269 TRACE("(%p)->(%p)\n", This, p);
1271 if(!This->mime_types) {
1272 HRESULT hres;
1274 hres = create_mime_types_collection(This, &This->mime_types);
1275 if(FAILED(hres))
1276 return hres;
1277 }else {
1278 IHTMLMimeTypesCollection_AddRef(&This->mime_types->IHTMLMimeTypesCollection_iface);
1281 *p = &This->mime_types->IHTMLMimeTypesCollection_iface;
1282 return S_OK;
1285 static HRESULT WINAPI OmNavigator_get_plugins(IOmNavigator *iface, IHTMLPluginsCollection **p)
1287 OmNavigator *This = impl_from_IOmNavigator(iface);
1289 TRACE("(%p)->(%p)\n", This, p);
1291 if(!This->plugins) {
1292 HRESULT hres;
1294 hres = create_plugins_collection(This, &This->plugins);
1295 if(FAILED(hres))
1296 return hres;
1297 }else {
1298 IHTMLPluginsCollection_AddRef(&This->plugins->IHTMLPluginsCollection_iface);
1301 *p = &This->plugins->IHTMLPluginsCollection_iface;
1302 return S_OK;
1305 static HRESULT WINAPI OmNavigator_get_cookieEnabled(IOmNavigator *iface, VARIANT_BOOL *p)
1307 OmNavigator *This = impl_from_IOmNavigator(iface);
1309 WARN("(%p)->(%p) semi-stub\n", This, p);
1311 *p = VARIANT_TRUE;
1312 return S_OK;
1315 static HRESULT WINAPI OmNavigator_get_opsProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
1317 OmNavigator *This = impl_from_IOmNavigator(iface);
1318 FIXME("(%p)->(%p)\n", This, p);
1319 return E_NOTIMPL;
1322 static HRESULT WINAPI OmNavigator_toString(IOmNavigator *iface, BSTR *String)
1324 OmNavigator *This = impl_from_IOmNavigator(iface);
1326 TRACE("(%p)->(%p)\n", This, String);
1328 return dispex_to_string(&This->dispex, String);
1331 static HRESULT WINAPI OmNavigator_get_cpuClass(IOmNavigator *iface, BSTR *p)
1333 OmNavigator *This = impl_from_IOmNavigator(iface);
1335 TRACE("(%p)->(%p)\n", This, p);
1337 #ifdef _WIN64
1338 *p = SysAllocString(L"x64");
1339 #else
1340 *p = SysAllocString(L"x86");
1341 #endif
1342 return *p ? S_OK : E_OUTOFMEMORY;
1345 static HRESULT get_language_string(LCID lcid, BSTR *p)
1347 BSTR ret;
1348 int len;
1350 len = LCIDToLocaleName(lcid, NULL, 0, 0);
1351 if(!len) {
1352 WARN("LCIDToLocaleName failed: %lu\n", GetLastError());
1353 return E_FAIL;
1356 ret = SysAllocStringLen(NULL, len-1);
1357 if(!ret)
1358 return E_OUTOFMEMORY;
1360 len = LCIDToLocaleName(lcid, ret, len, 0);
1361 if(!len) {
1362 WARN("LCIDToLocaleName failed: %lu\n", GetLastError());
1363 SysFreeString(ret);
1364 return E_FAIL;
1367 *p = ret;
1368 return S_OK;
1371 static HRESULT WINAPI OmNavigator_get_systemLanguage(IOmNavigator *iface, BSTR *p)
1373 OmNavigator *This = impl_from_IOmNavigator(iface);
1375 TRACE("(%p)->(%p)\n", This, p);
1377 return get_language_string(LOCALE_SYSTEM_DEFAULT, p);
1380 static HRESULT WINAPI OmNavigator_get_browserLanguage(IOmNavigator *iface, BSTR *p)
1382 OmNavigator *This = impl_from_IOmNavigator(iface);
1384 TRACE("(%p)->(%p)\n", This, p);
1386 return get_language_string(GetUserDefaultUILanguage(), p);
1389 static HRESULT WINAPI OmNavigator_get_userLanguage(IOmNavigator *iface, BSTR *p)
1391 OmNavigator *This = impl_from_IOmNavigator(iface);
1393 TRACE("(%p)->(%p)\n", This, p);
1395 return get_language_string(LOCALE_USER_DEFAULT, p);
1398 static HRESULT WINAPI OmNavigator_get_platform(IOmNavigator *iface, BSTR *p)
1400 OmNavigator *This = impl_from_IOmNavigator(iface);
1402 TRACE("(%p)->(%p)\n", This, p);
1404 #ifdef _WIN64
1405 *p = SysAllocString(L"Win64");
1406 #else
1407 *p = SysAllocString(L"Win32");
1408 #endif
1409 return S_OK;
1412 static HRESULT WINAPI OmNavigator_get_appMinorVersion(IOmNavigator *iface, BSTR *p)
1414 OmNavigator *This = impl_from_IOmNavigator(iface);
1416 TRACE("(%p)->(%p)\n", This, p);
1418 /* NOTE: MSIE returns "0" or values like ";SP2;". Returning "0" should be enough. */
1419 *p = SysAllocString(L"0");
1420 return S_OK;
1423 static HRESULT WINAPI OmNavigator_get_connectionSpeed(IOmNavigator *iface, LONG *p)
1425 OmNavigator *This = impl_from_IOmNavigator(iface);
1426 FIXME("(%p)->(%p)\n", This, p);
1427 return E_NOTIMPL;
1430 static HRESULT WINAPI OmNavigator_get_onLine(IOmNavigator *iface, VARIANT_BOOL *p)
1432 OmNavigator *This = impl_from_IOmNavigator(iface);
1434 WARN("(%p)->(%p) semi-stub, returning true\n", This, p);
1436 *p = VARIANT_TRUE;
1437 return S_OK;
1440 static HRESULT WINAPI OmNavigator_get_userProfile(IOmNavigator *iface, IHTMLOpsProfile **p)
1442 OmNavigator *This = impl_from_IOmNavigator(iface);
1443 FIXME("(%p)->(%p)\n", This, p);
1444 return E_NOTIMPL;
1447 static const IOmNavigatorVtbl OmNavigatorVtbl = {
1448 OmNavigator_QueryInterface,
1449 OmNavigator_AddRef,
1450 OmNavigator_Release,
1451 OmNavigator_GetTypeInfoCount,
1452 OmNavigator_GetTypeInfo,
1453 OmNavigator_GetIDsOfNames,
1454 OmNavigator_Invoke,
1455 OmNavigator_get_appCodeName,
1456 OmNavigator_get_appName,
1457 OmNavigator_get_appVersion,
1458 OmNavigator_get_userAgent,
1459 OmNavigator_javaEnabled,
1460 OmNavigator_taintEnabled,
1461 OmNavigator_get_mimeTypes,
1462 OmNavigator_get_plugins,
1463 OmNavigator_get_cookieEnabled,
1464 OmNavigator_get_opsProfile,
1465 OmNavigator_toString,
1466 OmNavigator_get_cpuClass,
1467 OmNavigator_get_systemLanguage,
1468 OmNavigator_get_browserLanguage,
1469 OmNavigator_get_userLanguage,
1470 OmNavigator_get_platform,
1471 OmNavigator_get_appMinorVersion,
1472 OmNavigator_get_connectionSpeed,
1473 OmNavigator_get_onLine,
1474 OmNavigator_get_userProfile
1477 static const tid_t OmNavigator_iface_tids[] = {
1478 IOmNavigator_tid,
1481 static dispex_static_data_t OmNavigator_dispex = {
1482 L"Navigator",
1483 NULL,
1484 DispHTMLNavigator_tid,
1485 OmNavigator_iface_tids
1488 HRESULT create_navigator(compat_mode_t compat_mode, IOmNavigator **navigator)
1490 OmNavigator *ret;
1492 ret = heap_alloc_zero(sizeof(*ret));
1493 if(!ret)
1494 return E_OUTOFMEMORY;
1496 ret->IOmNavigator_iface.lpVtbl = &OmNavigatorVtbl;
1497 ret->ref = 1;
1499 init_dispatch(&ret->dispex, (IUnknown*)&ret->IOmNavigator_iface, &OmNavigator_dispex, compat_mode);
1501 *navigator = &ret->IOmNavigator_iface;
1502 return S_OK;
1505 typedef struct {
1506 DispatchEx dispex;
1507 IHTMLPerformanceTiming IHTMLPerformanceTiming_iface;
1509 LONG ref;
1510 } HTMLPerformanceTiming;
1512 static inline HTMLPerformanceTiming *impl_from_IHTMLPerformanceTiming(IHTMLPerformanceTiming *iface)
1514 return CONTAINING_RECORD(iface, HTMLPerformanceTiming, IHTMLPerformanceTiming_iface);
1517 static HRESULT WINAPI HTMLPerformanceTiming_QueryInterface(IHTMLPerformanceTiming *iface, REFIID riid, void **ppv)
1519 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1521 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
1523 if(IsEqualGUID(&IID_IUnknown, riid)) {
1524 *ppv = &This->IHTMLPerformanceTiming_iface;
1525 }else if(IsEqualGUID(&IID_IHTMLPerformanceTiming, riid)) {
1526 *ppv = &This->IHTMLPerformanceTiming_iface;
1527 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1528 return *ppv ? S_OK : E_NOINTERFACE;
1529 }else {
1530 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
1531 *ppv = NULL;
1532 return E_NOINTERFACE;
1535 IUnknown_AddRef((IUnknown*)*ppv);
1536 return S_OK;
1539 static ULONG WINAPI HTMLPerformanceTiming_AddRef(IHTMLPerformanceTiming *iface)
1541 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1542 LONG ref = InterlockedIncrement(&This->ref);
1544 TRACE("(%p) ref=%ld\n", This, ref);
1546 return ref;
1549 static ULONG WINAPI HTMLPerformanceTiming_Release(IHTMLPerformanceTiming *iface)
1551 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1552 LONG ref = InterlockedDecrement(&This->ref);
1554 TRACE("(%p) ref=%ld\n", This, ref);
1556 if(!ref) {
1557 release_dispex(&This->dispex);
1558 heap_free(This);
1561 return ref;
1564 static HRESULT WINAPI HTMLPerformanceTiming_GetTypeInfoCount(IHTMLPerformanceTiming *iface, UINT *pctinfo)
1566 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1567 FIXME("(%p)->(%p)\n", This, pctinfo);
1568 return E_NOTIMPL;
1571 static HRESULT WINAPI HTMLPerformanceTiming_GetTypeInfo(IHTMLPerformanceTiming *iface, UINT iTInfo,
1572 LCID lcid, ITypeInfo **ppTInfo)
1574 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1576 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1579 static HRESULT WINAPI HTMLPerformanceTiming_GetIDsOfNames(IHTMLPerformanceTiming *iface, REFIID riid,
1580 LPOLESTR *rgszNames, UINT cNames,
1581 LCID lcid, DISPID *rgDispId)
1583 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1585 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1586 lcid, rgDispId);
1589 static HRESULT WINAPI HTMLPerformanceTiming_Invoke(IHTMLPerformanceTiming *iface, DISPID dispIdMember,
1590 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1591 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1593 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1595 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1596 pDispParams, pVarResult, pExcepInfo, puArgErr);
1599 #define TIMING_FAKE_TIMESTAMP 0xdeadbeef
1601 static HRESULT WINAPI HTMLPerformanceTiming_get_navigationStart(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1603 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1605 FIXME("(%p)->(%p) returning fake value\n", This, p);
1607 *p = TIMING_FAKE_TIMESTAMP;
1608 return S_OK;
1611 static HRESULT WINAPI HTMLPerformanceTiming_get_unloadEventStart(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1613 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1615 FIXME("(%p)->(%p) returning fake value\n", This, p);
1617 *p = TIMING_FAKE_TIMESTAMP;
1618 return S_OK;
1621 static HRESULT WINAPI HTMLPerformanceTiming_get_unloadEventEnd(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1623 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1625 FIXME("(%p)->(%p) returning fake value\n", This, p);
1627 *p = TIMING_FAKE_TIMESTAMP;
1628 return S_OK;
1631 static HRESULT WINAPI HTMLPerformanceTiming_get_redirectStart(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1633 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1635 FIXME("(%p)->(%p) returning fake value\n", This, p);
1637 *p = TIMING_FAKE_TIMESTAMP;
1638 return S_OK;
1641 static HRESULT WINAPI HTMLPerformanceTiming_get_redirectEnd(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1643 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1645 FIXME("(%p)->(%p) returning fake value\n", This, p);
1647 *p = TIMING_FAKE_TIMESTAMP;
1648 return S_OK;
1651 static HRESULT WINAPI HTMLPerformanceTiming_get_fetchStart(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1653 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1655 FIXME("(%p)->(%p) returning fake value\n", This, p);
1657 *p = TIMING_FAKE_TIMESTAMP;
1658 return S_OK;
1661 static HRESULT WINAPI HTMLPerformanceTiming_get_domainLookupStart(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1663 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1665 FIXME("(%p)->(%p) returning fake value\n", This, p);
1667 *p = TIMING_FAKE_TIMESTAMP;
1668 return S_OK;
1671 static HRESULT WINAPI HTMLPerformanceTiming_get_domainLookupEnd(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1673 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1675 FIXME("(%p)->(%p) returning fake value\n", This, p);
1677 *p = TIMING_FAKE_TIMESTAMP;
1678 return S_OK;
1681 static HRESULT WINAPI HTMLPerformanceTiming_get_connectStart(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1683 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1685 FIXME("(%p)->(%p) returning fake value\n", This, p);
1687 *p = TIMING_FAKE_TIMESTAMP;
1688 return S_OK;
1691 static HRESULT WINAPI HTMLPerformanceTiming_get_connectEnd(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1693 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1695 FIXME("(%p)->(%p) returning fake value\n", This, p);
1697 *p = TIMING_FAKE_TIMESTAMP;
1698 return S_OK;
1701 static HRESULT WINAPI HTMLPerformanceTiming_get_requestStart(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1703 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1705 FIXME("(%p)->(%p) returning fake value\n", This, p);
1707 *p = TIMING_FAKE_TIMESTAMP;
1708 return S_OK;
1711 static HRESULT WINAPI HTMLPerformanceTiming_get_responseStart(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1713 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1715 FIXME("(%p)->(%p) returning fake value\n", This, p);
1717 *p = TIMING_FAKE_TIMESTAMP;
1718 return S_OK;
1721 static HRESULT WINAPI HTMLPerformanceTiming_get_responseEnd(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1723 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1725 FIXME("(%p)->(%p) returning fake value\n", This, p);
1727 *p = TIMING_FAKE_TIMESTAMP;
1728 return S_OK;
1731 static HRESULT WINAPI HTMLPerformanceTiming_get_domLoading(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1733 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1735 FIXME("(%p)->(%p) returning fake value\n", This, p);
1737 *p = TIMING_FAKE_TIMESTAMP;
1738 return S_OK;
1741 static HRESULT WINAPI HTMLPerformanceTiming_get_domInteractive(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1743 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1745 FIXME("(%p)->(%p) returning fake value\n", This, p);
1747 *p = TIMING_FAKE_TIMESTAMP;
1748 return S_OK;
1751 static HRESULT WINAPI HTMLPerformanceTiming_get_domContentLoadedEventStart(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1753 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1755 FIXME("(%p)->(%p) returning fake value\n", This, p);
1757 *p = TIMING_FAKE_TIMESTAMP;
1758 return S_OK;
1761 static HRESULT WINAPI HTMLPerformanceTiming_get_domContentLoadedEventEnd(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1763 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1765 FIXME("(%p)->(%p) returning fake value\n", This, p);
1767 *p = TIMING_FAKE_TIMESTAMP;
1768 return S_OK;
1771 static HRESULT WINAPI HTMLPerformanceTiming_get_domComplete(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1773 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1775 FIXME("(%p)->(%p) returning fake value\n", This, p);
1777 *p = TIMING_FAKE_TIMESTAMP;
1778 return S_OK;
1781 static HRESULT WINAPI HTMLPerformanceTiming_get_loadEventStart(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1783 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1785 FIXME("(%p)->(%p) returning fake value\n", This, p);
1787 *p = TIMING_FAKE_TIMESTAMP;
1788 return S_OK;
1791 static HRESULT WINAPI HTMLPerformanceTiming_get_loadEventEnd(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1793 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1795 FIXME("(%p)->(%p) returning fake value\n", This, p);
1797 *p = TIMING_FAKE_TIMESTAMP;
1798 return S_OK;
1801 static HRESULT WINAPI HTMLPerformanceTiming_get_msFirstPaint(IHTMLPerformanceTiming *iface, ULONGLONG *p)
1803 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1805 FIXME("(%p)->(%p) returning fake value\n", This, p);
1807 *p = TIMING_FAKE_TIMESTAMP;
1808 return S_OK;
1811 static HRESULT WINAPI HTMLPerformanceTiming_toString(IHTMLPerformanceTiming *iface, BSTR *string)
1813 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1815 TRACE("(%p)->(%p)\n", This, string);
1817 return dispex_to_string(&This->dispex, string);
1820 static HRESULT WINAPI HTMLPerformanceTiming_toJSON(IHTMLPerformanceTiming *iface, VARIANT *p)
1822 HTMLPerformanceTiming *This = impl_from_IHTMLPerformanceTiming(iface);
1823 FIXME("(%p)->(%p)\n", This, p);
1824 return E_NOTIMPL;
1827 static const IHTMLPerformanceTimingVtbl HTMLPerformanceTimingVtbl = {
1828 HTMLPerformanceTiming_QueryInterface,
1829 HTMLPerformanceTiming_AddRef,
1830 HTMLPerformanceTiming_Release,
1831 HTMLPerformanceTiming_GetTypeInfoCount,
1832 HTMLPerformanceTiming_GetTypeInfo,
1833 HTMLPerformanceTiming_GetIDsOfNames,
1834 HTMLPerformanceTiming_Invoke,
1835 HTMLPerformanceTiming_get_navigationStart,
1836 HTMLPerformanceTiming_get_unloadEventStart,
1837 HTMLPerformanceTiming_get_unloadEventEnd,
1838 HTMLPerformanceTiming_get_redirectStart,
1839 HTMLPerformanceTiming_get_redirectEnd,
1840 HTMLPerformanceTiming_get_fetchStart,
1841 HTMLPerformanceTiming_get_domainLookupStart,
1842 HTMLPerformanceTiming_get_domainLookupEnd,
1843 HTMLPerformanceTiming_get_connectStart,
1844 HTMLPerformanceTiming_get_connectEnd,
1845 HTMLPerformanceTiming_get_requestStart,
1846 HTMLPerformanceTiming_get_responseStart,
1847 HTMLPerformanceTiming_get_responseEnd,
1848 HTMLPerformanceTiming_get_domLoading,
1849 HTMLPerformanceTiming_get_domInteractive,
1850 HTMLPerformanceTiming_get_domContentLoadedEventStart,
1851 HTMLPerformanceTiming_get_domContentLoadedEventEnd,
1852 HTMLPerformanceTiming_get_domComplete,
1853 HTMLPerformanceTiming_get_loadEventStart,
1854 HTMLPerformanceTiming_get_loadEventEnd,
1855 HTMLPerformanceTiming_get_msFirstPaint,
1856 HTMLPerformanceTiming_toString,
1857 HTMLPerformanceTiming_toJSON
1860 static const tid_t HTMLPerformanceTiming_iface_tids[] = {
1861 IHTMLPerformanceTiming_tid,
1864 static dispex_static_data_t HTMLPerformanceTiming_dispex = {
1865 L"PerformanceTiming",
1866 NULL,
1867 IHTMLPerformanceTiming_tid,
1868 HTMLPerformanceTiming_iface_tids
1871 typedef struct {
1872 DispatchEx dispex;
1873 IHTMLPerformanceNavigation IHTMLPerformanceNavigation_iface;
1875 LONG ref;
1876 } HTMLPerformanceNavigation;
1878 static inline HTMLPerformanceNavigation *impl_from_IHTMLPerformanceNavigation(IHTMLPerformanceNavigation *iface)
1880 return CONTAINING_RECORD(iface, HTMLPerformanceNavigation, IHTMLPerformanceNavigation_iface);
1883 static HRESULT WINAPI HTMLPerformanceNavigation_QueryInterface(IHTMLPerformanceNavigation *iface, REFIID riid, void **ppv)
1885 HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface);
1887 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
1889 if(IsEqualGUID(&IID_IUnknown, riid)) {
1890 *ppv = &This->IHTMLPerformanceNavigation_iface;
1891 }else if(IsEqualGUID(&IID_IHTMLPerformanceNavigation, riid)) {
1892 *ppv = &This->IHTMLPerformanceNavigation_iface;
1893 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
1894 return *ppv ? S_OK : E_NOINTERFACE;
1895 }else {
1896 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
1897 *ppv = NULL;
1898 return E_NOINTERFACE;
1901 IUnknown_AddRef((IUnknown*)*ppv);
1902 return S_OK;
1905 static ULONG WINAPI HTMLPerformanceNavigation_AddRef(IHTMLPerformanceNavigation *iface)
1907 HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface);
1908 LONG ref = InterlockedIncrement(&This->ref);
1910 TRACE("(%p) ref=%ld\n", This, ref);
1912 return ref;
1915 static ULONG WINAPI HTMLPerformanceNavigation_Release(IHTMLPerformanceNavigation *iface)
1917 HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface);
1918 LONG ref = InterlockedDecrement(&This->ref);
1920 TRACE("(%p) ref=%ld\n", This, ref);
1922 if(!ref) {
1923 release_dispex(&This->dispex);
1924 heap_free(This);
1927 return ref;
1930 static HRESULT WINAPI HTMLPerformanceNavigation_GetTypeInfoCount(IHTMLPerformanceNavigation *iface, UINT *pctinfo)
1932 HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface);
1933 FIXME("(%p)->(%p)\n", This, pctinfo);
1934 return E_NOTIMPL;
1937 static HRESULT WINAPI HTMLPerformanceNavigation_GetTypeInfo(IHTMLPerformanceNavigation *iface, UINT iTInfo,
1938 LCID lcid, ITypeInfo **ppTInfo)
1940 HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface);
1942 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1945 static HRESULT WINAPI HTMLPerformanceNavigation_GetIDsOfNames(IHTMLPerformanceNavigation *iface, REFIID riid,
1946 LPOLESTR *rgszNames, UINT cNames,
1947 LCID lcid, DISPID *rgDispId)
1949 HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface);
1951 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
1952 lcid, rgDispId);
1955 static HRESULT WINAPI HTMLPerformanceNavigation_Invoke(IHTMLPerformanceNavigation *iface, DISPID dispIdMember,
1956 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1957 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1959 HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface);
1961 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1962 pDispParams, pVarResult, pExcepInfo, puArgErr);
1965 static HRESULT WINAPI HTMLPerformanceNavigation_get_type(IHTMLPerformanceNavigation *iface, ULONG *p)
1967 HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface);
1969 FIXME("(%p)->(%p) returning TYPE_NAVIGATE\n", This, p);
1971 *p = 0; /* TYPE_NAVIGATE */
1972 return S_OK;
1975 static HRESULT WINAPI HTMLPerformanceNavigation_get_redirectCount(IHTMLPerformanceNavigation *iface, ULONG *p)
1977 HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface);
1978 FIXME("(%p)->(%p)\n", This, p);
1979 return E_NOTIMPL;
1982 static HRESULT WINAPI HTMLPerformanceNavigation_toString(IHTMLPerformanceNavigation *iface, BSTR *string)
1984 HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface);
1986 TRACE("(%p)->(%p)\n", This, string);
1988 return dispex_to_string(&This->dispex, string);
1991 static HRESULT WINAPI HTMLPerformanceNavigation_toJSON(IHTMLPerformanceNavigation *iface, VARIANT *p)
1993 HTMLPerformanceNavigation *This = impl_from_IHTMLPerformanceNavigation(iface);
1994 FIXME("(%p)->(%p)\n", This, p);
1995 return E_NOTIMPL;
1998 static const IHTMLPerformanceNavigationVtbl HTMLPerformanceNavigationVtbl = {
1999 HTMLPerformanceNavigation_QueryInterface,
2000 HTMLPerformanceNavigation_AddRef,
2001 HTMLPerformanceNavigation_Release,
2002 HTMLPerformanceNavigation_GetTypeInfoCount,
2003 HTMLPerformanceNavigation_GetTypeInfo,
2004 HTMLPerformanceNavigation_GetIDsOfNames,
2005 HTMLPerformanceNavigation_Invoke,
2006 HTMLPerformanceNavigation_get_type,
2007 HTMLPerformanceNavigation_get_redirectCount,
2008 HTMLPerformanceNavigation_toString,
2009 HTMLPerformanceNavigation_toJSON
2012 static const tid_t HTMLPerformanceNavigation_iface_tids[] = {
2013 IHTMLPerformanceNavigation_tid,
2016 static dispex_static_data_t HTMLPerformanceNavigation_dispex = {
2017 L"PerformanceNavigation",
2018 NULL,
2019 IHTMLPerformanceNavigation_tid,
2020 HTMLPerformanceNavigation_iface_tids
2023 typedef struct {
2024 DispatchEx dispex;
2025 IHTMLPerformance IHTMLPerformance_iface;
2027 LONG ref;
2029 IHTMLPerformanceNavigation *navigation;
2030 IHTMLPerformanceTiming *timing;
2031 } HTMLPerformance;
2033 static inline HTMLPerformance *impl_from_IHTMLPerformance(IHTMLPerformance *iface)
2035 return CONTAINING_RECORD(iface, HTMLPerformance, IHTMLPerformance_iface);
2038 static HRESULT WINAPI HTMLPerformance_QueryInterface(IHTMLPerformance *iface, REFIID riid, void **ppv)
2040 HTMLPerformance *This = impl_from_IHTMLPerformance(iface);
2042 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
2044 if(IsEqualGUID(&IID_IUnknown, riid)) {
2045 *ppv = &This->IHTMLPerformance_iface;
2046 }else if(IsEqualGUID(&IID_IHTMLPerformance, riid)) {
2047 *ppv = &This->IHTMLPerformance_iface;
2048 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
2049 return *ppv ? S_OK : E_NOINTERFACE;
2050 }else {
2051 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
2052 *ppv = NULL;
2053 return E_NOINTERFACE;
2056 IUnknown_AddRef((IUnknown*)*ppv);
2057 return S_OK;
2060 static ULONG WINAPI HTMLPerformance_AddRef(IHTMLPerformance *iface)
2062 HTMLPerformance *This = impl_from_IHTMLPerformance(iface);
2063 LONG ref = InterlockedIncrement(&This->ref);
2065 TRACE("(%p) ref=%ld\n", This, ref);
2067 return ref;
2070 static ULONG WINAPI HTMLPerformance_Release(IHTMLPerformance *iface)
2072 HTMLPerformance *This = impl_from_IHTMLPerformance(iface);
2073 LONG ref = InterlockedDecrement(&This->ref);
2075 TRACE("(%p) ref=%ld\n", This, ref);
2077 if(!ref) {
2078 if(This->timing)
2079 IHTMLPerformanceTiming_Release(This->timing);
2080 if(This->navigation)
2081 IHTMLPerformanceNavigation_Release(This->navigation);
2082 release_dispex(&This->dispex);
2083 heap_free(This);
2086 return ref;
2089 static HRESULT WINAPI HTMLPerformance_GetTypeInfoCount(IHTMLPerformance *iface, UINT *pctinfo)
2091 HTMLPerformance *This = impl_from_IHTMLPerformance(iface);
2092 FIXME("(%p)->(%p)\n", This, pctinfo);
2093 return E_NOTIMPL;
2096 static HRESULT WINAPI HTMLPerformance_GetTypeInfo(IHTMLPerformance *iface, UINT iTInfo,
2097 LCID lcid, ITypeInfo **ppTInfo)
2099 HTMLPerformance *This = impl_from_IHTMLPerformance(iface);
2101 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2104 static HRESULT WINAPI HTMLPerformance_GetIDsOfNames(IHTMLPerformance *iface, REFIID riid,
2105 LPOLESTR *rgszNames, UINT cNames,
2106 LCID lcid, DISPID *rgDispId)
2108 HTMLPerformance *This = impl_from_IHTMLPerformance(iface);
2110 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2111 lcid, rgDispId);
2114 static HRESULT WINAPI HTMLPerformance_Invoke(IHTMLPerformance *iface, DISPID dispIdMember,
2115 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2116 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2118 HTMLPerformance *This = impl_from_IHTMLPerformance(iface);
2120 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2121 pDispParams, pVarResult, pExcepInfo, puArgErr);
2124 static HRESULT WINAPI HTMLPerformance_get_navigation(IHTMLPerformance *iface,
2125 IHTMLPerformanceNavigation **p)
2127 HTMLPerformance *This = impl_from_IHTMLPerformance(iface);
2129 TRACE("(%p)->(%p)\n", This, p);
2131 if(!This->navigation) {
2132 HTMLPerformanceNavigation *navigation;
2134 navigation = heap_alloc_zero(sizeof(*navigation));
2135 if(!navigation)
2136 return E_OUTOFMEMORY;
2138 navigation->IHTMLPerformanceNavigation_iface.lpVtbl = &HTMLPerformanceNavigationVtbl;
2139 navigation->ref = 1;
2140 init_dispatch(&navigation->dispex, (IUnknown*)&navigation->IHTMLPerformanceNavigation_iface,
2141 &HTMLPerformanceNavigation_dispex, dispex_compat_mode(&This->dispex));
2143 This->navigation = &navigation->IHTMLPerformanceNavigation_iface;
2146 IHTMLPerformanceNavigation_AddRef(*p = This->navigation);
2147 return S_OK;
2150 static HRESULT WINAPI HTMLPerformance_get_timing(IHTMLPerformance *iface, IHTMLPerformanceTiming **p)
2152 HTMLPerformance *This = impl_from_IHTMLPerformance(iface);
2154 TRACE("(%p)->(%p)\n", This, p);
2156 if(!This->timing) {
2157 HTMLPerformanceTiming *timing;
2159 timing = heap_alloc_zero(sizeof(*timing));
2160 if(!timing)
2161 return E_OUTOFMEMORY;
2163 timing->IHTMLPerformanceTiming_iface.lpVtbl = &HTMLPerformanceTimingVtbl;
2164 timing->ref = 1;
2165 init_dispatch(&timing->dispex, (IUnknown*)&timing->IHTMLPerformanceTiming_iface,
2166 &HTMLPerformanceTiming_dispex, dispex_compat_mode(&This->dispex));
2168 This->timing = &timing->IHTMLPerformanceTiming_iface;
2171 IHTMLPerformanceTiming_AddRef(*p = This->timing);
2172 return S_OK;
2175 static HRESULT WINAPI HTMLPerformance_toString(IHTMLPerformance *iface, BSTR *string)
2177 HTMLPerformance *This = impl_from_IHTMLPerformance(iface);
2179 TRACE("(%p)->(%p)\n", This, string);
2181 return dispex_to_string(&This->dispex, string);
2184 static HRESULT WINAPI HTMLPerformance_toJSON(IHTMLPerformance *iface, VARIANT *var)
2186 HTMLPerformance *This = impl_from_IHTMLPerformance(iface);
2187 FIXME("(%p)->(%p)\n", This, var);
2188 return E_NOTIMPL;
2191 static const IHTMLPerformanceVtbl HTMLPerformanceVtbl = {
2192 HTMLPerformance_QueryInterface,
2193 HTMLPerformance_AddRef,
2194 HTMLPerformance_Release,
2195 HTMLPerformance_GetTypeInfoCount,
2196 HTMLPerformance_GetTypeInfo,
2197 HTMLPerformance_GetIDsOfNames,
2198 HTMLPerformance_Invoke,
2199 HTMLPerformance_get_navigation,
2200 HTMLPerformance_get_timing,
2201 HTMLPerformance_toString,
2202 HTMLPerformance_toJSON
2205 static const tid_t HTMLPerformance_iface_tids[] = {
2206 IHTMLPerformance_tid,
2209 static dispex_static_data_t HTMLPerformance_dispex = {
2210 L"Performance",
2211 NULL,
2212 IHTMLPerformance_tid,
2213 HTMLPerformance_iface_tids
2216 HRESULT create_performance(compat_mode_t compat_mode, IHTMLPerformance **ret)
2218 HTMLPerformance *performance;
2220 performance = heap_alloc_zero(sizeof(*performance));
2221 if(!performance)
2222 return E_OUTOFMEMORY;
2224 performance->IHTMLPerformance_iface.lpVtbl = &HTMLPerformanceVtbl;
2225 performance->ref = 1;
2227 init_dispatch(&performance->dispex, (IUnknown*)&performance->IHTMLPerformance_iface,
2228 &HTMLPerformance_dispex, compat_mode);
2230 *ret = &performance->IHTMLPerformance_iface;
2231 return S_OK;
2234 typedef struct {
2235 DispatchEx dispex;
2236 IHTMLNamespaceCollection IHTMLNamespaceCollection_iface;
2238 LONG ref;
2239 } HTMLNamespaceCollection;
2241 static inline HTMLNamespaceCollection *impl_from_IHTMLNamespaceCollection(IHTMLNamespaceCollection *iface)
2243 return CONTAINING_RECORD(iface, HTMLNamespaceCollection, IHTMLNamespaceCollection_iface);
2246 static HRESULT WINAPI HTMLNamespaceCollection_QueryInterface(IHTMLNamespaceCollection *iface, REFIID riid, void **ppv)
2248 HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
2250 TRACE("(%p)->(%s %p)\n", This, debugstr_mshtml_guid(riid), ppv);
2252 if(IsEqualGUID(&IID_IUnknown, riid)) {
2253 *ppv = &This->IHTMLNamespaceCollection_iface;
2254 }else if(IsEqualGUID(&IID_IHTMLNamespaceCollection, riid)) {
2255 *ppv = &This->IHTMLNamespaceCollection_iface;
2256 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
2257 return *ppv ? S_OK : E_NOINTERFACE;
2258 }else {
2259 WARN("Unsupported interface %s\n", debugstr_mshtml_guid(riid));
2260 *ppv = NULL;
2261 return E_NOINTERFACE;
2264 IUnknown_AddRef((IUnknown*)*ppv);
2265 return S_OK;
2268 static ULONG WINAPI HTMLNamespaceCollection_AddRef(IHTMLNamespaceCollection *iface)
2270 HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
2271 LONG ref = InterlockedIncrement(&This->ref);
2273 TRACE("(%p) ref=%ld\n", This, ref);
2275 return ref;
2278 static ULONG WINAPI HTMLNamespaceCollection_Release(IHTMLNamespaceCollection *iface)
2280 HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
2281 LONG ref = InterlockedDecrement(&This->ref);
2283 TRACE("(%p) ref=%ld\n", This, ref);
2285 if(!ref) {
2286 release_dispex(&This->dispex);
2287 heap_free(This);
2290 return ref;
2293 static HRESULT WINAPI HTMLNamespaceCollection_GetTypeInfoCount(IHTMLNamespaceCollection *iface, UINT *pctinfo)
2295 HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
2296 FIXME("(%p)->(%p)\n", This, pctinfo);
2297 return E_NOTIMPL;
2300 static HRESULT WINAPI HTMLNamespaceCollection_GetTypeInfo(IHTMLNamespaceCollection *iface, UINT iTInfo,
2301 LCID lcid, ITypeInfo **ppTInfo)
2303 HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
2305 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2308 static HRESULT WINAPI HTMLNamespaceCollection_GetIDsOfNames(IHTMLNamespaceCollection *iface, REFIID riid,
2309 LPOLESTR *rgszNames, UINT cNames,
2310 LCID lcid, DISPID *rgDispId)
2312 HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
2314 return IDispatchEx_GetIDsOfNames(&This->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2315 lcid, rgDispId);
2318 static HRESULT WINAPI HTMLNamespaceCollection_Invoke(IHTMLNamespaceCollection *iface, DISPID dispIdMember,
2319 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2320 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2322 HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
2324 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2325 pDispParams, pVarResult, pExcepInfo, puArgErr);
2328 static HRESULT WINAPI HTMLNamespaceCollection_get_length(IHTMLNamespaceCollection *iface, LONG *p)
2330 HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
2331 FIXME("(%p)->(%p) returning 0\n", This, p);
2332 *p = 0;
2333 return S_OK;
2336 static HRESULT WINAPI HTMLNamespaceCollection_item(IHTMLNamespaceCollection *iface, VARIANT index, IDispatch **p)
2338 HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
2339 FIXME("(%p)->(%s %p)\n", This, debugstr_variant(&index), p);
2340 return E_NOTIMPL;
2343 static HRESULT WINAPI HTMLNamespaceCollection_add(IHTMLNamespaceCollection *iface, BSTR namespace, BSTR urn,
2344 VARIANT implementation_url, IDispatch **p)
2346 HTMLNamespaceCollection *This = impl_from_IHTMLNamespaceCollection(iface);
2347 FIXME("(%p)->(%s %s %s %p)\n", This, debugstr_w(namespace), debugstr_w(urn), debugstr_variant(&implementation_url), p);
2348 return E_NOTIMPL;
2351 static const IHTMLNamespaceCollectionVtbl HTMLNamespaceCollectionVtbl = {
2352 HTMLNamespaceCollection_QueryInterface,
2353 HTMLNamespaceCollection_AddRef,
2354 HTMLNamespaceCollection_Release,
2355 HTMLNamespaceCollection_GetTypeInfoCount,
2356 HTMLNamespaceCollection_GetTypeInfo,
2357 HTMLNamespaceCollection_GetIDsOfNames,
2358 HTMLNamespaceCollection_Invoke,
2359 HTMLNamespaceCollection_get_length,
2360 HTMLNamespaceCollection_item,
2361 HTMLNamespaceCollection_add
2364 static const tid_t HTMLNamespaceCollection_iface_tids[] = {
2365 IHTMLNamespaceCollection_tid,
2368 static dispex_static_data_t HTMLNamespaceCollection_dispex = {
2369 L"MSNamespaceInfoCollection",
2370 NULL,
2371 DispHTMLNamespaceCollection_tid,
2372 HTMLNamespaceCollection_iface_tids
2375 HRESULT create_namespace_collection(compat_mode_t compat_mode, IHTMLNamespaceCollection **ret)
2377 HTMLNamespaceCollection *namespaces;
2379 if (!(namespaces = heap_alloc_zero(sizeof(*namespaces))))
2380 return E_OUTOFMEMORY;
2382 namespaces->IHTMLNamespaceCollection_iface.lpVtbl = &HTMLNamespaceCollectionVtbl;
2383 namespaces->ref = 1;
2384 init_dispatch(&namespaces->dispex, (IUnknown*)&namespaces->IHTMLNamespaceCollection_iface,
2385 &HTMLNamespaceCollection_dispex, compat_mode);
2386 *ret = &namespaces->IHTMLNamespaceCollection_iface;
2387 return S_OK;
2390 struct console {
2391 DispatchEx dispex;
2392 IWineMSHTMLConsole IWineMSHTMLConsole_iface;
2393 LONG ref;
2396 static inline struct console *impl_from_IWineMSHTMLConsole(IWineMSHTMLConsole *iface)
2398 return CONTAINING_RECORD(iface, struct console, IWineMSHTMLConsole_iface);
2401 static HRESULT WINAPI console_QueryInterface(IWineMSHTMLConsole *iface, REFIID riid, void **ppv)
2403 struct console *console = impl_from_IWineMSHTMLConsole(iface);
2405 TRACE("(%p)->(%s %p)\n", console, debugstr_mshtml_guid(riid), ppv);
2407 if(IsEqualGUID(&IID_IUnknown, riid)) {
2408 *ppv = &console->IWineMSHTMLConsole_iface;
2409 }else if(IsEqualGUID(&IID_IWineMSHTMLConsole, riid)) {
2410 *ppv = &console->IWineMSHTMLConsole_iface;
2411 }else if(dispex_query_interface(&console->dispex, riid, ppv)) {
2412 return *ppv ? S_OK : E_NOINTERFACE;
2413 }else {
2414 WARN("(%p)->(%s %p)\n", console, debugstr_mshtml_guid(riid), ppv);
2415 *ppv = NULL;
2416 return E_NOINTERFACE;
2419 IUnknown_AddRef((IUnknown*)*ppv);
2420 return S_OK;
2423 static ULONG WINAPI console_AddRef(IWineMSHTMLConsole *iface)
2425 struct console *console = impl_from_IWineMSHTMLConsole(iface);
2426 LONG ref = InterlockedIncrement(&console->ref);
2428 TRACE("(%p) ref=%ld\n", console, ref);
2430 return ref;
2433 static ULONG WINAPI console_Release(IWineMSHTMLConsole *iface)
2435 struct console *console = impl_from_IWineMSHTMLConsole(iface);
2436 LONG ref = InterlockedDecrement(&console->ref);
2438 TRACE("(%p) ref=%ld\n", console, ref);
2440 if(!ref) {
2441 release_dispex(&console->dispex);
2442 heap_free(console);
2445 return ref;
2448 static HRESULT WINAPI console_GetTypeInfoCount(IWineMSHTMLConsole *iface, UINT *pctinfo)
2450 struct console *console = impl_from_IWineMSHTMLConsole(iface);
2451 FIXME("(%p)->(%p)\n", console, pctinfo);
2452 return E_NOTIMPL;
2455 static HRESULT WINAPI console_GetTypeInfo(IWineMSHTMLConsole *iface, UINT iTInfo,
2456 LCID lcid, ITypeInfo **ppTInfo)
2458 struct console *console = impl_from_IWineMSHTMLConsole(iface);
2460 return IDispatchEx_GetTypeInfo(&console->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2463 static HRESULT WINAPI console_GetIDsOfNames(IWineMSHTMLConsole *iface, REFIID riid,
2464 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2466 struct console *console = impl_from_IWineMSHTMLConsole(iface);
2468 return IDispatchEx_GetIDsOfNames(&console->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2469 lcid, rgDispId);
2472 static HRESULT WINAPI console_Invoke(IWineMSHTMLConsole *iface, DISPID dispIdMember,
2473 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2474 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2476 struct console *console = impl_from_IWineMSHTMLConsole(iface);
2478 return IDispatchEx_Invoke(&console->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2479 pDispParams, pVarResult, pExcepInfo, puArgErr);
2482 static HRESULT WINAPI console_assert(IWineMSHTMLConsole *iface, VARIANT_BOOL *assertion, VARIANT *vararg_start)
2484 FIXME("iface %p, assertion %p, vararg_start %p stub.\n", iface, assertion, vararg_start);
2486 return S_OK;
2489 static HRESULT WINAPI console_clear(IWineMSHTMLConsole *iface)
2491 FIXME("iface %p stub.\n", iface);
2493 return S_OK;
2496 static HRESULT WINAPI console_count(IWineMSHTMLConsole *iface, VARIANT *label)
2498 FIXME("iface %p, label %p stub.\n", iface, label);
2500 return S_OK;
2503 static HRESULT WINAPI console_debug(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
2505 FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
2507 return S_OK;
2510 static HRESULT WINAPI console_dir(IWineMSHTMLConsole *iface, VARIANT *object)
2512 FIXME("iface %p, object %p stub.\n", iface, object);
2514 return S_OK;
2517 static HRESULT WINAPI console_dirxml(IWineMSHTMLConsole *iface, VARIANT *object)
2519 FIXME("iface %p, object %p stub.\n", iface, object);
2521 return S_OK;
2524 static HRESULT WINAPI console_error(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
2526 FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
2528 return S_OK;
2531 static HRESULT WINAPI console_group(IWineMSHTMLConsole *iface, VARIANT *label)
2533 FIXME("iface %p, label %p stub.\n", iface, label);
2535 return S_OK;
2538 static HRESULT WINAPI console_group_collapsed(IWineMSHTMLConsole *iface, VARIANT *label)
2540 FIXME("iface %p, label %p stub.\n", iface, label);
2542 return S_OK;
2545 static HRESULT WINAPI console_group_end(IWineMSHTMLConsole *iface)
2547 FIXME("iface %p, stub.\n", iface);
2549 return S_OK;
2552 static HRESULT WINAPI console_info(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
2554 FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
2556 return S_OK;
2559 static HRESULT WINAPI console_log(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
2561 FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
2563 return S_OK;
2566 static HRESULT WINAPI console_time(IWineMSHTMLConsole *iface, VARIANT *label)
2568 FIXME("iface %p, label %p stub.\n", iface, label);
2570 return S_OK;
2573 static HRESULT WINAPI console_time_end(IWineMSHTMLConsole *iface, VARIANT *label)
2575 FIXME("iface %p, label %p stub.\n", iface, label);
2577 return S_OK;
2580 static HRESULT WINAPI console_trace(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
2582 FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
2584 return S_OK;
2587 static HRESULT WINAPI console_warn(IWineMSHTMLConsole *iface, VARIANT *vararg_start)
2589 FIXME("iface %p, vararg_start %p stub.\n", iface, vararg_start);
2591 return S_OK;
2594 static const IWineMSHTMLConsoleVtbl WineMSHTMLConsoleVtbl = {
2595 console_QueryInterface,
2596 console_AddRef,
2597 console_Release,
2598 console_GetTypeInfoCount,
2599 console_GetTypeInfo,
2600 console_GetIDsOfNames,
2601 console_Invoke,
2602 console_assert,
2603 console_clear,
2604 console_count,
2605 console_debug,
2606 console_dir,
2607 console_dirxml,
2608 console_error,
2609 console_group,
2610 console_group_collapsed,
2611 console_group_end,
2612 console_info,
2613 console_log,
2614 console_time,
2615 console_time_end,
2616 console_trace,
2617 console_warn,
2620 static const tid_t console_iface_tids[] = {
2621 IWineMSHTMLConsole_tid,
2624 static dispex_static_data_t console_dispex = {
2625 L"Console",
2626 NULL,
2627 IWineMSHTMLConsole_tid,
2628 console_iface_tids
2631 void create_console(compat_mode_t compat_mode, IWineMSHTMLConsole **ret)
2633 struct console *obj;
2635 obj = heap_alloc_zero(sizeof(*obj));
2636 if(!obj)
2638 ERR("No memory.\n");
2639 return;
2642 obj->IWineMSHTMLConsole_iface.lpVtbl = &WineMSHTMLConsoleVtbl;
2643 obj->ref = 1;
2644 init_dispatch(&obj->dispex, (IUnknown*)&obj->IWineMSHTMLConsole_iface, &console_dispex, compat_mode);
2646 *ret = &obj->IWineMSHTMLConsole_iface;
2649 struct media_query_list {
2650 DispatchEx dispex;
2651 IWineMSHTMLMediaQueryList IWineMSHTMLMediaQueryList_iface;
2652 LONG ref;
2653 nsIDOMMediaQueryList *nsquerylist;
2656 static inline struct media_query_list *impl_from_IWineMSHTMLMediaQueryList(IWineMSHTMLMediaQueryList *iface)
2658 return CONTAINING_RECORD(iface, struct media_query_list, IWineMSHTMLMediaQueryList_iface);
2661 static HRESULT WINAPI media_query_list_QueryInterface(IWineMSHTMLMediaQueryList *iface, REFIID riid, void **ppv)
2663 struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface);
2665 TRACE("(%p)->(%s %p)\n", media_query_list, debugstr_mshtml_guid(riid), ppv);
2667 if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IWineMSHTMLMediaQueryList, riid)) {
2668 *ppv = &media_query_list->IWineMSHTMLMediaQueryList_iface;
2669 }else if(dispex_query_interface(&media_query_list->dispex, riid, ppv)) {
2670 return *ppv ? S_OK : E_NOINTERFACE;
2671 }else {
2672 *ppv = NULL;
2673 return E_NOINTERFACE;
2676 IUnknown_AddRef((IUnknown*)*ppv);
2677 return S_OK;
2680 static ULONG WINAPI media_query_list_AddRef(IWineMSHTMLMediaQueryList *iface)
2682 struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface);
2683 LONG ref = InterlockedIncrement(&media_query_list->ref);
2685 TRACE("(%p) ref=%ld\n", media_query_list, ref);
2687 return ref;
2690 static ULONG WINAPI media_query_list_Release(IWineMSHTMLMediaQueryList *iface)
2692 struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface);
2693 LONG ref = InterlockedDecrement(&media_query_list->ref);
2695 TRACE("(%p) ref=%ld\n", media_query_list, ref);
2697 if(!ref) {
2698 nsIDOMMediaQueryList_Release(media_query_list->nsquerylist);
2699 release_dispex(&media_query_list->dispex);
2700 heap_free(media_query_list);
2703 return ref;
2706 static HRESULT WINAPI media_query_list_GetTypeInfoCount(IWineMSHTMLMediaQueryList *iface, UINT *pctinfo)
2708 struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface);
2710 TRACE("(%p)->(%p)\n", media_query_list, pctinfo);
2712 return IDispatchEx_GetTypeInfoCount(&media_query_list->dispex.IDispatchEx_iface, pctinfo);
2715 static HRESULT WINAPI media_query_list_GetTypeInfo(IWineMSHTMLMediaQueryList *iface, UINT iTInfo,
2716 LCID lcid, ITypeInfo **ppTInfo)
2718 struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface);
2720 return IDispatchEx_GetTypeInfo(&media_query_list->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2723 static HRESULT WINAPI media_query_list_GetIDsOfNames(IWineMSHTMLMediaQueryList *iface, REFIID riid,
2724 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
2726 struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface);
2728 return IDispatchEx_GetIDsOfNames(&media_query_list->dispex.IDispatchEx_iface, riid, rgszNames, cNames,
2729 lcid, rgDispId);
2732 static HRESULT WINAPI media_query_list_Invoke(IWineMSHTMLMediaQueryList *iface, DISPID dispIdMember,
2733 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2734 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2736 struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface);
2738 return IDispatchEx_Invoke(&media_query_list->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2739 pDispParams, pVarResult, pExcepInfo, puArgErr);
2742 static HRESULT WINAPI media_query_list_get_media(IWineMSHTMLMediaQueryList *iface, BSTR *p)
2744 struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface);
2745 nsAString nsstr;
2747 TRACE("(%p)->(%p)\n", media_query_list, p);
2749 nsAString_InitDepend(&nsstr, NULL);
2750 return return_nsstr(nsIDOMMediaQueryList_GetMedia(media_query_list->nsquerylist, &nsstr), &nsstr, p);
2753 static HRESULT WINAPI media_query_list_get_matches(IWineMSHTMLMediaQueryList *iface, VARIANT_BOOL *p)
2755 struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface);
2756 nsresult nsres;
2757 cpp_bool b;
2759 TRACE("(%p)->(%p)\n", media_query_list, p);
2761 nsres = nsIDOMMediaQueryList_GetMatches(media_query_list->nsquerylist, &b);
2762 if(NS_FAILED(nsres))
2763 return map_nsresult(nsres);
2764 *p = b ? VARIANT_TRUE : VARIANT_FALSE;
2765 return S_OK;
2768 static HRESULT WINAPI media_query_list_addListener(IWineMSHTMLMediaQueryList *iface, VARIANT *listener)
2770 struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface);
2772 FIXME("(%p)->(%s)\n", media_query_list, debugstr_variant(listener));
2774 return E_NOTIMPL;
2777 static HRESULT WINAPI media_query_list_removeListener(IWineMSHTMLMediaQueryList *iface, VARIANT *listener)
2779 struct media_query_list *media_query_list = impl_from_IWineMSHTMLMediaQueryList(iface);
2781 FIXME("(%p)->(%s)\n", media_query_list, debugstr_variant(listener));
2783 return E_NOTIMPL;
2786 static const IWineMSHTMLMediaQueryListVtbl media_query_list_vtbl = {
2787 media_query_list_QueryInterface,
2788 media_query_list_AddRef,
2789 media_query_list_Release,
2790 media_query_list_GetTypeInfoCount,
2791 media_query_list_GetTypeInfo,
2792 media_query_list_GetIDsOfNames,
2793 media_query_list_Invoke,
2794 media_query_list_get_media,
2795 media_query_list_get_matches,
2796 media_query_list_addListener,
2797 media_query_list_removeListener
2800 static const tid_t media_query_list_iface_tids[] = {
2801 IWineMSHTMLMediaQueryList_tid,
2804 static dispex_static_data_t media_query_list_dispex = {
2805 L"MediaQueryList",
2806 NULL,
2807 IWineMSHTMLMediaQueryList_tid,
2808 media_query_list_iface_tids
2811 HRESULT create_media_query_list(HTMLWindow *window, BSTR media_query, IDispatch **ret)
2813 struct media_query_list *media_query_list;
2814 nsISupports *nsunk;
2815 nsAString nsstr;
2816 nsresult nsres;
2818 if(!media_query || !media_query[0])
2819 return E_INVALIDARG;
2821 if(!(media_query_list = heap_alloc(sizeof(*media_query_list))))
2822 return E_OUTOFMEMORY;
2824 nsAString_InitDepend(&nsstr, media_query);
2825 nsres = nsIDOMWindow_MatchMedia(window->outer_window->nswindow, &nsstr, &nsunk);
2826 nsAString_Finish(&nsstr);
2827 if(NS_FAILED(nsres)) {
2828 heap_free(media_query_list);
2829 return map_nsresult(nsres);
2831 nsres = nsISupports_QueryInterface(nsunk, &IID_nsIDOMMediaQueryList, (void**)&media_query_list->nsquerylist);
2832 assert(NS_SUCCEEDED(nsres));
2833 nsISupports_Release(nsunk);
2835 media_query_list->IWineMSHTMLMediaQueryList_iface.lpVtbl = &media_query_list_vtbl;
2836 media_query_list->ref = 1;
2837 init_dispatch(&media_query_list->dispex, (IUnknown*)&media_query_list->IWineMSHTMLMediaQueryList_iface,
2838 &media_query_list_dispex, dispex_compat_mode(&window->inner_window->event_target.dispex));
2840 *ret = (IDispatch*)&media_query_list->IWineMSHTMLMediaQueryList_iface;
2841 return S_OK;