wined3d: Get rid of wined3d_surface_set_format().
[wine.git] / dlls / mshtml / htmlwindow.c
blob654f2e058cb876c2dd70d6660eabbff225af7221
1 /*
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
19 #include <stdarg.h>
21 #define COBJMACROS
23 #include "windef.h"
24 #include "winbase.h"
25 #include "winuser.h"
26 #include "ole2.h"
27 #include "mshtmdid.h"
28 #include "shlguid.h"
29 #include "shobjidl.h"
31 #define NO_SHLWAPI_REG
32 #include "shlwapi.h"
34 #include "wine/debug.h"
36 #include "mshtml_private.h"
37 #include "htmlevent.h"
38 #include "binding.h"
39 #include "resource.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)
47 if(window->doc) {
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;
56 if(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;
63 if(doc_node)
64 htmldoc_addref(&doc_node->basedoc);
67 if(doc_node && window->doc_obj && window->doc_obj->usermode == EDITMODE) {
68 nsAString mode_str;
69 nsresult nsres;
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);
76 if(NS_FAILED(nsres))
77 ERR("SetDesignMode failed: %08x\n", nsres);
81 static void release_children(HTMLWindow *This)
83 HTMLWindow *child;
85 while(!list_empty(&This->children)) {
86 child = LIST_ENTRY(list_tail(&This->children), HTMLWindow, sibling_entry);
88 list_remove(&child->sibling_entry);
89 child->parent = NULL;
90 IHTMLWindow2_Release(&child->IHTMLWindow2_iface);
94 static HRESULT get_location(HTMLWindow *This, HTMLLocation **ret)
96 if(This->location) {
97 IHTMLLocation_AddRef(&This->location->IHTMLLocation_iface);
98 }else {
99 HRESULT hres;
101 hres = HTMLLocation_Create(This, &This->location);
102 if(FAILED(hres))
103 return hres;
106 *ret = This->location;
107 return S_OK;
110 static inline HRESULT set_window_event(HTMLWindow *window, eventid_t eid, VARIANT *var)
112 if(!window->doc) {
113 FIXME("No document\n");
114 return E_FAIL;
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)
122 if(!window->doc) {
123 FIXME("No document\n");
124 return E_FAIL;
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);
139 *ppv = NULL;
141 if(IsEqualGUID(&IID_IUnknown, riid)) {
142 TRACE("(%p)->(IID_IUnknown %p)\n", This, ppv);
143 *ppv = &This->IHTMLWindow2_iface;
144 }else if(IsEqualGUID(&IID_IDispatch, riid)) {
145 TRACE("(%p)->(IID_IDispatch %p)\n", This, ppv);
146 *ppv = &This->IHTMLWindow2_iface;
147 }else if(IsEqualGUID(&IID_IDispatchEx, riid)) {
148 TRACE("(%p)->(IID_IDispatchEx %p)\n", This, ppv);
149 *ppv = &This->IDispatchEx_iface;
150 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2, riid)) {
151 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This, ppv);
152 *ppv = &This->IHTMLWindow2_iface;
153 }else if(IsEqualGUID(&IID_IHTMLWindow2, riid)) {
154 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This, ppv);
155 *ppv = &This->IHTMLWindow2_iface;
156 }else if(IsEqualGUID(&IID_IHTMLWindow3, riid)) {
157 TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This, ppv);
158 *ppv = &This->IHTMLWindow3_iface;
159 }else if(IsEqualGUID(&IID_IHTMLWindow4, riid)) {
160 TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This, ppv);
161 *ppv = &This->IHTMLWindow4_iface;
162 }else if(IsEqualGUID(&IID_IHTMLWindow6, riid)) {
163 TRACE("(%p)->(IID_IHTMLWindow6 %p)\n", This, ppv);
164 *ppv = &This->IHTMLWindow6_iface;
165 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow, riid)) {
166 TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This, ppv);
167 *ppv = &This->IHTMLPrivateWindow_iface;
168 }else if(IsEqualGUID(&IID_IServiceProvider, riid)) {
169 TRACE("(%p)->(IID_IServiceProvider %p)\n", This, ppv);
170 *ppv = &This->IServiceProvider_iface;
171 }else if(dispex_query_interface(&This->dispex, riid, ppv)) {
172 return *ppv ? S_OK : E_NOINTERFACE;
175 if(*ppv) {
176 IUnknown_AddRef((IUnknown*)*ppv);
177 return S_OK;
180 WARN("(%p)->(%s %p)\n", This, debugstr_guid(riid), ppv);
181 return E_NOINTERFACE;
184 static ULONG WINAPI HTMLWindow2_AddRef(IHTMLWindow2 *iface)
186 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
187 LONG ref = InterlockedIncrement(&This->ref);
189 TRACE("(%p) ref=%d\n", This, ref);
191 return ref;
194 static ULONG WINAPI HTMLWindow2_Release(IHTMLWindow2 *iface)
196 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
197 LONG ref = InterlockedDecrement(&This->ref);
199 TRACE("(%p) ref=%d\n", This, ref);
201 if(!ref) {
202 DWORD i;
204 remove_target_tasks(This->task_magic);
205 set_window_bscallback(This, NULL);
206 set_current_mon(This, NULL);
207 window_set_docnode(This, NULL);
208 release_children(This);
210 if(This->secmgr)
211 IInternetSecurityManager_Release(This->secmgr);
213 if(This->frame_element)
214 This->frame_element->content_window = NULL;
216 if(This->option_factory) {
217 This->option_factory->window = NULL;
218 IHTMLOptionElementFactory_Release(&This->option_factory->IHTMLOptionElementFactory_iface);
221 if(This->image_factory) {
222 This->image_factory->window = NULL;
223 IHTMLImageElementFactory_Release(&This->image_factory->IHTMLImageElementFactory_iface);
226 if(This->location) {
227 This->location->window = NULL;
228 IHTMLLocation_Release(&This->location->IHTMLLocation_iface);
231 if(This->screen)
232 IHTMLScreen_Release(This->screen);
234 for(i=0; i < This->global_prop_cnt; i++)
235 heap_free(This->global_props[i].name);
237 This->window_ref->window = NULL;
238 windowref_release(This->window_ref);
240 heap_free(This->global_props);
241 release_script_hosts(This);
243 if(This->nswindow)
244 nsIDOMWindow_Release(This->nswindow);
246 list_remove(&This->entry);
247 release_dispex(&This->dispex);
248 heap_free(This);
251 return ref;
254 static HRESULT WINAPI HTMLWindow2_GetTypeInfoCount(IHTMLWindow2 *iface, UINT *pctinfo)
256 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
258 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
261 static HRESULT WINAPI HTMLWindow2_GetTypeInfo(IHTMLWindow2 *iface, UINT iTInfo,
262 LCID lcid, ITypeInfo **ppTInfo)
264 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
266 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
269 static HRESULT WINAPI HTMLWindow2_GetIDsOfNames(IHTMLWindow2 *iface, REFIID riid,
270 LPOLESTR *rgszNames, UINT cNames,
271 LCID lcid, DISPID *rgDispId)
273 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
275 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
276 rgDispId);
279 static HRESULT WINAPI HTMLWindow2_Invoke(IHTMLWindow2 *iface, DISPID dispIdMember,
280 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
281 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
283 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
285 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
286 pDispParams, pVarResult, pExcepInfo, puArgErr);
289 static HRESULT get_frame_by_index(nsIDOMWindowCollection *nsFrames, PRUint32 index, HTMLWindow **ret)
291 PRUint32 length;
292 nsIDOMWindow *nsWindow;
293 nsresult nsres;
295 nsres = nsIDOMWindowCollection_GetLength(nsFrames, &length);
296 if(NS_FAILED(nsres)) {
297 FIXME("nsIDOMWindowCollection_GetLength failed: 0x%08x\n", nsres);
298 return E_FAIL;
301 if(index >= length)
302 return DISP_E_MEMBERNOTFOUND;
304 nsres = nsIDOMWindowCollection_Item(nsFrames, index, &nsWindow);
305 if(NS_FAILED(nsres)) {
306 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
307 return E_FAIL;
310 *ret = nswindow_to_window(nsWindow);
312 nsIDOMWindow_Release(nsWindow);
314 return S_OK;
317 static HRESULT WINAPI HTMLWindow2_item(IHTMLWindow2 *iface, VARIANT *pvarIndex, VARIANT *pvarResult)
319 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
320 nsIDOMWindowCollection *nsFrames;
321 HTMLWindow *window = NULL;
322 HRESULT hres = S_OK;
323 nsresult nsres;
325 TRACE("(%p)->(%p %p)\n", This, pvarIndex, pvarResult);
327 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nsFrames);
328 if(NS_FAILED(nsres)) {
329 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres);
330 return E_FAIL;
333 switch(V_VT(pvarIndex)) {
334 case VT_I4: {
335 int index = V_I4(pvarIndex);
336 TRACE("Getting index %d\n", index);
337 if(index < 0)
338 break;
339 hres = get_frame_by_index(nsFrames, index, &window);
340 break;
342 case VT_UINT: {
343 unsigned int index = V_UINT(pvarIndex);
344 TRACE("Getting index %u\n", index);
345 hres = get_frame_by_index(nsFrames, index, &window);
346 break;
348 case VT_BSTR: {
349 BSTR str = V_BSTR(pvarIndex);
350 PRUint32 length, i;
352 TRACE("Getting name %s\n", wine_dbgstr_w(str));
354 nsIDOMWindowCollection_GetLength(nsFrames, &length);
356 window = NULL;
357 for(i = 0; i < length && !window; ++i) {
358 HTMLWindow *cur_window;
359 nsIDOMWindow *nsWindow;
360 BSTR id;
362 nsres = nsIDOMWindowCollection_Item(nsFrames, i, &nsWindow);
363 if(NS_FAILED(nsres)) {
364 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres);
365 hres = E_FAIL;
366 break;
369 cur_window = nswindow_to_window(nsWindow);
371 nsIDOMWindow_Release(nsWindow);
373 hres = IHTMLElement_get_id(&cur_window->frame_element->element.IHTMLElement_iface, &id);
374 if(FAILED(hres)) {
375 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres);
376 break;
379 if(!strcmpW(id, str))
380 window = cur_window;
382 SysFreeString(id);
384 break;
386 default:
387 hres = E_INVALIDARG;
390 nsIDOMWindowCollection_Release(nsFrames);
391 if(FAILED(hres))
392 return hres;
393 if(!window)
394 return DISP_E_MEMBERNOTFOUND;
396 IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
397 V_VT(pvarResult) = VT_DISPATCH;
398 V_DISPATCH(pvarResult) = (IDispatch*)window;
399 return S_OK;
402 static HRESULT WINAPI HTMLWindow2_get_length(IHTMLWindow2 *iface, LONG *p)
404 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
405 nsIDOMWindowCollection *nscollection;
406 PRUint32 length;
407 nsresult nsres;
409 TRACE("(%p)->(%p)\n", This, p);
411 nsres = nsIDOMWindow_GetFrames(This->nswindow, &nscollection);
412 if(NS_FAILED(nsres)) {
413 ERR("GetFrames failed: %08x\n", nsres);
414 return E_FAIL;
417 nsres = nsIDOMWindowCollection_GetLength(nscollection, &length);
418 nsIDOMWindowCollection_Release(nscollection);
419 if(NS_FAILED(nsres)) {
420 ERR("GetLength failed: %08x\n", nsres);
421 return E_FAIL;
424 *p = length;
425 return S_OK;
428 static HRESULT WINAPI HTMLWindow2_get_frames(IHTMLWindow2 *iface, IHTMLFramesCollection2 **p)
430 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
431 FIXME("(%p)->(%p): semi-stub\n", This, p);
433 /* FIXME: Should return a separate Window object */
434 *p = (IHTMLFramesCollection2*)&This->IHTMLWindow2_iface;
435 HTMLWindow2_AddRef(iface);
436 return S_OK;
439 static HRESULT WINAPI HTMLWindow2_put_defaultStatus(IHTMLWindow2 *iface, BSTR v)
441 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
442 FIXME("(%p)->(%s)\n", This, debugstr_w(v));
443 return E_NOTIMPL;
446 static HRESULT WINAPI HTMLWindow2_get_defaultStatus(IHTMLWindow2 *iface, BSTR *p)
448 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
449 FIXME("(%p)->(%p)\n", This, p);
450 return E_NOTIMPL;
453 static HRESULT WINAPI HTMLWindow2_put_status(IHTMLWindow2 *iface, BSTR v)
455 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
457 WARN("(%p)->(%s)\n", This, debugstr_w(v));
460 * FIXME: Since IE7, setting status is blocked, but still possible in certain circumstances.
461 * Ignoring the call should be enough for us.
463 return S_OK;
466 static HRESULT WINAPI HTMLWindow2_get_status(IHTMLWindow2 *iface, BSTR *p)
468 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
470 TRACE("(%p)->(%p)\n", This, p);
472 /* See put_status */
473 *p = NULL;
474 return S_OK;
477 static HRESULT WINAPI HTMLWindow2_setTimeout(IHTMLWindow2 *iface, BSTR expression,
478 LONG msec, VARIANT *language, LONG *timerID)
480 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
481 VARIANT expr_var;
483 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
485 V_VT(&expr_var) = VT_BSTR;
486 V_BSTR(&expr_var) = expression;
488 return IHTMLWindow3_setTimeout(&This->IHTMLWindow3_iface, &expr_var, msec, language, timerID);
491 static HRESULT WINAPI HTMLWindow2_clearTimeout(IHTMLWindow2 *iface, LONG timerID)
493 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
495 TRACE("(%p)->(%d)\n", This, timerID);
497 return clear_task_timer(&This->doc->basedoc, FALSE, timerID);
500 #define MAX_MESSAGE_LEN 2000
502 static HRESULT WINAPI HTMLWindow2_alert(IHTMLWindow2 *iface, BSTR message)
504 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
505 WCHAR title[100], *msg = message;
506 DWORD len;
508 TRACE("(%p)->(%s)\n", This, debugstr_w(message));
510 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, title,
511 sizeof(title)/sizeof(WCHAR))) {
512 WARN("Could not load message box title: %d\n", GetLastError());
513 return S_OK;
516 len = SysStringLen(message);
517 if(len > MAX_MESSAGE_LEN) {
518 msg = heap_alloc((MAX_MESSAGE_LEN+1)*sizeof(WCHAR));
519 if(!msg)
520 return E_OUTOFMEMORY;
521 memcpy(msg, message, MAX_MESSAGE_LEN*sizeof(WCHAR));
522 msg[MAX_MESSAGE_LEN] = 0;
525 MessageBoxW(This->doc_obj->hwnd, msg, title, MB_ICONWARNING);
526 if(msg != message)
527 heap_free(msg);
528 return S_OK;
531 static HRESULT WINAPI HTMLWindow2_confirm(IHTMLWindow2 *iface, BSTR message,
532 VARIANT_BOOL *confirmed)
534 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
535 WCHAR wszTitle[100];
537 TRACE("(%p)->(%s %p)\n", This, debugstr_w(message), confirmed);
539 if(!confirmed) return E_INVALIDARG;
541 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
542 sizeof(wszTitle)/sizeof(WCHAR))) {
543 WARN("Could not load message box title: %d\n", GetLastError());
544 *confirmed = VARIANT_TRUE;
545 return S_OK;
548 if(MessageBoxW(This->doc_obj->hwnd, message, wszTitle,
549 MB_OKCANCEL|MB_ICONQUESTION)==IDOK)
550 *confirmed = VARIANT_TRUE;
551 else *confirmed = VARIANT_FALSE;
553 return S_OK;
556 typedef struct
558 BSTR message;
559 BSTR dststr;
560 VARIANT *textdata;
561 }prompt_arg;
563 static INT_PTR CALLBACK prompt_dlgproc(HWND hwnd, UINT msg,
564 WPARAM wparam, LPARAM lparam)
566 switch(msg)
568 case WM_INITDIALOG:
570 prompt_arg *arg = (prompt_arg*)lparam;
571 WCHAR wszTitle[100];
573 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE, wszTitle,
574 sizeof(wszTitle)/sizeof(WCHAR))) {
575 WARN("Could not load message box title: %d\n", GetLastError());
576 EndDialog(hwnd, wparam);
577 return FALSE;
580 SetWindowLongPtrW(hwnd, DWLP_USER, lparam);
581 SetWindowTextW(hwnd, wszTitle);
582 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_PROMPT), arg->message);
583 SetWindowTextW(GetDlgItem(hwnd, ID_PROMPT_EDIT), arg->dststr);
584 return FALSE;
586 case WM_COMMAND:
587 switch(wparam)
589 case MAKEWPARAM(IDCANCEL, BN_CLICKED):
590 EndDialog(hwnd, wparam);
591 return TRUE;
592 case MAKEWPARAM(IDOK, BN_CLICKED):
594 prompt_arg *arg =
595 (prompt_arg*)GetWindowLongPtrW(hwnd, DWLP_USER);
596 HWND hwndPrompt = GetDlgItem(hwnd, ID_PROMPT_EDIT);
597 INT len = GetWindowTextLengthW(hwndPrompt);
599 if(!arg->textdata)
601 EndDialog(hwnd, wparam);
602 return TRUE;
605 V_VT(arg->textdata) = VT_BSTR;
606 if(!len && !arg->dststr)
607 V_BSTR(arg->textdata) = NULL;
608 else
610 V_BSTR(arg->textdata) = SysAllocStringLen(NULL, len);
611 GetWindowTextW(hwndPrompt, V_BSTR(arg->textdata), len+1);
613 EndDialog(hwnd, wparam);
614 return TRUE;
617 return FALSE;
618 case WM_CLOSE:
619 EndDialog(hwnd, IDCANCEL);
620 return TRUE;
621 default:
622 return FALSE;
626 static HRESULT WINAPI HTMLWindow2_prompt(IHTMLWindow2 *iface, BSTR message,
627 BSTR dststr, VARIANT *textdata)
629 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
630 prompt_arg arg;
632 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(message), debugstr_w(dststr), textdata);
634 if(textdata) V_VT(textdata) = VT_NULL;
636 arg.message = message;
637 arg.dststr = dststr;
638 arg.textdata = textdata;
640 DialogBoxParamW(hInst, MAKEINTRESOURCEW(ID_PROMPT_DIALOG),
641 This->doc_obj->hwnd, prompt_dlgproc, (LPARAM)&arg);
642 return S_OK;
645 static HRESULT WINAPI HTMLWindow2_get_Image(IHTMLWindow2 *iface, IHTMLImageElementFactory **p)
647 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
649 TRACE("(%p)->(%p)\n", This, p);
651 if(!This->image_factory)
652 This->image_factory = HTMLImageElementFactory_Create(This);
654 *p = &This->image_factory->IHTMLImageElementFactory_iface;
655 IHTMLImageElementFactory_AddRef(*p);
657 return S_OK;
660 static HRESULT WINAPI HTMLWindow2_get_location(IHTMLWindow2 *iface, IHTMLLocation **p)
662 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
663 HTMLLocation *location;
664 HRESULT hres;
666 TRACE("(%p)->(%p)\n", This, p);
668 hres = get_location(This, &location);
669 if(FAILED(hres))
670 return hres;
672 *p = &location->IHTMLLocation_iface;
673 return S_OK;
676 static HRESULT WINAPI HTMLWindow2_get_history(IHTMLWindow2 *iface, IOmHistory **p)
678 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
679 FIXME("(%p)->(%p)\n", This, p);
680 return E_NOTIMPL;
683 static HRESULT WINAPI HTMLWindow2_close(IHTMLWindow2 *iface)
685 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
686 FIXME("(%p)->()\n", This);
687 return E_NOTIMPL;
690 static HRESULT WINAPI HTMLWindow2_put_opener(IHTMLWindow2 *iface, VARIANT v)
692 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
693 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
694 return E_NOTIMPL;
697 static HRESULT WINAPI HTMLWindow2_get_opener(IHTMLWindow2 *iface, VARIANT *p)
699 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
700 FIXME("(%p)->(%p)\n", This, p);
701 return E_NOTIMPL;
704 static HRESULT WINAPI HTMLWindow2_get_navigator(IHTMLWindow2 *iface, IOmNavigator **p)
706 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
708 TRACE("(%p)->(%p)\n", This, p);
710 *p = OmNavigator_Create();
711 return S_OK;
714 static HRESULT WINAPI HTMLWindow2_put_name(IHTMLWindow2 *iface, BSTR v)
716 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
717 nsAString name_str;
718 nsresult nsres;
720 TRACE("(%p)->(%s)\n", This, debugstr_w(v));
722 nsAString_InitDepend(&name_str, v);
723 nsres = nsIDOMWindow_SetName(This->nswindow, &name_str);
724 nsAString_Finish(&name_str);
725 if(NS_FAILED(nsres))
726 ERR("SetName failed: %08x\n", nsres);
728 return S_OK;
731 static HRESULT WINAPI HTMLWindow2_get_name(IHTMLWindow2 *iface, BSTR *p)
733 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
734 nsAString name_str;
735 nsresult nsres;
736 HRESULT hres;
738 TRACE("(%p)->(%p)\n", This, p);
740 nsAString_Init(&name_str, NULL);
741 nsres = nsIDOMWindow_GetName(This->nswindow, &name_str);
742 if(NS_SUCCEEDED(nsres)) {
743 const PRUnichar *name;
745 nsAString_GetData(&name_str, &name);
746 if(*name) {
747 *p = SysAllocString(name);
748 hres = *p ? S_OK : E_OUTOFMEMORY;
749 }else {
750 *p = NULL;
751 hres = S_OK;
753 }else {
754 ERR("GetName failed: %08x\n", nsres);
755 hres = E_FAIL;
757 nsAString_Finish(&name_str);
759 return hres;
762 static HRESULT WINAPI HTMLWindow2_get_parent(IHTMLWindow2 *iface, IHTMLWindow2 **p)
764 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
765 TRACE("(%p)->(%p)\n", This, p);
767 if(This->parent) {
768 *p = &This->parent->IHTMLWindow2_iface;
769 IHTMLWindow2_AddRef(*p);
770 }else
771 *p = NULL;
773 return S_OK;
776 static HRESULT WINAPI HTMLWindow2_open(IHTMLWindow2 *iface, BSTR url, BSTR name,
777 BSTR features, VARIANT_BOOL replace, IHTMLWindow2 **pomWindowResult)
779 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
780 INewWindowManager *new_window_mgr;
781 IUri *uri;
782 HRESULT hres;
784 TRACE("(%p)->(%s %s %s %x %p)\n", This, debugstr_w(url), debugstr_w(name),
785 debugstr_w(features), replace, pomWindowResult);
787 if(!This->doc_obj)
788 return E_UNEXPECTED;
790 if(name && *name == '_') {
791 FIXME("Unsupported name %s\n", debugstr_w(name));
792 return E_NOTIMPL;
795 hres = do_query_service((IUnknown*)This->doc_obj->client, &SID_SNewWindowManager, &IID_INewWindowManager,
796 (void**)&new_window_mgr);
797 if(FAILED(hres)) {
798 FIXME("No INewWindowManager\n");
799 return E_NOTIMPL;
802 hres = INewWindowManager_EvaluateNewWindow(new_window_mgr, url, name, This->url,
803 features, !!replace, This->doc_obj->has_popup ? 0 : NWMF_FIRST, 0);
804 INewWindowManager_Release(new_window_mgr);
805 This->doc_obj->has_popup = TRUE;
806 if(FAILED(hres)) {
807 *pomWindowResult = NULL;
808 return S_OK;
811 if(This->uri)
812 hres = CoInternetCombineUrlEx(This->uri, url, URL_ESCAPE_SPACES_ONLY|URL_DONT_ESCAPE_EXTRA_INFO, &uri, 0);
813 else
814 hres = CreateUri(url, 0, 0, &uri);
815 if(FAILED(hres))
816 return hres;
818 hres = navigate_new_window(This, uri, name, pomWindowResult);
819 IUri_Release(uri);
820 return hres;
823 static HRESULT WINAPI HTMLWindow2_get_self(IHTMLWindow2 *iface, IHTMLWindow2 **p)
825 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
827 TRACE("(%p)->(%p)\n", This, p);
829 /* FIXME: We should return kind of proxy window here. */
830 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
831 *p = &This->IHTMLWindow2_iface;
832 return S_OK;
835 static HRESULT WINAPI HTMLWindow2_get_top(IHTMLWindow2 *iface, IHTMLWindow2 **p)
837 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
838 HTMLWindow *curr;
839 TRACE("(%p)->(%p)\n", This, p);
841 curr = This;
842 while(curr->parent)
843 curr = curr->parent;
844 *p = &curr->IHTMLWindow2_iface;
845 IHTMLWindow2_AddRef(*p);
847 return S_OK;
850 static HRESULT WINAPI HTMLWindow2_get_window(IHTMLWindow2 *iface, IHTMLWindow2 **p)
852 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
854 TRACE("(%p)->(%p)\n", This, p);
856 /* FIXME: We should return kind of proxy window here. */
857 IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
858 *p = &This->IHTMLWindow2_iface;
859 return S_OK;
862 static HRESULT WINAPI HTMLWindow2_navigate(IHTMLWindow2 *iface, BSTR url)
864 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
865 FIXME("(%p)->(%s)\n", This, debugstr_w(url));
866 return E_NOTIMPL;
869 static HRESULT WINAPI HTMLWindow2_put_onfocus(IHTMLWindow2 *iface, VARIANT v)
871 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
872 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
873 return E_NOTIMPL;
876 static HRESULT WINAPI HTMLWindow2_get_onfocus(IHTMLWindow2 *iface, VARIANT *p)
878 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
879 FIXME("(%p)->(%p)\n", This, p);
880 return E_NOTIMPL;
883 static HRESULT WINAPI HTMLWindow2_put_onblur(IHTMLWindow2 *iface, VARIANT v)
885 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
886 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
887 return E_NOTIMPL;
890 static HRESULT WINAPI HTMLWindow2_get_onblur(IHTMLWindow2 *iface, VARIANT *p)
892 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
893 FIXME("(%p)->(%p)\n", This, p);
894 return E_NOTIMPL;
897 static HRESULT WINAPI HTMLWindow2_put_onload(IHTMLWindow2 *iface, VARIANT v)
899 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
901 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
903 return set_window_event(This, EVENTID_LOAD, &v);
906 static HRESULT WINAPI HTMLWindow2_get_onload(IHTMLWindow2 *iface, VARIANT *p)
908 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
910 TRACE("(%p)->(%p)\n", This, p);
912 return get_window_event(This, EVENTID_LOAD, p);
915 static HRESULT WINAPI HTMLWindow2_put_onbeforeunload(IHTMLWindow2 *iface, VARIANT v)
917 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
919 TRACE("(%p)->(v(%d))\n", This, V_VT(&v));
921 return set_window_event(This, EVENTID_BEFOREUNLOAD, &v);
924 static HRESULT WINAPI HTMLWindow2_get_onbeforeunload(IHTMLWindow2 *iface, VARIANT *p)
926 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
928 TRACE("(%p)->(%p)\n", This, p);
930 return get_window_event(This, EVENTID_BEFOREUNLOAD, p);
933 static HRESULT WINAPI HTMLWindow2_put_onunload(IHTMLWindow2 *iface, VARIANT v)
935 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
936 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
937 return E_NOTIMPL;
940 static HRESULT WINAPI HTMLWindow2_get_onunload(IHTMLWindow2 *iface, VARIANT *p)
942 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
943 FIXME("(%p)->(%p)\n", This, p);
944 return E_NOTIMPL;
947 static HRESULT WINAPI HTMLWindow2_put_onhelp(IHTMLWindow2 *iface, VARIANT v)
949 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
950 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
951 return E_NOTIMPL;
954 static HRESULT WINAPI HTMLWindow2_get_onhelp(IHTMLWindow2 *iface, VARIANT *p)
956 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
957 FIXME("(%p)->(%p)\n", This, p);
958 return E_NOTIMPL;
961 static HRESULT WINAPI HTMLWindow2_put_onerror(IHTMLWindow2 *iface, VARIANT v)
963 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
964 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
965 return E_NOTIMPL;
968 static HRESULT WINAPI HTMLWindow2_get_onerror(IHTMLWindow2 *iface, VARIANT *p)
970 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
971 FIXME("(%p)->(%p)\n", This, p);
972 return E_NOTIMPL;
975 static HRESULT WINAPI HTMLWindow2_put_onresize(IHTMLWindow2 *iface, VARIANT v)
977 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
979 TRACE("(%p)->(%s)\n", This, debugstr_variant(&v));
981 return set_window_event(This, EVENTID_RESIZE, &v);
984 static HRESULT WINAPI HTMLWindow2_get_onresize(IHTMLWindow2 *iface, VARIANT *p)
986 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
988 TRACE("(%p)->(%p)\n", This, p);
990 return get_window_event(This, EVENTID_RESIZE, p);
993 static HRESULT WINAPI HTMLWindow2_put_onscroll(IHTMLWindow2 *iface, VARIANT v)
995 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
996 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
997 return E_NOTIMPL;
1000 static HRESULT WINAPI HTMLWindow2_get_onscroll(IHTMLWindow2 *iface, VARIANT *p)
1002 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1003 FIXME("(%p)->(%p)\n", This, p);
1004 return E_NOTIMPL;
1007 static HRESULT WINAPI HTMLWindow2_get_document(IHTMLWindow2 *iface, IHTMLDocument2 **p)
1009 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1011 TRACE("(%p)->(%p)\n", This, p);
1013 if(This->doc) {
1014 /* FIXME: We should return a wrapper object here */
1015 *p = &This->doc->basedoc.IHTMLDocument2_iface;
1016 IHTMLDocument2_AddRef(*p);
1017 }else {
1018 *p = NULL;
1021 return S_OK;
1024 static HRESULT WINAPI HTMLWindow2_get_event(IHTMLWindow2 *iface, IHTMLEventObj **p)
1026 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1028 TRACE("(%p)->(%p)\n", This, p);
1030 if(This->event)
1031 IHTMLEventObj_AddRef(This->event);
1032 *p = This->event;
1033 return S_OK;
1036 static HRESULT WINAPI HTMLWindow2_get__newEnum(IHTMLWindow2 *iface, IUnknown **p)
1038 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1039 FIXME("(%p)->(%p)\n", This, p);
1040 return E_NOTIMPL;
1043 static HRESULT WINAPI HTMLWindow2_showModalDialog(IHTMLWindow2 *iface, BSTR dialog,
1044 VARIANT *varArgIn, VARIANT *varOptions, VARIANT *varArgOut)
1046 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1047 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(dialog), varArgIn, varOptions, varArgOut);
1048 return E_NOTIMPL;
1051 static HRESULT WINAPI HTMLWindow2_showHelp(IHTMLWindow2 *iface, BSTR helpURL, VARIANT helpArg,
1052 BSTR features)
1054 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1055 FIXME("(%p)->(%s v(%d) %s)\n", This, debugstr_w(helpURL), V_VT(&helpArg), debugstr_w(features));
1056 return E_NOTIMPL;
1059 static HRESULT WINAPI HTMLWindow2_get_screen(IHTMLWindow2 *iface, IHTMLScreen **p)
1061 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1063 TRACE("(%p)->(%p)\n", This, p);
1065 if(!This->screen) {
1066 HRESULT hres;
1068 hres = HTMLScreen_Create(&This->screen);
1069 if(FAILED(hres))
1070 return hres;
1073 *p = This->screen;
1074 IHTMLScreen_AddRef(This->screen);
1075 return S_OK;
1078 static HRESULT WINAPI HTMLWindow2_get_Option(IHTMLWindow2 *iface, IHTMLOptionElementFactory **p)
1080 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1082 TRACE("(%p)->(%p)\n", This, p);
1084 if(!This->option_factory)
1085 This->option_factory = HTMLOptionElementFactory_Create(This);
1087 *p = &This->option_factory->IHTMLOptionElementFactory_iface;
1088 IHTMLOptionElementFactory_AddRef(*p);
1090 return S_OK;
1093 static HRESULT WINAPI HTMLWindow2_focus(IHTMLWindow2 *iface)
1095 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1097 TRACE("(%p)->()\n", This);
1099 if(This->doc_obj)
1100 SetFocus(This->doc_obj->hwnd);
1101 return S_OK;
1104 static HRESULT WINAPI HTMLWindow2_get_closed(IHTMLWindow2 *iface, VARIANT_BOOL *p)
1106 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1107 FIXME("(%p)->(%p)\n", This, p);
1108 return E_NOTIMPL;
1111 static HRESULT WINAPI HTMLWindow2_blur(IHTMLWindow2 *iface)
1113 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1114 FIXME("(%p)->()\n", This);
1115 return E_NOTIMPL;
1118 static HRESULT WINAPI HTMLWindow2_scroll(IHTMLWindow2 *iface, LONG x, LONG y)
1120 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1121 FIXME("(%p)->(%d %d)\n", This, x, y);
1122 return E_NOTIMPL;
1125 static HRESULT WINAPI HTMLWindow2_get_clientInformation(IHTMLWindow2 *iface, IOmNavigator **p)
1127 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1128 FIXME("(%p)->(%p)\n", This, p);
1129 return E_NOTIMPL;
1132 static HRESULT WINAPI HTMLWindow2_setInterval(IHTMLWindow2 *iface, BSTR expression,
1133 LONG msec, VARIANT *language, LONG *timerID)
1135 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1136 VARIANT expr;
1138 TRACE("(%p)->(%s %d %p %p)\n", This, debugstr_w(expression), msec, language, timerID);
1140 V_VT(&expr) = VT_BSTR;
1141 V_BSTR(&expr) = expression;
1142 return IHTMLWindow3_setInterval(&This->IHTMLWindow3_iface, &expr, msec, language, timerID);
1145 static HRESULT WINAPI HTMLWindow2_clearInterval(IHTMLWindow2 *iface, LONG timerID)
1147 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1149 TRACE("(%p)->(%d)\n", This, timerID);
1151 return clear_task_timer(&This->doc->basedoc, TRUE, timerID);
1154 static HRESULT WINAPI HTMLWindow2_put_offscreenBuffering(IHTMLWindow2 *iface, VARIANT v)
1156 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1157 FIXME("(%p)->(v(%d))\n", This, V_VT(&v));
1158 return E_NOTIMPL;
1161 static HRESULT WINAPI HTMLWindow2_get_offscreenBuffering(IHTMLWindow2 *iface, VARIANT *p)
1163 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1164 FIXME("(%p)->(%p)\n", This, p);
1165 return E_NOTIMPL;
1168 static HRESULT WINAPI HTMLWindow2_execScript(IHTMLWindow2 *iface, BSTR scode, BSTR language,
1169 VARIANT *pvarRet)
1171 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1173 TRACE("(%p)->(%s %s %p)\n", This, debugstr_w(scode), debugstr_w(language), pvarRet);
1175 return exec_script(This, scode, language, pvarRet);
1178 static HRESULT WINAPI HTMLWindow2_toString(IHTMLWindow2 *iface, BSTR *String)
1180 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1182 static const WCHAR objectW[] = {'[','o','b','j','e','c','t',']',0};
1184 TRACE("(%p)->(%p)\n", This, String);
1186 if(!String)
1187 return E_INVALIDARG;
1189 *String = SysAllocString(objectW);
1190 return *String ? S_OK : E_OUTOFMEMORY;
1193 static HRESULT WINAPI HTMLWindow2_scrollBy(IHTMLWindow2 *iface, LONG x, LONG y)
1195 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1196 nsresult nsres;
1198 TRACE("(%p)->(%d %d)\n", This, x, y);
1200 nsres = nsIDOMWindow_ScrollBy(This->nswindow, x, y);
1201 if(NS_FAILED(nsres))
1202 ERR("ScrollBy failed: %08x\n", nsres);
1204 return S_OK;
1207 static HRESULT WINAPI HTMLWindow2_scrollTo(IHTMLWindow2 *iface, LONG x, LONG y)
1209 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1210 nsresult nsres;
1212 TRACE("(%p)->(%d %d)\n", This, x, y);
1214 nsres = nsIDOMWindow_ScrollTo(This->nswindow, x, y);
1215 if(NS_FAILED(nsres))
1216 ERR("ScrollTo failed: %08x\n", nsres);
1218 return S_OK;
1221 static HRESULT WINAPI HTMLWindow2_moveTo(IHTMLWindow2 *iface, LONG x, LONG y)
1223 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1224 FIXME("(%p)->(%d %d)\n", This, x, y);
1225 return E_NOTIMPL;
1228 static HRESULT WINAPI HTMLWindow2_moveBy(IHTMLWindow2 *iface, LONG x, LONG y)
1230 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1231 FIXME("(%p)->(%d %d)\n", This, x, y);
1232 return E_NOTIMPL;
1235 static HRESULT WINAPI HTMLWindow2_resizeTo(IHTMLWindow2 *iface, LONG x, LONG y)
1237 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1238 FIXME("(%p)->(%d %d)\n", This, x, y);
1239 return E_NOTIMPL;
1242 static HRESULT WINAPI HTMLWindow2_resizeBy(IHTMLWindow2 *iface, LONG x, LONG y)
1244 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1245 FIXME("(%p)->(%d %d)\n", This, x, y);
1246 return E_NOTIMPL;
1249 static HRESULT WINAPI HTMLWindow2_get_external(IHTMLWindow2 *iface, IDispatch **p)
1251 HTMLWindow *This = impl_from_IHTMLWindow2(iface);
1253 TRACE("(%p)->(%p)\n", This, p);
1255 *p = NULL;
1257 if(!This->doc_obj->hostui)
1258 return S_OK;
1260 return IDocHostUIHandler_GetExternal(This->doc_obj->hostui, p);
1263 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl = {
1264 HTMLWindow2_QueryInterface,
1265 HTMLWindow2_AddRef,
1266 HTMLWindow2_Release,
1267 HTMLWindow2_GetTypeInfoCount,
1268 HTMLWindow2_GetTypeInfo,
1269 HTMLWindow2_GetIDsOfNames,
1270 HTMLWindow2_Invoke,
1271 HTMLWindow2_item,
1272 HTMLWindow2_get_length,
1273 HTMLWindow2_get_frames,
1274 HTMLWindow2_put_defaultStatus,
1275 HTMLWindow2_get_defaultStatus,
1276 HTMLWindow2_put_status,
1277 HTMLWindow2_get_status,
1278 HTMLWindow2_setTimeout,
1279 HTMLWindow2_clearTimeout,
1280 HTMLWindow2_alert,
1281 HTMLWindow2_confirm,
1282 HTMLWindow2_prompt,
1283 HTMLWindow2_get_Image,
1284 HTMLWindow2_get_location,
1285 HTMLWindow2_get_history,
1286 HTMLWindow2_close,
1287 HTMLWindow2_put_opener,
1288 HTMLWindow2_get_opener,
1289 HTMLWindow2_get_navigator,
1290 HTMLWindow2_put_name,
1291 HTMLWindow2_get_name,
1292 HTMLWindow2_get_parent,
1293 HTMLWindow2_open,
1294 HTMLWindow2_get_self,
1295 HTMLWindow2_get_top,
1296 HTMLWindow2_get_window,
1297 HTMLWindow2_navigate,
1298 HTMLWindow2_put_onfocus,
1299 HTMLWindow2_get_onfocus,
1300 HTMLWindow2_put_onblur,
1301 HTMLWindow2_get_onblur,
1302 HTMLWindow2_put_onload,
1303 HTMLWindow2_get_onload,
1304 HTMLWindow2_put_onbeforeunload,
1305 HTMLWindow2_get_onbeforeunload,
1306 HTMLWindow2_put_onunload,
1307 HTMLWindow2_get_onunload,
1308 HTMLWindow2_put_onhelp,
1309 HTMLWindow2_get_onhelp,
1310 HTMLWindow2_put_onerror,
1311 HTMLWindow2_get_onerror,
1312 HTMLWindow2_put_onresize,
1313 HTMLWindow2_get_onresize,
1314 HTMLWindow2_put_onscroll,
1315 HTMLWindow2_get_onscroll,
1316 HTMLWindow2_get_document,
1317 HTMLWindow2_get_event,
1318 HTMLWindow2_get__newEnum,
1319 HTMLWindow2_showModalDialog,
1320 HTMLWindow2_showHelp,
1321 HTMLWindow2_get_screen,
1322 HTMLWindow2_get_Option,
1323 HTMLWindow2_focus,
1324 HTMLWindow2_get_closed,
1325 HTMLWindow2_blur,
1326 HTMLWindow2_scroll,
1327 HTMLWindow2_get_clientInformation,
1328 HTMLWindow2_setInterval,
1329 HTMLWindow2_clearInterval,
1330 HTMLWindow2_put_offscreenBuffering,
1331 HTMLWindow2_get_offscreenBuffering,
1332 HTMLWindow2_execScript,
1333 HTMLWindow2_toString,
1334 HTMLWindow2_scrollBy,
1335 HTMLWindow2_scrollTo,
1336 HTMLWindow2_moveTo,
1337 HTMLWindow2_moveBy,
1338 HTMLWindow2_resizeTo,
1339 HTMLWindow2_resizeBy,
1340 HTMLWindow2_get_external
1343 static inline HTMLWindow *impl_from_IHTMLWindow3(IHTMLWindow3 *iface)
1345 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow3_iface);
1348 static HRESULT WINAPI HTMLWindow3_QueryInterface(IHTMLWindow3 *iface, REFIID riid, void **ppv)
1350 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1352 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1355 static ULONG WINAPI HTMLWindow3_AddRef(IHTMLWindow3 *iface)
1357 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1359 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1362 static ULONG WINAPI HTMLWindow3_Release(IHTMLWindow3 *iface)
1364 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1366 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1369 static HRESULT WINAPI HTMLWindow3_GetTypeInfoCount(IHTMLWindow3 *iface, UINT *pctinfo)
1371 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1373 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1376 static HRESULT WINAPI HTMLWindow3_GetTypeInfo(IHTMLWindow3 *iface, UINT iTInfo,
1377 LCID lcid, ITypeInfo **ppTInfo)
1379 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1381 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1384 static HRESULT WINAPI HTMLWindow3_GetIDsOfNames(IHTMLWindow3 *iface, REFIID riid,
1385 LPOLESTR *rgszNames, UINT cNames,
1386 LCID lcid, DISPID *rgDispId)
1388 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1390 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1391 rgDispId);
1394 static HRESULT WINAPI HTMLWindow3_Invoke(IHTMLWindow3 *iface, DISPID dispIdMember,
1395 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1396 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1398 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1400 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1401 pDispParams, pVarResult, pExcepInfo, puArgErr);
1404 static HRESULT WINAPI HTMLWindow3_get_screenLeft(IHTMLWindow3 *iface, LONG *p)
1406 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1407 FIXME("(%p)->(%p)\n", This, p);
1408 return E_NOTIMPL;
1411 static HRESULT WINAPI HTMLWindow3_get_screenTop(IHTMLWindow3 *iface, LONG *p)
1413 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1414 FIXME("(%p)->(%p)\n", This, p);
1415 return E_NOTIMPL;
1418 static HRESULT WINAPI HTMLWindow3_attachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp, VARIANT_BOOL *pfResult)
1420 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1422 TRACE("(%p)->(%s %p %p)\n", This, debugstr_w(event), pDisp, pfResult);
1424 if(!This->doc) {
1425 FIXME("No document\n");
1426 return E_FAIL;
1429 return attach_event(&This->doc->body_event_target, NULL, &This->doc->basedoc, event, pDisp, pfResult);
1432 static HRESULT WINAPI HTMLWindow3_detachEvent(IHTMLWindow3 *iface, BSTR event, IDispatch *pDisp)
1434 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1435 FIXME("(%p)->()\n", This);
1436 return E_NOTIMPL;
1439 static HRESULT window_set_timer(HTMLWindow *This, VARIANT *expr, LONG msec, VARIANT *language,
1440 BOOL interval, LONG *timer_id)
1442 IDispatch *disp = NULL;
1444 switch(V_VT(expr)) {
1445 case VT_DISPATCH:
1446 disp = V_DISPATCH(expr);
1447 IDispatch_AddRef(disp);
1448 break;
1450 case VT_BSTR:
1451 disp = script_parse_event(This, V_BSTR(expr));
1452 break;
1454 default:
1455 FIXME("unimplemented vt=%d\n", V_VT(expr));
1456 return E_NOTIMPL;
1459 if(!disp)
1460 return E_FAIL;
1462 *timer_id = set_task_timer(&This->doc->basedoc, msec, interval, disp);
1463 IDispatch_Release(disp);
1465 return S_OK;
1468 static HRESULT WINAPI HTMLWindow3_setTimeout(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1469 VARIANT *language, LONG *timerID)
1471 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1473 TRACE("(%p)->(%p(%d) %d %p %p)\n", This, expression, V_VT(expression), msec, language, timerID);
1475 return window_set_timer(This, expression, msec, language, FALSE, timerID);
1478 static HRESULT WINAPI HTMLWindow3_setInterval(IHTMLWindow3 *iface, VARIANT *expression, LONG msec,
1479 VARIANT *language, LONG *timerID)
1481 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1483 TRACE("(%p)->(%p %d %p %p)\n", This, expression, msec, language, timerID);
1485 return window_set_timer(This, expression, msec, language, TRUE, timerID);
1488 static HRESULT WINAPI HTMLWindow3_print(IHTMLWindow3 *iface)
1490 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1491 FIXME("(%p)\n", This);
1492 return E_NOTIMPL;
1495 static HRESULT WINAPI HTMLWindow3_put_onbeforeprint(IHTMLWindow3 *iface, VARIANT v)
1497 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1498 FIXME("(%p)->()\n", This);
1499 return E_NOTIMPL;
1502 static HRESULT WINAPI HTMLWindow3_get_onbeforeprint(IHTMLWindow3 *iface, VARIANT *p)
1504 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1505 FIXME("(%p)->(%p)\n", This, p);
1506 return E_NOTIMPL;
1509 static HRESULT WINAPI HTMLWindow3_put_onafterprint(IHTMLWindow3 *iface, VARIANT v)
1511 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1512 FIXME("(%p)->()\n", This);
1513 return E_NOTIMPL;
1516 static HRESULT WINAPI HTMLWindow3_get_onafterprint(IHTMLWindow3 *iface, VARIANT *p)
1518 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1519 FIXME("(%p)->(%p)\n", This, p);
1520 return E_NOTIMPL;
1523 static HRESULT WINAPI HTMLWindow3_get_clipboardData(IHTMLWindow3 *iface, IHTMLDataTransfer **p)
1525 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1526 FIXME("(%p)->(%p)\n", This, p);
1527 return E_NOTIMPL;
1530 static HRESULT WINAPI HTMLWindow3_showModelessDialog(IHTMLWindow3 *iface, BSTR url,
1531 VARIANT *varArgIn, VARIANT *options, IHTMLWindow2 **pDialog)
1533 HTMLWindow *This = impl_from_IHTMLWindow3(iface);
1534 FIXME("(%p)->(%s %p %p %p)\n", This, debugstr_w(url), varArgIn, options, pDialog);
1535 return E_NOTIMPL;
1538 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl = {
1539 HTMLWindow3_QueryInterface,
1540 HTMLWindow3_AddRef,
1541 HTMLWindow3_Release,
1542 HTMLWindow3_GetTypeInfoCount,
1543 HTMLWindow3_GetTypeInfo,
1544 HTMLWindow3_GetIDsOfNames,
1545 HTMLWindow3_Invoke,
1546 HTMLWindow3_get_screenLeft,
1547 HTMLWindow3_get_screenTop,
1548 HTMLWindow3_attachEvent,
1549 HTMLWindow3_detachEvent,
1550 HTMLWindow3_setTimeout,
1551 HTMLWindow3_setInterval,
1552 HTMLWindow3_print,
1553 HTMLWindow3_put_onbeforeprint,
1554 HTMLWindow3_get_onbeforeprint,
1555 HTMLWindow3_put_onafterprint,
1556 HTMLWindow3_get_onafterprint,
1557 HTMLWindow3_get_clipboardData,
1558 HTMLWindow3_showModelessDialog
1561 static inline HTMLWindow *impl_from_IHTMLWindow4(IHTMLWindow4 *iface)
1563 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow4_iface);
1566 static HRESULT WINAPI HTMLWindow4_QueryInterface(IHTMLWindow4 *iface, REFIID riid, void **ppv)
1568 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1570 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1573 static ULONG WINAPI HTMLWindow4_AddRef(IHTMLWindow4 *iface)
1575 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1577 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1580 static ULONG WINAPI HTMLWindow4_Release(IHTMLWindow4 *iface)
1582 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1584 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1587 static HRESULT WINAPI HTMLWindow4_GetTypeInfoCount(IHTMLWindow4 *iface, UINT *pctinfo)
1589 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1591 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1594 static HRESULT WINAPI HTMLWindow4_GetTypeInfo(IHTMLWindow4 *iface, UINT iTInfo,
1595 LCID lcid, ITypeInfo **ppTInfo)
1597 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1599 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1602 static HRESULT WINAPI HTMLWindow4_GetIDsOfNames(IHTMLWindow4 *iface, REFIID riid,
1603 LPOLESTR *rgszNames, UINT cNames,
1604 LCID lcid, DISPID *rgDispId)
1606 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1608 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1609 rgDispId);
1612 static HRESULT WINAPI HTMLWindow4_Invoke(IHTMLWindow4 *iface, DISPID dispIdMember,
1613 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1614 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1616 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1618 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1619 pDispParams, pVarResult, pExcepInfo, puArgErr);
1622 static HRESULT WINAPI HTMLWindow4_createPopup(IHTMLWindow4 *iface, VARIANT *varArgIn,
1623 IDispatch **ppPopup)
1625 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1626 FIXME("(%p)->(%p %p)\n", This, varArgIn, ppPopup);
1627 return E_NOTIMPL;
1630 static HRESULT WINAPI HTMLWindow4_get_frameElement(IHTMLWindow4 *iface, IHTMLFrameBase **p)
1632 HTMLWindow *This = impl_from_IHTMLWindow4(iface);
1633 TRACE("(%p)->(%p)\n", This, p);
1635 if(This->frame_element) {
1636 *p = &This->frame_element->IHTMLFrameBase_iface;
1637 IHTMLFrameBase_AddRef(*p);
1638 }else
1639 *p = NULL;
1641 return S_OK;
1644 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl = {
1645 HTMLWindow4_QueryInterface,
1646 HTMLWindow4_AddRef,
1647 HTMLWindow4_Release,
1648 HTMLWindow4_GetTypeInfoCount,
1649 HTMLWindow4_GetTypeInfo,
1650 HTMLWindow4_GetIDsOfNames,
1651 HTMLWindow4_Invoke,
1652 HTMLWindow4_createPopup,
1653 HTMLWindow4_get_frameElement
1656 static inline HTMLWindow *impl_from_IHTMLWindow6(IHTMLWindow6 *iface)
1658 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLWindow6_iface);
1661 static HRESULT WINAPI HTMLWindow6_QueryInterface(IHTMLWindow6 *iface, REFIID riid, void **ppv)
1663 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1665 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1668 static ULONG WINAPI HTMLWindow6_AddRef(IHTMLWindow6 *iface)
1670 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1672 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1675 static ULONG WINAPI HTMLWindow6_Release(IHTMLWindow6 *iface)
1677 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1679 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1682 static HRESULT WINAPI HTMLWindow6_GetTypeInfoCount(IHTMLWindow6 *iface, UINT *pctinfo)
1684 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1686 return IDispatchEx_GetTypeInfoCount(&This->IDispatchEx_iface, pctinfo);
1689 static HRESULT WINAPI HTMLWindow6_GetTypeInfo(IHTMLWindow6 *iface, UINT iTInfo,
1690 LCID lcid, ITypeInfo **ppTInfo)
1692 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1694 return IDispatchEx_GetTypeInfo(&This->IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1697 static HRESULT WINAPI HTMLWindow6_GetIDsOfNames(IHTMLWindow6 *iface, REFIID riid,
1698 LPOLESTR *rgszNames, UINT cNames,
1699 LCID lcid, DISPID *rgDispId)
1701 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1703 return IDispatchEx_GetIDsOfNames(&This->IDispatchEx_iface, riid, rgszNames, cNames, lcid,
1704 rgDispId);
1707 static HRESULT WINAPI HTMLWindow6_Invoke(IHTMLWindow6 *iface, DISPID dispIdMember,
1708 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
1709 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
1711 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1713 return IDispatchEx_Invoke(&This->IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
1714 pDispParams, pVarResult, pExcepInfo, puArgErr);
1717 static HRESULT WINAPI HTMLWindow6_put_XDomainRequest(IHTMLWindow6 *iface, VARIANT v)
1719 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1720 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1721 return E_NOTIMPL;
1724 static HRESULT WINAPI HTMLWindow6_get_XDomainRequest(IHTMLWindow6 *iface, VARIANT *p)
1726 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1727 FIXME("(%p)->(%p)\n", This, p);
1728 return E_NOTIMPL;
1731 static HRESULT WINAPI HTMLWindow6_get_sessionStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1733 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1734 FIXME("(%p)->(%p)\n", This, p);
1735 return E_NOTIMPL;
1738 static HRESULT WINAPI HTMLWindow6_get_localStorage(IHTMLWindow6 *iface, IHTMLStorage **p)
1740 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1741 FIXME("(%p)->(%p)\n", This, p);
1742 return E_NOTIMPL;
1745 static HRESULT WINAPI HTMLWindow6_put_onhashchange(IHTMLWindow6 *iface, VARIANT v)
1747 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1748 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1749 return E_NOTIMPL;
1752 static HRESULT WINAPI HTMLWindow6_get_onhashchange(IHTMLWindow6 *iface, VARIANT *p)
1754 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1755 FIXME("(%p)->(%p)\n", This, p);
1756 return E_NOTIMPL;
1759 static HRESULT WINAPI HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6 *iface, LONG *p)
1761 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1762 FIXME("(%p)->(%p)\n", This, p);
1763 return E_NOTIMPL;
1766 static HRESULT WINAPI HTMLWindow6_postMessage(IHTMLWindow6 *iface, BSTR msg, VARIANT targetOrigin)
1768 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1769 FIXME("(%p)->(%s %s)\n", This, debugstr_w(msg), debugstr_variant(&targetOrigin));
1770 return E_NOTIMPL;
1773 static HRESULT WINAPI HTMLWindow6_toStaticHTML(IHTMLWindow6 *iface, BSTR bstrHTML, BSTR *pbstrStaticHTML)
1775 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1776 FIXME("(%p)->(%s %p)\n", This, debugstr_w(bstrHTML), pbstrStaticHTML);
1777 return E_NOTIMPL;
1780 static HRESULT WINAPI HTMLWindow6_put_onmessage(IHTMLWindow6 *iface, VARIANT v)
1782 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1783 FIXME("(%p)->(%s)\n", This, debugstr_variant(&v));
1784 return E_NOTIMPL;
1787 static HRESULT WINAPI HTMLWindow6_get_onmessage(IHTMLWindow6 *iface, VARIANT *p)
1789 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1790 FIXME("(%p)->(%p)\n", This, p);
1791 return E_NOTIMPL;
1794 static HRESULT WINAPI HTMLWindow6_msWriteProfilerMark(IHTMLWindow6 *iface, BSTR bstrProfilerMark)
1796 HTMLWindow *This = impl_from_IHTMLWindow6(iface);
1797 FIXME("(%p)->(%s)\n", This, debugstr_w(bstrProfilerMark));
1798 return E_NOTIMPL;
1801 static const IHTMLWindow6Vtbl HTMLWindow6Vtbl = {
1802 HTMLWindow6_QueryInterface,
1803 HTMLWindow6_AddRef,
1804 HTMLWindow6_Release,
1805 HTMLWindow6_GetTypeInfoCount,
1806 HTMLWindow6_GetTypeInfo,
1807 HTMLWindow6_GetIDsOfNames,
1808 HTMLWindow6_Invoke,
1809 HTMLWindow6_put_XDomainRequest,
1810 HTMLWindow6_get_XDomainRequest,
1811 HTMLWindow6_get_sessionStorage,
1812 HTMLWindow6_get_localStorage,
1813 HTMLWindow6_put_onhashchange,
1814 HTMLWindow6_get_onhashchange,
1815 HTMLWindow6_get_maxConnectionsPerServer,
1816 HTMLWindow6_postMessage,
1817 HTMLWindow6_toStaticHTML,
1818 HTMLWindow6_put_onmessage,
1819 HTMLWindow6_get_onmessage,
1820 HTMLWindow6_msWriteProfilerMark
1823 static inline HTMLWindow *impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow *iface)
1825 return CONTAINING_RECORD(iface, HTMLWindow, IHTMLPrivateWindow_iface);
1828 static HRESULT WINAPI HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow *iface, REFIID riid, void **ppv)
1830 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1832 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1835 static ULONG WINAPI HTMLPrivateWindow_AddRef(IHTMLPrivateWindow *iface)
1837 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1839 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1842 static ULONG WINAPI HTMLPrivateWindow_Release(IHTMLPrivateWindow *iface)
1844 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1846 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1849 static HRESULT WINAPI HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow *iface, BSTR url, BSTR arg2, BSTR arg3,
1850 BSTR arg4, VARIANT *post_data_var, VARIANT *headers_var, ULONG flags)
1852 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1853 OLECHAR *translated_url = NULL;
1854 DWORD post_data_size = 0;
1855 BYTE *post_data = NULL;
1856 WCHAR *headers = NULL;
1857 IUri *uri;
1858 HRESULT hres;
1860 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This, debugstr_w(url), debugstr_w(arg2), debugstr_w(arg3), debugstr_w(arg4),
1861 debugstr_variant(post_data_var), debugstr_variant(headers_var), flags);
1863 if(This->doc_obj->hostui) {
1864 hres = IDocHostUIHandler_TranslateUrl(This->doc_obj->hostui, 0, url, &translated_url);
1865 if(hres != S_OK)
1866 translated_url = NULL;
1869 hres = CreateUri(translated_url ? translated_url : url, 0, 0, &uri);
1870 CoTaskMemFree(translated_url);
1871 if(FAILED(hres))
1872 return hres;
1874 if(post_data_var) {
1875 if(V_VT(post_data_var) == (VT_ARRAY|VT_UI1)) {
1876 SafeArrayAccessData(V_ARRAY(post_data_var), (void**)&post_data);
1877 post_data_size = V_ARRAY(post_data_var)->rgsabound[0].cElements;
1881 if(headers_var && V_VT(headers_var) != VT_EMPTY && V_VT(headers_var) != VT_ERROR) {
1882 if(V_VT(headers_var) != VT_BSTR)
1883 return E_INVALIDARG;
1885 headers = V_BSTR(headers_var);
1888 hres = super_navigate(This, uri, headers, post_data, post_data_size);
1889 IUri_Release(uri);
1890 if(post_data)
1891 SafeArrayUnaccessData(V_ARRAY(post_data_var));
1893 return hres;
1896 static HRESULT WINAPI HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow *iface, BSTR *url)
1898 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1899 FIXME("(%p)->(%p)\n", This, url);
1900 return E_NOTIMPL;
1903 static HRESULT WINAPI HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow *iface, IOleCommandTarget *cmdtrg)
1905 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1906 FIXME("(%p)->(%p)\n", This, cmdtrg);
1907 return E_NOTIMPL;
1910 static HRESULT WINAPI HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow *iface, int arg)
1912 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1913 FIXME("(%p)->(%x)\n", This, arg);
1914 return E_NOTIMPL;
1917 static HRESULT WINAPI HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow *iface, LPCWSTR name, IHTMLWindow2 **ret)
1919 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1920 FIXME("(%p)->(%s %p)\n", This, debugstr_w(name), ret);
1921 return E_NOTIMPL;
1924 static HRESULT WINAPI HTMLPrivateWindow_GetAddressBarUrl(IHTMLPrivateWindow *iface, BSTR *url)
1926 HTMLWindow *This = impl_from_IHTMLPrivateWindow(iface);
1927 TRACE("(%p)->(%p)\n", This, url);
1929 if(!url)
1930 return E_INVALIDARG;
1932 *url = SysAllocString(This->url);
1933 return S_OK;
1936 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl = {
1937 HTMLPrivateWindow_QueryInterface,
1938 HTMLPrivateWindow_AddRef,
1939 HTMLPrivateWindow_Release,
1940 HTMLPrivateWindow_SuperNavigate,
1941 HTMLPrivateWindow_GetPendingUrl,
1942 HTMLPrivateWindow_SetPICSTarget,
1943 HTMLPrivateWindow_PICSComplete,
1944 HTMLPrivateWindow_FindWindowByName,
1945 HTMLPrivateWindow_GetAddressBarUrl
1948 static inline HTMLWindow *impl_from_IDispatchEx(IDispatchEx *iface)
1950 return CONTAINING_RECORD(iface, HTMLWindow, IDispatchEx_iface);
1953 static HRESULT WINAPI WindowDispEx_QueryInterface(IDispatchEx *iface, REFIID riid, void **ppv)
1955 HTMLWindow *This = impl_from_IDispatchEx(iface);
1957 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
1960 static ULONG WINAPI WindowDispEx_AddRef(IDispatchEx *iface)
1962 HTMLWindow *This = impl_from_IDispatchEx(iface);
1964 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
1967 static ULONG WINAPI WindowDispEx_Release(IDispatchEx *iface)
1969 HTMLWindow *This = impl_from_IDispatchEx(iface);
1971 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
1974 static HRESULT WINAPI WindowDispEx_GetTypeInfoCount(IDispatchEx *iface, UINT *pctinfo)
1976 HTMLWindow *This = impl_from_IDispatchEx(iface);
1978 TRACE("(%p)->(%p)\n", This, pctinfo);
1980 return IDispatchEx_GetTypeInfoCount(&This->dispex.IDispatchEx_iface, pctinfo);
1983 static HRESULT WINAPI WindowDispEx_GetTypeInfo(IDispatchEx *iface, UINT iTInfo,
1984 LCID lcid, ITypeInfo **ppTInfo)
1986 HTMLWindow *This = impl_from_IDispatchEx(iface);
1988 TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
1990 return IDispatchEx_GetTypeInfo(&This->dispex.IDispatchEx_iface, iTInfo, lcid, ppTInfo);
1993 static HRESULT WINAPI WindowDispEx_GetIDsOfNames(IDispatchEx *iface, REFIID riid,
1994 LPOLESTR *rgszNames, UINT cNames,
1995 LCID lcid, DISPID *rgDispId)
1997 HTMLWindow *This = impl_from_IDispatchEx(iface);
1998 UINT i;
1999 HRESULT hres;
2001 WARN("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
2002 lcid, rgDispId);
2004 for(i=0; i < cNames; i++) {
2005 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
2006 hres = IDispatchEx_GetDispID(&This->IDispatchEx_iface, rgszNames[i], 0, rgDispId+i);
2007 if(FAILED(hres))
2008 return hres;
2011 return S_OK;
2014 static HRESULT WINAPI WindowDispEx_Invoke(IDispatchEx *iface, DISPID dispIdMember,
2015 REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pDispParams,
2016 VARIANT *pVarResult, EXCEPINFO *pExcepInfo, UINT *puArgErr)
2018 HTMLWindow *This = impl_from_IDispatchEx(iface);
2020 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
2021 lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
2023 /* FIXME: Use script dispatch */
2025 return IDispatchEx_Invoke(&This->dispex.IDispatchEx_iface, dispIdMember, riid, lcid, wFlags,
2026 pDispParams, pVarResult, pExcepInfo, puArgErr);
2029 static global_prop_t *alloc_global_prop(HTMLWindow *This, global_prop_type_t type, BSTR name)
2031 if(This->global_prop_cnt == This->global_prop_size) {
2032 global_prop_t *new_props;
2033 DWORD new_size;
2035 if(This->global_props) {
2036 new_size = This->global_prop_size*2;
2037 new_props = heap_realloc(This->global_props, new_size*sizeof(global_prop_t));
2038 }else {
2039 new_size = 16;
2040 new_props = heap_alloc(new_size*sizeof(global_prop_t));
2042 if(!new_props)
2043 return NULL;
2044 This->global_props = new_props;
2045 This->global_prop_size = new_size;
2048 This->global_props[This->global_prop_cnt].name = heap_strdupW(name);
2049 if(!This->global_props[This->global_prop_cnt].name)
2050 return NULL;
2052 This->global_props[This->global_prop_cnt].type = type;
2053 return This->global_props + This->global_prop_cnt++;
2056 static inline DWORD prop_to_dispid(HTMLWindow *This, global_prop_t *prop)
2058 return MSHTML_DISPID_CUSTOM_MIN + (prop-This->global_props);
2061 HRESULT search_window_props(HTMLWindow *This, BSTR bstrName, DWORD grfdex, DISPID *pid)
2063 DWORD i;
2064 ScriptHost *script_host;
2065 DISPID id;
2067 for(i=0; i < This->global_prop_cnt; i++) {
2068 /* FIXME: case sensitivity */
2069 if(!strcmpW(This->global_props[i].name, bstrName)) {
2070 *pid = MSHTML_DISPID_CUSTOM_MIN+i;
2071 return S_OK;
2075 if(find_global_prop(This, bstrName, grfdex, &script_host, &id)) {
2076 global_prop_t *prop;
2078 prop = alloc_global_prop(This, GLOBAL_SCRIPTVAR, bstrName);
2079 if(!prop)
2080 return E_OUTOFMEMORY;
2082 prop->script_host = script_host;
2083 prop->id = id;
2085 *pid = prop_to_dispid(This, prop);
2086 return S_OK;
2089 return DISP_E_UNKNOWNNAME;
2092 static HRESULT WINAPI WindowDispEx_GetDispID(IDispatchEx *iface, BSTR bstrName, DWORD grfdex, DISPID *pid)
2094 HTMLWindow *This = impl_from_IDispatchEx(iface);
2095 HRESULT hres;
2097 TRACE("(%p)->(%s %x %p)\n", This, debugstr_w(bstrName), grfdex, pid);
2099 hres = search_window_props(This, bstrName, grfdex, pid);
2100 if(hres != DISP_E_UNKNOWNNAME)
2101 return hres;
2103 hres = IDispatchEx_GetDispID(&This->dispex.IDispatchEx_iface, bstrName, grfdex, pid);
2104 if(hres != DISP_E_UNKNOWNNAME)
2105 return hres;
2107 if(This->doc) {
2108 global_prop_t *prop;
2109 IHTMLElement *elem;
2111 hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
2112 bstrName, &elem);
2113 if(SUCCEEDED(hres) && elem) {
2114 IHTMLElement_Release(elem);
2116 prop = alloc_global_prop(This, GLOBAL_ELEMENTVAR, bstrName);
2117 if(!prop)
2118 return E_OUTOFMEMORY;
2120 *pid = prop_to_dispid(This, prop);
2121 return S_OK;
2125 return DISP_E_UNKNOWNNAME;
2128 static HRESULT WINAPI WindowDispEx_InvokeEx(IDispatchEx *iface, DISPID id, LCID lcid, WORD wFlags, DISPPARAMS *pdp,
2129 VARIANT *pvarRes, EXCEPINFO *pei, IServiceProvider *pspCaller)
2131 HTMLWindow *This = impl_from_IDispatchEx(iface);
2133 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This, id, lcid, wFlags, pdp, pvarRes, pei, pspCaller);
2135 if(id == DISPID_IHTMLWINDOW2_LOCATION && (wFlags & DISPATCH_PROPERTYPUT)) {
2136 HTMLLocation *location;
2137 HRESULT hres;
2139 TRACE("forwarding to location.href\n");
2141 hres = get_location(This, &location);
2142 if(FAILED(hres))
2143 return hres;
2145 hres = IDispatchEx_InvokeEx(&location->dispex.IDispatchEx_iface, DISPID_VALUE, lcid,
2146 wFlags, pdp, pvarRes, pei, pspCaller);
2147 IHTMLLocation_Release(&location->IHTMLLocation_iface);
2148 return hres;
2151 return IDispatchEx_InvokeEx(&This->dispex.IDispatchEx_iface, id, lcid, wFlags, pdp, pvarRes,
2152 pei, pspCaller);
2155 static HRESULT WINAPI WindowDispEx_DeleteMemberByName(IDispatchEx *iface, BSTR bstrName, DWORD grfdex)
2157 HTMLWindow *This = impl_from_IDispatchEx(iface);
2159 TRACE("(%p)->(%s %x)\n", This, debugstr_w(bstrName), grfdex);
2161 return IDispatchEx_DeleteMemberByName(&This->dispex.IDispatchEx_iface, bstrName, grfdex);
2164 static HRESULT WINAPI WindowDispEx_DeleteMemberByDispID(IDispatchEx *iface, DISPID id)
2166 HTMLWindow *This = impl_from_IDispatchEx(iface);
2168 TRACE("(%p)->(%x)\n", This, id);
2170 return IDispatchEx_DeleteMemberByDispID(&This->dispex.IDispatchEx_iface, id);
2173 static HRESULT WINAPI WindowDispEx_GetMemberProperties(IDispatchEx *iface, DISPID id, DWORD grfdexFetch, DWORD *pgrfdex)
2175 HTMLWindow *This = impl_from_IDispatchEx(iface);
2177 TRACE("(%p)->(%x %x %p)\n", This, id, grfdexFetch, pgrfdex);
2179 return IDispatchEx_GetMemberProperties(&This->dispex.IDispatchEx_iface, id, grfdexFetch,
2180 pgrfdex);
2183 static HRESULT WINAPI WindowDispEx_GetMemberName(IDispatchEx *iface, DISPID id, BSTR *pbstrName)
2185 HTMLWindow *This = impl_from_IDispatchEx(iface);
2187 TRACE("(%p)->(%x %p)\n", This, id, pbstrName);
2189 return IDispatchEx_GetMemberName(&This->dispex.IDispatchEx_iface, id, pbstrName);
2192 static HRESULT WINAPI WindowDispEx_GetNextDispID(IDispatchEx *iface, DWORD grfdex, DISPID id, DISPID *pid)
2194 HTMLWindow *This = impl_from_IDispatchEx(iface);
2196 TRACE("(%p)->(%x %x %p)\n", This, grfdex, id, pid);
2198 return IDispatchEx_GetNextDispID(&This->dispex.IDispatchEx_iface, grfdex, id, pid);
2201 static HRESULT WINAPI WindowDispEx_GetNameSpaceParent(IDispatchEx *iface, IUnknown **ppunk)
2203 HTMLWindow *This = impl_from_IDispatchEx(iface);
2205 TRACE("(%p)->(%p)\n", This, ppunk);
2207 *ppunk = NULL;
2208 return S_OK;
2211 static const IDispatchExVtbl WindowDispExVtbl = {
2212 WindowDispEx_QueryInterface,
2213 WindowDispEx_AddRef,
2214 WindowDispEx_Release,
2215 WindowDispEx_GetTypeInfoCount,
2216 WindowDispEx_GetTypeInfo,
2217 WindowDispEx_GetIDsOfNames,
2218 WindowDispEx_Invoke,
2219 WindowDispEx_GetDispID,
2220 WindowDispEx_InvokeEx,
2221 WindowDispEx_DeleteMemberByName,
2222 WindowDispEx_DeleteMemberByDispID,
2223 WindowDispEx_GetMemberProperties,
2224 WindowDispEx_GetMemberName,
2225 WindowDispEx_GetNextDispID,
2226 WindowDispEx_GetNameSpaceParent
2229 static inline HTMLWindow *impl_from_IServiceProvider(IServiceProvider *iface)
2231 return CONTAINING_RECORD(iface, HTMLWindow, IServiceProvider_iface);
2234 static HRESULT WINAPI HTMLWindowSP_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
2236 HTMLWindow *This = impl_from_IServiceProvider(iface);
2237 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2240 static ULONG WINAPI HTMLWindowSP_AddRef(IServiceProvider *iface)
2242 HTMLWindow *This = impl_from_IServiceProvider(iface);
2243 return IHTMLWindow2_AddRef(&This->IHTMLWindow2_iface);
2246 static ULONG WINAPI HTMLWindowSP_Release(IServiceProvider *iface)
2248 HTMLWindow *This = impl_from_IServiceProvider(iface);
2249 return IHTMLWindow2_Release(&This->IHTMLWindow2_iface);
2252 static HRESULT WINAPI HTMLWindowSP_QueryService(IServiceProvider *iface, REFGUID guidService, REFIID riid, void **ppv)
2254 HTMLWindow *This = impl_from_IServiceProvider(iface);
2256 if(IsEqualGUID(guidService, &IID_IHTMLWindow2)) {
2257 TRACE("IID_IHTMLWindow2\n");
2258 return IHTMLWindow2_QueryInterface(&This->IHTMLWindow2_iface, riid, ppv);
2261 TRACE("(%p)->(%s %s %p)\n", This, debugstr_guid(guidService), debugstr_guid(riid), ppv);
2263 if(!This->doc_obj)
2264 return E_NOINTERFACE;
2266 return IServiceProvider_QueryService(&This->doc_obj->basedoc.IServiceProvider_iface,
2267 guidService, riid, ppv);
2270 static const IServiceProviderVtbl ServiceProviderVtbl = {
2271 HTMLWindowSP_QueryInterface,
2272 HTMLWindowSP_AddRef,
2273 HTMLWindowSP_Release,
2274 HTMLWindowSP_QueryService
2277 static inline HTMLWindow *impl_from_DispatchEx(DispatchEx *iface)
2279 return CONTAINING_RECORD(iface, HTMLWindow, dispex);
2282 static HRESULT HTMLWindow_invoke(DispatchEx *dispex, DISPID id, LCID lcid, WORD flags, DISPPARAMS *params,
2283 VARIANT *res, EXCEPINFO *ei, IServiceProvider *caller)
2285 HTMLWindow *This = impl_from_DispatchEx(dispex);
2286 global_prop_t *prop;
2287 DWORD idx;
2288 HRESULT hres;
2290 idx = id - MSHTML_DISPID_CUSTOM_MIN;
2291 if(idx >= This->global_prop_cnt)
2292 return DISP_E_MEMBERNOTFOUND;
2294 prop = This->global_props+idx;
2296 switch(prop->type) {
2297 case GLOBAL_SCRIPTVAR: {
2298 IDispatchEx *iface;
2299 IDispatch *disp;
2301 disp = get_script_disp(prop->script_host);
2302 if(!disp)
2303 return E_UNEXPECTED;
2305 hres = IDispatch_QueryInterface(disp, &IID_IDispatchEx, (void**)&iface);
2306 if(SUCCEEDED(hres)) {
2307 TRACE("%s >>>\n", debugstr_w(prop->name));
2308 hres = IDispatchEx_InvokeEx(iface, prop->id, lcid, flags, params, res, ei, caller);
2309 if(hres == S_OK)
2310 TRACE("%s <<<\n", debugstr_w(prop->name));
2311 else
2312 WARN("%s <<< %08x\n", debugstr_w(prop->name), hres);
2313 IDispatchEx_Release(iface);
2314 }else {
2315 FIXME("No IDispatchEx\n");
2317 IDispatch_Release(disp);
2318 break;
2320 case GLOBAL_ELEMENTVAR: {
2321 IHTMLElement *elem;
2323 hres = IHTMLDocument3_getElementById(&This->doc->basedoc.IHTMLDocument3_iface,
2324 prop->name, &elem);
2325 if(FAILED(hres))
2326 return hres;
2328 if(!elem)
2329 return DISP_E_MEMBERNOTFOUND;
2331 V_VT(res) = VT_DISPATCH;
2332 V_DISPATCH(res) = (IDispatch*)elem;
2333 break;
2335 default:
2336 ERR("invalid type %d\n", prop->type);
2337 hres = DISP_E_MEMBERNOTFOUND;
2340 return hres;
2344 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl = {
2345 NULL,
2346 NULL,
2347 HTMLWindow_invoke,
2348 NULL
2351 static const tid_t HTMLWindow_iface_tids[] = {
2352 IHTMLWindow2_tid,
2353 IHTMLWindow3_tid,
2354 IHTMLWindow4_tid,
2355 IHTMLWindow6_tid,
2359 static dispex_static_data_t HTMLWindow_dispex = {
2360 &HTMLWindow_dispex_vtbl,
2361 DispHTMLWindow2_tid,
2362 NULL,
2363 HTMLWindow_iface_tids
2366 HRESULT HTMLWindow_Create(HTMLDocumentObj *doc_obj, nsIDOMWindow *nswindow, HTMLWindow *parent, HTMLWindow **ret)
2368 HTMLWindow *window;
2369 HRESULT hres;
2371 window = heap_alloc_zero(sizeof(HTMLWindow));
2372 if(!window)
2373 return E_OUTOFMEMORY;
2375 window->window_ref = heap_alloc(sizeof(windowref_t));
2376 if(!window->window_ref) {
2377 heap_free(window);
2378 return E_OUTOFMEMORY;
2381 window->IHTMLWindow2_iface.lpVtbl = &HTMLWindow2Vtbl;
2382 window->IHTMLWindow3_iface.lpVtbl = &HTMLWindow3Vtbl;
2383 window->IHTMLWindow4_iface.lpVtbl = &HTMLWindow4Vtbl;
2384 window->IHTMLWindow6_iface.lpVtbl = &HTMLWindow6Vtbl;
2385 window->IHTMLPrivateWindow_iface.lpVtbl = &HTMLPrivateWindowVtbl;
2386 window->IDispatchEx_iface.lpVtbl = &WindowDispExVtbl;
2387 window->IServiceProvider_iface.lpVtbl = &ServiceProviderVtbl;
2388 window->ref = 1;
2389 window->doc_obj = doc_obj;
2391 window->window_ref->window = window;
2392 window->window_ref->ref = 1;
2394 init_dispex(&window->dispex, (IUnknown*)&window->IHTMLWindow2_iface, &HTMLWindow_dispex);
2396 if(nswindow) {
2397 nsIDOMWindow_AddRef(nswindow);
2398 window->nswindow = nswindow;
2401 window->scriptmode = parent ? parent->scriptmode : SCRIPTMODE_GECKO;
2402 window->readystate = READYSTATE_UNINITIALIZED;
2403 list_init(&window->script_hosts);
2405 hres = CoInternetCreateSecurityManager(NULL, &window->secmgr, 0);
2406 if(FAILED(hres)) {
2407 IHTMLWindow2_Release(&window->IHTMLWindow2_iface);
2408 return hres;
2411 window->task_magic = get_task_target_magic();
2412 update_window_doc(window);
2414 list_init(&window->children);
2415 list_add_head(&window_list, &window->entry);
2417 if(parent) {
2418 IHTMLWindow2_AddRef(&window->IHTMLWindow2_iface);
2420 window->parent = parent;
2421 list_add_tail(&parent->children, &window->sibling_entry);
2424 *ret = window;
2425 return S_OK;
2428 void update_window_doc(HTMLWindow *window)
2430 nsIDOMHTMLDocument *nshtmldoc;
2431 nsIDOMDocument *nsdoc;
2432 nsresult nsres;
2434 nsres = nsIDOMWindow_GetDocument(window->nswindow, &nsdoc);
2435 if(NS_FAILED(nsres) || !nsdoc) {
2436 ERR("GetDocument failed: %08x\n", nsres);
2437 return;
2440 nsres = nsIDOMDocument_QueryInterface(nsdoc, &IID_nsIDOMHTMLDocument, (void**)&nshtmldoc);
2441 nsIDOMDocument_Release(nsdoc);
2442 if(NS_FAILED(nsres)) {
2443 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres);
2444 return;
2447 if(!window->doc || window->doc->nsdoc != nshtmldoc) {
2448 HTMLDocumentNode *doc;
2449 HRESULT hres;
2451 hres = create_doc_from_nsdoc(nshtmldoc, window->doc_obj, window, &doc);
2452 if(SUCCEEDED(hres)) {
2453 window_set_docnode(window, doc);
2454 htmldoc_release(&doc->basedoc);
2455 }else {
2456 ERR("create_doc_from_nsdoc failed: %08x\n", hres);
2460 nsIDOMHTMLDocument_Release(nshtmldoc);
2463 HTMLWindow *nswindow_to_window(const nsIDOMWindow *nswindow)
2465 HTMLWindow *iter;
2467 LIST_FOR_EACH_ENTRY(iter, &window_list, HTMLWindow, entry) {
2468 if(iter->nswindow == nswindow)
2469 return iter;
2472 return NULL;