2 * Copyright 2006-2010 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
31 #define NO_SHLWAPI_REG
34 #include "wine/debug.h"
36 #include "mshtml_private.h"
37 #include "htmlevent.h"
41 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
43 static struct list window_list = LIST_INIT(window_list);
45 static void window_set_docnode(HTMLWindow *window, HTMLDocumentNode *doc_node)
48 if(window->doc_obj && window == window->doc_obj->basedoc.window)
49 window->doc->basedoc.cp_container.forward_container = NULL;
50 detach_events(window->doc);
51 abort_document_bindings(window->doc);
52 window->doc->basedoc.window = NULL;
53 htmldoc_release(&window->doc->basedoc);
55 window->doc = doc_node;
57 htmldoc_addref(&doc_node->basedoc);
59 if(window->doc_obj && window->doc_obj->basedoc.window == window) {
60 if(window->doc_obj->basedoc.doc_node)
61 htmldoc_release(&window->doc_obj->basedoc.doc_node->basedoc);
62 window->doc_obj->basedoc.doc_node = doc_node;
64 htmldoc_addref(&doc_node->basedoc);
67 if(doc_node && window->doc_obj && window->doc_obj->usermode == EDITMODE) {
71 static const PRUnichar onW[] = {'o','n',0};
73 nsAString_Init(&mode_str, onW);
74 nsres = nsIDOMHTMLDocument_SetDesignMode(doc_node->nsdoc, &mode_str);
75 nsAString_Finish(&mode_str);
77 ERR("SetDesignMode failed: %08x\n", nsres);
81 static void release_children(HTMLWindow *This)
85 while(!list_empty(&This->children)) {
86 child = LIST_ENTRY(list_tail(&This->children), HTMLWindow, sibling_entry);
88 list_remove(&child->sibling_entry);
90 IHTMLWindow2_Release(&child->IHTMLWindow2_iface);
94 static HRESULT get_location(HTMLWindow *This, HTMLLocation **ret)
97 IHTMLLocation_AddRef(&This->location->IHTMLLocation_iface);
101 hres = HTMLLocation_Create(This, &This->location);
106 *ret = This->location;
110 void get_top_window(HTMLWindow *window, HTMLWindow **ret)
114 for(iter = window; iter->parent; iter = iter->parent);
118 static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
121 FIXME("No document\n");
125 return set_event_handler(&window->doc->body_event_target, NULL, window->doc, eid, var);
128 static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
131 FIXME("No document\n");
135 return get_event_handler(&window->doc->body_event_target, eid, var);
138 static inline HTMLWindow *impl_from_IHTMLWindow2(IHTMLWindow2 *iface)
140 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow2_iface);
143 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
145 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
149 if(IsEqualGUID(&IID_IUnknown, riid)) {
150 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
151 *ppv = &This->IHTMLWindow2_iface;
152 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
153 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
154 *ppv = &This->IHTMLWindow2_iface;
155 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
156 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
157 *ppv = &This->IDispatchEx_iface;
158 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2, riid)) {
159 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
160 *ppv = &This->IHTMLWindow2_iface;
161 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
162 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
163 *ppv = &This->IHTMLWindow2_iface;
164 }else if(IsEqualGUID(&IID_IHTMLWindow3, riid)) {
165 TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This, ppv);
166 *ppv = &This->IHTMLWindow3_iface;
167 }else if(IsEqualGUID(&IID_IHTMLWindow4, riid)) {
168 TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This, ppv);
169 *ppv = &This->IHTMLWindow4_iface;
170 }else if(IsEqualGUID(&IID_IHTMLWindow5, riid)) {
171 TRACE("(%p)->(IID_IHTMLWindow5 %p)\n", This, ppv);
172 *ppv = &This->IHTMLWindow5_iface;
173 }else if(IsEqualGUID(&IID_IHTMLWindow6, riid)) {
174 TRACE("(%p)->(IID_IHTMLWindow6 %p)\n", This, ppv);
175 *ppv = &This->IHTMLWindow6_iface;
176 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow, riid)) {
177 TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This, ppv);
178 *ppv = &This->IHTMLPrivateWindow_iface;
179 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
180 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
181 *ppv = &This->IServiceProvider_iface;
182 }else if(IsEqualGUID(&IID_ITravelLogClient, riid)) {
183 TRACE("(%p)->(IID_ITravelLogClient %p)\n", This, ppv);
184 *ppv = &This->ITravelLogClient_iface;
185 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
186 return *ppv ? S_OK : E_NOINTERFACE;
190 IUnknown_AddRef((IUnknown*)*ppv);
194 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
195 return E_NOINTERFACE;
198 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
200 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
201 LONG ref = InterlockedIncrement(&This->ref);
203 TRACE("(%p) ref=%d\n", This, ref);
208 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
210 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
211 LONG ref = InterlockedDecrement(&This->ref);
213 TRACE("(%p) ref=%d\n", This, ref);
218 remove_target_tasks(This->task_magic);
219 set_window_bscallback(This, NULL);
220 set_current_mon(This, NULL);
221 window_set_docnode(This, NULL);
222 release_children(This);
225 IInternetSecurityManager_Release(This->secmgr);
227 if(This->frame_element)
228 This->frame_element->content_window = NULL;
230 if(This->option_factory) {
231 This->option_factory->window = NULL;
232 IHTMLOptionElementFactory_Release(&This->option_factory->IHTMLOptionElementFactory_iface);
235 if(This->image_factory) {
236 This->image_factory->window = NULL;
237 IHTMLImageElementFactory_Release(&This->image_factory->IHTMLImageElementFactory_iface);
241 This->location->window = NULL;
242 IHTMLLocation_Release(&This->location->IHTMLLocation_iface);
246 IHTMLScreen_Release(This->screen);
248 for(i=0; i < This->global_prop_cnt; i++)
249 heap_free(This->global_props[i].name);
251 This->window_ref->window = NULL;
252 windowref_release(This->window_ref);
254 heap_free(This->global_props);
255 release_script_hosts(This);
258 nsIDOMWindow_Release(This->nswindow);
260 list_remove(&This->entry);
261 release_dispex(&This->dispex);
268 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
270 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
272 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
275 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
276 LCID lcid, ITypeInfo **ppTInfo)
278 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
280 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
283 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
284 LPOLESTR *rgszNames, UINT cNames,
285 LCID lcid, DISPID *rgDispId)
287 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
289 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
293 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
294 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
295 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
297 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
299 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
300 pDispParams, pVarResult, pExcepInfo, puArgErr);
303 static HRESULT get_frame_by_index(nsIDOMWindowCollection *nsFrames, PRUint32 index, HTMLWindow **ret)
306 nsIDOMWindow *nsWindow;
309 nsres = nsIDOMWindowCollection_GetLength(nsFrames, &length);
310 if(NS_FAILED(nsres)) {
311 FIXME("nsIDOMWindowCollection_GetLength failed: 0x%08x\n", nsres);
316 return DISP_E_MEMBERNOTFOUND;
318 nsres = nsIDOMWindowCollection_Item(nsFrames, index, &nsWindow);
319 if(NS_FAILED(nsres)) {
320 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
324 *ret = nswindow_to_window(nsWindow);
326 nsIDOMWindow_Release(nsWindow);
331 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
333 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
334 nsIDOMWindowCollection *nsFrames;
335 HTMLWindow *window = NULL;
339 TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
341 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nsFrames);
342 if(NS_FAILED(nsres)) {
343 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres);
347 switch(V_VT(pvarIndex)) {
349 int index = V_I4(pvarIndex);
350 TRACE("Getting index %d\n", index);
353 hres = get_frame_by_index(nsFrames, index, &window);
357 unsigned int index = V_UINT(pvarIndex);
358 TRACE("Getting index %u\n", index);
359 hres = get_frame_by_index(nsFrames, index, &window);
363 BSTR str = V_BSTR(pvarIndex);
366 TRACE("Getting name %s\n", wine_dbgstr_w(str));
368 nsIDOMWindowCollection_GetLength(nsFrames, &length);
371 for(i = 0; i < length && !window; ++i) {
372 HTMLWindow *cur_window;
373 nsIDOMWindow *nsWindow;
376 nsres = nsIDOMWindowCollection_Item(nsFrames, i, &nsWindow);
377 if(NS_FAILED(nsres)) {
378 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
383 cur_window = nswindow_to_window(nsWindow);
385 nsIDOMWindow_Release(nsWindow);
387 hres = IHTMLElement_get_id(&cur_window->frame_element->element.IHTMLElement_iface, &id);
389 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres);
393 if(!strcmpW(id, str))
404 nsIDOMWindowCollection_Release(nsFrames);
408 return DISP_E_MEMBERNOTFOUND;
410 IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
411 V_VT(pvarResult) = VT_DISPATCH;
412 V_DISPATCH(pvarResult) = (IDispatch*)window;
416 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
418 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
419 nsIDOMWindowCollection *nscollection;
423 TRACE("(%p)->(%p)\n", This, p);
425 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nscollection);
426 if(NS_FAILED(nsres)) {
427 ERR("GetFrames failed: %08x\n", nsres);
431 nsres = nsIDOMWindowCollection_GetLength(nscollection, &length);
432 nsIDOMWindowCollection_Release(nscollection);
433 if(NS_FAILED(nsres)) {
434 ERR("GetLength failed: %08x\n", nsres);
442 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
444 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
445 FIXME("(%p)->(%p): semi-stub\n", This, p);
447 /* FIXME: Should return a separate Window object */
448 *p = (IHTMLFramesCollection2*)&This->IHTMLWindow2_iface;
449 HTMLWindow2_AddRef(iface);
453 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
455 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
456 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
460 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
462 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
463 FIXME("(%p)->(%p)\n", This, p);
467 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
469 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
471 WARN("(%p)->(%s)\n", This, debugstr_w(v));
474 * FIXME: Since IE7, setting status is blocked, but still possible in certain circumstances.
475 * Ignoring the call should be enough for us.
480 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
482 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
484 TRACE("(%p)->(%p)\n", This, p);
491 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
492 LONG msec, VARIANT *language, LONG *timerID)
494 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
497 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
499 V_VT(&expr_var) = VT_BSTR;
500 V_BSTR(&expr_var) = expression;
502 return IHTMLWindow3_setTimeout(&This->IHTMLWindow3_iface, &expr_var, msec, language, timerID);
505 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID)
507 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
509 TRACE("(%p)->(%d)\n", This, timerID);
511 return clear_task_timer(&This->doc->basedoc, FALSE, timerID);
514 #define MAX_MESSAGE_LEN 2000
516 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
518 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
519 WCHAR title[100], *msg = message;
522 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
524 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, title,
525 sizeof(title)/sizeof(WCHAR))) {
526 WARN("Could not load message box title: %d\n", GetLastError());
530 len = SysStringLen(message);
531 if(len > MAX_MESSAGE_LEN) {
532 msg = heap_alloc((MAX_MESSAGE_LEN+1)*sizeof(WCHAR));
534 return E_OUTOFMEMORY;
535 memcpy(msg, message, MAX_MESSAGE_LEN*sizeof(WCHAR));
536 msg[MAX_MESSAGE_LEN] = 0;
539 MessageBoxW(This->doc_obj->hwnd, msg, title, MB_ICONWARNING);
545 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
546 VARIANT_BOOL *confirmed)
548 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
551 TRACE("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
553 if(!confirmed) return E_INVALIDARG;
555 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
556 sizeof(wszTitle)/sizeof(WCHAR))) {
557 WARN("Could not load message box title: %d\n", GetLastError());
558 *confirmed = VARIANT_TRUE;
562 if(MessageBoxW(This->doc_obj->hwnd, message, wszTitle,
563 MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
564 *confirmed = VARIANT_TRUE;
565 else *confirmed = VARIANT_FALSE;
577 static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
578 WPARAM wparam, LPARAM lparam)
584 prompt_arg *arg = (prompt_arg*)lparam;
587 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
588 sizeof(wszTitle)/sizeof(WCHAR))) {
589 WARN("Could not load message box title: %d\n", GetLastError());
590 EndDialog(hwnd, wparam);
594 SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
595 SetWindowTextW(hwnd, wszTitle);
596 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_PROMPT), arg->message);
597 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_EDIT), arg->dststr);
603 case MAKEWPARAM(IDCANCEL, BN_CLICKED):
604 EndDialog(hwnd, wparam);
606 case MAKEWPARAM(IDOK, BN_CLICKED):
609 (prompt_arg*)GetWindowLongPtrW(hwnd, DWLP_USER);
610 HWND hwndPrompt = GetDlgItem(hwnd, ID_PROMPT_EDIT);
611 INT len = GetWindowTextLengthW(hwndPrompt);
615 EndDialog(hwnd, wparam);
619 V_VT(arg->textdata) = VT_BSTR;
620 if(!len && !arg->dststr)
621 V_BSTR(arg->textdata) = NULL;
624 V_BSTR(arg->textdata) = SysAllocStringLen(NULL, len);
625 GetWindowTextW(hwndPrompt, V_BSTR(arg->textdata), len+1);
627 EndDialog(hwnd, wparam);
633 EndDialog(hwnd, IDCANCEL);
640 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
641 BSTR dststr, VARIANT *textdata)
643 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
646 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
648 if(textdata) V_VT(textdata) = VT_NULL;
650 arg.message = message;
652 arg.textdata = textdata;
654 DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
655 This->doc_obj->hwnd, prompt_dlgproc, (LPARAM)&arg);
659 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
661 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
663 TRACE("(%p)->(%p)\n", This, p);
665 if(!This->image_factory)
666 This->image_factory = HTMLImageElementFactory_Create(This);
668 *p = &This->image_factory->IHTMLImageElementFactory_iface;
669 IHTMLImageElementFactory_AddRef(*p);
674 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
676 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
677 HTMLLocation *location;
680 TRACE("(%p)->(%p)\n", This, p);
682 hres = get_location(This, &location);
686 *p = &location->IHTMLLocation_iface;
690 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
692 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
694 TRACE("(%p)->(%p)\n", This, p);
699 hres = create_history(&This->history);
704 IOmHistory_AddRef(This->history);
709 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
711 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
712 FIXME("(%p)->()\n", This);
716 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
718 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
719 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
723 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
725 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
727 FIXME("(%p)->(%p) returning empty\n", This, p);
733 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
735 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
737 TRACE("(%p)->(%p)\n", This, p);
739 *p = OmNavigator_Create();
743 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
745 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
749 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
751 nsAString_InitDepend(&name_str, v);
752 nsres = nsIDOMWindow_SetName(This->nswindow, &name_str);
753 nsAString_Finish(&name_str);
755 ERR("SetName failed: %08x\n", nsres);
760 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
762 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
766 TRACE("(%p)->(%p)\n", This, p);
768 nsAString_Init(&name_str, NULL);
769 nsres = nsIDOMWindow_GetName(This->nswindow, &name_str);
770 return return_nsstr(nsres, &name_str, p);
773 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
775 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
777 TRACE("(%p)->(%p)\n", This, p);
780 return IHTMLWindow2_get_self(&This->IHTMLWindow2_iface, p);
782 *p = &This->parent->IHTMLWindow2_iface;
783 IHTMLWindow2_AddRef(*p);
787 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
788 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
790 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
791 INewWindowManager *new_window_mgr;
795 TRACE("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
796 debugstr_w(features), replace, pomWindowResult);
801 if(name && *name == '_') {
802 FIXME("Unsupported name %s\n", debugstr_w(name));
806 hres = do_query_service((IUnknown*)This->doc_obj->client, &SID_SNewWindowManager, &IID_INewWindowManager,
807 (void**)&new_window_mgr);
809 FIXME("No INewWindowManager\n");
813 hres = INewWindowManager_EvaluateNewWindow(new_window_mgr, url, name, This->url,
814 features, !!replace, This->doc_obj->has_popup ? 0 : NWMF_FIRST, 0);
815 INewWindowManager_Release(new_window_mgr);
816 This->doc_obj->has_popup = TRUE;
818 *pomWindowResult = NULL;
822 hres = create_relative_uri(This, url, &uri);
826 hres = navigate_new_window(This, uri, name, pomWindowResult);
831 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
833 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
835 TRACE("(%p)->(%p)\n", This, p);
837 /* FIXME: We should return kind of proxy window here. */
838 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
839 *p = &This->IHTMLWindow2_iface;
843 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
845 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
848 TRACE("(%p)->(%p)\n", This, p);
850 get_top_window(This, &top);
851 *p = &top->IHTMLWindow2_iface;
852 IHTMLWindow2_AddRef(*p);
857 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
859 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
861 TRACE("(%p)->(%p)\n", This, p);
863 /* FIXME: We should return kind of proxy window here. */
864 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
865 *p = &This->IHTMLWindow2_iface;
869 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
871 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
872 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
876 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
878 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
879 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
883 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
885 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
886 FIXME("(%p)->(%p)\n", This, p);
890 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
892 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
893 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
897 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
899 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
900 FIXME("(%p)->(%p)\n", This, p);
904 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
906 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
908 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
910 return set_window_event(This, EVENTID_LOAD, &v);
913 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
915 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
917 TRACE("(%p)->(%p)\n", This, p);
919 return get_window_event(This, EVENTID_LOAD, p);
922 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
924 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
926 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
928 return set_window_event(This, EVENTID_BEFOREUNLOAD, &v);
931 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
933 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
935 TRACE("(%p)->(%p)\n", This, p);
937 return get_window_event(This, EVENTID_BEFOREUNLOAD, p);
940 static HRESULT WINAPI HTMLWindow2_put_onunload(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_onunload(IHTMLWindow2 *iface, VARIANT *p)
949 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
950 FIXME("(%p)->(%p)\n", This, p);
954 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
956 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
957 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
961 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
963 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
964 FIXME("(%p)->(%p)\n", This, p);
968 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
970 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
972 FIXME("(%p)->(%s) semi-stub\n", This, debugstr_variant(&v));
974 return set_window_event(This, EVENTID_ERROR, &v);
977 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
979 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
981 TRACE("(%p)->(%p)\n", This, p);
983 return get_window_event(This, EVENTID_ERROR, p);
986 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
988 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
990 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
992 return set_window_event(This, EVENTID_RESIZE, &v);
995 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
997 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
999 TRACE("(%p)->(%p)\n", This, p);
1001 return get_window_event(This, EVENTID_RESIZE, p);
1004 static HRESULT WINAPI HTMLWindow2_put_onscroll(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_onscroll(IHTMLWindow2 *iface, VARIANT *p)
1013 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1014 FIXME("(%p)->(%p)\n", This, p);
1018 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
1020 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1022 TRACE("(%p)->(%p)\n", This, p);
1025 /* FIXME: We should return a wrapper object here */
1026 *p = &This->doc->basedoc.IHTMLDocument2_iface;
1027 IHTMLDocument2_AddRef(*p);
1035 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
1037 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1039 TRACE("(%p)->(%p)\n", This, p);
1042 IHTMLEventObj_AddRef(This->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);
1074 TRACE("(%p)->(%p)\n", This, p);
1079 hres = HTMLScreen_Create(&This->screen);
1085 IHTMLScreen_AddRef(This->screen);
1089 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
1091 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1093 TRACE("(%p)->(%p)\n", This, p);
1095 if(!This->option_factory)
1096 This->option_factory = HTMLOptionElementFactory_Create(This);
1098 *p = &This->option_factory->IHTMLOptionElementFactory_iface;
1099 IHTMLOptionElementFactory_AddRef(*p);
1104 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
1106 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1108 TRACE("(%p)->()\n", This);
1111 SetFocus(This->doc_obj->hwnd);
1115 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
1117 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1118 FIXME("(%p)->(%p)\n", This, p);
1122 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
1124 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1125 FIXME("(%p)->()\n", This);
1129 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, LONG x, LONG y)
1131 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1132 FIXME("(%p)->(%d %d)\n", This, x, y);
1136 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
1138 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1139 FIXME("(%p)->(%p)\n", This, p);
1143 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
1144 LONG msec, VARIANT *language, LONG *timerID)
1146 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1149 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
1151 V_VT(&expr) = VT_BSTR;
1152 V_BSTR(&expr) = expression;
1153 return IHTMLWindow3_setInterval(&This->IHTMLWindow3_iface, &expr, msec, language, timerID);
1156 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerID)
1158 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1160 TRACE("(%p)->(%d)\n", This, timerID);
1162 return clear_task_timer(&This->doc->basedoc, TRUE, timerID);
1165 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
1167 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1168 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1172 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
1174 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1175 FIXME("(%p)->(%p)\n", This, p);
1179 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
1182 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1184 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
1186 return exec_script(This, scode, language, pvarRet);
1189 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
1191 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1193 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1195 TRACE("(%p)->(%p)\n", This, String);
1198 return E_INVALIDARG;
1200 *String = SysAllocString(objectW);
1201 return *String ? S_OK : E_OUTOFMEMORY;
1204 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, LONG x, LONG y)
1206 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1209 TRACE("(%p)->(%d %d)\n", This, x, y);
1211 nsres = nsIDOMWindow_ScrollBy(This->nswindow, x, y);
1212 if(NS_FAILED(nsres))
1213 ERR("ScrollBy failed: %08x\n", nsres);
1218 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, LONG x, LONG y)
1220 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1223 TRACE("(%p)->(%d %d)\n", This, x, y);
1225 nsres = nsIDOMWindow_ScrollTo(This->nswindow, x, y);
1226 if(NS_FAILED(nsres))
1227 ERR("ScrollTo failed: %08x\n", nsres);
1232 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, LONG x, LONG y)
1234 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1235 FIXME("(%p)->(%d %d)\n", This, x, y);
1239 static HRESULT WINAPI HTMLWindow2_moveBy(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_resizeTo(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_resizeBy(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_get_external(IHTMLWindow2 *iface, IDispatch **p)
1262 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1264 TRACE("(%p)->(%p)\n", This, p);
1268 if(!This->doc_obj->hostui)
1271 return IDocHostUIHandler_GetExternal(This->doc_obj->hostui, p);
1274 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
1275 HTMLWindow2_QueryInterface,
1277 HTMLWindow2_Release,
1278 HTMLWindow2_GetTypeInfoCount,
1279 HTMLWindow2_GetTypeInfo,
1280 HTMLWindow2_GetIDsOfNames,
1283 HTMLWindow2_get_length,
1284 HTMLWindow2_get_frames,
1285 HTMLWindow2_put_defaultStatus,
1286 HTMLWindow2_get_defaultStatus,
1287 HTMLWindow2_put_status,
1288 HTMLWindow2_get_status,
1289 HTMLWindow2_setTimeout,
1290 HTMLWindow2_clearTimeout,
1292 HTMLWindow2_confirm,
1294 HTMLWindow2_get_Image,
1295 HTMLWindow2_get_location,
1296 HTMLWindow2_get_history,
1298 HTMLWindow2_put_opener,
1299 HTMLWindow2_get_opener,
1300 HTMLWindow2_get_navigator,
1301 HTMLWindow2_put_name,
1302 HTMLWindow2_get_name,
1303 HTMLWindow2_get_parent,
1305 HTMLWindow2_get_self,
1306 HTMLWindow2_get_top,
1307 HTMLWindow2_get_window,
1308 HTMLWindow2_navigate,
1309 HTMLWindow2_put_onfocus,
1310 HTMLWindow2_get_onfocus,
1311 HTMLWindow2_put_onblur,
1312 HTMLWindow2_get_onblur,
1313 HTMLWindow2_put_onload,
1314 HTMLWindow2_get_onload,
1315 HTMLWindow2_put_onbeforeunload,
1316 HTMLWindow2_get_onbeforeunload,
1317 HTMLWindow2_put_onunload,
1318 HTMLWindow2_get_onunload,
1319 HTMLWindow2_put_onhelp,
1320 HTMLWindow2_get_onhelp,
1321 HTMLWindow2_put_onerror,
1322 HTMLWindow2_get_onerror,
1323 HTMLWindow2_put_onresize,
1324 HTMLWindow2_get_onresize,
1325 HTMLWindow2_put_onscroll,
1326 HTMLWindow2_get_onscroll,
1327 HTMLWindow2_get_document,
1328 HTMLWindow2_get_event,
1329 HTMLWindow2_get__newEnum,
1330 HTMLWindow2_showModalDialog,
1331 HTMLWindow2_showHelp,
1332 HTMLWindow2_get_screen,
1333 HTMLWindow2_get_Option,
1335 HTMLWindow2_get_closed,
1338 HTMLWindow2_get_clientInformation,
1339 HTMLWindow2_setInterval,
1340 HTMLWindow2_clearInterval,
1341 HTMLWindow2_put_offscreenBuffering,
1342 HTMLWindow2_get_offscreenBuffering,
1343 HTMLWindow2_execScript,
1344 HTMLWindow2_toString,
1345 HTMLWindow2_scrollBy,
1346 HTMLWindow2_scrollTo,
1349 HTMLWindow2_resizeTo,
1350 HTMLWindow2_resizeBy,
1351 HTMLWindow2_get_external
1354 static inline HTMLWindow *impl_from_IHTMLWindow3(IHTMLWindow3 *iface)
1356 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow3_iface);
1359 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
1361 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1363 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1366 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
1368 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1370 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1373 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
1375 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1377 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1380 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
1382 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1384 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1387 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
1388 LCID lcid, ITypeInfo **ppTInfo)
1390 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1392 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1395 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
1396 LPOLESTR *rgszNames, UINT cNames,
1397 LCID lcid, DISPID *rgDispId)
1399 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1401 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1405 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
1406 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1407 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1409 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1411 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1412 pDispParams, pVarResult, pExcepInfo, puArgErr);
1415 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, LONG *p)
1417 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1418 FIXME("(%p)->(%p)\n", This, p);
1422 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, LONG *p)
1424 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1425 FIXME("(%p)->(%p)\n", This, p);
1429 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
1431 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1433 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
1436 FIXME("No document\n");
1440 return attach_event(&This->doc->body_event_target, NULL, &This->doc->basedoc, event, pDisp, pfResult);
1443 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
1445 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1447 TRACE("(%p)->()\n", This);
1450 FIXME("No document\n");
1454 return detach_event(This->doc->body_event_target, &This->doc->basedoc, event, pDisp);
1457 static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, LONG msec, VARIANT *language,
1458 BOOL interval, LONG *timer_id)
1460 IDispatch *disp = NULL;
1462 switch(V_VT(expr)) {
1464 disp = V_DISPATCH(expr);
1465 IDispatch_AddRef(disp);
1469 disp = script_parse_event(This, V_BSTR(expr));
1473 FIXME("unimplemented expr %s\n", debugstr_variant(expr));
1480 *timer_id = set_task_timer(&This->doc->basedoc, msec, interval, disp);
1481 IDispatch_Release(disp);
1486 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1487 VARIANT *language, LONG *timerID)
1489 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1491 TRACE("(%p)->(%s %d %s %p)\n", This, debugstr_variant(expression), msec, debugstr_variant(language), timerID);
1493 return window_set_timer(This, expression, msec, language, FALSE, timerID);
1496 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1497 VARIANT *language, LONG *timerID)
1499 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1501 TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID);
1503 return window_set_timer(This, expression, msec, language, TRUE, timerID);
1506 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
1508 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1509 FIXME("(%p)\n", This);
1513 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
1515 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1516 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1520 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
1522 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1523 FIXME("(%p)->(%p)\n", This, p);
1527 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
1529 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1530 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1534 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
1536 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1537 FIXME("(%p)->(%p)\n", This, p);
1541 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
1543 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1544 FIXME("(%p)->(%p)\n", This, p);
1548 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
1549 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
1551 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1552 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
1556 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
1557 HTMLWindow3_QueryInterface,
1559 HTMLWindow3_Release,
1560 HTMLWindow3_GetTypeInfoCount,
1561 HTMLWindow3_GetTypeInfo,
1562 HTMLWindow3_GetIDsOfNames,
1564 HTMLWindow3_get_screenLeft,
1565 HTMLWindow3_get_screenTop,
1566 HTMLWindow3_attachEvent,
1567 HTMLWindow3_detachEvent,
1568 HTMLWindow3_setTimeout,
1569 HTMLWindow3_setInterval,
1571 HTMLWindow3_put_onbeforeprint,
1572 HTMLWindow3_get_onbeforeprint,
1573 HTMLWindow3_put_onafterprint,
1574 HTMLWindow3_get_onafterprint,
1575 HTMLWindow3_get_clipboardData,
1576 HTMLWindow3_showModelessDialog
1579 static inline HTMLWindow *impl_from_IHTMLWindow4(IHTMLWindow4 *iface)
1581 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow4_iface);
1584 static HRESULT WINAPI HTMLWindow4_QueryInterface(IHTMLWindow4 *iface, REFIID riid, void **ppv)
1586 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1588 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1591 static ULONG WINAPI HTMLWindow4_AddRef(IHTMLWindow4 *iface)
1593 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1595 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1598 static ULONG WINAPI HTMLWindow4_Release(IHTMLWindow4 *iface)
1600 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1602 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1605 static HRESULT WINAPI HTMLWindow4_GetTypeInfoCount(IHTMLWindow4 *iface, UINT *pctinfo)
1607 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1609 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1612 static HRESULT WINAPI HTMLWindow4_GetTypeInfo(IHTMLWindow4 *iface, UINT iTInfo,
1613 LCID lcid, ITypeInfo **ppTInfo)
1615 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1617 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1620 static HRESULT WINAPI HTMLWindow4_GetIDsOfNames(IHTMLWindow4 *iface, REFIID riid,
1621 LPOLESTR *rgszNames, UINT cNames,
1622 LCID lcid, DISPID *rgDispId)
1624 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1626 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1630 static HRESULT WINAPI HTMLWindow4_Invoke(IHTMLWindow4 *iface, DISPID dispIdMember,
1631 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1632 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1634 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1636 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1637 pDispParams, pVarResult, pExcepInfo, puArgErr);
1640 static HRESULT WINAPI HTMLWindow4_createPopup(IHTMLWindow4 *iface, VARIANT *varArgIn,
1641 IDispatch **ppPopup)
1643 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1644 FIXME("(%p)->(%p %p)\n", This, varArgIn, ppPopup);
1648 static HRESULT WINAPI HTMLWindow4_get_frameElement(IHTMLWindow4 *iface, IHTMLFrameBase **p)
1650 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1651 TRACE("(%p)->(%p)\n", This, p);
1653 if(This->frame_element) {
1654 *p = &This->frame_element->IHTMLFrameBase_iface;
1655 IHTMLFrameBase_AddRef(*p);
1662 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl = {
1663 HTMLWindow4_QueryInterface,
1665 HTMLWindow4_Release,
1666 HTMLWindow4_GetTypeInfoCount,
1667 HTMLWindow4_GetTypeInfo,
1668 HTMLWindow4_GetIDsOfNames,
1670 HTMLWindow4_createPopup,
1671 HTMLWindow4_get_frameElement
1674 static inline HTMLWindow *impl_from_IHTMLWindow5(IHTMLWindow5 *iface)
1676 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow5_iface);
1679 static HRESULT WINAPI HTMLWindow5_QueryInterface(IHTMLWindow5 *iface, REFIID riid, void **ppv)
1681 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1683 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1686 static ULONG WINAPI HTMLWindow5_AddRef(IHTMLWindow5 *iface)
1688 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1690 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1693 static ULONG WINAPI HTMLWindow5_Release(IHTMLWindow5 *iface)
1695 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1697 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1700 static HRESULT WINAPI HTMLWindow5_GetTypeInfoCount(IHTMLWindow5 *iface, UINT *pctinfo)
1702 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1704 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1707 static HRESULT WINAPI HTMLWindow5_GetTypeInfo(IHTMLWindow5 *iface, UINT iTInfo,
1708 LCID lcid, ITypeInfo **ppTInfo)
1710 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1712 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1715 static HRESULT WINAPI HTMLWindow5_GetIDsOfNames(IHTMLWindow5 *iface, REFIID riid,
1716 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1718 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1720 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1724 static HRESULT WINAPI HTMLWindow5_Invoke(IHTMLWindow5 *iface, DISPID dispIdMember,
1725 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1726 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1728 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1730 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1731 pDispParams, pVarResult, pExcepInfo, puArgErr);
1734 static HRESULT WINAPI HTMLWindow5_put_XMLHttpRequest(IHTMLWindow5 *iface, VARIANT v)
1736 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1737 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1741 static HRESULT WINAPI HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5 *iface, VARIANT *p)
1743 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1744 FIXME("(%p)->(%p)\n", This, p);
1748 static const IHTMLWindow5Vtbl HTMLWindow5Vtbl = {
1749 HTMLWindow5_QueryInterface,
1751 HTMLWindow5_Release,
1752 HTMLWindow5_GetTypeInfoCount,
1753 HTMLWindow5_GetTypeInfo,
1754 HTMLWindow5_GetIDsOfNames,
1756 HTMLWindow5_put_XMLHttpRequest,
1757 HTMLWindow5_get_XMLHttpRequest
1760 static inline HTMLWindow *impl_from_IHTMLWindow6(IHTMLWindow6 *iface)
1762 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow6_iface);
1765 static HRESULT WINAPI HTMLWindow6_QueryInterface(IHTMLWindow6 *iface, REFIID riid, void **ppv)
1767 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1769 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1772 static ULONG WINAPI HTMLWindow6_AddRef(IHTMLWindow6 *iface)
1774 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1776 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1779 static ULONG WINAPI HTMLWindow6_Release(IHTMLWindow6 *iface)
1781 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1783 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1786 static HRESULT WINAPI HTMLWindow6_GetTypeInfoCount(IHTMLWindow6 *iface, UINT *pctinfo)
1788 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1790 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1793 static HRESULT WINAPI HTMLWindow6_GetTypeInfo(IHTMLWindow6 *iface, UINT iTInfo,
1794 LCID lcid, ITypeInfo **ppTInfo)
1796 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1798 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1801 static HRESULT WINAPI HTMLWindow6_GetIDsOfNames(IHTMLWindow6 *iface, REFIID riid,
1802 LPOLESTR *rgszNames, UINT cNames,
1803 LCID lcid, DISPID *rgDispId)
1805 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1807 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1811 static HRESULT WINAPI HTMLWindow6_Invoke(IHTMLWindow6 *iface, DISPID dispIdMember,
1812 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1813 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1815 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1817 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1818 pDispParams, pVarResult, pExcepInfo, puArgErr);
1821 static HRESULT WINAPI HTMLWindow6_put_XDomainRequest(IHTMLWindow6 *iface, VARIANT v)
1823 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1824 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1828 static HRESULT WINAPI HTMLWindow6_get_XDomainRequest(IHTMLWindow6 *iface, VARIANT *p)
1830 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1831 FIXME("(%p)->(%p)\n", This, p);
1835 static HRESULT WINAPI HTMLWindow6_get_sessionStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1837 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1838 FIXME("(%p)->(%p)\n", This, p);
1842 static HRESULT WINAPI HTMLWindow6_get_localStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1844 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1845 FIXME("(%p)->(%p)\n", This, p);
1849 static HRESULT WINAPI HTMLWindow6_put_onhashchange(IHTMLWindow6 *iface, VARIANT v)
1851 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1852 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1856 static HRESULT WINAPI HTMLWindow6_get_onhashchange(IHTMLWindow6 *iface, VARIANT *p)
1858 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1859 FIXME("(%p)->(%p)\n", This, p);
1863 static HRESULT WINAPI HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6 *iface, LONG *p)
1865 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1866 FIXME("(%p)->(%p)\n", This, p);
1870 static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VARIANT targetOrigin)
1872 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1873 FIXME("(%p)->(%s %s)\n", This, debugstr_w(msg), debugstr_variant(&targetOrigin));
1877 static HRESULT WINAPI HTMLWindow6_toStaticHTML(IHTMLWindow6 *iface, BSTR bstrHTML, BSTR *pbstrStaticHTML)
1879 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1880 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrHTML), pbstrStaticHTML);
1884 static HRESULT WINAPI HTMLWindow6_put_onmessage(IHTMLWindow6 *iface, VARIANT v)
1886 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1887 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1891 static HRESULT WINAPI HTMLWindow6_get_onmessage(IHTMLWindow6 *iface, VARIANT *p)
1893 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1894 FIXME("(%p)->(%p)\n", This, p);
1898 static HRESULT WINAPI HTMLWindow6_msWriteProfilerMark(IHTMLWindow6 *iface, BSTR bstrProfilerMark)
1900 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1901 FIXME("(%p)->(%s)\n", This, debugstr_w(bstrProfilerMark));
1905 static const IHTMLWindow6Vtbl HTMLWindow6Vtbl = {
1906 HTMLWindow6_QueryInterface,
1908 HTMLWindow6_Release,
1909 HTMLWindow6_GetTypeInfoCount,
1910 HTMLWindow6_GetTypeInfo,
1911 HTMLWindow6_GetIDsOfNames,
1913 HTMLWindow6_put_XDomainRequest,
1914 HTMLWindow6_get_XDomainRequest,
1915 HTMLWindow6_get_sessionStorage,
1916 HTMLWindow6_get_localStorage,
1917 HTMLWindow6_put_onhashchange,
1918 HTMLWindow6_get_onhashchange,
1919 HTMLWindow6_get_maxConnectionsPerServer,
1920 HTMLWindow6_postMessage,
1921 HTMLWindow6_toStaticHTML,
1922 HTMLWindow6_put_onmessage,
1923 HTMLWindow6_get_onmessage,
1924 HTMLWindow6_msWriteProfilerMark
1927 static inline HTMLWindow *impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow *iface)
1929 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLPrivateWindow_iface);
1932 static HRESULT WINAPI HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow *iface, REFIID riid, void **ppv)
1934 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1936 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1939 static ULONG WINAPI HTMLPrivateWindow_AddRef(IHTMLPrivateWindow *iface)
1941 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1943 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1946 static ULONG WINAPI HTMLPrivateWindow_Release(IHTMLPrivateWindow *iface)
1948 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1950 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1953 static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface, BSTR url, BSTR arg2, BSTR arg3,
1954 BSTR arg4, VARIANT *post_data_var, VARIANT *headers_var, ULONG flags)
1956 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1957 OLECHAR *translated_url = NULL;
1958 DWORD post_data_size = 0;
1959 BYTE *post_data = NULL;
1960 WCHAR *headers = NULL;
1964 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This, debugstr_w(url), debugstr_w(arg2), debugstr_w(arg3), debugstr_w(arg4),
1965 debugstr_variant(post_data_var), debugstr_variant(headers_var), flags);
1967 if(This->doc_obj->hostui) {
1968 hres = IDocHostUIHandler_TranslateUrl(This->doc_obj->hostui, 0, url, &translated_url);
1970 translated_url = NULL;
1973 hres = CreateUri(translated_url ? translated_url : url, 0, 0, &uri);
1974 CoTaskMemFree(translated_url);
1979 if(V_VT(post_data_var) == (VT_ARRAY|VT_UI1)) {
1980 SafeArrayAccessData(V_ARRAY(post_data_var), (void**)&post_data);
1981 post_data_size = V_ARRAY(post_data_var)->rgsabound[0].cElements;
1985 if(headers_var && V_VT(headers_var) != VT_EMPTY && V_VT(headers_var) != VT_ERROR) {
1986 if(V_VT(headers_var) != VT_BSTR)
1987 return E_INVALIDARG;
1989 headers = V_BSTR(headers_var);
1992 hres = super_navigate(This, uri, headers, post_data, post_data_size);
1995 SafeArrayUnaccessData(V_ARRAY(post_data_var));
2000 static HRESULT WINAPI HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow *iface, BSTR *url)
2002 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2003 FIXME("(%p)->(%p)\n", This, url);
2007 static HRESULT WINAPI HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow *iface, IOleCommandTarget *cmdtrg)
2009 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2010 FIXME("(%p)->(%p)\n", This, cmdtrg);
2014 static HRESULT WINAPI HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow *iface, int arg)
2016 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2017 FIXME("(%p)->(%x)\n", This, arg);
2021 static HRESULT WINAPI HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow *iface, LPCWSTR name, IHTMLWindow2 **ret)
2023 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2024 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), ret);
2028 static HRESULT WINAPI HTMLPrivateWindow_GetAddressBarUrl(IHTMLPrivateWindow *iface, BSTR *url)
2030 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2031 TRACE("(%p)->(%p)\n", This, url);
2034 return E_INVALIDARG;
2036 *url = SysAllocString(This->url);
2040 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl = {
2041 HTMLPrivateWindow_QueryInterface,
2042 HTMLPrivateWindow_AddRef,
2043 HTMLPrivateWindow_Release,
2044 HTMLPrivateWindow_SuperNavigate,
2045 HTMLPrivateWindow_GetPendingUrl,
2046 HTMLPrivateWindow_SetPICSTarget,
2047 HTMLPrivateWindow_PICSComplete,
2048 HTMLPrivateWindow_FindWindowByName,
2049 HTMLPrivateWindow_GetAddressBarUrl
2052 static inline HTMLWindow *impl_from_ITravelLogClient(ITravelLogClient *iface)
2054 return CONTAINING_RECORD(iface, HTMLWindow, ITravelLogClient_iface);
2057 static HRESULT WINAPI TravelLogClient_QueryInterface(ITravelLogClient *iface, REFIID riid, void **ppv)
2059 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2061 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2064 static ULONG WINAPI TravelLogClient_AddRef(ITravelLogClient *iface)
2066 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2068 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2071 static ULONG WINAPI TravelLogClient_Release(ITravelLogClient *iface)
2073 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2075 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2078 static HRESULT WINAPI TravelLogClient_FindWindowByIndex(ITravelLogClient *iface, DWORD dwID, IUnknown **ppunk)
2080 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2082 FIXME("(%p)->(%d %p) semi-stub\n", This, dwID, ppunk);
2088 static HRESULT WINAPI TravelLogClient_GetWindowData(ITravelLogClient *iface, IStream *pStream, LPWINDOWDATA pWinData)
2090 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2091 FIXME("(%p)->(%p %p)\n", This, pStream, pWinData);
2095 static HRESULT WINAPI TravelLogClient_LoadHistoryPosition(ITravelLogClient *iface, LPWSTR pszUrlLocation, DWORD dwPosition)
2097 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2098 FIXME("(%p)->(%s %d)\n", This, debugstr_w(pszUrlLocation), dwPosition);
2102 static const ITravelLogClientVtbl TravelLogClientVtbl = {
2103 TravelLogClient_QueryInterface,
2104 TravelLogClient_AddRef,
2105 TravelLogClient_Release,
2106 TravelLogClient_FindWindowByIndex,
2107 TravelLogClient_GetWindowData,
2108 TravelLogClient_LoadHistoryPosition
2111 static inline HTMLWindow *impl_from_IDispatchEx(IDispatchEx *iface)
2113 return CONTAINING_RECORD(iface, HTMLWindow, IDispatchEx_iface);
2116 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
2118 HTMLWindow *This = impl_from_IDispatchEx(iface);
2120 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2123 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
2125 HTMLWindow *This = impl_from_IDispatchEx(iface);
2127 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2130 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
2132 HTMLWindow *This = impl_from_IDispatchEx(iface);
2134 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2137 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
2139 HTMLWindow *This = impl_from_IDispatchEx(iface);
2141 TRACE("(%p)->(%p)\n", This, pctinfo);
2143 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2146 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
2147 LCID lcid, ITypeInfo **ppTInfo)
2149 HTMLWindow *This = impl_from_IDispatchEx(iface);
2151 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
2153 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2156 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
2157 LPOLESTR *rgszNames, UINT cNames,
2158 LCID lcid, DISPID *rgDispId)
2160 HTMLWindow *This = impl_from_IDispatchEx(iface);
2164 WARN("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
2167 for(i=0; i < cNames; i++) {
2168 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
2169 hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
2177 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
2178 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2179 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2181 HTMLWindow *This = impl_from_IDispatchEx(iface);
2183 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
2184 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2186 /* FIXME: Use script dispatch */
2188 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2189 pDispParams, pVarResult, pExcepInfo, puArgErr);
2192 static global_prop_t *alloc_global_prop(HTMLWindow *This, global_prop_type_t type, BSTR name)
2194 if(This->global_prop_cnt == This->global_prop_size) {
2195 global_prop_t *new_props;
2198 if(This->global_props) {
2199 new_size = This->global_prop_size*2;
2200 new_props = heap_realloc(This->global_props, new_size*sizeof(global_prop_t));
2203 new_props = heap_alloc(new_size*sizeof(global_prop_t));
2207 This->global_props = new_props;
2208 This->global_prop_size = new_size;
2211 This->global_props[This->global_prop_cnt].name = heap_strdupW(name);
2212 if(!This->global_props[This->global_prop_cnt].name)
2215 This->global_props[This->global_prop_cnt].type = type;
2216 return This->global_props + This->global_prop_cnt++;
2219 static inline DWORD prop_to_dispid(HTMLWindow *This, global_prop_t *prop)
2221 return MSHTML_DISPID_CUSTOM_MIN + (prop-This->global_props);
2224 HRESULT search_window_props(HTMLWindow *This, BSTR bstrName, DWORD grfdex, DISPID *pid)
2227 ScriptHost *script_host;
2230 for(i=0; i < This->global_prop_cnt; i++) {
2231 /* FIXME: case sensitivity */
2232 if(!strcmpW(This->global_props[i].name, bstrName)) {
2233 *pid = MSHTML_DISPID_CUSTOM_MIN+i;
2238 if(find_global_prop(This, bstrName, grfdex, &script_host, &id)) {
2239 global_prop_t *prop;
2241 prop = alloc_global_prop(This, GLOBAL_SCRIPTVAR, bstrName);
2243 return E_OUTOFMEMORY;
2245 prop->script_host = script_host;
2248 *pid = prop_to_dispid(This, prop);
2252 return DISP_E_UNKNOWNNAME;
2255 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
2257 HTMLWindow *This = impl_from_IDispatchEx(iface);
2260 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
2262 hres = search_window_props(This, bstrName, grfdex, pid);
2263 if(hres != DISP_E_UNKNOWNNAME)
2266 hres = IDispatchEx_GetDispID(&This->dispex.IDispatchEx_iface, bstrName, grfdex, pid);
2267 if(hres != DISP_E_UNKNOWNNAME)
2271 global_prop_t *prop;
2274 hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
2276 if(SUCCEEDED(hres) && elem) {
2277 IHTMLElement_Release(elem);
2279 prop = alloc_global_prop(This, GLOBAL_ELEMENTVAR, bstrName);
2281 return E_OUTOFMEMORY;
2283 *pid = prop_to_dispid(This, prop);
2288 return DISP_E_UNKNOWNNAME;
2291 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
2292 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
2294 HTMLWindow *This = impl_from_IDispatchEx(iface);
2296 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
2298 if(id == DISPID_IHTMLWINDOW2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT)) {
2299 HTMLLocation *location;
2302 TRACE("forwarding to location.href\n");
2304 hres = get_location(This, &location);
2308 hres = IDispatchEx_InvokeEx(&location->dispex.IDispatchEx_iface, DISPID_VALUE, lcid,
2309 wFlags, pdp, pvarRes, pei, pspCaller);
2310 IHTMLLocation_Release(&location->IHTMLLocation_iface);
2314 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes,
2318 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
2320 HTMLWindow *This = impl_from_IDispatchEx(iface);
2322 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
2324 return IDispatchEx_DeleteMemberByName(&This->dispex.IDispatchEx_iface, bstrName, grfdex);
2327 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
2329 HTMLWindow *This = impl_from_IDispatchEx(iface);
2331 TRACE("(%p)->(%x)\n", This, id);
2333 return IDispatchEx_DeleteMemberByDispID(&This->dispex.IDispatchEx_iface, id);
2336 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
2338 HTMLWindow *This = impl_from_IDispatchEx(iface);
2340 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
2342 return IDispatchEx_GetMemberProperties(&This->dispex.IDispatchEx_iface, id, grfdexFetch,
2346 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
2348 HTMLWindow *This = impl_from_IDispatchEx(iface);
2350 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
2352 return IDispatchEx_GetMemberName(&This->dispex.IDispatchEx_iface, id, pbstrName);
2355 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
2357 HTMLWindow *This = impl_from_IDispatchEx(iface);
2359 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
2361 return IDispatchEx_GetNextDispID(&This->dispex.IDispatchEx_iface, grfdex, id, pid);
2364 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
2366 HTMLWindow *This = impl_from_IDispatchEx(iface);
2368 TRACE("(%p)->(%p)\n", This, ppunk);
2374 static const IDispatchExVtbl WindowDispExVtbl = {
2375 WindowDispEx_QueryInterface,
2376 WindowDispEx_AddRef,
2377 WindowDispEx_Release,
2378 WindowDispEx_GetTypeInfoCount,
2379 WindowDispEx_GetTypeInfo,
2380 WindowDispEx_GetIDsOfNames,
2381 WindowDispEx_Invoke,
2382 WindowDispEx_GetDispID,
2383 WindowDispEx_InvokeEx,
2384 WindowDispEx_DeleteMemberByName,
2385 WindowDispEx_DeleteMemberByDispID,
2386 WindowDispEx_GetMemberProperties,
2387 WindowDispEx_GetMemberName,
2388 WindowDispEx_GetNextDispID,
2389 WindowDispEx_GetNameSpaceParent
2392 static inline HTMLWindow *impl_from_IServiceProvider(IServiceProvider *iface)
2394 return CONTAINING_RECORD(iface, HTMLWindow, IServiceProvider_iface);
2397 static HRESULT WINAPI HTMLWindowSP_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
2399 HTMLWindow *This = impl_from_IServiceProvider(iface);
2400 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2403 static ULONG WINAPI HTMLWindowSP_AddRef(IServiceProvider *iface)
2405 HTMLWindow *This = impl_from_IServiceProvider(iface);
2406 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2409 static ULONG WINAPI HTMLWindowSP_Release(IServiceProvider *iface)
2411 HTMLWindow *This = impl_from_IServiceProvider(iface);
2412 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2415 static HRESULT WINAPI HTMLWindowSP_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv)
2417 HTMLWindow *This = impl_from_IServiceProvider(iface);
2419 if(IsEqualGUID(guidService, &IID_IHTMLWindow2)) {
2420 TRACE("IID_IHTMLWindow2\n");
2421 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2424 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
2427 return E_NOINTERFACE;
2429 return IServiceProvider_QueryService(&This->doc_obj->basedoc.IServiceProvider_iface,
2430 guidService, riid, ppv);
2433 static const IServiceProviderVtbl ServiceProviderVtbl = {
2434 HTMLWindowSP_QueryInterface,
2435 HTMLWindowSP_AddRef,
2436 HTMLWindowSP_Release,
2437 HTMLWindowSP_QueryService
2440 static inline HTMLWindow *impl_from_DispatchEx(DispatchEx *iface)
2442 return CONTAINING_RECORD(iface, HTMLWindow, dispex);
2445 static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2446 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2448 HTMLWindow *This = impl_from_DispatchEx(dispex);
2449 global_prop_t *prop;
2453 idx = id - MSHTML_DISPID_CUSTOM_MIN;
2454 if(idx >= This->global_prop_cnt)
2455 return DISP_E_MEMBERNOTFOUND;
2457 prop = This->global_props+idx;
2459 switch(prop->type) {
2460 case GLOBAL_SCRIPTVAR: {
2464 disp = get_script_disp(prop->script_host);
2466 return E_UNEXPECTED;
2468 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&iface);
2469 if(SUCCEEDED(hres)) {
2470 TRACE("%s >>>\n", debugstr_w(prop->name));
2471 hres = IDispatchEx_InvokeEx(iface, prop->id, lcid, flags, params, res, ei, caller);
2473 TRACE("%s <<<\n", debugstr_w(prop->name));
2475 WARN("%s <<< %08x\n", debugstr_w(prop->name), hres);
2476 IDispatchEx_Release(iface);
2478 FIXME("No IDispatchEx\n");
2480 IDispatch_Release(disp);
2483 case GLOBAL_ELEMENTVAR:
2485 case DISPATCH_PROPERTYGET: {
2488 hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
2494 return DISP_E_MEMBERNOTFOUND;
2496 V_VT(res) = VT_DISPATCH;
2497 V_DISPATCH(res) = (IDispatch*)elem;
2500 case DISPATCH_PROPERTYPUT: {
2503 hres = dispex_get_dynid(&This->dispex, prop->name, &dispex_id);
2507 prop->type = GLOBAL_DISPEXVAR;
2508 prop->id = dispex_id;
2509 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, dispex_id, 0, flags, params, res, ei, caller);
2512 FIXME("Not supported flags: %x\n", flags);
2515 case GLOBAL_DISPEXVAR:
2516 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, prop->id, 0, flags, params, res, ei, caller);
2518 ERR("invalid type %d\n", prop->type);
2519 hres = DISP_E_MEMBERNOTFOUND;
2526 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl = {
2533 static const tid_t HTMLWindow_iface_tids[] = {
2541 static dispex_static_data_t HTMLWindow_dispex = {
2542 &HTMLWindow_dispex_vtbl,
2543 DispHTMLWindow2_tid,
2545 HTMLWindow_iface_tids
2548 HRESULT HTMLWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, HTMLWindow *parent, HTMLWindow **ret)
2553 window = heap_alloc_zero(sizeof(HTMLWindow));
2555 return E_OUTOFMEMORY;
2557 window->window_ref = heap_alloc(sizeof(windowref_t));
2558 if(!window->window_ref) {
2560 return E_OUTOFMEMORY;
2563 window->IHTMLWindow2_iface.lpVtbl = &HTMLWindow2Vtbl;
2564 window->IHTMLWindow3_iface.lpVtbl = &HTMLWindow3Vtbl;
2565 window->IHTMLWindow4_iface.lpVtbl = &HTMLWindow4Vtbl;
2566 window->IHTMLWindow5_iface.lpVtbl = &HTMLWindow5Vtbl;
2567 window->IHTMLWindow6_iface.lpVtbl = &HTMLWindow6Vtbl;
2568 window->IHTMLPrivateWindow_iface.lpVtbl = &HTMLPrivateWindowVtbl;
2569 window->IDispatchEx_iface.lpVtbl = &WindowDispExVtbl;
2570 window->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
2571 window->ITravelLogClient_iface.lpVtbl = &TravelLogClientVtbl;
2573 window->doc_obj = doc_obj;
2575 window->window_ref->window = window;
2576 window->window_ref->ref = 1;
2578 init_dispex(&window->dispex, (IUnknown*)&window->IHTMLWindow2_iface, &HTMLWindow_dispex);
2581 nsIDOMWindow_AddRef(nswindow);
2582 window->nswindow = nswindow;
2585 window->scriptmode = parent ? parent->scriptmode : SCRIPTMODE_GECKO;
2586 window->readystate = READYSTATE_UNINITIALIZED;
2587 list_init(&window->script_hosts);
2589 hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0);
2591 IHTMLWindow2_Release(&window->IHTMLWindow2_iface);
2595 window->task_magic = get_task_target_magic();
2596 update_window_doc(window);
2598 list_init(&window->children);
2599 list_add_head(&window_list, &window->entry);
2602 IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
2604 window->parent = parent;
2605 list_add_tail(&parent->children, &window->sibling_entry);
2612 void update_window_doc(HTMLWindow *window)
2614 nsIDOMHTMLDocument *nshtmldoc;
2615 nsIDOMDocument *nsdoc;
2618 nsres = nsIDOMWindow_GetDocument(window->nswindow, &nsdoc);
2619 if(NS_FAILED(nsres) || !nsdoc) {
2620 ERR("GetDocument failed: %08x\n", nsres);
2624 nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
2625 nsIDOMDocument_Release(nsdoc);
2626 if(NS_FAILED(nsres)) {
2627 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres);
2631 if(!window->doc || window->doc->nsdoc != nshtmldoc) {
2632 HTMLDocumentNode *doc;
2635 hres = create_doc_from_nsdoc(nshtmldoc, window->doc_obj, window, &doc);
2636 if(SUCCEEDED(hres)) {
2637 window_set_docnode(window, doc);
2638 htmldoc_release(&doc->basedoc);
2640 ERR("create_doc_from_nsdoc failed: %08x\n", hres);
2644 nsIDOMHTMLDocument_Release(nshtmldoc);
2647 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
2651 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) {
2652 if(iter->nswindow == nswindow)