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 HRESULT window_set_docnode(HTMLOuterWindow*,HTMLDocumentNode*);
48 static inline BOOL is_outer_window(HTMLWindow *window)
50 return &window->outer_window->base == window;
53 static void release_children(HTMLOuterWindow *This)
55 HTMLOuterWindow *child;
57 while(!list_empty(&This->children)) {
58 child = LIST_ENTRY(list_tail(&This->children), HTMLOuterWindow, sibling_entry);
60 list_remove(&child->sibling_entry);
62 IHTMLWindow2_Release(&child->base.IHTMLWindow2_iface);
66 static HRESULT get_location(HTMLOuterWindow *This, HTMLLocation **ret)
69 IHTMLLocation_AddRef(&This->location->IHTMLLocation_iface);
73 hres = HTMLLocation_Create(This, &This->location);
78 *ret = This->location;
82 void get_top_window(HTMLOuterWindow *window, HTMLOuterWindow **ret)
84 HTMLOuterWindow *iter;
86 for(iter = window; iter->parent; iter = iter->parent);
90 static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
92 if(!window->inner_window->doc) {
93 FIXME("No document\n");
97 return set_event_handler(&window->inner_window->doc->body_event_target, NULL, window->inner_window->doc, eid, var);
100 static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
102 if(!window->inner_window->doc) {
103 FIXME("No document\n");
107 return get_event_handler(&window->inner_window->doc->body_event_target, eid, var);
110 static inline HTMLWindow *impl_from_IHTMLWindow2(IHTMLWindow2 *iface)
112 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow2_iface);
115 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
117 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
121 if(IsEqualGUID(&IID_IUnknown, riid)) {
122 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
123 *ppv = &This->IHTMLWindow2_iface;
124 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
125 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
126 *ppv = &This->IHTMLWindow2_iface;
127 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
128 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
129 *ppv = &This->IDispatchEx_iface;
130 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2, riid)) {
131 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
132 *ppv = &This->IHTMLWindow2_iface;
133 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
134 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
135 *ppv = &This->IHTMLWindow2_iface;
136 }else if(IsEqualGUID(&IID_IHTMLWindow3, riid)) {
137 TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This, ppv);
138 *ppv = &This->IHTMLWindow3_iface;
139 }else if(IsEqualGUID(&IID_IHTMLWindow4, riid)) {
140 TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This, ppv);
141 *ppv = &This->IHTMLWindow4_iface;
142 }else if(IsEqualGUID(&IID_IHTMLWindow5, riid)) {
143 TRACE("(%p)->(IID_IHTMLWindow5 %p)\n", This, ppv);
144 *ppv = &This->IHTMLWindow5_iface;
145 }else if(IsEqualGUID(&IID_IHTMLWindow6, riid)) {
146 TRACE("(%p)->(IID_IHTMLWindow6 %p)\n", This, ppv);
147 *ppv = &This->IHTMLWindow6_iface;
148 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow, riid)) {
149 TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This, ppv);
150 *ppv = &This->IHTMLPrivateWindow_iface;
151 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
152 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
153 *ppv = &This->IServiceProvider_iface;
154 }else if(IsEqualGUID(&IID_ITravelLogClient, riid)) {
155 TRACE("(%p)->(IID_ITravelLogClient %p)\n", This, ppv);
156 *ppv = &This->ITravelLogClient_iface;
157 }else if(dispex_query_interface(&This->inner_window->dispex, riid, ppv)) {
159 return E_NOINTERFACE;
163 IUnknown_AddRef((IUnknown*)*ppv);
167 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
168 return E_NOINTERFACE;
171 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
173 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
174 LONG ref = InterlockedIncrement(&This->ref);
176 TRACE("(%p) ref=%d\n", This, ref);
181 static void release_outer_window(HTMLOuterWindow *This)
183 remove_target_tasks(This->task_magic);
184 set_window_bscallback(This, NULL);
185 set_current_mon(This, NULL);
186 window_set_docnode(This, NULL);
187 release_children(This);
190 IInternetSecurityManager_Release(This->secmgr);
192 if(This->frame_element)
193 This->frame_element->content_window = NULL;
196 This->location->window = NULL;
197 IHTMLLocation_Release(&This->location->IHTMLLocation_iface);
200 This->window_ref->window = NULL;
201 windowref_release(This->window_ref);
204 nsIDOMWindow_Release(This->nswindow);
206 list_remove(&This->entry);
210 static void release_inner_window(HTMLInnerWindow *This)
214 release_script_hosts(This);
216 htmldoc_release(&This->doc->basedoc);
217 release_dispex(&This->dispex);
219 for(i=0; i < This->global_prop_cnt; i++)
220 heap_free(This->global_props[i].name);
221 heap_free(This->global_props);
223 if(This->image_factory) {
224 This->image_factory->window = NULL;
225 IHTMLImageElementFactory_Release(&This->image_factory->IHTMLImageElementFactory_iface);
228 if(This->option_factory) {
229 This->option_factory->window = NULL;
230 IHTMLOptionElementFactory_Release(&This->option_factory->IHTMLOptionElementFactory_iface);
234 IHTMLScreen_Release(This->screen);
236 IOmHistory_Release(This->history);
241 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
243 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
244 LONG ref = InterlockedDecrement(&This->ref);
246 TRACE("(%p) ref=%d\n", This, ref);
249 if(is_outer_window(This))
250 release_outer_window(This->outer_window);
252 release_inner_window(This->inner_window);
258 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
260 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
262 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
265 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
266 LCID lcid, ITypeInfo **ppTInfo)
268 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
270 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
273 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
274 LPOLESTR *rgszNames, UINT cNames,
275 LCID lcid, DISPID *rgDispId)
277 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
279 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
283 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
284 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
285 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
287 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
289 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
290 pDispParams, pVarResult, pExcepInfo, puArgErr);
293 static HRESULT get_frame_by_index(nsIDOMWindowCollection *nsFrames, PRUint32 index, HTMLOuterWindow **ret)
296 nsIDOMWindow *nsWindow;
299 nsres = nsIDOMWindowCollection_GetLength(nsFrames, &length);
300 if(NS_FAILED(nsres)) {
301 FIXME("nsIDOMWindowCollection_GetLength failed: 0x%08x\n", nsres);
306 return DISP_E_MEMBERNOTFOUND;
308 nsres = nsIDOMWindowCollection_Item(nsFrames, index, &nsWindow);
309 if(NS_FAILED(nsres)) {
310 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
314 *ret = nswindow_to_window(nsWindow);
316 nsIDOMWindow_Release(nsWindow);
321 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
323 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
324 nsIDOMWindowCollection *nsFrames;
325 HTMLOuterWindow *window = NULL;
329 TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
331 nsres = nsIDOMWindow_GetFrames(This->outer_window->nswindow, &nsFrames);
332 if(NS_FAILED(nsres)) {
333 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres);
337 switch(V_VT(pvarIndex)) {
339 int index = V_I4(pvarIndex);
340 TRACE("Getting index %d\n", index);
343 hres = get_frame_by_index(nsFrames, index, &window);
347 unsigned int index = V_UINT(pvarIndex);
348 TRACE("Getting index %u\n", index);
349 hres = get_frame_by_index(nsFrames, index, &window);
353 BSTR str = V_BSTR(pvarIndex);
356 TRACE("Getting name %s\n", wine_dbgstr_w(str));
358 nsIDOMWindowCollection_GetLength(nsFrames, &length);
361 for(i = 0; i < length && !window; ++i) {
362 HTMLOuterWindow *cur_window;
363 nsIDOMWindow *nsWindow;
366 nsres = nsIDOMWindowCollection_Item(nsFrames, i, &nsWindow);
367 if(NS_FAILED(nsres)) {
368 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
373 cur_window = nswindow_to_window(nsWindow);
375 nsIDOMWindow_Release(nsWindow);
377 hres = IHTMLElement_get_id(&cur_window->frame_element->element.IHTMLElement_iface, &id);
379 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres);
383 if(!strcmpW(id, str))
394 nsIDOMWindowCollection_Release(nsFrames);
398 return DISP_E_MEMBERNOTFOUND;
400 IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
401 V_VT(pvarResult) = VT_DISPATCH;
402 V_DISPATCH(pvarResult) = (IDispatch*)window;
406 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
408 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
409 nsIDOMWindowCollection *nscollection;
413 TRACE("(%p)->(%p)\n", This, p);
415 nsres = nsIDOMWindow_GetFrames(This->outer_window->nswindow, &nscollection);
416 if(NS_FAILED(nsres)) {
417 ERR("GetFrames failed: %08x\n", nsres);
421 nsres = nsIDOMWindowCollection_GetLength(nscollection, &length);
422 nsIDOMWindowCollection_Release(nscollection);
423 if(NS_FAILED(nsres)) {
424 ERR("GetLength failed: %08x\n", nsres);
432 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
434 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
435 FIXME("(%p)->(%p): semi-stub\n", This, p);
437 /* FIXME: Should return a separate Window object */
438 *p = (IHTMLFramesCollection2*)&This->IHTMLWindow2_iface;
439 HTMLWindow2_AddRef(iface);
443 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
445 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
446 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
450 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
452 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
453 FIXME("(%p)->(%p)\n", This, p);
457 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
459 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
461 WARN("(%p)->(%s)\n", This, debugstr_w(v));
464 * FIXME: Since IE7, setting status is blocked, but still possible in certain circumstances.
465 * Ignoring the call should be enough for us.
470 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
472 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
474 TRACE("(%p)->(%p)\n", This, p);
481 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
482 LONG msec, VARIANT *language, LONG *timerID)
484 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
487 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
489 V_VT(&expr_var) = VT_BSTR;
490 V_BSTR(&expr_var) = expression;
492 return IHTMLWindow3_setTimeout(&This->IHTMLWindow3_iface, &expr_var, msec, language, timerID);
495 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID)
497 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
499 TRACE("(%p)->(%d)\n", This, timerID);
501 return clear_task_timer(&This->inner_window->doc->basedoc, FALSE, timerID);
504 #define MAX_MESSAGE_LEN 2000
506 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
508 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
509 WCHAR title[100], *msg = message;
512 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
514 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, title,
515 sizeof(title)/sizeof(WCHAR))) {
516 WARN("Could not load message box title: %d\n", GetLastError());
520 len = SysStringLen(message);
521 if(len > MAX_MESSAGE_LEN) {
522 msg = heap_alloc((MAX_MESSAGE_LEN+1)*sizeof(WCHAR));
524 return E_OUTOFMEMORY;
525 memcpy(msg, message, MAX_MESSAGE_LEN*sizeof(WCHAR));
526 msg[MAX_MESSAGE_LEN] = 0;
529 MessageBoxW(This->outer_window->doc_obj->hwnd, msg, title, MB_ICONWARNING);
535 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
536 VARIANT_BOOL *confirmed)
538 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
541 TRACE("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
543 if(!confirmed) return E_INVALIDARG;
545 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
546 sizeof(wszTitle)/sizeof(WCHAR))) {
547 WARN("Could not load message box title: %d\n", GetLastError());
548 *confirmed = VARIANT_TRUE;
552 if(MessageBoxW(This->outer_window->doc_obj->hwnd, message, wszTitle,
553 MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
554 *confirmed = VARIANT_TRUE;
555 else *confirmed = VARIANT_FALSE;
567 static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
568 WPARAM wparam, LPARAM lparam)
574 prompt_arg *arg = (prompt_arg*)lparam;
577 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
578 sizeof(wszTitle)/sizeof(WCHAR))) {
579 WARN("Could not load message box title: %d\n", GetLastError());
580 EndDialog(hwnd, wparam);
584 SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
585 SetWindowTextW(hwnd, wszTitle);
586 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_PROMPT), arg->message);
587 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_EDIT), arg->dststr);
593 case MAKEWPARAM(IDCANCEL, BN_CLICKED):
594 EndDialog(hwnd, wparam);
596 case MAKEWPARAM(IDOK, BN_CLICKED):
599 (prompt_arg*)GetWindowLongPtrW(hwnd, DWLP_USER);
600 HWND hwndPrompt = GetDlgItem(hwnd, ID_PROMPT_EDIT);
601 INT len = GetWindowTextLengthW(hwndPrompt);
605 EndDialog(hwnd, wparam);
609 V_VT(arg->textdata) = VT_BSTR;
610 if(!len && !arg->dststr)
611 V_BSTR(arg->textdata) = NULL;
614 V_BSTR(arg->textdata) = SysAllocStringLen(NULL, len);
615 GetWindowTextW(hwndPrompt, V_BSTR(arg->textdata), len+1);
617 EndDialog(hwnd, wparam);
623 EndDialog(hwnd, IDCANCEL);
630 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
631 BSTR dststr, VARIANT *textdata)
633 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
636 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
638 if(textdata) V_VT(textdata) = VT_NULL;
640 arg.message = message;
642 arg.textdata = textdata;
644 DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
645 This->outer_window->doc_obj->hwnd, prompt_dlgproc, (LPARAM)&arg);
649 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
651 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
652 HTMLInnerWindow *window = This->inner_window;
654 TRACE("(%p)->(%p)\n", This, p);
656 if(!window->image_factory) {
659 hres = HTMLImageElementFactory_Create(window, &window->image_factory);
664 *p = &window->image_factory->IHTMLImageElementFactory_iface;
665 IHTMLImageElementFactory_AddRef(*p);
670 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
672 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
673 HTMLLocation *location;
676 TRACE("(%p)->(%p)\n", This, p);
678 hres = get_location(This->outer_window, &location);
682 *p = &location->IHTMLLocation_iface;
686 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
688 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
689 HTMLInnerWindow *window = This->inner_window;
691 TRACE("(%p)->(%p)\n", This, p);
693 if(!window->history) {
696 hres = create_history(&window->history);
701 IOmHistory_AddRef(window->history);
702 *p = window->history;
706 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
708 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
709 FIXME("(%p)->()\n", This);
713 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
715 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
716 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
720 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
722 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
724 FIXME("(%p)->(%p) returning empty\n", This, p);
730 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
732 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
734 TRACE("(%p)->(%p)\n", This, p);
736 *p = OmNavigator_Create();
740 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
742 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
746 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
748 nsAString_InitDepend(&name_str, v);
749 nsres = nsIDOMWindow_SetName(This->outer_window->nswindow, &name_str);
750 nsAString_Finish(&name_str);
752 ERR("SetName failed: %08x\n", nsres);
757 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
759 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
763 TRACE("(%p)->(%p)\n", This, p);
765 nsAString_Init(&name_str, NULL);
766 nsres = nsIDOMWindow_GetName(This->outer_window->nswindow, &name_str);
767 return return_nsstr(nsres, &name_str, p);
770 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
772 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
773 HTMLOuterWindow *window = This->outer_window;
775 TRACE("(%p)->(%p)\n", This, p);
778 return IHTMLWindow2_get_self(&This->IHTMLWindow2_iface, p);
780 *p = &window->parent->base.IHTMLWindow2_iface;
781 IHTMLWindow2_AddRef(*p);
785 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
786 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
788 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
789 HTMLOuterWindow *window = This->outer_window;
790 INewWindowManager *new_window_mgr;
794 TRACE("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
795 debugstr_w(features), replace, pomWindowResult);
800 if(name && *name == '_') {
801 FIXME("Unsupported name %s\n", debugstr_w(name));
805 hres = do_query_service((IUnknown*)window->doc_obj->client, &SID_SNewWindowManager, &IID_INewWindowManager,
806 (void**)&new_window_mgr);
808 FIXME("No INewWindowManager\n");
812 hres = INewWindowManager_EvaluateNewWindow(new_window_mgr, url, name, window->url,
813 features, !!replace, window->doc_obj->has_popup ? 0 : NWMF_FIRST, 0);
814 INewWindowManager_Release(new_window_mgr);
815 window->doc_obj->has_popup = TRUE;
817 *pomWindowResult = NULL;
821 hres = create_relative_uri(window, url, &uri);
825 hres = navigate_new_window(window, uri, name, pomWindowResult);
830 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
832 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
834 TRACE("(%p)->(%p)\n", This, p);
836 /* FIXME: We should return kind of proxy window here. */
837 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
838 *p = &This->IHTMLWindow2_iface;
842 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
844 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
845 HTMLOuterWindow *top;
847 TRACE("(%p)->(%p)\n", This, p);
849 get_top_window(This->outer_window, &top);
850 *p = &top->base.IHTMLWindow2_iface;
851 IHTMLWindow2_AddRef(*p);
856 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
858 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
860 TRACE("(%p)->(%p)\n", This, p);
862 /* FIXME: We should return kind of proxy window here. */
863 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
864 *p = &This->IHTMLWindow2_iface;
868 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
870 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
871 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
875 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
877 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
878 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
882 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
884 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
885 FIXME("(%p)->(%p)\n", This, p);
889 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
891 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
892 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
896 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
898 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
899 FIXME("(%p)->(%p)\n", This, p);
903 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
905 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
907 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
909 return set_window_event(This, EVENTID_LOAD, &v);
912 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
914 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
916 TRACE("(%p)->(%p)\n", This, p);
918 return get_window_event(This, EVENTID_LOAD, p);
921 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
923 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
925 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
927 return set_window_event(This, EVENTID_BEFOREUNLOAD, &v);
930 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
932 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
934 TRACE("(%p)->(%p)\n", This, p);
936 return get_window_event(This, EVENTID_BEFOREUNLOAD, p);
939 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
941 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
942 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
946 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
948 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
949 FIXME("(%p)->(%p)\n", This, p);
953 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
955 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
956 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
960 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
962 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
963 FIXME("(%p)->(%p)\n", This, p);
967 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
969 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
971 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
973 return set_window_event(This, EVENTID_ERROR, &v);
976 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
978 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
980 TRACE("(%p)->(%p)\n", This, p);
982 return get_window_event(This, EVENTID_ERROR, p);
985 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
987 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
989 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
991 return set_window_event(This, EVENTID_RESIZE, &v);
994 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
996 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
998 TRACE("(%p)->(%p)\n", This, p);
1000 return get_window_event(This, EVENTID_RESIZE, p);
1003 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
1005 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1006 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1010 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
1012 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1013 FIXME("(%p)->(%p)\n", This, p);
1017 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
1019 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1021 TRACE("(%p)->(%p)\n", This, p);
1023 if(This->inner_window->doc) {
1024 /* FIXME: We should return a wrapper object here */
1025 *p = &This->inner_window->doc->basedoc.IHTMLDocument2_iface;
1026 IHTMLDocument2_AddRef(*p);
1034 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
1036 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1037 HTMLInnerWindow *window = This->inner_window;
1039 TRACE("(%p)->(%p)\n", This, p);
1042 IHTMLEventObj_AddRef(window->event);
1047 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
1049 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1050 FIXME("(%p)->(%p)\n", This, p);
1054 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
1055 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
1057 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1058 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
1062 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
1065 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1066 FIXME("(%p)->(%s %s %s)\n", This, debugstr_w(helpURL), debugstr_variant(&helpArg), debugstr_w(features));
1070 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
1072 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1073 HTMLInnerWindow *window = This->inner_window;
1075 TRACE("(%p)->(%p)\n", This, p);
1077 if(!window->screen) {
1080 hres = HTMLScreen_Create(&window->screen);
1085 *p = window->screen;
1086 IHTMLScreen_AddRef(window->screen);
1090 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
1092 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1093 HTMLInnerWindow *window = This->inner_window;
1095 TRACE("(%p)->(%p)\n", This, p);
1097 if(!window->option_factory) {
1100 hres = HTMLOptionElementFactory_Create(window, &window->option_factory);
1105 *p = &window->option_factory->IHTMLOptionElementFactory_iface;
1106 IHTMLOptionElementFactory_AddRef(*p);
1111 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
1113 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1115 TRACE("(%p)->()\n", This);
1117 if(This->outer_window->doc_obj)
1118 SetFocus(This->outer_window->doc_obj->hwnd);
1122 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
1124 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1125 FIXME("(%p)->(%p)\n", This, p);
1129 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
1131 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1132 FIXME("(%p)->()\n", This);
1136 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, LONG x, LONG y)
1138 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1139 FIXME("(%p)->(%d %d)\n", This, x, y);
1143 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
1145 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1146 FIXME("(%p)->(%p)\n", This, p);
1150 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
1151 LONG msec, VARIANT *language, LONG *timerID)
1153 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1156 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
1158 V_VT(&expr) = VT_BSTR;
1159 V_BSTR(&expr) = expression;
1160 return IHTMLWindow3_setInterval(&This->IHTMLWindow3_iface, &expr, msec, language, timerID);
1163 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerID)
1165 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1167 TRACE("(%p)->(%d)\n", This, timerID);
1169 return clear_task_timer(&This->inner_window->doc->basedoc, TRUE, timerID);
1172 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
1174 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1175 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1179 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
1181 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1182 FIXME("(%p)->(%p)\n", This, p);
1186 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
1189 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1191 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
1193 return exec_script(This->inner_window, scode, language, pvarRet);
1196 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
1198 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1200 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1202 TRACE("(%p)->(%p)\n", This, String);
1205 return E_INVALIDARG;
1207 *String = SysAllocString(objectW);
1208 return *String ? S_OK : E_OUTOFMEMORY;
1211 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, LONG x, LONG y)
1213 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1216 TRACE("(%p)->(%d %d)\n", This, x, y);
1218 nsres = nsIDOMWindow_ScrollBy(This->outer_window->nswindow, x, y);
1219 if(NS_FAILED(nsres))
1220 ERR("ScrollBy failed: %08x\n", nsres);
1225 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, LONG x, LONG y)
1227 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1230 TRACE("(%p)->(%d %d)\n", This, x, y);
1232 nsres = nsIDOMWindow_ScrollTo(This->outer_window->nswindow, x, y);
1233 if(NS_FAILED(nsres))
1234 ERR("ScrollTo failed: %08x\n", nsres);
1239 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, LONG x, LONG y)
1241 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1242 FIXME("(%p)->(%d %d)\n", This, x, y);
1246 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, LONG x, LONG y)
1248 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1249 FIXME("(%p)->(%d %d)\n", This, x, y);
1253 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, LONG x, LONG y)
1255 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1256 FIXME("(%p)->(%d %d)\n", This, x, y);
1260 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, LONG x, LONG y)
1262 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1263 FIXME("(%p)->(%d %d)\n", This, x, y);
1267 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
1269 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1271 TRACE("(%p)->(%p)\n", This, p);
1275 if(!This->outer_window->doc_obj->hostui)
1278 return IDocHostUIHandler_GetExternal(This->outer_window->doc_obj->hostui, p);
1281 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
1282 HTMLWindow2_QueryInterface,
1284 HTMLWindow2_Release,
1285 HTMLWindow2_GetTypeInfoCount,
1286 HTMLWindow2_GetTypeInfo,
1287 HTMLWindow2_GetIDsOfNames,
1290 HTMLWindow2_get_length,
1291 HTMLWindow2_get_frames,
1292 HTMLWindow2_put_defaultStatus,
1293 HTMLWindow2_get_defaultStatus,
1294 HTMLWindow2_put_status,
1295 HTMLWindow2_get_status,
1296 HTMLWindow2_setTimeout,
1297 HTMLWindow2_clearTimeout,
1299 HTMLWindow2_confirm,
1301 HTMLWindow2_get_Image,
1302 HTMLWindow2_get_location,
1303 HTMLWindow2_get_history,
1305 HTMLWindow2_put_opener,
1306 HTMLWindow2_get_opener,
1307 HTMLWindow2_get_navigator,
1308 HTMLWindow2_put_name,
1309 HTMLWindow2_get_name,
1310 HTMLWindow2_get_parent,
1312 HTMLWindow2_get_self,
1313 HTMLWindow2_get_top,
1314 HTMLWindow2_get_window,
1315 HTMLWindow2_navigate,
1316 HTMLWindow2_put_onfocus,
1317 HTMLWindow2_get_onfocus,
1318 HTMLWindow2_put_onblur,
1319 HTMLWindow2_get_onblur,
1320 HTMLWindow2_put_onload,
1321 HTMLWindow2_get_onload,
1322 HTMLWindow2_put_onbeforeunload,
1323 HTMLWindow2_get_onbeforeunload,
1324 HTMLWindow2_put_onunload,
1325 HTMLWindow2_get_onunload,
1326 HTMLWindow2_put_onhelp,
1327 HTMLWindow2_get_onhelp,
1328 HTMLWindow2_put_onerror,
1329 HTMLWindow2_get_onerror,
1330 HTMLWindow2_put_onresize,
1331 HTMLWindow2_get_onresize,
1332 HTMLWindow2_put_onscroll,
1333 HTMLWindow2_get_onscroll,
1334 HTMLWindow2_get_document,
1335 HTMLWindow2_get_event,
1336 HTMLWindow2_get__newEnum,
1337 HTMLWindow2_showModalDialog,
1338 HTMLWindow2_showHelp,
1339 HTMLWindow2_get_screen,
1340 HTMLWindow2_get_Option,
1342 HTMLWindow2_get_closed,
1345 HTMLWindow2_get_clientInformation,
1346 HTMLWindow2_setInterval,
1347 HTMLWindow2_clearInterval,
1348 HTMLWindow2_put_offscreenBuffering,
1349 HTMLWindow2_get_offscreenBuffering,
1350 HTMLWindow2_execScript,
1351 HTMLWindow2_toString,
1352 HTMLWindow2_scrollBy,
1353 HTMLWindow2_scrollTo,
1356 HTMLWindow2_resizeTo,
1357 HTMLWindow2_resizeBy,
1358 HTMLWindow2_get_external
1361 static inline HTMLWindow *impl_from_IHTMLWindow3(IHTMLWindow3 *iface)
1363 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow3_iface);
1366 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
1368 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1370 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1373 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
1375 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1377 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1380 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
1382 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1384 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1387 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
1389 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1391 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1394 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
1395 LCID lcid, ITypeInfo **ppTInfo)
1397 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1399 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1402 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
1403 LPOLESTR *rgszNames, UINT cNames,
1404 LCID lcid, DISPID *rgDispId)
1406 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1408 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1412 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
1413 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1414 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1416 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1418 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1419 pDispParams, pVarResult, pExcepInfo, puArgErr);
1422 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, LONG *p)
1424 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1425 FIXME("(%p)->(%p)\n", This, p);
1429 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, LONG *p)
1431 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1432 FIXME("(%p)->(%p)\n", This, p);
1436 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
1438 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1439 HTMLInnerWindow *window = This->inner_window;
1441 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
1444 FIXME("No document\n");
1448 return attach_event(&window->doc->body_event_target, NULL, &window->doc->basedoc, event, pDisp, pfResult);
1451 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
1453 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1454 HTMLInnerWindow *window = This->inner_window;
1456 TRACE("(%p)->()\n", This);
1459 FIXME("No document\n");
1463 return detach_event(window->doc->body_event_target, &window->doc->basedoc, event, pDisp);
1466 static HRESULT window_set_timer(HTMLInnerWindow *This, VARIANT *expr, LONG msec, VARIANT *language,
1467 BOOL interval, LONG *timer_id)
1469 IDispatch *disp = NULL;
1471 switch(V_VT(expr)) {
1473 disp = V_DISPATCH(expr);
1474 IDispatch_AddRef(disp);
1478 disp = script_parse_event(This->base.inner_window, V_BSTR(expr));
1482 FIXME("unimplemented expr %s\n", debugstr_variant(expr));
1489 *timer_id = set_task_timer(&This->doc->basedoc, msec, interval, disp);
1490 IDispatch_Release(disp);
1495 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1496 VARIANT *language, LONG *timerID)
1498 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1500 TRACE("(%p)->(%s %d %s %p)\n", This, debugstr_variant(expression), msec, debugstr_variant(language), timerID);
1502 return window_set_timer(This->inner_window, expression, msec, language, FALSE, timerID);
1505 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1506 VARIANT *language, LONG *timerID)
1508 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1510 TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID);
1512 return window_set_timer(This->inner_window, expression, msec, language, TRUE, timerID);
1515 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
1517 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1518 FIXME("(%p)\n", This);
1522 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
1524 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1525 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1529 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
1531 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1532 FIXME("(%p)->(%p)\n", This, p);
1536 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
1538 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1539 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1543 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
1545 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1546 FIXME("(%p)->(%p)\n", This, p);
1550 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
1552 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1553 FIXME("(%p)->(%p)\n", This, p);
1557 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
1558 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
1560 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1561 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
1565 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
1566 HTMLWindow3_QueryInterface,
1568 HTMLWindow3_Release,
1569 HTMLWindow3_GetTypeInfoCount,
1570 HTMLWindow3_GetTypeInfo,
1571 HTMLWindow3_GetIDsOfNames,
1573 HTMLWindow3_get_screenLeft,
1574 HTMLWindow3_get_screenTop,
1575 HTMLWindow3_attachEvent,
1576 HTMLWindow3_detachEvent,
1577 HTMLWindow3_setTimeout,
1578 HTMLWindow3_setInterval,
1580 HTMLWindow3_put_onbeforeprint,
1581 HTMLWindow3_get_onbeforeprint,
1582 HTMLWindow3_put_onafterprint,
1583 HTMLWindow3_get_onafterprint,
1584 HTMLWindow3_get_clipboardData,
1585 HTMLWindow3_showModelessDialog
1588 static inline HTMLWindow *impl_from_IHTMLWindow4(IHTMLWindow4 *iface)
1590 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow4_iface);
1593 static HRESULT WINAPI HTMLWindow4_QueryInterface(IHTMLWindow4 *iface, REFIID riid, void **ppv)
1595 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1597 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1600 static ULONG WINAPI HTMLWindow4_AddRef(IHTMLWindow4 *iface)
1602 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1604 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1607 static ULONG WINAPI HTMLWindow4_Release(IHTMLWindow4 *iface)
1609 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1611 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1614 static HRESULT WINAPI HTMLWindow4_GetTypeInfoCount(IHTMLWindow4 *iface, UINT *pctinfo)
1616 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1618 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1621 static HRESULT WINAPI HTMLWindow4_GetTypeInfo(IHTMLWindow4 *iface, UINT iTInfo,
1622 LCID lcid, ITypeInfo **ppTInfo)
1624 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1626 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1629 static HRESULT WINAPI HTMLWindow4_GetIDsOfNames(IHTMLWindow4 *iface, REFIID riid,
1630 LPOLESTR *rgszNames, UINT cNames,
1631 LCID lcid, DISPID *rgDispId)
1633 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1635 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1639 static HRESULT WINAPI HTMLWindow4_Invoke(IHTMLWindow4 *iface, DISPID dispIdMember,
1640 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1641 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1643 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1645 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1646 pDispParams, pVarResult, pExcepInfo, puArgErr);
1649 static HRESULT WINAPI HTMLWindow4_createPopup(IHTMLWindow4 *iface, VARIANT *varArgIn,
1650 IDispatch **ppPopup)
1652 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1653 FIXME("(%p)->(%p %p)\n", This, varArgIn, ppPopup);
1657 static HRESULT WINAPI HTMLWindow4_get_frameElement(IHTMLWindow4 *iface, IHTMLFrameBase **p)
1659 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1660 TRACE("(%p)->(%p)\n", This, p);
1662 if(This->outer_window->frame_element) {
1663 *p = &This->outer_window->frame_element->IHTMLFrameBase_iface;
1664 IHTMLFrameBase_AddRef(*p);
1671 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl = {
1672 HTMLWindow4_QueryInterface,
1674 HTMLWindow4_Release,
1675 HTMLWindow4_GetTypeInfoCount,
1676 HTMLWindow4_GetTypeInfo,
1677 HTMLWindow4_GetIDsOfNames,
1679 HTMLWindow4_createPopup,
1680 HTMLWindow4_get_frameElement
1683 static inline HTMLWindow *impl_from_IHTMLWindow5(IHTMLWindow5 *iface)
1685 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow5_iface);
1688 static HRESULT WINAPI HTMLWindow5_QueryInterface(IHTMLWindow5 *iface, REFIID riid, void **ppv)
1690 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1692 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1695 static ULONG WINAPI HTMLWindow5_AddRef(IHTMLWindow5 *iface)
1697 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1699 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1702 static ULONG WINAPI HTMLWindow5_Release(IHTMLWindow5 *iface)
1704 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1706 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1709 static HRESULT WINAPI HTMLWindow5_GetTypeInfoCount(IHTMLWindow5 *iface, UINT *pctinfo)
1711 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1713 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1716 static HRESULT WINAPI HTMLWindow5_GetTypeInfo(IHTMLWindow5 *iface, UINT iTInfo,
1717 LCID lcid, ITypeInfo **ppTInfo)
1719 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1721 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1724 static HRESULT WINAPI HTMLWindow5_GetIDsOfNames(IHTMLWindow5 *iface, REFIID riid,
1725 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1727 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1729 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1733 static HRESULT WINAPI HTMLWindow5_Invoke(IHTMLWindow5 *iface, DISPID dispIdMember,
1734 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1735 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1737 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1739 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1740 pDispParams, pVarResult, pExcepInfo, puArgErr);
1743 static HRESULT WINAPI HTMLWindow5_put_XMLHttpRequest(IHTMLWindow5 *iface, VARIANT v)
1745 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1746 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1750 static HRESULT WINAPI HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5 *iface, VARIANT *p)
1752 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1753 FIXME("(%p)->(%p)\n", This, p);
1757 static const IHTMLWindow5Vtbl HTMLWindow5Vtbl = {
1758 HTMLWindow5_QueryInterface,
1760 HTMLWindow5_Release,
1761 HTMLWindow5_GetTypeInfoCount,
1762 HTMLWindow5_GetTypeInfo,
1763 HTMLWindow5_GetIDsOfNames,
1765 HTMLWindow5_put_XMLHttpRequest,
1766 HTMLWindow5_get_XMLHttpRequest
1769 static inline HTMLWindow *impl_from_IHTMLWindow6(IHTMLWindow6 *iface)
1771 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow6_iface);
1774 static HRESULT WINAPI HTMLWindow6_QueryInterface(IHTMLWindow6 *iface, REFIID riid, void **ppv)
1776 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1778 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1781 static ULONG WINAPI HTMLWindow6_AddRef(IHTMLWindow6 *iface)
1783 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1785 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1788 static ULONG WINAPI HTMLWindow6_Release(IHTMLWindow6 *iface)
1790 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1792 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1795 static HRESULT WINAPI HTMLWindow6_GetTypeInfoCount(IHTMLWindow6 *iface, UINT *pctinfo)
1797 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1799 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1802 static HRESULT WINAPI HTMLWindow6_GetTypeInfo(IHTMLWindow6 *iface, UINT iTInfo,
1803 LCID lcid, ITypeInfo **ppTInfo)
1805 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1807 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1810 static HRESULT WINAPI HTMLWindow6_GetIDsOfNames(IHTMLWindow6 *iface, REFIID riid,
1811 LPOLESTR *rgszNames, UINT cNames,
1812 LCID lcid, DISPID *rgDispId)
1814 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1816 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1820 static HRESULT WINAPI HTMLWindow6_Invoke(IHTMLWindow6 *iface, DISPID dispIdMember,
1821 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1822 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1824 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1826 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1827 pDispParams, pVarResult, pExcepInfo, puArgErr);
1830 static HRESULT WINAPI HTMLWindow6_put_XDomainRequest(IHTMLWindow6 *iface, VARIANT v)
1832 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1833 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1837 static HRESULT WINAPI HTMLWindow6_get_XDomainRequest(IHTMLWindow6 *iface, VARIANT *p)
1839 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1840 FIXME("(%p)->(%p)\n", This, p);
1844 static HRESULT WINAPI HTMLWindow6_get_sessionStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1846 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1847 FIXME("(%p)->(%p)\n", This, p);
1851 static HRESULT WINAPI HTMLWindow6_get_localStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1853 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1854 FIXME("(%p)->(%p)\n", This, p);
1858 static HRESULT WINAPI HTMLWindow6_put_onhashchange(IHTMLWindow6 *iface, VARIANT v)
1860 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1861 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1865 static HRESULT WINAPI HTMLWindow6_get_onhashchange(IHTMLWindow6 *iface, VARIANT *p)
1867 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1868 FIXME("(%p)->(%p)\n", This, p);
1872 static HRESULT WINAPI HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6 *iface, LONG *p)
1874 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1875 FIXME("(%p)->(%p)\n", This, p);
1879 static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VARIANT targetOrigin)
1881 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1882 FIXME("(%p)->(%s %s)\n", This, debugstr_w(msg), debugstr_variant(&targetOrigin));
1886 static HRESULT WINAPI HTMLWindow6_toStaticHTML(IHTMLWindow6 *iface, BSTR bstrHTML, BSTR *pbstrStaticHTML)
1888 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1889 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrHTML), pbstrStaticHTML);
1893 static HRESULT WINAPI HTMLWindow6_put_onmessage(IHTMLWindow6 *iface, VARIANT v)
1895 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1896 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1900 static HRESULT WINAPI HTMLWindow6_get_onmessage(IHTMLWindow6 *iface, VARIANT *p)
1902 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1903 FIXME("(%p)->(%p)\n", This, p);
1907 static HRESULT WINAPI HTMLWindow6_msWriteProfilerMark(IHTMLWindow6 *iface, BSTR bstrProfilerMark)
1909 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1910 FIXME("(%p)->(%s)\n", This, debugstr_w(bstrProfilerMark));
1914 static const IHTMLWindow6Vtbl HTMLWindow6Vtbl = {
1915 HTMLWindow6_QueryInterface,
1917 HTMLWindow6_Release,
1918 HTMLWindow6_GetTypeInfoCount,
1919 HTMLWindow6_GetTypeInfo,
1920 HTMLWindow6_GetIDsOfNames,
1922 HTMLWindow6_put_XDomainRequest,
1923 HTMLWindow6_get_XDomainRequest,
1924 HTMLWindow6_get_sessionStorage,
1925 HTMLWindow6_get_localStorage,
1926 HTMLWindow6_put_onhashchange,
1927 HTMLWindow6_get_onhashchange,
1928 HTMLWindow6_get_maxConnectionsPerServer,
1929 HTMLWindow6_postMessage,
1930 HTMLWindow6_toStaticHTML,
1931 HTMLWindow6_put_onmessage,
1932 HTMLWindow6_get_onmessage,
1933 HTMLWindow6_msWriteProfilerMark
1936 static inline HTMLWindow *impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow *iface)
1938 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLPrivateWindow_iface);
1941 static HRESULT WINAPI HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow *iface, REFIID riid, void **ppv)
1943 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1945 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1948 static ULONG WINAPI HTMLPrivateWindow_AddRef(IHTMLPrivateWindow *iface)
1950 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1952 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1955 static ULONG WINAPI HTMLPrivateWindow_Release(IHTMLPrivateWindow *iface)
1957 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1959 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1962 static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface, BSTR url, BSTR arg2, BSTR arg3,
1963 BSTR arg4, VARIANT *post_data_var, VARIANT *headers_var, ULONG flags)
1965 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1966 HTMLOuterWindow *window = This->outer_window;
1967 OLECHAR *translated_url = NULL;
1968 DWORD post_data_size = 0;
1969 BYTE *post_data = NULL;
1970 WCHAR *headers = NULL;
1974 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This, debugstr_w(url), debugstr_w(arg2), debugstr_w(arg3), debugstr_w(arg4),
1975 debugstr_variant(post_data_var), debugstr_variant(headers_var), flags);
1977 if(window->doc_obj->hostui) {
1978 hres = IDocHostUIHandler_TranslateUrl(window->doc_obj->hostui, 0, url, &translated_url);
1980 translated_url = NULL;
1983 hres = CreateUri(translated_url ? translated_url : url, 0, 0, &uri);
1984 CoTaskMemFree(translated_url);
1989 if(V_VT(post_data_var) == (VT_ARRAY|VT_UI1)) {
1990 SafeArrayAccessData(V_ARRAY(post_data_var), (void**)&post_data);
1991 post_data_size = V_ARRAY(post_data_var)->rgsabound[0].cElements;
1995 if(headers_var && V_VT(headers_var) != VT_EMPTY && V_VT(headers_var) != VT_ERROR) {
1996 if(V_VT(headers_var) != VT_BSTR)
1997 return E_INVALIDARG;
1999 headers = V_BSTR(headers_var);
2002 hres = super_navigate(window, uri, headers, post_data, post_data_size);
2005 SafeArrayUnaccessData(V_ARRAY(post_data_var));
2010 static HRESULT WINAPI HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow *iface, BSTR *url)
2012 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2013 FIXME("(%p)->(%p)\n", This, url);
2017 static HRESULT WINAPI HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow *iface, IOleCommandTarget *cmdtrg)
2019 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2020 FIXME("(%p)->(%p)\n", This, cmdtrg);
2024 static HRESULT WINAPI HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow *iface, int arg)
2026 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2027 FIXME("(%p)->(%x)\n", This, arg);
2031 static HRESULT WINAPI HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow *iface, LPCWSTR name, IHTMLWindow2 **ret)
2033 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2034 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), ret);
2038 static HRESULT WINAPI HTMLPrivateWindow_GetAddressBarUrl(IHTMLPrivateWindow *iface, BSTR *url)
2040 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2041 TRACE("(%p)->(%p)\n", This, url);
2044 return E_INVALIDARG;
2046 *url = SysAllocString(This->outer_window->url);
2050 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl = {
2051 HTMLPrivateWindow_QueryInterface,
2052 HTMLPrivateWindow_AddRef,
2053 HTMLPrivateWindow_Release,
2054 HTMLPrivateWindow_SuperNavigate,
2055 HTMLPrivateWindow_GetPendingUrl,
2056 HTMLPrivateWindow_SetPICSTarget,
2057 HTMLPrivateWindow_PICSComplete,
2058 HTMLPrivateWindow_FindWindowByName,
2059 HTMLPrivateWindow_GetAddressBarUrl
2062 static inline HTMLWindow *impl_from_ITravelLogClient(ITravelLogClient *iface)
2064 return CONTAINING_RECORD(iface, HTMLWindow, ITravelLogClient_iface);
2067 static HRESULT WINAPI TravelLogClient_QueryInterface(ITravelLogClient *iface, REFIID riid, void **ppv)
2069 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2071 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2074 static ULONG WINAPI TravelLogClient_AddRef(ITravelLogClient *iface)
2076 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2078 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2081 static ULONG WINAPI TravelLogClient_Release(ITravelLogClient *iface)
2083 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2085 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2088 static HRESULT WINAPI TravelLogClient_FindWindowByIndex(ITravelLogClient *iface, DWORD dwID, IUnknown **ppunk)
2090 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2092 FIXME("(%p)->(%d %p) semi-stub\n", This, dwID, ppunk);
2098 static HRESULT WINAPI TravelLogClient_GetWindowData(ITravelLogClient *iface, IStream *pStream, LPWINDOWDATA pWinData)
2100 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2101 FIXME("(%p)->(%p %p)\n", This, pStream, pWinData);
2105 static HRESULT WINAPI TravelLogClient_LoadHistoryPosition(ITravelLogClient *iface, LPWSTR pszUrlLocation, DWORD dwPosition)
2107 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2108 FIXME("(%p)->(%s %d)\n", This, debugstr_w(pszUrlLocation), dwPosition);
2112 static const ITravelLogClientVtbl TravelLogClientVtbl = {
2113 TravelLogClient_QueryInterface,
2114 TravelLogClient_AddRef,
2115 TravelLogClient_Release,
2116 TravelLogClient_FindWindowByIndex,
2117 TravelLogClient_GetWindowData,
2118 TravelLogClient_LoadHistoryPosition
2121 static inline HTMLWindow *impl_from_IDispatchEx(IDispatchEx *iface)
2123 return CONTAINING_RECORD(iface, HTMLWindow, IDispatchEx_iface);
2126 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
2128 HTMLWindow *This = impl_from_IDispatchEx(iface);
2130 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2133 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
2135 HTMLWindow *This = impl_from_IDispatchEx(iface);
2137 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2140 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
2142 HTMLWindow *This = impl_from_IDispatchEx(iface);
2144 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2147 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
2149 HTMLWindow *This = impl_from_IDispatchEx(iface);
2151 TRACE("(%p)->(%p)\n", This, pctinfo);
2153 return IDispatchEx_GetTypeInfoCount(&This->inner_window->dispex.IDispatchEx_iface, pctinfo);
2156 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
2157 LCID lcid, ITypeInfo **ppTInfo)
2159 HTMLWindow *This = impl_from_IDispatchEx(iface);
2161 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
2163 return IDispatchEx_GetTypeInfo(&This->inner_window->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2166 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
2167 LPOLESTR *rgszNames, UINT cNames,
2168 LCID lcid, DISPID *rgDispId)
2170 HTMLWindow *This = impl_from_IDispatchEx(iface);
2174 WARN("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
2177 for(i=0; i < cNames; i++) {
2178 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
2179 hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
2187 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
2188 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2189 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2191 HTMLWindow *This = impl_from_IDispatchEx(iface);
2193 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
2194 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2196 /* FIXME: Use script dispatch */
2198 return IDispatchEx_Invoke(&This->inner_window->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2199 pDispParams, pVarResult, pExcepInfo, puArgErr);
2202 static global_prop_t *alloc_global_prop(HTMLInnerWindow *This, global_prop_type_t type, BSTR name)
2204 if(This->global_prop_cnt == This->global_prop_size) {
2205 global_prop_t *new_props;
2208 if(This->global_props) {
2209 new_size = This->global_prop_size*2;
2210 new_props = heap_realloc(This->global_props, new_size*sizeof(global_prop_t));
2213 new_props = heap_alloc(new_size*sizeof(global_prop_t));
2217 This->global_props = new_props;
2218 This->global_prop_size = new_size;
2221 This->global_props[This->global_prop_cnt].name = heap_strdupW(name);
2222 if(!This->global_props[This->global_prop_cnt].name)
2225 This->global_props[This->global_prop_cnt].type = type;
2226 return This->global_props + This->global_prop_cnt++;
2229 static inline DWORD prop_to_dispid(HTMLInnerWindow *This, global_prop_t *prop)
2231 return MSHTML_DISPID_CUSTOM_MIN + (prop-This->global_props);
2234 HRESULT search_window_props(HTMLInnerWindow *This, BSTR bstrName, DWORD grfdex, DISPID *pid)
2237 ScriptHost *script_host;
2240 for(i=0; i < This->global_prop_cnt; i++) {
2241 /* FIXME: case sensitivity */
2242 if(!strcmpW(This->global_props[i].name, bstrName)) {
2243 *pid = MSHTML_DISPID_CUSTOM_MIN+i;
2248 if(find_global_prop(This->base.inner_window, bstrName, grfdex, &script_host, &id)) {
2249 global_prop_t *prop;
2251 prop = alloc_global_prop(This, GLOBAL_SCRIPTVAR, bstrName);
2253 return E_OUTOFMEMORY;
2255 prop->script_host = script_host;
2258 *pid = prop_to_dispid(This, prop);
2262 return DISP_E_UNKNOWNNAME;
2265 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
2267 HTMLWindow *This = impl_from_IDispatchEx(iface);
2268 HTMLInnerWindow *window = This->inner_window;
2271 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
2273 hres = search_window_props(window, bstrName, grfdex, pid);
2274 if(hres != DISP_E_UNKNOWNNAME)
2277 hres = IDispatchEx_GetDispID(&window->base.inner_window->dispex.IDispatchEx_iface, bstrName, grfdex, pid);
2278 if(hres != DISP_E_UNKNOWNNAME)
2281 if(window->base.inner_window->doc) {
2282 global_prop_t *prop;
2285 hres = IHTMLDocument3_getElementById(&window->base.inner_window->doc->basedoc.IHTMLDocument3_iface,
2287 if(SUCCEEDED(hres) && elem) {
2288 IHTMLElement_Release(elem);
2290 prop = alloc_global_prop(window, GLOBAL_ELEMENTVAR, bstrName);
2292 return E_OUTOFMEMORY;
2294 *pid = prop_to_dispid(window, prop);
2299 return DISP_E_UNKNOWNNAME;
2302 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
2303 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
2305 HTMLWindow *This = impl_from_IDispatchEx(iface);
2306 HTMLOuterWindow *window = This->outer_window;
2308 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
2310 if(id == DISPID_IHTMLWINDOW2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT)) {
2311 HTMLLocation *location;
2314 TRACE("forwarding to location.href\n");
2316 hres = get_location(window, &location);
2320 hres = IDispatchEx_InvokeEx(&location->dispex.IDispatchEx_iface, DISPID_VALUE, lcid,
2321 wFlags, pdp, pvarRes, pei, pspCaller);
2322 IHTMLLocation_Release(&location->IHTMLLocation_iface);
2326 return IDispatchEx_InvokeEx(&window->base.inner_window->dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes,
2330 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
2332 HTMLWindow *This = impl_from_IDispatchEx(iface);
2334 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
2336 return IDispatchEx_DeleteMemberByName(&This->inner_window->dispex.IDispatchEx_iface, bstrName, grfdex);
2339 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
2341 HTMLWindow *This = impl_from_IDispatchEx(iface);
2343 TRACE("(%p)->(%x)\n", This, id);
2345 return IDispatchEx_DeleteMemberByDispID(&This->inner_window->dispex.IDispatchEx_iface, id);
2348 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
2350 HTMLWindow *This = impl_from_IDispatchEx(iface);
2352 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
2354 return IDispatchEx_GetMemberProperties(&This->inner_window->dispex.IDispatchEx_iface, id, grfdexFetch,
2358 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
2360 HTMLWindow *This = impl_from_IDispatchEx(iface);
2362 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
2364 return IDispatchEx_GetMemberName(&This->inner_window->dispex.IDispatchEx_iface, id, pbstrName);
2367 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
2369 HTMLWindow *This = impl_from_IDispatchEx(iface);
2371 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
2373 return IDispatchEx_GetNextDispID(&This->inner_window->dispex.IDispatchEx_iface, grfdex, id, pid);
2376 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
2378 HTMLWindow *This = impl_from_IDispatchEx(iface);
2380 TRACE("(%p)->(%p)\n", This, ppunk);
2386 static const IDispatchExVtbl WindowDispExVtbl = {
2387 WindowDispEx_QueryInterface,
2388 WindowDispEx_AddRef,
2389 WindowDispEx_Release,
2390 WindowDispEx_GetTypeInfoCount,
2391 WindowDispEx_GetTypeInfo,
2392 WindowDispEx_GetIDsOfNames,
2393 WindowDispEx_Invoke,
2394 WindowDispEx_GetDispID,
2395 WindowDispEx_InvokeEx,
2396 WindowDispEx_DeleteMemberByName,
2397 WindowDispEx_DeleteMemberByDispID,
2398 WindowDispEx_GetMemberProperties,
2399 WindowDispEx_GetMemberName,
2400 WindowDispEx_GetNextDispID,
2401 WindowDispEx_GetNameSpaceParent
2404 static inline HTMLWindow *impl_from_IServiceProvider(IServiceProvider *iface)
2406 return CONTAINING_RECORD(iface, HTMLWindow, IServiceProvider_iface);
2409 static HRESULT WINAPI HTMLWindowSP_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
2411 HTMLWindow *This = impl_from_IServiceProvider(iface);
2412 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2415 static ULONG WINAPI HTMLWindowSP_AddRef(IServiceProvider *iface)
2417 HTMLWindow *This = impl_from_IServiceProvider(iface);
2418 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2421 static ULONG WINAPI HTMLWindowSP_Release(IServiceProvider *iface)
2423 HTMLWindow *This = impl_from_IServiceProvider(iface);
2424 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2427 static HRESULT WINAPI HTMLWindowSP_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv)
2429 HTMLWindow *This = impl_from_IServiceProvider(iface);
2431 if(IsEqualGUID(guidService, &IID_IHTMLWindow2)) {
2432 TRACE("IID_IHTMLWindow2\n");
2433 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2436 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
2438 if(!This->outer_window->doc_obj)
2439 return E_NOINTERFACE;
2441 return IServiceProvider_QueryService(&This->outer_window->doc_obj->basedoc.IServiceProvider_iface,
2442 guidService, riid, ppv);
2445 static const IServiceProviderVtbl ServiceProviderVtbl = {
2446 HTMLWindowSP_QueryInterface,
2447 HTMLWindowSP_AddRef,
2448 HTMLWindowSP_Release,
2449 HTMLWindowSP_QueryService
2452 static inline HTMLInnerWindow *impl_from_DispatchEx(DispatchEx *iface)
2454 return CONTAINING_RECORD(iface, HTMLInnerWindow, dispex);
2457 static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2458 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2460 HTMLInnerWindow *This = impl_from_DispatchEx(dispex);
2461 global_prop_t *prop;
2465 idx = id - MSHTML_DISPID_CUSTOM_MIN;
2466 if(idx >= This->global_prop_cnt)
2467 return DISP_E_MEMBERNOTFOUND;
2469 prop = This->global_props+idx;
2471 switch(prop->type) {
2472 case GLOBAL_SCRIPTVAR: {
2476 disp = get_script_disp(prop->script_host);
2478 return E_UNEXPECTED;
2480 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&iface);
2481 if(SUCCEEDED(hres)) {
2482 TRACE("%s >>>\n", debugstr_w(prop->name));
2483 hres = IDispatchEx_InvokeEx(iface, prop->id, lcid, flags, params, res, ei, caller);
2485 TRACE("%s <<<\n", debugstr_w(prop->name));
2487 WARN("%s <<< %08x\n", debugstr_w(prop->name), hres);
2488 IDispatchEx_Release(iface);
2490 FIXME("No IDispatchEx\n");
2492 IDispatch_Release(disp);
2495 case GLOBAL_ELEMENTVAR:
2497 case DISPATCH_PROPERTYGET: {
2500 hres = IHTMLDocument3_getElementById(&This->base.inner_window->doc->basedoc.IHTMLDocument3_iface,
2506 return DISP_E_MEMBERNOTFOUND;
2508 V_VT(res) = VT_DISPATCH;
2509 V_DISPATCH(res) = (IDispatch*)elem;
2512 case DISPATCH_PROPERTYPUT: {
2515 hres = dispex_get_dynid(&This->dispex, prop->name, &dispex_id);
2519 prop->type = GLOBAL_DISPEXVAR;
2520 prop->id = dispex_id;
2521 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, dispex_id, 0, flags, params, res, ei, caller);
2524 FIXME("Not supported flags: %x\n", flags);
2527 case GLOBAL_DISPEXVAR:
2528 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, prop->id, 0, flags, params, res, ei, caller);
2530 ERR("invalid type %d\n", prop->type);
2531 hres = DISP_E_MEMBERNOTFOUND;
2538 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl = {
2545 static const tid_t HTMLWindow_iface_tids[] = {
2553 static dispex_static_data_t HTMLWindow_dispex = {
2554 &HTMLWindow_dispex_vtbl,
2555 DispHTMLWindow2_tid,
2557 HTMLWindow_iface_tids
2560 static void *alloc_window(size_t size)
2564 window = heap_alloc_zero(size);
2568 window->IHTMLWindow2_iface.lpVtbl = &HTMLWindow2Vtbl;
2569 window->IHTMLWindow3_iface.lpVtbl = &HTMLWindow3Vtbl;
2570 window->IHTMLWindow4_iface.lpVtbl = &HTMLWindow4Vtbl;
2571 window->IHTMLWindow5_iface.lpVtbl = &HTMLWindow5Vtbl;
2572 window->IHTMLWindow6_iface.lpVtbl = &HTMLWindow6Vtbl;
2573 window->IHTMLPrivateWindow_iface.lpVtbl = &HTMLPrivateWindowVtbl;
2574 window->IDispatchEx_iface.lpVtbl = &WindowDispExVtbl;
2575 window->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
2576 window->ITravelLogClient_iface.lpVtbl = &TravelLogClientVtbl;
2582 static HRESULT create_inner_window(HTMLOuterWindow *outer_window, HTMLDocumentNode *doc_node, HTMLInnerWindow **ret)
2584 HTMLInnerWindow *window;
2586 window = alloc_window(sizeof(HTMLInnerWindow));
2588 return E_OUTOFMEMORY;
2590 list_init(&window->script_hosts);
2592 window->base.outer_window = outer_window;
2593 window->base.inner_window = window;
2595 htmldoc_addref(&doc_node->basedoc);
2596 window->doc = doc_node;
2598 init_dispex(&window->dispex, (IUnknown*)&window->base.IHTMLWindow2_iface, &HTMLWindow_dispex);
2604 HRESULT HTMLOuterWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow,
2605 HTMLOuterWindow *parent, HTMLOuterWindow **ret)
2607 HTMLOuterWindow *window;
2610 window = alloc_window(sizeof(HTMLOuterWindow));
2612 return E_OUTOFMEMORY;
2614 window->base.outer_window = window;
2615 window->base.inner_window = NULL;
2617 window->window_ref = heap_alloc(sizeof(windowref_t));
2618 if(!window->window_ref) {
2620 return E_OUTOFMEMORY;
2623 window->doc_obj = doc_obj;
2625 window->window_ref->window = window;
2626 window->window_ref->ref = 1;
2629 nsIDOMWindow_AddRef(nswindow);
2630 window->nswindow = nswindow;
2633 window->scriptmode = parent ? parent->scriptmode : SCRIPTMODE_GECKO;
2634 window->readystate = READYSTATE_UNINITIALIZED;
2636 hres = update_window_doc(window);
2638 IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
2642 hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0);
2644 IHTMLWindow2_Release(&window->base.IHTMLWindow2_iface);
2648 window->task_magic = get_task_target_magic();
2650 list_init(&window->children);
2651 list_add_head(&window_list, &window->entry);
2654 IHTMLWindow2_AddRef(&window->base.IHTMLWindow2_iface);
2656 window->parent = parent;
2657 list_add_tail(&parent->children, &window->sibling_entry);
2664 static HRESULT window_set_docnode(HTMLOuterWindow *window, HTMLDocumentNode *doc_node)
2666 HTMLInnerWindow *inner_window;
2669 if(window->base.inner_window) {
2670 if(window->doc_obj && window == window->doc_obj->basedoc.window)
2671 window->base.inner_window->doc->basedoc.cp_container.forward_container = NULL;
2672 detach_events(window->base.inner_window->doc);
2673 abort_document_bindings(window->base.inner_window->doc);
2674 release_script_hosts(window->base.inner_window);
2678 hres = create_inner_window(window, doc_node, &inner_window);
2682 inner_window = NULL;
2685 if(window->base.inner_window) {
2686 window->base.inner_window->doc->basedoc.window = NULL;
2687 window->base.inner_window->base.outer_window = NULL;
2688 IHTMLWindow2_Release(&window->base.inner_window->base.IHTMLWindow2_iface);
2690 window->base.inner_window = inner_window;
2695 if(window->doc_obj && window->doc_obj->basedoc.window == window) {
2696 if(window->doc_obj->basedoc.doc_node)
2697 htmldoc_release(&window->doc_obj->basedoc.doc_node->basedoc);
2698 window->doc_obj->basedoc.doc_node = doc_node;
2700 htmldoc_addref(&doc_node->basedoc);
2703 if(doc_node && window->doc_obj && window->doc_obj->usermode == EDITMODE) {
2707 static const PRUnichar onW[] = {'o','n',0};
2709 nsAString_Init(&mode_str, onW);
2710 nsres = nsIDOMHTMLDocument_SetDesignMode(doc_node->nsdoc, &mode_str);
2711 nsAString_Finish(&mode_str);
2712 if(NS_FAILED(nsres))
2713 ERR("SetDesignMode failed: %08x\n", nsres);
2719 HRESULT update_window_doc(HTMLOuterWindow *window)
2721 nsIDOMHTMLDocument *nshtmldoc;
2722 nsIDOMDocument *nsdoc;
2726 nsres = nsIDOMWindow_GetDocument(window->nswindow, &nsdoc);
2727 if(NS_FAILED(nsres) || !nsdoc) {
2728 ERR("GetDocument failed: %08x\n", nsres);
2732 nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
2733 nsIDOMDocument_Release(nsdoc);
2734 if(NS_FAILED(nsres)) {
2735 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres);
2739 if(!window->base.inner_window || window->base.inner_window->doc->nsdoc != nshtmldoc) {
2740 HTMLDocumentNode *doc;
2742 hres = create_doc_from_nsdoc(nshtmldoc, window->doc_obj, window, &doc);
2743 if(SUCCEEDED(hres)) {
2744 hres = window_set_docnode(window, doc);
2745 htmldoc_release(&doc->basedoc);
2747 ERR("create_doc_from_nsdoc failed: %08x\n", hres);
2753 nsIDOMHTMLDocument_Release(nshtmldoc);
2757 HTMLOuterWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
2759 HTMLOuterWindow *iter;
2761 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLOuterWindow, entry) {
2762 if(iter->nswindow == nswindow)