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"
42 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
44 static struct list window_list = LIST_INIT(window_list);
46 static inline BOOL is_outer_window(HTMLWindow *window)
48 return &window->outer_window->base == window;
51 static void release_children(HTMLOuterWindow *This)
53 HTMLOuterWindow *child;
55 while(!list_empty(&This->children)) {
56 child = LIST_ENTRY(list_tail(&This->children), HTMLOuterWindow, sibling_entry);
58 list_remove(&child->sibling_entry);
60 IHTMLWindow2_Release(&child->base.IHTMLWindow2_iface);
64 static HRESULT get_location(HTMLInnerWindow *This, HTMLLocation **ret)
67 IHTMLLocation_AddRef(&This->location->IHTMLLocation_iface);
71 hres = HTMLLocation_Create(This, &This->location);
76 *ret = This->location;
80 void get_top_window(HTMLOuterWindow *window, HTMLOuterWindow **ret)
82 HTMLOuterWindow *iter;
84 for(iter = window; iter->parent; iter = iter->parent);
88 static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
90 if(!window->inner_window->doc) {
91 FIXME("No document\n");
95 return set_event_handler(&window->inner_window->doc->body_event_target, NULL, window->inner_window->doc, eid, var);
98 static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
100 if(!window->inner_window->doc) {
101 FIXME("No document\n");
105 return get_event_handler(&window->inner_window->doc->body_event_target, eid, var);
108 static void detach_inner_window(HTMLOuterWindow *outer_window)
110 HTMLInnerWindow *window = outer_window->base.inner_window;
115 if(outer_window->doc_obj && outer_window == outer_window->doc_obj->basedoc.window)
116 window->doc->basedoc.cp_container.forward_container = NULL;
118 detach_events(window->doc);
119 abort_window_bindings(window);
120 release_script_hosts(window);
121 window->doc->basedoc.window = NULL;
122 window->base.outer_window = NULL;
124 IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
127 static inline HTMLWindow *impl_from_IHTMLWindow2(IHTMLWindow2 *iface)
129 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow2_iface);
132 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
134 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
138 if(IsEqualGUID(&IID_IUnknown, riid)) {
139 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
140 *ppv = &This->IHTMLWindow2_iface;
141 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
142 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
143 *ppv = &This->IHTMLWindow2_iface;
144 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
145 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
146 *ppv = &This->IDispatchEx_iface;
147 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2, riid)) {
148 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
149 *ppv = &This->IHTMLWindow2_iface;
150 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
151 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
152 *ppv = &This->IHTMLWindow2_iface;
153 }else if(IsEqualGUID(&IID_IHTMLWindow3, riid)) {
154 TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This, ppv);
155 *ppv = &This->IHTMLWindow3_iface;
156 }else if(IsEqualGUID(&IID_IHTMLWindow4, riid)) {
157 TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This, ppv);
158 *ppv = &This->IHTMLWindow4_iface;
159 }else if(IsEqualGUID(&IID_IHTMLWindow5, riid)) {
160 TRACE("(%p)->(IID_IHTMLWindow5 %p)\n", This, ppv);
161 *ppv = &This->IHTMLWindow5_iface;
162 }else if(IsEqualGUID(&IID_IHTMLWindow6, riid)) {
163 TRACE("(%p)->(IID_IHTMLWindow6 %p)\n", This, ppv);
164 *ppv = &This->IHTMLWindow6_iface;
165 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow, riid)) {
166 TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This, ppv);
167 *ppv = &This->IHTMLPrivateWindow_iface;
168 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
169 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
170 *ppv = &This->IServiceProvider_iface;
171 }else if(IsEqualGUID(&IID_ITravelLogClient, riid)) {
172 TRACE("(%p)->(IID_ITravelLogClient %p)\n", This, ppv);
173 *ppv = &This->ITravelLogClient_iface;
174 }else if(dispex_query_interface(&This->inner_window->dispex, riid, ppv)) {
176 return E_NOINTERFACE;
180 IUnknown_AddRef((IUnknown*)*ppv);
184 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
185 return E_NOINTERFACE;
188 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
190 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
191 LONG ref = InterlockedIncrement(&This->ref);
193 TRACE("(%p) ref=%d\n", This, ref);
198 static void release_outer_window(HTMLOuterWindow *This)
200 if(This->pending_window) {
201 abort_window_bindings(This->pending_window);
202 This->pending_window->base.outer_window = NULL;
203 IHTMLWindow2_Release(&This->pending_window->base.IHTMLWindow2_iface);
206 remove_target_tasks(This->task_magic);
207 set_current_mon(This, NULL);
208 detach_inner_window(This);
209 release_children(This);
212 IInternetSecurityManager_Release(This->secmgr);
214 if(This->frame_element)
215 This->frame_element->content_window = NULL;
217 This->window_ref->window = NULL;
218 windowref_release(This->window_ref);
221 nsIDOMWindow_Release(This->nswindow);
223 list_remove(&This->entry);
227 static void release_inner_window(HTMLInnerWindow *This)
233 remove_target_tasks(This->task_magic);
234 abort_window_bindings(This);
235 release_script_hosts(This);
238 This->doc->window = NULL;
239 htmldoc_release(&This->doc->basedoc);
242 release_dispex(&This->dispex);
244 for(i=0; i < This->global_prop_cnt; i++)
245 heap_free(This->global_props[i].name);
246 heap_free(This->global_props);
249 This->location->window = NULL;
250 IHTMLLocation_Release(&This->location->IHTMLLocation_iface);
253 if(This->image_factory) {
254 This->image_factory->window = NULL;
255 IHTMLImageElementFactory_Release(&This->image_factory->IHTMLImageElementFactory_iface);
258 if(This->option_factory) {
259 This->option_factory->window = NULL;
260 IHTMLOptionElementFactory_Release(&This->option_factory->IHTMLOptionElementFactory_iface);
264 IHTMLScreen_Release(This->screen);
266 IOmHistory_Release(This->history);
268 IMoniker_Release(This->mon);
273 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
275 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
276 LONG ref = InterlockedDecrement(&This->ref);
278 TRACE("(%p) ref=%d\n", This, ref);
281 if(is_outer_window(This))
282 release_outer_window(This->outer_window);
284 release_inner_window(This->inner_window);
290 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
292 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
294 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
297 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
298 LCID lcid, ITypeInfo **ppTInfo)
300 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
302 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
305 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
306 LPOLESTR *rgszNames, UINT cNames,
307 LCID lcid, DISPID *rgDispId)
309 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
311 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
315 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
316 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
317 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
319 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
321 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
322 pDispParams, pVarResult, pExcepInfo, puArgErr);
325 static HRESULT get_frame_by_index(HTMLOuterWindow *This, PRUint32 index, HTMLOuterWindow **ret)
327 nsIDOMWindowCollection *nsframes;
328 nsIDOMWindow *nswindow;
332 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nsframes);
333 if(NS_FAILED(nsres)) {
334 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres);
338 nsres = nsIDOMWindowCollection_GetLength(nsframes, &length);
339 assert(nsres == NS_OK);
341 if(index >= length) {
342 nsIDOMWindowCollection_Release(nsframes);
343 return DISP_E_MEMBERNOTFOUND;
346 nsres = nsIDOMWindowCollection_Item(nsframes, index, &nswindow);
347 nsIDOMWindowCollection_Release(nsframes);
348 if(NS_FAILED(nsres)) {
349 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
353 *ret = nswindow_to_window(nswindow);
355 nsIDOMWindow_Release(nswindow);
359 static HRESULT get_frame_by_name(HTMLOuterWindow *This, const WCHAR *name, HTMLOuterWindow **ret)
361 nsIDOMWindowCollection *nsframes;
362 HTMLOuterWindow *window = NULL;
367 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nsframes);
368 if(NS_FAILED(nsres)) {
369 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres);
373 nsres = nsIDOMWindowCollection_GetLength(nsframes, &length);
374 assert(nsres == NS_OK);
376 for(i = 0; i < length && !window; ++i) {
377 HTMLOuterWindow *window_iter;
378 nsIDOMWindow *nswindow;
381 nsres = nsIDOMWindowCollection_Item(nsframes, i, &nswindow);
382 if(NS_FAILED(nsres)) {
383 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
388 window_iter = nswindow_to_window(nswindow);
390 nsIDOMWindow_Release(nswindow);
392 hres = IHTMLElement_get_id(&window_iter->frame_element->element.IHTMLElement_iface, &id);
394 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres);
398 if(id && !strcmpiW(id, name))
399 window = window_iter;
404 nsIDOMWindowCollection_Release(nsframes);
412 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
414 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
415 HTMLOuterWindow *window = NULL;
418 TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
420 switch(V_VT(pvarIndex)) {
422 int index = V_I4(pvarIndex);
423 TRACE("Getting index %d\n", index);
425 return DISP_E_MEMBERNOTFOUND;
426 hres = get_frame_by_index(This->outer_window, index, &window);
430 unsigned int index = V_UINT(pvarIndex);
431 TRACE("Getting index %u\n", index);
432 hres = get_frame_by_index(This->outer_window, index, &window);
436 BSTR str = V_BSTR(pvarIndex);
437 TRACE("Getting name %s\n", wine_dbgstr_w(str));
438 hres = get_frame_by_name(This->outer_window, str, &window);
442 WARN("Invalid index %s\n", debugstr_variant(pvarIndex));
449 return DISP_E_MEMBERNOTFOUND;
451 IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
452 V_VT(pvarResult) = VT_DISPATCH;
453 V_DISPATCH(pvarResult) = (IDispatch*)window;
457 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
459 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
460 nsIDOMWindowCollection *nscollection;
464 TRACE("(%p)->(%p)\n", This, p);
466 nsres = nsIDOMWindow_GetFrames(This->outer_window->nswindow, &nscollection);
467 if(NS_FAILED(nsres)) {
468 ERR("GetFrames failed: %08x\n", nsres);
472 nsres = nsIDOMWindowCollection_GetLength(nscollection, &length);
473 nsIDOMWindowCollection_Release(nscollection);
474 if(NS_FAILED(nsres)) {
475 ERR("GetLength failed: %08x\n", nsres);
483 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
485 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
486 FIXME("(%p)->(%p): semi-stub\n", This, p);
488 /* FIXME: Should return a separate Window object */
489 *p = (IHTMLFramesCollection2*)&This->IHTMLWindow2_iface;
490 HTMLWindow2_AddRef(iface);
494 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
496 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
497 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
501 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
503 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
504 FIXME("(%p)->(%p)\n", This, p);
508 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
510 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
512 WARN("(%p)->(%s)\n", This, debugstr_w(v));
515 * FIXME: Since IE7, setting status is blocked, but still possible in certain circumstances.
516 * Ignoring the call should be enough for us.
521 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
523 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
525 TRACE("(%p)->(%p)\n", This, p);
532 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
533 LONG msec, VARIANT *language, LONG *timerID)
535 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
538 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
540 V_VT(&expr_var) = VT_BSTR;
541 V_BSTR(&expr_var) = expression;
543 return IHTMLWindow3_setTimeout(&This->IHTMLWindow3_iface, &expr_var, msec, language, timerID);
546 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID)
548 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
550 TRACE("(%p)->(%d)\n", This, timerID);
552 return clear_task_timer(&This->inner_window->doc->basedoc, FALSE, timerID);
555 #define MAX_MESSAGE_LEN 2000
557 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
559 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
560 WCHAR title[100], *msg = message;
563 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
565 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, title,
566 sizeof(title)/sizeof(WCHAR))) {
567 WARN("Could not load message box title: %d\n", GetLastError());
571 len = SysStringLen(message);
572 if(len > MAX_MESSAGE_LEN) {
573 msg = heap_alloc((MAX_MESSAGE_LEN+1)*sizeof(WCHAR));
575 return E_OUTOFMEMORY;
576 memcpy(msg, message, MAX_MESSAGE_LEN*sizeof(WCHAR));
577 msg[MAX_MESSAGE_LEN] = 0;
580 MessageBoxW(This->outer_window->doc_obj->hwnd, msg, title, MB_ICONWARNING);
586 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
587 VARIANT_BOOL *confirmed)
589 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
592 TRACE("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
594 if(!confirmed) return E_INVALIDARG;
596 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
597 sizeof(wszTitle)/sizeof(WCHAR))) {
598 WARN("Could not load message box title: %d\n", GetLastError());
599 *confirmed = VARIANT_TRUE;
603 if(MessageBoxW(This->outer_window->doc_obj->hwnd, message, wszTitle,
604 MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
605 *confirmed = VARIANT_TRUE;
606 else *confirmed = VARIANT_FALSE;
618 static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
619 WPARAM wparam, LPARAM lparam)
625 prompt_arg *arg = (prompt_arg*)lparam;
628 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
629 sizeof(wszTitle)/sizeof(WCHAR))) {
630 WARN("Could not load message box title: %d\n", GetLastError());
631 EndDialog(hwnd, wparam);
635 SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
636 SetWindowTextW(hwnd, wszTitle);
637 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_PROMPT), arg->message);
638 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_EDIT), arg->dststr);
644 case MAKEWPARAM(IDCANCEL, BN_CLICKED):
645 EndDialog(hwnd, wparam);
647 case MAKEWPARAM(IDOK, BN_CLICKED):
650 (prompt_arg*)GetWindowLongPtrW(hwnd, DWLP_USER);
651 HWND hwndPrompt = GetDlgItem(hwnd, ID_PROMPT_EDIT);
652 INT len = GetWindowTextLengthW(hwndPrompt);
656 EndDialog(hwnd, wparam);
660 V_VT(arg->textdata) = VT_BSTR;
661 if(!len && !arg->dststr)
662 V_BSTR(arg->textdata) = NULL;
665 V_BSTR(arg->textdata) = SysAllocStringLen(NULL, len);
666 GetWindowTextW(hwndPrompt, V_BSTR(arg->textdata), len+1);
668 EndDialog(hwnd, wparam);
674 EndDialog(hwnd, IDCANCEL);
681 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
682 BSTR dststr, VARIANT *textdata)
684 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
687 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
689 if(textdata) V_VT(textdata) = VT_NULL;
691 arg.message = message;
693 arg.textdata = textdata;
695 DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
696 This->outer_window->doc_obj->hwnd, prompt_dlgproc, (LPARAM)&arg);
700 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
702 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
703 HTMLInnerWindow *window = This->inner_window;
705 TRACE("(%p)->(%p)\n", This, p);
707 if(!window->image_factory) {
710 hres = HTMLImageElementFactory_Create(window, &window->image_factory);
715 *p = &window->image_factory->IHTMLImageElementFactory_iface;
716 IHTMLImageElementFactory_AddRef(*p);
721 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
723 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
724 HTMLLocation *location;
727 TRACE("(%p)->(%p)\n", This, p);
729 hres = get_location(This->inner_window, &location);
733 *p = &location->IHTMLLocation_iface;
737 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
739 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
740 HTMLInnerWindow *window = This->inner_window;
742 TRACE("(%p)->(%p)\n", This, p);
744 if(!window->history) {
747 hres = create_history(&window->history);
752 IOmHistory_AddRef(window->history);
753 *p = window->history;
757 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
759 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
760 FIXME("(%p)->()\n", This);
764 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
766 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
767 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
771 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
773 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
775 FIXME("(%p)->(%p) returning empty\n", This, p);
781 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
783 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
785 TRACE("(%p)->(%p)\n", This, p);
787 *p = OmNavigator_Create();
791 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
793 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
797 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
799 nsAString_InitDepend(&name_str, v);
800 nsres = nsIDOMWindow_SetName(This->outer_window->nswindow, &name_str);
801 nsAString_Finish(&name_str);
803 ERR("SetName failed: %08x\n", nsres);
808 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
810 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
814 TRACE("(%p)->(%p)\n", This, p);
816 nsAString_Init(&name_str, NULL);
817 nsres = nsIDOMWindow_GetName(This->outer_window->nswindow, &name_str);
818 return return_nsstr(nsres, &name_str, p);
821 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
823 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
824 HTMLOuterWindow *window = This->outer_window;
826 TRACE("(%p)->(%p)\n", This, p);
829 return IHTMLWindow2_get_self(&This->IHTMLWindow2_iface, p);
831 *p = &window->parent->base.IHTMLWindow2_iface;
832 IHTMLWindow2_AddRef(*p);
836 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
837 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
839 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
840 HTMLOuterWindow *window = This->outer_window;
841 INewWindowManager *new_window_mgr;
845 TRACE("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
846 debugstr_w(features), replace, pomWindowResult);
851 if(name && *name == '_') {
852 FIXME("Unsupported name %s\n", debugstr_w(name));
856 hres = do_query_service((IUnknown*)window->doc_obj->client, &SID_SNewWindowManager, &IID_INewWindowManager,
857 (void**)&new_window_mgr);
859 FIXME("No INewWindowManager\n");
863 hres = INewWindowManager_EvaluateNewWindow(new_window_mgr, url, name, window->url,
864 features, !!replace, window->doc_obj->has_popup ? 0 : NWMF_FIRST, 0);
865 INewWindowManager_Release(new_window_mgr);
866 window->doc_obj->has_popup = TRUE;
868 *pomWindowResult = NULL;
872 hres = create_relative_uri(window, url, &uri);
876 hres = navigate_new_window(window, uri, name, pomWindowResult);
881 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
883 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
885 TRACE("(%p)->(%p)\n", This, p);
887 /* FIXME: We should return kind of proxy window here. */
888 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
889 *p = &This->IHTMLWindow2_iface;
893 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
895 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
896 HTMLOuterWindow *top;
898 TRACE("(%p)->(%p)\n", This, p);
900 get_top_window(This->outer_window, &top);
901 *p = &top->base.IHTMLWindow2_iface;
902 IHTMLWindow2_AddRef(*p);
907 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
909 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
911 TRACE("(%p)->(%p)\n", This, p);
913 /* FIXME: We should return kind of proxy window here. */
914 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
915 *p = &This->IHTMLWindow2_iface;
919 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
921 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
922 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
926 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
928 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
929 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
933 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
935 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
936 FIXME("(%p)->(%p)\n", This, p);
940 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
942 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
943 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
947 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
949 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
950 FIXME("(%p)->(%p)\n", This, p);
954 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
956 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
958 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
960 return set_window_event(This, EVENTID_LOAD, &v);
963 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
965 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
967 TRACE("(%p)->(%p)\n", This, p);
969 return get_window_event(This, EVENTID_LOAD, p);
972 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
974 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
976 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
978 return set_window_event(This, EVENTID_BEFOREUNLOAD, &v);
981 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
983 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
985 TRACE("(%p)->(%p)\n", This, p);
987 return get_window_event(This, EVENTID_BEFOREUNLOAD, p);
990 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
992 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
993 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
997 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
999 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1000 FIXME("(%p)->(%p)\n", This, p);
1004 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
1006 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1007 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1011 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
1013 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1014 FIXME("(%p)->(%p)\n", This, p);
1018 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
1020 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1022 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
1024 return set_window_event(This, EVENTID_ERROR, &v);
1027 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
1029 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1031 TRACE("(%p)->(%p)\n", This, p);
1033 return get_window_event(This, EVENTID_ERROR, p);
1036 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
1038 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1040 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
1042 return set_window_event(This, EVENTID_RESIZE, &v);
1045 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
1047 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1049 TRACE("(%p)->(%p)\n", This, p);
1051 return get_window_event(This, EVENTID_RESIZE, p);
1054 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
1056 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1057 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1061 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
1063 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1064 FIXME("(%p)->(%p)\n", This, p);
1068 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
1070 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1072 TRACE("(%p)->(%p)\n", This, p);
1074 if(This->inner_window->doc) {
1075 /* FIXME: We should return a wrapper object here */
1076 *p = &This->inner_window->doc->basedoc.IHTMLDocument2_iface;
1077 IHTMLDocument2_AddRef(*p);
1085 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
1087 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1088 HTMLInnerWindow *window = This->inner_window;
1090 TRACE("(%p)->(%p)\n", This, p);
1093 IHTMLEventObj_AddRef(window->event);
1098 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
1100 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1101 FIXME("(%p)->(%p)\n", This, p);
1105 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
1106 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
1108 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1109 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
1113 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
1116 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1117 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(helpURL), debugstr_variant(&helpArg), debugstr_w(features));
1121 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
1123 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1124 HTMLInnerWindow *window = This->inner_window;
1126 TRACE("(%p)->(%p)\n", This, p);
1128 if(!window->screen) {
1131 hres = HTMLScreen_Create(&window->screen);
1136 *p = window->screen;
1137 IHTMLScreen_AddRef(window->screen);
1141 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
1143 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1144 HTMLInnerWindow *window = This->inner_window;
1146 TRACE("(%p)->(%p)\n", This, p);
1148 if(!window->option_factory) {
1151 hres = HTMLOptionElementFactory_Create(window, &window->option_factory);
1156 *p = &window->option_factory->IHTMLOptionElementFactory_iface;
1157 IHTMLOptionElementFactory_AddRef(*p);
1162 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
1164 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1166 TRACE("(%p)->()\n", This);
1168 if(This->outer_window->doc_obj)
1169 SetFocus(This->outer_window->doc_obj->hwnd);
1173 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
1175 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1176 FIXME("(%p)->(%p)\n", This, p);
1180 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
1182 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1183 FIXME("(%p)->()\n", This);
1187 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, LONG x, LONG y)
1189 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1190 FIXME("(%p)->(%d %d)\n", This, x, y);
1194 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
1196 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1197 FIXME("(%p)->(%p)\n", This, p);
1201 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
1202 LONG msec, VARIANT *language, LONG *timerID)
1204 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1207 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
1209 V_VT(&expr) = VT_BSTR;
1210 V_BSTR(&expr) = expression;
1211 return IHTMLWindow3_setInterval(&This->IHTMLWindow3_iface, &expr, msec, language, timerID);
1214 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerID)
1216 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1218 TRACE("(%p)->(%d)\n", This, timerID);
1220 return clear_task_timer(&This->inner_window->doc->basedoc, TRUE, timerID);
1223 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
1225 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1226 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1230 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
1232 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1233 FIXME("(%p)->(%p)\n", This, p);
1237 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
1240 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1242 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
1244 return exec_script(This->inner_window, scode, language, pvarRet);
1247 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
1249 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1251 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1253 TRACE("(%p)->(%p)\n", This, String);
1256 return E_INVALIDARG;
1258 *String = SysAllocString(objectW);
1259 return *String ? S_OK : E_OUTOFMEMORY;
1262 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, LONG x, LONG y)
1264 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1267 TRACE("(%p)->(%d %d)\n", This, x, y);
1269 nsres = nsIDOMWindow_ScrollBy(This->outer_window->nswindow, x, y);
1270 if(NS_FAILED(nsres))
1271 ERR("ScrollBy failed: %08x\n", nsres);
1276 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, LONG x, LONG y)
1278 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1281 TRACE("(%p)->(%d %d)\n", This, x, y);
1283 nsres = nsIDOMWindow_ScrollTo(This->outer_window->nswindow, x, y);
1284 if(NS_FAILED(nsres))
1285 ERR("ScrollTo failed: %08x\n", nsres);
1290 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, LONG x, LONG y)
1292 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1293 FIXME("(%p)->(%d %d)\n", This, x, y);
1297 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, LONG x, LONG y)
1299 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1300 FIXME("(%p)->(%d %d)\n", This, x, y);
1304 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, LONG x, LONG y)
1306 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1307 FIXME("(%p)->(%d %d)\n", This, x, y);
1311 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, LONG x, LONG y)
1313 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1314 FIXME("(%p)->(%d %d)\n", This, x, y);
1318 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
1320 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1322 TRACE("(%p)->(%p)\n", This, p);
1326 if(!This->outer_window->doc_obj->hostui)
1329 return IDocHostUIHandler_GetExternal(This->outer_window->doc_obj->hostui, p);
1332 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
1333 HTMLWindow2_QueryInterface,
1335 HTMLWindow2_Release,
1336 HTMLWindow2_GetTypeInfoCount,
1337 HTMLWindow2_GetTypeInfo,
1338 HTMLWindow2_GetIDsOfNames,
1341 HTMLWindow2_get_length,
1342 HTMLWindow2_get_frames,
1343 HTMLWindow2_put_defaultStatus,
1344 HTMLWindow2_get_defaultStatus,
1345 HTMLWindow2_put_status,
1346 HTMLWindow2_get_status,
1347 HTMLWindow2_setTimeout,
1348 HTMLWindow2_clearTimeout,
1350 HTMLWindow2_confirm,
1352 HTMLWindow2_get_Image,
1353 HTMLWindow2_get_location,
1354 HTMLWindow2_get_history,
1356 HTMLWindow2_put_opener,
1357 HTMLWindow2_get_opener,
1358 HTMLWindow2_get_navigator,
1359 HTMLWindow2_put_name,
1360 HTMLWindow2_get_name,
1361 HTMLWindow2_get_parent,
1363 HTMLWindow2_get_self,
1364 HTMLWindow2_get_top,
1365 HTMLWindow2_get_window,
1366 HTMLWindow2_navigate,
1367 HTMLWindow2_put_onfocus,
1368 HTMLWindow2_get_onfocus,
1369 HTMLWindow2_put_onblur,
1370 HTMLWindow2_get_onblur,
1371 HTMLWindow2_put_onload,
1372 HTMLWindow2_get_onload,
1373 HTMLWindow2_put_onbeforeunload,
1374 HTMLWindow2_get_onbeforeunload,
1375 HTMLWindow2_put_onunload,
1376 HTMLWindow2_get_onunload,
1377 HTMLWindow2_put_onhelp,
1378 HTMLWindow2_get_onhelp,
1379 HTMLWindow2_put_onerror,
1380 HTMLWindow2_get_onerror,
1381 HTMLWindow2_put_onresize,
1382 HTMLWindow2_get_onresize,
1383 HTMLWindow2_put_onscroll,
1384 HTMLWindow2_get_onscroll,
1385 HTMLWindow2_get_document,
1386 HTMLWindow2_get_event,
1387 HTMLWindow2_get__newEnum,
1388 HTMLWindow2_showModalDialog,
1389 HTMLWindow2_showHelp,
1390 HTMLWindow2_get_screen,
1391 HTMLWindow2_get_Option,
1393 HTMLWindow2_get_closed,
1396 HTMLWindow2_get_clientInformation,
1397 HTMLWindow2_setInterval,
1398 HTMLWindow2_clearInterval,
1399 HTMLWindow2_put_offscreenBuffering,
1400 HTMLWindow2_get_offscreenBuffering,
1401 HTMLWindow2_execScript,
1402 HTMLWindow2_toString,
1403 HTMLWindow2_scrollBy,
1404 HTMLWindow2_scrollTo,
1407 HTMLWindow2_resizeTo,
1408 HTMLWindow2_resizeBy,
1409 HTMLWindow2_get_external
1412 static inline HTMLWindow *impl_from_IHTMLWindow3(IHTMLWindow3 *iface)
1414 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow3_iface);
1417 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
1419 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1421 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1424 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
1426 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1428 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1431 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
1433 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1435 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1438 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
1440 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1442 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1445 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
1446 LCID lcid, ITypeInfo **ppTInfo)
1448 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1450 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1453 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
1454 LPOLESTR *rgszNames, UINT cNames,
1455 LCID lcid, DISPID *rgDispId)
1457 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1459 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1463 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
1464 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1465 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1467 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1469 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1470 pDispParams, pVarResult, pExcepInfo, puArgErr);
1473 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, LONG *p)
1475 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1476 FIXME("(%p)->(%p)\n", This, p);
1480 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, LONG *p)
1482 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1483 FIXME("(%p)->(%p)\n", This, p);
1487 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
1489 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1490 HTMLInnerWindow *window = This->inner_window;
1492 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
1495 FIXME("No document\n");
1499 return attach_event(&window->doc->body_event_target, NULL, &window->doc->basedoc, event, pDisp, pfResult);
1502 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
1504 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1505 HTMLInnerWindow *window = This->inner_window;
1507 TRACE("(%p)->()\n", This);
1510 FIXME("No document\n");
1514 return detach_event(window->doc->body_event_target, &window->doc->basedoc, event, pDisp);
1517 static HRESULT window_set_timer(HTMLInnerWindow *This, VARIANT *expr, LONG msec, VARIANT *language,
1518 BOOL interval, LONG *timer_id)
1520 IDispatch *disp = NULL;
1522 switch(V_VT(expr)) {
1524 disp = V_DISPATCH(expr);
1525 IDispatch_AddRef(disp);
1529 disp = script_parse_event(This->base.inner_window, V_BSTR(expr));
1533 FIXME("unimplemented expr %s\n", debugstr_variant(expr));
1540 *timer_id = set_task_timer(&This->doc->basedoc, msec, interval, disp);
1541 IDispatch_Release(disp);
1546 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1547 VARIANT *language, LONG *timerID)
1549 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1551 TRACE("(%p)->(%s %d %s %p)\n", This, debugstr_variant(expression), msec, debugstr_variant(language), timerID);
1553 return window_set_timer(This->inner_window, expression, msec, language, FALSE, timerID);
1556 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1557 VARIANT *language, LONG *timerID)
1559 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1561 TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID);
1563 return window_set_timer(This->inner_window, expression, msec, language, TRUE, timerID);
1566 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
1568 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1569 FIXME("(%p)\n", This);
1573 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
1575 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1576 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1580 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
1582 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1583 FIXME("(%p)->(%p)\n", This, p);
1587 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
1589 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1590 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1594 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
1596 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1597 FIXME("(%p)->(%p)\n", This, p);
1601 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
1603 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1604 FIXME("(%p)->(%p)\n", This, p);
1608 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
1609 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
1611 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1612 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
1616 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
1617 HTMLWindow3_QueryInterface,
1619 HTMLWindow3_Release,
1620 HTMLWindow3_GetTypeInfoCount,
1621 HTMLWindow3_GetTypeInfo,
1622 HTMLWindow3_GetIDsOfNames,
1624 HTMLWindow3_get_screenLeft,
1625 HTMLWindow3_get_screenTop,
1626 HTMLWindow3_attachEvent,
1627 HTMLWindow3_detachEvent,
1628 HTMLWindow3_setTimeout,
1629 HTMLWindow3_setInterval,
1631 HTMLWindow3_put_onbeforeprint,
1632 HTMLWindow3_get_onbeforeprint,
1633 HTMLWindow3_put_onafterprint,
1634 HTMLWindow3_get_onafterprint,
1635 HTMLWindow3_get_clipboardData,
1636 HTMLWindow3_showModelessDialog
1639 static inline HTMLWindow *impl_from_IHTMLWindow4(IHTMLWindow4 *iface)
1641 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow4_iface);
1644 static HRESULT WINAPI HTMLWindow4_QueryInterface(IHTMLWindow4 *iface, REFIID riid, void **ppv)
1646 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1648 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1651 static ULONG WINAPI HTMLWindow4_AddRef(IHTMLWindow4 *iface)
1653 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1655 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1658 static ULONG WINAPI HTMLWindow4_Release(IHTMLWindow4 *iface)
1660 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1662 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1665 static HRESULT WINAPI HTMLWindow4_GetTypeInfoCount(IHTMLWindow4 *iface, UINT *pctinfo)
1667 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1669 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1672 static HRESULT WINAPI HTMLWindow4_GetTypeInfo(IHTMLWindow4 *iface, UINT iTInfo,
1673 LCID lcid, ITypeInfo **ppTInfo)
1675 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1677 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1680 static HRESULT WINAPI HTMLWindow4_GetIDsOfNames(IHTMLWindow4 *iface, REFIID riid,
1681 LPOLESTR *rgszNames, UINT cNames,
1682 LCID lcid, DISPID *rgDispId)
1684 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1686 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1690 static HRESULT WINAPI HTMLWindow4_Invoke(IHTMLWindow4 *iface, DISPID dispIdMember,
1691 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1692 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1694 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1696 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1697 pDispParams, pVarResult, pExcepInfo, puArgErr);
1700 static HRESULT WINAPI HTMLWindow4_createPopup(IHTMLWindow4 *iface, VARIANT *varArgIn,
1701 IDispatch **ppPopup)
1703 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1704 FIXME("(%p)->(%p %p)\n", This, varArgIn, ppPopup);
1708 static HRESULT WINAPI HTMLWindow4_get_frameElement(IHTMLWindow4 *iface, IHTMLFrameBase **p)
1710 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1711 TRACE("(%p)->(%p)\n", This, p);
1713 if(This->outer_window->frame_element) {
1714 *p = &This->outer_window->frame_element->IHTMLFrameBase_iface;
1715 IHTMLFrameBase_AddRef(*p);
1722 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl = {
1723 HTMLWindow4_QueryInterface,
1725 HTMLWindow4_Release,
1726 HTMLWindow4_GetTypeInfoCount,
1727 HTMLWindow4_GetTypeInfo,
1728 HTMLWindow4_GetIDsOfNames,
1730 HTMLWindow4_createPopup,
1731 HTMLWindow4_get_frameElement
1734 static inline HTMLWindow *impl_from_IHTMLWindow5(IHTMLWindow5 *iface)
1736 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow5_iface);
1739 static HRESULT WINAPI HTMLWindow5_QueryInterface(IHTMLWindow5 *iface, REFIID riid, void **ppv)
1741 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1743 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1746 static ULONG WINAPI HTMLWindow5_AddRef(IHTMLWindow5 *iface)
1748 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1750 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1753 static ULONG WINAPI HTMLWindow5_Release(IHTMLWindow5 *iface)
1755 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1757 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1760 static HRESULT WINAPI HTMLWindow5_GetTypeInfoCount(IHTMLWindow5 *iface, UINT *pctinfo)
1762 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1764 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1767 static HRESULT WINAPI HTMLWindow5_GetTypeInfo(IHTMLWindow5 *iface, UINT iTInfo,
1768 LCID lcid, ITypeInfo **ppTInfo)
1770 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1772 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1775 static HRESULT WINAPI HTMLWindow5_GetIDsOfNames(IHTMLWindow5 *iface, REFIID riid,
1776 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1778 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1780 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1784 static HRESULT WINAPI HTMLWindow5_Invoke(IHTMLWindow5 *iface, DISPID dispIdMember,
1785 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1786 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1788 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1790 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1791 pDispParams, pVarResult, pExcepInfo, puArgErr);
1794 static HRESULT WINAPI HTMLWindow5_put_XMLHttpRequest(IHTMLWindow5 *iface, VARIANT v)
1796 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1797 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1801 static HRESULT WINAPI HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5 *iface, VARIANT *p)
1803 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1804 FIXME("(%p)->(%p)\n", This, p);
1808 static const IHTMLWindow5Vtbl HTMLWindow5Vtbl = {
1809 HTMLWindow5_QueryInterface,
1811 HTMLWindow5_Release,
1812 HTMLWindow5_GetTypeInfoCount,
1813 HTMLWindow5_GetTypeInfo,
1814 HTMLWindow5_GetIDsOfNames,
1816 HTMLWindow5_put_XMLHttpRequest,
1817 HTMLWindow5_get_XMLHttpRequest
1820 static inline HTMLWindow *impl_from_IHTMLWindow6(IHTMLWindow6 *iface)
1822 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow6_iface);
1825 static HRESULT WINAPI HTMLWindow6_QueryInterface(IHTMLWindow6 *iface, REFIID riid, void **ppv)
1827 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1829 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1832 static ULONG WINAPI HTMLWindow6_AddRef(IHTMLWindow6 *iface)
1834 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1836 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1839 static ULONG WINAPI HTMLWindow6_Release(IHTMLWindow6 *iface)
1841 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1843 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1846 static HRESULT WINAPI HTMLWindow6_GetTypeInfoCount(IHTMLWindow6 *iface, UINT *pctinfo)
1848 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1850 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1853 static HRESULT WINAPI HTMLWindow6_GetTypeInfo(IHTMLWindow6 *iface, UINT iTInfo,
1854 LCID lcid, ITypeInfo **ppTInfo)
1856 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1858 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1861 static HRESULT WINAPI HTMLWindow6_GetIDsOfNames(IHTMLWindow6 *iface, REFIID riid,
1862 LPOLESTR *rgszNames, UINT cNames,
1863 LCID lcid, DISPID *rgDispId)
1865 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1867 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1871 static HRESULT WINAPI HTMLWindow6_Invoke(IHTMLWindow6 *iface, DISPID dispIdMember,
1872 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1873 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1875 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1877 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1878 pDispParams, pVarResult, pExcepInfo, puArgErr);
1881 static HRESULT WINAPI HTMLWindow6_put_XDomainRequest(IHTMLWindow6 *iface, VARIANT v)
1883 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1884 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1888 static HRESULT WINAPI HTMLWindow6_get_XDomainRequest(IHTMLWindow6 *iface, VARIANT *p)
1890 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1891 FIXME("(%p)->(%p)\n", This, p);
1895 static HRESULT WINAPI HTMLWindow6_get_sessionStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1897 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1899 FIXME("(%p)->(%p)\n", This, p);
1901 if(!This->inner_window->session_storage) {
1904 hres = create_storage(&This->inner_window->session_storage);
1909 IHTMLStorage_AddRef(This->inner_window->session_storage);
1910 *p = This->inner_window->session_storage;
1914 static HRESULT WINAPI HTMLWindow6_get_localStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1916 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1917 FIXME("(%p)->(%p)\n", This, p);
1921 static HRESULT WINAPI HTMLWindow6_put_onhashchange(IHTMLWindow6 *iface, VARIANT v)
1923 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1924 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1928 static HRESULT WINAPI HTMLWindow6_get_onhashchange(IHTMLWindow6 *iface, VARIANT *p)
1930 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1931 FIXME("(%p)->(%p)\n", This, p);
1935 static HRESULT WINAPI HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6 *iface, LONG *p)
1937 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1938 FIXME("(%p)->(%p)\n", This, p);
1942 static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VARIANT targetOrigin)
1944 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1945 FIXME("(%p)->(%s %s)\n", This, debugstr_w(msg), debugstr_variant(&targetOrigin));
1949 static HRESULT WINAPI HTMLWindow6_toStaticHTML(IHTMLWindow6 *iface, BSTR bstrHTML, BSTR *pbstrStaticHTML)
1951 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1952 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrHTML), pbstrStaticHTML);
1956 static HRESULT WINAPI HTMLWindow6_put_onmessage(IHTMLWindow6 *iface, VARIANT v)
1958 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1959 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1963 static HRESULT WINAPI HTMLWindow6_get_onmessage(IHTMLWindow6 *iface, VARIANT *p)
1965 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1966 FIXME("(%p)->(%p)\n", This, p);
1970 static HRESULT WINAPI HTMLWindow6_msWriteProfilerMark(IHTMLWindow6 *iface, BSTR bstrProfilerMark)
1972 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1973 FIXME("(%p)->(%s)\n", This, debugstr_w(bstrProfilerMark));
1977 static const IHTMLWindow6Vtbl HTMLWindow6Vtbl = {
1978 HTMLWindow6_QueryInterface,
1980 HTMLWindow6_Release,
1981 HTMLWindow6_GetTypeInfoCount,
1982 HTMLWindow6_GetTypeInfo,
1983 HTMLWindow6_GetIDsOfNames,
1985 HTMLWindow6_put_XDomainRequest,
1986 HTMLWindow6_get_XDomainRequest,
1987 HTMLWindow6_get_sessionStorage,
1988 HTMLWindow6_get_localStorage,
1989 HTMLWindow6_put_onhashchange,
1990 HTMLWindow6_get_onhashchange,
1991 HTMLWindow6_get_maxConnectionsPerServer,
1992 HTMLWindow6_postMessage,
1993 HTMLWindow6_toStaticHTML,
1994 HTMLWindow6_put_onmessage,
1995 HTMLWindow6_get_onmessage,
1996 HTMLWindow6_msWriteProfilerMark
1999 static inline HTMLWindow *impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow *iface)
2001 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLPrivateWindow_iface);
2004 static HRESULT WINAPI HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow *iface, REFIID riid, void **ppv)
2006 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2008 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2011 static ULONG WINAPI HTMLPrivateWindow_AddRef(IHTMLPrivateWindow *iface)
2013 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2015 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2018 static ULONG WINAPI HTMLPrivateWindow_Release(IHTMLPrivateWindow *iface)
2020 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2022 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2025 static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface, BSTR url, BSTR arg2, BSTR arg3,
2026 BSTR arg4, VARIANT *post_data_var, VARIANT *headers_var, ULONG flags)
2028 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2029 HTMLOuterWindow *window = This->outer_window;
2030 OLECHAR *translated_url = NULL;
2031 DWORD post_data_size = 0;
2032 BYTE *post_data = NULL;
2033 WCHAR *headers = NULL;
2037 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This, debugstr_w(url), debugstr_w(arg2), debugstr_w(arg3), debugstr_w(arg4),
2038 debugstr_variant(post_data_var), debugstr_variant(headers_var), flags);
2040 if(window->doc_obj->hostui) {
2041 hres = IDocHostUIHandler_TranslateUrl(window->doc_obj->hostui, 0, url, &translated_url);
2043 translated_url = NULL;
2046 hres = CreateUri(translated_url ? translated_url : url, 0, 0, &uri);
2047 CoTaskMemFree(translated_url);
2052 if(V_VT(post_data_var) == (VT_ARRAY|VT_UI1)) {
2053 SafeArrayAccessData(V_ARRAY(post_data_var), (void**)&post_data);
2054 post_data_size = V_ARRAY(post_data_var)->rgsabound[0].cElements;
2058 if(headers_var && V_VT(headers_var) != VT_EMPTY && V_VT(headers_var) != VT_ERROR) {
2059 if(V_VT(headers_var) != VT_BSTR)
2060 return E_INVALIDARG;
2062 headers = V_BSTR(headers_var);
2065 hres = super_navigate(window, uri, headers, post_data, post_data_size);
2068 SafeArrayUnaccessData(V_ARRAY(post_data_var));
2073 static HRESULT WINAPI HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow *iface, BSTR *url)
2075 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2076 FIXME("(%p)->(%p)\n", This, url);
2080 static HRESULT WINAPI HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow *iface, IOleCommandTarget *cmdtrg)
2082 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2083 FIXME("(%p)->(%p)\n", This, cmdtrg);
2087 static HRESULT WINAPI HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow *iface, int arg)
2089 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2090 FIXME("(%p)->(%x)\n", This, arg);
2094 static HRESULT WINAPI HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow *iface, LPCWSTR name, IHTMLWindow2 **ret)
2096 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2097 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), ret);
2101 static HRESULT WINAPI HTMLPrivateWindow_GetAddressBarUrl(IHTMLPrivateWindow *iface, BSTR *url)
2103 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2104 TRACE("(%p)->(%p)\n", This, url);
2107 return E_INVALIDARG;
2109 *url = SysAllocString(This->outer_window->url);
2113 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl = {
2114 HTMLPrivateWindow_QueryInterface,
2115 HTMLPrivateWindow_AddRef,
2116 HTMLPrivateWindow_Release,
2117 HTMLPrivateWindow_SuperNavigate,
2118 HTMLPrivateWindow_GetPendingUrl,
2119 HTMLPrivateWindow_SetPICSTarget,
2120 HTMLPrivateWindow_PICSComplete,
2121 HTMLPrivateWindow_FindWindowByName,
2122 HTMLPrivateWindow_GetAddressBarUrl
2125 static inline HTMLWindow *impl_from_ITravelLogClient(ITravelLogClient *iface)
2127 return CONTAINING_RECORD(iface, HTMLWindow, ITravelLogClient_iface);
2130 static HRESULT WINAPI TravelLogClient_QueryInterface(ITravelLogClient *iface, REFIID riid, void **ppv)
2132 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2134 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2137 static ULONG WINAPI TravelLogClient_AddRef(ITravelLogClient *iface)
2139 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2141 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2144 static ULONG WINAPI TravelLogClient_Release(ITravelLogClient *iface)
2146 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2148 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2151 static HRESULT WINAPI TravelLogClient_FindWindowByIndex(ITravelLogClient *iface, DWORD dwID, IUnknown **ppunk)
2153 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2155 FIXME("(%p)->(%d %p) semi-stub\n", This, dwID, ppunk);
2161 static HRESULT WINAPI TravelLogClient_GetWindowData(ITravelLogClient *iface, IStream *pStream, LPWINDOWDATA pWinData)
2163 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2164 FIXME("(%p)->(%p %p)\n", This, pStream, pWinData);
2168 static HRESULT WINAPI TravelLogClient_LoadHistoryPosition(ITravelLogClient *iface, LPWSTR pszUrlLocation, DWORD dwPosition)
2170 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2171 FIXME("(%p)->(%s %d)\n", This, debugstr_w(pszUrlLocation), dwPosition);
2175 static const ITravelLogClientVtbl TravelLogClientVtbl = {
2176 TravelLogClient_QueryInterface,
2177 TravelLogClient_AddRef,
2178 TravelLogClient_Release,
2179 TravelLogClient_FindWindowByIndex,
2180 TravelLogClient_GetWindowData,
2181 TravelLogClient_LoadHistoryPosition
2184 static inline HTMLWindow *impl_from_IDispatchEx(IDispatchEx *iface)
2186 return CONTAINING_RECORD(iface, HTMLWindow, IDispatchEx_iface);
2189 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
2191 HTMLWindow *This = impl_from_IDispatchEx(iface);
2193 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2196 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
2198 HTMLWindow *This = impl_from_IDispatchEx(iface);
2200 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2203 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
2205 HTMLWindow *This = impl_from_IDispatchEx(iface);
2207 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2210 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
2212 HTMLWindow *This = impl_from_IDispatchEx(iface);
2214 TRACE("(%p)->(%p)\n", This, pctinfo);
2216 return IDispatchEx_GetTypeInfoCount(&This->inner_window->dispex.IDispatchEx_iface, pctinfo);
2219 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
2220 LCID lcid, ITypeInfo **ppTInfo)
2222 HTMLWindow *This = impl_from_IDispatchEx(iface);
2224 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
2226 return IDispatchEx_GetTypeInfo(&This->inner_window->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2229 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
2230 LPOLESTR *rgszNames, UINT cNames,
2231 LCID lcid, DISPID *rgDispId)
2233 HTMLWindow *This = impl_from_IDispatchEx(iface);
2237 WARN("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
2240 for(i=0; i < cNames; i++) {
2241 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
2242 hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
2250 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
2251 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2252 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2254 HTMLWindow *This = impl_from_IDispatchEx(iface);
2256 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
2257 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2259 /* FIXME: Use script dispatch */
2261 return IDispatchEx_Invoke(&This->inner_window->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2262 pDispParams, pVarResult, pExcepInfo, puArgErr);
2265 static global_prop_t *alloc_global_prop(HTMLInnerWindow *This, global_prop_type_t type, BSTR name)
2267 if(This->global_prop_cnt == This->global_prop_size) {
2268 global_prop_t *new_props;
2271 if(This->global_props) {
2272 new_size = This->global_prop_size*2;
2273 new_props = heap_realloc(This->global_props, new_size*sizeof(global_prop_t));
2276 new_props = heap_alloc(new_size*sizeof(global_prop_t));
2280 This->global_props = new_props;
2281 This->global_prop_size = new_size;
2284 This->global_props[This->global_prop_cnt].name = heap_strdupW(name);
2285 if(!This->global_props[This->global_prop_cnt].name)
2288 This->global_props[This->global_prop_cnt].type = type;
2289 return This->global_props + This->global_prop_cnt++;
2292 static inline DWORD prop_to_dispid(HTMLInnerWindow *This, global_prop_t *prop)
2294 return MSHTML_DISPID_CUSTOM_MIN + (prop-This->global_props);
2297 HRESULT search_window_props(HTMLInnerWindow *This, BSTR bstrName, DWORD grfdex, DISPID *pid)
2300 ScriptHost *script_host;
2303 for(i=0; i < This->global_prop_cnt; i++) {
2304 /* FIXME: case sensitivity */
2305 if(!strcmpW(This->global_props[i].name, bstrName)) {
2306 *pid = MSHTML_DISPID_CUSTOM_MIN+i;
2311 if(find_global_prop(This->base.inner_window, bstrName, grfdex, &script_host, &id)) {
2312 global_prop_t *prop;
2314 prop = alloc_global_prop(This, GLOBAL_SCRIPTVAR, bstrName);
2316 return E_OUTOFMEMORY;
2318 prop->script_host = script_host;
2321 *pid = prop_to_dispid(This, prop);
2325 return DISP_E_UNKNOWNNAME;
2328 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
2330 HTMLWindow *This = impl_from_IDispatchEx(iface);
2331 HTMLInnerWindow *window = This->inner_window;
2334 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
2336 hres = search_window_props(window, bstrName, grfdex, pid);
2337 if(hres != DISP_E_UNKNOWNNAME)
2340 hres = IDispatchEx_GetDispID(&window->base.inner_window->dispex.IDispatchEx_iface, bstrName, grfdex, pid);
2341 if(hres != DISP_E_UNKNOWNNAME)
2344 if(window->base.inner_window->doc) {
2345 global_prop_t *prop;
2348 hres = IHTMLDocument3_getElementById(&window->base.inner_window->doc->basedoc.IHTMLDocument3_iface,
2350 if(SUCCEEDED(hres) && elem) {
2351 IHTMLElement_Release(elem);
2353 prop = alloc_global_prop(window, GLOBAL_ELEMENTVAR, bstrName);
2355 return E_OUTOFMEMORY;
2357 *pid = prop_to_dispid(window, prop);
2362 return DISP_E_UNKNOWNNAME;
2365 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
2366 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
2368 HTMLWindow *This = impl_from_IDispatchEx(iface);
2369 HTMLInnerWindow *window = This->inner_window;
2371 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
2373 if(id == DISPID_IHTMLWINDOW2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT)) {
2374 HTMLLocation *location;
2377 TRACE("forwarding to location.href\n");
2379 hres = get_location(window, &location);
2383 hres = IDispatchEx_InvokeEx(&location->dispex.IDispatchEx_iface, DISPID_VALUE, lcid,
2384 wFlags, pdp, pvarRes, pei, pspCaller);
2385 IHTMLLocation_Release(&location->IHTMLLocation_iface);
2389 return IDispatchEx_InvokeEx(&window->dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
2392 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
2394 HTMLWindow *This = impl_from_IDispatchEx(iface);
2396 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
2398 return IDispatchEx_DeleteMemberByName(&This->inner_window->dispex.IDispatchEx_iface, bstrName, grfdex);
2401 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
2403 HTMLWindow *This = impl_from_IDispatchEx(iface);
2405 TRACE("(%p)->(%x)\n", This, id);
2407 return IDispatchEx_DeleteMemberByDispID(&This->inner_window->dispex.IDispatchEx_iface, id);
2410 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
2412 HTMLWindow *This = impl_from_IDispatchEx(iface);
2414 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
2416 return IDispatchEx_GetMemberProperties(&This->inner_window->dispex.IDispatchEx_iface, id, grfdexFetch,
2420 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
2422 HTMLWindow *This = impl_from_IDispatchEx(iface);
2424 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
2426 return IDispatchEx_GetMemberName(&This->inner_window->dispex.IDispatchEx_iface, id, pbstrName);
2429 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
2431 HTMLWindow *This = impl_from_IDispatchEx(iface);
2433 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
2435 return IDispatchEx_GetNextDispID(&This->inner_window->dispex.IDispatchEx_iface, grfdex, id, pid);
2438 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
2440 HTMLWindow *This = impl_from_IDispatchEx(iface);
2442 TRACE("(%p)->(%p)\n", This, ppunk);
2448 static const IDispatchExVtbl WindowDispExVtbl = {
2449 WindowDispEx_QueryInterface,
2450 WindowDispEx_AddRef,
2451 WindowDispEx_Release,
2452 WindowDispEx_GetTypeInfoCount,
2453 WindowDispEx_GetTypeInfo,
2454 WindowDispEx_GetIDsOfNames,
2455 WindowDispEx_Invoke,
2456 WindowDispEx_GetDispID,
2457 WindowDispEx_InvokeEx,
2458 WindowDispEx_DeleteMemberByName,
2459 WindowDispEx_DeleteMemberByDispID,
2460 WindowDispEx_GetMemberProperties,
2461 WindowDispEx_GetMemberName,
2462 WindowDispEx_GetNextDispID,
2463 WindowDispEx_GetNameSpaceParent
2466 static inline HTMLWindow *impl_from_IServiceProvider(IServiceProvider *iface)
2468 return CONTAINING_RECORD(iface, HTMLWindow, IServiceProvider_iface);
2471 static HRESULT WINAPI HTMLWindowSP_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
2473 HTMLWindow *This = impl_from_IServiceProvider(iface);
2474 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2477 static ULONG WINAPI HTMLWindowSP_AddRef(IServiceProvider *iface)
2479 HTMLWindow *This = impl_from_IServiceProvider(iface);
2480 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2483 static ULONG WINAPI HTMLWindowSP_Release(IServiceProvider *iface)
2485 HTMLWindow *This = impl_from_IServiceProvider(iface);
2486 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2489 static HRESULT WINAPI HTMLWindowSP_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv)
2491 HTMLWindow *This = impl_from_IServiceProvider(iface);
2493 if(IsEqualGUID(guidService, &IID_IHTMLWindow2)) {
2494 TRACE("IID_IHTMLWindow2\n");
2495 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2498 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
2500 if(!This->outer_window->doc_obj)
2501 return E_NOINTERFACE;
2503 return IServiceProvider_QueryService(&This->outer_window->doc_obj->basedoc.IServiceProvider_iface,
2504 guidService, riid, ppv);
2507 static const IServiceProviderVtbl ServiceProviderVtbl = {
2508 HTMLWindowSP_QueryInterface,
2509 HTMLWindowSP_AddRef,
2510 HTMLWindowSP_Release,
2511 HTMLWindowSP_QueryService
2514 static inline HTMLInnerWindow *impl_from_DispatchEx(DispatchEx *iface)
2516 return CONTAINING_RECORD(iface, HTMLInnerWindow, dispex);
2519 static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2520 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2522 HTMLInnerWindow *This = impl_from_DispatchEx(dispex);
2523 global_prop_t *prop;
2527 idx = id - MSHTML_DISPID_CUSTOM_MIN;
2528 if(idx >= This->global_prop_cnt)
2529 return DISP_E_MEMBERNOTFOUND;
2531 prop = This->global_props+idx;
2533 switch(prop->type) {
2534 case GLOBAL_SCRIPTVAR: {
2538 disp = get_script_disp(prop->script_host);
2540 return E_UNEXPECTED;
2542 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&iface);
2543 if(SUCCEEDED(hres)) {
2544 TRACE("%s >>>\n", debugstr_w(prop->name));
2545 hres = IDispatchEx_InvokeEx(iface, prop->id, lcid, flags, params, res, ei, caller);
2547 TRACE("%s <<<\n", debugstr_w(prop->name));
2549 WARN("%s <<< %08x\n", debugstr_w(prop->name), hres);
2550 IDispatchEx_Release(iface);
2552 FIXME("No IDispatchEx\n");
2554 IDispatch_Release(disp);
2557 case GLOBAL_ELEMENTVAR:
2559 case DISPATCH_PROPERTYGET: {
2562 hres = IHTMLDocument3_getElementById(&This->base.inner_window->doc->basedoc.IHTMLDocument3_iface,
2568 return DISP_E_MEMBERNOTFOUND;
2570 V_VT(res) = VT_DISPATCH;
2571 V_DISPATCH(res) = (IDispatch*)elem;
2574 case DISPATCH_PROPERTYPUT: {
2577 hres = dispex_get_dynid(&This->dispex, prop->name, &dispex_id);
2581 prop->type = GLOBAL_DISPEXVAR;
2582 prop->id = dispex_id;
2583 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, dispex_id, 0, flags, params, res, ei, caller);
2586 FIXME("Not supported flags: %x\n", flags);
2589 case GLOBAL_DISPEXVAR:
2590 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, prop->id, 0, flags, params, res, ei, caller);
2592 ERR("invalid type %d\n", prop->type);
2593 hres = DISP_E_MEMBERNOTFOUND;
2600 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl = {
2607 static const tid_t HTMLWindow_iface_tids[] = {
2615 static dispex_static_data_t HTMLWindow_dispex = {
2616 &HTMLWindow_dispex_vtbl,
2617 DispHTMLWindow2_tid,
2619 HTMLWindow_iface_tids
2622 static void *alloc_window(size_t size)
2626 window = heap_alloc_zero(size);
2630 window->IHTMLWindow2_iface.lpVtbl = &HTMLWindow2Vtbl;
2631 window->IHTMLWindow3_iface.lpVtbl = &HTMLWindow3Vtbl;
2632 window->IHTMLWindow4_iface.lpVtbl = &HTMLWindow4Vtbl;
2633 window->IHTMLWindow5_iface.lpVtbl = &HTMLWindow5Vtbl;
2634 window->IHTMLWindow6_iface.lpVtbl = &HTMLWindow6Vtbl;
2635 window->IHTMLPrivateWindow_iface.lpVtbl = &HTMLPrivateWindowVtbl;
2636 window->IDispatchEx_iface.lpVtbl = &WindowDispExVtbl;
2637 window->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
2638 window->ITravelLogClient_iface.lpVtbl = &TravelLogClientVtbl;
2644 static HRESULT create_inner_window(HTMLOuterWindow *outer_window, IMoniker *mon, HTMLInnerWindow **ret)
2646 HTMLInnerWindow *window;
2648 window = alloc_window(sizeof(HTMLInnerWindow));
2650 return E_OUTOFMEMORY;
2652 list_init(&window->script_hosts);
2653 list_init(&window->bindings);
2655 window->base.outer_window = outer_window;
2656 window->base.inner_window = window;
2658 init_dispex(&window->dispex, (IUnknown*)&window->base.IHTMLWindow2_iface, &HTMLWindow_dispex);
2660 window->task_magic = get_task_target_magic();
2661 window->current_script_guid = CLSID_JScript;
2664 IMoniker_AddRef(mon);
2672 HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow,
2673 HTMLOuterWindow *parent, HTMLOuterWindow **ret)
2675 HTMLOuterWindow *window;
2678 window = alloc_window(sizeof(HTMLOuterWindow));
2680 return E_OUTOFMEMORY;
2682 window->base.outer_window = window;
2683 window->base.inner_window = NULL;
2685 window->window_ref = heap_alloc(sizeof(windowref_t));
2686 if(!window->window_ref) {
2688 return E_OUTOFMEMORY;
2691 window->doc_obj = doc_obj;
2693 window->window_ref->window = window;
2694 window->window_ref->ref = 1;
2697 nsIDOMWindow_AddRef(nswindow);
2698 window->nswindow = nswindow;
2701 window->scriptmode = parent ? parent->scriptmode : SCRIPTMODE_GECKO;
2702 window->readystate = READYSTATE_UNINITIALIZED;
2704 hres = create_pending_window(window, NULL);
2706 hres = update_window_doc(window->pending_window);
2708 IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
2712 hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0);
2714 IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
2718 window->task_magic = get_task_target_magic();
2720 list_init(&window->children);
2721 list_add_head(&window_list, &window->entry);
2724 IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
2726 window->parent = parent;
2727 list_add_tail(&parent->children, &window->sibling_entry);
2730 TRACE("%p inner_window %p\n", window, window->base.inner_window);
2736 HRESULT create_pending_window(HTMLOuterWindow *outer_window, nsChannelBSC *channelbsc)
2738 HTMLInnerWindow *pending_window;
2741 hres = create_inner_window(outer_window, outer_window->mon /* FIXME */, &pending_window);
2746 IBindStatusCallback_AddRef(&channelbsc->bsc.IBindStatusCallback_iface);
2747 pending_window->bscallback = channelbsc;
2750 if(outer_window->pending_window) {
2751 abort_window_bindings(outer_window->pending_window);
2752 outer_window->pending_window->base.outer_window = NULL;
2753 IHTMLWindow2_Release(&outer_window->pending_window->base.IHTMLWindow2_iface);
2756 outer_window->pending_window = pending_window;
2760 HRESULT update_window_doc(HTMLInnerWindow *window)
2762 HTMLOuterWindow *outer_window = window->base.outer_window;
2763 nsIDOMHTMLDocument *nshtmldoc;
2764 nsIDOMDocument *nsdoc;
2768 assert(!window->doc);
2771 ERR("NULL outer window\n");
2772 return E_UNEXPECTED;
2775 nsres = nsIDOMWindow_GetDocument(outer_window->nswindow, &nsdoc);
2776 if(NS_FAILED(nsres) || !nsdoc) {
2777 ERR("GetDocument failed: %08x\n", nsres);
2781 nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
2782 nsIDOMDocument_Release(nsdoc);
2783 if(NS_FAILED(nsres)) {
2784 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres);
2788 hres = create_doc_from_nsdoc(nshtmldoc, outer_window->doc_obj, window, &window->doc);
2789 nsIDOMHTMLDocument_Release(nshtmldoc);
2793 if(outer_window->doc_obj->usermode == EDITMODE) {
2797 static const PRUnichar onW[] = {'o','n',0};
2799 nsAString_Init(&mode_str, onW);
2800 nsres = nsIDOMHTMLDocument_SetDesignMode(window->doc->nsdoc, &mode_str);
2801 nsAString_Finish(&mode_str);
2802 if(NS_FAILED(nsres))
2803 ERR("SetDesignMode failed: %08x\n", nsres);
2806 if(window != outer_window->pending_window) {
2807 ERR("not current pending window\n");
2811 detach_inner_window(outer_window);
2812 outer_window->base.inner_window = window;
2813 outer_window->pending_window = NULL;
2815 if(outer_window->doc_obj->basedoc.window == outer_window || !outer_window->doc_obj->basedoc.window) {
2816 if(outer_window->doc_obj->basedoc.doc_node)
2817 htmldoc_release(&outer_window->doc_obj->basedoc.doc_node->basedoc);
2818 outer_window->doc_obj->basedoc.doc_node = window->doc;
2819 htmldoc_addref(&window->doc->basedoc);
2825 HTMLOuterWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
2827 HTMLOuterWindow *iter;
2829 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLOuterWindow, entry) {
2830 if(iter->nswindow == nswindow)