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 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);
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);
67 IUnknown_AddRef((IUnknown*)*ppv);
71 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
75 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
77 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
78 LONG ref = InterlockedIncrement(&This->ref);
80 TRACE("(%p) ref=%d\n", This, ref);
85 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
87 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
88 LONG ref = InterlockedDecrement(&This->ref);
90 TRACE("(%p) ref=%d\n", This, ref);
93 list_remove(&This->entry);
100 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
102 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
104 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
107 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
108 LCID lcid, ITypeInfo **ppTInfo)
110 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
112 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
115 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
116 LPOLESTR *rgszNames, UINT cNames,
117 LCID lcid, DISPID *rgDispId)
119 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
121 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
124 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
125 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
126 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
128 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
130 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
131 pVarResult, pExcepInfo, puArgErr);
134 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
136 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
137 FIXME("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
141 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, long *p)
143 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
144 FIXME("(%p)->(%p)\n", This, p);
148 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
150 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
151 FIXME("(%p)->(%p)\n", This, p);
155 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
157 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
158 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
162 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
164 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
165 FIXME("(%p)->(%p)\n", This, p);
169 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
171 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
172 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
176 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
178 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
179 FIXME("(%p)->(%p)\n", This, p);
183 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
184 long msec, VARIANT *language, long *timerID)
186 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
189 TRACE("(%p)->(%s %ld %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
191 V_VT(&expr_var) = VT_BSTR;
192 V_BSTR(&expr_var) = expression;
194 return IHTMLWindow3_setTimeout(HTMLWINDOW3(This), &expr_var, msec, language, timerID);
197 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, long timerID)
199 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
200 FIXME("(%p)->(%ld)\n", This, timerID);
204 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
206 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
209 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
211 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
212 sizeof(wszTitle)/sizeof(WCHAR))) {
213 WARN("Could not load message box title: %d\n", GetLastError());
217 MessageBoxW(This->doc->hwnd, message, wszTitle, MB_ICONWARNING);
221 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
222 VARIANT_BOOL *confirmed)
224 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
225 FIXME("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
229 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
230 BSTR dststr, VARIANT *textdata)
232 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
233 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
237 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
239 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
240 FIXME("(%p)->(%p)\n", This, p);
244 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
246 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
247 FIXME("(%p)->(%p)\n", This, p);
251 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
253 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
254 FIXME("(%p)->(%p)\n", This, p);
258 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
260 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
261 FIXME("(%p)->()\n", This);
265 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
267 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
268 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
272 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
274 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
275 FIXME("(%p)->(%p)\n", This, p);
279 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
281 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
283 TRACE("(%p)->(%p)\n", This, p);
285 *p = OmNavigator_Create();
289 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
291 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
292 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
296 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
298 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
299 FIXME("(%p)->(%p)\n", This, p);
303 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
305 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
306 FIXME("(%p)->(%p)\n", This, p);
310 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
311 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
313 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
314 FIXME("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
315 debugstr_w(features), replace, pomWindowResult);
319 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
321 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
322 FIXME("(%p)->(%p)\n", This, p);
326 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
328 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
329 FIXME("(%p)->(%p)\n", This, p);
333 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
335 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
336 FIXME("(%p)->(%p)\n", This, p);
340 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
342 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
343 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
347 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
349 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
350 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
354 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
356 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
357 FIXME("(%p)->(%p)\n", This, p);
361 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
363 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
364 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
368 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
370 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
371 FIXME("(%p)->(%p)\n", This, p);
375 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
377 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
378 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
382 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
384 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
385 FIXME("(%p)->(%p)\n", This, p);
389 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
391 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
392 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
396 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
398 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
399 FIXME("(%p)->(%p)\n", This, p);
403 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
405 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
406 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
410 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
412 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
413 FIXME("(%p)->(%p)\n", This, p);
417 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
419 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
420 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
424 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
426 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
427 FIXME("(%p)->(%p)\n", This, p);
431 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
433 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
434 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
438 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
440 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
441 FIXME("(%p)->(%p)\n", This, p);
445 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
447 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
448 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
452 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
454 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
455 FIXME("(%p)->(%p)\n", This, p);
459 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
461 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
462 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
466 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
468 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
469 FIXME("(%p)->(%p)\n", This, p);
473 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
475 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
477 TRACE("(%p)->(%p)\n", This, p);
480 /* FIXME: We should return a wrapper object here */
481 *p = HTMLDOC(This->doc);
482 IHTMLDocument2_AddRef(*p);
490 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
492 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
493 FIXME("(%p)->(%p)\n", This, p);
497 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
499 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
500 FIXME("(%p)->(%p)\n", This, p);
504 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
505 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
507 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
508 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
512 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
515 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
516 FIXME("(%p)->(%s v(%d) %s)\n", This, debugstr_w(helpURL), V_VT(&helpArg), debugstr_w(features));
520 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
522 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
523 FIXME("(%p)->(%p)\n", This, p);
527 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
529 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
531 TRACE("(%p)->(%p)\n", This, p);
533 if(!This->doc->option_factory)
534 This->doc->option_factory = HTMLOptionElementFactory_Create(This->doc);
536 *p = HTMLOPTFACTORY(This->doc->option_factory);
537 IHTMLOptionElementFactory_AddRef(*p);
542 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
544 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
545 FIXME("(%p)->()\n", This);
549 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
551 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
552 FIXME("(%p)->(%p)\n", This, p);
556 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
558 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
559 FIXME("(%p)->()\n", This);
563 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, long x, long y)
565 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
566 FIXME("(%p)->(%ld %ld)\n", This, x, y);
570 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
572 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
573 FIXME("(%p)->(%p)\n", This, p);
577 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
578 long msec, VARIANT *language, long *timerID)
580 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
581 FIXME("(%p)->(%s %ld %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
585 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, long timerID)
587 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
588 FIXME("(%p)->(%ld)\n", This, timerID);
592 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
594 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
595 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
599 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
601 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
602 FIXME("(%p)->(%p)\n", This, p);
606 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
609 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
610 FIXME("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
614 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
616 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
617 FIXME("(%p)->(%p)\n", This, String);
621 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, long x, long y)
623 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
624 FIXME("(%p)->(%ld %ld)\n", This, x, y);
628 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, long x, long y)
630 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
631 FIXME("(%p)->(%ld %ld)\n", This, x, y);
635 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, long x, long y)
637 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
638 FIXME("(%p)->(%ld %ld)\n", This, x, y);
642 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, long x, long y)
644 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
645 FIXME("(%p)->(%ld %ld)\n", This, x, y);
649 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, long x, long y)
651 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
652 FIXME("(%p)->(%ld %ld)\n", This, x, y);
656 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, long x, long y)
658 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
659 FIXME("(%p)->(%ld %ld)\n", This, x, y);
663 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
665 HTMLWindow *This = HTMLWINDOW2_THIS(iface);
667 TRACE("(%p)->(%p)\n", This, p);
671 if(!This->doc->hostui)
674 return IDocHostUIHandler_GetExternal(This->doc->hostui, p);
677 #undef HTMLWINDOW2_THIS
679 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
680 HTMLWindow2_QueryInterface,
683 HTMLWindow2_GetTypeInfoCount,
684 HTMLWindow2_GetTypeInfo,
685 HTMLWindow2_GetIDsOfNames,
688 HTMLWindow2_get_length,
689 HTMLWindow2_get_frames,
690 HTMLWindow2_put_defaultStatus,
691 HTMLWindow2_get_defaultStatus,
692 HTMLWindow2_put_status,
693 HTMLWindow2_get_status,
694 HTMLWindow2_setTimeout,
695 HTMLWindow2_clearTimeout,
699 HTMLWindow2_get_Image,
700 HTMLWindow2_get_location,
701 HTMLWindow2_get_history,
703 HTMLWindow2_put_opener,
704 HTMLWindow2_get_opener,
705 HTMLWindow2_get_navigator,
706 HTMLWindow2_put_name,
707 HTMLWindow2_get_name,
708 HTMLWindow2_get_parent,
710 HTMLWindow2_get_self,
712 HTMLWindow2_get_window,
713 HTMLWindow2_navigate,
714 HTMLWindow2_put_onfocus,
715 HTMLWindow2_get_onfocus,
716 HTMLWindow2_put_onblur,
717 HTMLWindow2_get_onblur,
718 HTMLWindow2_put_onload,
719 HTMLWindow2_get_onload,
720 HTMLWindow2_put_onbeforeunload,
721 HTMLWindow2_get_onbeforeunload,
722 HTMLWindow2_put_onunload,
723 HTMLWindow2_get_onunload,
724 HTMLWindow2_put_onhelp,
725 HTMLWindow2_get_onhelp,
726 HTMLWindow2_put_onerror,
727 HTMLWindow2_get_onerror,
728 HTMLWindow2_put_onresize,
729 HTMLWindow2_get_onresize,
730 HTMLWindow2_put_onscroll,
731 HTMLWindow2_get_onscroll,
732 HTMLWindow2_get_document,
733 HTMLWindow2_get_event,
734 HTMLWindow2_get__newEnum,
735 HTMLWindow2_showModalDialog,
736 HTMLWindow2_showHelp,
737 HTMLWindow2_get_screen,
738 HTMLWindow2_get_Option,
740 HTMLWindow2_get_closed,
743 HTMLWindow2_get_clientInformation,
744 HTMLWindow2_setInterval,
745 HTMLWindow2_clearInterval,
746 HTMLWindow2_put_offscreenBuffering,
747 HTMLWindow2_get_offscreenBuffering,
748 HTMLWindow2_execScript,
749 HTMLWindow2_toString,
750 HTMLWindow2_scrollBy,
751 HTMLWindow2_scrollTo,
754 HTMLWindow2_resizeTo,
755 HTMLWindow2_resizeBy,
756 HTMLWindow2_get_external
759 #define HTMLWINDOW3_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow3, iface)
761 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
763 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
765 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This), riid, ppv);
768 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
770 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
772 return IHTMLWindow2_AddRef(HTMLWINDOW2(This));
775 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
777 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
779 return IHTMLWindow2_Release(HTMLWINDOW2(This));
782 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
784 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
786 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This), pctinfo);
789 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
790 LCID lcid, ITypeInfo **ppTInfo)
792 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
794 return IDispatchEx_GetTypeInfo(DISPATCHEX(This), iTInfo, lcid, ppTInfo);
797 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
798 LPOLESTR *rgszNames, UINT cNames,
799 LCID lcid, DISPID *rgDispId)
801 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
803 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This), riid, rgszNames, cNames, lcid, rgDispId);
806 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
807 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
808 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
810 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
812 return IDispatchEx_Invoke(DISPATCHEX(This), dispIdMember, riid, lcid, wFlags, pDispParams,
813 pVarResult, pExcepInfo, puArgErr);
816 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, long *p)
818 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
819 FIXME("(%p)->(%p)\n", This, p);
823 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, long *p)
825 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
826 FIXME("(%p)->(%p)\n", This, p);
830 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
832 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
833 FIXME("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
837 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
839 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
840 FIXME("(%p)->()\n", This);
844 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, long msec,
845 VARIANT *language, long *timerID)
847 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
849 TRACE("(%p)->(%p(%d) %ld %p %p)\n", This, expression, V_VT(expression), msec, language, timerID);
851 switch(V_VT(expression)) {
853 *timerID = set_task_timer(This->doc, msec, V_DISPATCH(expression));
857 FIXME("unimplemented vt=%d\n", V_VT(expression));
863 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, long msec,
864 VARIANT *language, long *timerID)
866 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
867 FIXME("(%p)->(%p %ld %p %p)\n", This, expression, msec, language, timerID);
871 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
873 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
874 FIXME("(%p)\n", This);
878 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
880 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
881 FIXME("(%p)->()\n", This);
885 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
887 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
888 FIXME("(%p)->(%p)\n", This, p);
892 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
894 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
895 FIXME("(%p)->()\n", This);
899 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
901 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
902 FIXME("(%p)->(%p)\n", This, p);
906 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
908 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
909 FIXME("(%p)->(%p)\n", This, p);
913 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
914 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
916 HTMLWindow *This = HTMLWINDOW3_THIS(iface);
917 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
921 #undef HTMLWINDOW3_THIS
923 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
924 HTMLWindow3_QueryInterface,
927 HTMLWindow3_GetTypeInfoCount,
928 HTMLWindow3_GetTypeInfo,
929 HTMLWindow3_GetIDsOfNames,
931 HTMLWindow3_get_screenLeft,
932 HTMLWindow3_get_screenTop,
933 HTMLWindow3_attachEvent,
934 HTMLWindow3_detachEvent,
935 HTMLWindow3_setTimeout,
936 HTMLWindow3_setInterval,
938 HTMLWindow3_put_onbeforeprint,
939 HTMLWindow3_get_onbeforeprint,
940 HTMLWindow3_put_onafterprint,
941 HTMLWindow3_get_onafterprint,
942 HTMLWindow3_get_clipboardData,
943 HTMLWindow3_showModelessDialog
946 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLWindow, IDispatchEx, iface)
948 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
950 HTMLWindow *This = DISPEX_THIS(iface);
952 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This), riid, ppv);
955 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
957 HTMLWindow *This = DISPEX_THIS(iface);
959 return IHTMLWindow2_AddRef(HTMLWINDOW2(This));
962 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
964 HTMLWindow *This = DISPEX_THIS(iface);
966 return IHTMLWindow2_AddRef(HTMLWINDOW2(This));
969 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
971 HTMLWindow *This = DISPEX_THIS(iface);
973 TRACE("(%p)->(%p)\n", This, pctinfo);
975 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This->dispex), pctinfo);
978 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
979 LCID lcid, ITypeInfo **ppTInfo)
981 HTMLWindow *This = DISPEX_THIS(iface);
983 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
985 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This->dispex), iTInfo, lcid, ppTInfo);
988 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
989 LPOLESTR *rgszNames, UINT cNames,
990 LCID lcid, DISPID *rgDispId)
992 HTMLWindow *This = DISPEX_THIS(iface);
994 TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
997 /* FIXME: Use script dispatch */
999 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This->dispex), riid, rgszNames, cNames, lcid, rgDispId);
1002 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1003 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1004 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1006 HTMLWindow *This = DISPEX_THIS(iface);
1008 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1009 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1011 /* FIXME: Use script dispatch */
1013 return IDispatchEx_Invoke(DISPATCHEX(&This->dispex), dispIdMember, riid, lcid, wFlags, pDispParams,
1014 pVarResult, pExcepInfo, puArgErr);
1017 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
1019 HTMLWindow *This = DISPEX_THIS(iface);
1021 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
1023 return IDispatchEx_GetDispID(DISPATCHEX(&This->dispex), bstrName, grfdex, pid);
1026 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
1027 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
1029 HTMLWindow *This = DISPEX_THIS(iface);
1031 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1033 return IDispatchEx_InvokeEx(DISPATCHEX(&This->dispex), id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
1036 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
1038 HTMLWindow *This = DISPEX_THIS(iface);
1040 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
1042 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This->dispex), bstrName, grfdex);
1045 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
1047 HTMLWindow *This = DISPEX_THIS(iface);
1049 TRACE("(%p)->(%x)\n", This, id);
1051 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This->dispex), id);
1054 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
1056 HTMLWindow *This = DISPEX_THIS(iface);
1058 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
1060 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This->dispex), id, grfdexFetch, pgrfdex);
1063 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
1065 HTMLWindow *This = DISPEX_THIS(iface);
1067 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
1069 return IDispatchEx_GetMemberName(DISPATCHEX(&This->dispex), id, pbstrName);
1072 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
1074 HTMLWindow *This = DISPEX_THIS(iface);
1076 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
1078 return IDispatchEx_GetNextDispID(DISPATCHEX(&This->dispex), grfdex, id, pid);
1081 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
1083 HTMLWindow *This = DISPEX_THIS(iface);
1085 TRACE("(%p)->(%p)\n", This, ppunk);
1087 return IDispatchEx_GetNameSpaceParent(DISPATCHEX(&This->dispex), ppunk);
1092 static const IDispatchExVtbl WindowDispExVtbl = {
1093 WindowDispEx_QueryInterface,
1094 WindowDispEx_AddRef,
1095 WindowDispEx_Release,
1096 WindowDispEx_GetTypeInfoCount,
1097 WindowDispEx_GetTypeInfo,
1098 WindowDispEx_GetIDsOfNames,
1099 WindowDispEx_Invoke,
1100 WindowDispEx_GetDispID,
1101 WindowDispEx_InvokeEx,
1102 WindowDispEx_DeleteMemberByName,
1103 WindowDispEx_DeleteMemberByDispID,
1104 WindowDispEx_GetMemberProperties,
1105 WindowDispEx_GetMemberName,
1106 WindowDispEx_GetNextDispID,
1107 WindowDispEx_GetNameSpaceParent
1110 static dispex_static_data_t HTMLWindow_dispex = {
1111 DispHTMLWindow2_tid,
1120 static const char wineConfig_func[] =
1121 "window.__defineGetter__(\"external\",function() {\n"
1122 " return window.__wineWindow__.external;\n"
1124 "window.__wineWindow__ = wineWindow;\n";
1126 static void astr_to_nswstr(const char *str, nsAString *nsstr)
1131 len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0);
1132 wstr = heap_alloc(len*sizeof(WCHAR));
1133 MultiByteToWideChar(CP_ACP, 0, str, -1, wstr, len);
1135 nsAString_Init(nsstr, wstr);
1140 static nsresult call_js_func(nsIScriptContainer *script_container, nsISupports *target,
1141 const char *name, const char *body,
1142 PRUint32 argc, const char **arg_names, nsIArray *argv)
1144 nsACString name_str;
1146 JSObject func_obj, jsglobal;
1150 nsres = nsIScriptContainer_GetGlobalObject(script_container, &jsglobal);
1151 if(NS_FAILED(nsres))
1152 ERR("GetGlobalObject: %08x\n", nsres);
1154 nsACString_Init(&name_str, name);
1155 astr_to_nswstr(body, &body_str);
1157 nsres = nsIScriptContainer_CompileFunction(script_container, jsglobal, &name_str, argc, arg_names,
1158 &body_str, NULL, 1, FALSE, &func_obj);
1160 nsACString_Finish(&name_str);
1161 nsAString_Finish(&body_str);
1163 if(NS_FAILED(nsres)) {
1164 ERR("CompileFunction failed: %08x\n", nsres);
1168 nsres = nsIScriptContainer_CallFunction(script_container, target, jsglobal, func_obj, argv, &jsret);
1170 nsIScriptContainer_DropScriptObject(script_container, func_obj);
1171 nsIScriptContainer_DropScriptObject(script_container, jsglobal);
1172 if(NS_FAILED(nsres)) {
1173 ERR("CallFunction failed: %08x\n", nsres);
1177 nsIVariant_Release(jsret);
1181 void setup_nswindow(HTMLWindow *This)
1183 nsIScriptContainer *script_container;
1184 nsIDOMWindow *nswindow;
1185 nsIDOMDocument *domdoc;
1186 nsIWritableVariant *nsvar;
1187 nsIMutableArray *argv;
1190 static const char *args[] = {"wineWindow"};
1192 TRACE("(%p)\n", This);
1194 nsIWebNavigation_GetDocument(This->doc->nscontainer->navigation, &domdoc);
1195 nsres = nsIDOMDocument_QueryInterface(domdoc, &IID_nsIScriptContainer, (void**)&script_container);
1196 nsIDOMDocument_Release(domdoc);
1197 if(NS_FAILED(nsres)) {
1198 TRACE("Could not get nsIDOMScriptContainer: %08x\n", nsres);
1202 nsIWebBrowser_GetContentDOMWindow(This->doc->nscontainer->webbrowser, &nswindow);
1204 nsvar = create_nsvariant();
1205 nsres = nsIWritableVariant_SetAsInterface(nsvar, &IID_IDispatch, HTMLWINDOW2(This));
1206 if(NS_FAILED(nsres))
1207 ERR("SetAsInterface failed: %08x\n", nsres);
1209 argv = create_nsarray();
1210 nsres = nsIMutableArray_AppendElement(argv, (nsISupports*)nsvar, FALSE);
1211 nsIWritableVariant_Release(nsvar);
1212 if(NS_FAILED(nsres))
1213 ERR("AppendElement failed: %08x\n", nsres);
1215 call_js_func(script_container, (nsISupports*)nswindow/*HTMLWINDOW2(This)*/, "wineConfig",
1216 wineConfig_func, 1, args, (nsIArray*)argv);
1218 nsIMutableArray_Release(argv);
1219 nsIScriptContainer_Release(script_container);
1222 HTMLWindow *HTMLWindow_Create(HTMLDocument *doc)
1224 HTMLWindow *ret = heap_alloc(sizeof(HTMLWindow));
1226 ret->lpHTMLWindow2Vtbl = &HTMLWindow2Vtbl;
1227 ret->lpHTMLWindow3Vtbl = &HTMLWindow3Vtbl;
1228 ret->lpIDispatchExVtbl = &WindowDispExVtbl;
1232 init_dispex(&ret->dispex, (IUnknown*)HTMLWINDOW2(ret), &HTMLWindow_dispex);
1234 if(doc->nscontainer) {
1237 nsres = nsIWebBrowser_GetContentDOMWindow(doc->nscontainer->webbrowser, &ret->nswindow);
1238 if(NS_FAILED(nsres))
1239 ERR("GetContentDOMWindow failed: %08x\n", nsres);
1242 list_add_head(&window_list, &ret->entry);
1247 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
1251 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) {
1252 if(iter->nswindow == nswindow)