2 * Copyright 2006-2012 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 #define NO_SHLWAPI_REG
35 #include "wine/debug.h"
37 #include "mshtml_private.h"
38 #include "htmlevent.h"
39 #include "htmlscript.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
45 static struct list window_list = LIST_INIT(window_list);
47 static inline BOOL is_outer_window(HTMLWindow *window)
49 return &window->outer_window->base == window;
52 static void release_children(HTMLOuterWindow *This)
54 HTMLOuterWindow *child;
56 while(!list_empty(&This->children)) {
57 child = LIST_ENTRY(list_tail(&This->children), HTMLOuterWindow, sibling_entry);
59 list_remove(&child->sibling_entry);
61 IHTMLWindow2_Release(&child->base.IHTMLWindow2_iface);
65 static HRESULT get_location(HTMLInnerWindow *This, HTMLLocation **ret)
68 IHTMLLocation_AddRef(&This->location->IHTMLLocation_iface);
72 hres = HTMLLocation_Create(This, &This->location);
77 *ret = This->location;
81 void get_top_window(HTMLOuterWindow *window, HTMLOuterWindow **ret)
83 HTMLOuterWindow *iter;
85 for(iter = window; iter->parent; iter = iter->parent);
89 static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
91 if(!window->inner_window->doc) {
92 FIXME("No document\n");
96 return set_event_handler(&window->inner_window->doc->body_event_target, NULL, window->inner_window->doc, eid, var);
99 static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
101 if(!window->inner_window->doc) {
102 FIXME("No document\n");
106 return get_event_handler(&window->inner_window->doc->body_event_target, eid, var);
109 static void detach_inner_window(HTMLInnerWindow *window)
111 HTMLOuterWindow *outer_window = window->base.outer_window;
113 if(outer_window && outer_window->doc_obj && outer_window == outer_window->doc_obj->basedoc.window)
114 window->doc->basedoc.cp_container.forward_container = NULL;
117 detach_events(window->doc);
118 abort_window_bindings(window);
119 remove_target_tasks(window->task_magic);
120 release_script_hosts(window);
121 window->base.outer_window = NULL;
123 if(outer_window && outer_window->base.inner_window == window) {
124 outer_window->base.inner_window = NULL;
125 IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
129 static inline HTMLWindow *impl_from_IHTMLWindow2(IHTMLWindow2 *iface)
131 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow2_iface);
134 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
136 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
140 if(IsEqualGUID(&IID_IUnknown, riid)) {
141 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
142 *ppv = &This->IHTMLWindow2_iface;
143 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
144 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
145 *ppv = &This->IHTMLWindow2_iface;
146 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
147 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
148 *ppv = &This->IDispatchEx_iface;
149 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2, riid)) {
150 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
151 *ppv = &This->IHTMLWindow2_iface;
152 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
153 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
154 *ppv = &This->IHTMLWindow2_iface;
155 }else if(IsEqualGUID(&IID_IHTMLWindow3, riid)) {
156 TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This, ppv);
157 *ppv = &This->IHTMLWindow3_iface;
158 }else if(IsEqualGUID(&IID_IHTMLWindow4, riid)) {
159 TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This, ppv);
160 *ppv = &This->IHTMLWindow4_iface;
161 }else if(IsEqualGUID(&IID_IHTMLWindow5, riid)) {
162 TRACE("(%p)->(IID_IHTMLWindow5 %p)\n", This, ppv);
163 *ppv = &This->IHTMLWindow5_iface;
164 }else if(IsEqualGUID(&IID_IHTMLWindow6, riid)) {
165 TRACE("(%p)->(IID_IHTMLWindow6 %p)\n", This, ppv);
166 *ppv = &This->IHTMLWindow6_iface;
167 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow, riid)) {
168 TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This, ppv);
169 *ppv = &This->IHTMLPrivateWindow_iface;
170 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
171 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
172 *ppv = &This->IServiceProvider_iface;
173 }else if(IsEqualGUID(&IID_ITravelLogClient, riid)) {
174 TRACE("(%p)->(IID_ITravelLogClient %p)\n", This, ppv);
175 *ppv = &This->ITravelLogClient_iface;
176 }else if(dispex_query_interface(&This->inner_window->dispex, riid, ppv)) {
178 return E_NOINTERFACE;
182 IUnknown_AddRef((IUnknown*)*ppv);
186 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
187 return E_NOINTERFACE;
190 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
192 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
193 LONG ref = InterlockedIncrement(&This->ref);
195 TRACE("(%p) ref=%d\n", This, ref);
200 static void release_outer_window(HTMLOuterWindow *This)
202 if(This->pending_window) {
203 abort_window_bindings(This->pending_window);
204 This->pending_window->base.outer_window = NULL;
205 IHTMLWindow2_Release(&This->pending_window->base.IHTMLWindow2_iface);
208 remove_target_tasks(This->task_magic);
209 set_current_mon(This, NULL, 0);
210 if(This->base.inner_window)
211 detach_inner_window(This->base.inner_window);
212 release_children(This);
215 IInternetSecurityManager_Release(This->secmgr);
217 if(This->frame_element)
218 This->frame_element->content_window = NULL;
220 This->window_ref->window = NULL;
221 windowref_release(This->window_ref);
224 nsIDOMWindow_Release(This->nswindow);
226 list_remove(&This->entry);
230 static void release_inner_window(HTMLInnerWindow *This)
236 detach_inner_window(This);
239 This->doc->window = NULL;
240 htmldoc_release(&This->doc->basedoc);
243 release_dispex(&This->dispex);
245 for(i=0; i < This->global_prop_cnt; i++)
246 heap_free(This->global_props[i].name);
247 heap_free(This->global_props);
250 This->location->window = NULL;
251 IHTMLLocation_Release(&This->location->IHTMLLocation_iface);
254 if(This->image_factory) {
255 This->image_factory->window = NULL;
256 IHTMLImageElementFactory_Release(&This->image_factory->IHTMLImageElementFactory_iface);
259 if(This->option_factory) {
260 This->option_factory->window = NULL;
261 IHTMLOptionElementFactory_Release(&This->option_factory->IHTMLOptionElementFactory_iface);
265 IHTMLScreen_Release(This->screen);
267 IOmHistory_Release(This->history);
269 IMoniker_Release(This->mon);
274 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
276 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
277 LONG ref = InterlockedDecrement(&This->ref);
279 TRACE("(%p) ref=%d\n", This, ref);
282 if(is_outer_window(This))
283 release_outer_window(This->outer_window);
285 release_inner_window(This->inner_window);
291 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
293 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
295 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
298 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
299 LCID lcid, ITypeInfo **ppTInfo)
301 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
303 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
306 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
307 LPOLESTR *rgszNames, UINT cNames,
308 LCID lcid, DISPID *rgDispId)
310 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
312 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
316 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
317 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
318 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
320 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
322 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
323 pDispParams, pVarResult, pExcepInfo, puArgErr);
326 static HRESULT get_frame_by_index(HTMLOuterWindow *This, PRUint32 index, HTMLOuterWindow **ret)
328 nsIDOMWindowCollection *nsframes;
329 nsIDOMWindow *nswindow;
333 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nsframes);
334 if(NS_FAILED(nsres)) {
335 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres);
339 nsres = nsIDOMWindowCollection_GetLength(nsframes, &length);
340 assert(nsres == NS_OK);
342 if(index >= length) {
343 nsIDOMWindowCollection_Release(nsframes);
344 return DISP_E_MEMBERNOTFOUND;
347 nsres = nsIDOMWindowCollection_Item(nsframes, index, &nswindow);
348 nsIDOMWindowCollection_Release(nsframes);
349 if(NS_FAILED(nsres)) {
350 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
354 *ret = nswindow_to_window(nswindow);
356 nsIDOMWindow_Release(nswindow);
360 HRESULT get_frame_by_name(HTMLOuterWindow *This, const WCHAR *name, BOOL deep, HTMLOuterWindow **ret)
362 nsIDOMWindowCollection *nsframes;
363 HTMLOuterWindow *window = NULL;
364 nsIDOMWindow *nswindow;
370 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nsframes);
371 if(NS_FAILED(nsres)) {
372 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres);
376 nsAString_InitDepend(&name_str, name);
377 nsres = nsIDOMWindowCollection_NamedItem(nsframes, &name_str, &nswindow);
378 nsAString_Finish(&name_str);
379 if(NS_FAILED(nsres)) {
380 nsIDOMWindowCollection_Release(nsframes);
385 *ret = nswindow_to_window(nswindow);
389 nsres = nsIDOMWindowCollection_GetLength(nsframes, &length);
390 assert(nsres == NS_OK);
392 for(i = 0; i < length && !window; ++i) {
393 HTMLOuterWindow *window_iter;
396 nsres = nsIDOMWindowCollection_Item(nsframes, i, &nswindow);
397 if(NS_FAILED(nsres)) {
398 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
403 window_iter = nswindow_to_window(nswindow);
405 nsIDOMWindow_Release(nswindow);
407 hres = IHTMLElement_get_id(&window_iter->frame_element->element.IHTMLElement_iface, &id);
409 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres);
413 if(id && !strcmpiW(id, name))
414 window = window_iter;
419 get_frame_by_name(window_iter, name, TRUE, &window);
422 nsIDOMWindowCollection_Release(nsframes);
430 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
432 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
433 HTMLOuterWindow *window = NULL;
436 TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
438 switch(V_VT(pvarIndex)) {
440 int index = V_I4(pvarIndex);
441 TRACE("Getting index %d\n", index);
443 return DISP_E_MEMBERNOTFOUND;
444 hres = get_frame_by_index(This->outer_window, index, &window);
448 unsigned int index = V_UINT(pvarIndex);
449 TRACE("Getting index %u\n", index);
450 hres = get_frame_by_index(This->outer_window, index, &window);
454 BSTR str = V_BSTR(pvarIndex);
455 TRACE("Getting name %s\n", wine_dbgstr_w(str));
456 hres = get_frame_by_name(This->outer_window, str, FALSE, &window);
460 WARN("Invalid index %s\n", debugstr_variant(pvarIndex));
467 return DISP_E_MEMBERNOTFOUND;
469 IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
470 V_VT(pvarResult) = VT_DISPATCH;
471 V_DISPATCH(pvarResult) = (IDispatch*)window;
475 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
477 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
478 nsIDOMWindowCollection *nscollection;
482 TRACE("(%p)->(%p)\n", This, p);
484 nsres = nsIDOMWindow_GetFrames(This->outer_window->nswindow, &nscollection);
485 if(NS_FAILED(nsres)) {
486 ERR("GetFrames failed: %08x\n", nsres);
490 nsres = nsIDOMWindowCollection_GetLength(nscollection, &length);
491 nsIDOMWindowCollection_Release(nscollection);
492 if(NS_FAILED(nsres)) {
493 ERR("GetLength failed: %08x\n", nsres);
501 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
503 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
504 FIXME("(%p)->(%p): semi-stub\n", This, p);
506 /* FIXME: Should return a separate Window object */
507 *p = (IHTMLFramesCollection2*)&This->IHTMLWindow2_iface;
508 HTMLWindow2_AddRef(iface);
512 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
514 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
515 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
519 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
521 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
522 FIXME("(%p)->(%p)\n", This, p);
526 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
528 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
530 WARN("(%p)->(%s)\n", This, debugstr_w(v));
533 * FIXME: Since IE7, setting status is blocked, but still possible in certain circumstances.
534 * Ignoring the call should be enough for us.
539 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
541 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
543 TRACE("(%p)->(%p)\n", This, p);
550 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
551 LONG msec, VARIANT *language, LONG *timerID)
553 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
556 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
558 V_VT(&expr_var) = VT_BSTR;
559 V_BSTR(&expr_var) = expression;
561 return IHTMLWindow3_setTimeout(&This->IHTMLWindow3_iface, &expr_var, msec, language, timerID);
564 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID)
566 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
568 TRACE("(%p)->(%d)\n", This, timerID);
570 return clear_task_timer(This->inner_window, FALSE, timerID);
573 #define MAX_MESSAGE_LEN 2000
575 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
577 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
578 WCHAR title[100], *msg = message;
581 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
583 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, title,
584 sizeof(title)/sizeof(WCHAR))) {
585 WARN("Could not load message box title: %d\n", GetLastError());
589 len = SysStringLen(message);
590 if(len > MAX_MESSAGE_LEN) {
591 msg = heap_alloc((MAX_MESSAGE_LEN+1)*sizeof(WCHAR));
593 return E_OUTOFMEMORY;
594 memcpy(msg, message, MAX_MESSAGE_LEN*sizeof(WCHAR));
595 msg[MAX_MESSAGE_LEN] = 0;
598 MessageBoxW(This->outer_window->doc_obj->hwnd, msg, title, MB_ICONWARNING);
604 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
605 VARIANT_BOOL *confirmed)
607 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
610 TRACE("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
612 if(!confirmed) return E_INVALIDARG;
614 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
615 sizeof(wszTitle)/sizeof(WCHAR))) {
616 WARN("Could not load message box title: %d\n", GetLastError());
617 *confirmed = VARIANT_TRUE;
621 if(MessageBoxW(This->outer_window->doc_obj->hwnd, message, wszTitle,
622 MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
623 *confirmed = VARIANT_TRUE;
624 else *confirmed = VARIANT_FALSE;
636 static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
637 WPARAM wparam, LPARAM lparam)
643 prompt_arg *arg = (prompt_arg*)lparam;
646 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
647 sizeof(wszTitle)/sizeof(WCHAR))) {
648 WARN("Could not load message box title: %d\n", GetLastError());
649 EndDialog(hwnd, wparam);
653 SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
654 SetWindowTextW(hwnd, wszTitle);
655 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_PROMPT), arg->message);
656 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_EDIT), arg->dststr);
662 case MAKEWPARAM(IDCANCEL, BN_CLICKED):
663 EndDialog(hwnd, wparam);
665 case MAKEWPARAM(IDOK, BN_CLICKED):
668 (prompt_arg*)GetWindowLongPtrW(hwnd, DWLP_USER);
669 HWND hwndPrompt = GetDlgItem(hwnd, ID_PROMPT_EDIT);
670 INT len = GetWindowTextLengthW(hwndPrompt);
674 EndDialog(hwnd, wparam);
678 V_VT(arg->textdata) = VT_BSTR;
679 if(!len && !arg->dststr)
680 V_BSTR(arg->textdata) = NULL;
683 V_BSTR(arg->textdata) = SysAllocStringLen(NULL, len);
684 GetWindowTextW(hwndPrompt, V_BSTR(arg->textdata), len+1);
686 EndDialog(hwnd, wparam);
692 EndDialog(hwnd, IDCANCEL);
699 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
700 BSTR dststr, VARIANT *textdata)
702 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
705 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
707 if(textdata) V_VT(textdata) = VT_NULL;
709 arg.message = message;
711 arg.textdata = textdata;
713 DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
714 This->outer_window->doc_obj->hwnd, prompt_dlgproc, (LPARAM)&arg);
718 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
720 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
721 HTMLInnerWindow *window = This->inner_window;
723 TRACE("(%p)->(%p)\n", This, p);
725 if(!window->image_factory) {
728 hres = HTMLImageElementFactory_Create(window, &window->image_factory);
733 *p = &window->image_factory->IHTMLImageElementFactory_iface;
734 IHTMLImageElementFactory_AddRef(*p);
739 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
741 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
742 HTMLLocation *location;
745 TRACE("(%p)->(%p)\n", This, p);
747 hres = get_location(This->inner_window, &location);
751 *p = &location->IHTMLLocation_iface;
755 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
757 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
758 HTMLInnerWindow *window = This->inner_window;
760 TRACE("(%p)->(%p)\n", This, p);
762 if(!window->history) {
765 hres = create_history(&window->history);
770 IOmHistory_AddRef(window->history);
771 *p = window->history;
775 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
777 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
778 FIXME("(%p)->()\n", This);
782 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
784 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
785 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
789 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
791 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
793 FIXME("(%p)->(%p) returning empty\n", This, p);
799 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
801 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
803 TRACE("(%p)->(%p)\n", This, p);
805 *p = OmNavigator_Create();
806 return *p ? S_OK : E_OUTOFMEMORY;
809 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
811 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
815 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
817 nsAString_InitDepend(&name_str, v);
818 nsres = nsIDOMWindow_SetName(This->outer_window->nswindow, &name_str);
819 nsAString_Finish(&name_str);
821 ERR("SetName failed: %08x\n", nsres);
826 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
828 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
832 TRACE("(%p)->(%p)\n", This, p);
834 nsAString_Init(&name_str, NULL);
835 nsres = nsIDOMWindow_GetName(This->outer_window->nswindow, &name_str);
836 return return_nsstr(nsres, &name_str, p);
839 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
841 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
842 HTMLOuterWindow *window = This->outer_window;
844 TRACE("(%p)->(%p)\n", This, p);
847 return IHTMLWindow2_get_self(&This->IHTMLWindow2_iface, p);
849 *p = &window->parent->base.IHTMLWindow2_iface;
850 IHTMLWindow2_AddRef(*p);
854 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
855 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
857 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
858 HTMLOuterWindow *window = This->outer_window;
859 INewWindowManager *new_window_mgr;
864 TRACE("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
865 debugstr_w(features), replace, pomWindowResult);
867 if(!window->doc_obj || !window->uri_nofrag)
870 if(name && *name == '_') {
871 FIXME("Unsupported name %s\n", debugstr_w(name));
875 hres = do_query_service((IUnknown*)window->doc_obj->client, &SID_SNewWindowManager, &IID_INewWindowManager,
876 (void**)&new_window_mgr);
878 FIXME("No INewWindowManager\n");
882 hres = IUri_GetDisplayUri(window->uri_nofrag, &uri_str);
883 if(SUCCEEDED(hres)) {
884 hres = INewWindowManager_EvaluateNewWindow(new_window_mgr, url, name, uri_str,
885 features, !!replace, window->doc_obj->has_popup ? 0 : NWMF_FIRST, 0);
886 window->doc_obj->has_popup = TRUE;
887 SysFreeString(uri_str);
889 INewWindowManager_Release(new_window_mgr);
891 *pomWindowResult = NULL;
895 hres = create_relative_uri(window, url, &uri);
899 hres = navigate_new_window(window, uri, name, pomWindowResult);
904 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
906 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
908 TRACE("(%p)->(%p)\n", This, p);
910 /* FIXME: We should return kind of proxy window here. */
911 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
912 *p = &This->IHTMLWindow2_iface;
916 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
918 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
919 HTMLOuterWindow *top;
921 TRACE("(%p)->(%p)\n", This, p);
923 get_top_window(This->outer_window, &top);
924 *p = &top->base.IHTMLWindow2_iface;
925 IHTMLWindow2_AddRef(*p);
930 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
932 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
934 TRACE("(%p)->(%p)\n", This, p);
936 /* FIXME: We should return kind of proxy window here. */
937 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
938 *p = &This->IHTMLWindow2_iface;
942 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
944 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
945 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
949 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
951 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
952 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
956 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
958 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
959 FIXME("(%p)->(%p)\n", This, p);
963 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
965 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
967 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
969 return set_window_event(This, EVENTID_BLUR, &v);
972 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
974 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
976 TRACE("(%p)->(%p)\n", This, p);
978 return get_window_event(This, EVENTID_BLUR, p);
981 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
983 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
985 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
987 return set_window_event(This, EVENTID_LOAD, &v);
990 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
992 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
994 TRACE("(%p)->(%p)\n", This, p);
996 return get_window_event(This, EVENTID_LOAD, p);
999 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
1001 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1003 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1005 return set_window_event(This, EVENTID_BEFOREUNLOAD, &v);
1008 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
1010 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1012 TRACE("(%p)->(%p)\n", This, p);
1014 return get_window_event(This, EVENTID_BEFOREUNLOAD, p);
1017 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
1019 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1020 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1024 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
1026 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1027 FIXME("(%p)->(%p)\n", This, p);
1031 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
1033 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1035 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1037 return set_window_event(This, EVENTID_HELP, &v);
1040 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
1042 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1044 TRACE("(%p)->(%p)\n", This, p);
1046 return get_window_event(This, EVENTID_HELP, p);
1049 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
1051 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1053 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1055 return set_window_event(This, EVENTID_ERROR, &v);
1058 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
1060 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1062 TRACE("(%p)->(%p)\n", This, p);
1064 return get_window_event(This, EVENTID_ERROR, p);
1067 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
1069 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1071 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1073 return set_window_event(This, EVENTID_RESIZE, &v);
1076 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
1078 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1080 TRACE("(%p)->(%p)\n", This, p);
1082 return get_window_event(This, EVENTID_RESIZE, p);
1085 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
1087 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1089 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1091 return set_window_event(This, EVENTID_SCROLL, &v);
1094 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
1096 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1098 TRACE("(%p)->(%p)\n", This, p);
1100 return get_window_event(This, EVENTID_SCROLL, p);
1103 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
1105 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1107 TRACE("(%p)->(%p)\n", This, p);
1109 if(This->inner_window->doc) {
1110 /* FIXME: We should return a wrapper object here */
1111 *p = &This->inner_window->doc->basedoc.IHTMLDocument2_iface;
1112 IHTMLDocument2_AddRef(*p);
1120 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
1122 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1123 HTMLInnerWindow *window = This->inner_window;
1125 TRACE("(%p)->(%p)\n", This, p);
1128 IHTMLEventObj_AddRef(window->event);
1133 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
1135 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1136 FIXME("(%p)->(%p)\n", This, p);
1140 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
1141 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
1143 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1144 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
1148 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
1151 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1152 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(helpURL), debugstr_variant(&helpArg), debugstr_w(features));
1156 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
1158 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1159 HTMLInnerWindow *window = This->inner_window;
1161 TRACE("(%p)->(%p)\n", This, p);
1163 if(!window->screen) {
1166 hres = HTMLScreen_Create(&window->screen);
1171 *p = window->screen;
1172 IHTMLScreen_AddRef(window->screen);
1176 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
1178 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1179 HTMLInnerWindow *window = This->inner_window;
1181 TRACE("(%p)->(%p)\n", This, p);
1183 if(!window->option_factory) {
1186 hres = HTMLOptionElementFactory_Create(window, &window->option_factory);
1191 *p = &window->option_factory->IHTMLOptionElementFactory_iface;
1192 IHTMLOptionElementFactory_AddRef(*p);
1197 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
1199 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1201 TRACE("(%p)->()\n", This);
1203 if(This->outer_window->doc_obj)
1204 SetFocus(This->outer_window->doc_obj->hwnd);
1208 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
1210 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1211 FIXME("(%p)->(%p)\n", This, p);
1215 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
1217 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1218 FIXME("(%p)->()\n", This);
1222 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, LONG x, LONG y)
1224 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1225 FIXME("(%p)->(%d %d)\n", This, x, y);
1229 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
1231 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1232 FIXME("(%p)->(%p)\n", This, p);
1236 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
1237 LONG msec, VARIANT *language, LONG *timerID)
1239 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1242 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
1244 V_VT(&expr) = VT_BSTR;
1245 V_BSTR(&expr) = expression;
1246 return IHTMLWindow3_setInterval(&This->IHTMLWindow3_iface, &expr, msec, language, timerID);
1249 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerID)
1251 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1253 TRACE("(%p)->(%d)\n", This, timerID);
1255 return clear_task_timer(This->inner_window, TRUE, timerID);
1258 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
1260 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1261 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1265 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
1267 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1268 FIXME("(%p)->(%p)\n", This, p);
1272 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
1275 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1277 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
1279 return exec_script(This->inner_window, scode, language, pvarRet);
1282 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
1284 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1286 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1288 TRACE("(%p)->(%p)\n", This, String);
1291 return E_INVALIDARG;
1293 *String = SysAllocString(objectW);
1294 return *String ? S_OK : E_OUTOFMEMORY;
1297 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, LONG x, LONG y)
1299 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1302 TRACE("(%p)->(%d %d)\n", This, x, y);
1304 nsres = nsIDOMWindow_ScrollBy(This->outer_window->nswindow, x, y);
1305 if(NS_FAILED(nsres))
1306 ERR("ScrollBy failed: %08x\n", nsres);
1311 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, LONG x, LONG y)
1313 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1316 TRACE("(%p)->(%d %d)\n", This, x, y);
1318 nsres = nsIDOMWindow_ScrollTo(This->outer_window->nswindow, x, y);
1319 if(NS_FAILED(nsres))
1320 ERR("ScrollTo failed: %08x\n", nsres);
1325 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, LONG x, LONG y)
1327 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1328 FIXME("(%p)->(%d %d)\n", This, x, y);
1332 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, LONG x, LONG y)
1334 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1335 FIXME("(%p)->(%d %d)\n", This, x, y);
1339 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, LONG x, LONG y)
1341 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1342 FIXME("(%p)->(%d %d)\n", This, x, y);
1346 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, LONG x, LONG y)
1348 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1349 FIXME("(%p)->(%d %d)\n", This, x, y);
1353 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
1355 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1357 TRACE("(%p)->(%p)\n", This, p);
1361 if(!This->outer_window->doc_obj->hostui)
1364 return IDocHostUIHandler_GetExternal(This->outer_window->doc_obj->hostui, p);
1367 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
1368 HTMLWindow2_QueryInterface,
1370 HTMLWindow2_Release,
1371 HTMLWindow2_GetTypeInfoCount,
1372 HTMLWindow2_GetTypeInfo,
1373 HTMLWindow2_GetIDsOfNames,
1376 HTMLWindow2_get_length,
1377 HTMLWindow2_get_frames,
1378 HTMLWindow2_put_defaultStatus,
1379 HTMLWindow2_get_defaultStatus,
1380 HTMLWindow2_put_status,
1381 HTMLWindow2_get_status,
1382 HTMLWindow2_setTimeout,
1383 HTMLWindow2_clearTimeout,
1385 HTMLWindow2_confirm,
1387 HTMLWindow2_get_Image,
1388 HTMLWindow2_get_location,
1389 HTMLWindow2_get_history,
1391 HTMLWindow2_put_opener,
1392 HTMLWindow2_get_opener,
1393 HTMLWindow2_get_navigator,
1394 HTMLWindow2_put_name,
1395 HTMLWindow2_get_name,
1396 HTMLWindow2_get_parent,
1398 HTMLWindow2_get_self,
1399 HTMLWindow2_get_top,
1400 HTMLWindow2_get_window,
1401 HTMLWindow2_navigate,
1402 HTMLWindow2_put_onfocus,
1403 HTMLWindow2_get_onfocus,
1404 HTMLWindow2_put_onblur,
1405 HTMLWindow2_get_onblur,
1406 HTMLWindow2_put_onload,
1407 HTMLWindow2_get_onload,
1408 HTMLWindow2_put_onbeforeunload,
1409 HTMLWindow2_get_onbeforeunload,
1410 HTMLWindow2_put_onunload,
1411 HTMLWindow2_get_onunload,
1412 HTMLWindow2_put_onhelp,
1413 HTMLWindow2_get_onhelp,
1414 HTMLWindow2_put_onerror,
1415 HTMLWindow2_get_onerror,
1416 HTMLWindow2_put_onresize,
1417 HTMLWindow2_get_onresize,
1418 HTMLWindow2_put_onscroll,
1419 HTMLWindow2_get_onscroll,
1420 HTMLWindow2_get_document,
1421 HTMLWindow2_get_event,
1422 HTMLWindow2_get__newEnum,
1423 HTMLWindow2_showModalDialog,
1424 HTMLWindow2_showHelp,
1425 HTMLWindow2_get_screen,
1426 HTMLWindow2_get_Option,
1428 HTMLWindow2_get_closed,
1431 HTMLWindow2_get_clientInformation,
1432 HTMLWindow2_setInterval,
1433 HTMLWindow2_clearInterval,
1434 HTMLWindow2_put_offscreenBuffering,
1435 HTMLWindow2_get_offscreenBuffering,
1436 HTMLWindow2_execScript,
1437 HTMLWindow2_toString,
1438 HTMLWindow2_scrollBy,
1439 HTMLWindow2_scrollTo,
1442 HTMLWindow2_resizeTo,
1443 HTMLWindow2_resizeBy,
1444 HTMLWindow2_get_external
1447 static inline HTMLWindow *impl_from_IHTMLWindow3(IHTMLWindow3 *iface)
1449 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow3_iface);
1452 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
1454 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1456 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1459 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
1461 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1463 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1466 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
1468 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1470 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1473 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
1475 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1477 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1480 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
1481 LCID lcid, ITypeInfo **ppTInfo)
1483 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1485 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1488 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
1489 LPOLESTR *rgszNames, UINT cNames,
1490 LCID lcid, DISPID *rgDispId)
1492 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1494 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1498 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
1499 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1500 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1502 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1504 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1505 pDispParams, pVarResult, pExcepInfo, puArgErr);
1508 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, LONG *p)
1510 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1511 FIXME("(%p)->(%p)\n", This, p);
1515 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, LONG *p)
1517 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1518 FIXME("(%p)->(%p)\n", This, p);
1522 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
1524 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1525 HTMLInnerWindow *window = This->inner_window;
1527 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
1530 FIXME("No document\n");
1534 return attach_event(&window->doc->body_event_target, NULL, &window->doc->basedoc, event, pDisp, pfResult);
1537 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
1539 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1540 HTMLInnerWindow *window = This->inner_window;
1542 TRACE("(%p)->()\n", This);
1545 FIXME("No document\n");
1549 return detach_event(window->doc->body_event_target, &window->doc->basedoc, event, pDisp);
1552 static HRESULT window_set_timer(HTMLInnerWindow *This, VARIANT *expr, LONG msec, VARIANT *language,
1553 BOOL interval, LONG *timer_id)
1555 IDispatch *disp = NULL;
1558 switch(V_VT(expr)) {
1560 disp = V_DISPATCH(expr);
1561 IDispatch_AddRef(disp);
1565 disp = script_parse_event(This->base.inner_window, V_BSTR(expr));
1569 FIXME("unimplemented expr %s\n", debugstr_variant(expr));
1576 hres = set_task_timer(This, msec, interval, disp, timer_id);
1577 IDispatch_Release(disp);
1582 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1583 VARIANT *language, LONG *timerID)
1585 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1587 TRACE("(%p)->(%s %d %s %p)\n", This, debugstr_variant(expression), msec, debugstr_variant(language), timerID);
1589 return window_set_timer(This->inner_window, expression, msec, language, FALSE, timerID);
1592 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1593 VARIANT *language, LONG *timerID)
1595 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1597 TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID);
1599 return window_set_timer(This->inner_window, expression, msec, language, TRUE, timerID);
1602 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
1604 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1605 FIXME("(%p)\n", This);
1609 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
1611 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1612 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1616 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
1618 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1619 FIXME("(%p)->(%p)\n", This, p);
1623 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
1625 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1626 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1630 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
1632 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1633 FIXME("(%p)->(%p)\n", This, p);
1637 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
1639 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1640 FIXME("(%p)->(%p)\n", This, p);
1644 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
1645 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
1647 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1648 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
1652 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
1653 HTMLWindow3_QueryInterface,
1655 HTMLWindow3_Release,
1656 HTMLWindow3_GetTypeInfoCount,
1657 HTMLWindow3_GetTypeInfo,
1658 HTMLWindow3_GetIDsOfNames,
1660 HTMLWindow3_get_screenLeft,
1661 HTMLWindow3_get_screenTop,
1662 HTMLWindow3_attachEvent,
1663 HTMLWindow3_detachEvent,
1664 HTMLWindow3_setTimeout,
1665 HTMLWindow3_setInterval,
1667 HTMLWindow3_put_onbeforeprint,
1668 HTMLWindow3_get_onbeforeprint,
1669 HTMLWindow3_put_onafterprint,
1670 HTMLWindow3_get_onafterprint,
1671 HTMLWindow3_get_clipboardData,
1672 HTMLWindow3_showModelessDialog
1675 static inline HTMLWindow *impl_from_IHTMLWindow4(IHTMLWindow4 *iface)
1677 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow4_iface);
1680 static HRESULT WINAPI HTMLWindow4_QueryInterface(IHTMLWindow4 *iface, REFIID riid, void **ppv)
1682 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1684 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1687 static ULONG WINAPI HTMLWindow4_AddRef(IHTMLWindow4 *iface)
1689 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1691 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1694 static ULONG WINAPI HTMLWindow4_Release(IHTMLWindow4 *iface)
1696 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1698 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1701 static HRESULT WINAPI HTMLWindow4_GetTypeInfoCount(IHTMLWindow4 *iface, UINT *pctinfo)
1703 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1705 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1708 static HRESULT WINAPI HTMLWindow4_GetTypeInfo(IHTMLWindow4 *iface, UINT iTInfo,
1709 LCID lcid, ITypeInfo **ppTInfo)
1711 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1713 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1716 static HRESULT WINAPI HTMLWindow4_GetIDsOfNames(IHTMLWindow4 *iface, REFIID riid,
1717 LPOLESTR *rgszNames, UINT cNames,
1718 LCID lcid, DISPID *rgDispId)
1720 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1722 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1726 static HRESULT WINAPI HTMLWindow4_Invoke(IHTMLWindow4 *iface, DISPID dispIdMember,
1727 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1728 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1730 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1732 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1733 pDispParams, pVarResult, pExcepInfo, puArgErr);
1736 static HRESULT WINAPI HTMLWindow4_createPopup(IHTMLWindow4 *iface, VARIANT *varArgIn,
1737 IDispatch **ppPopup)
1739 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1740 FIXME("(%p)->(%p %p)\n", This, varArgIn, ppPopup);
1744 static HRESULT WINAPI HTMLWindow4_get_frameElement(IHTMLWindow4 *iface, IHTMLFrameBase **p)
1746 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1747 TRACE("(%p)->(%p)\n", This, p);
1749 if(This->outer_window->frame_element) {
1750 *p = &This->outer_window->frame_element->IHTMLFrameBase_iface;
1751 IHTMLFrameBase_AddRef(*p);
1758 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl = {
1759 HTMLWindow4_QueryInterface,
1761 HTMLWindow4_Release,
1762 HTMLWindow4_GetTypeInfoCount,
1763 HTMLWindow4_GetTypeInfo,
1764 HTMLWindow4_GetIDsOfNames,
1766 HTMLWindow4_createPopup,
1767 HTMLWindow4_get_frameElement
1770 static inline HTMLWindow *impl_from_IHTMLWindow5(IHTMLWindow5 *iface)
1772 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow5_iface);
1775 static HRESULT WINAPI HTMLWindow5_QueryInterface(IHTMLWindow5 *iface, REFIID riid, void **ppv)
1777 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1779 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1782 static ULONG WINAPI HTMLWindow5_AddRef(IHTMLWindow5 *iface)
1784 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1786 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1789 static ULONG WINAPI HTMLWindow5_Release(IHTMLWindow5 *iface)
1791 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1793 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1796 static HRESULT WINAPI HTMLWindow5_GetTypeInfoCount(IHTMLWindow5 *iface, UINT *pctinfo)
1798 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1800 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1803 static HRESULT WINAPI HTMLWindow5_GetTypeInfo(IHTMLWindow5 *iface, UINT iTInfo,
1804 LCID lcid, ITypeInfo **ppTInfo)
1806 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1808 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1811 static HRESULT WINAPI HTMLWindow5_GetIDsOfNames(IHTMLWindow5 *iface, REFIID riid,
1812 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1814 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1816 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1820 static HRESULT WINAPI HTMLWindow5_Invoke(IHTMLWindow5 *iface, DISPID dispIdMember,
1821 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1822 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1824 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1826 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1827 pDispParams, pVarResult, pExcepInfo, puArgErr);
1830 static HRESULT WINAPI HTMLWindow5_put_XMLHttpRequest(IHTMLWindow5 *iface, VARIANT v)
1832 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1833 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1837 static HRESULT WINAPI HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5 *iface, VARIANT *p)
1839 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1840 FIXME("(%p)->(%p)\n", This, p);
1844 static const IHTMLWindow5Vtbl HTMLWindow5Vtbl = {
1845 HTMLWindow5_QueryInterface,
1847 HTMLWindow5_Release,
1848 HTMLWindow5_GetTypeInfoCount,
1849 HTMLWindow5_GetTypeInfo,
1850 HTMLWindow5_GetIDsOfNames,
1852 HTMLWindow5_put_XMLHttpRequest,
1853 HTMLWindow5_get_XMLHttpRequest
1856 static inline HTMLWindow *impl_from_IHTMLWindow6(IHTMLWindow6 *iface)
1858 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow6_iface);
1861 static HRESULT WINAPI HTMLWindow6_QueryInterface(IHTMLWindow6 *iface, REFIID riid, void **ppv)
1863 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1865 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1868 static ULONG WINAPI HTMLWindow6_AddRef(IHTMLWindow6 *iface)
1870 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1872 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1875 static ULONG WINAPI HTMLWindow6_Release(IHTMLWindow6 *iface)
1877 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1879 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1882 static HRESULT WINAPI HTMLWindow6_GetTypeInfoCount(IHTMLWindow6 *iface, UINT *pctinfo)
1884 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1886 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1889 static HRESULT WINAPI HTMLWindow6_GetTypeInfo(IHTMLWindow6 *iface, UINT iTInfo,
1890 LCID lcid, ITypeInfo **ppTInfo)
1892 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1894 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1897 static HRESULT WINAPI HTMLWindow6_GetIDsOfNames(IHTMLWindow6 *iface, REFIID riid,
1898 LPOLESTR *rgszNames, UINT cNames,
1899 LCID lcid, DISPID *rgDispId)
1901 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1903 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1907 static HRESULT WINAPI HTMLWindow6_Invoke(IHTMLWindow6 *iface, DISPID dispIdMember,
1908 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1909 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1911 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1913 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1914 pDispParams, pVarResult, pExcepInfo, puArgErr);
1917 static HRESULT WINAPI HTMLWindow6_put_XDomainRequest(IHTMLWindow6 *iface, VARIANT v)
1919 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1920 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1924 static HRESULT WINAPI HTMLWindow6_get_XDomainRequest(IHTMLWindow6 *iface, VARIANT *p)
1926 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1927 FIXME("(%p)->(%p)\n", This, p);
1931 static HRESULT WINAPI HTMLWindow6_get_sessionStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1933 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1935 FIXME("(%p)->(%p)\n", This, p);
1937 if(!This->inner_window->session_storage) {
1940 hres = create_storage(&This->inner_window->session_storage);
1945 IHTMLStorage_AddRef(This->inner_window->session_storage);
1946 *p = This->inner_window->session_storage;
1950 static HRESULT WINAPI HTMLWindow6_get_localStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1952 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1953 FIXME("(%p)->(%p)\n", This, p);
1957 static HRESULT WINAPI HTMLWindow6_put_onhashchange(IHTMLWindow6 *iface, VARIANT v)
1959 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1960 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1964 static HRESULT WINAPI HTMLWindow6_get_onhashchange(IHTMLWindow6 *iface, VARIANT *p)
1966 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1967 FIXME("(%p)->(%p)\n", This, p);
1971 static HRESULT WINAPI HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6 *iface, LONG *p)
1973 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1974 FIXME("(%p)->(%p)\n", This, p);
1978 static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VARIANT targetOrigin)
1980 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1981 FIXME("(%p)->(%s %s)\n", This, debugstr_w(msg), debugstr_variant(&targetOrigin));
1985 static HRESULT WINAPI HTMLWindow6_toStaticHTML(IHTMLWindow6 *iface, BSTR bstrHTML, BSTR *pbstrStaticHTML)
1987 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1988 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrHTML), pbstrStaticHTML);
1992 static HRESULT WINAPI HTMLWindow6_put_onmessage(IHTMLWindow6 *iface, VARIANT v)
1994 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1995 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1999 static HRESULT WINAPI HTMLWindow6_get_onmessage(IHTMLWindow6 *iface, VARIANT *p)
2001 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
2002 FIXME("(%p)->(%p)\n", This, p);
2006 static HRESULT WINAPI HTMLWindow6_msWriteProfilerMark(IHTMLWindow6 *iface, BSTR bstrProfilerMark)
2008 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
2009 FIXME("(%p)->(%s)\n", This, debugstr_w(bstrProfilerMark));
2013 static const IHTMLWindow6Vtbl HTMLWindow6Vtbl = {
2014 HTMLWindow6_QueryInterface,
2016 HTMLWindow6_Release,
2017 HTMLWindow6_GetTypeInfoCount,
2018 HTMLWindow6_GetTypeInfo,
2019 HTMLWindow6_GetIDsOfNames,
2021 HTMLWindow6_put_XDomainRequest,
2022 HTMLWindow6_get_XDomainRequest,
2023 HTMLWindow6_get_sessionStorage,
2024 HTMLWindow6_get_localStorage,
2025 HTMLWindow6_put_onhashchange,
2026 HTMLWindow6_get_onhashchange,
2027 HTMLWindow6_get_maxConnectionsPerServer,
2028 HTMLWindow6_postMessage,
2029 HTMLWindow6_toStaticHTML,
2030 HTMLWindow6_put_onmessage,
2031 HTMLWindow6_get_onmessage,
2032 HTMLWindow6_msWriteProfilerMark
2035 static inline HTMLWindow *impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow *iface)
2037 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLPrivateWindow_iface);
2040 static HRESULT WINAPI HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow *iface, REFIID riid, void **ppv)
2042 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2044 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2047 static ULONG WINAPI HTMLPrivateWindow_AddRef(IHTMLPrivateWindow *iface)
2049 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2051 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2054 static ULONG WINAPI HTMLPrivateWindow_Release(IHTMLPrivateWindow *iface)
2056 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2058 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2061 static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface, BSTR url, BSTR arg2, BSTR arg3,
2062 BSTR arg4, VARIANT *post_data_var, VARIANT *headers_var, ULONG flags)
2064 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2065 HTMLOuterWindow *window = This->outer_window;
2066 OLECHAR *translated_url = NULL;
2067 DWORD post_data_size = 0;
2068 BYTE *post_data = NULL;
2069 WCHAR *headers = NULL;
2073 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This, debugstr_w(url), debugstr_w(arg2), debugstr_w(arg3), debugstr_w(arg4),
2074 debugstr_variant(post_data_var), debugstr_variant(headers_var), flags);
2076 if(window->doc_obj->hostui) {
2077 hres = IDocHostUIHandler_TranslateUrl(window->doc_obj->hostui, 0, url, &translated_url);
2079 translated_url = NULL;
2082 hres = CreateUri(translated_url ? translated_url : url, 0, 0, &uri);
2083 CoTaskMemFree(translated_url);
2088 if(V_VT(post_data_var) == (VT_ARRAY|VT_UI1)) {
2089 SafeArrayAccessData(V_ARRAY(post_data_var), (void**)&post_data);
2090 post_data_size = V_ARRAY(post_data_var)->rgsabound[0].cElements;
2094 if(headers_var && V_VT(headers_var) != VT_EMPTY && V_VT(headers_var) != VT_ERROR) {
2095 if(V_VT(headers_var) != VT_BSTR)
2096 return E_INVALIDARG;
2098 headers = V_BSTR(headers_var);
2101 hres = super_navigate(window, uri, BINDING_NAVIGATED, headers, post_data, post_data_size);
2104 SafeArrayUnaccessData(V_ARRAY(post_data_var));
2109 static HRESULT WINAPI HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow *iface, BSTR *url)
2111 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2112 FIXME("(%p)->(%p)\n", This, url);
2116 static HRESULT WINAPI HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow *iface, IOleCommandTarget *cmdtrg)
2118 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2119 FIXME("(%p)->(%p)\n", This, cmdtrg);
2123 static HRESULT WINAPI HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow *iface, int arg)
2125 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2126 FIXME("(%p)->(%x)\n", This, arg);
2130 static HRESULT WINAPI HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow *iface, LPCWSTR name, IHTMLWindow2 **ret)
2132 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2133 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), ret);
2137 static HRESULT WINAPI HTMLPrivateWindow_GetAddressBarUrl(IHTMLPrivateWindow *iface, BSTR *url)
2139 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2140 TRACE("(%p)->(%p)\n", This, url);
2143 return E_INVALIDARG;
2145 *url = SysAllocString(This->outer_window->url);
2149 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl = {
2150 HTMLPrivateWindow_QueryInterface,
2151 HTMLPrivateWindow_AddRef,
2152 HTMLPrivateWindow_Release,
2153 HTMLPrivateWindow_SuperNavigate,
2154 HTMLPrivateWindow_GetPendingUrl,
2155 HTMLPrivateWindow_SetPICSTarget,
2156 HTMLPrivateWindow_PICSComplete,
2157 HTMLPrivateWindow_FindWindowByName,
2158 HTMLPrivateWindow_GetAddressBarUrl
2161 static inline HTMLWindow *impl_from_ITravelLogClient(ITravelLogClient *iface)
2163 return CONTAINING_RECORD(iface, HTMLWindow, ITravelLogClient_iface);
2166 static HRESULT WINAPI TravelLogClient_QueryInterface(ITravelLogClient *iface, REFIID riid, void **ppv)
2168 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2170 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2173 static ULONG WINAPI TravelLogClient_AddRef(ITravelLogClient *iface)
2175 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2177 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2180 static ULONG WINAPI TravelLogClient_Release(ITravelLogClient *iface)
2182 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2184 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2187 static HRESULT WINAPI TravelLogClient_FindWindowByIndex(ITravelLogClient *iface, DWORD dwID, IUnknown **ppunk)
2189 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2191 FIXME("(%p)->(%d %p) semi-stub\n", This, dwID, ppunk);
2197 static HRESULT WINAPI TravelLogClient_GetWindowData(ITravelLogClient *iface, IStream *pStream, LPWINDOWDATA pWinData)
2199 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2200 FIXME("(%p)->(%p %p)\n", This, pStream, pWinData);
2204 static HRESULT WINAPI TravelLogClient_LoadHistoryPosition(ITravelLogClient *iface, LPWSTR pszUrlLocation, DWORD dwPosition)
2206 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2207 FIXME("(%p)->(%s %d)\n", This, debugstr_w(pszUrlLocation), dwPosition);
2211 static const ITravelLogClientVtbl TravelLogClientVtbl = {
2212 TravelLogClient_QueryInterface,
2213 TravelLogClient_AddRef,
2214 TravelLogClient_Release,
2215 TravelLogClient_FindWindowByIndex,
2216 TravelLogClient_GetWindowData,
2217 TravelLogClient_LoadHistoryPosition
2220 static inline HTMLWindow *impl_from_IDispatchEx(IDispatchEx *iface)
2222 return CONTAINING_RECORD(iface, HTMLWindow, IDispatchEx_iface);
2225 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
2227 HTMLWindow *This = impl_from_IDispatchEx(iface);
2229 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2232 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
2234 HTMLWindow *This = impl_from_IDispatchEx(iface);
2236 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2239 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
2241 HTMLWindow *This = impl_from_IDispatchEx(iface);
2243 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2246 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
2248 HTMLWindow *This = impl_from_IDispatchEx(iface);
2250 TRACE("(%p)->(%p)\n", This, pctinfo);
2252 return IDispatchEx_GetTypeInfoCount(&This->inner_window->dispex.IDispatchEx_iface, pctinfo);
2255 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
2256 LCID lcid, ITypeInfo **ppTInfo)
2258 HTMLWindow *This = impl_from_IDispatchEx(iface);
2260 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
2262 return IDispatchEx_GetTypeInfo(&This->inner_window->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2265 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
2266 LPOLESTR *rgszNames, UINT cNames,
2267 LCID lcid, DISPID *rgDispId)
2269 HTMLWindow *This = impl_from_IDispatchEx(iface);
2273 WARN("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
2276 for(i=0; i < cNames; i++) {
2277 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
2278 hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
2286 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
2287 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2288 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2290 HTMLWindow *This = impl_from_IDispatchEx(iface);
2292 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
2293 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2295 /* FIXME: Use script dispatch */
2297 return IDispatchEx_Invoke(&This->inner_window->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2298 pDispParams, pVarResult, pExcepInfo, puArgErr);
2301 static global_prop_t *alloc_global_prop(HTMLInnerWindow *This, global_prop_type_t type, BSTR name)
2303 if(This->global_prop_cnt == This->global_prop_size) {
2304 global_prop_t *new_props;
2307 if(This->global_props) {
2308 new_size = This->global_prop_size*2;
2309 new_props = heap_realloc(This->global_props, new_size*sizeof(global_prop_t));
2312 new_props = heap_alloc(new_size*sizeof(global_prop_t));
2316 This->global_props = new_props;
2317 This->global_prop_size = new_size;
2320 This->global_props[This->global_prop_cnt].name = heap_strdupW(name);
2321 if(!This->global_props[This->global_prop_cnt].name)
2324 This->global_props[This->global_prop_cnt].type = type;
2325 return This->global_props + This->global_prop_cnt++;
2328 static inline DWORD prop_to_dispid(HTMLInnerWindow *This, global_prop_t *prop)
2330 return MSHTML_DISPID_CUSTOM_MIN + (prop-This->global_props);
2333 HRESULT search_window_props(HTMLInnerWindow *This, BSTR bstrName, DWORD grfdex, DISPID *pid)
2336 ScriptHost *script_host;
2339 for(i=0; i < This->global_prop_cnt; i++) {
2340 /* FIXME: case sensitivity */
2341 if(!strcmpW(This->global_props[i].name, bstrName)) {
2342 *pid = MSHTML_DISPID_CUSTOM_MIN+i;
2347 if(find_global_prop(This->base.inner_window, bstrName, grfdex, &script_host, &id)) {
2348 global_prop_t *prop;
2350 prop = alloc_global_prop(This, GLOBAL_SCRIPTVAR, bstrName);
2352 return E_OUTOFMEMORY;
2354 prop->script_host = script_host;
2357 *pid = prop_to_dispid(This, prop);
2361 return DISP_E_UNKNOWNNAME;
2364 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
2366 HTMLWindow *This = impl_from_IDispatchEx(iface);
2367 HTMLInnerWindow *window = This->inner_window;
2370 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
2372 hres = search_window_props(window, bstrName, grfdex, pid);
2373 if(hres != DISP_E_UNKNOWNNAME)
2376 hres = IDispatchEx_GetDispID(&window->base.inner_window->dispex.IDispatchEx_iface, bstrName, grfdex, pid);
2377 if(hres != DISP_E_UNKNOWNNAME)
2380 if(This->outer_window) {
2381 HTMLOuterWindow *frame;
2383 hres = get_frame_by_name(This->outer_window, bstrName, FALSE, &frame);
2384 if(SUCCEEDED(hres) && frame) {
2385 global_prop_t *prop;
2387 IHTMLWindow2_Release(&frame->base.IHTMLWindow2_iface);
2389 prop = alloc_global_prop(window, GLOBAL_FRAMEVAR, bstrName);
2391 return E_OUTOFMEMORY;
2393 *pid = prop_to_dispid(window, prop);
2399 global_prop_t *prop;
2402 hres = IHTMLDocument3_getElementById(&window->base.inner_window->doc->basedoc.IHTMLDocument3_iface,
2404 if(SUCCEEDED(hres) && elem) {
2405 IHTMLElement_Release(elem);
2407 prop = alloc_global_prop(window, GLOBAL_ELEMENTVAR, bstrName);
2409 return E_OUTOFMEMORY;
2411 *pid = prop_to_dispid(window, prop);
2416 return DISP_E_UNKNOWNNAME;
2419 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
2420 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
2422 HTMLWindow *This = impl_from_IDispatchEx(iface);
2423 HTMLInnerWindow *window = This->inner_window;
2425 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
2427 if(id == DISPID_IHTMLWINDOW2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT)) {
2428 HTMLLocation *location;
2431 TRACE("forwarding to location.href\n");
2433 hres = get_location(window, &location);
2437 hres = IDispatchEx_InvokeEx(&location->dispex.IDispatchEx_iface, DISPID_VALUE, lcid,
2438 wFlags, pdp, pvarRes, pei, pspCaller);
2439 IHTMLLocation_Release(&location->IHTMLLocation_iface);
2443 return IDispatchEx_InvokeEx(&window->dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
2446 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
2448 HTMLWindow *This = impl_from_IDispatchEx(iface);
2450 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
2452 return IDispatchEx_DeleteMemberByName(&This->inner_window->dispex.IDispatchEx_iface, bstrName, grfdex);
2455 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
2457 HTMLWindow *This = impl_from_IDispatchEx(iface);
2459 TRACE("(%p)->(%x)\n", This, id);
2461 return IDispatchEx_DeleteMemberByDispID(&This->inner_window->dispex.IDispatchEx_iface, id);
2464 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
2466 HTMLWindow *This = impl_from_IDispatchEx(iface);
2468 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
2470 return IDispatchEx_GetMemberProperties(&This->inner_window->dispex.IDispatchEx_iface, id, grfdexFetch,
2474 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
2476 HTMLWindow *This = impl_from_IDispatchEx(iface);
2478 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
2480 return IDispatchEx_GetMemberName(&This->inner_window->dispex.IDispatchEx_iface, id, pbstrName);
2483 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
2485 HTMLWindow *This = impl_from_IDispatchEx(iface);
2487 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
2489 return IDispatchEx_GetNextDispID(&This->inner_window->dispex.IDispatchEx_iface, grfdex, id, pid);
2492 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
2494 HTMLWindow *This = impl_from_IDispatchEx(iface);
2496 TRACE("(%p)->(%p)\n", This, ppunk);
2502 static const IDispatchExVtbl WindowDispExVtbl = {
2503 WindowDispEx_QueryInterface,
2504 WindowDispEx_AddRef,
2505 WindowDispEx_Release,
2506 WindowDispEx_GetTypeInfoCount,
2507 WindowDispEx_GetTypeInfo,
2508 WindowDispEx_GetIDsOfNames,
2509 WindowDispEx_Invoke,
2510 WindowDispEx_GetDispID,
2511 WindowDispEx_InvokeEx,
2512 WindowDispEx_DeleteMemberByName,
2513 WindowDispEx_DeleteMemberByDispID,
2514 WindowDispEx_GetMemberProperties,
2515 WindowDispEx_GetMemberName,
2516 WindowDispEx_GetNextDispID,
2517 WindowDispEx_GetNameSpaceParent
2520 static inline HTMLWindow *impl_from_IServiceProvider(IServiceProvider *iface)
2522 return CONTAINING_RECORD(iface, HTMLWindow, IServiceProvider_iface);
2525 static HRESULT WINAPI HTMLWindowSP_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
2527 HTMLWindow *This = impl_from_IServiceProvider(iface);
2528 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2531 static ULONG WINAPI HTMLWindowSP_AddRef(IServiceProvider *iface)
2533 HTMLWindow *This = impl_from_IServiceProvider(iface);
2534 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2537 static ULONG WINAPI HTMLWindowSP_Release(IServiceProvider *iface)
2539 HTMLWindow *This = impl_from_IServiceProvider(iface);
2540 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2543 static HRESULT WINAPI HTMLWindowSP_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv)
2545 HTMLWindow *This = impl_from_IServiceProvider(iface);
2547 if(IsEqualGUID(guidService, &IID_IHTMLWindow2)) {
2548 TRACE("IID_IHTMLWindow2\n");
2549 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2552 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
2554 if(!This->outer_window->doc_obj)
2555 return E_NOINTERFACE;
2557 return IServiceProvider_QueryService(&This->outer_window->doc_obj->basedoc.IServiceProvider_iface,
2558 guidService, riid, ppv);
2561 static const IServiceProviderVtbl ServiceProviderVtbl = {
2562 HTMLWindowSP_QueryInterface,
2563 HTMLWindowSP_AddRef,
2564 HTMLWindowSP_Release,
2565 HTMLWindowSP_QueryService
2568 static inline HTMLInnerWindow *impl_from_DispatchEx(DispatchEx *iface)
2570 return CONTAINING_RECORD(iface, HTMLInnerWindow, dispex);
2573 static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2574 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2576 HTMLInnerWindow *This = impl_from_DispatchEx(dispex);
2577 global_prop_t *prop;
2581 idx = id - MSHTML_DISPID_CUSTOM_MIN;
2582 if(idx >= This->global_prop_cnt)
2583 return DISP_E_MEMBERNOTFOUND;
2585 prop = This->global_props+idx;
2587 switch(prop->type) {
2588 case GLOBAL_SCRIPTVAR: {
2592 disp = get_script_disp(prop->script_host);
2594 return E_UNEXPECTED;
2596 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&iface);
2597 if(SUCCEEDED(hres)) {
2598 TRACE("%s >>>\n", debugstr_w(prop->name));
2599 hres = IDispatchEx_InvokeEx(iface, prop->id, lcid, flags, params, res, ei, caller);
2601 TRACE("%s <<<\n", debugstr_w(prop->name));
2603 WARN("%s <<< %08x\n", debugstr_w(prop->name), hres);
2604 IDispatchEx_Release(iface);
2606 FIXME("No IDispatchEx\n");
2608 IDispatch_Release(disp);
2611 case GLOBAL_ELEMENTVAR:
2613 case DISPATCH_PROPERTYGET|DISPATCH_METHOD:
2614 case DISPATCH_PROPERTYGET: {
2617 hres = IHTMLDocument3_getElementById(&This->base.inner_window->doc->basedoc.IHTMLDocument3_iface,
2623 return DISP_E_MEMBERNOTFOUND;
2625 V_VT(res) = VT_DISPATCH;
2626 V_DISPATCH(res) = (IDispatch*)elem;
2629 case DISPATCH_PROPERTYPUT: {
2632 hres = dispex_get_dynid(&This->dispex, prop->name, &dispex_id);
2636 prop->type = GLOBAL_DISPEXVAR;
2637 prop->id = dispex_id;
2638 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, dispex_id, 0, flags, params, res, ei, caller);
2641 FIXME("Not supported flags: %x\n", flags);
2644 case GLOBAL_FRAMEVAR:
2645 if(!This->base.outer_window)
2646 return E_UNEXPECTED;
2649 case DISPATCH_PROPERTYGET: {
2650 HTMLOuterWindow *frame;
2652 hres = get_frame_by_name(This->base.outer_window, prop->name, FALSE, &frame);
2657 return DISP_E_MEMBERNOTFOUND;
2659 V_VT(res) = VT_DISPATCH;
2660 V_DISPATCH(res) = (IDispatch*)&frame->base.inner_window->base.IHTMLWindow2_iface;
2661 IDispatch_AddRef(V_DISPATCH(res));
2665 FIXME("Not supported flags: %x\n", flags);
2668 case GLOBAL_DISPEXVAR:
2669 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, prop->id, 0, flags, params, res, ei, caller);
2671 ERR("invalid type %d\n", prop->type);
2672 hres = DISP_E_MEMBERNOTFOUND;
2679 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl = {
2686 static const tid_t HTMLWindow_iface_tids[] = {
2694 static dispex_static_data_t HTMLWindow_dispex = {
2695 &HTMLWindow_dispex_vtbl,
2696 DispHTMLWindow2_tid,
2698 HTMLWindow_iface_tids
2701 static void *alloc_window(size_t size)
2705 window = heap_alloc_zero(size);
2709 window->IHTMLWindow2_iface.lpVtbl = &HTMLWindow2Vtbl;
2710 window->IHTMLWindow3_iface.lpVtbl = &HTMLWindow3Vtbl;
2711 window->IHTMLWindow4_iface.lpVtbl = &HTMLWindow4Vtbl;
2712 window->IHTMLWindow5_iface.lpVtbl = &HTMLWindow5Vtbl;
2713 window->IHTMLWindow6_iface.lpVtbl = &HTMLWindow6Vtbl;
2714 window->IHTMLPrivateWindow_iface.lpVtbl = &HTMLPrivateWindowVtbl;
2715 window->IDispatchEx_iface.lpVtbl = &WindowDispExVtbl;
2716 window->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
2717 window->ITravelLogClient_iface.lpVtbl = &TravelLogClientVtbl;
2723 static HRESULT create_inner_window(HTMLOuterWindow *outer_window, IMoniker *mon, HTMLInnerWindow **ret)
2725 HTMLInnerWindow *window;
2727 window = alloc_window(sizeof(HTMLInnerWindow));
2729 return E_OUTOFMEMORY;
2731 list_init(&window->script_hosts);
2732 list_init(&window->bindings);
2733 list_init(&window->script_queue);
2735 window->base.outer_window = outer_window;
2736 window->base.inner_window = window;
2738 init_dispex(&window->dispex, (IUnknown*)&window->base.IHTMLWindow2_iface, &HTMLWindow_dispex);
2740 window->task_magic = get_task_target_magic();
2743 IMoniker_AddRef(mon);
2751 HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow,
2752 HTMLOuterWindow *parent, HTMLOuterWindow **ret)
2754 HTMLOuterWindow *window;
2757 window = alloc_window(sizeof(HTMLOuterWindow));
2759 return E_OUTOFMEMORY;
2761 window->base.outer_window = window;
2762 window->base.inner_window = NULL;
2764 window->window_ref = heap_alloc(sizeof(windowref_t));
2765 if(!window->window_ref) {
2767 return E_OUTOFMEMORY;
2770 window->doc_obj = doc_obj;
2772 window->window_ref->window = window;
2773 window->window_ref->ref = 1;
2776 nsIDOMWindow_AddRef(nswindow);
2777 window->nswindow = nswindow;
2780 window->scriptmode = parent ? parent->scriptmode : SCRIPTMODE_GECKO;
2781 window->readystate = READYSTATE_UNINITIALIZED;
2783 hres = create_pending_window(window, NULL);
2785 hres = update_window_doc(window->pending_window);
2787 IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
2791 hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0);
2793 IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
2797 window->task_magic = get_task_target_magic();
2799 list_init(&window->children);
2800 list_add_head(&window_list, &window->entry);
2803 IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
2805 window->parent = parent;
2806 list_add_tail(&parent->children, &window->sibling_entry);
2809 TRACE("%p inner_window %p\n", window, window->base.inner_window);
2815 HRESULT create_pending_window(HTMLOuterWindow *outer_window, nsChannelBSC *channelbsc)
2817 HTMLInnerWindow *pending_window;
2820 hres = create_inner_window(outer_window, outer_window->mon /* FIXME */, &pending_window);
2825 IBindStatusCallback_AddRef(&channelbsc->bsc.IBindStatusCallback_iface);
2826 pending_window->bscallback = channelbsc;
2829 if(outer_window->pending_window) {
2830 abort_window_bindings(outer_window->pending_window);
2831 outer_window->pending_window->base.outer_window = NULL;
2832 IHTMLWindow2_Release(&outer_window->pending_window->base.IHTMLWindow2_iface);
2835 outer_window->pending_window = pending_window;
2839 HRESULT update_window_doc(HTMLInnerWindow *window)
2841 HTMLOuterWindow *outer_window = window->base.outer_window;
2842 nsIDOMHTMLDocument *nshtmldoc;
2843 nsIDOMDocument *nsdoc;
2847 assert(!window->doc);
2850 ERR("NULL outer window\n");
2851 return E_UNEXPECTED;
2854 nsres = nsIDOMWindow_GetDocument(outer_window->nswindow, &nsdoc);
2855 if(NS_FAILED(nsres) || !nsdoc) {
2856 ERR("GetDocument failed: %08x\n", nsres);
2860 nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
2861 nsIDOMDocument_Release(nsdoc);
2862 if(NS_FAILED(nsres)) {
2863 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres);
2867 hres = create_doc_from_nsdoc(nshtmldoc, outer_window->doc_obj, window, &window->doc);
2868 nsIDOMHTMLDocument_Release(nshtmldoc);
2872 if(outer_window->doc_obj->usermode == EDITMODE) {
2876 static const PRUnichar onW[] = {'o','n',0};
2878 nsAString_Init(&mode_str, onW);
2879 nsres = nsIDOMHTMLDocument_SetDesignMode(window->doc->nsdoc, &mode_str);
2880 nsAString_Finish(&mode_str);
2881 if(NS_FAILED(nsres))
2882 ERR("SetDesignMode failed: %08x\n", nsres);
2885 if(window != outer_window->pending_window) {
2886 ERR("not current pending window\n");
2890 if(outer_window->base.inner_window)
2891 detach_inner_window(outer_window->base.inner_window);
2892 outer_window->base.inner_window = window;
2893 outer_window->pending_window = NULL;
2895 if(outer_window->doc_obj->basedoc.window == outer_window || !outer_window->doc_obj->basedoc.window) {
2896 if(outer_window->doc_obj->basedoc.doc_node)
2897 htmldoc_release(&outer_window->doc_obj->basedoc.doc_node->basedoc);
2898 outer_window->doc_obj->basedoc.doc_node = window->doc;
2899 htmldoc_addref(&window->doc->basedoc);
2905 HTMLOuterWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
2907 HTMLOuterWindow *iter;
2909 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLOuterWindow, entry) {
2910 if(iter->nswindow == nswindow)