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_IHTMLWindow5, riid)) {
163 TRACE("(%p)->(IID_IHTMLWindow5 %p)\n", This, ppv);
164 *ppv = &This->IHTMLWindow5_iface;
165 }else if(IsEqualGUID(&IID_IHTMLWindow6, riid)) {
166 TRACE("(%p)->(IID_IHTMLWindow6 %p)\n", This, ppv);
167 *ppv = &This->IHTMLWindow6_iface;
168 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow, riid)) {
169 TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This, ppv);
170 *ppv = &This->IHTMLPrivateWindow_iface;
171 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
172 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
173 *ppv = &This->IServiceProvider_iface;
174 }else if(IsEqualGUID(&IID_ITravelLogClient, riid)) {
175 TRACE("(%p)->(IID_ITravelLogClient %p)\n", This, ppv);
176 *ppv = &This->ITravelLogClient_iface;
177 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
178 return *ppv ? S_OK : E_NOINTERFACE;
182 IUnknown_AddRef((IUnknown*)*ppv);
186 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
187 return E_NOINTERFACE;
190 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
192 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
193 LONG ref = InterlockedIncrement(&This->ref);
195 TRACE("(%p) ref=%d\n", This, ref);
200 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
202 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
203 LONG ref = InterlockedDecrement(&This->ref);
205 TRACE("(%p) ref=%d\n", This, ref);
210 remove_target_tasks(This->task_magic);
211 set_window_bscallback(This, NULL);
212 set_current_mon(This, NULL);
213 window_set_docnode(This, NULL);
214 release_children(This);
217 IInternetSecurityManager_Release(This->secmgr);
219 if(This->frame_element)
220 This->frame_element->content_window = NULL;
222 if(This->option_factory) {
223 This->option_factory->window = NULL;
224 IHTMLOptionElementFactory_Release(&This->option_factory->IHTMLOptionElementFactory_iface);
227 if(This->image_factory) {
228 This->image_factory->window = NULL;
229 IHTMLImageElementFactory_Release(&This->image_factory->IHTMLImageElementFactory_iface);
233 This->location->window = NULL;
234 IHTMLLocation_Release(&This->location->IHTMLLocation_iface);
238 IHTMLScreen_Release(This->screen);
240 for(i=0; i < This->global_prop_cnt; i++)
241 heap_free(This->global_props[i].name);
243 This->window_ref->window = NULL;
244 windowref_release(This->window_ref);
246 heap_free(This->global_props);
247 release_script_hosts(This);
250 nsIDOMWindow_Release(This->nswindow);
252 list_remove(&This->entry);
253 release_dispex(&This->dispex);
260 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
262 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
264 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
267 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
268 LCID lcid, ITypeInfo **ppTInfo)
270 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
272 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
275 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
276 LPOLESTR *rgszNames, UINT cNames,
277 LCID lcid, DISPID *rgDispId)
279 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
281 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
285 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
286 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
287 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
289 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
291 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
292 pDispParams, pVarResult, pExcepInfo, puArgErr);
295 static HRESULT get_frame_by_index(nsIDOMWindowCollection *nsFrames, PRUint32 index, HTMLWindow **ret)
298 nsIDOMWindow *nsWindow;
301 nsres = nsIDOMWindowCollection_GetLength(nsFrames, &length);
302 if(NS_FAILED(nsres)) {
303 FIXME("nsIDOMWindowCollection_GetLength failed: 0x%08x\n", nsres);
308 return DISP_E_MEMBERNOTFOUND;
310 nsres = nsIDOMWindowCollection_Item(nsFrames, index, &nsWindow);
311 if(NS_FAILED(nsres)) {
312 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
316 *ret = nswindow_to_window(nsWindow);
318 nsIDOMWindow_Release(nsWindow);
323 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
325 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
326 nsIDOMWindowCollection *nsFrames;
327 HTMLWindow *window = NULL;
331 TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
333 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nsFrames);
334 if(NS_FAILED(nsres)) {
335 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres);
339 switch(V_VT(pvarIndex)) {
341 int index = V_I4(pvarIndex);
342 TRACE("Getting index %d\n", index);
345 hres = get_frame_by_index(nsFrames, index, &window);
349 unsigned int index = V_UINT(pvarIndex);
350 TRACE("Getting index %u\n", index);
351 hres = get_frame_by_index(nsFrames, index, &window);
355 BSTR str = V_BSTR(pvarIndex);
358 TRACE("Getting name %s\n", wine_dbgstr_w(str));
360 nsIDOMWindowCollection_GetLength(nsFrames, &length);
363 for(i = 0; i < length && !window; ++i) {
364 HTMLWindow *cur_window;
365 nsIDOMWindow *nsWindow;
368 nsres = nsIDOMWindowCollection_Item(nsFrames, i, &nsWindow);
369 if(NS_FAILED(nsres)) {
370 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
375 cur_window = nswindow_to_window(nsWindow);
377 nsIDOMWindow_Release(nsWindow);
379 hres = IHTMLElement_get_id(&cur_window->frame_element->element.IHTMLElement_iface, &id);
381 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres);
385 if(!strcmpW(id, str))
396 nsIDOMWindowCollection_Release(nsFrames);
400 return DISP_E_MEMBERNOTFOUND;
402 IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
403 V_VT(pvarResult) = VT_DISPATCH;
404 V_DISPATCH(pvarResult) = (IDispatch*)window;
408 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
410 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
411 nsIDOMWindowCollection *nscollection;
415 TRACE("(%p)->(%p)\n", This, p);
417 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nscollection);
418 if(NS_FAILED(nsres)) {
419 ERR("GetFrames failed: %08x\n", nsres);
423 nsres = nsIDOMWindowCollection_GetLength(nscollection, &length);
424 nsIDOMWindowCollection_Release(nscollection);
425 if(NS_FAILED(nsres)) {
426 ERR("GetLength failed: %08x\n", nsres);
434 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
436 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
437 FIXME("(%p)->(%p): semi-stub\n", This, p);
439 /* FIXME: Should return a separate Window object */
440 *p = (IHTMLFramesCollection2*)&This->IHTMLWindow2_iface;
441 HTMLWindow2_AddRef(iface);
445 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
447 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
448 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
452 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
454 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
455 FIXME("(%p)->(%p)\n", This, p);
459 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
461 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
463 WARN("(%p)->(%s)\n", This, debugstr_w(v));
466 * FIXME: Since IE7, setting status is blocked, but still possible in certain circumstances.
467 * Ignoring the call should be enough for us.
472 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
474 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
476 TRACE("(%p)->(%p)\n", This, p);
483 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
484 LONG msec, VARIANT *language, LONG *timerID)
486 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
489 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
491 V_VT(&expr_var) = VT_BSTR;
492 V_BSTR(&expr_var) = expression;
494 return IHTMLWindow3_setTimeout(&This->IHTMLWindow3_iface, &expr_var, msec, language, timerID);
497 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID)
499 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
501 TRACE("(%p)->(%d)\n", This, timerID);
503 return clear_task_timer(&This->doc->basedoc, FALSE, timerID);
506 #define MAX_MESSAGE_LEN 2000
508 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
510 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
511 WCHAR title[100], *msg = message;
514 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
516 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, title,
517 sizeof(title)/sizeof(WCHAR))) {
518 WARN("Could not load message box title: %d\n", GetLastError());
522 len = SysStringLen(message);
523 if(len > MAX_MESSAGE_LEN) {
524 msg = heap_alloc((MAX_MESSAGE_LEN+1)*sizeof(WCHAR));
526 return E_OUTOFMEMORY;
527 memcpy(msg, message, MAX_MESSAGE_LEN*sizeof(WCHAR));
528 msg[MAX_MESSAGE_LEN] = 0;
531 MessageBoxW(This->doc_obj->hwnd, msg, title, MB_ICONWARNING);
537 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
538 VARIANT_BOOL *confirmed)
540 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
543 TRACE("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
545 if(!confirmed) return E_INVALIDARG;
547 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
548 sizeof(wszTitle)/sizeof(WCHAR))) {
549 WARN("Could not load message box title: %d\n", GetLastError());
550 *confirmed = VARIANT_TRUE;
554 if(MessageBoxW(This->doc_obj->hwnd, message, wszTitle,
555 MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
556 *confirmed = VARIANT_TRUE;
557 else *confirmed = VARIANT_FALSE;
569 static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
570 WPARAM wparam, LPARAM lparam)
576 prompt_arg *arg = (prompt_arg*)lparam;
579 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
580 sizeof(wszTitle)/sizeof(WCHAR))) {
581 WARN("Could not load message box title: %d\n", GetLastError());
582 EndDialog(hwnd, wparam);
586 SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
587 SetWindowTextW(hwnd, wszTitle);
588 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_PROMPT), arg->message);
589 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_EDIT), arg->dststr);
595 case MAKEWPARAM(IDCANCEL, BN_CLICKED):
596 EndDialog(hwnd, wparam);
598 case MAKEWPARAM(IDOK, BN_CLICKED):
601 (prompt_arg*)GetWindowLongPtrW(hwnd, DWLP_USER);
602 HWND hwndPrompt = GetDlgItem(hwnd, ID_PROMPT_EDIT);
603 INT len = GetWindowTextLengthW(hwndPrompt);
607 EndDialog(hwnd, wparam);
611 V_VT(arg->textdata) = VT_BSTR;
612 if(!len && !arg->dststr)
613 V_BSTR(arg->textdata) = NULL;
616 V_BSTR(arg->textdata) = SysAllocStringLen(NULL, len);
617 GetWindowTextW(hwndPrompt, V_BSTR(arg->textdata), len+1);
619 EndDialog(hwnd, wparam);
625 EndDialog(hwnd, IDCANCEL);
632 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
633 BSTR dststr, VARIANT *textdata)
635 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
638 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
640 if(textdata) V_VT(textdata) = VT_NULL;
642 arg.message = message;
644 arg.textdata = textdata;
646 DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
647 This->doc_obj->hwnd, prompt_dlgproc, (LPARAM)&arg);
651 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
653 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
655 TRACE("(%p)->(%p)\n", This, p);
657 if(!This->image_factory)
658 This->image_factory = HTMLImageElementFactory_Create(This);
660 *p = &This->image_factory->IHTMLImageElementFactory_iface;
661 IHTMLImageElementFactory_AddRef(*p);
666 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
668 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
669 HTMLLocation *location;
672 TRACE("(%p)->(%p)\n", This, p);
674 hres = get_location(This, &location);
678 *p = &location->IHTMLLocation_iface;
682 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
684 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
685 FIXME("(%p)->(%p)\n", This, p);
689 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
691 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
692 FIXME("(%p)->()\n", This);
696 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
698 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
699 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
703 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
705 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
706 FIXME("(%p)->(%p)\n", This, p);
710 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
712 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
714 TRACE("(%p)->(%p)\n", This, p);
716 *p = OmNavigator_Create();
720 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
722 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
726 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
728 nsAString_InitDepend(&name_str, v);
729 nsres = nsIDOMWindow_SetName(This->nswindow, &name_str);
730 nsAString_Finish(&name_str);
732 ERR("SetName failed: %08x\n", nsres);
737 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
739 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
744 TRACE("(%p)->(%p)\n", This, p);
746 nsAString_Init(&name_str, NULL);
747 nsres = nsIDOMWindow_GetName(This->nswindow, &name_str);
748 if(NS_SUCCEEDED(nsres)) {
749 const PRUnichar *name;
751 nsAString_GetData(&name_str, &name);
753 *p = SysAllocString(name);
754 hres = *p ? S_OK : E_OUTOFMEMORY;
760 ERR("GetName failed: %08x\n", nsres);
763 nsAString_Finish(&name_str);
768 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
770 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
771 TRACE("(%p)->(%p)\n", This, p);
774 *p = &This->parent->IHTMLWindow2_iface;
775 IHTMLWindow2_AddRef(*p);
782 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
783 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
785 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
786 INewWindowManager *new_window_mgr;
790 TRACE("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
791 debugstr_w(features), replace, pomWindowResult);
796 if(name && *name == '_') {
797 FIXME("Unsupported name %s\n", debugstr_w(name));
801 hres = do_query_service((IUnknown*)This->doc_obj->client, &SID_SNewWindowManager, &IID_INewWindowManager,
802 (void**)&new_window_mgr);
804 FIXME("No INewWindowManager\n");
808 hres = INewWindowManager_EvaluateNewWindow(new_window_mgr, url, name, This->url,
809 features, !!replace, This->doc_obj->has_popup ? 0 : NWMF_FIRST, 0);
810 INewWindowManager_Release(new_window_mgr);
811 This->doc_obj->has_popup = TRUE;
813 *pomWindowResult = NULL;
817 hres = create_relative_uri(This, url, &uri);
821 hres = navigate_new_window(This, uri, name, pomWindowResult);
826 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
828 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
830 TRACE("(%p)->(%p)\n", This, p);
832 /* FIXME: We should return kind of proxy window here. */
833 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
834 *p = &This->IHTMLWindow2_iface;
838 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
840 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
842 TRACE("(%p)->(%p)\n", This, p);
847 *p = &curr->IHTMLWindow2_iface;
848 IHTMLWindow2_AddRef(*p);
853 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
855 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
857 TRACE("(%p)->(%p)\n", This, p);
859 /* FIXME: We should return kind of proxy window here. */
860 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
861 *p = &This->IHTMLWindow2_iface;
865 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
867 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
868 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
872 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
874 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
875 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
879 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
881 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
882 FIXME("(%p)->(%p)\n", This, p);
886 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
888 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
889 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
893 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
895 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
896 FIXME("(%p)->(%p)\n", This, p);
900 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
902 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
904 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
906 return set_window_event(This, EVENTID_LOAD, &v);
909 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
911 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
913 TRACE("(%p)->(%p)\n", This, p);
915 return get_window_event(This, EVENTID_LOAD, p);
918 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
920 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
922 TRACE("(%p)->(v(%d))\n", This, V_VT(&v));
924 return set_window_event(This, EVENTID_BEFOREUNLOAD, &v);
927 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
929 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
931 TRACE("(%p)->(%p)\n", This, p);
933 return get_window_event(This, EVENTID_BEFOREUNLOAD, p);
936 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
938 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
939 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
943 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
945 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
946 FIXME("(%p)->(%p)\n", This, p);
950 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
952 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
953 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
957 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
959 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
960 FIXME("(%p)->(%p)\n", This, p);
964 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
966 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
967 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
971 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
973 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
974 FIXME("(%p)->(%p)\n", This, p);
978 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
980 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
982 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
984 return set_window_event(This, EVENTID_RESIZE, &v);
987 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
989 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
991 TRACE("(%p)->(%p)\n", This, p);
993 return get_window_event(This, EVENTID_RESIZE, p);
996 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
998 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
999 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
1003 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
1005 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1006 FIXME("(%p)->(%p)\n", This, p);
1010 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
1012 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1014 TRACE("(%p)->(%p)\n", This, p);
1017 /* FIXME: We should return a wrapper object here */
1018 *p = &This->doc->basedoc.IHTMLDocument2_iface;
1019 IHTMLDocument2_AddRef(*p);
1027 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
1029 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1031 TRACE("(%p)->(%p)\n", This, p);
1034 IHTMLEventObj_AddRef(This->event);
1039 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
1041 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1042 FIXME("(%p)->(%p)\n", This, p);
1046 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
1047 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
1049 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1050 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
1054 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
1057 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1058 FIXME("(%p)->(%s v(%d) %s)\n", This, debugstr_w(helpURL), V_VT(&helpArg), debugstr_w(features));
1062 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
1064 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1066 TRACE("(%p)->(%p)\n", This, p);
1071 hres = HTMLScreen_Create(&This->screen);
1077 IHTMLScreen_AddRef(This->screen);
1081 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
1083 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1085 TRACE("(%p)->(%p)\n", This, p);
1087 if(!This->option_factory)
1088 This->option_factory = HTMLOptionElementFactory_Create(This);
1090 *p = &This->option_factory->IHTMLOptionElementFactory_iface;
1091 IHTMLOptionElementFactory_AddRef(*p);
1096 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
1098 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1100 TRACE("(%p)->()\n", This);
1103 SetFocus(This->doc_obj->hwnd);
1107 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
1109 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1110 FIXME("(%p)->(%p)\n", This, p);
1114 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
1116 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1117 FIXME("(%p)->()\n", This);
1121 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, LONG x, LONG y)
1123 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1124 FIXME("(%p)->(%d %d)\n", This, x, y);
1128 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
1130 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1131 FIXME("(%p)->(%p)\n", This, p);
1135 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
1136 LONG msec, VARIANT *language, LONG *timerID)
1138 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1141 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
1143 V_VT(&expr) = VT_BSTR;
1144 V_BSTR(&expr) = expression;
1145 return IHTMLWindow3_setInterval(&This->IHTMLWindow3_iface, &expr, msec, language, timerID);
1148 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerID)
1150 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1152 TRACE("(%p)->(%d)\n", This, timerID);
1154 return clear_task_timer(&This->doc->basedoc, TRUE, timerID);
1157 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
1159 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1160 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
1164 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
1166 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1167 FIXME("(%p)->(%p)\n", This, p);
1171 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
1174 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1176 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
1178 return exec_script(This, scode, language, pvarRet);
1181 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
1183 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1185 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1187 TRACE("(%p)->(%p)\n", This, String);
1190 return E_INVALIDARG;
1192 *String = SysAllocString(objectW);
1193 return *String ? S_OK : E_OUTOFMEMORY;
1196 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, LONG x, LONG y)
1198 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1201 TRACE("(%p)->(%d %d)\n", This, x, y);
1203 nsres = nsIDOMWindow_ScrollBy(This->nswindow, x, y);
1204 if(NS_FAILED(nsres))
1205 ERR("ScrollBy failed: %08x\n", nsres);
1210 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, LONG x, LONG y)
1212 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1215 TRACE("(%p)->(%d %d)\n", This, x, y);
1217 nsres = nsIDOMWindow_ScrollTo(This->nswindow, x, y);
1218 if(NS_FAILED(nsres))
1219 ERR("ScrollTo failed: %08x\n", nsres);
1224 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, LONG x, LONG y)
1226 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1227 FIXME("(%p)->(%d %d)\n", This, x, y);
1231 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, LONG x, LONG y)
1233 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1234 FIXME("(%p)->(%d %d)\n", This, x, y);
1238 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, LONG x, LONG y)
1240 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1241 FIXME("(%p)->(%d %d)\n", This, x, y);
1245 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, LONG x, LONG y)
1247 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1248 FIXME("(%p)->(%d %d)\n", This, x, y);
1252 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
1254 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1256 TRACE("(%p)->(%p)\n", This, p);
1260 if(!This->doc_obj->hostui)
1263 return IDocHostUIHandler_GetExternal(This->doc_obj->hostui, p);
1266 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
1267 HTMLWindow2_QueryInterface,
1269 HTMLWindow2_Release,
1270 HTMLWindow2_GetTypeInfoCount,
1271 HTMLWindow2_GetTypeInfo,
1272 HTMLWindow2_GetIDsOfNames,
1275 HTMLWindow2_get_length,
1276 HTMLWindow2_get_frames,
1277 HTMLWindow2_put_defaultStatus,
1278 HTMLWindow2_get_defaultStatus,
1279 HTMLWindow2_put_status,
1280 HTMLWindow2_get_status,
1281 HTMLWindow2_setTimeout,
1282 HTMLWindow2_clearTimeout,
1284 HTMLWindow2_confirm,
1286 HTMLWindow2_get_Image,
1287 HTMLWindow2_get_location,
1288 HTMLWindow2_get_history,
1290 HTMLWindow2_put_opener,
1291 HTMLWindow2_get_opener,
1292 HTMLWindow2_get_navigator,
1293 HTMLWindow2_put_name,
1294 HTMLWindow2_get_name,
1295 HTMLWindow2_get_parent,
1297 HTMLWindow2_get_self,
1298 HTMLWindow2_get_top,
1299 HTMLWindow2_get_window,
1300 HTMLWindow2_navigate,
1301 HTMLWindow2_put_onfocus,
1302 HTMLWindow2_get_onfocus,
1303 HTMLWindow2_put_onblur,
1304 HTMLWindow2_get_onblur,
1305 HTMLWindow2_put_onload,
1306 HTMLWindow2_get_onload,
1307 HTMLWindow2_put_onbeforeunload,
1308 HTMLWindow2_get_onbeforeunload,
1309 HTMLWindow2_put_onunload,
1310 HTMLWindow2_get_onunload,
1311 HTMLWindow2_put_onhelp,
1312 HTMLWindow2_get_onhelp,
1313 HTMLWindow2_put_onerror,
1314 HTMLWindow2_get_onerror,
1315 HTMLWindow2_put_onresize,
1316 HTMLWindow2_get_onresize,
1317 HTMLWindow2_put_onscroll,
1318 HTMLWindow2_get_onscroll,
1319 HTMLWindow2_get_document,
1320 HTMLWindow2_get_event,
1321 HTMLWindow2_get__newEnum,
1322 HTMLWindow2_showModalDialog,
1323 HTMLWindow2_showHelp,
1324 HTMLWindow2_get_screen,
1325 HTMLWindow2_get_Option,
1327 HTMLWindow2_get_closed,
1330 HTMLWindow2_get_clientInformation,
1331 HTMLWindow2_setInterval,
1332 HTMLWindow2_clearInterval,
1333 HTMLWindow2_put_offscreenBuffering,
1334 HTMLWindow2_get_offscreenBuffering,
1335 HTMLWindow2_execScript,
1336 HTMLWindow2_toString,
1337 HTMLWindow2_scrollBy,
1338 HTMLWindow2_scrollTo,
1341 HTMLWindow2_resizeTo,
1342 HTMLWindow2_resizeBy,
1343 HTMLWindow2_get_external
1346 static inline HTMLWindow *impl_from_IHTMLWindow3(IHTMLWindow3 *iface)
1348 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow3_iface);
1351 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
1353 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1355 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1358 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
1360 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1362 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1365 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
1367 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1369 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1372 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
1374 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1376 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1379 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
1380 LCID lcid, ITypeInfo **ppTInfo)
1382 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1384 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1387 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
1388 LPOLESTR *rgszNames, UINT cNames,
1389 LCID lcid, DISPID *rgDispId)
1391 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1393 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1397 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
1398 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1399 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1401 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1403 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1404 pDispParams, pVarResult, pExcepInfo, puArgErr);
1407 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, LONG *p)
1409 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1410 FIXME("(%p)->(%p)\n", This, p);
1414 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, LONG *p)
1416 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1417 FIXME("(%p)->(%p)\n", This, p);
1421 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
1423 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1425 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
1428 FIXME("No document\n");
1432 return attach_event(&This->doc->body_event_target, NULL, &This->doc->basedoc, event, pDisp, pfResult);
1435 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
1437 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1438 FIXME("(%p)->()\n", This);
1442 static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, LONG msec, VARIANT *language,
1443 BOOL interval, LONG *timer_id)
1445 IDispatch *disp = NULL;
1447 switch(V_VT(expr)) {
1449 disp = V_DISPATCH(expr);
1450 IDispatch_AddRef(disp);
1454 disp = script_parse_event(This, V_BSTR(expr));
1458 FIXME("unimplemented vt=%d\n", V_VT(expr));
1465 *timer_id = set_task_timer(&This->doc->basedoc, msec, interval, disp);
1466 IDispatch_Release(disp);
1471 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1472 VARIANT *language, LONG *timerID)
1474 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1476 TRACE("(%p)->(%p(%d) %d %p %p)\n", This, expression, V_VT(expression), msec, language, timerID);
1478 return window_set_timer(This, expression, msec, language, FALSE, timerID);
1481 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1482 VARIANT *language, LONG *timerID)
1484 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1486 TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID);
1488 return window_set_timer(This, expression, msec, language, TRUE, timerID);
1491 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
1493 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1494 FIXME("(%p)\n", This);
1498 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
1500 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1501 FIXME("(%p)->()\n", This);
1505 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
1507 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1508 FIXME("(%p)->(%p)\n", This, p);
1512 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
1514 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1515 FIXME("(%p)->()\n", This);
1519 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
1521 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1522 FIXME("(%p)->(%p)\n", This, p);
1526 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
1528 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1529 FIXME("(%p)->(%p)\n", This, p);
1533 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
1534 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
1536 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1537 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
1541 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
1542 HTMLWindow3_QueryInterface,
1544 HTMLWindow3_Release,
1545 HTMLWindow3_GetTypeInfoCount,
1546 HTMLWindow3_GetTypeInfo,
1547 HTMLWindow3_GetIDsOfNames,
1549 HTMLWindow3_get_screenLeft,
1550 HTMLWindow3_get_screenTop,
1551 HTMLWindow3_attachEvent,
1552 HTMLWindow3_detachEvent,
1553 HTMLWindow3_setTimeout,
1554 HTMLWindow3_setInterval,
1556 HTMLWindow3_put_onbeforeprint,
1557 HTMLWindow3_get_onbeforeprint,
1558 HTMLWindow3_put_onafterprint,
1559 HTMLWindow3_get_onafterprint,
1560 HTMLWindow3_get_clipboardData,
1561 HTMLWindow3_showModelessDialog
1564 static inline HTMLWindow *impl_from_IHTMLWindow4(IHTMLWindow4 *iface)
1566 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow4_iface);
1569 static HRESULT WINAPI HTMLWindow4_QueryInterface(IHTMLWindow4 *iface, REFIID riid, void **ppv)
1571 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1573 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1576 static ULONG WINAPI HTMLWindow4_AddRef(IHTMLWindow4 *iface)
1578 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1580 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1583 static ULONG WINAPI HTMLWindow4_Release(IHTMLWindow4 *iface)
1585 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1587 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1590 static HRESULT WINAPI HTMLWindow4_GetTypeInfoCount(IHTMLWindow4 *iface, UINT *pctinfo)
1592 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1594 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1597 static HRESULT WINAPI HTMLWindow4_GetTypeInfo(IHTMLWindow4 *iface, UINT iTInfo,
1598 LCID lcid, ITypeInfo **ppTInfo)
1600 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1602 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1605 static HRESULT WINAPI HTMLWindow4_GetIDsOfNames(IHTMLWindow4 *iface, REFIID riid,
1606 LPOLESTR *rgszNames, UINT cNames,
1607 LCID lcid, DISPID *rgDispId)
1609 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1611 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1615 static HRESULT WINAPI HTMLWindow4_Invoke(IHTMLWindow4 *iface, DISPID dispIdMember,
1616 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1617 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1619 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1621 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1622 pDispParams, pVarResult, pExcepInfo, puArgErr);
1625 static HRESULT WINAPI HTMLWindow4_createPopup(IHTMLWindow4 *iface, VARIANT *varArgIn,
1626 IDispatch **ppPopup)
1628 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1629 FIXME("(%p)->(%p %p)\n", This, varArgIn, ppPopup);
1633 static HRESULT WINAPI HTMLWindow4_get_frameElement(IHTMLWindow4 *iface, IHTMLFrameBase **p)
1635 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1636 TRACE("(%p)->(%p)\n", This, p);
1638 if(This->frame_element) {
1639 *p = &This->frame_element->IHTMLFrameBase_iface;
1640 IHTMLFrameBase_AddRef(*p);
1647 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl = {
1648 HTMLWindow4_QueryInterface,
1650 HTMLWindow4_Release,
1651 HTMLWindow4_GetTypeInfoCount,
1652 HTMLWindow4_GetTypeInfo,
1653 HTMLWindow4_GetIDsOfNames,
1655 HTMLWindow4_createPopup,
1656 HTMLWindow4_get_frameElement
1659 static inline HTMLWindow *impl_from_IHTMLWindow5(IHTMLWindow5 *iface)
1661 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow5_iface);
1664 static HRESULT WINAPI HTMLWindow5_QueryInterface(IHTMLWindow5 *iface, REFIID riid, void **ppv)
1666 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1668 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1671 static ULONG WINAPI HTMLWindow5_AddRef(IHTMLWindow5 *iface)
1673 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1675 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1678 static ULONG WINAPI HTMLWindow5_Release(IHTMLWindow5 *iface)
1680 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1682 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1685 static HRESULT WINAPI HTMLWindow5_GetTypeInfoCount(IHTMLWindow5 *iface, UINT *pctinfo)
1687 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1689 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1692 static HRESULT WINAPI HTMLWindow5_GetTypeInfo(IHTMLWindow5 *iface, UINT iTInfo,
1693 LCID lcid, ITypeInfo **ppTInfo)
1695 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1697 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1700 static HRESULT WINAPI HTMLWindow5_GetIDsOfNames(IHTMLWindow5 *iface, REFIID riid,
1701 LPOLESTR *rgszNames, UINT cNames, LCID lcid, DISPID *rgDispId)
1703 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1705 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1709 static HRESULT WINAPI HTMLWindow5_Invoke(IHTMLWindow5 *iface, DISPID dispIdMember,
1710 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1711 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1713 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1715 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1716 pDispParams, pVarResult, pExcepInfo, puArgErr);
1719 static HRESULT WINAPI HTMLWindow5_put_XMLHttpRequest(IHTMLWindow5 *iface, VARIANT v)
1721 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1722 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1726 static HRESULT WINAPI HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5 *iface, VARIANT *p)
1728 HTMLWindow *This = impl_from_IHTMLWindow5(iface);
1729 FIXME("(%p)->(%p)\n", This, p);
1733 static const IHTMLWindow5Vtbl HTMLWindow5Vtbl = {
1734 HTMLWindow5_QueryInterface,
1736 HTMLWindow5_Release,
1737 HTMLWindow5_GetTypeInfoCount,
1738 HTMLWindow5_GetTypeInfo,
1739 HTMLWindow5_GetIDsOfNames,
1741 HTMLWindow5_put_XMLHttpRequest,
1742 HTMLWindow5_get_XMLHttpRequest
1745 static inline HTMLWindow *impl_from_IHTMLWindow6(IHTMLWindow6 *iface)
1747 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow6_iface);
1750 static HRESULT WINAPI HTMLWindow6_QueryInterface(IHTMLWindow6 *iface, REFIID riid, void **ppv)
1752 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1754 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1757 static ULONG WINAPI HTMLWindow6_AddRef(IHTMLWindow6 *iface)
1759 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1761 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1764 static ULONG WINAPI HTMLWindow6_Release(IHTMLWindow6 *iface)
1766 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1768 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1771 static HRESULT WINAPI HTMLWindow6_GetTypeInfoCount(IHTMLWindow6 *iface, UINT *pctinfo)
1773 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1775 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1778 static HRESULT WINAPI HTMLWindow6_GetTypeInfo(IHTMLWindow6 *iface, UINT iTInfo,
1779 LCID lcid, ITypeInfo **ppTInfo)
1781 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1783 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1786 static HRESULT WINAPI HTMLWindow6_GetIDsOfNames(IHTMLWindow6 *iface, REFIID riid,
1787 LPOLESTR *rgszNames, UINT cNames,
1788 LCID lcid, DISPID *rgDispId)
1790 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1792 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1796 static HRESULT WINAPI HTMLWindow6_Invoke(IHTMLWindow6 *iface, DISPID dispIdMember,
1797 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1798 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1800 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1802 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1803 pDispParams, pVarResult, pExcepInfo, puArgErr);
1806 static HRESULT WINAPI HTMLWindow6_put_XDomainRequest(IHTMLWindow6 *iface, VARIANT v)
1808 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1809 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1813 static HRESULT WINAPI HTMLWindow6_get_XDomainRequest(IHTMLWindow6 *iface, VARIANT *p)
1815 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1816 FIXME("(%p)->(%p)\n", This, p);
1820 static HRESULT WINAPI HTMLWindow6_get_sessionStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1822 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1823 FIXME("(%p)->(%p)\n", This, p);
1827 static HRESULT WINAPI HTMLWindow6_get_localStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1829 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1830 FIXME("(%p)->(%p)\n", This, p);
1834 static HRESULT WINAPI HTMLWindow6_put_onhashchange(IHTMLWindow6 *iface, VARIANT v)
1836 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1837 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1841 static HRESULT WINAPI HTMLWindow6_get_onhashchange(IHTMLWindow6 *iface, VARIANT *p)
1843 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1844 FIXME("(%p)->(%p)\n", This, p);
1848 static HRESULT WINAPI HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6 *iface, LONG *p)
1850 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1851 FIXME("(%p)->(%p)\n", This, p);
1855 static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VARIANT targetOrigin)
1857 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1858 FIXME("(%p)->(%s %s)\n", This, debugstr_w(msg), debugstr_variant(&targetOrigin));
1862 static HRESULT WINAPI HTMLWindow6_toStaticHTML(IHTMLWindow6 *iface, BSTR bstrHTML, BSTR *pbstrStaticHTML)
1864 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1865 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrHTML), pbstrStaticHTML);
1869 static HRESULT WINAPI HTMLWindow6_put_onmessage(IHTMLWindow6 *iface, VARIANT v)
1871 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1872 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1876 static HRESULT WINAPI HTMLWindow6_get_onmessage(IHTMLWindow6 *iface, VARIANT *p)
1878 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1879 FIXME("(%p)->(%p)\n", This, p);
1883 static HRESULT WINAPI HTMLWindow6_msWriteProfilerMark(IHTMLWindow6 *iface, BSTR bstrProfilerMark)
1885 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1886 FIXME("(%p)->(%s)\n", This, debugstr_w(bstrProfilerMark));
1890 static const IHTMLWindow6Vtbl HTMLWindow6Vtbl = {
1891 HTMLWindow6_QueryInterface,
1893 HTMLWindow6_Release,
1894 HTMLWindow6_GetTypeInfoCount,
1895 HTMLWindow6_GetTypeInfo,
1896 HTMLWindow6_GetIDsOfNames,
1898 HTMLWindow6_put_XDomainRequest,
1899 HTMLWindow6_get_XDomainRequest,
1900 HTMLWindow6_get_sessionStorage,
1901 HTMLWindow6_get_localStorage,
1902 HTMLWindow6_put_onhashchange,
1903 HTMLWindow6_get_onhashchange,
1904 HTMLWindow6_get_maxConnectionsPerServer,
1905 HTMLWindow6_postMessage,
1906 HTMLWindow6_toStaticHTML,
1907 HTMLWindow6_put_onmessage,
1908 HTMLWindow6_get_onmessage,
1909 HTMLWindow6_msWriteProfilerMark
1912 static inline HTMLWindow *impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow *iface)
1914 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLPrivateWindow_iface);
1917 static HRESULT WINAPI HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow *iface, REFIID riid, void **ppv)
1919 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1921 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1924 static ULONG WINAPI HTMLPrivateWindow_AddRef(IHTMLPrivateWindow *iface)
1926 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1928 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1931 static ULONG WINAPI HTMLPrivateWindow_Release(IHTMLPrivateWindow *iface)
1933 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1935 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1938 static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface, BSTR url, BSTR arg2, BSTR arg3,
1939 BSTR arg4, VARIANT *post_data_var, VARIANT *headers_var, ULONG flags)
1941 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1942 OLECHAR *translated_url = NULL;
1943 DWORD post_data_size = 0;
1944 BYTE *post_data = NULL;
1945 WCHAR *headers = NULL;
1949 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This, debugstr_w(url), debugstr_w(arg2), debugstr_w(arg3), debugstr_w(arg4),
1950 debugstr_variant(post_data_var), debugstr_variant(headers_var), flags);
1952 if(This->doc_obj->hostui) {
1953 hres = IDocHostUIHandler_TranslateUrl(This->doc_obj->hostui, 0, url, &translated_url);
1955 translated_url = NULL;
1958 hres = CreateUri(translated_url ? translated_url : url, 0, 0, &uri);
1959 CoTaskMemFree(translated_url);
1964 if(V_VT(post_data_var) == (VT_ARRAY|VT_UI1)) {
1965 SafeArrayAccessData(V_ARRAY(post_data_var), (void**)&post_data);
1966 post_data_size = V_ARRAY(post_data_var)->rgsabound[0].cElements;
1970 if(headers_var && V_VT(headers_var) != VT_EMPTY && V_VT(headers_var) != VT_ERROR) {
1971 if(V_VT(headers_var) != VT_BSTR)
1972 return E_INVALIDARG;
1974 headers = V_BSTR(headers_var);
1977 hres = super_navigate(This, uri, headers, post_data, post_data_size);
1980 SafeArrayUnaccessData(V_ARRAY(post_data_var));
1985 static HRESULT WINAPI HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow *iface, BSTR *url)
1987 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1988 FIXME("(%p)->(%p)\n", This, url);
1992 static HRESULT WINAPI HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow *iface, IOleCommandTarget *cmdtrg)
1994 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1995 FIXME("(%p)->(%p)\n", This, cmdtrg);
1999 static HRESULT WINAPI HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow *iface, int arg)
2001 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2002 FIXME("(%p)->(%x)\n", This, arg);
2006 static HRESULT WINAPI HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow *iface, LPCWSTR name, IHTMLWindow2 **ret)
2008 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2009 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), ret);
2013 static HRESULT WINAPI HTMLPrivateWindow_GetAddressBarUrl(IHTMLPrivateWindow *iface, BSTR *url)
2015 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
2016 TRACE("(%p)->(%p)\n", This, url);
2019 return E_INVALIDARG;
2021 *url = SysAllocString(This->url);
2025 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl = {
2026 HTMLPrivateWindow_QueryInterface,
2027 HTMLPrivateWindow_AddRef,
2028 HTMLPrivateWindow_Release,
2029 HTMLPrivateWindow_SuperNavigate,
2030 HTMLPrivateWindow_GetPendingUrl,
2031 HTMLPrivateWindow_SetPICSTarget,
2032 HTMLPrivateWindow_PICSComplete,
2033 HTMLPrivateWindow_FindWindowByName,
2034 HTMLPrivateWindow_GetAddressBarUrl
2037 static inline HTMLWindow *impl_from_ITravelLogClient(ITravelLogClient *iface)
2039 return CONTAINING_RECORD(iface, HTMLWindow, ITravelLogClient_iface);
2042 static HRESULT WINAPI TravelLogClient_QueryInterface(ITravelLogClient *iface, REFIID riid, void **ppv)
2044 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2046 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2049 static ULONG WINAPI TravelLogClient_AddRef(ITravelLogClient *iface)
2051 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2053 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2056 static ULONG WINAPI TravelLogClient_Release(ITravelLogClient *iface)
2058 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2060 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2063 static HRESULT WINAPI TravelLogClient_FindWindowByIndex(ITravelLogClient *iface, DWORD dwID, IUnknown **ppunk)
2065 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2067 FIXME("(%p)->(%d %p) semi-stub\n", This, dwID, ppunk);
2073 static HRESULT WINAPI TravelLogClient_GetWindowData(ITravelLogClient *iface, IStream *pStream, LPWINDOWDATA pWinData)
2075 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2076 FIXME("(%p)->(%p %p)\n", This, pStream, pWinData);
2080 static HRESULT WINAPI TravelLogClient_LoadHistoryPosition(ITravelLogClient *iface, LPWSTR pszUrlLocation, DWORD dwPosition)
2082 HTMLWindow *This = impl_from_ITravelLogClient(iface);
2083 FIXME("(%p)->(%s %d)\n", This, debugstr_w(pszUrlLocation), dwPosition);
2087 static const ITravelLogClientVtbl TravelLogClientVtbl = {
2088 TravelLogClient_QueryInterface,
2089 TravelLogClient_AddRef,
2090 TravelLogClient_Release,
2091 TravelLogClient_FindWindowByIndex,
2092 TravelLogClient_GetWindowData,
2093 TravelLogClient_LoadHistoryPosition
2096 static inline HTMLWindow *impl_from_IDispatchEx(IDispatchEx *iface)
2098 return CONTAINING_RECORD(iface, HTMLWindow, IDispatchEx_iface);
2101 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
2103 HTMLWindow *This = impl_from_IDispatchEx(iface);
2105 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2108 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
2110 HTMLWindow *This = impl_from_IDispatchEx(iface);
2112 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2115 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
2117 HTMLWindow *This = impl_from_IDispatchEx(iface);
2119 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2122 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
2124 HTMLWindow *This = impl_from_IDispatchEx(iface);
2126 TRACE("(%p)->(%p)\n", This, pctinfo);
2128 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
2131 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
2132 LCID lcid, ITypeInfo **ppTInfo)
2134 HTMLWindow *This = impl_from_IDispatchEx(iface);
2136 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
2138 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
2141 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
2142 LPOLESTR *rgszNames, UINT cNames,
2143 LCID lcid, DISPID *rgDispId)
2145 HTMLWindow *This = impl_from_IDispatchEx(iface);
2149 WARN("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
2152 for(i=0; i < cNames; i++) {
2153 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
2154 hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
2162 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
2163 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2164 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2166 HTMLWindow *This = impl_from_IDispatchEx(iface);
2168 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
2169 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2171 /* FIXME: Use script dispatch */
2173 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2174 pDispParams, pVarResult, pExcepInfo, puArgErr);
2177 static global_prop_t *alloc_global_prop(HTMLWindow *This, global_prop_type_t type, BSTR name)
2179 if(This->global_prop_cnt == This->global_prop_size) {
2180 global_prop_t *new_props;
2183 if(This->global_props) {
2184 new_size = This->global_prop_size*2;
2185 new_props = heap_realloc(This->global_props, new_size*sizeof(global_prop_t));
2188 new_props = heap_alloc(new_size*sizeof(global_prop_t));
2192 This->global_props = new_props;
2193 This->global_prop_size = new_size;
2196 This->global_props[This->global_prop_cnt].name = heap_strdupW(name);
2197 if(!This->global_props[This->global_prop_cnt].name)
2200 This->global_props[This->global_prop_cnt].type = type;
2201 return This->global_props + This->global_prop_cnt++;
2204 static inline DWORD prop_to_dispid(HTMLWindow *This, global_prop_t *prop)
2206 return MSHTML_DISPID_CUSTOM_MIN + (prop-This->global_props);
2209 HRESULT search_window_props(HTMLWindow *This, BSTR bstrName, DWORD grfdex, DISPID *pid)
2212 ScriptHost *script_host;
2215 for(i=0; i < This->global_prop_cnt; i++) {
2216 /* FIXME: case sensitivity */
2217 if(!strcmpW(This->global_props[i].name, bstrName)) {
2218 *pid = MSHTML_DISPID_CUSTOM_MIN+i;
2223 if(find_global_prop(This, bstrName, grfdex, &script_host, &id)) {
2224 global_prop_t *prop;
2226 prop = alloc_global_prop(This, GLOBAL_SCRIPTVAR, bstrName);
2228 return E_OUTOFMEMORY;
2230 prop->script_host = script_host;
2233 *pid = prop_to_dispid(This, prop);
2237 return DISP_E_UNKNOWNNAME;
2240 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
2242 HTMLWindow *This = impl_from_IDispatchEx(iface);
2245 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
2247 hres = search_window_props(This, bstrName, grfdex, pid);
2248 if(hres != DISP_E_UNKNOWNNAME)
2251 hres = IDispatchEx_GetDispID(&This->dispex.IDispatchEx_iface, bstrName, grfdex, pid);
2252 if(hres != DISP_E_UNKNOWNNAME)
2256 global_prop_t *prop;
2259 hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
2261 if(SUCCEEDED(hres) && elem) {
2262 IHTMLElement_Release(elem);
2264 prop = alloc_global_prop(This, GLOBAL_ELEMENTVAR, bstrName);
2266 return E_OUTOFMEMORY;
2268 *pid = prop_to_dispid(This, prop);
2273 return DISP_E_UNKNOWNNAME;
2276 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
2277 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
2279 HTMLWindow *This = impl_from_IDispatchEx(iface);
2281 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
2283 if(id == DISPID_IHTMLWINDOW2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT)) {
2284 HTMLLocation *location;
2287 TRACE("forwarding to location.href\n");
2289 hres = get_location(This, &location);
2293 hres = IDispatchEx_InvokeEx(&location->dispex.IDispatchEx_iface, DISPID_VALUE, lcid,
2294 wFlags, pdp, pvarRes, pei, pspCaller);
2295 IHTMLLocation_Release(&location->IHTMLLocation_iface);
2299 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes,
2303 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
2305 HTMLWindow *This = impl_from_IDispatchEx(iface);
2307 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
2309 return IDispatchEx_DeleteMemberByName(&This->dispex.IDispatchEx_iface, bstrName, grfdex);
2312 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
2314 HTMLWindow *This = impl_from_IDispatchEx(iface);
2316 TRACE("(%p)->(%x)\n", This, id);
2318 return IDispatchEx_DeleteMemberByDispID(&This->dispex.IDispatchEx_iface, id);
2321 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
2323 HTMLWindow *This = impl_from_IDispatchEx(iface);
2325 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
2327 return IDispatchEx_GetMemberProperties(&This->dispex.IDispatchEx_iface, id, grfdexFetch,
2331 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
2333 HTMLWindow *This = impl_from_IDispatchEx(iface);
2335 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
2337 return IDispatchEx_GetMemberName(&This->dispex.IDispatchEx_iface, id, pbstrName);
2340 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
2342 HTMLWindow *This = impl_from_IDispatchEx(iface);
2344 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
2346 return IDispatchEx_GetNextDispID(&This->dispex.IDispatchEx_iface, grfdex, id, pid);
2349 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
2351 HTMLWindow *This = impl_from_IDispatchEx(iface);
2353 TRACE("(%p)->(%p)\n", This, ppunk);
2359 static const IDispatchExVtbl WindowDispExVtbl = {
2360 WindowDispEx_QueryInterface,
2361 WindowDispEx_AddRef,
2362 WindowDispEx_Release,
2363 WindowDispEx_GetTypeInfoCount,
2364 WindowDispEx_GetTypeInfo,
2365 WindowDispEx_GetIDsOfNames,
2366 WindowDispEx_Invoke,
2367 WindowDispEx_GetDispID,
2368 WindowDispEx_InvokeEx,
2369 WindowDispEx_DeleteMemberByName,
2370 WindowDispEx_DeleteMemberByDispID,
2371 WindowDispEx_GetMemberProperties,
2372 WindowDispEx_GetMemberName,
2373 WindowDispEx_GetNextDispID,
2374 WindowDispEx_GetNameSpaceParent
2377 static inline HTMLWindow *impl_from_IServiceProvider(IServiceProvider *iface)
2379 return CONTAINING_RECORD(iface, HTMLWindow, IServiceProvider_iface);
2382 static HRESULT WINAPI HTMLWindowSP_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
2384 HTMLWindow *This = impl_from_IServiceProvider(iface);
2385 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2388 static ULONG WINAPI HTMLWindowSP_AddRef(IServiceProvider *iface)
2390 HTMLWindow *This = impl_from_IServiceProvider(iface);
2391 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2394 static ULONG WINAPI HTMLWindowSP_Release(IServiceProvider *iface)
2396 HTMLWindow *This = impl_from_IServiceProvider(iface);
2397 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2400 static HRESULT WINAPI HTMLWindowSP_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv)
2402 HTMLWindow *This = impl_from_IServiceProvider(iface);
2404 if(IsEqualGUID(guidService, &IID_IHTMLWindow2)) {
2405 TRACE("IID_IHTMLWindow2\n");
2406 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2409 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
2412 return E_NOINTERFACE;
2414 return IServiceProvider_QueryService(&This->doc_obj->basedoc.IServiceProvider_iface,
2415 guidService, riid, ppv);
2418 static const IServiceProviderVtbl ServiceProviderVtbl = {
2419 HTMLWindowSP_QueryInterface,
2420 HTMLWindowSP_AddRef,
2421 HTMLWindowSP_Release,
2422 HTMLWindowSP_QueryService
2425 static inline HTMLWindow *impl_from_DispatchEx(DispatchEx *iface)
2427 return CONTAINING_RECORD(iface, HTMLWindow, dispex);
2430 static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2431 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2433 HTMLWindow *This = impl_from_DispatchEx(dispex);
2434 global_prop_t *prop;
2438 idx = id - MSHTML_DISPID_CUSTOM_MIN;
2439 if(idx >= This->global_prop_cnt)
2440 return DISP_E_MEMBERNOTFOUND;
2442 prop = This->global_props+idx;
2444 switch(prop->type) {
2445 case GLOBAL_SCRIPTVAR: {
2449 disp = get_script_disp(prop->script_host);
2451 return E_UNEXPECTED;
2453 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&iface);
2454 if(SUCCEEDED(hres)) {
2455 TRACE("%s >>>\n", debugstr_w(prop->name));
2456 hres = IDispatchEx_InvokeEx(iface, prop->id, lcid, flags, params, res, ei, caller);
2458 TRACE("%s <<<\n", debugstr_w(prop->name));
2460 WARN("%s <<< %08x\n", debugstr_w(prop->name), hres);
2461 IDispatchEx_Release(iface);
2463 FIXME("No IDispatchEx\n");
2465 IDispatch_Release(disp);
2468 case GLOBAL_ELEMENTVAR: {
2471 hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
2477 return DISP_E_MEMBERNOTFOUND;
2479 V_VT(res) = VT_DISPATCH;
2480 V_DISPATCH(res) = (IDispatch*)elem;
2484 ERR("invalid type %d\n", prop->type);
2485 hres = DISP_E_MEMBERNOTFOUND;
2492 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl = {
2499 static const tid_t HTMLWindow_iface_tids[] = {
2507 static dispex_static_data_t HTMLWindow_dispex = {
2508 &HTMLWindow_dispex_vtbl,
2509 DispHTMLWindow2_tid,
2511 HTMLWindow_iface_tids
2514 HRESULT HTMLWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, HTMLWindow *parent, HTMLWindow **ret)
2519 window = heap_alloc_zero(sizeof(HTMLWindow));
2521 return E_OUTOFMEMORY;
2523 window->window_ref = heap_alloc(sizeof(windowref_t));
2524 if(!window->window_ref) {
2526 return E_OUTOFMEMORY;
2529 window->IHTMLWindow2_iface.lpVtbl = &HTMLWindow2Vtbl;
2530 window->IHTMLWindow3_iface.lpVtbl = &HTMLWindow3Vtbl;
2531 window->IHTMLWindow4_iface.lpVtbl = &HTMLWindow4Vtbl;
2532 window->IHTMLWindow5_iface.lpVtbl = &HTMLWindow5Vtbl;
2533 window->IHTMLWindow6_iface.lpVtbl = &HTMLWindow6Vtbl;
2534 window->IHTMLPrivateWindow_iface.lpVtbl = &HTMLPrivateWindowVtbl;
2535 window->IDispatchEx_iface.lpVtbl = &WindowDispExVtbl;
2536 window->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
2537 window->ITravelLogClient_iface.lpVtbl = &TravelLogClientVtbl;
2539 window->doc_obj = doc_obj;
2541 window->window_ref->window = window;
2542 window->window_ref->ref = 1;
2544 init_dispex(&window->dispex, (IUnknown*)&window->IHTMLWindow2_iface, &HTMLWindow_dispex);
2547 nsIDOMWindow_AddRef(nswindow);
2548 window->nswindow = nswindow;
2551 window->scriptmode = parent ? parent->scriptmode : SCRIPTMODE_GECKO;
2552 window->readystate = READYSTATE_UNINITIALIZED;
2553 list_init(&window->script_hosts);
2555 hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0);
2557 IHTMLWindow2_Release(&window->IHTMLWindow2_iface);
2561 window->task_magic = get_task_target_magic();
2562 update_window_doc(window);
2564 list_init(&window->children);
2565 list_add_head(&window_list, &window->entry);
2568 IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
2570 window->parent = parent;
2571 list_add_tail(&parent->children, &window->sibling_entry);
2578 void update_window_doc(HTMLWindow *window)
2580 nsIDOMHTMLDocument *nshtmldoc;
2581 nsIDOMDocument *nsdoc;
2584 nsres = nsIDOMWindow_GetDocument(window->nswindow, &nsdoc);
2585 if(NS_FAILED(nsres) || !nsdoc) {
2586 ERR("GetDocument failed: %08x\n", nsres);
2590 nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
2591 nsIDOMDocument_Release(nsdoc);
2592 if(NS_FAILED(nsres)) {
2593 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres);
2597 if(!window->doc || window->doc->nsdoc != nshtmldoc) {
2598 HTMLDocumentNode *doc;
2601 hres = create_doc_from_nsdoc(nshtmldoc, window->doc_obj, window, &doc);
2602 if(SUCCEEDED(hres)) {
2603 window_set_docnode(window, doc);
2604 htmldoc_release(&doc->basedoc);
2606 ERR("create_doc_from_nsdoc failed: %08x\n", hres);
2610 nsIDOMHTMLDocument_Release(nshtmldoc);
2613 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
2617 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) {
2618 if(iter->nswindow == nswindow)