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
30 #define NO_SHLWAPI_REG
33 #include "wine/debug.h"
35 #include "mshtml_private.h"
36 #include "htmlevent.h"
40 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
42 static struct list window_list = LIST_INIT(window_list);
44 static void window_set_docnode(HTMLWindow *window, HTMLDocumentNode *doc_node)
47 if(window->doc_obj && window == window->doc_obj->basedoc.window)
48 window->doc->basedoc.cp_container.forward_container = NULL;
49 detach_events(window->doc);
50 abort_document_bindings(window->doc);
51 window->doc->basedoc.window = NULL;
52 htmldoc_release(&window->doc->basedoc);
54 window->doc = doc_node;
56 htmldoc_addref(&doc_node->basedoc);
58 if(window->doc_obj && window->doc_obj->basedoc.window == window) {
59 if(window->doc_obj->basedoc.doc_node)
60 htmldoc_release(&window->doc_obj->basedoc.doc_node->basedoc);
61 window->doc_obj->basedoc.doc_node = doc_node;
63 htmldoc_addref(&doc_node->basedoc);
66 if(doc_node && window->doc_obj && window->doc_obj->usermode == EDITMODE) {
70 static const PRUnichar onW[] = {'o','n',0};
72 nsAString_Init(&mode_str, onW);
73 nsres = nsIDOMHTMLDocument_SetDesignMode(doc_node->nsdoc, &mode_str);
74 nsAString_Finish(&mode_str);
76 ERR("SetDesignMode failed: %08x\n", nsres);
80 static void release_children(HTMLWindow *This)
84 while(!list_empty(&This->children)) {
85 child = LIST_ENTRY(list_tail(&This->children), HTMLWindow, sibling_entry);
87 list_remove(&child->sibling_entry);
89 IHTMLWindow2_Release(&child->IHTMLWindow2_iface);
93 static HRESULT get_location(HTMLWindow *This, HTMLLocation **ret)
96 IHTMLLocation_AddRef(&This->location->IHTMLLocation_iface);
100 hres = HTMLLocation_Create(This, &This->location);
105 *ret = This->location;
109 static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
112 FIXME("No document\n");
116 return set_event_handler(&window->doc->body_event_target, NULL, window->doc, eid, var);
119 static inline HRESULT get_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
122 FIXME("No document\n");
126 return get_event_handler(&window->doc->body_event_target, eid, var);
129 static inline HTMLWindow *impl_from_IHTMLWindow2(IHTMLWindow2 *iface)
131 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow2_iface);
134 static HRESULT WINAPI HTMLWindow2_QueryInterface(IHTMLWindow2 *iface, REFIID riid, void **ppv)
136 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
140 if(IsEqualGUID(&IID_IUnknown, riid)) {
141 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
142 *ppv = &This->IHTMLWindow2_iface;
143 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
144 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
145 *ppv = &This->IHTMLWindow2_iface;
146 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
147 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
148 *ppv = &This->IDispatchEx_iface;
149 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2, riid)) {
150 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
151 *ppv = &This->IHTMLWindow2_iface;
152 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
153 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
154 *ppv = &This->IHTMLWindow2_iface;
155 }else if(IsEqualGUID(&IID_IHTMLWindow3, riid)) {
156 TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This, ppv);
157 *ppv = &This->IHTMLWindow3_iface;
158 }else if(IsEqualGUID(&IID_IHTMLWindow4, riid)) {
159 TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This, ppv);
160 *ppv = &This->IHTMLWindow4_iface;
161 }else if(IsEqualGUID(&IID_IHTMLWindow6, riid)) {
162 TRACE("(%p)->(IID_IHTMLWindow6 %p)\n", This, ppv);
163 *ppv = &This->IHTMLWindow6_iface;
164 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow, riid)) {
165 TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This, ppv);
166 *ppv = &This->IHTMLPrivateWindow_iface;
167 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
168 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
169 *ppv = &This->IServiceProvider_iface;
170 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
171 return *ppv ? S_OK : E_NOINTERFACE;
175 IUnknown_AddRef((IUnknown*)*ppv);
179 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
180 return E_NOINTERFACE;
183 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
185 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
186 LONG ref = InterlockedIncrement(&This->ref);
188 TRACE("(%p) ref=%d\n", This, ref);
193 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
195 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
196 LONG ref = InterlockedDecrement(&This->ref);
198 TRACE("(%p) ref=%d\n", This, ref);
203 remove_target_tasks(This->task_magic);
204 set_window_bscallback(This, NULL);
205 set_current_mon(This, NULL);
206 window_set_docnode(This, NULL);
207 release_children(This);
210 IInternetSecurityManager_Release(This->secmgr);
212 if(This->frame_element)
213 This->frame_element->content_window = NULL;
215 if(This->option_factory) {
216 This->option_factory->window = NULL;
217 IHTMLOptionElementFactory_Release(&This->option_factory->IHTMLOptionElementFactory_iface);
220 if(This->image_factory) {
221 This->image_factory->window = NULL;
222 IHTMLImageElementFactory_Release(&This->image_factory->IHTMLImageElementFactory_iface);
226 This->location->window = NULL;
227 IHTMLLocation_Release(&This->location->IHTMLLocation_iface);
231 IHTMLScreen_Release(This->screen);
233 for(i=0; i < This->global_prop_cnt; i++)
234 heap_free(This->global_props[i].name);
236 This->window_ref->window = NULL;
237 windowref_release(This->window_ref);
239 heap_free(This->global_props);
240 release_script_hosts(This);
243 nsIDOMWindow_Release(This->nswindow);
245 list_remove(&This->entry);
246 release_dispex(&This->dispex);
253 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
255 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
257 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
260 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
261 LCID lcid, ITypeInfo **ppTInfo)
263 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
265 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
268 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
269 LPOLESTR *rgszNames, UINT cNames,
270 LCID lcid, DISPID *rgDispId)
272 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
274 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
278 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
279 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
280 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
282 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
284 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
285 pDispParams, pVarResult, pExcepInfo, puArgErr);
288 static HRESULT get_frame_by_index(nsIDOMWindowCollection *nsFrames, PRUint32 index, HTMLWindow **ret)
291 nsIDOMWindow *nsWindow;
294 nsres = nsIDOMWindowCollection_GetLength(nsFrames, &length);
295 if(NS_FAILED(nsres)) {
296 FIXME("nsIDOMWindowCollection_GetLength failed: 0x%08x\n", nsres);
301 return DISP_E_MEMBERNOTFOUND;
303 nsres = nsIDOMWindowCollection_Item(nsFrames, index, &nsWindow);
304 if(NS_FAILED(nsres)) {
305 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
309 *ret = nswindow_to_window(nsWindow);
311 nsIDOMWindow_Release(nsWindow);
316 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
318 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
319 nsIDOMWindowCollection *nsFrames;
320 HTMLWindow *window = NULL;
324 TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
326 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nsFrames);
327 if(NS_FAILED(nsres)) {
328 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres);
332 switch(V_VT(pvarIndex)) {
334 int index = V_I4(pvarIndex);
335 TRACE("Getting index %d\n", index);
338 hres = get_frame_by_index(nsFrames, index, &window);
342 unsigned int index = V_UINT(pvarIndex);
343 TRACE("Getting index %u\n", index);
344 hres = get_frame_by_index(nsFrames, index, &window);
348 BSTR str = V_BSTR(pvarIndex);
351 TRACE("Getting name %s\n", wine_dbgstr_w(str));
353 nsIDOMWindowCollection_GetLength(nsFrames, &length);
356 for(i = 0; i < length && !window; ++i) {
357 HTMLWindow *cur_window;
358 nsIDOMWindow *nsWindow;
361 nsres = nsIDOMWindowCollection_Item(nsFrames, i, &nsWindow);
362 if(NS_FAILED(nsres)) {
363 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
368 cur_window = nswindow_to_window(nsWindow);
370 nsIDOMWindow_Release(nsWindow);
372 hres = IHTMLElement_get_id(&cur_window->frame_element->element.IHTMLElement_iface, &id);
374 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres);
378 if(!strcmpW(id, str))
389 nsIDOMWindowCollection_Release(nsFrames);
393 return DISP_E_MEMBERNOTFOUND;
395 IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
396 V_VT(pvarResult) = VT_DISPATCH;
397 V_DISPATCH(pvarResult) = (IDispatch*)window;
401 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
403 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
404 nsIDOMWindowCollection *nscollection;
408 TRACE("(%p)->(%p)\n", This, p);
410 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nscollection);
411 if(NS_FAILED(nsres)) {
412 ERR("GetFrames failed: %08x\n", nsres);
416 nsres = nsIDOMWindowCollection_GetLength(nscollection, &length);
417 nsIDOMWindowCollection_Release(nscollection);
418 if(NS_FAILED(nsres)) {
419 ERR("GetLength failed: %08x\n", nsres);
427 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
429 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
430 FIXME("(%p)->(%p): semi-stub\n", This, p);
432 /* FIXME: Should return a separate Window object */
433 *p = (IHTMLFramesCollection2*)&This->IHTMLWindow2_iface;
434 HTMLWindow2_AddRef(iface);
438 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
440 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
441 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
445 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
447 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
448 FIXME("(%p)->(%p)\n", This, p);
452 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
454 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
456 WARN("(%p)->(%s)\n", This, debugstr_w(v));
459 * FIXME: Since IE7, setting status is blocked, but still possible in certain circumstances.
460 * Ignoring the call should be enough for us.
465 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
467 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
469 TRACE("(%p)->(%p)\n", This, p);
476 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
477 LONG msec, VARIANT *language, LONG *timerID)
479 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
482 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
484 V_VT(&expr_var) = VT_BSTR;
485 V_BSTR(&expr_var) = expression;
487 return IHTMLWindow3_setTimeout(&This->IHTMLWindow3_iface, &expr_var, msec, language, timerID);
490 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID)
492 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
494 TRACE("(%p)->(%d)\n", This, timerID);
496 return clear_task_timer(&This->doc->basedoc, FALSE, timerID);
499 #define MAX_MESSAGE_LEN 2000
501 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
503 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
504 WCHAR title[100], *msg = message;
507 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
509 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, title,
510 sizeof(title)/sizeof(WCHAR))) {
511 WARN("Could not load message box title: %d\n", GetLastError());
515 len = SysStringLen(message);
516 if(len > MAX_MESSAGE_LEN) {
517 msg = heap_alloc((MAX_MESSAGE_LEN+1)*sizeof(WCHAR));
519 return E_OUTOFMEMORY;
520 memcpy(msg, message, MAX_MESSAGE_LEN*sizeof(WCHAR));
521 msg[MAX_MESSAGE_LEN] = 0;
524 MessageBoxW(This->doc_obj->hwnd, msg, title, MB_ICONWARNING);
530 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
531 VARIANT_BOOL *confirmed)
533 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
536 TRACE("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
538 if(!confirmed) return E_INVALIDARG;
540 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
541 sizeof(wszTitle)/sizeof(WCHAR))) {
542 WARN("Could not load message box title: %d\n", GetLastError());
543 *confirmed = VARIANT_TRUE;
547 if(MessageBoxW(This->doc_obj->hwnd, message, wszTitle,
548 MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
549 *confirmed = VARIANT_TRUE;
550 else *confirmed = VARIANT_FALSE;
562 static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
563 WPARAM wparam, LPARAM lparam)
569 prompt_arg *arg = (prompt_arg*)lparam;
572 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
573 sizeof(wszTitle)/sizeof(WCHAR))) {
574 WARN("Could not load message box title: %d\n", GetLastError());
575 EndDialog(hwnd, wparam);
579 SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
580 SetWindowTextW(hwnd, wszTitle);
581 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_PROMPT), arg->message);
582 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_EDIT), arg->dststr);
588 case MAKEWPARAM(IDCANCEL, BN_CLICKED):
589 EndDialog(hwnd, wparam);
591 case MAKEWPARAM(IDOK, BN_CLICKED):
594 (prompt_arg*)GetWindowLongPtrW(hwnd, DWLP_USER);
595 HWND hwndPrompt = GetDlgItem(hwnd, ID_PROMPT_EDIT);
596 INT len = GetWindowTextLengthW(hwndPrompt);
600 EndDialog(hwnd, wparam);
604 V_VT(arg->textdata) = VT_BSTR;
605 if(!len && !arg->dststr)
606 V_BSTR(arg->textdata) = NULL;
609 V_BSTR(arg->textdata) = SysAllocStringLen(NULL, len);
610 GetWindowTextW(hwndPrompt, V_BSTR(arg->textdata), len+1);
612 EndDialog(hwnd, wparam);
618 EndDialog(hwnd, IDCANCEL);
625 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
626 BSTR dststr, VARIANT *textdata)
628 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
631 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
633 if(textdata) V_VT(textdata) = VT_NULL;
635 arg.message = message;
637 arg.textdata = textdata;
639 DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
640 This->doc_obj->hwnd, prompt_dlgproc, (LPARAM)&arg);
644 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
646 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
648 TRACE("(%p)->(%p)\n", This, p);
650 if(!This->image_factory)
651 This->image_factory = HTMLImageElementFactory_Create(This);
653 *p = &This->image_factory->IHTMLImageElementFactory_iface;
654 IHTMLImageElementFactory_AddRef(*p);
659 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
661 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
662 HTMLLocation *location;
665 TRACE("(%p)->(%p)\n", This, p);
667 hres = get_location(This, &location);
671 *p = &location->IHTMLLocation_iface;
675 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
677 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
678 FIXME("(%p)->(%p)\n", This, p);
682 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
684 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
685 FIXME("(%p)->()\n", This);
689 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
691 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
692 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
696 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
698 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
699 FIXME("(%p)->(%p)\n", This, p);
703 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
705 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
707 TRACE("(%p)->(%p)\n", This, p);
709 *p = OmNavigator_Create();
713 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
715 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
719 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
721 nsAString_InitDepend(&name_str, v);
722 nsres = nsIDOMWindow_SetName(This->nswindow, &name_str);
723 nsAString_Finish(&name_str);
725 ERR("SetName failed: %08x\n", nsres);
730 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
732 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
737 TRACE("(%p)->(%p)\n", This, p);
739 nsAString_Init(&name_str, NULL);
740 nsres = nsIDOMWindow_GetName(This->nswindow, &name_str);
741 if(NS_SUCCEEDED(nsres)) {
742 const PRUnichar *name;
744 nsAString_GetData(&name_str, &name);
746 *p = SysAllocString(name);
747 hres = *p ? S_OK : E_OUTOFMEMORY;
753 ERR("GetName failed: %08x\n", nsres);
756 nsAString_Finish(&name_str);
761 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
763 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
764 TRACE("(%p)->(%p)\n", This, p);
767 *p = &This->parent->IHTMLWindow2_iface;
768 IHTMLWindow2_AddRef(*p);
775 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
776 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
778 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
779 FIXME("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
780 debugstr_w(features), replace, pomWindowResult);
784 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
786 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
788 TRACE("(%p)->(%p)\n", This, p);
790 /* FIXME: We should return kind of proxy window here. */
791 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
792 *p = &This->IHTMLWindow2_iface;
796 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
798 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
800 TRACE("(%p)->(%p)\n", This, p);
805 *p = &curr->IHTMLWindow2_iface;
806 IHTMLWindow2_AddRef(*p);
811 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
813 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
815 TRACE("(%p)->(%p)\n", This, p);
817 /* FIXME: We should return kind of proxy window here. */
818 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
819 *p = &This->IHTMLWindow2_iface;
823 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
825 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
826 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
830 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
832 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
833 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
837 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
839 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
840 FIXME("(%p)->(%p)\n", This, p);
844 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
846 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
847 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
851 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
853 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
854 FIXME("(%p)->(%p)\n", This, p);
858 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
860 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
862 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
864 return set_window_event(This, EVENTID_LOAD, &v);
867 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
869 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
871 TRACE("(%p)->(%p)\n", This, p);
873 return get_window_event(This, EVENTID_LOAD, p);
876 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
878 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
880 TRACE("(%p)->(v(%d))\n", This, V_VT(&v));
882 return set_window_event(This, EVENTID_BEFOREUNLOAD, &v);
885 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
887 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
889 TRACE("(%p)->(%p)\n", This, p);
891 return get_window_event(This, EVENTID_BEFOREUNLOAD, p);
894 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
896 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
897 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
901 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
903 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
904 FIXME("(%p)->(%p)\n", This, p);
908 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
910 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
911 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
915 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
917 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
918 FIXME("(%p)->(%p)\n", This, p);
922 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
924 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
925 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
929 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
931 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
932 FIXME("(%p)->(%p)\n", This, p);
936 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
938 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
940 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
942 return set_window_event(This, EVENTID_RESIZE, &v);
945 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
947 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
949 TRACE("(%p)->(%p)\n", This, p);
951 return get_window_event(This, EVENTID_RESIZE, p);
954 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
956 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
957 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
961 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
963 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
964 FIXME("(%p)->(%p)\n", This, p);
968 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
970 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
972 TRACE("(%p)->(%p)\n", This, p);
975 /* FIXME: We should return a wrapper object here */
976 *p = &This->doc->basedoc.IHTMLDocument2_iface;
977 IHTMLDocument2_AddRef(*p);
985 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
987 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
989 TRACE("(%p)->(%p)\n", This, p);
992 IHTMLEventObj_AddRef(This->event);
997 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
999 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1000 FIXME("(%p)->(%p)\n", This, p);
1004 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
1005 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
1007 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1008 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
1012 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
1015 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1016 FIXME("(%p)->(%s v(%d) %s)\n", This, debugstr_w(helpURL), V_VT(&helpArg), debugstr_w(features));
1020 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
1022 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1024 TRACE("(%p)->(%p)\n", This, p);
1029 hres = HTMLScreen_Create(&This->screen);
1035 IHTMLScreen_AddRef(This->screen);
1039 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
1041 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1043 TRACE("(%p)->(%p)\n", This, p);
1045 if(!This->option_factory)
1046 This->option_factory = HTMLOptionElementFactory_Create(This);
1048 *p = &This->option_factory->IHTMLOptionElementFactory_iface;
1049 IHTMLOptionElementFactory_AddRef(*p);
1054 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
1056 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1058 TRACE("(%p)->()\n", This);
1061 SetFocus(This->doc_obj->hwnd);
1065 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
1067 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1068 FIXME("(%p)->(%p)\n", This, p);
1072 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
1074 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1075 FIXME("(%p)->()\n", This);
1079 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, LONG x, LONG y)
1081 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1082 FIXME("(%p)->(%d %d)\n", This, x, y);
1086 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
1088 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1089 FIXME("(%p)->(%p)\n", This, p);
1093 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
1094 LONG msec, VARIANT *language, LONG *timerID)
1096 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1099 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
1101 V_VT(&expr) = VT_BSTR;
1102 V_BSTR(&expr) = expression;
1103 return IHTMLWindow3_setInterval(&This->IHTMLWindow3_iface, &expr, msec, language, timerID);
1106 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerID)
1108 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1110 TRACE("(%p)->(%d)\n", This, timerID);
1112 return clear_task_timer(&This->doc->basedoc, TRUE, timerID);
1115 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
1117 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1118 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
1122 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
1124 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1125 FIXME("(%p)->(%p)\n", This, p);
1129 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
1132 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1134 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
1136 return exec_script(This, scode, language, pvarRet);
1139 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
1141 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1143 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1145 TRACE("(%p)->(%p)\n", This, String);
1148 return E_INVALIDARG;
1150 *String = SysAllocString(objectW);
1151 return *String ? S_OK : E_OUTOFMEMORY;
1154 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, LONG x, LONG y)
1156 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1159 TRACE("(%p)->(%d %d)\n", This, x, y);
1161 nsres = nsIDOMWindow_ScrollBy(This->nswindow, x, y);
1162 if(NS_FAILED(nsres))
1163 ERR("ScrollBy failed: %08x\n", nsres);
1168 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, LONG x, LONG y)
1170 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1173 TRACE("(%p)->(%d %d)\n", This, x, y);
1175 nsres = nsIDOMWindow_ScrollTo(This->nswindow, x, y);
1176 if(NS_FAILED(nsres))
1177 ERR("ScrollTo failed: %08x\n", nsres);
1182 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, LONG x, LONG y)
1184 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1185 FIXME("(%p)->(%d %d)\n", This, x, y);
1189 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, LONG x, LONG y)
1191 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1192 FIXME("(%p)->(%d %d)\n", This, x, y);
1196 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, LONG x, LONG y)
1198 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1199 FIXME("(%p)->(%d %d)\n", This, x, y);
1203 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, LONG x, LONG y)
1205 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1206 FIXME("(%p)->(%d %d)\n", This, x, y);
1210 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
1212 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1214 TRACE("(%p)->(%p)\n", This, p);
1218 if(!This->doc_obj->hostui)
1221 return IDocHostUIHandler_GetExternal(This->doc_obj->hostui, p);
1224 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
1225 HTMLWindow2_QueryInterface,
1227 HTMLWindow2_Release,
1228 HTMLWindow2_GetTypeInfoCount,
1229 HTMLWindow2_GetTypeInfo,
1230 HTMLWindow2_GetIDsOfNames,
1233 HTMLWindow2_get_length,
1234 HTMLWindow2_get_frames,
1235 HTMLWindow2_put_defaultStatus,
1236 HTMLWindow2_get_defaultStatus,
1237 HTMLWindow2_put_status,
1238 HTMLWindow2_get_status,
1239 HTMLWindow2_setTimeout,
1240 HTMLWindow2_clearTimeout,
1242 HTMLWindow2_confirm,
1244 HTMLWindow2_get_Image,
1245 HTMLWindow2_get_location,
1246 HTMLWindow2_get_history,
1248 HTMLWindow2_put_opener,
1249 HTMLWindow2_get_opener,
1250 HTMLWindow2_get_navigator,
1251 HTMLWindow2_put_name,
1252 HTMLWindow2_get_name,
1253 HTMLWindow2_get_parent,
1255 HTMLWindow2_get_self,
1256 HTMLWindow2_get_top,
1257 HTMLWindow2_get_window,
1258 HTMLWindow2_navigate,
1259 HTMLWindow2_put_onfocus,
1260 HTMLWindow2_get_onfocus,
1261 HTMLWindow2_put_onblur,
1262 HTMLWindow2_get_onblur,
1263 HTMLWindow2_put_onload,
1264 HTMLWindow2_get_onload,
1265 HTMLWindow2_put_onbeforeunload,
1266 HTMLWindow2_get_onbeforeunload,
1267 HTMLWindow2_put_onunload,
1268 HTMLWindow2_get_onunload,
1269 HTMLWindow2_put_onhelp,
1270 HTMLWindow2_get_onhelp,
1271 HTMLWindow2_put_onerror,
1272 HTMLWindow2_get_onerror,
1273 HTMLWindow2_put_onresize,
1274 HTMLWindow2_get_onresize,
1275 HTMLWindow2_put_onscroll,
1276 HTMLWindow2_get_onscroll,
1277 HTMLWindow2_get_document,
1278 HTMLWindow2_get_event,
1279 HTMLWindow2_get__newEnum,
1280 HTMLWindow2_showModalDialog,
1281 HTMLWindow2_showHelp,
1282 HTMLWindow2_get_screen,
1283 HTMLWindow2_get_Option,
1285 HTMLWindow2_get_closed,
1288 HTMLWindow2_get_clientInformation,
1289 HTMLWindow2_setInterval,
1290 HTMLWindow2_clearInterval,
1291 HTMLWindow2_put_offscreenBuffering,
1292 HTMLWindow2_get_offscreenBuffering,
1293 HTMLWindow2_execScript,
1294 HTMLWindow2_toString,
1295 HTMLWindow2_scrollBy,
1296 HTMLWindow2_scrollTo,
1299 HTMLWindow2_resizeTo,
1300 HTMLWindow2_resizeBy,
1301 HTMLWindow2_get_external
1304 static inline HTMLWindow *impl_from_IHTMLWindow3(IHTMLWindow3 *iface)
1306 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow3_iface);
1309 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
1311 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1313 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1316 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
1318 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1320 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1323 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
1325 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1327 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1330 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
1332 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1334 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1337 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
1338 LCID lcid, ITypeInfo **ppTInfo)
1340 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1342 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1345 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
1346 LPOLESTR *rgszNames, UINT cNames,
1347 LCID lcid, DISPID *rgDispId)
1349 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1351 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1355 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
1356 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1357 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1359 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1361 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1362 pDispParams, pVarResult, pExcepInfo, puArgErr);
1365 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, LONG *p)
1367 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1368 FIXME("(%p)->(%p)\n", This, p);
1372 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, LONG *p)
1374 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1375 FIXME("(%p)->(%p)\n", This, p);
1379 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
1381 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1383 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
1386 FIXME("No document\n");
1390 return attach_event(&This->doc->body_event_target, NULL, &This->doc->basedoc, event, pDisp, pfResult);
1393 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
1395 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1396 FIXME("(%p)->()\n", This);
1400 static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, LONG msec, VARIANT *language,
1401 BOOL interval, LONG *timer_id)
1403 IDispatch *disp = NULL;
1405 switch(V_VT(expr)) {
1407 disp = V_DISPATCH(expr);
1408 IDispatch_AddRef(disp);
1412 disp = script_parse_event(This, V_BSTR(expr));
1416 FIXME("unimplemented vt=%d\n", V_VT(expr));
1423 *timer_id = set_task_timer(&This->doc->basedoc, msec, interval, disp);
1424 IDispatch_Release(disp);
1429 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1430 VARIANT *language, LONG *timerID)
1432 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1434 TRACE("(%p)->(%p(%d) %d %p %p)\n", This, expression, V_VT(expression), msec, language, timerID);
1436 return window_set_timer(This, expression, msec, language, FALSE, timerID);
1439 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1440 VARIANT *language, LONG *timerID)
1442 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1444 TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID);
1446 return window_set_timer(This, expression, msec, language, TRUE, timerID);
1449 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
1451 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1452 FIXME("(%p)\n", This);
1456 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
1458 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1459 FIXME("(%p)->()\n", This);
1463 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
1465 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1466 FIXME("(%p)->(%p)\n", This, p);
1470 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
1472 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1473 FIXME("(%p)->()\n", This);
1477 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
1479 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1480 FIXME("(%p)->(%p)\n", This, p);
1484 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
1486 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1487 FIXME("(%p)->(%p)\n", This, p);
1491 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
1492 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
1494 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1495 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
1499 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
1500 HTMLWindow3_QueryInterface,
1502 HTMLWindow3_Release,
1503 HTMLWindow3_GetTypeInfoCount,
1504 HTMLWindow3_GetTypeInfo,
1505 HTMLWindow3_GetIDsOfNames,
1507 HTMLWindow3_get_screenLeft,
1508 HTMLWindow3_get_screenTop,
1509 HTMLWindow3_attachEvent,
1510 HTMLWindow3_detachEvent,
1511 HTMLWindow3_setTimeout,
1512 HTMLWindow3_setInterval,
1514 HTMLWindow3_put_onbeforeprint,
1515 HTMLWindow3_get_onbeforeprint,
1516 HTMLWindow3_put_onafterprint,
1517 HTMLWindow3_get_onafterprint,
1518 HTMLWindow3_get_clipboardData,
1519 HTMLWindow3_showModelessDialog
1522 static inline HTMLWindow *impl_from_IHTMLWindow4(IHTMLWindow4 *iface)
1524 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow4_iface);
1527 static HRESULT WINAPI HTMLWindow4_QueryInterface(IHTMLWindow4 *iface, REFIID riid, void **ppv)
1529 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1531 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1534 static ULONG WINAPI HTMLWindow4_AddRef(IHTMLWindow4 *iface)
1536 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1538 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1541 static ULONG WINAPI HTMLWindow4_Release(IHTMLWindow4 *iface)
1543 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1545 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1548 static HRESULT WINAPI HTMLWindow4_GetTypeInfoCount(IHTMLWindow4 *iface, UINT *pctinfo)
1550 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1552 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1555 static HRESULT WINAPI HTMLWindow4_GetTypeInfo(IHTMLWindow4 *iface, UINT iTInfo,
1556 LCID lcid, ITypeInfo **ppTInfo)
1558 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1560 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1563 static HRESULT WINAPI HTMLWindow4_GetIDsOfNames(IHTMLWindow4 *iface, REFIID riid,
1564 LPOLESTR *rgszNames, UINT cNames,
1565 LCID lcid, DISPID *rgDispId)
1567 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1569 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1573 static HRESULT WINAPI HTMLWindow4_Invoke(IHTMLWindow4 *iface, DISPID dispIdMember,
1574 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1575 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1577 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1579 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1580 pDispParams, pVarResult, pExcepInfo, puArgErr);
1583 static HRESULT WINAPI HTMLWindow4_createPopup(IHTMLWindow4 *iface, VARIANT *varArgIn,
1584 IDispatch **ppPopup)
1586 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1587 FIXME("(%p)->(%p %p)\n", This, varArgIn, ppPopup);
1591 static HRESULT WINAPI HTMLWindow4_get_frameElement(IHTMLWindow4 *iface, IHTMLFrameBase **p)
1593 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1594 TRACE("(%p)->(%p)\n", This, p);
1596 if(This->frame_element) {
1597 *p = &This->frame_element->IHTMLFrameBase_iface;
1598 IHTMLFrameBase_AddRef(*p);
1605 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl = {
1606 HTMLWindow4_QueryInterface,
1608 HTMLWindow4_Release,
1609 HTMLWindow4_GetTypeInfoCount,
1610 HTMLWindow4_GetTypeInfo,
1611 HTMLWindow4_GetIDsOfNames,
1613 HTMLWindow4_createPopup,
1614 HTMLWindow4_get_frameElement
1617 static inline HTMLWindow *impl_from_IHTMLWindow6(IHTMLWindow6 *iface)
1619 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow6_iface);
1622 static HRESULT WINAPI HTMLWindow6_QueryInterface(IHTMLWindow6 *iface, REFIID riid, void **ppv)
1624 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1626 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1629 static ULONG WINAPI HTMLWindow6_AddRef(IHTMLWindow6 *iface)
1631 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1633 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1636 static ULONG WINAPI HTMLWindow6_Release(IHTMLWindow6 *iface)
1638 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1640 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1643 static HRESULT WINAPI HTMLWindow6_GetTypeInfoCount(IHTMLWindow6 *iface, UINT *pctinfo)
1645 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1647 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1650 static HRESULT WINAPI HTMLWindow6_GetTypeInfo(IHTMLWindow6 *iface, UINT iTInfo,
1651 LCID lcid, ITypeInfo **ppTInfo)
1653 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1655 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1658 static HRESULT WINAPI HTMLWindow6_GetIDsOfNames(IHTMLWindow6 *iface, REFIID riid,
1659 LPOLESTR *rgszNames, UINT cNames,
1660 LCID lcid, DISPID *rgDispId)
1662 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1664 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1668 static HRESULT WINAPI HTMLWindow6_Invoke(IHTMLWindow6 *iface, DISPID dispIdMember,
1669 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1670 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1672 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1674 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1675 pDispParams, pVarResult, pExcepInfo, puArgErr);
1678 static HRESULT WINAPI HTMLWindow6_put_XDomainRequest(IHTMLWindow6 *iface, VARIANT v)
1680 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1681 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1685 static HRESULT WINAPI HTMLWindow6_get_XDomainRequest(IHTMLWindow6 *iface, VARIANT *p)
1687 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1688 FIXME("(%p)->(%p)\n", This, p);
1692 static HRESULT WINAPI HTMLWindow6_get_sessionStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1694 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1695 FIXME("(%p)->(%p)\n", This, p);
1699 static HRESULT WINAPI HTMLWindow6_get_localStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1701 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1702 FIXME("(%p)->(%p)\n", This, p);
1706 static HRESULT WINAPI HTMLWindow6_put_onhashchange(IHTMLWindow6 *iface, VARIANT v)
1708 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1709 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1713 static HRESULT WINAPI HTMLWindow6_get_onhashchange(IHTMLWindow6 *iface, VARIANT *p)
1715 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1716 FIXME("(%p)->(%p)\n", This, p);
1720 static HRESULT WINAPI HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6 *iface, LONG *p)
1722 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1723 FIXME("(%p)->(%p)\n", This, p);
1727 static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VARIANT targetOrigin)
1729 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1730 FIXME("(%p)->(%s %s)\n", This, debugstr_w(msg), debugstr_variant(&targetOrigin));
1734 static HRESULT WINAPI HTMLWindow6_toStaticHTML(IHTMLWindow6 *iface, BSTR bstrHTML, BSTR *pbstrStaticHTML)
1736 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1737 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrHTML), pbstrStaticHTML);
1741 static HRESULT WINAPI HTMLWindow6_put_onmessage(IHTMLWindow6 *iface, VARIANT v)
1743 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1744 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1748 static HRESULT WINAPI HTMLWindow6_get_onmessage(IHTMLWindow6 *iface, VARIANT *p)
1750 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1751 FIXME("(%p)->(%p)\n", This, p);
1755 static HRESULT WINAPI HTMLWindow6_msWriteProfilerMark(IHTMLWindow6 *iface, BSTR bstrProfilerMark)
1757 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1758 FIXME("(%p)->(%s)\n", This, debugstr_w(bstrProfilerMark));
1762 static const IHTMLWindow6Vtbl HTMLWindow6Vtbl = {
1763 HTMLWindow6_QueryInterface,
1765 HTMLWindow6_Release,
1766 HTMLWindow6_GetTypeInfoCount,
1767 HTMLWindow6_GetTypeInfo,
1768 HTMLWindow6_GetIDsOfNames,
1770 HTMLWindow6_put_XDomainRequest,
1771 HTMLWindow6_get_XDomainRequest,
1772 HTMLWindow6_get_sessionStorage,
1773 HTMLWindow6_get_localStorage,
1774 HTMLWindow6_put_onhashchange,
1775 HTMLWindow6_get_onhashchange,
1776 HTMLWindow6_get_maxConnectionsPerServer,
1777 HTMLWindow6_postMessage,
1778 HTMLWindow6_toStaticHTML,
1779 HTMLWindow6_put_onmessage,
1780 HTMLWindow6_get_onmessage,
1781 HTMLWindow6_msWriteProfilerMark
1784 static inline HTMLWindow *impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow *iface)
1786 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLPrivateWindow_iface);
1789 static HRESULT WINAPI HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow *iface, REFIID riid, void **ppv)
1791 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1793 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1796 static ULONG WINAPI HTMLPrivateWindow_AddRef(IHTMLPrivateWindow *iface)
1798 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1800 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1803 static ULONG WINAPI HTMLPrivateWindow_Release(IHTMLPrivateWindow *iface)
1805 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1807 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1810 static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface, BSTR url, BSTR arg2, BSTR arg3,
1811 BSTR arg4, VARIANT *post_data_var, VARIANT *headers_var, ULONG flags)
1813 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1814 OLECHAR *translated_url = NULL;
1815 DWORD post_data_size = 0;
1816 BYTE *post_data = NULL;
1817 WCHAR *headers = NULL;
1821 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This, debugstr_w(url), debugstr_w(arg2), debugstr_w(arg3), debugstr_w(arg4),
1822 debugstr_variant(post_data_var), debugstr_variant(headers_var), flags);
1824 if(This->doc_obj->hostui) {
1825 hres = IDocHostUIHandler_TranslateUrl(This->doc_obj->hostui, 0, url, &translated_url);
1827 translated_url = NULL;
1830 hres = CreateUri(translated_url ? translated_url : url, 0, 0, &uri);
1831 CoTaskMemFree(translated_url);
1836 if(V_VT(post_data_var) == (VT_ARRAY|VT_UI1)) {
1837 SafeArrayAccessData(V_ARRAY(post_data_var), (void**)&post_data);
1838 post_data_size = V_ARRAY(post_data_var)->rgsabound[0].cElements;
1842 if(headers_var && V_VT(headers_var) != VT_EMPTY && V_VT(headers_var) != VT_ERROR) {
1843 if(V_VT(headers_var) != VT_BSTR)
1844 return E_INVALIDARG;
1846 headers = V_BSTR(headers_var);
1849 hres = super_navigate(This, uri, headers, post_data, post_data_size);
1852 SafeArrayUnaccessData(V_ARRAY(post_data_var));
1857 static HRESULT WINAPI HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow *iface, BSTR *url)
1859 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1860 FIXME("(%p)->(%p)\n", This, url);
1864 static HRESULT WINAPI HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow *iface, IOleCommandTarget *cmdtrg)
1866 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1867 FIXME("(%p)->(%p)\n", This, cmdtrg);
1871 static HRESULT WINAPI HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow *iface, int arg)
1873 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1874 FIXME("(%p)->(%x)\n", This, arg);
1878 static HRESULT WINAPI HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow *iface, LPCWSTR name, IHTMLWindow2 **ret)
1880 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1881 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), ret);
1885 static HRESULT WINAPI HTMLPrivateWindow_GetAddressBarUrl(IHTMLPrivateWindow *iface, BSTR *url)
1887 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1888 TRACE("(%p)->(%p)\n", This, url);
1891 return E_INVALIDARG;
1893 *url = SysAllocString(This->url);
1897 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl = {
1898 HTMLPrivateWindow_QueryInterface,
1899 HTMLPrivateWindow_AddRef,
1900 HTMLPrivateWindow_Release,
1901 HTMLPrivateWindow_SuperNavigate,
1902 HTMLPrivateWindow_GetPendingUrl,
1903 HTMLPrivateWindow_SetPICSTarget,
1904 HTMLPrivateWindow_PICSComplete,
1905 HTMLPrivateWindow_FindWindowByName,
1906 HTMLPrivateWindow_GetAddressBarUrl
1909 static inline HTMLWindow *impl_from_IDispatchEx(IDispatchEx *iface)
1911 return CONTAINING_RECORD(iface, HTMLWindow, IDispatchEx_iface);
1914 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1916 HTMLWindow *This = impl_from_IDispatchEx(iface);
1918 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1921 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
1923 HTMLWindow *This = impl_from_IDispatchEx(iface);
1925 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1928 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
1930 HTMLWindow *This = impl_from_IDispatchEx(iface);
1932 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1935 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1937 HTMLWindow *This = impl_from_IDispatchEx(iface);
1939 TRACE("(%p)->(%p)\n", This, pctinfo);
1941 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1944 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1945 LCID lcid, ITypeInfo **ppTInfo)
1947 HTMLWindow *This = impl_from_IDispatchEx(iface);
1949 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1951 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1954 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1955 LPOLESTR *rgszNames, UINT cNames,
1956 LCID lcid, DISPID *rgDispId)
1958 HTMLWindow *This = impl_from_IDispatchEx(iface);
1962 WARN("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
1965 for(i=0; i < cNames; i++) {
1966 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
1967 hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
1975 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
1976 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1977 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1979 HTMLWindow *This = impl_from_IDispatchEx(iface);
1981 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
1982 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
1984 /* FIXME: Use script dispatch */
1986 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1987 pDispParams, pVarResult, pExcepInfo, puArgErr);
1990 static global_prop_t *alloc_global_prop(HTMLWindow *This, global_prop_type_t type, BSTR name)
1992 if(This->global_prop_cnt == This->global_prop_size) {
1993 global_prop_t *new_props;
1996 if(This->global_props) {
1997 new_size = This->global_prop_size*2;
1998 new_props = heap_realloc(This->global_props, new_size*sizeof(global_prop_t));
2001 new_props = heap_alloc(new_size*sizeof(global_prop_t));
2005 This->global_props = new_props;
2006 This->global_prop_size = new_size;
2009 This->global_props[This->global_prop_cnt].name = heap_strdupW(name);
2010 if(!This->global_props[This->global_prop_cnt].name)
2013 This->global_props[This->global_prop_cnt].type = type;
2014 return This->global_props + This->global_prop_cnt++;
2017 static inline DWORD prop_to_dispid(HTMLWindow *This, global_prop_t *prop)
2019 return MSHTML_DISPID_CUSTOM_MIN + (prop-This->global_props);
2022 HRESULT search_window_props(HTMLWindow *This, BSTR bstrName, DWORD grfdex, DISPID *pid)
2025 ScriptHost *script_host;
2028 for(i=0; i < This->global_prop_cnt; i++) {
2029 /* FIXME: case sensitivity */
2030 if(!strcmpW(This->global_props[i].name, bstrName)) {
2031 *pid = MSHTML_DISPID_CUSTOM_MIN+i;
2036 if(find_global_prop(This, bstrName, grfdex, &script_host, &id)) {
2037 global_prop_t *prop;
2039 prop = alloc_global_prop(This, GLOBAL_SCRIPTVAR, bstrName);
2041 return E_OUTOFMEMORY;
2043 prop->script_host = script_host;
2046 *pid = prop_to_dispid(This, prop);
2050 return DISP_E_UNKNOWNNAME;
2053 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
2055 HTMLWindow *This = impl_from_IDispatchEx(iface);
2058 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
2060 hres = search_window_props(This, bstrName, grfdex, pid);
2061 if(hres != DISP_E_UNKNOWNNAME)
2064 hres = IDispatchEx_GetDispID(&This->dispex.IDispatchEx_iface, bstrName, grfdex, pid);
2065 if(hres != DISP_E_UNKNOWNNAME)
2069 global_prop_t *prop;
2072 hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
2074 if(SUCCEEDED(hres) && elem) {
2075 IHTMLElement_Release(elem);
2077 prop = alloc_global_prop(This, GLOBAL_ELEMENTVAR, bstrName);
2079 return E_OUTOFMEMORY;
2081 *pid = prop_to_dispid(This, prop);
2086 return DISP_E_UNKNOWNNAME;
2089 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
2090 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
2092 HTMLWindow *This = impl_from_IDispatchEx(iface);
2094 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
2096 if(id == DISPID_IHTMLWINDOW2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT)) {
2097 HTMLLocation *location;
2100 TRACE("forwarding to location.href\n");
2102 hres = get_location(This, &location);
2106 hres = IDispatchEx_InvokeEx(&location->dispex.IDispatchEx_iface, DISPID_VALUE, lcid,
2107 wFlags, pdp, pvarRes, pei, pspCaller);
2108 IHTMLLocation_Release(&location->IHTMLLocation_iface);
2112 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes,
2116 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
2118 HTMLWindow *This = impl_from_IDispatchEx(iface);
2120 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
2122 return IDispatchEx_DeleteMemberByName(&This->dispex.IDispatchEx_iface, bstrName, grfdex);
2125 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
2127 HTMLWindow *This = impl_from_IDispatchEx(iface);
2129 TRACE("(%p)->(%x)\n", This, id);
2131 return IDispatchEx_DeleteMemberByDispID(&This->dispex.IDispatchEx_iface, id);
2134 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
2136 HTMLWindow *This = impl_from_IDispatchEx(iface);
2138 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
2140 return IDispatchEx_GetMemberProperties(&This->dispex.IDispatchEx_iface, id, grfdexFetch,
2144 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
2146 HTMLWindow *This = impl_from_IDispatchEx(iface);
2148 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
2150 return IDispatchEx_GetMemberName(&This->dispex.IDispatchEx_iface, id, pbstrName);
2153 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
2155 HTMLWindow *This = impl_from_IDispatchEx(iface);
2157 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
2159 return IDispatchEx_GetNextDispID(&This->dispex.IDispatchEx_iface, grfdex, id, pid);
2162 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
2164 HTMLWindow *This = impl_from_IDispatchEx(iface);
2166 TRACE("(%p)->(%p)\n", This, ppunk);
2172 static const IDispatchExVtbl WindowDispExVtbl = {
2173 WindowDispEx_QueryInterface,
2174 WindowDispEx_AddRef,
2175 WindowDispEx_Release,
2176 WindowDispEx_GetTypeInfoCount,
2177 WindowDispEx_GetTypeInfo,
2178 WindowDispEx_GetIDsOfNames,
2179 WindowDispEx_Invoke,
2180 WindowDispEx_GetDispID,
2181 WindowDispEx_InvokeEx,
2182 WindowDispEx_DeleteMemberByName,
2183 WindowDispEx_DeleteMemberByDispID,
2184 WindowDispEx_GetMemberProperties,
2185 WindowDispEx_GetMemberName,
2186 WindowDispEx_GetNextDispID,
2187 WindowDispEx_GetNameSpaceParent
2190 static inline HTMLWindow *impl_from_IServiceProvider(IServiceProvider *iface)
2192 return CONTAINING_RECORD(iface, HTMLWindow, IServiceProvider_iface);
2195 static HRESULT WINAPI HTMLWindowSP_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
2197 HTMLWindow *This = impl_from_IServiceProvider(iface);
2198 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2201 static ULONG WINAPI HTMLWindowSP_AddRef(IServiceProvider *iface)
2203 HTMLWindow *This = impl_from_IServiceProvider(iface);
2204 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2207 static ULONG WINAPI HTMLWindowSP_Release(IServiceProvider *iface)
2209 HTMLWindow *This = impl_from_IServiceProvider(iface);
2210 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2213 static HRESULT WINAPI HTMLWindowSP_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv)
2215 HTMLWindow *This = impl_from_IServiceProvider(iface);
2217 if(IsEqualGUID(guidService, &IID_IHTMLWindow2)) {
2218 TRACE("IID_IHTMLWindow2\n");
2219 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2222 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
2225 return E_NOINTERFACE;
2227 return IServiceProvider_QueryService(&This->doc_obj->basedoc.IServiceProvider_iface,
2228 guidService, riid, ppv);
2231 static const IServiceProviderVtbl ServiceProviderVtbl = {
2232 HTMLWindowSP_QueryInterface,
2233 HTMLWindowSP_AddRef,
2234 HTMLWindowSP_Release,
2235 HTMLWindowSP_QueryService
2238 static inline HTMLWindow *impl_from_DispatchEx(DispatchEx *iface)
2240 return CONTAINING_RECORD(iface, HTMLWindow, dispex);
2243 static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2244 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2246 HTMLWindow *This = impl_from_DispatchEx(dispex);
2247 global_prop_t *prop;
2251 idx = id - MSHTML_DISPID_CUSTOM_MIN;
2252 if(idx >= This->global_prop_cnt)
2253 return DISP_E_MEMBERNOTFOUND;
2255 prop = This->global_props+idx;
2257 switch(prop->type) {
2258 case GLOBAL_SCRIPTVAR: {
2262 disp = get_script_disp(prop->script_host);
2264 return E_UNEXPECTED;
2266 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&iface);
2267 if(SUCCEEDED(hres)) {
2268 TRACE("%s >>>\n", debugstr_w(prop->name));
2269 hres = IDispatchEx_InvokeEx(iface, prop->id, lcid, flags, params, res, ei, caller);
2271 TRACE("%s <<<\n", debugstr_w(prop->name));
2273 WARN("%s <<< %08x\n", debugstr_w(prop->name), hres);
2274 IDispatchEx_Release(iface);
2276 FIXME("No IDispatchEx\n");
2278 IDispatch_Release(disp);
2281 case GLOBAL_ELEMENTVAR: {
2284 hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
2290 return DISP_E_MEMBERNOTFOUND;
2292 V_VT(res) = VT_DISPATCH;
2293 V_DISPATCH(res) = (IDispatch*)elem;
2297 ERR("invalid type %d\n", prop->type);
2298 hres = DISP_E_MEMBERNOTFOUND;
2305 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl = {
2312 static const tid_t HTMLWindow_iface_tids[] = {
2320 static dispex_static_data_t HTMLWindow_dispex = {
2321 &HTMLWindow_dispex_vtbl,
2322 DispHTMLWindow2_tid,
2324 HTMLWindow_iface_tids
2327 HRESULT HTMLWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, HTMLWindow *parent, HTMLWindow **ret)
2332 window = heap_alloc_zero(sizeof(HTMLWindow));
2334 return E_OUTOFMEMORY;
2336 window->window_ref = heap_alloc(sizeof(windowref_t));
2337 if(!window->window_ref) {
2339 return E_OUTOFMEMORY;
2342 window->IHTMLWindow2_iface.lpVtbl = &HTMLWindow2Vtbl;
2343 window->IHTMLWindow3_iface.lpVtbl = &HTMLWindow3Vtbl;
2344 window->IHTMLWindow4_iface.lpVtbl = &HTMLWindow4Vtbl;
2345 window->IHTMLWindow6_iface.lpVtbl = &HTMLWindow6Vtbl;
2346 window->IHTMLPrivateWindow_iface.lpVtbl = &HTMLPrivateWindowVtbl;
2347 window->IDispatchEx_iface.lpVtbl = &WindowDispExVtbl;
2348 window->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
2350 window->doc_obj = doc_obj;
2352 window->window_ref->window = window;
2353 window->window_ref->ref = 1;
2355 init_dispex(&window->dispex, (IUnknown*)&window->IHTMLWindow2_iface, &HTMLWindow_dispex);
2358 nsIDOMWindow_AddRef(nswindow);
2359 window->nswindow = nswindow;
2362 window->scriptmode = parent ? parent->scriptmode : SCRIPTMODE_GECKO;
2363 window->readystate = READYSTATE_UNINITIALIZED;
2364 list_init(&window->script_hosts);
2366 hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0);
2368 IHTMLWindow2_Release(&window->IHTMLWindow2_iface);
2372 window->task_magic = get_task_target_magic();
2373 update_window_doc(window);
2375 list_init(&window->children);
2376 list_add_head(&window_list, &window->entry);
2379 IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
2381 window->parent = parent;
2382 list_add_tail(&parent->children, &window->sibling_entry);
2389 void update_window_doc(HTMLWindow *window)
2391 nsIDOMHTMLDocument *nshtmldoc;
2392 nsIDOMDocument *nsdoc;
2395 nsres = nsIDOMWindow_GetDocument(window->nswindow, &nsdoc);
2396 if(NS_FAILED(nsres) || !nsdoc) {
2397 ERR("GetDocument failed: %08x\n", nsres);
2401 nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
2402 nsIDOMDocument_Release(nsdoc);
2403 if(NS_FAILED(nsres)) {
2404 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres);
2408 if(!window->doc || window->doc->nsdoc != nshtmldoc) {
2409 HTMLDocumentNode *doc;
2412 hres = create_doc_from_nsdoc(nshtmldoc, window->doc_obj, window, &doc);
2413 if(SUCCEEDED(hres)) {
2414 window_set_docnode(window, doc);
2415 htmldoc_release(&doc->basedoc);
2417 ERR("create_doc_from_nsdoc failed: %08x\n", hres);
2421 nsIDOMHTMLDocument_Release(nshtmldoc);
2424 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
2428 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) {
2429 if(iter->nswindow == nswindow)