oleaut32: Thousands separator support for VarFormat.
[wine/hacks.git] / dlls / mshtml / htmlwindow.c
blob76efb9dcb8caa518d9f2b0627109737671ae39a8
1 /*
2 * Copyright 2006 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"
29 #include "wine/unicode.h"
31 #include "mshtml_private.h"
32 #include "resource.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 static struct list window_list = LIST_INIT(window_list);
38 #define HTMLWINDOW2_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow2, iface)
40 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
42 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
44 *ppv = NULL;
46 if(IsEqualGUID(&IID_IUnknown, riid)) {
47 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
48 *ppv = HTMLWINDOW2(This);
49 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
50 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
51 *ppv = HTMLWINDOW2(This);
52 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
53 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
54 *ppv = DISPATCHEX(This);
55 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2, riid)) {
56 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
57 *ppv = HTMLWINDOW2(This);
58 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
59 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
60 *ppv = HTMLWINDOW2(This);
61 }else if(IsEqualGUID(&IID_IHTMLWindow3, riid)) {
62 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
63 *ppv = HTMLWINDOW3(This);
64 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
65 return *ppv ? S_OK : E_NOINTERFACE;
68 if(*ppv) {
69 IUnknown_AddRef((IUnknown*)*ppv);
70 return S_OK;
73 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
74 return E_NOINTERFACE;
77 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
79 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
80 LONG ref = InterlockedIncrement(&This->ref);
82 TRACE("(%p) ref=%d\n", This, ref);
84 return ref;
87 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
89 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
90 LONG ref = InterlockedDecrement(&This->ref);
92 TRACE("(%p) ref=%d\n", This, ref);
94 if(!ref) {
95 list_remove(&This->entry);
96 heap_free(This);
99 return ref;
102 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
104 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
106 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
109 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
110 LCID lcid, ITypeInfo **ppTInfo)
112 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
114 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
117 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
118 LPOLESTR *rgszNames, UINT cNames,
119 LCID lcid, DISPID *rgDispId)
121 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
123 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
126 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
127 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
128 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
130 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
132 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
133 pVarResult, pExcepInfo, puArgErr);
136 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
138 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
139 FIXME("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
140 return E_NOTIMPL;
143 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, long *p)
145 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
146 FIXME("(%p)->(%p)\n", This, p);
147 return E_NOTIMPL;
150 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
152 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
153 FIXME("(%p)->(%p)\n", This, p);
154 return E_NOTIMPL;
157 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
159 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
160 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
161 return E_NOTIMPL;
164 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
166 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
167 FIXME("(%p)->(%p)\n", This, p);
168 return E_NOTIMPL;
171 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
173 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
174 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
175 return E_NOTIMPL;
178 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
180 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
181 FIXME("(%p)->(%p)\n", This, p);
182 return E_NOTIMPL;
185 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
186 long msec, VARIANT *language, long *timerID)
188 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
189 VARIANT expr_var;
191 TRACE("(%p)->(%s %ld %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
193 V_VT(&expr_var) = VT_BSTR;
194 V_BSTR(&expr_var) = expression;
196 return IHTMLWindow3_setTimeout(HTMLWINDOW3(This), &expr_var, msec, language, timerID);
199 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, long timerID)
201 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
203 TRACE("(%p)->(%ld)\n", This, timerID);
205 return clear_task_timer(This->doc, FALSE, timerID);
208 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
210 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
211 WCHAR wszTitle[100];
213 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
215 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
216 sizeof(wszTitle)/sizeof(WCHAR))) {
217 WARN("Could not load message box title: %d\n", GetLastError());
218 return S_OK;
221 MessageBoxW(This->doc->hwnd, message, wszTitle, MB_ICONWARNING);
222 return S_OK;
225 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
226 VARIANT_BOOL *confirmed)
228 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
229 FIXME("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
230 return E_NOTIMPL;
233 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
234 BSTR dststr, VARIANT *textdata)
236 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
237 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
238 return E_NOTIMPL;
241 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
243 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
244 FIXME("(%p)->(%p)\n", This, p);
245 return E_NOTIMPL;
248 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
250 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
251 FIXME("(%p)->(%p)\n", This, p);
252 return E_NOTIMPL;
255 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
257 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
258 FIXME("(%p)->(%p)\n", This, p);
259 return E_NOTIMPL;
262 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
264 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
265 FIXME("(%p)->()\n", This);
266 return E_NOTIMPL;
269 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
271 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
272 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
273 return E_NOTIMPL;
276 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
278 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
279 FIXME("(%p)->(%p)\n", This, p);
280 return E_NOTIMPL;
283 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
285 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
287 TRACE("(%p)->(%p)\n", This, p);
289 *p = OmNavigator_Create();
290 return S_OK;
293 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
295 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
296 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
297 return E_NOTIMPL;
300 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
302 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
303 FIXME("(%p)->(%p)\n", This, p);
304 return E_NOTIMPL;
307 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
309 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
310 FIXME("(%p)->(%p)\n", This, p);
311 return E_NOTIMPL;
314 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
315 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
317 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
318 FIXME("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
319 debugstr_w(features), replace, pomWindowResult);
320 return E_NOTIMPL;
323 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
325 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
327 TRACE("(%p)->(%p)\n", This, p);
329 /* FIXME: We should return kind of proxy window here. */
330 IHTMLWindow2_AddRef(HTMLWINDOW2(This));
331 *p = HTMLWINDOW2(This);
332 return S_OK;
335 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
337 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
338 FIXME("(%p)->(%p)\n", This, p);
339 return E_NOTIMPL;
342 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
344 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
346 TRACE("(%p)->(%p)\n", This, p);
348 /* FIXME: We should return kind of proxy window here. */
349 IHTMLWindow2_AddRef(HTMLWINDOW2(This));
350 *p = HTMLWINDOW2(This);
351 return S_OK;
354 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
356 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
357 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
358 return E_NOTIMPL;
361 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
363 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
364 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
365 return E_NOTIMPL;
368 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
370 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
371 FIXME("(%p)->(%p)\n", This, p);
372 return E_NOTIMPL;
375 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
377 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
378 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
379 return E_NOTIMPL;
382 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
384 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
385 FIXME("(%p)->(%p)\n", This, p);
386 return E_NOTIMPL;
389 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
391 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
392 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
393 return E_NOTIMPL;
396 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
398 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
399 FIXME("(%p)->(%p)\n", This, p);
400 return E_NOTIMPL;
403 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
405 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
406 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
407 return E_NOTIMPL;
410 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
412 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
413 FIXME("(%p)->(%p)\n", This, p);
414 return E_NOTIMPL;
417 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
419 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
420 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
421 return E_NOTIMPL;
424 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
426 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
427 FIXME("(%p)->(%p)\n", This, p);
428 return E_NOTIMPL;
431 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
433 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
434 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
435 return E_NOTIMPL;
438 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
440 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
441 FIXME("(%p)->(%p)\n", This, p);
442 return E_NOTIMPL;
445 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
447 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
448 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
449 return E_NOTIMPL;
452 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
454 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
455 FIXME("(%p)->(%p)\n", This, p);
456 return E_NOTIMPL;
459 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
461 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
462 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
463 return E_NOTIMPL;
466 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
468 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
469 FIXME("(%p)->(%p)\n", This, p);
470 return E_NOTIMPL;
473 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
475 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
476 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
477 return E_NOTIMPL;
480 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
482 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
483 FIXME("(%p)->(%p)\n", This, p);
484 return E_NOTIMPL;
487 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
489 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
491 TRACE("(%p)->(%p)\n", This, p);
493 if(This->doc) {
494 /* FIXME: We should return a wrapper object here */
495 *p = HTMLDOC(This->doc);
496 IHTMLDocument2_AddRef(*p);
497 }else {
498 *p = NULL;
501 return S_OK;
504 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
506 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
507 FIXME("(%p)->(%p)\n", This, p);
508 return E_NOTIMPL;
511 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
513 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
514 FIXME("(%p)->(%p)\n", This, p);
515 return E_NOTIMPL;
518 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
519 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
521 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
522 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
523 return E_NOTIMPL;
526 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
527 BSTR features)
529 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
530 FIXME("(%p)->(%s v(%d) %s)\n", This, debugstr_w(helpURL), V_VT(&helpArg), debugstr_w(features));
531 return E_NOTIMPL;
534 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
536 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
537 FIXME("(%p)->(%p)\n", This, p);
538 return E_NOTIMPL;
541 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
543 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
545 TRACE("(%p)->(%p)\n", This, p);
547 if(!This->doc->option_factory)
548 This->doc->option_factory = HTMLOptionElementFactory_Create(This->doc);
550 *p = HTMLOPTFACTORY(This->doc->option_factory);
551 IHTMLOptionElementFactory_AddRef(*p);
553 return S_OK;
556 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
558 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
559 FIXME("(%p)->()\n", This);
560 return E_NOTIMPL;
563 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
565 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
566 FIXME("(%p)->(%p)\n", This, p);
567 return E_NOTIMPL;
570 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
572 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
573 FIXME("(%p)->()\n", This);
574 return E_NOTIMPL;
577 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, long x, long y)
579 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
580 FIXME("(%p)->(%ld %ld)\n", This, x, y);
581 return E_NOTIMPL;
584 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
586 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
587 FIXME("(%p)->(%p)\n", This, p);
588 return E_NOTIMPL;
591 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
592 long msec, VARIANT *language, long *timerID)
594 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
595 VARIANT expr;
597 TRACE("(%p)->(%s %ld %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
599 V_VT(&expr) = VT_BSTR;
600 V_BSTR(&expr) = expression;
601 return IHTMLWindow3_setInterval(HTMLWINDOW3(This), &expr, msec, language, timerID);
604 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, long timerID)
606 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
608 TRACE("(%p)->(%ld)\n", This, timerID);
610 return clear_task_timer(This->doc, TRUE, timerID);
613 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
615 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
616 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
617 return E_NOTIMPL;
620 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
622 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
623 FIXME("(%p)->(%p)\n", This, p);
624 return E_NOTIMPL;
627 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
628 VARIANT *pvarRet)
630 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
631 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
632 return E_NOTIMPL;
635 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
637 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
638 FIXME("(%p)->(%p)\n", This, String);
639 return E_NOTIMPL;
642 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, long x, long y)
644 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
645 nsresult nsres;
647 TRACE("(%p)->(%ld %ld)\n", This, x, y);
649 nsres = nsIDOMWindow_ScrollBy(This->nswindow, x, y);
650 if(NS_FAILED(nsres))
651 ERR("ScrollBy failed: %08x\n", nsres);
653 return S_OK;
656 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, long x, long y)
658 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
659 nsresult nsres;
661 TRACE("(%p)->(%ld %ld)\n", This, x, y);
663 nsres = nsIDOMWindow_ScrollTo(This->nswindow, x, y);
664 if(NS_FAILED(nsres))
665 ERR("ScrollTo failed: %08x\n", nsres);
667 return S_OK;
670 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, long x, long y)
672 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
673 FIXME("(%p)->(%ld %ld)\n", This, x, y);
674 return E_NOTIMPL;
677 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, long x, long y)
679 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
680 FIXME("(%p)->(%ld %ld)\n", This, x, y);
681 return E_NOTIMPL;
684 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, long x, long y)
686 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
687 FIXME("(%p)->(%ld %ld)\n", This, x, y);
688 return E_NOTIMPL;
691 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, long x, long y)
693 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
694 FIXME("(%p)->(%ld %ld)\n", This, x, y);
695 return E_NOTIMPL;
698 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
700 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
702 TRACE("(%p)->(%p)\n", This, p);
704 *p = NULL;
706 if(!This->doc->hostui)
707 return S_OK;
709 return IDocHostUIHandler_GetExternal(This->doc->hostui, p);
712 #undef HTMLWINDOW2_THIS
714 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
715 HTMLWindow2_QueryInterface,
716 HTMLWindow2_AddRef,
717 HTMLWindow2_Release,
718 HTMLWindow2_GetTypeInfoCount,
719 HTMLWindow2_GetTypeInfo,
720 HTMLWindow2_GetIDsOfNames,
721 HTMLWindow2_Invoke,
722 HTMLWindow2_item,
723 HTMLWindow2_get_length,
724 HTMLWindow2_get_frames,
725 HTMLWindow2_put_defaultStatus,
726 HTMLWindow2_get_defaultStatus,
727 HTMLWindow2_put_status,
728 HTMLWindow2_get_status,
729 HTMLWindow2_setTimeout,
730 HTMLWindow2_clearTimeout,
731 HTMLWindow2_alert,
732 HTMLWindow2_confirm,
733 HTMLWindow2_prompt,
734 HTMLWindow2_get_Image,
735 HTMLWindow2_get_location,
736 HTMLWindow2_get_history,
737 HTMLWindow2_close,
738 HTMLWindow2_put_opener,
739 HTMLWindow2_get_opener,
740 HTMLWindow2_get_navigator,
741 HTMLWindow2_put_name,
742 HTMLWindow2_get_name,
743 HTMLWindow2_get_parent,
744 HTMLWindow2_open,
745 HTMLWindow2_get_self,
746 HTMLWindow2_get_top,
747 HTMLWindow2_get_window,
748 HTMLWindow2_navigate,
749 HTMLWindow2_put_onfocus,
750 HTMLWindow2_get_onfocus,
751 HTMLWindow2_put_onblur,
752 HTMLWindow2_get_onblur,
753 HTMLWindow2_put_onload,
754 HTMLWindow2_get_onload,
755 HTMLWindow2_put_onbeforeunload,
756 HTMLWindow2_get_onbeforeunload,
757 HTMLWindow2_put_onunload,
758 HTMLWindow2_get_onunload,
759 HTMLWindow2_put_onhelp,
760 HTMLWindow2_get_onhelp,
761 HTMLWindow2_put_onerror,
762 HTMLWindow2_get_onerror,
763 HTMLWindow2_put_onresize,
764 HTMLWindow2_get_onresize,
765 HTMLWindow2_put_onscroll,
766 HTMLWindow2_get_onscroll,
767 HTMLWindow2_get_document,
768 HTMLWindow2_get_event,
769 HTMLWindow2_get__newEnum,
770 HTMLWindow2_showModalDialog,
771 HTMLWindow2_showHelp,
772 HTMLWindow2_get_screen,
773 HTMLWindow2_get_Option,
774 HTMLWindow2_focus,
775 HTMLWindow2_get_closed,
776 HTMLWindow2_blur,
777 HTMLWindow2_scroll,
778 HTMLWindow2_get_clientInformation,
779 HTMLWindow2_setInterval,
780 HTMLWindow2_clearInterval,
781 HTMLWindow2_put_offscreenBuffering,
782 HTMLWindow2_get_offscreenBuffering,
783 HTMLWindow2_execScript,
784 HTMLWindow2_toString,
785 HTMLWindow2_scrollBy,
786 HTMLWindow2_scrollTo,
787 HTMLWindow2_moveTo,
788 HTMLWindow2_moveBy,
789 HTMLWindow2_resizeTo,
790 HTMLWindow2_resizeBy,
791 HTMLWindow2_get_external
794 #define HTMLWINDOW3_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow3, iface)
796 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
798 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
800 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This), riid, ppv);
803 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
805 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
807 return IHTMLWindow2_AddRef(HTMLWINDOW2(This));
810 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
812 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
814 return IHTMLWindow2_Release(HTMLWINDOW2(This));
817 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
819 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
821 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
824 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
825 LCID lcid, ITypeInfo **ppTInfo)
827 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
829 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
832 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
833 LPOLESTR *rgszNames, UINT cNames,
834 LCID lcid, DISPID *rgDispId)
836 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
838 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
841 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
842 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
843 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
845 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
847 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
848 pVarResult, pExcepInfo, puArgErr);
851 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, long *p)
853 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
854 FIXME("(%p)->(%p)\n", This, p);
855 return E_NOTIMPL;
858 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, long *p)
860 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
861 FIXME("(%p)->(%p)\n", This, p);
862 return E_NOTIMPL;
865 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
867 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
868 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
869 return E_NOTIMPL;
872 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
874 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
875 FIXME("(%p)->()\n", This);
876 return E_NOTIMPL;
879 static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, long msec, VARIANT *language,
880 BOOL interval, long *timer_id)
882 IDispatch *disp = NULL;
884 switch(V_VT(expr)) {
885 case VT_DISPATCH:
886 disp = V_DISPATCH(expr);
887 IDispatch_AddRef(disp);
888 break;
890 case VT_BSTR:
891 disp = script_parse_event(This->doc, V_BSTR(expr));
892 break;
894 default:
895 FIXME("unimplemented vt=%d\n", V_VT(expr));
896 return E_NOTIMPL;
899 if(!disp)
900 return E_FAIL;
902 *timer_id = set_task_timer(This->doc, msec, interval, disp);
903 IDispatch_Release(disp);
905 return S_OK;
908 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, long msec,
909 VARIANT *language, long *timerID)
911 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
913 TRACE("(%p)->(%p(%d) %ld %p %p)\n", This, expression, V_VT(expression), msec, language, timerID);
915 return window_set_timer(This, expression, msec, language, FALSE, timerID);
918 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, long msec,
919 VARIANT *language, long *timerID)
921 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
923 TRACE("(%p)->(%p %ld %p %p)\n", This, expression, msec, language, timerID);
925 return window_set_timer(This, expression, msec, language, TRUE, timerID);
928 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
930 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
931 FIXME("(%p)\n", This);
932 return E_NOTIMPL;
935 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
937 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
938 FIXME("(%p)->()\n", This);
939 return E_NOTIMPL;
942 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
944 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
945 FIXME("(%p)->(%p)\n", This, p);
946 return E_NOTIMPL;
949 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
951 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
952 FIXME("(%p)->()\n", This);
953 return E_NOTIMPL;
956 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
958 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
959 FIXME("(%p)->(%p)\n", This, p);
960 return E_NOTIMPL;
963 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
965 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
966 FIXME("(%p)->(%p)\n", This, p);
967 return E_NOTIMPL;
970 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
971 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
973 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
974 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
975 return E_NOTIMPL;
978 #undef HTMLWINDOW3_THIS
980 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
981 HTMLWindow3_QueryInterface,
982 HTMLWindow3_AddRef,
983 HTMLWindow3_Release,
984 HTMLWindow3_GetTypeInfoCount,
985 HTMLWindow3_GetTypeInfo,
986 HTMLWindow3_GetIDsOfNames,
987 HTMLWindow3_Invoke,
988 HTMLWindow3_get_screenLeft,
989 HTMLWindow3_get_screenTop,
990 HTMLWindow3_attachEvent,
991 HTMLWindow3_detachEvent,
992 HTMLWindow3_setTimeout,
993 HTMLWindow3_setInterval,
994 HTMLWindow3_print,
995 HTMLWindow3_put_onbeforeprint,
996 HTMLWindow3_get_onbeforeprint,
997 HTMLWindow3_put_onafterprint,
998 HTMLWindow3_get_onafterprint,
999 HTMLWindow3_get_clipboardData,
1000 HTMLWindow3_showModelessDialog
1003 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLWindow, IDispatchEx, iface)
1005 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1007 HTMLWindow *This = DISPEX_THIS(iface);
1009 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This), riid, ppv);
1012 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
1014 HTMLWindow *This = DISPEX_THIS(iface);
1016 return IHTMLWindow2_AddRef(HTMLWINDOW2(This));
1019 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
1021 HTMLWindow *This = DISPEX_THIS(iface);
1023 return IHTMLWindow2_Release(HTMLWINDOW2(This));
1026 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1028 HTMLWindow *This = DISPEX_THIS(iface);
1030 TRACE("(%p)->(%p)\n", This, pctinfo);
1032 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
1035 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1036 LCID lcid, ITypeInfo **ppTInfo)
1038 HTMLWindow *This = DISPEX_THIS(iface);
1040 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1042 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
1045 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1046 LPOLESTR *rgszNames, UINT cNames,
1047 LCID lcid, DISPID *rgDispId)
1049 HTMLWindow *This = DISPEX_THIS(iface);
1051 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1052 lcid, rgDispId);
1054 /* FIXME: Use script dispatch */
1056 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1059 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1060 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1061 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1063 HTMLWindow *This = DISPEX_THIS(iface);
1065 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1066 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1068 /* FIXME: Use script dispatch */
1070 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1071 pVarResult, pExcepInfo, puArgErr);
1074 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1076 HTMLWindow *This = DISPEX_THIS(iface);
1078 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
1080 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1083 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1084 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1086 HTMLWindow *This = DISPEX_THIS(iface);
1088 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1090 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1093 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1095 HTMLWindow *This = DISPEX_THIS(iface);
1097 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
1099 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1102 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1104 HTMLWindow *This = DISPEX_THIS(iface);
1106 TRACE("(%p)->(%x)\n", This, id);
1108 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1111 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1113 HTMLWindow *This = DISPEX_THIS(iface);
1115 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
1117 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1120 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1122 HTMLWindow *This = DISPEX_THIS(iface);
1124 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
1126 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1129 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1131 HTMLWindow *This = DISPEX_THIS(iface);
1133 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
1135 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1138 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1140 HTMLWindow *This = DISPEX_THIS(iface);
1142 TRACE("(%p)->(%p)\n", This, ppunk);
1144 *ppunk = NULL;
1145 return S_OK;
1148 #undef DISPEX_THIS
1150 static const IDispatchExVtbl WindowDispExVtbl = {
1151 WindowDispEx_QueryInterface,
1152 WindowDispEx_AddRef,
1153 WindowDispEx_Release,
1154 WindowDispEx_GetTypeInfoCount,
1155 WindowDispEx_GetTypeInfo,
1156 WindowDispEx_GetIDsOfNames,
1157 WindowDispEx_Invoke,
1158 WindowDispEx_GetDispID,
1159 WindowDispEx_InvokeEx,
1160 WindowDispEx_DeleteMemberByName,
1161 WindowDispEx_DeleteMemberByDispID,
1162 WindowDispEx_GetMemberProperties,
1163 WindowDispEx_GetMemberName,
1164 WindowDispEx_GetNextDispID,
1165 WindowDispEx_GetNameSpaceParent
1168 static const tid_t HTMLWindow_iface_tids[] = {
1169 IHTMLWindow2_tid,
1170 IHTMLWindow3_tid,
1173 static dispex_static_data_t HTMLWindow_dispex = {
1174 NULL,
1175 DispHTMLWindow2_tid,
1176 NULL,
1177 HTMLWindow_iface_tids
1180 static const char wineConfig_func[] =
1181 "window.__defineGetter__(\"external\",function() {\n"
1182 " return window.__wineWindow__.external;\n"
1183 "});\n"
1184 "window.__wineWindow__ = wineWindow;\n";
1186 static void astr_to_nswstr(const char *str, nsAString *nsstr)
1188 LPWSTR wstr;
1189 int len;
1191 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
1192 wstr = heap_alloc(len*sizeof(WCHAR));
1193 MultiByteToWideChar(CP_ACP, 0, str, -1, wstr, len);
1195 nsAString_Init(nsstr, wstr);
1197 heap_free(wstr);
1200 static nsresult call_js_func(nsIScriptContainer *script_container, nsISupports *target,
1201 const char *name, const char *body,
1202 PRUint32 argc, const char **arg_names, nsIArray *argv)
1204 nsACString name_str;
1205 nsAString body_str;
1206 JSObject func_obj, jsglobal;
1207 nsIVariant *jsret;
1208 nsresult nsres;
1210 nsres = nsIScriptContainer_GetGlobalObject(script_container, &jsglobal);
1211 if(NS_FAILED(nsres))
1212 ERR("GetGlobalObject: %08x\n", nsres);
1214 nsACString_Init(&name_str, name);
1215 astr_to_nswstr(body, &body_str);
1217 nsres = nsIScriptContainer_CompileFunction(script_container, jsglobal, &name_str, argc, arg_names,
1218 &body_str, NULL, 1, FALSE, &func_obj);
1220 nsACString_Finish(&name_str);
1221 nsAString_Finish(&body_str);
1223 if(NS_FAILED(nsres)) {
1224 ERR("CompileFunction failed: %08x\n", nsres);
1225 return nsres;
1228 nsres = nsIScriptContainer_CallFunction(script_container, target, jsglobal, func_obj, argv, &jsret);
1230 nsIScriptContainer_DropScriptObject(script_container, func_obj);
1231 nsIScriptContainer_DropScriptObject(script_container, jsglobal);
1232 if(NS_FAILED(nsres)) {
1233 ERR("CallFunction failed: %08x\n", nsres);
1234 return nsres;
1237 nsIVariant_Release(jsret);
1238 return NS_OK;
1241 void setup_nswindow(HTMLWindow *This)
1243 nsIScriptContainer *script_container;
1244 nsIDOMWindow *nswindow;
1245 nsIDOMDocument *domdoc;
1246 nsIWritableVariant *nsvar;
1247 nsIMutableArray *argv;
1248 nsresult nsres;
1250 static const char *args[] = {"wineWindow"};
1252 TRACE("(%p)\n", This);
1254 nsIWebNavigation_GetDocument(This->doc->nscontainer->navigation, &domdoc);
1255 nsres = nsIDOMDocument_QueryInterface(domdoc, &IID_nsIScriptContainer, (void**)&script_container);
1256 nsIDOMDocument_Release(domdoc);
1257 if(NS_FAILED(nsres)) {
1258 TRACE("Could not get nsIDOMScriptContainer: %08x\n", nsres);
1259 return;
1262 nsIWebBrowser_GetContentDOMWindow(This->doc->nscontainer->webbrowser, &nswindow);
1264 nsvar = create_nsvariant();
1265 nsres = nsIWritableVariant_SetAsInterface(nsvar, &IID_IDispatch, HTMLWINDOW2(This));
1266 if(NS_FAILED(nsres))
1267 ERR("SetAsInterface failed: %08x\n", nsres);
1269 argv = create_nsarray();
1270 nsres = nsIMutableArray_AppendElement(argv, (nsISupports*)nsvar, FALSE);
1271 nsIWritableVariant_Release(nsvar);
1272 if(NS_FAILED(nsres))
1273 ERR("AppendElement failed: %08x\n", nsres);
1275 call_js_func(script_container, (nsISupports*)nswindow/*HTMLWINDOW2(This)*/, "wineConfig",
1276 wineConfig_func, 1, args, (nsIArray*)argv);
1278 nsIMutableArray_Release(argv);
1279 nsIScriptContainer_Release(script_container);
1282 HTMLWindow *HTMLWindow_Create(HTMLDocument *doc)
1284 HTMLWindow *ret = heap_alloc_zero(sizeof(HTMLWindow));
1286 ret->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl;
1287 ret->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl;
1288 ret->lpIDispatchExVtbl = &WindowDispExVtbl;
1289 ret->ref = 1;
1290 ret->doc = doc;
1292 init_dispex(&ret->dispex, (IUnknown*)HTMLWINDOW2(ret), &HTMLWindow_dispex);
1294 if(doc->nscontainer) {
1295 nsresult nsres;
1297 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &ret->nswindow);
1298 if(NS_FAILED(nsres))
1299 ERR("GetContentDOMWindow failed: %08x\n", nsres);
1302 list_add_head(&window_list, &ret->entry);
1304 return ret;
1307 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
1309 HTMLWindow *iter;
1311 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) {
1312 if(iter->nswindow == nswindow)
1313 return iter;
1316 return NULL;