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 static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
113 FIXME("No document\n");
117 return set_event_handler(&window->doc->body_event_target, NULL, window->doc, eid, var);
120 static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
123 FIXME("No document\n");
127 return get_event_handler(&window->doc->body_event_target, eid, var);
130 static inline HTMLWindow *impl_from_IHTMLWindow2(IHTMLWindow2 *iface)
132 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow2_iface);
135 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
137 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
141 if(IsEqualGUID(&IID_IUnknown, riid)) {
142 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
143 *ppv = &This->IHTMLWindow2_iface;
144 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
145 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
146 *ppv = &This->IHTMLWindow2_iface;
147 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
148 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
149 *ppv = &This->IDispatchEx_iface;
150 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2, riid)) {
151 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
152 *ppv = &This->IHTMLWindow2_iface;
153 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
154 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
155 *ppv = &This->IHTMLWindow2_iface;
156 }else if(IsEqualGUID(&IID_IHTMLWindow3, riid)) {
157 TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This, ppv);
158 *ppv = &This->IHTMLWindow3_iface;
159 }else if(IsEqualGUID(&IID_IHTMLWindow4, riid)) {
160 TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This, ppv);
161 *ppv = &This->IHTMLWindow4_iface;
162 }else if(IsEqualGUID(&IID_IHTMLWindow6, riid)) {
163 TRACE("(%p)->(IID_IHTMLWindow6 %p)\n", This, ppv);
164 *ppv = &This->IHTMLWindow6_iface;
165 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow, riid)) {
166 TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This, ppv);
167 *ppv = &This->IHTMLPrivateWindow_iface;
168 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
169 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
170 *ppv = &This->IServiceProvider_iface;
171 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
172 return *ppv ? S_OK : E_NOINTERFACE;
176 IUnknown_AddRef((IUnknown*)*ppv);
180 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
181 return E_NOINTERFACE;
184 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
186 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
187 LONG ref = InterlockedIncrement(&This->ref);
189 TRACE("(%p) ref=%d\n", This, ref);
194 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
196 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
197 LONG ref = InterlockedDecrement(&This->ref);
199 TRACE("(%p) ref=%d\n", This, ref);
204 remove_target_tasks(This->task_magic);
205 set_window_bscallback(This, NULL);
206 set_current_mon(This, NULL);
207 window_set_docnode(This, NULL);
208 release_children(This);
211 IInternetSecurityManager_Release(This->secmgr);
213 if(This->frame_element)
214 This->frame_element->content_window = NULL;
216 if(This->option_factory) {
217 This->option_factory->window = NULL;
218 IHTMLOptionElementFactory_Release(&This->option_factory->IHTMLOptionElementFactory_iface);
221 if(This->image_factory) {
222 This->image_factory->window = NULL;
223 IHTMLImageElementFactory_Release(&This->image_factory->IHTMLImageElementFactory_iface);
227 This->location->window = NULL;
228 IHTMLLocation_Release(&This->location->IHTMLLocation_iface);
232 IHTMLScreen_Release(This->screen);
234 for(i=0; i < This->global_prop_cnt; i++)
235 heap_free(This->global_props[i].name);
237 This->window_ref->window = NULL;
238 windowref_release(This->window_ref);
240 heap_free(This->global_props);
241 release_script_hosts(This);
244 nsIDOMWindow_Release(This->nswindow);
246 list_remove(&This->entry);
247 release_dispex(&This->dispex);
254 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
256 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
258 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
261 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
262 LCID lcid, ITypeInfo **ppTInfo)
264 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
266 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
269 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
270 LPOLESTR *rgszNames, UINT cNames,
271 LCID lcid, DISPID *rgDispId)
273 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
275 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
279 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
280 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
281 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
283 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
285 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
286 pDispParams, pVarResult, pExcepInfo, puArgErr);
289 static HRESULT get_frame_by_index(nsIDOMWindowCollection *nsFrames, PRUint32 index, HTMLWindow **ret)
292 nsIDOMWindow *nsWindow;
295 nsres = nsIDOMWindowCollection_GetLength(nsFrames, &length);
296 if(NS_FAILED(nsres)) {
297 FIXME("nsIDOMWindowCollection_GetLength failed: 0x%08x\n", nsres);
302 return DISP_E_MEMBERNOTFOUND;
304 nsres = nsIDOMWindowCollection_Item(nsFrames, index, &nsWindow);
305 if(NS_FAILED(nsres)) {
306 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
310 *ret = nswindow_to_window(nsWindow);
312 nsIDOMWindow_Release(nsWindow);
317 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
319 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
320 nsIDOMWindowCollection *nsFrames;
321 HTMLWindow *window = NULL;
325 TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
327 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nsFrames);
328 if(NS_FAILED(nsres)) {
329 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres);
333 switch(V_VT(pvarIndex)) {
335 int index = V_I4(pvarIndex);
336 TRACE("Getting index %d\n", index);
339 hres = get_frame_by_index(nsFrames, index, &window);
343 unsigned int index = V_UINT(pvarIndex);
344 TRACE("Getting index %u\n", index);
345 hres = get_frame_by_index(nsFrames, index, &window);
349 BSTR str = V_BSTR(pvarIndex);
352 TRACE("Getting name %s\n", wine_dbgstr_w(str));
354 nsIDOMWindowCollection_GetLength(nsFrames, &length);
357 for(i = 0; i < length && !window; ++i) {
358 HTMLWindow *cur_window;
359 nsIDOMWindow *nsWindow;
362 nsres = nsIDOMWindowCollection_Item(nsFrames, i, &nsWindow);
363 if(NS_FAILED(nsres)) {
364 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
369 cur_window = nswindow_to_window(nsWindow);
371 nsIDOMWindow_Release(nsWindow);
373 hres = IHTMLElement_get_id(&cur_window->frame_element->element.IHTMLElement_iface, &id);
375 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres);
379 if(!strcmpW(id, str))
390 nsIDOMWindowCollection_Release(nsFrames);
394 return DISP_E_MEMBERNOTFOUND;
396 IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
397 V_VT(pvarResult) = VT_DISPATCH;
398 V_DISPATCH(pvarResult) = (IDispatch*)window;
402 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
404 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
405 nsIDOMWindowCollection *nscollection;
409 TRACE("(%p)->(%p)\n", This, p);
411 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nscollection);
412 if(NS_FAILED(nsres)) {
413 ERR("GetFrames failed: %08x\n", nsres);
417 nsres = nsIDOMWindowCollection_GetLength(nscollection, &length);
418 nsIDOMWindowCollection_Release(nscollection);
419 if(NS_FAILED(nsres)) {
420 ERR("GetLength failed: %08x\n", nsres);
428 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
430 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
431 FIXME("(%p)->(%p): semi-stub\n", This, p);
433 /* FIXME: Should return a separate Window object */
434 *p = (IHTMLFramesCollection2*)&This->IHTMLWindow2_iface;
435 HTMLWindow2_AddRef(iface);
439 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
441 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
442 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
446 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
448 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
449 FIXME("(%p)->(%p)\n", This, p);
453 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
455 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
457 WARN("(%p)->(%s)\n", This, debugstr_w(v));
460 * FIXME: Since IE7, setting status is blocked, but still possible in certain circumstances.
461 * Ignoring the call should be enough for us.
466 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
468 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
470 TRACE("(%p)->(%p)\n", This, p);
477 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
478 LONG msec, VARIANT *language, LONG *timerID)
480 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
483 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
485 V_VT(&expr_var) = VT_BSTR;
486 V_BSTR(&expr_var) = expression;
488 return IHTMLWindow3_setTimeout(&This->IHTMLWindow3_iface, &expr_var, msec, language, timerID);
491 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID)
493 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
495 TRACE("(%p)->(%d)\n", This, timerID);
497 return clear_task_timer(&This->doc->basedoc, FALSE, timerID);
500 #define MAX_MESSAGE_LEN 2000
502 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
504 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
505 WCHAR title[100], *msg = message;
508 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
510 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, title,
511 sizeof(title)/sizeof(WCHAR))) {
512 WARN("Could not load message box title: %d\n", GetLastError());
516 len = SysStringLen(message);
517 if(len > MAX_MESSAGE_LEN) {
518 msg = heap_alloc((MAX_MESSAGE_LEN+1)*sizeof(WCHAR));
520 return E_OUTOFMEMORY;
521 memcpy(msg, message, MAX_MESSAGE_LEN*sizeof(WCHAR));
522 msg[MAX_MESSAGE_LEN] = 0;
525 MessageBoxW(This->doc_obj->hwnd, msg, title, MB_ICONWARNING);
531 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
532 VARIANT_BOOL *confirmed)
534 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
537 TRACE("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
539 if(!confirmed) return E_INVALIDARG;
541 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
542 sizeof(wszTitle)/sizeof(WCHAR))) {
543 WARN("Could not load message box title: %d\n", GetLastError());
544 *confirmed = VARIANT_TRUE;
548 if(MessageBoxW(This->doc_obj->hwnd, message, wszTitle,
549 MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
550 *confirmed = VARIANT_TRUE;
551 else *confirmed = VARIANT_FALSE;
563 static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
564 WPARAM wparam, LPARAM lparam)
570 prompt_arg *arg = (prompt_arg*)lparam;
573 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
574 sizeof(wszTitle)/sizeof(WCHAR))) {
575 WARN("Could not load message box title: %d\n", GetLastError());
576 EndDialog(hwnd, wparam);
580 SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
581 SetWindowTextW(hwnd, wszTitle);
582 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_PROMPT), arg->message);
583 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_EDIT), arg->dststr);
589 case MAKEWPARAM(IDCANCEL, BN_CLICKED):
590 EndDialog(hwnd, wparam);
592 case MAKEWPARAM(IDOK, BN_CLICKED):
595 (prompt_arg*)GetWindowLongPtrW(hwnd, DWLP_USER);
596 HWND hwndPrompt = GetDlgItem(hwnd, ID_PROMPT_EDIT);
597 INT len = GetWindowTextLengthW(hwndPrompt);
601 EndDialog(hwnd, wparam);
605 V_VT(arg->textdata) = VT_BSTR;
606 if(!len && !arg->dststr)
607 V_BSTR(arg->textdata) = NULL;
610 V_BSTR(arg->textdata) = SysAllocStringLen(NULL, len);
611 GetWindowTextW(hwndPrompt, V_BSTR(arg->textdata), len+1);
613 EndDialog(hwnd, wparam);
619 EndDialog(hwnd, IDCANCEL);
626 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
627 BSTR dststr, VARIANT *textdata)
629 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
632 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
634 if(textdata) V_VT(textdata) = VT_NULL;
636 arg.message = message;
638 arg.textdata = textdata;
640 DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
641 This->doc_obj->hwnd, prompt_dlgproc, (LPARAM)&arg);
645 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
647 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
649 TRACE("(%p)->(%p)\n", This, p);
651 if(!This->image_factory)
652 This->image_factory = HTMLImageElementFactory_Create(This);
654 *p = &This->image_factory->IHTMLImageElementFactory_iface;
655 IHTMLImageElementFactory_AddRef(*p);
660 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
662 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
663 HTMLLocation *location;
666 TRACE("(%p)->(%p)\n", This, p);
668 hres = get_location(This, &location);
672 *p = &location->IHTMLLocation_iface;
676 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
678 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
679 FIXME("(%p)->(%p)\n", This, p);
683 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
685 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
686 FIXME("(%p)->()\n", This);
690 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
692 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
693 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
697 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
699 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
700 FIXME("(%p)->(%p)\n", This, p);
704 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
706 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
708 TRACE("(%p)->(%p)\n", This, p);
710 *p = OmNavigator_Create();
714 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
716 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
720 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
722 nsAString_InitDepend(&name_str, v);
723 nsres = nsIDOMWindow_SetName(This->nswindow, &name_str);
724 nsAString_Finish(&name_str);
726 ERR("SetName failed: %08x\n", nsres);
731 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
733 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
738 TRACE("(%p)->(%p)\n", This, p);
740 nsAString_Init(&name_str, NULL);
741 nsres = nsIDOMWindow_GetName(This->nswindow, &name_str);
742 if(NS_SUCCEEDED(nsres)) {
743 const PRUnichar *name;
745 nsAString_GetData(&name_str, &name);
747 *p = SysAllocString(name);
748 hres = *p ? S_OK : E_OUTOFMEMORY;
754 ERR("GetName failed: %08x\n", nsres);
757 nsAString_Finish(&name_str);
762 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
764 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
765 TRACE("(%p)->(%p)\n", This, p);
768 *p = &This->parent->IHTMLWindow2_iface;
769 IHTMLWindow2_AddRef(*p);
776 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
777 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
779 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
780 INewWindowManager *new_window_mgr;
784 TRACE("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
785 debugstr_w(features), replace, pomWindowResult);
790 if(name && *name == '_') {
791 FIXME("Unsupported name %s\n", debugstr_w(name));
795 hres = do_query_service((IUnknown*)This->doc_obj->client, &SID_SNewWindowManager, &IID_INewWindowManager,
796 (void**)&new_window_mgr);
798 FIXME("No INewWindowManager\n");
802 hres = INewWindowManager_EvaluateNewWindow(new_window_mgr, url, name, This->url,
803 features, !!replace, This->doc_obj->has_popup ? 0 : NWMF_FIRST, 0);
804 INewWindowManager_Release(new_window_mgr);
805 This->doc_obj->has_popup = TRUE;
807 *pomWindowResult = NULL;
812 hres = CoInternetCombineUrlEx(This->uri, url, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO, &uri, 0);
814 hres = CreateUri(url, 0, 0, &uri);
818 hres = navigate_new_window(This, uri, name, pomWindowResult);
823 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
825 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
827 TRACE("(%p)->(%p)\n", This, p);
829 /* FIXME: We should return kind of proxy window here. */
830 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
831 *p = &This->IHTMLWindow2_iface;
835 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
837 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
839 TRACE("(%p)->(%p)\n", This, p);
844 *p = &curr->IHTMLWindow2_iface;
845 IHTMLWindow2_AddRef(*p);
850 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
852 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
854 TRACE("(%p)->(%p)\n", This, p);
856 /* FIXME: We should return kind of proxy window here. */
857 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
858 *p = &This->IHTMLWindow2_iface;
862 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
864 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
865 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
869 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
871 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
872 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
876 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
878 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
879 FIXME("(%p)->(%p)\n", This, p);
883 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
885 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
886 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
890 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
892 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
893 FIXME("(%p)->(%p)\n", This, p);
897 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
899 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
901 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
903 return set_window_event(This, EVENTID_LOAD, &v);
906 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
908 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
910 TRACE("(%p)->(%p)\n", This, p);
912 return get_window_event(This, EVENTID_LOAD, p);
915 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
917 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
919 TRACE("(%p)->(v(%d))\n", This, V_VT(&v));
921 return set_window_event(This, EVENTID_BEFOREUNLOAD, &v);
924 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
926 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
928 TRACE("(%p)->(%p)\n", This, p);
930 return get_window_event(This, EVENTID_BEFOREUNLOAD, p);
933 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
935 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
936 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
940 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
942 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
943 FIXME("(%p)->(%p)\n", This, p);
947 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
949 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
950 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
954 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
956 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
957 FIXME("(%p)->(%p)\n", This, p);
961 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
963 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
964 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
968 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
970 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
971 FIXME("(%p)->(%p)\n", This, p);
975 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
977 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
979 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
981 return set_window_event(This, EVENTID_RESIZE, &v);
984 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
986 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
988 TRACE("(%p)->(%p)\n", This, p);
990 return get_window_event(This, EVENTID_RESIZE, p);
993 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
995 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
996 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
1000 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
1002 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1003 FIXME("(%p)->(%p)\n", This, p);
1007 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
1009 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1011 TRACE("(%p)->(%p)\n", This, p);
1014 /* FIXME: We should return a wrapper object here */
1015 *p = &This->doc->basedoc.IHTMLDocument2_iface;
1016 IHTMLDocument2_AddRef(*p);
1024 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
1026 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1028 TRACE("(%p)->(%p)\n", This, p);
1031 IHTMLEventObj_AddRef(This->event);
1036 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
1038 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1039 FIXME("(%p)->(%p)\n", This, p);
1043 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
1044 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
1046 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1047 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
1051 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
1054 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1055 FIXME("(%p)->(%s v(%d) %s)\n", This, debugstr_w(helpURL), V_VT(&helpArg), debugstr_w(features));
1059 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
1061 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1063 TRACE("(%p)->(%p)\n", This, p);
1068 hres = HTMLScreen_Create(&This->screen);
1074 IHTMLScreen_AddRef(This->screen);
1078 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
1080 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1082 TRACE("(%p)->(%p)\n", This, p);
1084 if(!This->option_factory)
1085 This->option_factory = HTMLOptionElementFactory_Create(This);
1087 *p = &This->option_factory->IHTMLOptionElementFactory_iface;
1088 IHTMLOptionElementFactory_AddRef(*p);
1093 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
1095 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1097 TRACE("(%p)->()\n", This);
1100 SetFocus(This->doc_obj->hwnd);
1104 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
1106 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1107 FIXME("(%p)->(%p)\n", This, p);
1111 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
1113 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1114 FIXME("(%p)->()\n", This);
1118 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, LONG x, LONG y)
1120 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1121 FIXME("(%p)->(%d %d)\n", This, x, y);
1125 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
1127 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1128 FIXME("(%p)->(%p)\n", This, p);
1132 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
1133 LONG msec, VARIANT *language, LONG *timerID)
1135 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1138 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
1140 V_VT(&expr) = VT_BSTR;
1141 V_BSTR(&expr) = expression;
1142 return IHTMLWindow3_setInterval(&This->IHTMLWindow3_iface, &expr, msec, language, timerID);
1145 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerID)
1147 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1149 TRACE("(%p)->(%d)\n", This, timerID);
1151 return clear_task_timer(&This->doc->basedoc, TRUE, timerID);
1154 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
1156 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1157 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
1161 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
1163 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1164 FIXME("(%p)->(%p)\n", This, p);
1168 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
1171 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1173 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
1175 return exec_script(This, scode, language, pvarRet);
1178 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
1180 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1182 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1184 TRACE("(%p)->(%p)\n", This, String);
1187 return E_INVALIDARG;
1189 *String = SysAllocString(objectW);
1190 return *String ? S_OK : E_OUTOFMEMORY;
1193 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, LONG x, LONG y)
1195 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1198 TRACE("(%p)->(%d %d)\n", This, x, y);
1200 nsres = nsIDOMWindow_ScrollBy(This->nswindow, x, y);
1201 if(NS_FAILED(nsres))
1202 ERR("ScrollBy failed: %08x\n", nsres);
1207 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, LONG x, LONG y)
1209 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1212 TRACE("(%p)->(%d %d)\n", This, x, y);
1214 nsres = nsIDOMWindow_ScrollTo(This->nswindow, x, y);
1215 if(NS_FAILED(nsres))
1216 ERR("ScrollTo failed: %08x\n", nsres);
1221 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, LONG x, LONG y)
1223 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1224 FIXME("(%p)->(%d %d)\n", This, x, y);
1228 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, LONG x, LONG y)
1230 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1231 FIXME("(%p)->(%d %d)\n", This, x, y);
1235 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, LONG x, LONG y)
1237 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1238 FIXME("(%p)->(%d %d)\n", This, x, y);
1242 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, LONG x, LONG y)
1244 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1245 FIXME("(%p)->(%d %d)\n", This, x, y);
1249 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
1251 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1253 TRACE("(%p)->(%p)\n", This, p);
1257 if(!This->doc_obj->hostui)
1260 return IDocHostUIHandler_GetExternal(This->doc_obj->hostui, p);
1263 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
1264 HTMLWindow2_QueryInterface,
1266 HTMLWindow2_Release,
1267 HTMLWindow2_GetTypeInfoCount,
1268 HTMLWindow2_GetTypeInfo,
1269 HTMLWindow2_GetIDsOfNames,
1272 HTMLWindow2_get_length,
1273 HTMLWindow2_get_frames,
1274 HTMLWindow2_put_defaultStatus,
1275 HTMLWindow2_get_defaultStatus,
1276 HTMLWindow2_put_status,
1277 HTMLWindow2_get_status,
1278 HTMLWindow2_setTimeout,
1279 HTMLWindow2_clearTimeout,
1281 HTMLWindow2_confirm,
1283 HTMLWindow2_get_Image,
1284 HTMLWindow2_get_location,
1285 HTMLWindow2_get_history,
1287 HTMLWindow2_put_opener,
1288 HTMLWindow2_get_opener,
1289 HTMLWindow2_get_navigator,
1290 HTMLWindow2_put_name,
1291 HTMLWindow2_get_name,
1292 HTMLWindow2_get_parent,
1294 HTMLWindow2_get_self,
1295 HTMLWindow2_get_top,
1296 HTMLWindow2_get_window,
1297 HTMLWindow2_navigate,
1298 HTMLWindow2_put_onfocus,
1299 HTMLWindow2_get_onfocus,
1300 HTMLWindow2_put_onblur,
1301 HTMLWindow2_get_onblur,
1302 HTMLWindow2_put_onload,
1303 HTMLWindow2_get_onload,
1304 HTMLWindow2_put_onbeforeunload,
1305 HTMLWindow2_get_onbeforeunload,
1306 HTMLWindow2_put_onunload,
1307 HTMLWindow2_get_onunload,
1308 HTMLWindow2_put_onhelp,
1309 HTMLWindow2_get_onhelp,
1310 HTMLWindow2_put_onerror,
1311 HTMLWindow2_get_onerror,
1312 HTMLWindow2_put_onresize,
1313 HTMLWindow2_get_onresize,
1314 HTMLWindow2_put_onscroll,
1315 HTMLWindow2_get_onscroll,
1316 HTMLWindow2_get_document,
1317 HTMLWindow2_get_event,
1318 HTMLWindow2_get__newEnum,
1319 HTMLWindow2_showModalDialog,
1320 HTMLWindow2_showHelp,
1321 HTMLWindow2_get_screen,
1322 HTMLWindow2_get_Option,
1324 HTMLWindow2_get_closed,
1327 HTMLWindow2_get_clientInformation,
1328 HTMLWindow2_setInterval,
1329 HTMLWindow2_clearInterval,
1330 HTMLWindow2_put_offscreenBuffering,
1331 HTMLWindow2_get_offscreenBuffering,
1332 HTMLWindow2_execScript,
1333 HTMLWindow2_toString,
1334 HTMLWindow2_scrollBy,
1335 HTMLWindow2_scrollTo,
1338 HTMLWindow2_resizeTo,
1339 HTMLWindow2_resizeBy,
1340 HTMLWindow2_get_external
1343 static inline HTMLWindow *impl_from_IHTMLWindow3(IHTMLWindow3 *iface)
1345 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow3_iface);
1348 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
1350 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1352 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1355 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
1357 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1359 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1362 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
1364 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1366 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1369 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
1371 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1373 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1376 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
1377 LCID lcid, ITypeInfo **ppTInfo)
1379 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1381 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1384 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
1385 LPOLESTR *rgszNames, UINT cNames,
1386 LCID lcid, DISPID *rgDispId)
1388 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1390 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1394 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
1395 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1396 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1398 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1400 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1401 pDispParams, pVarResult, pExcepInfo, puArgErr);
1404 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, LONG *p)
1406 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1407 FIXME("(%p)->(%p)\n", This, p);
1411 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, LONG *p)
1413 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1414 FIXME("(%p)->(%p)\n", This, p);
1418 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
1420 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1422 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
1425 FIXME("No document\n");
1429 return attach_event(&This->doc->body_event_target, NULL, &This->doc->basedoc, event, pDisp, pfResult);
1432 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
1434 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1435 FIXME("(%p)->()\n", This);
1439 static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, LONG msec, VARIANT *language,
1440 BOOL interval, LONG *timer_id)
1442 IDispatch *disp = NULL;
1444 switch(V_VT(expr)) {
1446 disp = V_DISPATCH(expr);
1447 IDispatch_AddRef(disp);
1451 disp = script_parse_event(This, V_BSTR(expr));
1455 FIXME("unimplemented vt=%d\n", V_VT(expr));
1462 *timer_id = set_task_timer(&This->doc->basedoc, msec, interval, disp);
1463 IDispatch_Release(disp);
1468 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1469 VARIANT *language, LONG *timerID)
1471 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1473 TRACE("(%p)->(%p(%d) %d %p %p)\n", This, expression, V_VT(expression), msec, language, timerID);
1475 return window_set_timer(This, expression, msec, language, FALSE, timerID);
1478 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1479 VARIANT *language, LONG *timerID)
1481 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1483 TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID);
1485 return window_set_timer(This, expression, msec, language, TRUE, timerID);
1488 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
1490 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1491 FIXME("(%p)\n", This);
1495 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
1497 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1498 FIXME("(%p)->()\n", This);
1502 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
1504 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1505 FIXME("(%p)->(%p)\n", This, p);
1509 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
1511 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1512 FIXME("(%p)->()\n", This);
1516 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
1518 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1519 FIXME("(%p)->(%p)\n", This, p);
1523 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
1525 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1526 FIXME("(%p)->(%p)\n", This, p);
1530 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
1531 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
1533 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1534 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
1538 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
1539 HTMLWindow3_QueryInterface,
1541 HTMLWindow3_Release,
1542 HTMLWindow3_GetTypeInfoCount,
1543 HTMLWindow3_GetTypeInfo,
1544 HTMLWindow3_GetIDsOfNames,
1546 HTMLWindow3_get_screenLeft,
1547 HTMLWindow3_get_screenTop,
1548 HTMLWindow3_attachEvent,
1549 HTMLWindow3_detachEvent,
1550 HTMLWindow3_setTimeout,
1551 HTMLWindow3_setInterval,
1553 HTMLWindow3_put_onbeforeprint,
1554 HTMLWindow3_get_onbeforeprint,
1555 HTMLWindow3_put_onafterprint,
1556 HTMLWindow3_get_onafterprint,
1557 HTMLWindow3_get_clipboardData,
1558 HTMLWindow3_showModelessDialog
1561 static inline HTMLWindow *impl_from_IHTMLWindow4(IHTMLWindow4 *iface)
1563 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow4_iface);
1566 static HRESULT WINAPI HTMLWindow4_QueryInterface(IHTMLWindow4 *iface, REFIID riid, void **ppv)
1568 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1570 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1573 static ULONG WINAPI HTMLWindow4_AddRef(IHTMLWindow4 *iface)
1575 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1577 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1580 static ULONG WINAPI HTMLWindow4_Release(IHTMLWindow4 *iface)
1582 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1584 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1587 static HRESULT WINAPI HTMLWindow4_GetTypeInfoCount(IHTMLWindow4 *iface, UINT *pctinfo)
1589 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1591 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1594 static HRESULT WINAPI HTMLWindow4_GetTypeInfo(IHTMLWindow4 *iface, UINT iTInfo,
1595 LCID lcid, ITypeInfo **ppTInfo)
1597 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1599 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1602 static HRESULT WINAPI HTMLWindow4_GetIDsOfNames(IHTMLWindow4 *iface, REFIID riid,
1603 LPOLESTR *rgszNames, UINT cNames,
1604 LCID lcid, DISPID *rgDispId)
1606 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1608 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1612 static HRESULT WINAPI HTMLWindow4_Invoke(IHTMLWindow4 *iface, DISPID dispIdMember,
1613 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1614 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1616 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1618 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1619 pDispParams, pVarResult, pExcepInfo, puArgErr);
1622 static HRESULT WINAPI HTMLWindow4_createPopup(IHTMLWindow4 *iface, VARIANT *varArgIn,
1623 IDispatch **ppPopup)
1625 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1626 FIXME("(%p)->(%p %p)\n", This, varArgIn, ppPopup);
1630 static HRESULT WINAPI HTMLWindow4_get_frameElement(IHTMLWindow4 *iface, IHTMLFrameBase **p)
1632 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1633 TRACE("(%p)->(%p)\n", This, p);
1635 if(This->frame_element) {
1636 *p = &This->frame_element->IHTMLFrameBase_iface;
1637 IHTMLFrameBase_AddRef(*p);
1644 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl = {
1645 HTMLWindow4_QueryInterface,
1647 HTMLWindow4_Release,
1648 HTMLWindow4_GetTypeInfoCount,
1649 HTMLWindow4_GetTypeInfo,
1650 HTMLWindow4_GetIDsOfNames,
1652 HTMLWindow4_createPopup,
1653 HTMLWindow4_get_frameElement
1656 static inline HTMLWindow *impl_from_IHTMLWindow6(IHTMLWindow6 *iface)
1658 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow6_iface);
1661 static HRESULT WINAPI HTMLWindow6_QueryInterface(IHTMLWindow6 *iface, REFIID riid, void **ppv)
1663 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1665 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1668 static ULONG WINAPI HTMLWindow6_AddRef(IHTMLWindow6 *iface)
1670 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1672 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1675 static ULONG WINAPI HTMLWindow6_Release(IHTMLWindow6 *iface)
1677 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1679 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1682 static HRESULT WINAPI HTMLWindow6_GetTypeInfoCount(IHTMLWindow6 *iface, UINT *pctinfo)
1684 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1686 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1689 static HRESULT WINAPI HTMLWindow6_GetTypeInfo(IHTMLWindow6 *iface, UINT iTInfo,
1690 LCID lcid, ITypeInfo **ppTInfo)
1692 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1694 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1697 static HRESULT WINAPI HTMLWindow6_GetIDsOfNames(IHTMLWindow6 *iface, REFIID riid,
1698 LPOLESTR *rgszNames, UINT cNames,
1699 LCID lcid, DISPID *rgDispId)
1701 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1703 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1707 static HRESULT WINAPI HTMLWindow6_Invoke(IHTMLWindow6 *iface, DISPID dispIdMember,
1708 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1709 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1711 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1713 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1714 pDispParams, pVarResult, pExcepInfo, puArgErr);
1717 static HRESULT WINAPI HTMLWindow6_put_XDomainRequest(IHTMLWindow6 *iface, VARIANT v)
1719 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1720 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1724 static HRESULT WINAPI HTMLWindow6_get_XDomainRequest(IHTMLWindow6 *iface, VARIANT *p)
1726 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1727 FIXME("(%p)->(%p)\n", This, p);
1731 static HRESULT WINAPI HTMLWindow6_get_sessionStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1733 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1734 FIXME("(%p)->(%p)\n", This, p);
1738 static HRESULT WINAPI HTMLWindow6_get_localStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1740 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1741 FIXME("(%p)->(%p)\n", This, p);
1745 static HRESULT WINAPI HTMLWindow6_put_onhashchange(IHTMLWindow6 *iface, VARIANT v)
1747 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1748 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1752 static HRESULT WINAPI HTMLWindow6_get_onhashchange(IHTMLWindow6 *iface, VARIANT *p)
1754 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1755 FIXME("(%p)->(%p)\n", This, p);
1759 static HRESULT WINAPI HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6 *iface, LONG *p)
1761 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1762 FIXME("(%p)->(%p)\n", This, p);
1766 static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VARIANT targetOrigin)
1768 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1769 FIXME("(%p)->(%s %s)\n", This, debugstr_w(msg), debugstr_variant(&targetOrigin));
1773 static HRESULT WINAPI HTMLWindow6_toStaticHTML(IHTMLWindow6 *iface, BSTR bstrHTML, BSTR *pbstrStaticHTML)
1775 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1776 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrHTML), pbstrStaticHTML);
1780 static HRESULT WINAPI HTMLWindow6_put_onmessage(IHTMLWindow6 *iface, VARIANT v)
1782 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1783 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1787 static HRESULT WINAPI HTMLWindow6_get_onmessage(IHTMLWindow6 *iface, VARIANT *p)
1789 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1790 FIXME("(%p)->(%p)\n", This, p);
1794 static HRESULT WINAPI HTMLWindow6_msWriteProfilerMark(IHTMLWindow6 *iface, BSTR bstrProfilerMark)
1796 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1797 FIXME("(%p)->(%s)\n", This, debugstr_w(bstrProfilerMark));
1801 static const IHTMLWindow6Vtbl HTMLWindow6Vtbl = {
1802 HTMLWindow6_QueryInterface,
1804 HTMLWindow6_Release,
1805 HTMLWindow6_GetTypeInfoCount,
1806 HTMLWindow6_GetTypeInfo,
1807 HTMLWindow6_GetIDsOfNames,
1809 HTMLWindow6_put_XDomainRequest,
1810 HTMLWindow6_get_XDomainRequest,
1811 HTMLWindow6_get_sessionStorage,
1812 HTMLWindow6_get_localStorage,
1813 HTMLWindow6_put_onhashchange,
1814 HTMLWindow6_get_onhashchange,
1815 HTMLWindow6_get_maxConnectionsPerServer,
1816 HTMLWindow6_postMessage,
1817 HTMLWindow6_toStaticHTML,
1818 HTMLWindow6_put_onmessage,
1819 HTMLWindow6_get_onmessage,
1820 HTMLWindow6_msWriteProfilerMark
1823 static inline HTMLWindow *impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow *iface)
1825 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLPrivateWindow_iface);
1828 static HRESULT WINAPI HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow *iface, REFIID riid, void **ppv)
1830 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1832 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1835 static ULONG WINAPI HTMLPrivateWindow_AddRef(IHTMLPrivateWindow *iface)
1837 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1839 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1842 static ULONG WINAPI HTMLPrivateWindow_Release(IHTMLPrivateWindow *iface)
1844 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1846 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1849 static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface, BSTR url, BSTR arg2, BSTR arg3,
1850 BSTR arg4, VARIANT *post_data_var, VARIANT *headers_var, ULONG flags)
1852 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1853 OLECHAR *translated_url = NULL;
1854 DWORD post_data_size = 0;
1855 BYTE *post_data = NULL;
1856 WCHAR *headers = NULL;
1860 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This, debugstr_w(url), debugstr_w(arg2), debugstr_w(arg3), debugstr_w(arg4),
1861 debugstr_variant(post_data_var), debugstr_variant(headers_var), flags);
1863 if(This->doc_obj->hostui) {
1864 hres = IDocHostUIHandler_TranslateUrl(This->doc_obj->hostui, 0, url, &translated_url);
1866 translated_url = NULL;
1869 hres = CreateUri(translated_url ? translated_url : url, 0, 0, &uri);
1870 CoTaskMemFree(translated_url);
1875 if(V_VT(post_data_var) == (VT_ARRAY|VT_UI1)) {
1876 SafeArrayAccessData(V_ARRAY(post_data_var), (void**)&post_data);
1877 post_data_size = V_ARRAY(post_data_var)->rgsabound[0].cElements;
1881 if(headers_var && V_VT(headers_var) != VT_EMPTY && V_VT(headers_var) != VT_ERROR) {
1882 if(V_VT(headers_var) != VT_BSTR)
1883 return E_INVALIDARG;
1885 headers = V_BSTR(headers_var);
1888 hres = super_navigate(This, uri, headers, post_data, post_data_size);
1891 SafeArrayUnaccessData(V_ARRAY(post_data_var));
1896 static HRESULT WINAPI HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow *iface, BSTR *url)
1898 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1899 FIXME("(%p)->(%p)\n", This, url);
1903 static HRESULT WINAPI HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow *iface, IOleCommandTarget *cmdtrg)
1905 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1906 FIXME("(%p)->(%p)\n", This, cmdtrg);
1910 static HRESULT WINAPI HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow *iface, int arg)
1912 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1913 FIXME("(%p)->(%x)\n", This, arg);
1917 static HRESULT WINAPI HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow *iface, LPCWSTR name, IHTMLWindow2 **ret)
1919 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1920 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), ret);
1924 static HRESULT WINAPI HTMLPrivateWindow_GetAddressBarUrl(IHTMLPrivateWindow *iface, BSTR *url)
1926 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1927 TRACE("(%p)->(%p)\n", This, url);
1930 return E_INVALIDARG;
1932 *url = SysAllocString(This->url);
1936 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl = {
1937 HTMLPrivateWindow_QueryInterface,
1938 HTMLPrivateWindow_AddRef,
1939 HTMLPrivateWindow_Release,
1940 HTMLPrivateWindow_SuperNavigate,
1941 HTMLPrivateWindow_GetPendingUrl,
1942 HTMLPrivateWindow_SetPICSTarget,
1943 HTMLPrivateWindow_PICSComplete,
1944 HTMLPrivateWindow_FindWindowByName,
1945 HTMLPrivateWindow_GetAddressBarUrl
1948 static inline HTMLWindow *impl_from_IDispatchEx(IDispatchEx *iface)
1950 return CONTAINING_RECORD(iface, HTMLWindow, IDispatchEx_iface);
1953 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1955 HTMLWindow *This = impl_from_IDispatchEx(iface);
1957 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1960 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
1962 HTMLWindow *This = impl_from_IDispatchEx(iface);
1964 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1967 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
1969 HTMLWindow *This = impl_from_IDispatchEx(iface);
1971 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1974 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1976 HTMLWindow *This = impl_from_IDispatchEx(iface);
1978 TRACE("(%p)->(%p)\n", This, pctinfo);
1980 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1983 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1984 LCID lcid, ITypeInfo **ppTInfo)
1986 HTMLWindow *This = impl_from_IDispatchEx(iface);
1988 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1990 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1993 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1994 LPOLESTR *rgszNames, UINT cNames,
1995 LCID lcid, DISPID *rgDispId)
1997 HTMLWindow *This = impl_from_IDispatchEx(iface);
2001 WARN("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
2004 for(i=0; i < cNames; i++) {
2005 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
2006 hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
2014 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
2015 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2016 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2018 HTMLWindow *This = impl_from_IDispatchEx(iface);
2020 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
2021 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2023 /* FIXME: Use script dispatch */
2025 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2026 pDispParams, pVarResult, pExcepInfo, puArgErr);
2029 static global_prop_t *alloc_global_prop(HTMLWindow *This, global_prop_type_t type, BSTR name)
2031 if(This->global_prop_cnt == This->global_prop_size) {
2032 global_prop_t *new_props;
2035 if(This->global_props) {
2036 new_size = This->global_prop_size*2;
2037 new_props = heap_realloc(This->global_props, new_size*sizeof(global_prop_t));
2040 new_props = heap_alloc(new_size*sizeof(global_prop_t));
2044 This->global_props = new_props;
2045 This->global_prop_size = new_size;
2048 This->global_props[This->global_prop_cnt].name = heap_strdupW(name);
2049 if(!This->global_props[This->global_prop_cnt].name)
2052 This->global_props[This->global_prop_cnt].type = type;
2053 return This->global_props + This->global_prop_cnt++;
2056 static inline DWORD prop_to_dispid(HTMLWindow *This, global_prop_t *prop)
2058 return MSHTML_DISPID_CUSTOM_MIN + (prop-This->global_props);
2061 HRESULT search_window_props(HTMLWindow *This, BSTR bstrName, DWORD grfdex, DISPID *pid)
2064 ScriptHost *script_host;
2067 for(i=0; i < This->global_prop_cnt; i++) {
2068 /* FIXME: case sensitivity */
2069 if(!strcmpW(This->global_props[i].name, bstrName)) {
2070 *pid = MSHTML_DISPID_CUSTOM_MIN+i;
2075 if(find_global_prop(This, bstrName, grfdex, &script_host, &id)) {
2076 global_prop_t *prop;
2078 prop = alloc_global_prop(This, GLOBAL_SCRIPTVAR, bstrName);
2080 return E_OUTOFMEMORY;
2082 prop->script_host = script_host;
2085 *pid = prop_to_dispid(This, prop);
2089 return DISP_E_UNKNOWNNAME;
2092 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
2094 HTMLWindow *This = impl_from_IDispatchEx(iface);
2097 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
2099 hres = search_window_props(This, bstrName, grfdex, pid);
2100 if(hres != DISP_E_UNKNOWNNAME)
2103 hres = IDispatchEx_GetDispID(&This->dispex.IDispatchEx_iface, bstrName, grfdex, pid);
2104 if(hres != DISP_E_UNKNOWNNAME)
2108 global_prop_t *prop;
2111 hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
2113 if(SUCCEEDED(hres) && elem) {
2114 IHTMLElement_Release(elem);
2116 prop = alloc_global_prop(This, GLOBAL_ELEMENTVAR, bstrName);
2118 return E_OUTOFMEMORY;
2120 *pid = prop_to_dispid(This, prop);
2125 return DISP_E_UNKNOWNNAME;
2128 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
2129 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
2131 HTMLWindow *This = impl_from_IDispatchEx(iface);
2133 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
2135 if(id == DISPID_IHTMLWINDOW2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT)) {
2136 HTMLLocation *location;
2139 TRACE("forwarding to location.href\n");
2141 hres = get_location(This, &location);
2145 hres = IDispatchEx_InvokeEx(&location->dispex.IDispatchEx_iface, DISPID_VALUE, lcid,
2146 wFlags, pdp, pvarRes, pei, pspCaller);
2147 IHTMLLocation_Release(&location->IHTMLLocation_iface);
2151 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes,
2155 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
2157 HTMLWindow *This = impl_from_IDispatchEx(iface);
2159 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
2161 return IDispatchEx_DeleteMemberByName(&This->dispex.IDispatchEx_iface, bstrName, grfdex);
2164 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
2166 HTMLWindow *This = impl_from_IDispatchEx(iface);
2168 TRACE("(%p)->(%x)\n", This, id);
2170 return IDispatchEx_DeleteMemberByDispID(&This->dispex.IDispatchEx_iface, id);
2173 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
2175 HTMLWindow *This = impl_from_IDispatchEx(iface);
2177 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
2179 return IDispatchEx_GetMemberProperties(&This->dispex.IDispatchEx_iface, id, grfdexFetch,
2183 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
2185 HTMLWindow *This = impl_from_IDispatchEx(iface);
2187 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
2189 return IDispatchEx_GetMemberName(&This->dispex.IDispatchEx_iface, id, pbstrName);
2192 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
2194 HTMLWindow *This = impl_from_IDispatchEx(iface);
2196 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
2198 return IDispatchEx_GetNextDispID(&This->dispex.IDispatchEx_iface, grfdex, id, pid);
2201 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
2203 HTMLWindow *This = impl_from_IDispatchEx(iface);
2205 TRACE("(%p)->(%p)\n", This, ppunk);
2211 static const IDispatchExVtbl WindowDispExVtbl = {
2212 WindowDispEx_QueryInterface,
2213 WindowDispEx_AddRef,
2214 WindowDispEx_Release,
2215 WindowDispEx_GetTypeInfoCount,
2216 WindowDispEx_GetTypeInfo,
2217 WindowDispEx_GetIDsOfNames,
2218 WindowDispEx_Invoke,
2219 WindowDispEx_GetDispID,
2220 WindowDispEx_InvokeEx,
2221 WindowDispEx_DeleteMemberByName,
2222 WindowDispEx_DeleteMemberByDispID,
2223 WindowDispEx_GetMemberProperties,
2224 WindowDispEx_GetMemberName,
2225 WindowDispEx_GetNextDispID,
2226 WindowDispEx_GetNameSpaceParent
2229 static inline HTMLWindow *impl_from_IServiceProvider(IServiceProvider *iface)
2231 return CONTAINING_RECORD(iface, HTMLWindow, IServiceProvider_iface);
2234 static HRESULT WINAPI HTMLWindowSP_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
2236 HTMLWindow *This = impl_from_IServiceProvider(iface);
2237 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2240 static ULONG WINAPI HTMLWindowSP_AddRef(IServiceProvider *iface)
2242 HTMLWindow *This = impl_from_IServiceProvider(iface);
2243 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2246 static ULONG WINAPI HTMLWindowSP_Release(IServiceProvider *iface)
2248 HTMLWindow *This = impl_from_IServiceProvider(iface);
2249 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2252 static HRESULT WINAPI HTMLWindowSP_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv)
2254 HTMLWindow *This = impl_from_IServiceProvider(iface);
2256 if(IsEqualGUID(guidService, &IID_IHTMLWindow2)) {
2257 TRACE("IID_IHTMLWindow2\n");
2258 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2261 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
2264 return E_NOINTERFACE;
2266 return IServiceProvider_QueryService(&This->doc_obj->basedoc.IServiceProvider_iface,
2267 guidService, riid, ppv);
2270 static const IServiceProviderVtbl ServiceProviderVtbl = {
2271 HTMLWindowSP_QueryInterface,
2272 HTMLWindowSP_AddRef,
2273 HTMLWindowSP_Release,
2274 HTMLWindowSP_QueryService
2277 static inline HTMLWindow *impl_from_DispatchEx(DispatchEx *iface)
2279 return CONTAINING_RECORD(iface, HTMLWindow, dispex);
2282 static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2283 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2285 HTMLWindow *This = impl_from_DispatchEx(dispex);
2286 global_prop_t *prop;
2290 idx = id - MSHTML_DISPID_CUSTOM_MIN;
2291 if(idx >= This->global_prop_cnt)
2292 return DISP_E_MEMBERNOTFOUND;
2294 prop = This->global_props+idx;
2296 switch(prop->type) {
2297 case GLOBAL_SCRIPTVAR: {
2301 disp = get_script_disp(prop->script_host);
2303 return E_UNEXPECTED;
2305 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&iface);
2306 if(SUCCEEDED(hres)) {
2307 TRACE("%s >>>\n", debugstr_w(prop->name));
2308 hres = IDispatchEx_InvokeEx(iface, prop->id, lcid, flags, params, res, ei, caller);
2310 TRACE("%s <<<\n", debugstr_w(prop->name));
2312 WARN("%s <<< %08x\n", debugstr_w(prop->name), hres);
2313 IDispatchEx_Release(iface);
2315 FIXME("No IDispatchEx\n");
2317 IDispatch_Release(disp);
2320 case GLOBAL_ELEMENTVAR: {
2323 hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
2329 return DISP_E_MEMBERNOTFOUND;
2331 V_VT(res) = VT_DISPATCH;
2332 V_DISPATCH(res) = (IDispatch*)elem;
2336 ERR("invalid type %d\n", prop->type);
2337 hres = DISP_E_MEMBERNOTFOUND;
2344 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl = {
2351 static const tid_t HTMLWindow_iface_tids[] = {
2359 static dispex_static_data_t HTMLWindow_dispex = {
2360 &HTMLWindow_dispex_vtbl,
2361 DispHTMLWindow2_tid,
2363 HTMLWindow_iface_tids
2366 HRESULT HTMLWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, HTMLWindow *parent, HTMLWindow **ret)
2371 window = heap_alloc_zero(sizeof(HTMLWindow));
2373 return E_OUTOFMEMORY;
2375 window->window_ref = heap_alloc(sizeof(windowref_t));
2376 if(!window->window_ref) {
2378 return E_OUTOFMEMORY;
2381 window->IHTMLWindow2_iface.lpVtbl = &HTMLWindow2Vtbl;
2382 window->IHTMLWindow3_iface.lpVtbl = &HTMLWindow3Vtbl;
2383 window->IHTMLWindow4_iface.lpVtbl = &HTMLWindow4Vtbl;
2384 window->IHTMLWindow6_iface.lpVtbl = &HTMLWindow6Vtbl;
2385 window->IHTMLPrivateWindow_iface.lpVtbl = &HTMLPrivateWindowVtbl;
2386 window->IDispatchEx_iface.lpVtbl = &WindowDispExVtbl;
2387 window->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
2389 window->doc_obj = doc_obj;
2391 window->window_ref->window = window;
2392 window->window_ref->ref = 1;
2394 init_dispex(&window->dispex, (IUnknown*)&window->IHTMLWindow2_iface, &HTMLWindow_dispex);
2397 nsIDOMWindow_AddRef(nswindow);
2398 window->nswindow = nswindow;
2401 window->scriptmode = parent ? parent->scriptmode : SCRIPTMODE_GECKO;
2402 window->readystate = READYSTATE_UNINITIALIZED;
2403 list_init(&window->script_hosts);
2405 hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0);
2407 IHTMLWindow2_Release(&window->IHTMLWindow2_iface);
2411 window->task_magic = get_task_target_magic();
2412 update_window_doc(window);
2414 list_init(&window->children);
2415 list_add_head(&window_list, &window->entry);
2418 IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
2420 window->parent = parent;
2421 list_add_tail(&parent->children, &window->sibling_entry);
2428 void update_window_doc(HTMLWindow *window)
2430 nsIDOMHTMLDocument *nshtmldoc;
2431 nsIDOMDocument *nsdoc;
2434 nsres = nsIDOMWindow_GetDocument(window->nswindow, &nsdoc);
2435 if(NS_FAILED(nsres) || !nsdoc) {
2436 ERR("GetDocument failed: %08x\n", nsres);
2440 nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
2441 nsIDOMDocument_Release(nsdoc);
2442 if(NS_FAILED(nsres)) {
2443 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres);
2447 if(!window->doc || window->doc->nsdoc != nshtmldoc) {
2448 HTMLDocumentNode *doc;
2451 hres = create_doc_from_nsdoc(nshtmldoc, window->doc_obj, window, &doc);
2452 if(SUCCEEDED(hres)) {
2453 window_set_docnode(window, doc);
2454 htmldoc_release(&doc->basedoc);
2456 ERR("create_doc_from_nsdoc failed: %08x\n", hres);
2460 nsIDOMHTMLDocument_Release(nshtmldoc);
2463 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
2467 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) {
2468 if(iter->nswindow == nswindow)