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
28 #include "wine/debug.h"
29 #include "wine/unicode.h"
31 #include "mshtml_private.h"
34 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
36 #define HTMLWINDOW2_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow2, iface)
38 static struct list window_list = LIST_INIT(window_list);
40 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
42 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
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_IHTMLFramesCollection2, riid)) {
53 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
54 *ppv = HTMLWINDOW2(This);
55 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
56 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
57 *ppv = HTMLWINDOW2(This);
61 IUnknown_AddRef((IUnknown*)*ppv);
65 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
69 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
71 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
72 LONG ref = InterlockedIncrement(&This->ref);
74 TRACE("(%p) ref=%d\n", This, ref);
79 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
81 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
82 LONG ref = InterlockedDecrement(&This->ref);
84 TRACE("(%p) ref=%d\n", This, ref);
87 list_remove(&This->entry);
94 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
96 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
98 TRACE("(%p)->(%p)\n", This, pctinfo);
104 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
105 LCID lcid, ITypeInfo **ppTInfo)
107 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
110 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
112 hres = get_typeinfo(IHTMLWindow2_tid, ppTInfo);
114 ITypeInfo_AddRef(*ppTInfo);
119 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
120 LPOLESTR *rgszNames, UINT cNames,
121 LCID lcid, DISPID *rgDispId)
123 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
127 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
130 hres = get_typeinfo(IHTMLWindow2_tid, &typeinfo);
132 hres = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
137 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
138 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
139 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
141 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
145 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
146 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
148 hres = get_typeinfo(IHTMLWindow2_tid, &typeinfo);
150 hres = ITypeInfo_Invoke(typeinfo, HTMLWINDOW2(This), dispIdMember, wFlags, pDispParams,
151 pVarResult, pExcepInfo, puArgErr);
156 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
158 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
159 FIXME("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
163 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, long *p)
165 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
166 FIXME("(%p)->(%p)\n", This, p);
170 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
172 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
173 FIXME("(%p)->(%p)\n", This, p);
177 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
179 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
180 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
184 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
186 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
187 FIXME("(%p)->(%p)\n", This, p);
191 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
193 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
194 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
198 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
200 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
201 FIXME("(%p)->(%p)\n", This, p);
205 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
206 long msec, VARIANT *language, long *timerID)
208 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
209 FIXME("(%p)->(%s %ld %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
213 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, long timerID)
215 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
216 FIXME("(%p)->(%ld)\n", This, timerID);
220 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
222 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
225 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
227 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
228 sizeof(wszTitle)/sizeof(WCHAR))) {
229 WARN("Could not load message box title: %d\n", GetLastError());
233 MessageBoxW(This->doc->hwnd, message, wszTitle, MB_ICONWARNING);
237 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
238 VARIANT_BOOL *confirmed)
240 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
241 FIXME("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
245 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
246 BSTR dststr, VARIANT *textdata)
248 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
249 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
253 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
255 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
256 FIXME("(%p)->(%p)\n", This, p);
260 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
262 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
263 FIXME("(%p)->(%p)\n", This, p);
267 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
269 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
270 FIXME("(%p)->(%p)\n", This, p);
274 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
276 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
277 FIXME("(%p)->()\n", This);
281 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
283 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
284 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
288 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
290 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
291 FIXME("(%p)->(%p)\n", This, p);
295 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
297 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
299 TRACE("(%p)->(%p)\n", This, p);
301 *p = OmNavigator_Create();
305 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
307 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
308 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
312 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
314 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
315 FIXME("(%p)->(%p)\n", This, p);
319 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
321 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
322 FIXME("(%p)->(%p)\n", This, p);
326 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
327 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
329 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
330 FIXME("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
331 debugstr_w(features), replace, pomWindowResult);
335 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
337 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
338 FIXME("(%p)->(%p)\n", This, p);
342 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
344 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
345 FIXME("(%p)->(%p)\n", This, p);
349 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
351 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
352 FIXME("(%p)->(%p)\n", This, p);
356 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
358 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
359 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
363 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
365 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
366 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
370 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
372 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
373 FIXME("(%p)->(%p)\n", This, p);
377 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
379 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
380 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
384 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
386 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
387 FIXME("(%p)->(%p)\n", This, p);
391 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
393 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
394 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
398 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
400 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
401 FIXME("(%p)->(%p)\n", This, p);
405 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
407 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
408 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
412 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
414 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
415 FIXME("(%p)->(%p)\n", This, p);
419 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
421 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
422 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
426 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
428 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
429 FIXME("(%p)->(%p)\n", This, p);
433 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
435 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
436 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
440 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
442 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
443 FIXME("(%p)->(%p)\n", This, p);
447 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
449 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
450 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
454 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
456 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
457 FIXME("(%p)->(%p)\n", This, p);
461 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
463 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
464 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
468 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
470 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
471 FIXME("(%p)->(%p)\n", This, p);
475 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
477 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
478 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
482 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
484 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
485 FIXME("(%p)->(%p)\n", This, p);
489 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
491 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
492 FIXME("(%p)->(%p)\n", This, p);
496 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
498 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
499 FIXME("(%p)->(%p)\n", This, p);
503 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
505 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
506 FIXME("(%p)->(%p)\n", This, p);
510 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
511 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
513 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
514 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
518 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
521 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
522 FIXME("(%p)->(%s v(%d) %s)\n", This, debugstr_w(helpURL), V_VT(&helpArg), debugstr_w(features));
526 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
528 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
529 FIXME("(%p)->(%p)\n", This, p);
533 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
535 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
537 TRACE("(%p)->(%p)\n", This, p);
539 if(!This->doc->option_factory)
540 This->doc->option_factory = HTMLOptionElementFactory_Create(This->doc);
542 *p = HTMLOPTFACTORY(This->doc->option_factory);
543 IHTMLOptionElementFactory_AddRef(*p);
548 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
550 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
551 FIXME("(%p)->()\n", This);
555 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
557 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
558 FIXME("(%p)->(%p)\n", This, p);
562 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
564 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
565 FIXME("(%p)->()\n", This);
569 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, long x, long y)
571 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
572 FIXME("(%p)->(%ld %ld)\n", This, x, y);
576 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
578 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
579 FIXME("(%p)->(%p)\n", This, p);
583 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
584 long msec, VARIANT *language, long *timerID)
586 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
587 FIXME("(%p)->(%s %ld %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
591 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, long timerID)
593 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
594 FIXME("(%p)->(%ld)\n", This, timerID);
598 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
600 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
601 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
605 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
607 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
608 FIXME("(%p)->(%p)\n", This, p);
612 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
615 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
616 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
620 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
622 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
623 FIXME("(%p)->(%p)\n", This, String);
627 static HRESULT WINAPI HTMLWindow2_scrollBy(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_scrollTo(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_moveTo(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_moveBy(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_resizeTo(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_resizeBy(IHTMLWindow2 *iface, long x, long y)
664 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
665 FIXME("(%p)->(%ld %ld)\n", This, x, y);
669 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
671 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
673 TRACE("(%p)->(%p)\n", This, p);
677 if(!This->doc->hostui)
680 return IDocHostUIHandler_GetExternal(This->doc->hostui, p);
683 #undef HTMLWINDOW2_THIS
685 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
686 HTMLWindow2_QueryInterface,
689 HTMLWindow2_GetTypeInfoCount,
690 HTMLWindow2_GetTypeInfo,
691 HTMLWindow2_GetIDsOfNames,
694 HTMLWindow2_get_length,
695 HTMLWindow2_get_frames,
696 HTMLWindow2_put_defaultStatus,
697 HTMLWindow2_get_defaultStatus,
698 HTMLWindow2_put_status,
699 HTMLWindow2_get_status,
700 HTMLWindow2_setTimeout,
701 HTMLWindow2_clearTimeout,
705 HTMLWindow2_get_Image,
706 HTMLWindow2_get_location,
707 HTMLWindow2_get_history,
709 HTMLWindow2_put_opener,
710 HTMLWindow2_get_opener,
711 HTMLWindow2_get_navigator,
712 HTMLWindow2_put_name,
713 HTMLWindow2_get_name,
714 HTMLWindow2_get_parent,
716 HTMLWindow2_get_self,
718 HTMLWindow2_get_window,
719 HTMLWindow2_navigate,
720 HTMLWindow2_put_onfocus,
721 HTMLWindow2_get_onfocus,
722 HTMLWindow2_put_onblur,
723 HTMLWindow2_get_onblur,
724 HTMLWindow2_put_onload,
725 HTMLWindow2_get_onload,
726 HTMLWindow2_put_onbeforeunload,
727 HTMLWindow2_get_onbeforeunload,
728 HTMLWindow2_put_onunload,
729 HTMLWindow2_get_onunload,
730 HTMLWindow2_put_onhelp,
731 HTMLWindow2_get_onhelp,
732 HTMLWindow2_put_onerror,
733 HTMLWindow2_get_onerror,
734 HTMLWindow2_put_onresize,
735 HTMLWindow2_get_onresize,
736 HTMLWindow2_put_onscroll,
737 HTMLWindow2_get_onscroll,
738 HTMLWindow2_get_document,
739 HTMLWindow2_get_event,
740 HTMLWindow2_get__newEnum,
741 HTMLWindow2_showModalDialog,
742 HTMLWindow2_showHelp,
743 HTMLWindow2_get_screen,
744 HTMLWindow2_get_Option,
746 HTMLWindow2_get_closed,
749 HTMLWindow2_get_clientInformation,
750 HTMLWindow2_setInterval,
751 HTMLWindow2_clearInterval,
752 HTMLWindow2_put_offscreenBuffering,
753 HTMLWindow2_get_offscreenBuffering,
754 HTMLWindow2_execScript,
755 HTMLWindow2_toString,
756 HTMLWindow2_scrollBy,
757 HTMLWindow2_scrollTo,
760 HTMLWindow2_resizeTo,
761 HTMLWindow2_resizeBy,
762 HTMLWindow2_get_external
765 static const char wineConfig_func[] =
766 "window.__defineGetter__(\"external\",function() {\n"
767 " return window.__wineWindow__.external;\n"
769 "window.__wineWindow__ = wineWindow;\n";
771 static void astr_to_nswstr(const char *str, nsAString *nsstr)
776 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
777 wstr = heap_alloc(len*sizeof(WCHAR));
778 MultiByteToWideChar(CP_ACP, 0, str, -1, wstr, len);
780 nsAString_Init(nsstr, wstr);
785 static nsresult call_js_func(nsIScriptContainer *script_container, nsISupports *target,
786 const char *name, const char *body,
787 PRUint32 argc, const char **arg_names, nsIArray *argv)
791 JSObject func_obj, jsglobal;
795 nsres = nsIScriptContainer_GetGlobalObject(script_container, &jsglobal);
797 ERR("GetGlobalObject: %08x\n", nsres);
799 nsACString_Init(&name_str, name);
800 astr_to_nswstr(body, &body_str);
802 nsres = nsIScriptContainer_CompileFunction(script_container, jsglobal, &name_str, argc, arg_names,
803 &body_str, NULL, 1, FALSE, &func_obj);
805 nsACString_Finish(&name_str);
806 nsAString_Finish(&body_str);
808 if(NS_FAILED(nsres)) {
809 ERR("CompileFunction failed: %08x\n", nsres);
813 nsres = nsIScriptContainer_CallFunction(script_container, target, jsglobal, func_obj, argv, &jsret);
815 nsIScriptContainer_DropScriptObject(script_container, func_obj);
816 nsIScriptContainer_DropScriptObject(script_container, jsglobal);
817 if(NS_FAILED(nsres)) {
818 ERR("CallFunction failed: %08x\n", nsres);
822 nsIVariant_Release(jsret);
826 void setup_nswindow(HTMLWindow *This)
828 nsIScriptContainer *script_container;
829 nsIDOMWindow *nswindow;
830 nsIDOMDocument *domdoc;
831 nsIWritableVariant *nsvar;
832 nsIMutableArray *argv;
835 static const char *args[] = {"wineWindow"};
837 TRACE("(%p)\n", This);
839 nsIWebNavigation_GetDocument(This->doc->nscontainer->navigation, &domdoc);
840 nsres = nsIDOMDocument_QueryInterface(domdoc, &IID_nsIScriptContainer, (void**)&script_container);
841 nsIDOMDocument_Release(domdoc);
842 if(NS_FAILED(nsres)) {
843 TRACE("Could not get nsIDOMScriptContainer: %08x\n", nsres);
847 nsIWebBrowser_GetContentDOMWindow(This->doc->nscontainer->webbrowser, &nswindow);
849 nsvar = create_nsvariant();
850 nsres = nsIWritableVariant_SetAsInterface(nsvar, &IID_IDispatch, HTMLWINDOW2(This));
852 ERR("SetAsInterface failed: %08x\n", nsres);
854 argv = create_nsarray();
855 nsres = nsIMutableArray_AppendElement(argv, (nsISupports*)nsvar, FALSE);
856 nsIWritableVariant_Release(nsvar);
858 ERR("AppendElement failed: %08x\n", nsres);
860 call_js_func(script_container, (nsISupports*)nswindow/*HTMLWINDOW2(This)*/, "wineConfig",
861 wineConfig_func, 1, args, (nsIArray*)argv);
863 nsIMutableArray_Release(argv);
864 nsIScriptContainer_Release(script_container);
867 HTMLWindow *HTMLWindow_Create(HTMLDocument *doc)
869 HTMLWindow *ret = heap_alloc(sizeof(HTMLWindow));
871 ret->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl;
873 ret->nswindow = NULL;
876 if(doc->nscontainer) {
879 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &ret->nswindow);
881 ERR("GetContentDOMWindow failed: %08x\n", nsres);
884 list_add_head(&window_list, &ret->entry);
889 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
893 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) {
894 if(iter->nswindow == nswindow)