2 * Copyright 2006 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
28 #include "wine/debug.h"
29 #include "wine/unicode.h"
31 #include "mshtml_private.h"
32 #include "htmlevent.h"
35 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
37 static struct list window_list
= LIST_INIT(window_list
);
39 static void window_set_docnode(HTMLWindow
*window
, HTMLDocumentNode
*doc_node
)
42 abort_document_bindings(window
->doc
);
43 window
->doc
->basedoc
.window
= NULL
;
44 htmldoc_release(&window
->doc
->basedoc
);
46 window
->doc
= doc_node
;
48 htmldoc_addref(&doc_node
->basedoc
);
50 if(window
->doc_obj
&& window
->doc_obj
->basedoc
.window
== window
) {
51 if(window
->doc_obj
->basedoc
.doc_node
)
52 htmldoc_release(&window
->doc_obj
->basedoc
.doc_node
->basedoc
);
53 window
->doc_obj
->basedoc
.doc_node
= doc_node
;
55 htmldoc_addref(&doc_node
->basedoc
);
59 nsIDOMWindow
*get_nsdoc_window(nsIDOMDocument
*nsdoc
)
61 nsIDOMDocumentView
*nsdocview
;
62 nsIDOMAbstractView
*nsview
;
63 nsIDOMWindow
*nswindow
;
66 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMDocumentView
, (void**)&nsdocview
);
67 nsIDOMDocument_Release(nsdoc
);
68 if(NS_FAILED(nsres
)) {
69 ERR("Could not get nsIDOMDocumentView iface: %08x\n", nsres
);
73 nsres
= nsIDOMDocumentView_GetDefaultView(nsdocview
, &nsview
);
74 nsIDOMDocumentView_Release(nsview
);
75 if(NS_FAILED(nsres
)) {
76 ERR("GetDefaultView failed: %08x\n", nsres
);
80 nsres
= nsIDOMAbstractView_QueryInterface(nsview
, &IID_nsIDOMWindow
, (void**)&nswindow
);
81 nsIDOMAbstractView_Release(nsview
);
82 if(NS_FAILED(nsres
)) {
83 ERR("Coult not get nsIDOMWindow iface: %08x\n", nsres
);
90 static void release_children(HTMLWindow
*This
)
94 while(!list_empty(&This
->children
)) {
95 child
= LIST_ENTRY(list_tail(&This
->children
), HTMLWindow
, sibling_entry
);
97 list_remove(&child
->sibling_entry
);
99 IHTMLWindow2_Release(HTMLWINDOW2(child
));
103 #define HTMLWINDOW2_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow2, iface)
105 static HRESULT WINAPI
HTMLWindow2_QueryInterface(IHTMLWindow2
*iface
, REFIID riid
, void **ppv
)
107 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
111 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
112 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
113 *ppv
= HTMLWINDOW2(This
);
114 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
115 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
116 *ppv
= HTMLWINDOW2(This
);
117 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
118 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
119 *ppv
= DISPATCHEX(This
);
120 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2
, riid
)) {
121 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This
, ppv
);
122 *ppv
= HTMLWINDOW2(This
);
123 }else if(IsEqualGUID(&IID_IHTMLWindow2
, riid
)) {
124 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This
, ppv
);
125 *ppv
= HTMLWINDOW2(This
);
126 }else if(IsEqualGUID(&IID_IHTMLWindow3
, riid
)) {
127 TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This
, ppv
);
128 *ppv
= HTMLWINDOW3(This
);
129 }else if(IsEqualGUID(&IID_IHTMLWindow4
, riid
)) {
130 TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This
, ppv
);
131 *ppv
= HTMLWINDOW4(This
);
132 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
133 return *ppv
? S_OK
: E_NOINTERFACE
;
137 IUnknown_AddRef((IUnknown
*)*ppv
);
141 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
142 return E_NOINTERFACE
;
145 static ULONG WINAPI
HTMLWindow2_AddRef(IHTMLWindow2
*iface
)
147 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
148 LONG ref
= InterlockedIncrement(&This
->ref
);
150 TRACE("(%p) ref=%d\n", This
, ref
);
155 static ULONG WINAPI
HTMLWindow2_Release(IHTMLWindow2
*iface
)
157 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
158 LONG ref
= InterlockedDecrement(&This
->ref
);
160 TRACE("(%p) ref=%d\n", This
, ref
);
165 remove_target_tasks(This
->task_magic
);
166 set_window_bscallback(This
, NULL
);
167 set_current_mon(This
, NULL
);
168 window_set_docnode(This
, NULL
);
169 release_children(This
);
171 if(This
->option_factory
) {
172 This
->option_factory
->window
= NULL
;
173 IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This
->option_factory
));
176 if(This
->image_factory
) {
177 This
->image_factory
->window
= NULL
;
178 IHTMLImageElementFactory_Release(HTMLIMGFACTORY(This
->image_factory
));
182 This
->location
->window
= NULL
;
183 IHTMLLocation_Release(HTMLLOCATION(This
->location
));
186 if(This
->event_target
)
187 release_event_target(This
->event_target
);
188 for(i
=0; i
< This
->global_prop_cnt
; i
++)
189 heap_free(This
->global_props
[i
].name
);
191 This
->window_ref
->window
= NULL
;
192 windowref_release(This
->window_ref
);
194 heap_free(This
->global_props
);
195 release_script_hosts(This
);
196 list_remove(&This
->entry
);
197 release_dispex(&This
->dispex
);
204 static HRESULT WINAPI
HTMLWindow2_GetTypeInfoCount(IHTMLWindow2
*iface
, UINT
*pctinfo
)
206 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
208 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This
), pctinfo
);
211 static HRESULT WINAPI
HTMLWindow2_GetTypeInfo(IHTMLWindow2
*iface
, UINT iTInfo
,
212 LCID lcid
, ITypeInfo
**ppTInfo
)
214 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
216 return IDispatchEx_GetTypeInfo(DISPATCHEX(This
), iTInfo
, lcid
, ppTInfo
);
219 static HRESULT WINAPI
HTMLWindow2_GetIDsOfNames(IHTMLWindow2
*iface
, REFIID riid
,
220 LPOLESTR
*rgszNames
, UINT cNames
,
221 LCID lcid
, DISPID
*rgDispId
)
223 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
225 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
228 static HRESULT WINAPI
HTMLWindow2_Invoke(IHTMLWindow2
*iface
, DISPID dispIdMember
,
229 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
230 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
232 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
234 return IDispatchEx_Invoke(DISPATCHEX(This
), dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
235 pVarResult
, pExcepInfo
, puArgErr
);
238 static HRESULT WINAPI
HTMLWindow2_item(IHTMLWindow2
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
240 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
241 FIXME("(%p)->(%p %p)\n", This
, pvarIndex
, pvarResult
);
245 static HRESULT WINAPI
HTMLWindow2_get_length(IHTMLWindow2
*iface
, LONG
*p
)
247 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
248 nsIDOMWindowCollection
*nscollection
;
252 TRACE("(%p)->(%p)\n", This
, p
);
254 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nscollection
);
255 if(NS_FAILED(nsres
)) {
256 ERR("GetFrames failed: %08x\n", nsres
);
260 nsres
= nsIDOMWindowCollection_GetLength(nscollection
, &length
);
261 nsIDOMWindowCollection_Release(nscollection
);
262 if(NS_FAILED(nsres
)) {
263 ERR("GetLength failed: %08x\n", nsres
);
271 static HRESULT WINAPI
HTMLWindow2_get_frames(IHTMLWindow2
*iface
, IHTMLFramesCollection2
**p
)
273 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
274 FIXME("(%p)->(%p)\n", This
, p
);
278 static HRESULT WINAPI
HTMLWindow2_put_defaultStatus(IHTMLWindow2
*iface
, BSTR v
)
280 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
281 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
285 static HRESULT WINAPI
HTMLWindow2_get_defaultStatus(IHTMLWindow2
*iface
, BSTR
*p
)
287 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
288 FIXME("(%p)->(%p)\n", This
, p
);
292 static HRESULT WINAPI
HTMLWindow2_put_status(IHTMLWindow2
*iface
, BSTR v
)
294 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
295 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
299 static HRESULT WINAPI
HTMLWindow2_get_status(IHTMLWindow2
*iface
, BSTR
*p
)
301 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
302 FIXME("(%p)->(%p)\n", This
, p
);
306 static HRESULT WINAPI
HTMLWindow2_setTimeout(IHTMLWindow2
*iface
, BSTR expression
,
307 LONG msec
, VARIANT
*language
, LONG
*timerID
)
309 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
312 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
314 V_VT(&expr_var
) = VT_BSTR
;
315 V_BSTR(&expr_var
) = expression
;
317 return IHTMLWindow3_setTimeout(HTMLWINDOW3(This
), &expr_var
, msec
, language
, timerID
);
320 static HRESULT WINAPI
HTMLWindow2_clearTimeout(IHTMLWindow2
*iface
, LONG timerID
)
322 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
324 TRACE("(%p)->(%d)\n", This
, timerID
);
326 return clear_task_timer(&This
->doc
->basedoc
, FALSE
, timerID
);
329 static HRESULT WINAPI
HTMLWindow2_alert(IHTMLWindow2
*iface
, BSTR message
)
331 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
334 TRACE("(%p)->(%s)\n", This
, debugstr_w(message
));
336 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
337 sizeof(wszTitle
)/sizeof(WCHAR
))) {
338 WARN("Could not load message box title: %d\n", GetLastError());
342 MessageBoxW(This
->doc_obj
->hwnd
, message
, wszTitle
, MB_ICONWARNING
);
346 static HRESULT WINAPI
HTMLWindow2_confirm(IHTMLWindow2
*iface
, BSTR message
,
347 VARIANT_BOOL
*confirmed
)
349 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
352 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(message
), confirmed
);
354 if(!confirmed
) return E_INVALIDARG
;
356 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
357 sizeof(wszTitle
)/sizeof(WCHAR
))) {
358 WARN("Could not load message box title: %d\n", GetLastError());
359 *confirmed
= VARIANT_TRUE
;
363 if(MessageBoxW(This
->doc_obj
->hwnd
, message
, wszTitle
,
364 MB_OKCANCEL
|MB_ICONQUESTION
)==IDOK
)
365 *confirmed
= VARIANT_TRUE
;
366 else *confirmed
= VARIANT_FALSE
;
378 static INT_PTR CALLBACK
prompt_dlgproc(HWND hwnd
, UINT msg
,
379 WPARAM wparam
, LPARAM lparam
)
385 prompt_arg
*arg
= (prompt_arg
*)lparam
;
388 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
389 sizeof(wszTitle
)/sizeof(WCHAR
))) {
390 WARN("Could not load message box title: %d\n", GetLastError());
391 EndDialog(hwnd
, wparam
);
395 SetWindowLongPtrW(hwnd
, DWLP_USER
, lparam
);
396 SetWindowTextW(hwnd
, wszTitle
);
397 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_PROMPT
), arg
->message
);
398 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_EDIT
), arg
->dststr
);
404 case MAKEWPARAM(IDCANCEL
, BN_CLICKED
):
405 EndDialog(hwnd
, wparam
);
407 case MAKEWPARAM(IDOK
, BN_CLICKED
):
410 (prompt_arg
*)GetWindowLongPtrW(hwnd
, DWLP_USER
);
411 HWND hwndPrompt
= GetDlgItem(hwnd
, ID_PROMPT_EDIT
);
412 INT len
= GetWindowTextLengthW(hwndPrompt
);
416 EndDialog(hwnd
, wparam
);
420 V_VT(arg
->textdata
) = VT_BSTR
;
421 if(!len
&& !arg
->dststr
)
422 V_BSTR(arg
->textdata
) = NULL
;
425 V_BSTR(arg
->textdata
) = SysAllocStringLen(NULL
, len
);
426 GetWindowTextW(hwndPrompt
, V_BSTR(arg
->textdata
), len
+1);
428 EndDialog(hwnd
, wparam
);
434 EndDialog(hwnd
, IDCANCEL
);
441 static HRESULT WINAPI
HTMLWindow2_prompt(IHTMLWindow2
*iface
, BSTR message
,
442 BSTR dststr
, VARIANT
*textdata
)
444 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
447 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(message
), debugstr_w(dststr
), textdata
);
449 if(textdata
) V_VT(textdata
) = VT_NULL
;
451 arg
.message
= message
;
453 arg
.textdata
= textdata
;
455 DialogBoxParamW(hInst
, MAKEINTRESOURCEW(ID_PROMPT_DIALOG
),
456 This
->doc_obj
->hwnd
, prompt_dlgproc
, (LPARAM
)&arg
);
460 static HRESULT WINAPI
HTMLWindow2_get_Image(IHTMLWindow2
*iface
, IHTMLImageElementFactory
**p
)
462 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
464 TRACE("(%p)->(%p)\n", This
, p
);
466 if(!This
->image_factory
)
467 This
->image_factory
= HTMLImageElementFactory_Create(This
);
469 *p
= HTMLIMGFACTORY(This
->image_factory
);
470 IHTMLImageElementFactory_AddRef(*p
);
475 static HRESULT WINAPI
HTMLWindow2_get_location(IHTMLWindow2
*iface
, IHTMLLocation
**p
)
477 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
479 TRACE("(%p)->(%p)\n", This
, p
);
482 IHTMLLocation_AddRef(HTMLLOCATION(This
->location
));
486 hres
= HTMLLocation_Create(This
, &This
->location
);
491 *p
= HTMLLOCATION(This
->location
);
495 static HRESULT WINAPI
HTMLWindow2_get_history(IHTMLWindow2
*iface
, IOmHistory
**p
)
497 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
498 FIXME("(%p)->(%p)\n", This
, p
);
502 static HRESULT WINAPI
HTMLWindow2_close(IHTMLWindow2
*iface
)
504 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
505 FIXME("(%p)->()\n", This
);
509 static HRESULT WINAPI
HTMLWindow2_put_opener(IHTMLWindow2
*iface
, VARIANT v
)
511 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
512 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
516 static HRESULT WINAPI
HTMLWindow2_get_opener(IHTMLWindow2
*iface
, VARIANT
*p
)
518 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
519 FIXME("(%p)->(%p)\n", This
, p
);
523 static HRESULT WINAPI
HTMLWindow2_get_navigator(IHTMLWindow2
*iface
, IOmNavigator
**p
)
525 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
527 TRACE("(%p)->(%p)\n", This
, p
);
529 *p
= OmNavigator_Create();
533 static HRESULT WINAPI
HTMLWindow2_put_name(IHTMLWindow2
*iface
, BSTR v
)
535 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
539 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
541 nsAString_Init(&name_str
, v
);
542 nsres
= nsIDOMWindow_SetName(This
->nswindow
, &name_str
);
543 nsAString_Finish(&name_str
);
545 ERR("SetName failed: %08x\n", nsres
);
550 static HRESULT WINAPI
HTMLWindow2_get_name(IHTMLWindow2
*iface
, BSTR
*p
)
552 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
557 TRACE("(%p)->(%p)\n", This
, p
);
559 nsAString_Init(&name_str
, NULL
);
560 nsres
= nsIDOMWindow_GetName(This
->nswindow
, &name_str
);
561 if(NS_SUCCEEDED(nsres
)) {
562 const PRUnichar
*name
;
564 nsAString_GetData(&name_str
, &name
);
566 *p
= SysAllocString(name
);
567 hres
= *p
? S_OK
: E_OUTOFMEMORY
;
573 ERR("GetName failed: %08x\n", nsres
);
576 nsAString_Finish(&name_str
);
581 static HRESULT WINAPI
HTMLWindow2_get_parent(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
583 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
584 FIXME("(%p)->(%p)\n", This
, p
);
588 static HRESULT WINAPI
HTMLWindow2_open(IHTMLWindow2
*iface
, BSTR url
, BSTR name
,
589 BSTR features
, VARIANT_BOOL replace
, IHTMLWindow2
**pomWindowResult
)
591 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
592 FIXME("(%p)->(%s %s %s %x %p)\n", This
, debugstr_w(url
), debugstr_w(name
),
593 debugstr_w(features
), replace
, pomWindowResult
);
597 static HRESULT WINAPI
HTMLWindow2_get_self(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
599 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
601 TRACE("(%p)->(%p)\n", This
, p
);
603 /* FIXME: We should return kind of proxy window here. */
604 IHTMLWindow2_AddRef(HTMLWINDOW2(This
));
605 *p
= HTMLWINDOW2(This
);
609 static HRESULT WINAPI
HTMLWindow2_get_top(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
611 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
612 FIXME("(%p)->(%p)\n", This
, p
);
616 static HRESULT WINAPI
HTMLWindow2_get_window(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
618 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
620 TRACE("(%p)->(%p)\n", This
, p
);
622 /* FIXME: We should return kind of proxy window here. */
623 IHTMLWindow2_AddRef(HTMLWINDOW2(This
));
624 *p
= HTMLWINDOW2(This
);
628 static HRESULT WINAPI
HTMLWindow2_navigate(IHTMLWindow2
*iface
, BSTR url
)
630 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
631 FIXME("(%p)->(%s)\n", This
, debugstr_w(url
));
635 static HRESULT WINAPI
HTMLWindow2_put_onfocus(IHTMLWindow2
*iface
, VARIANT v
)
637 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
638 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
642 static HRESULT WINAPI
HTMLWindow2_get_onfocus(IHTMLWindow2
*iface
, VARIANT
*p
)
644 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
645 FIXME("(%p)->(%p)\n", This
, p
);
649 static HRESULT WINAPI
HTMLWindow2_put_onblur(IHTMLWindow2
*iface
, VARIANT v
)
651 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
652 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
656 static HRESULT WINAPI
HTMLWindow2_get_onblur(IHTMLWindow2
*iface
, VARIANT
*p
)
658 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
659 FIXME("(%p)->(%p)\n", This
, p
);
663 static HRESULT WINAPI
HTMLWindow2_put_onload(IHTMLWindow2
*iface
, VARIANT v
)
665 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
667 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
669 return set_window_event(This
, EVENTID_LOAD
, &v
);
672 static HRESULT WINAPI
HTMLWindow2_get_onload(IHTMLWindow2
*iface
, VARIANT
*p
)
674 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
676 TRACE("(%p)->(%p)\n", This
, p
);
678 return get_window_event(This
, EVENTID_LOAD
, p
);
681 static HRESULT WINAPI
HTMLWindow2_put_onbeforeunload(IHTMLWindow2
*iface
, VARIANT v
)
683 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
685 TRACE("(%p)->(v(%d))\n", This
, V_VT(&v
));
687 return set_window_event(This
, EVENTID_BEFOREUNLOAD
, &v
);
690 static HRESULT WINAPI
HTMLWindow2_get_onbeforeunload(IHTMLWindow2
*iface
, VARIANT
*p
)
692 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
694 TRACE("(%p)->(%p)\n", This
, p
);
696 return get_window_event(This
, EVENTID_BEFOREUNLOAD
, p
);
699 static HRESULT WINAPI
HTMLWindow2_put_onunload(IHTMLWindow2
*iface
, VARIANT v
)
701 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
702 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
706 static HRESULT WINAPI
HTMLWindow2_get_onunload(IHTMLWindow2
*iface
, VARIANT
*p
)
708 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
709 FIXME("(%p)->(%p)\n", This
, p
);
713 static HRESULT WINAPI
HTMLWindow2_put_onhelp(IHTMLWindow2
*iface
, VARIANT v
)
715 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
716 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
720 static HRESULT WINAPI
HTMLWindow2_get_onhelp(IHTMLWindow2
*iface
, VARIANT
*p
)
722 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
723 FIXME("(%p)->(%p)\n", This
, p
);
727 static HRESULT WINAPI
HTMLWindow2_put_onerror(IHTMLWindow2
*iface
, VARIANT v
)
729 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
730 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
734 static HRESULT WINAPI
HTMLWindow2_get_onerror(IHTMLWindow2
*iface
, VARIANT
*p
)
736 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
737 FIXME("(%p)->(%p)\n", This
, p
);
741 static HRESULT WINAPI
HTMLWindow2_put_onresize(IHTMLWindow2
*iface
, VARIANT v
)
743 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
744 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
748 static HRESULT WINAPI
HTMLWindow2_get_onresize(IHTMLWindow2
*iface
, VARIANT
*p
)
750 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
751 FIXME("(%p)->(%p)\n", This
, p
);
755 static HRESULT WINAPI
HTMLWindow2_put_onscroll(IHTMLWindow2
*iface
, VARIANT v
)
757 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
758 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
762 static HRESULT WINAPI
HTMLWindow2_get_onscroll(IHTMLWindow2
*iface
, VARIANT
*p
)
764 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
765 FIXME("(%p)->(%p)\n", This
, p
);
769 static HRESULT WINAPI
HTMLWindow2_get_document(IHTMLWindow2
*iface
, IHTMLDocument2
**p
)
771 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
773 TRACE("(%p)->(%p)\n", This
, p
);
776 /* FIXME: We should return a wrapper object here */
777 *p
= HTMLDOC(&This
->doc
->basedoc
);
778 IHTMLDocument2_AddRef(*p
);
786 static HRESULT WINAPI
HTMLWindow2_get_event(IHTMLWindow2
*iface
, IHTMLEventObj
**p
)
788 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
790 TRACE("(%p)->(%p)\n", This
, p
);
793 IHTMLEventObj_AddRef(This
->event
);
798 static HRESULT WINAPI
HTMLWindow2_get__newEnum(IHTMLWindow2
*iface
, IUnknown
**p
)
800 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
801 FIXME("(%p)->(%p)\n", This
, p
);
805 static HRESULT WINAPI
HTMLWindow2_showModalDialog(IHTMLWindow2
*iface
, BSTR dialog
,
806 VARIANT
*varArgIn
, VARIANT
*varOptions
, VARIANT
*varArgOut
)
808 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
809 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(dialog
), varArgIn
, varOptions
, varArgOut
);
813 static HRESULT WINAPI
HTMLWindow2_showHelp(IHTMLWindow2
*iface
, BSTR helpURL
, VARIANT helpArg
,
816 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
817 FIXME("(%p)->(%s v(%d) %s)\n", This
, debugstr_w(helpURL
), V_VT(&helpArg
), debugstr_w(features
));
821 static HRESULT WINAPI
HTMLWindow2_get_screen(IHTMLWindow2
*iface
, IHTMLScreen
**p
)
823 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
824 FIXME("(%p)->(%p)\n", This
, p
);
828 static HRESULT WINAPI
HTMLWindow2_get_Option(IHTMLWindow2
*iface
, IHTMLOptionElementFactory
**p
)
830 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
832 TRACE("(%p)->(%p)\n", This
, p
);
834 if(!This
->option_factory
)
835 This
->option_factory
= HTMLOptionElementFactory_Create(This
);
837 *p
= HTMLOPTFACTORY(This
->option_factory
);
838 IHTMLOptionElementFactory_AddRef(*p
);
843 static HRESULT WINAPI
HTMLWindow2_focus(IHTMLWindow2
*iface
)
845 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
846 FIXME("(%p)->()\n", This
);
850 static HRESULT WINAPI
HTMLWindow2_get_closed(IHTMLWindow2
*iface
, VARIANT_BOOL
*p
)
852 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
853 FIXME("(%p)->(%p)\n", This
, p
);
857 static HRESULT WINAPI
HTMLWindow2_blur(IHTMLWindow2
*iface
)
859 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
860 FIXME("(%p)->()\n", This
);
864 static HRESULT WINAPI
HTMLWindow2_scroll(IHTMLWindow2
*iface
, LONG x
, LONG y
)
866 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
867 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
871 static HRESULT WINAPI
HTMLWindow2_get_clientInformation(IHTMLWindow2
*iface
, IOmNavigator
**p
)
873 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
874 FIXME("(%p)->(%p)\n", This
, p
);
878 static HRESULT WINAPI
HTMLWindow2_setInterval(IHTMLWindow2
*iface
, BSTR expression
,
879 LONG msec
, VARIANT
*language
, LONG
*timerID
)
881 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
884 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
886 V_VT(&expr
) = VT_BSTR
;
887 V_BSTR(&expr
) = expression
;
888 return IHTMLWindow3_setInterval(HTMLWINDOW3(This
), &expr
, msec
, language
, timerID
);
891 static HRESULT WINAPI
HTMLWindow2_clearInterval(IHTMLWindow2
*iface
, LONG timerID
)
893 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
895 TRACE("(%p)->(%d)\n", This
, timerID
);
897 return clear_task_timer(&This
->doc
->basedoc
, TRUE
, timerID
);
900 static HRESULT WINAPI
HTMLWindow2_put_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT v
)
902 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
903 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
907 static HRESULT WINAPI
HTMLWindow2_get_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT
*p
)
909 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
910 FIXME("(%p)->(%p)\n", This
, p
);
914 static HRESULT WINAPI
HTMLWindow2_execScript(IHTMLWindow2
*iface
, BSTR scode
, BSTR language
,
917 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
918 FIXME("(%p)->(%s %s %p)\n", This
, debugstr_w(scode
), debugstr_w(language
), pvarRet
);
922 static HRESULT WINAPI
HTMLWindow2_toString(IHTMLWindow2
*iface
, BSTR
*String
)
924 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
926 static const WCHAR objectW
[] = {'[','o','b','j','e','c','t',']',0};
928 TRACE("(%p)->(%p)\n", This
, String
);
933 *String
= SysAllocString(objectW
);
934 return *String
? S_OK
: E_OUTOFMEMORY
;
937 static HRESULT WINAPI
HTMLWindow2_scrollBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
939 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
942 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
944 nsres
= nsIDOMWindow_ScrollBy(This
->nswindow
, x
, y
);
946 ERR("ScrollBy failed: %08x\n", nsres
);
951 static HRESULT WINAPI
HTMLWindow2_scrollTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
953 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
956 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
958 nsres
= nsIDOMWindow_ScrollTo(This
->nswindow
, x
, y
);
960 ERR("ScrollTo failed: %08x\n", nsres
);
965 static HRESULT WINAPI
HTMLWindow2_moveTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
967 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
968 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
972 static HRESULT WINAPI
HTMLWindow2_moveBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
974 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
975 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
979 static HRESULT WINAPI
HTMLWindow2_resizeTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
981 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
982 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
986 static HRESULT WINAPI
HTMLWindow2_resizeBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
988 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
989 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
993 static HRESULT WINAPI
HTMLWindow2_get_external(IHTMLWindow2
*iface
, IDispatch
**p
)
995 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
997 TRACE("(%p)->(%p)\n", This
, p
);
1001 if(!This
->doc_obj
->hostui
)
1004 return IDocHostUIHandler_GetExternal(This
->doc_obj
->hostui
, p
);
1007 static HRESULT
HTMLWindow_invoke(IUnknown
*iface
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
1008 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
1010 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1011 global_prop_t
*prop
;
1015 idx
= id
- MSHTML_DISPID_CUSTOM_MIN
;
1016 if(idx
>= This
->global_prop_cnt
)
1017 return DISP_E_MEMBERNOTFOUND
;
1019 prop
= This
->global_props
+idx
;
1021 switch(prop
->type
) {
1022 case GLOBAL_SCRIPTVAR
: {
1023 IDispatchEx
*dispex
;
1026 disp
= get_script_disp(prop
->script_host
);
1028 return E_UNEXPECTED
;
1030 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
1031 if(SUCCEEDED(hres
)) {
1032 TRACE("%s >>>\n", debugstr_w(prop
->name
));
1033 hres
= IDispatchEx_InvokeEx(dispex
, prop
->id
, lcid
, flags
, params
, res
, ei
, caller
);
1035 TRACE("%s <<<\n", debugstr_w(prop
->name
));
1037 WARN("%s <<< %08x\n", debugstr_w(prop
->name
), hres
);
1038 IDispatchEx_Release(dispex
);
1040 FIXME("No IDispatchEx\n");
1042 IDispatch_Release(disp
);
1045 case GLOBAL_ELEMENTVAR
: {
1048 hres
= IHTMLDocument3_getElementById(HTMLDOC3(&This
->doc
->basedoc
), prop
->name
, &elem
);
1053 return DISP_E_MEMBERNOTFOUND
;
1055 V_VT(res
) = VT_DISPATCH
;
1056 V_DISPATCH(res
) = (IDispatch
*)elem
;
1060 ERR("invalid type %d\n", prop
->type
);
1061 hres
= DISP_E_MEMBERNOTFOUND
;
1067 #undef HTMLWINDOW2_THIS
1069 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl
= {
1070 HTMLWindow2_QueryInterface
,
1072 HTMLWindow2_Release
,
1073 HTMLWindow2_GetTypeInfoCount
,
1074 HTMLWindow2_GetTypeInfo
,
1075 HTMLWindow2_GetIDsOfNames
,
1078 HTMLWindow2_get_length
,
1079 HTMLWindow2_get_frames
,
1080 HTMLWindow2_put_defaultStatus
,
1081 HTMLWindow2_get_defaultStatus
,
1082 HTMLWindow2_put_status
,
1083 HTMLWindow2_get_status
,
1084 HTMLWindow2_setTimeout
,
1085 HTMLWindow2_clearTimeout
,
1087 HTMLWindow2_confirm
,
1089 HTMLWindow2_get_Image
,
1090 HTMLWindow2_get_location
,
1091 HTMLWindow2_get_history
,
1093 HTMLWindow2_put_opener
,
1094 HTMLWindow2_get_opener
,
1095 HTMLWindow2_get_navigator
,
1096 HTMLWindow2_put_name
,
1097 HTMLWindow2_get_name
,
1098 HTMLWindow2_get_parent
,
1100 HTMLWindow2_get_self
,
1101 HTMLWindow2_get_top
,
1102 HTMLWindow2_get_window
,
1103 HTMLWindow2_navigate
,
1104 HTMLWindow2_put_onfocus
,
1105 HTMLWindow2_get_onfocus
,
1106 HTMLWindow2_put_onblur
,
1107 HTMLWindow2_get_onblur
,
1108 HTMLWindow2_put_onload
,
1109 HTMLWindow2_get_onload
,
1110 HTMLWindow2_put_onbeforeunload
,
1111 HTMLWindow2_get_onbeforeunload
,
1112 HTMLWindow2_put_onunload
,
1113 HTMLWindow2_get_onunload
,
1114 HTMLWindow2_put_onhelp
,
1115 HTMLWindow2_get_onhelp
,
1116 HTMLWindow2_put_onerror
,
1117 HTMLWindow2_get_onerror
,
1118 HTMLWindow2_put_onresize
,
1119 HTMLWindow2_get_onresize
,
1120 HTMLWindow2_put_onscroll
,
1121 HTMLWindow2_get_onscroll
,
1122 HTMLWindow2_get_document
,
1123 HTMLWindow2_get_event
,
1124 HTMLWindow2_get__newEnum
,
1125 HTMLWindow2_showModalDialog
,
1126 HTMLWindow2_showHelp
,
1127 HTMLWindow2_get_screen
,
1128 HTMLWindow2_get_Option
,
1130 HTMLWindow2_get_closed
,
1133 HTMLWindow2_get_clientInformation
,
1134 HTMLWindow2_setInterval
,
1135 HTMLWindow2_clearInterval
,
1136 HTMLWindow2_put_offscreenBuffering
,
1137 HTMLWindow2_get_offscreenBuffering
,
1138 HTMLWindow2_execScript
,
1139 HTMLWindow2_toString
,
1140 HTMLWindow2_scrollBy
,
1141 HTMLWindow2_scrollTo
,
1144 HTMLWindow2_resizeTo
,
1145 HTMLWindow2_resizeBy
,
1146 HTMLWindow2_get_external
1149 #define HTMLWINDOW3_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow3, iface)
1151 static HRESULT WINAPI
HTMLWindow3_QueryInterface(IHTMLWindow3
*iface
, REFIID riid
, void **ppv
)
1153 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1155 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This
), riid
, ppv
);
1158 static ULONG WINAPI
HTMLWindow3_AddRef(IHTMLWindow3
*iface
)
1160 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1162 return IHTMLWindow2_AddRef(HTMLWINDOW2(This
));
1165 static ULONG WINAPI
HTMLWindow3_Release(IHTMLWindow3
*iface
)
1167 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1169 return IHTMLWindow2_Release(HTMLWINDOW2(This
));
1172 static HRESULT WINAPI
HTMLWindow3_GetTypeInfoCount(IHTMLWindow3
*iface
, UINT
*pctinfo
)
1174 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1176 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This
), pctinfo
);
1179 static HRESULT WINAPI
HTMLWindow3_GetTypeInfo(IHTMLWindow3
*iface
, UINT iTInfo
,
1180 LCID lcid
, ITypeInfo
**ppTInfo
)
1182 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1184 return IDispatchEx_GetTypeInfo(DISPATCHEX(This
), iTInfo
, lcid
, ppTInfo
);
1187 static HRESULT WINAPI
HTMLWindow3_GetIDsOfNames(IHTMLWindow3
*iface
, REFIID riid
,
1188 LPOLESTR
*rgszNames
, UINT cNames
,
1189 LCID lcid
, DISPID
*rgDispId
)
1191 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1193 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1196 static HRESULT WINAPI
HTMLWindow3_Invoke(IHTMLWindow3
*iface
, DISPID dispIdMember
,
1197 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1198 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1200 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1202 return IDispatchEx_Invoke(DISPATCHEX(This
), dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1203 pVarResult
, pExcepInfo
, puArgErr
);
1206 static HRESULT WINAPI
HTMLWindow3_get_screenLeft(IHTMLWindow3
*iface
, LONG
*p
)
1208 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1209 FIXME("(%p)->(%p)\n", This
, p
);
1213 static HRESULT WINAPI
HTMLWindow3_get_screenTop(IHTMLWindow3
*iface
, LONG
*p
)
1215 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1216 FIXME("(%p)->(%p)\n", This
, p
);
1220 static HRESULT WINAPI
HTMLWindow3_attachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
, VARIANT_BOOL
*pfResult
)
1222 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1224 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(event
), pDisp
, pfResult
);
1226 return attach_event(&This
->event_target
, &This
->doc_obj
->basedoc
, event
, pDisp
, pfResult
);
1229 static HRESULT WINAPI
HTMLWindow3_detachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
)
1231 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1232 FIXME("(%p)->()\n", This
);
1236 static HRESULT
window_set_timer(HTMLWindow
*This
, VARIANT
*expr
, LONG msec
, VARIANT
*language
,
1237 BOOL interval
, LONG
*timer_id
)
1239 IDispatch
*disp
= NULL
;
1241 switch(V_VT(expr
)) {
1243 disp
= V_DISPATCH(expr
);
1244 IDispatch_AddRef(disp
);
1248 disp
= script_parse_event(This
, V_BSTR(expr
));
1252 FIXME("unimplemented vt=%d\n", V_VT(expr
));
1259 *timer_id
= set_task_timer(&This
->doc
->basedoc
, msec
, interval
, disp
);
1260 IDispatch_Release(disp
);
1265 static HRESULT WINAPI
HTMLWindow3_setTimeout(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1266 VARIANT
*language
, LONG
*timerID
)
1268 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1270 TRACE("(%p)->(%p(%d) %d %p %p)\n", This
, expression
, V_VT(expression
), msec
, language
, timerID
);
1272 return window_set_timer(This
, expression
, msec
, language
, FALSE
, timerID
);
1275 static HRESULT WINAPI
HTMLWindow3_setInterval(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1276 VARIANT
*language
, LONG
*timerID
)
1278 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1280 TRACE("(%p)->(%p %d %p %p)\n", This
, expression
, msec
, language
, timerID
);
1282 return window_set_timer(This
, expression
, msec
, language
, TRUE
, timerID
);
1285 static HRESULT WINAPI
HTMLWindow3_print(IHTMLWindow3
*iface
)
1287 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1288 FIXME("(%p)\n", This
);
1292 static HRESULT WINAPI
HTMLWindow3_put_onbeforeprint(IHTMLWindow3
*iface
, VARIANT v
)
1294 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1295 FIXME("(%p)->()\n", This
);
1299 static HRESULT WINAPI
HTMLWindow3_get_onbeforeprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1301 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1302 FIXME("(%p)->(%p)\n", This
, p
);
1306 static HRESULT WINAPI
HTMLWindow3_put_onafterprint(IHTMLWindow3
*iface
, VARIANT v
)
1308 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1309 FIXME("(%p)->()\n", This
);
1313 static HRESULT WINAPI
HTMLWindow3_get_onafterprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1315 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1316 FIXME("(%p)->(%p)\n", This
, p
);
1320 static HRESULT WINAPI
HTMLWindow3_get_clipboardData(IHTMLWindow3
*iface
, IHTMLDataTransfer
**p
)
1322 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1323 FIXME("(%p)->(%p)\n", This
, p
);
1327 static HRESULT WINAPI
HTMLWindow3_showModelessDialog(IHTMLWindow3
*iface
, BSTR url
,
1328 VARIANT
*varArgIn
, VARIANT
*options
, IHTMLWindow2
**pDialog
)
1330 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1331 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(url
), varArgIn
, options
, pDialog
);
1335 #undef HTMLWINDOW3_THIS
1337 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl
= {
1338 HTMLWindow3_QueryInterface
,
1340 HTMLWindow3_Release
,
1341 HTMLWindow3_GetTypeInfoCount
,
1342 HTMLWindow3_GetTypeInfo
,
1343 HTMLWindow3_GetIDsOfNames
,
1345 HTMLWindow3_get_screenLeft
,
1346 HTMLWindow3_get_screenTop
,
1347 HTMLWindow3_attachEvent
,
1348 HTMLWindow3_detachEvent
,
1349 HTMLWindow3_setTimeout
,
1350 HTMLWindow3_setInterval
,
1352 HTMLWindow3_put_onbeforeprint
,
1353 HTMLWindow3_get_onbeforeprint
,
1354 HTMLWindow3_put_onafterprint
,
1355 HTMLWindow3_get_onafterprint
,
1356 HTMLWindow3_get_clipboardData
,
1357 HTMLWindow3_showModelessDialog
1360 #define HTMLWINDOW4_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow4, iface)
1362 static HRESULT WINAPI
HTMLWindow4_QueryInterface(IHTMLWindow4
*iface
, REFIID riid
, void **ppv
)
1364 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1366 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This
), riid
, ppv
);
1369 static ULONG WINAPI
HTMLWindow4_AddRef(IHTMLWindow4
*iface
)
1371 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1373 return IHTMLWindow2_AddRef(HTMLWINDOW2(This
));
1376 static ULONG WINAPI
HTMLWindow4_Release(IHTMLWindow4
*iface
)
1378 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1380 return IHTMLWindow2_Release(HTMLWINDOW2(This
));
1383 static HRESULT WINAPI
HTMLWindow4_GetTypeInfoCount(IHTMLWindow4
*iface
, UINT
*pctinfo
)
1385 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1387 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This
), pctinfo
);
1390 static HRESULT WINAPI
HTMLWindow4_GetTypeInfo(IHTMLWindow4
*iface
, UINT iTInfo
,
1391 LCID lcid
, ITypeInfo
**ppTInfo
)
1393 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1395 return IDispatchEx_GetTypeInfo(DISPATCHEX(This
), iTInfo
, lcid
, ppTInfo
);
1398 static HRESULT WINAPI
HTMLWindow4_GetIDsOfNames(IHTMLWindow4
*iface
, REFIID riid
,
1399 LPOLESTR
*rgszNames
, UINT cNames
,
1400 LCID lcid
, DISPID
*rgDispId
)
1402 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1404 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1407 static HRESULT WINAPI
HTMLWindow4_Invoke(IHTMLWindow4
*iface
, DISPID dispIdMember
,
1408 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1409 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1411 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1413 return IDispatchEx_Invoke(DISPATCHEX(This
), dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1414 pVarResult
, pExcepInfo
, puArgErr
);
1417 static HRESULT WINAPI
HTMLWindow4_createPopup(IHTMLWindow4
*iface
, VARIANT
*varArgIn
,
1418 IDispatch
**ppPopup
)
1420 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1421 FIXME("(%p)->(%p %p)\n", This
, varArgIn
, ppPopup
);
1425 static HRESULT WINAPI
HTMLWindow4_get_frameElement(IHTMLWindow4
*iface
, IHTMLFrameBase
**p
)
1427 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1428 FIXME("(%p)->(%p)\n", This
, p
);
1432 #undef HTMLWINDOW4_THIS
1434 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl
= {
1435 HTMLWindow4_QueryInterface
,
1437 HTMLWindow4_Release
,
1438 HTMLWindow4_GetTypeInfoCount
,
1439 HTMLWindow4_GetTypeInfo
,
1440 HTMLWindow4_GetIDsOfNames
,
1442 HTMLWindow4_createPopup
,
1443 HTMLWindow4_get_frameElement
1446 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLWindow, IDispatchEx, iface)
1448 static HRESULT WINAPI
WindowDispEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
1450 HTMLWindow
*This
= DISPEX_THIS(iface
);
1452 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This
), riid
, ppv
);
1455 static ULONG WINAPI
WindowDispEx_AddRef(IDispatchEx
*iface
)
1457 HTMLWindow
*This
= DISPEX_THIS(iface
);
1459 return IHTMLWindow2_AddRef(HTMLWINDOW2(This
));
1462 static ULONG WINAPI
WindowDispEx_Release(IDispatchEx
*iface
)
1464 HTMLWindow
*This
= DISPEX_THIS(iface
);
1466 return IHTMLWindow2_Release(HTMLWINDOW2(This
));
1469 static HRESULT WINAPI
WindowDispEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
1471 HTMLWindow
*This
= DISPEX_THIS(iface
);
1473 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1475 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->dispex
), pctinfo
);
1478 static HRESULT WINAPI
WindowDispEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
1479 LCID lcid
, ITypeInfo
**ppTInfo
)
1481 HTMLWindow
*This
= DISPEX_THIS(iface
);
1483 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1485 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This
->dispex
), iTInfo
, lcid
, ppTInfo
);
1488 static HRESULT WINAPI
WindowDispEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
1489 LPOLESTR
*rgszNames
, UINT cNames
,
1490 LCID lcid
, DISPID
*rgDispId
)
1492 HTMLWindow
*This
= DISPEX_THIS(iface
);
1494 TRACE("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1497 /* FIXME: Use script dispatch */
1499 return IDispatchEx_GetIDsOfNames(DISPATCHEX(&This
->dispex
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1502 static HRESULT WINAPI
WindowDispEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
1503 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1504 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1506 HTMLWindow
*This
= DISPEX_THIS(iface
);
1508 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1509 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1511 /* FIXME: Use script dispatch */
1513 return IDispatchEx_Invoke(DISPATCHEX(&This
->dispex
), dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1514 pVarResult
, pExcepInfo
, puArgErr
);
1517 static global_prop_t
*alloc_global_prop(HTMLWindow
*This
, global_prop_type_t type
, BSTR name
)
1519 if(This
->global_prop_cnt
== This
->global_prop_size
) {
1520 global_prop_t
*new_props
;
1523 if(This
->global_props
) {
1524 new_size
= This
->global_prop_size
*2;
1525 new_props
= heap_realloc(This
->global_props
, new_size
*sizeof(global_prop_t
));
1528 new_props
= heap_alloc(new_size
*sizeof(global_prop_t
));
1532 This
->global_props
= new_props
;
1533 This
->global_prop_size
= new_size
;
1536 This
->global_props
[This
->global_prop_cnt
].name
= heap_strdupW(name
);
1537 if(!This
->global_props
[This
->global_prop_cnt
].name
)
1540 This
->global_props
[This
->global_prop_cnt
].type
= type
;
1541 return This
->global_props
+ This
->global_prop_cnt
++;
1544 static inline DWORD
prop_to_dispid(HTMLWindow
*This
, global_prop_t
*prop
)
1546 return MSHTML_DISPID_CUSTOM_MIN
+ (prop
-This
->global_props
);
1549 static HRESULT WINAPI
WindowDispEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
1551 HTMLWindow
*This
= DISPEX_THIS(iface
);
1552 ScriptHost
*script_host
;
1557 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(bstrName
), grfdex
, pid
);
1559 for(i
=0; i
< This
->global_prop_cnt
; i
++) {
1560 /* FIXME: case sensitivity */
1561 if(!strcmpW(This
->global_props
[i
].name
, bstrName
)) {
1562 *pid
= MSHTML_DISPID_CUSTOM_MIN
+i
;
1567 if(find_global_prop(This
, bstrName
, grfdex
, &script_host
, &id
)) {
1568 global_prop_t
*prop
;
1570 prop
= alloc_global_prop(This
, GLOBAL_SCRIPTVAR
, bstrName
);
1572 return E_OUTOFMEMORY
;
1574 prop
->script_host
= script_host
;
1577 *pid
= prop_to_dispid(This
, prop
);
1581 hres
= IDispatchEx_GetDispID(DISPATCHEX(&This
->dispex
), bstrName
, grfdex
, pid
);
1582 if(hres
!= DISP_E_UNKNOWNNAME
)
1586 global_prop_t
*prop
;
1589 hres
= IHTMLDocument3_getElementById(HTMLDOC3(&This
->doc
->basedoc
), bstrName
, &elem
);
1590 if(SUCCEEDED(hres
) && elem
) {
1591 IHTMLElement_Release(elem
);
1593 prop
= alloc_global_prop(This
, GLOBAL_ELEMENTVAR
, bstrName
);
1595 return E_OUTOFMEMORY
;
1597 *pid
= prop_to_dispid(This
, prop
);
1602 return DISP_E_UNKNOWNNAME
;
1605 static HRESULT WINAPI
WindowDispEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1606 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1608 HTMLWindow
*This
= DISPEX_THIS(iface
);
1610 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1612 return IDispatchEx_InvokeEx(DISPATCHEX(&This
->dispex
), id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1615 static HRESULT WINAPI
WindowDispEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
1617 HTMLWindow
*This
= DISPEX_THIS(iface
);
1619 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(bstrName
), grfdex
);
1621 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This
->dispex
), bstrName
, grfdex
);
1624 static HRESULT WINAPI
WindowDispEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
1626 HTMLWindow
*This
= DISPEX_THIS(iface
);
1628 TRACE("(%p)->(%x)\n", This
, id
);
1630 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This
->dispex
), id
);
1633 static HRESULT WINAPI
WindowDispEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
1635 HTMLWindow
*This
= DISPEX_THIS(iface
);
1637 TRACE("(%p)->(%x %x %p)\n", This
, id
, grfdexFetch
, pgrfdex
);
1639 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This
->dispex
), id
, grfdexFetch
, pgrfdex
);
1642 static HRESULT WINAPI
WindowDispEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
1644 HTMLWindow
*This
= DISPEX_THIS(iface
);
1646 TRACE("(%p)->(%x %p)\n", This
, id
, pbstrName
);
1648 return IDispatchEx_GetMemberName(DISPATCHEX(&This
->dispex
), id
, pbstrName
);
1651 static HRESULT WINAPI
WindowDispEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
1653 HTMLWindow
*This
= DISPEX_THIS(iface
);
1655 TRACE("(%p)->(%x %x %p)\n", This
, grfdex
, id
, pid
);
1657 return IDispatchEx_GetNextDispID(DISPATCHEX(&This
->dispex
), grfdex
, id
, pid
);
1660 static HRESULT WINAPI
WindowDispEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
1662 HTMLWindow
*This
= DISPEX_THIS(iface
);
1664 TRACE("(%p)->(%p)\n", This
, ppunk
);
1672 static const IDispatchExVtbl WindowDispExVtbl
= {
1673 WindowDispEx_QueryInterface
,
1674 WindowDispEx_AddRef
,
1675 WindowDispEx_Release
,
1676 WindowDispEx_GetTypeInfoCount
,
1677 WindowDispEx_GetTypeInfo
,
1678 WindowDispEx_GetIDsOfNames
,
1679 WindowDispEx_Invoke
,
1680 WindowDispEx_GetDispID
,
1681 WindowDispEx_InvokeEx
,
1682 WindowDispEx_DeleteMemberByName
,
1683 WindowDispEx_DeleteMemberByDispID
,
1684 WindowDispEx_GetMemberProperties
,
1685 WindowDispEx_GetMemberName
,
1686 WindowDispEx_GetNextDispID
,
1687 WindowDispEx_GetNameSpaceParent
1690 static const tid_t HTMLWindow_iface_tids
[] = {
1697 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl
= {
1703 static dispex_static_data_t HTMLWindow_dispex
= {
1704 &HTMLWindow_dispex_vtbl
,
1705 DispHTMLWindow2_tid
,
1707 HTMLWindow_iface_tids
1710 HRESULT
HTMLWindow_Create(HTMLDocumentObj
*doc_obj
, nsIDOMWindow
*nswindow
, HTMLWindow
*parent
, HTMLWindow
**ret
)
1714 window
= heap_alloc_zero(sizeof(HTMLWindow
));
1716 return E_OUTOFMEMORY
;
1718 window
->window_ref
= heap_alloc(sizeof(windowref_t
));
1719 if(!window
->window_ref
) {
1721 return E_OUTOFMEMORY
;
1724 window
->lpHTMLWindow2Vtbl
= &HTMLWindow2Vtbl
;
1725 window
->lpHTMLWindow3Vtbl
= &HTMLWindow3Vtbl
;
1726 window
->lpHTMLWindow4Vtbl
= &HTMLWindow4Vtbl
;
1727 window
->lpIDispatchExVtbl
= &WindowDispExVtbl
;
1729 window
->doc_obj
= doc_obj
;
1731 window
->window_ref
->window
= window
;
1732 window
->window_ref
->ref
= 1;
1734 init_dispex(&window
->dispex
, (IUnknown
*)HTMLWINDOW2(window
), &HTMLWindow_dispex
);
1737 nsIDOMWindow_AddRef(nswindow
);
1738 window
->nswindow
= nswindow
;
1741 window
->scriptmode
= parent
? parent
->scriptmode
: SCRIPTMODE_GECKO
;
1742 window
->readystate
= READYSTATE_UNINITIALIZED
;
1743 list_init(&window
->script_hosts
);
1745 window
->task_magic
= get_task_target_magic();
1746 update_window_doc(window
);
1748 list_init(&window
->children
);
1749 list_add_head(&window_list
, &window
->entry
);
1752 IHTMLWindow2_AddRef(HTMLWINDOW2(window
));
1754 window
->parent
= parent
;
1755 list_add_tail(&parent
->children
, &window
->sibling_entry
);
1762 void update_window_doc(HTMLWindow
*window
)
1764 nsIDOMHTMLDocument
*nshtmldoc
;
1765 nsIDOMDocument
*nsdoc
;
1768 nsres
= nsIDOMWindow_GetDocument(window
->nswindow
, &nsdoc
);
1769 if(NS_FAILED(nsres
) || !nsdoc
) {
1770 ERR("GetDocument failed: %08x\n", nsres
);
1774 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMHTMLDocument
, (void**)&nshtmldoc
);
1775 nsIDOMDocument_Release(nsdoc
);
1776 if(NS_FAILED(nsres
)) {
1777 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres
);
1781 if(!window
->doc
|| window
->doc
->nsdoc
!= nshtmldoc
) {
1782 HTMLDocumentNode
*doc
;
1785 hres
= create_doc_from_nsdoc(nshtmldoc
, window
->doc_obj
, window
, &doc
);
1786 if(SUCCEEDED(hres
)) {
1787 window_set_docnode(window
, doc
);
1788 htmldoc_release(&doc
->basedoc
);
1790 ERR("create_doc_from_nsdoc failed: %08x\n", hres
);
1794 nsIDOMHTMLDocument_Release(nshtmldoc
);
1797 HTMLWindow
*nswindow_to_window(const nsIDOMWindow
*nswindow
)
1801 LIST_FOR_EACH_ENTRY(iter
, &window_list
, HTMLWindow
, entry
) {
1802 if(iter
->nswindow
== nswindow
)