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
32 #include "wine/debug.h"
33 #include "wine/unicode.h"
35 #include "mshtml_private.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
40 #define HTMLWINDOW2_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow2, iface)
42 static struct list window_list = LIST_INIT(window_list);
44 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
46 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
50 if(IsEqualGUID(&IID_IUnknown, riid)) {
51 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
52 *ppv = HTMLWINDOW2(This);
53 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
54 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
55 *ppv = HTMLWINDOW2(This);
56 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2, riid)) {
57 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
58 *ppv = HTMLWINDOW2(This);
59 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
60 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
61 *ppv = HTMLWINDOW2(This);
65 IUnknown_AddRef((IUnknown*)*ppv);
69 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
73 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
75 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
76 LONG ref = InterlockedIncrement(&This->ref);
78 TRACE("(%p) ref=%d\n", This, ref);
83 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
85 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
86 LONG ref = InterlockedDecrement(&This->ref);
88 TRACE("(%p) ref=%d\n", This, ref);
91 list_remove(&This->entry);
98 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
100 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
102 TRACE("(%p)->(%p)\n", This, pctinfo);
108 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
109 LCID lcid, ITypeInfo **ppTInfo)
111 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
114 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
116 hres = get_typeinfo(IHTMLWindow2_tid, ppTInfo);
118 ITypeInfo_AddRef(*ppTInfo);
123 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
124 LPOLESTR *rgszNames, UINT cNames,
125 LCID lcid, DISPID *rgDispId)
127 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
131 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
134 hres = get_typeinfo(IHTMLWindow2_tid, &typeinfo);
136 hres = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
141 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
142 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
143 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
145 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
149 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
150 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
152 hres = get_typeinfo(IHTMLWindow2_tid, &typeinfo);
154 hres = ITypeInfo_Invoke(typeinfo, HTMLWINDOW2(This), dispIdMember, wFlags, pDispParams,
155 pVarResult, pExcepInfo, puArgErr);
160 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
162 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
163 FIXME("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
167 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, long *p)
169 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
170 FIXME("(%p)->(%p)\n", This, p);
174 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
176 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
177 FIXME("(%p)->(%p)\n", This, p);
181 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
183 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
184 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
188 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
190 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
191 FIXME("(%p)->(%p)\n", This, p);
195 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
197 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
198 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
202 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
204 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
205 FIXME("(%p)->(%p)\n", This, p);
209 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
210 long msec, VARIANT *language, long *timerID)
212 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
213 FIXME("(%p)->(%s %ld %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
217 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, long timerID)
219 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
220 FIXME("(%p)->(%ld)\n", This, timerID);
224 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
226 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
229 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
231 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
232 sizeof(wszTitle)/sizeof(WCHAR))) {
233 WARN("Could not load message box title: %d\n", GetLastError());
237 MessageBoxW(This->doc->hwnd, message, wszTitle, MB_ICONWARNING);
241 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
242 VARIANT_BOOL *confirmed)
244 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
245 FIXME("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
249 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
250 BSTR dststr, VARIANT *textdata)
252 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
253 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
257 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
259 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
260 FIXME("(%p)->(%p)\n", This, p);
264 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
266 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
267 FIXME("(%p)->(%p)\n", This, p);
271 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
273 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
274 FIXME("(%p)->(%p)\n", This, p);
278 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
280 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
281 FIXME("(%p)->()\n", This);
285 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
287 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
288 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
292 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
294 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
295 FIXME("(%p)->(%p)\n", This, p);
299 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
301 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
302 FIXME("(%p)->(%p)\n", This, p);
306 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
308 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
309 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
313 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
315 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
316 FIXME("(%p)->(%p)\n", This, p);
320 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
322 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
323 FIXME("(%p)->(%p)\n", This, p);
327 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
328 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
330 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
331 FIXME("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
332 debugstr_w(features), replace, pomWindowResult);
336 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
338 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
339 FIXME("(%p)->(%p)\n", This, p);
343 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
345 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
346 FIXME("(%p)->(%p)\n", This, p);
350 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
352 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
353 FIXME("(%p)->(%p)\n", This, p);
357 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
359 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
360 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
364 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
366 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
367 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
371 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
373 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
374 FIXME("(%p)->(%p)\n", This, p);
378 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
380 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
381 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
385 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
387 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
388 FIXME("(%p)->(%p)\n", This, p);
392 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
394 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
395 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
399 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
401 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
402 FIXME("(%p)->(%p)\n", This, p);
406 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
408 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
409 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
413 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
415 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
416 FIXME("(%p)->(%p)\n", This, p);
420 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
422 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
423 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
427 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
429 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
430 FIXME("(%p)->(%p)\n", This, p);
434 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
436 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
437 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
441 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
443 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
444 FIXME("(%p)->(%p)\n", This, p);
448 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
450 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
451 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
455 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
457 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
458 FIXME("(%p)->(%p)\n", This, p);
462 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
464 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
465 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
469 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
471 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
472 FIXME("(%p)->(%p)\n", This, p);
476 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
478 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
479 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
483 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
485 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
486 FIXME("(%p)->(%p)\n", This, p);
490 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
492 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
493 FIXME("(%p)->(%p)\n", This, p);
497 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
499 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
500 FIXME("(%p)->(%p)\n", This, p);
504 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
506 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
507 FIXME("(%p)->(%p)\n", This, p);
511 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
512 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
514 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
515 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
519 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
522 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
523 FIXME("(%p)->(%s v(%d) %s)\n", This, debugstr_w(helpURL), V_VT(&helpArg), debugstr_w(features));
527 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
529 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
530 FIXME("(%p)->(%p)\n", This, p);
534 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
536 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
537 FIXME("(%p)->(%p)\n", This, p);
541 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
543 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
544 FIXME("(%p)->()\n", This);
548 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
550 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
551 FIXME("(%p)->(%p)\n", This, p);
555 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
557 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
558 FIXME("(%p)->()\n", This);
562 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, long x, long y)
564 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
565 FIXME("(%p)->(%ld %ld)\n", This, x, y);
569 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
571 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
572 FIXME("(%p)->(%p)\n", This, p);
576 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
577 long msec, VARIANT *language, long *timerID)
579 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
580 FIXME("(%p)->(%s %ld %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
584 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, long timerID)
586 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
587 FIXME("(%p)->(%ld)\n", This, timerID);
591 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
593 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
594 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
598 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
600 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
601 FIXME("(%p)->(%p)\n", This, p);
605 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
608 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
609 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
613 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
615 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
616 FIXME("(%p)->(%p)\n", This, String);
620 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, long x, long y)
622 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
623 FIXME("(%p)->(%ld %ld)\n", This, x, y);
627 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, long x, long y)
629 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
630 FIXME("(%p)->(%ld %ld)\n", This, x, y);
634 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, long x, long y)
636 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
637 FIXME("(%p)->(%ld %ld)\n", This, x, y);
641 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, long x, long y)
643 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
644 FIXME("(%p)->(%ld %ld)\n", This, x, y);
648 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, long x, long y)
650 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
651 FIXME("(%p)->(%ld %ld)\n", This, x, y);
655 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, long x, long y)
657 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
658 FIXME("(%p)->(%ld %ld)\n", This, x, y);
662 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
664 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
666 TRACE("(%p)->(%p)\n", This, p);
670 if(!This->doc->hostui)
673 return IDocHostUIHandler_GetExternal(This->doc->hostui, p);
676 #undef HTMLWINDOW2_THIS
678 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
679 HTMLWindow2_QueryInterface,
682 HTMLWindow2_GetTypeInfoCount,
683 HTMLWindow2_GetTypeInfo,
684 HTMLWindow2_GetIDsOfNames,
687 HTMLWindow2_get_length,
688 HTMLWindow2_get_frames,
689 HTMLWindow2_put_defaultStatus,
690 HTMLWindow2_get_defaultStatus,
691 HTMLWindow2_put_status,
692 HTMLWindow2_get_status,
693 HTMLWindow2_setTimeout,
694 HTMLWindow2_clearTimeout,
698 HTMLWindow2_get_Image,
699 HTMLWindow2_get_location,
700 HTMLWindow2_get_history,
702 HTMLWindow2_put_opener,
703 HTMLWindow2_get_opener,
704 HTMLWindow2_get_navigator,
705 HTMLWindow2_put_name,
706 HTMLWindow2_get_name,
707 HTMLWindow2_get_parent,
709 HTMLWindow2_get_self,
711 HTMLWindow2_get_window,
712 HTMLWindow2_navigate,
713 HTMLWindow2_put_onfocus,
714 HTMLWindow2_get_onfocus,
715 HTMLWindow2_put_onblur,
716 HTMLWindow2_get_onblur,
717 HTMLWindow2_put_onload,
718 HTMLWindow2_get_onload,
719 HTMLWindow2_put_onbeforeunload,
720 HTMLWindow2_get_onbeforeunload,
721 HTMLWindow2_put_onunload,
722 HTMLWindow2_get_onunload,
723 HTMLWindow2_put_onhelp,
724 HTMLWindow2_get_onhelp,
725 HTMLWindow2_put_onerror,
726 HTMLWindow2_get_onerror,
727 HTMLWindow2_put_onresize,
728 HTMLWindow2_get_onresize,
729 HTMLWindow2_put_onscroll,
730 HTMLWindow2_get_onscroll,
731 HTMLWindow2_get_document,
732 HTMLWindow2_get_event,
733 HTMLWindow2_get__newEnum,
734 HTMLWindow2_showModalDialog,
735 HTMLWindow2_showHelp,
736 HTMLWindow2_get_screen,
737 HTMLWindow2_get_Option,
739 HTMLWindow2_get_closed,
742 HTMLWindow2_get_clientInformation,
743 HTMLWindow2_setInterval,
744 HTMLWindow2_clearInterval,
745 HTMLWindow2_put_offscreenBuffering,
746 HTMLWindow2_get_offscreenBuffering,
747 HTMLWindow2_execScript,
748 HTMLWindow2_toString,
749 HTMLWindow2_scrollBy,
750 HTMLWindow2_scrollTo,
753 HTMLWindow2_resizeTo,
754 HTMLWindow2_resizeBy,
755 HTMLWindow2_get_external
758 static const char wineConfig_func[] =
759 "window.__defineGetter__(\"external\",function() {\n"
760 " return window.__wineWindow__.external;\n"
762 "window.__wineWindow__ = wineWindow;\n";
764 static void astr_to_nswstr(const char *str, nsAString *nsstr)
769 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
770 wstr = mshtml_alloc(len*sizeof(WCHAR));
771 MultiByteToWideChar(CP_ACP, 0, str, -1, wstr, len);
773 nsAString_Init(nsstr, wstr);
778 static nsresult call_js_func(nsIScriptContainer *script_container, nsISupports *target,
779 const char *name, const char *body,
780 PRUint32 argc, const char **arg_names, nsIArray *argv)
784 JSObject func_obj, jsglobal;
788 nsres = nsIScriptContainer_GetGlobalObject(script_container, &jsglobal);
790 ERR("GetGlobalObject: %08x\n", nsres);
792 nsACString_Init(&name_str, name);
793 astr_to_nswstr(body, &body_str);
795 nsres = nsIScriptContainer_CompileFunction(script_container, jsglobal, &name_str, argc, arg_names,
796 &body_str, NULL, 1, FALSE, &func_obj);
798 nsACString_Finish(&name_str);
799 nsAString_Finish(&body_str);
801 if(NS_FAILED(nsres)) {
802 ERR("CompileFunction failed: %08x\n", nsres);
806 nsres = nsIScriptContainer_CallFunction(script_container, target, jsglobal, func_obj, argv, &jsret);
808 nsIScriptContainer_DropScriptObject(script_container, func_obj);
809 nsIScriptContainer_DropScriptObject(script_container, jsglobal);
810 if(NS_FAILED(nsres)) {
811 ERR("CallFunction failed: %08x\n", nsres);
815 nsIVariant_Release(jsret);
819 void setup_nswindow(HTMLWindow *This)
821 nsIScriptContainer *script_container;
822 nsIDOMWindow *nswindow;
823 nsIDOMDocument *domdoc;
824 nsIWritableVariant *nsvar;
825 nsIMutableArray *argv;
828 static const char *args[] = {"wineWindow"};
830 TRACE("(%p)\n", This);
832 nsIWebNavigation_GetDocument(This->doc->nscontainer->navigation, &domdoc);
833 nsres = nsIDOMDocument_QueryInterface(domdoc, &IID_nsIScriptContainer, (void**)&script_container);
834 nsIDOMDocument_Release(domdoc);
835 if(NS_FAILED(nsres)) {
836 TRACE("Could not get nsIDOMScriptContainer: %08x\n", nsres);
840 nsIWebBrowser_GetContentDOMWindow(This->doc->nscontainer->webbrowser, &nswindow);
842 nsvar = create_nsvariant();
843 nsres = nsIWritableVariant_SetAsInterface(nsvar, &IID_IDispatch, HTMLWINDOW2(This));
845 ERR("SetAsInterface failed: %08x\n", nsres);
847 argv = create_nsarray();
848 nsres = nsIMutableArray_AppendElement(argv, (nsISupports*)nsvar, FALSE);
849 nsIWritableVariant_Release(nsvar);
851 ERR("AppendElement failed: %08x\n", nsres);
853 call_js_func(script_container, (nsISupports*)nswindow/*HTMLWINDOW2(This)*/, "wineConfig",
854 wineConfig_func, 1, args, (nsIArray*)argv);
856 nsIMutableArray_Release(argv);
857 nsIScriptContainer_Release(script_container);
860 HTMLWindow *HTMLWindow_Create(HTMLDocument *doc)
862 HTMLWindow *ret = mshtml_alloc(sizeof(HTMLWindow));
864 ret->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl;
866 ret->nswindow = NULL;
869 if(doc->nscontainer) {
872 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &ret->nswindow);
874 ERR("GetContentDOMWindow failed: %08x\n", nsres);
877 list_add_head(&window_list, &ret->entry);
882 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
886 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) {
887 if(iter->nswindow == nswindow)