2 * Copyright 2006-2012 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
33 #define NO_SHLWAPI_REG
36 #include "wine/debug.h"
38 #include "mshtml_private.h"
39 #include "htmlevent.h"
40 #include "htmlscript.h"
41 #include "pluginhost.h"
45 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
47 static struct list window_list
= LIST_INIT(window_list
);
49 static inline BOOL
is_outer_window(HTMLWindow
*window
)
51 return &window
->outer_window
->base
== window
;
54 static void release_children(HTMLOuterWindow
*This
)
56 HTMLOuterWindow
*child
;
58 while(!list_empty(&This
->children
)) {
59 child
= LIST_ENTRY(list_tail(&This
->children
), HTMLOuterWindow
, sibling_entry
);
61 list_remove(&child
->sibling_entry
);
63 IHTMLWindow2_Release(&child
->base
.IHTMLWindow2_iface
);
67 static HRESULT
get_location(HTMLInnerWindow
*This
, HTMLLocation
**ret
)
70 IHTMLLocation_AddRef(&This
->location
->IHTMLLocation_iface
);
74 hres
= HTMLLocation_Create(This
, &This
->location
);
79 *ret
= This
->location
;
83 void get_top_window(HTMLOuterWindow
*window
, HTMLOuterWindow
**ret
)
85 HTMLOuterWindow
*iter
;
87 for(iter
= window
; iter
->parent
; iter
= iter
->parent
);
91 static inline HRESULT
set_window_event(HTMLWindow
*window
, eventid_t eid
, VARIANT
*var
)
93 if(!window
->inner_window
->doc
) {
94 FIXME("No document\n");
98 return set_event_handler(&window
->inner_window
->event_target
, eid
, var
);
101 static inline HRESULT
get_window_event(HTMLWindow
*window
, eventid_t eid
, VARIANT
*var
)
103 if(!window
->inner_window
->doc
) {
104 FIXME("No document\n");
108 return get_event_handler(&window
->inner_window
->event_target
, eid
, var
);
111 static void detach_inner_window(HTMLInnerWindow
*window
)
113 HTMLOuterWindow
*outer_window
= window
->base
.outer_window
;
115 if(outer_window
&& outer_window
->doc_obj
&& outer_window
== outer_window
->doc_obj
->basedoc
.window
)
116 window
->doc
->basedoc
.cp_container
.forward_container
= NULL
;
119 detach_events(window
->doc
);
120 while(!list_empty(&window
->doc
->plugin_hosts
))
121 detach_plugin_host(LIST_ENTRY(list_head(&window
->doc
->plugin_hosts
), PluginHost
, entry
));
124 abort_window_bindings(window
);
125 remove_target_tasks(window
->task_magic
);
126 release_script_hosts(window
);
127 window
->base
.outer_window
= NULL
;
129 if(outer_window
&& outer_window
->base
.inner_window
== window
) {
130 outer_window
->base
.inner_window
= NULL
;
131 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
135 static inline HTMLWindow
*impl_from_IHTMLWindow2(IHTMLWindow2
*iface
)
137 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow2_iface
);
140 static HRESULT WINAPI
HTMLWindow2_QueryInterface(IHTMLWindow2
*iface
, REFIID riid
, void **ppv
)
142 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
144 TRACE("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
146 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
147 *ppv
= &This
->IHTMLWindow2_iface
;
148 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
149 *ppv
= &This
->IHTMLWindow2_iface
;
150 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
151 *ppv
= &This
->IDispatchEx_iface
;
152 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2
, riid
)) {
153 *ppv
= &This
->IHTMLWindow2_iface
;
154 }else if(IsEqualGUID(&IID_IHTMLWindow2
, riid
)) {
155 *ppv
= &This
->IHTMLWindow2_iface
;
156 }else if(IsEqualGUID(&IID_IHTMLWindow3
, riid
)) {
157 *ppv
= &This
->IHTMLWindow3_iface
;
158 }else if(IsEqualGUID(&IID_IHTMLWindow4
, riid
)) {
159 *ppv
= &This
->IHTMLWindow4_iface
;
160 }else if(IsEqualGUID(&IID_IHTMLWindow5
, riid
)) {
161 *ppv
= &This
->IHTMLWindow5_iface
;
162 }else if(IsEqualGUID(&IID_IHTMLWindow6
, riid
)) {
163 *ppv
= &This
->IHTMLWindow6_iface
;
164 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow
, riid
)) {
165 *ppv
= &This
->IHTMLPrivateWindow_iface
;
166 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
167 *ppv
= &This
->IServiceProvider_iface
;
168 }else if(IsEqualGUID(&IID_ITravelLogClient
, riid
)) {
169 *ppv
= &This
->ITravelLogClient_iface
;
170 }else if(IsEqualGUID(&IID_IObjectIdentity
, riid
)) {
171 *ppv
= &This
->IObjectIdentity_iface
;
172 }else if(dispex_query_interface(&This
->inner_window
->event_target
.dispex
, riid
, ppv
)) {
174 return E_NOINTERFACE
;
177 WARN("(%p)->(%s %p)\n", This
, debugstr_mshtml_guid(riid
), ppv
);
178 return E_NOINTERFACE
;
181 IUnknown_AddRef((IUnknown
*)*ppv
);
185 static ULONG WINAPI
HTMLWindow2_AddRef(IHTMLWindow2
*iface
)
187 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
188 LONG ref
= InterlockedIncrement(&This
->ref
);
190 TRACE("(%p) ref=%d\n", This
, ref
);
195 static void release_outer_window(HTMLOuterWindow
*This
)
197 if(This
->pending_window
) {
198 abort_window_bindings(This
->pending_window
);
199 This
->pending_window
->base
.outer_window
= NULL
;
200 IHTMLWindow2_Release(&This
->pending_window
->base
.IHTMLWindow2_iface
);
203 remove_target_tasks(This
->task_magic
);
204 set_current_mon(This
, NULL
, 0);
205 if(This
->base
.inner_window
)
206 detach_inner_window(This
->base
.inner_window
);
207 release_children(This
);
210 IInternetSecurityManager_Release(This
->secmgr
);
212 if(This
->frame_element
)
213 This
->frame_element
->content_window
= NULL
;
215 This
->window_ref
->window
= NULL
;
216 windowref_release(This
->window_ref
);
219 nsIDOMWindow_Release(This
->nswindow
);
220 if(This
->window_proxy
)
221 mozIDOMWindowProxy_Release(This
->window_proxy
);
223 list_remove(&This
->entry
);
227 static void release_inner_window(HTMLInnerWindow
*This
)
233 detach_inner_window(This
);
236 This
->doc
->window
= NULL
;
237 htmldoc_release(&This
->doc
->basedoc
);
240 release_dispex(&This
->event_target
.dispex
);
242 for(i
=0; i
< This
->global_prop_cnt
; i
++)
243 heap_free(This
->global_props
[i
].name
);
244 heap_free(This
->global_props
);
247 This
->location
->window
= NULL
;
248 IHTMLLocation_Release(&This
->location
->IHTMLLocation_iface
);
251 if(This
->image_factory
) {
252 This
->image_factory
->window
= NULL
;
253 IHTMLImageElementFactory_Release(&This
->image_factory
->IHTMLImageElementFactory_iface
);
256 if(This
->option_factory
) {
257 This
->option_factory
->window
= NULL
;
258 IHTMLOptionElementFactory_Release(&This
->option_factory
->IHTMLOptionElementFactory_iface
);
261 if(This
->xhr_factory
) {
262 This
->xhr_factory
->window
= NULL
;
263 IHTMLXMLHttpRequestFactory_Release(&This
->xhr_factory
->IHTMLXMLHttpRequestFactory_iface
);
267 IHTMLScreen_Release(This
->screen
);
270 This
->history
->window
= NULL
;
271 IOmHistory_Release(&This
->history
->IOmHistory_iface
);
274 if(This
->session_storage
)
275 IHTMLStorage_Release(This
->session_storage
);
278 IMoniker_Release(This
->mon
);
283 static ULONG WINAPI
HTMLWindow2_Release(IHTMLWindow2
*iface
)
285 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
286 LONG ref
= InterlockedDecrement(&This
->ref
);
288 TRACE("(%p) ref=%d\n", This
, ref
);
291 if(is_outer_window(This
))
292 release_outer_window(This
->outer_window
);
294 release_inner_window(This
->inner_window
);
300 static HRESULT WINAPI
HTMLWindow2_GetTypeInfoCount(IHTMLWindow2
*iface
, UINT
*pctinfo
)
302 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
304 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
307 static HRESULT WINAPI
HTMLWindow2_GetTypeInfo(IHTMLWindow2
*iface
, UINT iTInfo
,
308 LCID lcid
, ITypeInfo
**ppTInfo
)
310 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
312 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
315 static HRESULT WINAPI
HTMLWindow2_GetIDsOfNames(IHTMLWindow2
*iface
, REFIID riid
,
316 LPOLESTR
*rgszNames
, UINT cNames
,
317 LCID lcid
, DISPID
*rgDispId
)
319 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
321 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
325 static HRESULT WINAPI
HTMLWindow2_Invoke(IHTMLWindow2
*iface
, DISPID dispIdMember
,
326 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
327 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
329 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
331 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
332 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
335 static HRESULT
get_frame_by_index(HTMLOuterWindow
*This
, UINT32 index
, HTMLOuterWindow
**ret
)
337 nsIDOMWindowCollection
*nsframes
;
338 mozIDOMWindowProxy
*mozwindow
;
342 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nsframes
);
343 if(NS_FAILED(nsres
)) {
344 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres
);
348 nsres
= nsIDOMWindowCollection_GetLength(nsframes
, &length
);
349 assert(nsres
== NS_OK
);
351 if(index
>= length
) {
352 nsIDOMWindowCollection_Release(nsframes
);
353 return DISP_E_MEMBERNOTFOUND
;
356 nsres
= nsIDOMWindowCollection_Item(nsframes
, index
, &mozwindow
);
357 nsIDOMWindowCollection_Release(nsframes
);
358 if(NS_FAILED(nsres
)) {
359 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
363 *ret
= mozwindow_to_window(mozwindow
);
365 mozIDOMWindowProxy_Release(mozwindow
);
369 HRESULT
get_frame_by_name(HTMLOuterWindow
*This
, const WCHAR
*name
, BOOL deep
, HTMLOuterWindow
**ret
)
371 nsIDOMWindowCollection
*nsframes
;
372 HTMLOuterWindow
*window
= NULL
;
373 mozIDOMWindowProxy
*mozwindow
;
379 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nsframes
);
380 if(NS_FAILED(nsres
)) {
381 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres
);
386 WARN("nsIDOMWindow_GetFrames returned NULL nsframes: %p\n", This
->nswindow
);
387 return DISP_E_MEMBERNOTFOUND
;
390 nsAString_InitDepend(&name_str
, name
);
391 nsres
= nsIDOMWindowCollection_NamedItem(nsframes
, &name_str
, &mozwindow
);
392 nsAString_Finish(&name_str
);
393 if(NS_FAILED(nsres
)) {
394 nsIDOMWindowCollection_Release(nsframes
);
399 *ret
= mozwindow_to_window(mozwindow
);
403 nsres
= nsIDOMWindowCollection_GetLength(nsframes
, &length
);
404 assert(nsres
== NS_OK
);
406 for(i
= 0; i
< length
&& !window
; ++i
) {
407 HTMLOuterWindow
*window_iter
;
410 nsres
= nsIDOMWindowCollection_Item(nsframes
, i
, &mozwindow
);
411 if(NS_FAILED(nsres
)) {
412 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
417 window_iter
= mozwindow_to_window(mozwindow
);
419 mozIDOMWindowProxy_Release(mozwindow
);
422 WARN("nsIDOMWindow without HTMLOuterWindow: %p\n", mozwindow
);
426 hres
= IHTMLElement_get_id(&window_iter
->frame_element
->element
.IHTMLElement_iface
, &id
);
428 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres
);
432 if(id
&& !strcmpiW(id
, name
))
433 window
= window_iter
;
438 get_frame_by_name(window_iter
, name
, TRUE
, &window
);
441 nsIDOMWindowCollection_Release(nsframes
);
449 static HRESULT WINAPI
HTMLWindow2_item(IHTMLWindow2
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
451 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
452 HTMLOuterWindow
*window
= NULL
;
455 TRACE("(%p)->(%p %p)\n", This
, pvarIndex
, pvarResult
);
457 switch(V_VT(pvarIndex
)) {
459 int index
= V_I4(pvarIndex
);
460 TRACE("Getting index %d\n", index
);
462 return DISP_E_MEMBERNOTFOUND
;
463 hres
= get_frame_by_index(This
->outer_window
, index
, &window
);
467 unsigned int index
= V_UINT(pvarIndex
);
468 TRACE("Getting index %u\n", index
);
469 hres
= get_frame_by_index(This
->outer_window
, index
, &window
);
473 BSTR str
= V_BSTR(pvarIndex
);
474 TRACE("Getting name %s\n", wine_dbgstr_w(str
));
475 hres
= get_frame_by_name(This
->outer_window
, str
, FALSE
, &window
);
479 WARN("Invalid index %s\n", debugstr_variant(pvarIndex
));
486 return DISP_E_MEMBERNOTFOUND
;
488 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
489 V_VT(pvarResult
) = VT_DISPATCH
;
490 V_DISPATCH(pvarResult
) = (IDispatch
*)window
;
494 static HRESULT WINAPI
HTMLWindow2_get_length(IHTMLWindow2
*iface
, LONG
*p
)
496 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
497 nsIDOMWindowCollection
*nscollection
;
501 TRACE("(%p)->(%p)\n", This
, p
);
503 nsres
= nsIDOMWindow_GetFrames(This
->outer_window
->nswindow
, &nscollection
);
504 if(NS_FAILED(nsres
)) {
505 ERR("GetFrames failed: %08x\n", nsres
);
509 nsres
= nsIDOMWindowCollection_GetLength(nscollection
, &length
);
510 nsIDOMWindowCollection_Release(nscollection
);
511 if(NS_FAILED(nsres
)) {
512 ERR("GetLength failed: %08x\n", nsres
);
520 static HRESULT WINAPI
HTMLWindow2_get_frames(IHTMLWindow2
*iface
, IHTMLFramesCollection2
**p
)
522 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
523 FIXME("(%p)->(%p): semi-stub\n", This
, p
);
525 /* FIXME: Should return a separate Window object */
526 *p
= (IHTMLFramesCollection2
*)&This
->IHTMLWindow2_iface
;
527 HTMLWindow2_AddRef(iface
);
531 static HRESULT WINAPI
HTMLWindow2_put_defaultStatus(IHTMLWindow2
*iface
, BSTR v
)
533 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
534 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
538 static HRESULT WINAPI
HTMLWindow2_get_defaultStatus(IHTMLWindow2
*iface
, BSTR
*p
)
540 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
541 FIXME("(%p)->(%p)\n", This
, p
);
545 static HRESULT WINAPI
HTMLWindow2_put_status(IHTMLWindow2
*iface
, BSTR v
)
547 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
549 WARN("(%p)->(%s)\n", This
, debugstr_w(v
));
552 * FIXME: Since IE7, setting status is blocked, but still possible in certain circumstances.
553 * Ignoring the call should be enough for us.
558 static HRESULT WINAPI
HTMLWindow2_get_status(IHTMLWindow2
*iface
, BSTR
*p
)
560 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
562 TRACE("(%p)->(%p)\n", This
, p
);
569 static HRESULT WINAPI
HTMLWindow2_setTimeout(IHTMLWindow2
*iface
, BSTR expression
,
570 LONG msec
, VARIANT
*language
, LONG
*timerID
)
572 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
575 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
577 V_VT(&expr_var
) = VT_BSTR
;
578 V_BSTR(&expr_var
) = expression
;
580 return IHTMLWindow3_setTimeout(&This
->IHTMLWindow3_iface
, &expr_var
, msec
, language
, timerID
);
583 static HRESULT WINAPI
HTMLWindow2_clearTimeout(IHTMLWindow2
*iface
, LONG timerID
)
585 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
587 TRACE("(%p)->(%d)\n", This
, timerID
);
589 return clear_task_timer(This
->inner_window
, timerID
);
592 #define MAX_MESSAGE_LEN 2000
594 static HRESULT WINAPI
HTMLWindow2_alert(IHTMLWindow2
*iface
, BSTR message
)
596 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
597 WCHAR title
[100], *msg
= message
;
600 TRACE("(%p)->(%s)\n", This
, debugstr_w(message
));
602 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, title
,
603 sizeof(title
)/sizeof(WCHAR
))) {
604 WARN("Could not load message box title: %d\n", GetLastError());
608 len
= SysStringLen(message
);
609 if(len
> MAX_MESSAGE_LEN
) {
610 msg
= heap_alloc((MAX_MESSAGE_LEN
+1)*sizeof(WCHAR
));
612 return E_OUTOFMEMORY
;
613 memcpy(msg
, message
, MAX_MESSAGE_LEN
*sizeof(WCHAR
));
614 msg
[MAX_MESSAGE_LEN
] = 0;
617 MessageBoxW(This
->outer_window
->doc_obj
->hwnd
, msg
, title
, MB_ICONWARNING
);
623 static HRESULT WINAPI
HTMLWindow2_confirm(IHTMLWindow2
*iface
, BSTR message
,
624 VARIANT_BOOL
*confirmed
)
626 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
629 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(message
), confirmed
);
631 if(!confirmed
) return E_INVALIDARG
;
633 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
634 sizeof(wszTitle
)/sizeof(WCHAR
))) {
635 WARN("Could not load message box title: %d\n", GetLastError());
636 *confirmed
= VARIANT_TRUE
;
640 if(MessageBoxW(This
->outer_window
->doc_obj
->hwnd
, message
, wszTitle
,
641 MB_OKCANCEL
|MB_ICONQUESTION
)==IDOK
)
642 *confirmed
= VARIANT_TRUE
;
643 else *confirmed
= VARIANT_FALSE
;
655 static INT_PTR CALLBACK
prompt_dlgproc(HWND hwnd
, UINT msg
,
656 WPARAM wparam
, LPARAM lparam
)
662 prompt_arg
*arg
= (prompt_arg
*)lparam
;
665 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
666 sizeof(wszTitle
)/sizeof(WCHAR
))) {
667 WARN("Could not load message box title: %d\n", GetLastError());
668 EndDialog(hwnd
, wparam
);
672 SetWindowLongPtrW(hwnd
, DWLP_USER
, lparam
);
673 SetWindowTextW(hwnd
, wszTitle
);
674 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_PROMPT
), arg
->message
);
675 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_EDIT
), arg
->dststr
);
681 case MAKEWPARAM(IDCANCEL
, BN_CLICKED
):
682 EndDialog(hwnd
, wparam
);
684 case MAKEWPARAM(IDOK
, BN_CLICKED
):
687 (prompt_arg
*)GetWindowLongPtrW(hwnd
, DWLP_USER
);
688 HWND hwndPrompt
= GetDlgItem(hwnd
, ID_PROMPT_EDIT
);
689 INT len
= GetWindowTextLengthW(hwndPrompt
);
693 EndDialog(hwnd
, wparam
);
697 V_VT(arg
->textdata
) = VT_BSTR
;
698 if(!len
&& !arg
->dststr
)
699 V_BSTR(arg
->textdata
) = NULL
;
702 V_BSTR(arg
->textdata
) = SysAllocStringLen(NULL
, len
);
703 GetWindowTextW(hwndPrompt
, V_BSTR(arg
->textdata
), len
+1);
705 EndDialog(hwnd
, wparam
);
711 EndDialog(hwnd
, IDCANCEL
);
718 static HRESULT WINAPI
HTMLWindow2_prompt(IHTMLWindow2
*iface
, BSTR message
,
719 BSTR dststr
, VARIANT
*textdata
)
721 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
724 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(message
), debugstr_w(dststr
), textdata
);
726 if(textdata
) V_VT(textdata
) = VT_NULL
;
728 arg
.message
= message
;
730 arg
.textdata
= textdata
;
732 DialogBoxParamW(hInst
, MAKEINTRESOURCEW(ID_PROMPT_DIALOG
),
733 This
->outer_window
->doc_obj
->hwnd
, prompt_dlgproc
, (LPARAM
)&arg
);
737 static HRESULT WINAPI
HTMLWindow2_get_Image(IHTMLWindow2
*iface
, IHTMLImageElementFactory
**p
)
739 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
740 HTMLInnerWindow
*window
= This
->inner_window
;
742 TRACE("(%p)->(%p)\n", This
, p
);
744 if(!window
->image_factory
) {
747 hres
= HTMLImageElementFactory_Create(window
, &window
->image_factory
);
752 *p
= &window
->image_factory
->IHTMLImageElementFactory_iface
;
753 IHTMLImageElementFactory_AddRef(*p
);
758 static HRESULT WINAPI
HTMLWindow2_get_location(IHTMLWindow2
*iface
, IHTMLLocation
**p
)
760 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
761 HTMLLocation
*location
;
764 TRACE("(%p)->(%p)\n", This
, p
);
766 hres
= get_location(This
->inner_window
, &location
);
770 *p
= &location
->IHTMLLocation_iface
;
774 static HRESULT WINAPI
HTMLWindow2_get_history(IHTMLWindow2
*iface
, IOmHistory
**p
)
776 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
777 HTMLInnerWindow
*window
= This
->inner_window
;
779 TRACE("(%p)->(%p)\n", This
, p
);
781 if(!window
->history
) {
784 hres
= create_history(window
, &window
->history
);
789 IOmHistory_AddRef(&window
->history
->IOmHistory_iface
);
790 *p
= &window
->history
->IOmHistory_iface
;
794 static BOOL
notify_webbrowser_close(HTMLOuterWindow
*window
, HTMLDocumentObj
*doc
)
796 IConnectionPointContainer
*cp_container
;
797 VARIANT_BOOL cancel
= VARIANT_FALSE
;
798 IEnumConnections
*enum_conn
;
800 DISPPARAMS dp
= {args
, NULL
, 2, 0};
801 CONNECTDATA conn_data
;
802 IConnectionPoint
*cp
;
810 hres
= IUnknown_QueryInterface(doc
->webbrowser
, &IID_IConnectionPointContainer
, (void**)&cp_container
);
814 hres
= IConnectionPointContainer_FindConnectionPoint(cp_container
, &DIID_DWebBrowserEvents2
, &cp
);
815 IConnectionPointContainer_Release(cp_container
);
819 hres
= IConnectionPoint_EnumConnections(cp
, &enum_conn
);
820 IConnectionPoint_Release(cp
);
825 conn_data
.pUnk
= NULL
;
826 conn_data
.dwCookie
= 0;
828 hres
= IEnumConnections_Next(enum_conn
, 1, &conn_data
, &fetched
);
832 hres
= IUnknown_QueryInterface(conn_data
.pUnk
, &IID_IDispatch
, (void**)&disp
);
833 IUnknown_Release(conn_data
.pUnk
);
837 V_VT(args
) = VT_BYREF
|VT_BOOL
;
838 V_BOOLREF(args
) = &cancel
;
839 V_VT(args
+1) = VT_BOOL
;
840 V_BOOL(args
+1) = window
->parent
? VARIANT_TRUE
: VARIANT_FALSE
;
841 hres
= IDispatch_Invoke(disp
, DISPID_WINDOWCLOSING
, &IID_NULL
, 0, DISPATCH_METHOD
, &dp
, NULL
, NULL
, NULL
);
842 IDispatch_Release(disp
);
844 cancel
= VARIANT_FALSE
;
847 IEnumConnections_Release(enum_conn
);
851 static HRESULT WINAPI
HTMLWindow2_close(IHTMLWindow2
*iface
)
853 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
854 HTMLOuterWindow
*window
= This
->outer_window
;
856 TRACE("(%p)\n", This
);
858 if(!window
->doc_obj
) {
859 FIXME("No document object\n");
863 if(!notify_webbrowser_close(window
, window
->doc_obj
))
866 FIXME("default action not implemented\n");
870 static HRESULT WINAPI
HTMLWindow2_put_opener(IHTMLWindow2
*iface
, VARIANT v
)
872 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
873 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
877 static HRESULT WINAPI
HTMLWindow2_get_opener(IHTMLWindow2
*iface
, VARIANT
*p
)
879 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
881 FIXME("(%p)->(%p) returning empty\n", This
, p
);
887 static HRESULT WINAPI
HTMLWindow2_get_navigator(IHTMLWindow2
*iface
, IOmNavigator
**p
)
889 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
891 TRACE("(%p)->(%p)\n", This
, p
);
893 *p
= OmNavigator_Create();
894 return *p
? S_OK
: E_OUTOFMEMORY
;
897 static HRESULT WINAPI
HTMLWindow2_put_name(IHTMLWindow2
*iface
, BSTR v
)
899 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
903 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
905 nsAString_InitDepend(&name_str
, v
);
906 nsres
= nsIDOMWindow_SetName(This
->outer_window
->nswindow
, &name_str
);
907 nsAString_Finish(&name_str
);
909 ERR("SetName failed: %08x\n", nsres
);
914 static HRESULT WINAPI
HTMLWindow2_get_name(IHTMLWindow2
*iface
, BSTR
*p
)
916 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
920 TRACE("(%p)->(%p)\n", This
, p
);
922 nsAString_Init(&name_str
, NULL
);
923 nsres
= nsIDOMWindow_GetName(This
->outer_window
->nswindow
, &name_str
);
924 return return_nsstr(nsres
, &name_str
, p
);
927 static HRESULT WINAPI
HTMLWindow2_get_parent(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
929 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
930 HTMLOuterWindow
*window
= This
->outer_window
;
932 TRACE("(%p)->(%p)\n", This
, p
);
935 return IHTMLWindow2_get_self(&This
->IHTMLWindow2_iface
, p
);
937 *p
= &window
->parent
->base
.IHTMLWindow2_iface
;
938 IHTMLWindow2_AddRef(*p
);
942 static HRESULT WINAPI
HTMLWindow2_open(IHTMLWindow2
*iface
, BSTR url
, BSTR name
,
943 BSTR features
, VARIANT_BOOL replace
, IHTMLWindow2
**pomWindowResult
)
945 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
946 HTMLOuterWindow
*window
= This
->outer_window
;
947 INewWindowManager
*new_window_mgr
;
952 static const WCHAR _selfW
[] = {'_','s','e','l','f',0};
954 TRACE("(%p)->(%s %s %s %x %p)\n", This
, debugstr_w(url
), debugstr_w(name
),
955 debugstr_w(features
), replace
, pomWindowResult
);
957 if(!window
->doc_obj
|| !window
->uri_nofrag
)
960 if(name
&& *name
== '_') {
961 if(!strcmpW(name
, _selfW
)) {
962 if((features
&& *features
) || replace
)
963 FIXME("Unsupported arguments for _self target\n");
965 hres
= IHTMLWindow2_navigate(&This
->IHTMLWindow2_iface
, url
);
969 if(pomWindowResult
) {
970 FIXME("Returning this window for _self target\n");
971 *pomWindowResult
= &This
->IHTMLWindow2_iface
;
972 IHTMLWindow2_AddRef(*pomWindowResult
);
978 FIXME("Unsupported name %s\n", debugstr_w(name
));
982 hres
= do_query_service((IUnknown
*)window
->doc_obj
->client
, &SID_SNewWindowManager
, &IID_INewWindowManager
,
983 (void**)&new_window_mgr
);
985 FIXME("No INewWindowManager\n");
989 hres
= IUri_GetDisplayUri(window
->uri_nofrag
, &uri_str
);
990 if(SUCCEEDED(hres
)) {
991 hres
= INewWindowManager_EvaluateNewWindow(new_window_mgr
, url
, name
, uri_str
,
992 features
, !!replace
, window
->doc_obj
->has_popup
? 0 : NWMF_FIRST
, 0);
993 window
->doc_obj
->has_popup
= TRUE
;
994 SysFreeString(uri_str
);
996 INewWindowManager_Release(new_window_mgr
);
998 *pomWindowResult
= NULL
;
1002 hres
= create_relative_uri(window
, url
, &uri
);
1006 hres
= navigate_new_window(window
, uri
, name
, NULL
, pomWindowResult
);
1011 static HRESULT WINAPI
HTMLWindow2_get_self(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
1013 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1015 TRACE("(%p)->(%p)\n", This
, p
);
1017 /* FIXME: We should return kind of proxy window here. */
1018 IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1019 *p
= &This
->IHTMLWindow2_iface
;
1023 static HRESULT WINAPI
HTMLWindow2_get_top(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
1025 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1026 HTMLOuterWindow
*top
;
1028 TRACE("(%p)->(%p)\n", This
, p
);
1030 get_top_window(This
->outer_window
, &top
);
1031 *p
= &top
->base
.IHTMLWindow2_iface
;
1032 IHTMLWindow2_AddRef(*p
);
1037 static HRESULT WINAPI
HTMLWindow2_get_window(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
1039 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1041 TRACE("(%p)->(%p)\n", This
, p
);
1043 /* FIXME: We should return kind of proxy window here. */
1044 IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1045 *p
= &This
->IHTMLWindow2_iface
;
1049 static HRESULT WINAPI
HTMLWindow2_navigate(IHTMLWindow2
*iface
, BSTR url
)
1051 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1053 TRACE("(%p)->(%s)\n", This
, debugstr_w(url
));
1055 return navigate_url(This
->outer_window
, url
, This
->outer_window
->uri
, BINDING_NAVIGATED
);
1058 static HRESULT WINAPI
HTMLWindow2_put_onfocus(IHTMLWindow2
*iface
, VARIANT v
)
1060 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1062 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1064 return set_window_event(This
, EVENTID_FOCUS
, &v
);
1067 static HRESULT WINAPI
HTMLWindow2_get_onfocus(IHTMLWindow2
*iface
, VARIANT
*p
)
1069 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1071 TRACE("(%p)->(%p)\n", This
, p
);
1073 return get_window_event(This
, EVENTID_FOCUS
, p
);
1076 static HRESULT WINAPI
HTMLWindow2_put_onblur(IHTMLWindow2
*iface
, VARIANT v
)
1078 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1080 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1082 return set_window_event(This
, EVENTID_BLUR
, &v
);
1085 static HRESULT WINAPI
HTMLWindow2_get_onblur(IHTMLWindow2
*iface
, VARIANT
*p
)
1087 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1089 TRACE("(%p)->(%p)\n", This
, p
);
1091 return get_window_event(This
, EVENTID_BLUR
, p
);
1094 static HRESULT WINAPI
HTMLWindow2_put_onload(IHTMLWindow2
*iface
, VARIANT v
)
1096 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1098 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1100 return set_window_event(This
, EVENTID_LOAD
, &v
);
1103 static HRESULT WINAPI
HTMLWindow2_get_onload(IHTMLWindow2
*iface
, VARIANT
*p
)
1105 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1107 TRACE("(%p)->(%p)\n", This
, p
);
1109 return get_window_event(This
, EVENTID_LOAD
, p
);
1112 static HRESULT WINAPI
HTMLWindow2_put_onbeforeunload(IHTMLWindow2
*iface
, VARIANT v
)
1114 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1116 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1118 return set_window_event(This
, EVENTID_BEFOREUNLOAD
, &v
);
1121 static HRESULT WINAPI
HTMLWindow2_get_onbeforeunload(IHTMLWindow2
*iface
, VARIANT
*p
)
1123 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1125 TRACE("(%p)->(%p)\n", This
, p
);
1127 return get_window_event(This
, EVENTID_BEFOREUNLOAD
, p
);
1130 static HRESULT WINAPI
HTMLWindow2_put_onunload(IHTMLWindow2
*iface
, VARIANT v
)
1132 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1134 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1136 return set_window_event(This
, EVENTID_UNLOAD
, &v
);
1139 static HRESULT WINAPI
HTMLWindow2_get_onunload(IHTMLWindow2
*iface
, VARIANT
*p
)
1141 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1143 TRACE("(%p)->(%p)\n", This
, p
);
1145 return get_window_event(This
, EVENTID_UNLOAD
, p
);
1148 static HRESULT WINAPI
HTMLWindow2_put_onhelp(IHTMLWindow2
*iface
, VARIANT v
)
1150 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1152 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1154 return set_window_event(This
, EVENTID_HELP
, &v
);
1157 static HRESULT WINAPI
HTMLWindow2_get_onhelp(IHTMLWindow2
*iface
, VARIANT
*p
)
1159 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1161 TRACE("(%p)->(%p)\n", This
, p
);
1163 return get_window_event(This
, EVENTID_HELP
, p
);
1166 static HRESULT WINAPI
HTMLWindow2_put_onerror(IHTMLWindow2
*iface
, VARIANT v
)
1168 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1170 FIXME("(%p)->(%s) semi-stub\n", This
, debugstr_variant(&v
));
1172 return set_window_event(This
, EVENTID_ERROR
, &v
);
1175 static HRESULT WINAPI
HTMLWindow2_get_onerror(IHTMLWindow2
*iface
, VARIANT
*p
)
1177 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1179 TRACE("(%p)->(%p)\n", This
, p
);
1181 return get_window_event(This
, EVENTID_ERROR
, p
);
1184 static HRESULT WINAPI
HTMLWindow2_put_onresize(IHTMLWindow2
*iface
, VARIANT v
)
1186 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1188 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1190 return set_window_event(This
, EVENTID_RESIZE
, &v
);
1193 static HRESULT WINAPI
HTMLWindow2_get_onresize(IHTMLWindow2
*iface
, VARIANT
*p
)
1195 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1197 TRACE("(%p)->(%p)\n", This
, p
);
1199 return get_window_event(This
, EVENTID_RESIZE
, p
);
1202 static HRESULT WINAPI
HTMLWindow2_put_onscroll(IHTMLWindow2
*iface
, VARIANT v
)
1204 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1206 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1208 return set_window_event(This
, EVENTID_SCROLL
, &v
);
1211 static HRESULT WINAPI
HTMLWindow2_get_onscroll(IHTMLWindow2
*iface
, VARIANT
*p
)
1213 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1215 TRACE("(%p)->(%p)\n", This
, p
);
1217 return get_window_event(This
, EVENTID_SCROLL
, p
);
1220 static HRESULT WINAPI
HTMLWindow2_get_document(IHTMLWindow2
*iface
, IHTMLDocument2
**p
)
1222 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1224 TRACE("(%p)->(%p)\n", This
, p
);
1226 if(This
->inner_window
->doc
) {
1227 /* FIXME: We should return a wrapper object here */
1228 *p
= &This
->inner_window
->doc
->basedoc
.IHTMLDocument2_iface
;
1229 IHTMLDocument2_AddRef(*p
);
1237 static HRESULT WINAPI
HTMLWindow2_get_event(IHTMLWindow2
*iface
, IHTMLEventObj
**p
)
1239 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1240 HTMLInnerWindow
*window
= This
->inner_window
;
1242 TRACE("(%p)->(%p)\n", This
, p
);
1245 IHTMLEventObj_AddRef(window
->event
);
1250 static HRESULT WINAPI
HTMLWindow2_get__newEnum(IHTMLWindow2
*iface
, IUnknown
**p
)
1252 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1253 FIXME("(%p)->(%p)\n", This
, p
);
1257 static HRESULT WINAPI
HTMLWindow2_showModalDialog(IHTMLWindow2
*iface
, BSTR dialog
,
1258 VARIANT
*varArgIn
, VARIANT
*varOptions
, VARIANT
*varArgOut
)
1260 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1261 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(dialog
), varArgIn
, varOptions
, varArgOut
);
1265 static HRESULT WINAPI
HTMLWindow2_showHelp(IHTMLWindow2
*iface
, BSTR helpURL
, VARIANT helpArg
,
1268 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1269 FIXME("(%p)->(%s %s %s)\n", This
, debugstr_w(helpURL
), debugstr_variant(&helpArg
), debugstr_w(features
));
1273 static HRESULT WINAPI
HTMLWindow2_get_screen(IHTMLWindow2
*iface
, IHTMLScreen
**p
)
1275 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1276 HTMLInnerWindow
*window
= This
->inner_window
;
1278 TRACE("(%p)->(%p)\n", This
, p
);
1280 if(!window
->screen
) {
1283 hres
= HTMLScreen_Create(&window
->screen
);
1288 *p
= window
->screen
;
1289 IHTMLScreen_AddRef(window
->screen
);
1293 static HRESULT WINAPI
HTMLWindow2_get_Option(IHTMLWindow2
*iface
, IHTMLOptionElementFactory
**p
)
1295 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1296 HTMLInnerWindow
*window
= This
->inner_window
;
1298 TRACE("(%p)->(%p)\n", This
, p
);
1300 if(!window
->option_factory
) {
1303 hres
= HTMLOptionElementFactory_Create(window
, &window
->option_factory
);
1308 *p
= &window
->option_factory
->IHTMLOptionElementFactory_iface
;
1309 IHTMLOptionElementFactory_AddRef(*p
);
1314 static HRESULT WINAPI
HTMLWindow2_focus(IHTMLWindow2
*iface
)
1316 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1318 TRACE("(%p)->()\n", This
);
1320 if(This
->outer_window
->doc_obj
)
1321 SetFocus(This
->outer_window
->doc_obj
->hwnd
);
1325 static HRESULT WINAPI
HTMLWindow2_get_closed(IHTMLWindow2
*iface
, VARIANT_BOOL
*p
)
1327 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1328 FIXME("(%p)->(%p)\n", This
, p
);
1332 static HRESULT WINAPI
HTMLWindow2_blur(IHTMLWindow2
*iface
)
1334 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1335 FIXME("(%p)->()\n", This
);
1339 static HRESULT WINAPI
HTMLWindow2_scroll(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1341 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1344 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1346 nsres
= nsIDOMWindow_Scroll(This
->outer_window
->nswindow
, x
, y
);
1347 if(NS_FAILED(nsres
)) {
1348 ERR("ScrollBy failed: %08x\n", nsres
);
1355 static HRESULT WINAPI
HTMLWindow2_get_clientInformation(IHTMLWindow2
*iface
, IOmNavigator
**p
)
1357 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1359 TRACE("(%p)->(%p)\n", This
, p
);
1361 return IHTMLWindow2_get_navigator(&This
->IHTMLWindow2_iface
, p
);
1364 static HRESULT WINAPI
HTMLWindow2_setInterval(IHTMLWindow2
*iface
, BSTR expression
,
1365 LONG msec
, VARIANT
*language
, LONG
*timerID
)
1367 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1370 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
1372 V_VT(&expr
) = VT_BSTR
;
1373 V_BSTR(&expr
) = expression
;
1374 return IHTMLWindow3_setInterval(&This
->IHTMLWindow3_iface
, &expr
, msec
, language
, timerID
);
1377 static HRESULT WINAPI
HTMLWindow2_clearInterval(IHTMLWindow2
*iface
, LONG timerID
)
1379 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1381 TRACE("(%p)->(%d)\n", This
, timerID
);
1383 return clear_task_timer(This
->inner_window
, timerID
);
1386 static HRESULT WINAPI
HTMLWindow2_put_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT v
)
1388 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1389 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1393 static HRESULT WINAPI
HTMLWindow2_get_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT
*p
)
1395 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1396 FIXME("(%p)->(%p)\n", This
, p
);
1400 static HRESULT WINAPI
HTMLWindow2_execScript(IHTMLWindow2
*iface
, BSTR scode
, BSTR language
,
1403 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1405 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(scode
), debugstr_w(language
), pvarRet
);
1407 return exec_script(This
->inner_window
, scode
, language
, pvarRet
);
1410 static HRESULT WINAPI
HTMLWindow2_toString(IHTMLWindow2
*iface
, BSTR
*String
)
1412 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1414 static const WCHAR objectW
[] = {'[','o','b','j','e','c','t',']',0};
1416 TRACE("(%p)->(%p)\n", This
, String
);
1419 return E_INVALIDARG
;
1421 *String
= SysAllocString(objectW
);
1422 return *String
? S_OK
: E_OUTOFMEMORY
;
1425 static HRESULT WINAPI
HTMLWindow2_scrollBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1427 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1430 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1432 nsres
= nsIDOMWindow_ScrollBy(This
->outer_window
->nswindow
, x
, y
);
1433 if(NS_FAILED(nsres
))
1434 ERR("ScrollBy failed: %08x\n", nsres
);
1439 static HRESULT WINAPI
HTMLWindow2_scrollTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1441 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1444 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1446 nsres
= nsIDOMWindow_ScrollTo(This
->outer_window
->nswindow
, x
, y
);
1447 if(NS_FAILED(nsres
))
1448 ERR("ScrollTo failed: %08x\n", nsres
);
1453 static HRESULT WINAPI
HTMLWindow2_moveTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1455 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1456 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1460 static HRESULT WINAPI
HTMLWindow2_moveBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1462 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1463 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1467 static HRESULT WINAPI
HTMLWindow2_resizeTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1469 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1470 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1474 static HRESULT WINAPI
HTMLWindow2_resizeBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1476 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1477 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1481 static HRESULT WINAPI
HTMLWindow2_get_external(IHTMLWindow2
*iface
, IDispatch
**p
)
1483 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1485 TRACE("(%p)->(%p)\n", This
, p
);
1489 if(!This
->outer_window
->doc_obj
->hostui
)
1492 return IDocHostUIHandler_GetExternal(This
->outer_window
->doc_obj
->hostui
, p
);
1495 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl
= {
1496 HTMLWindow2_QueryInterface
,
1498 HTMLWindow2_Release
,
1499 HTMLWindow2_GetTypeInfoCount
,
1500 HTMLWindow2_GetTypeInfo
,
1501 HTMLWindow2_GetIDsOfNames
,
1504 HTMLWindow2_get_length
,
1505 HTMLWindow2_get_frames
,
1506 HTMLWindow2_put_defaultStatus
,
1507 HTMLWindow2_get_defaultStatus
,
1508 HTMLWindow2_put_status
,
1509 HTMLWindow2_get_status
,
1510 HTMLWindow2_setTimeout
,
1511 HTMLWindow2_clearTimeout
,
1513 HTMLWindow2_confirm
,
1515 HTMLWindow2_get_Image
,
1516 HTMLWindow2_get_location
,
1517 HTMLWindow2_get_history
,
1519 HTMLWindow2_put_opener
,
1520 HTMLWindow2_get_opener
,
1521 HTMLWindow2_get_navigator
,
1522 HTMLWindow2_put_name
,
1523 HTMLWindow2_get_name
,
1524 HTMLWindow2_get_parent
,
1526 HTMLWindow2_get_self
,
1527 HTMLWindow2_get_top
,
1528 HTMLWindow2_get_window
,
1529 HTMLWindow2_navigate
,
1530 HTMLWindow2_put_onfocus
,
1531 HTMLWindow2_get_onfocus
,
1532 HTMLWindow2_put_onblur
,
1533 HTMLWindow2_get_onblur
,
1534 HTMLWindow2_put_onload
,
1535 HTMLWindow2_get_onload
,
1536 HTMLWindow2_put_onbeforeunload
,
1537 HTMLWindow2_get_onbeforeunload
,
1538 HTMLWindow2_put_onunload
,
1539 HTMLWindow2_get_onunload
,
1540 HTMLWindow2_put_onhelp
,
1541 HTMLWindow2_get_onhelp
,
1542 HTMLWindow2_put_onerror
,
1543 HTMLWindow2_get_onerror
,
1544 HTMLWindow2_put_onresize
,
1545 HTMLWindow2_get_onresize
,
1546 HTMLWindow2_put_onscroll
,
1547 HTMLWindow2_get_onscroll
,
1548 HTMLWindow2_get_document
,
1549 HTMLWindow2_get_event
,
1550 HTMLWindow2_get__newEnum
,
1551 HTMLWindow2_showModalDialog
,
1552 HTMLWindow2_showHelp
,
1553 HTMLWindow2_get_screen
,
1554 HTMLWindow2_get_Option
,
1556 HTMLWindow2_get_closed
,
1559 HTMLWindow2_get_clientInformation
,
1560 HTMLWindow2_setInterval
,
1561 HTMLWindow2_clearInterval
,
1562 HTMLWindow2_put_offscreenBuffering
,
1563 HTMLWindow2_get_offscreenBuffering
,
1564 HTMLWindow2_execScript
,
1565 HTMLWindow2_toString
,
1566 HTMLWindow2_scrollBy
,
1567 HTMLWindow2_scrollTo
,
1570 HTMLWindow2_resizeTo
,
1571 HTMLWindow2_resizeBy
,
1572 HTMLWindow2_get_external
1575 static inline HTMLWindow
*impl_from_IHTMLWindow3(IHTMLWindow3
*iface
)
1577 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow3_iface
);
1580 static HRESULT WINAPI
HTMLWindow3_QueryInterface(IHTMLWindow3
*iface
, REFIID riid
, void **ppv
)
1582 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1584 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1587 static ULONG WINAPI
HTMLWindow3_AddRef(IHTMLWindow3
*iface
)
1589 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1591 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1594 static ULONG WINAPI
HTMLWindow3_Release(IHTMLWindow3
*iface
)
1596 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1598 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1601 static HRESULT WINAPI
HTMLWindow3_GetTypeInfoCount(IHTMLWindow3
*iface
, UINT
*pctinfo
)
1603 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1605 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1608 static HRESULT WINAPI
HTMLWindow3_GetTypeInfo(IHTMLWindow3
*iface
, UINT iTInfo
,
1609 LCID lcid
, ITypeInfo
**ppTInfo
)
1611 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1613 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1616 static HRESULT WINAPI
HTMLWindow3_GetIDsOfNames(IHTMLWindow3
*iface
, REFIID riid
,
1617 LPOLESTR
*rgszNames
, UINT cNames
,
1618 LCID lcid
, DISPID
*rgDispId
)
1620 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1622 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1626 static HRESULT WINAPI
HTMLWindow3_Invoke(IHTMLWindow3
*iface
, DISPID dispIdMember
,
1627 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1628 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1630 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1632 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1633 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1636 static HRESULT WINAPI
HTMLWindow3_get_screenLeft(IHTMLWindow3
*iface
, LONG
*p
)
1638 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1641 TRACE("(%p)->(%p)\n", This
, p
);
1643 nsres
= nsIDOMWindow_GetScreenX(This
->outer_window
->nswindow
, p
);
1644 if(NS_FAILED(nsres
)) {
1645 ERR("GetScreenX failed: %08x\n", nsres
);
1652 static HRESULT WINAPI
HTMLWindow3_get_screenTop(IHTMLWindow3
*iface
, LONG
*p
)
1654 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1657 TRACE("(%p)->(%p)\n", This
, p
);
1659 nsres
= nsIDOMWindow_GetScreenY(This
->outer_window
->nswindow
, p
);
1660 if(NS_FAILED(nsres
)) {
1661 ERR("GetScreenY failed: %08x\n", nsres
);
1668 static HRESULT WINAPI
HTMLWindow3_attachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
, VARIANT_BOOL
*pfResult
)
1670 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1671 HTMLInnerWindow
*window
= This
->inner_window
;
1673 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(event
), pDisp
, pfResult
);
1676 FIXME("No document\n");
1680 return attach_event(&window
->event_target
, event
, pDisp
, pfResult
);
1683 static HRESULT WINAPI
HTMLWindow3_detachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
)
1685 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1686 HTMLInnerWindow
*window
= This
->inner_window
;
1688 TRACE("(%p)->()\n", This
);
1691 FIXME("No document\n");
1695 return detach_event(&window
->event_target
, event
, pDisp
);
1698 static HRESULT
window_set_timer(HTMLInnerWindow
*This
, VARIANT
*expr
, LONG msec
, VARIANT
*language
,
1699 BOOL interval
, LONG
*timer_id
)
1701 IDispatch
*disp
= NULL
;
1704 switch(V_VT(expr
)) {
1706 disp
= V_DISPATCH(expr
);
1707 IDispatch_AddRef(disp
);
1711 disp
= script_parse_event(This
->base
.inner_window
, V_BSTR(expr
));
1715 FIXME("unimplemented expr %s\n", debugstr_variant(expr
));
1722 hres
= set_task_timer(This
, msec
, interval
, disp
, timer_id
);
1723 IDispatch_Release(disp
);
1728 static HRESULT WINAPI
HTMLWindow3_setTimeout(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1729 VARIANT
*language
, LONG
*timerID
)
1731 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1733 TRACE("(%p)->(%s %d %s %p)\n", This
, debugstr_variant(expression
), msec
, debugstr_variant(language
), timerID
);
1735 return window_set_timer(This
->inner_window
, expression
, msec
, language
, FALSE
, timerID
);
1738 static HRESULT WINAPI
HTMLWindow3_setInterval(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1739 VARIANT
*language
, LONG
*timerID
)
1741 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1743 TRACE("(%p)->(%p %d %p %p)\n", This
, expression
, msec
, language
, timerID
);
1745 return window_set_timer(This
->inner_window
, expression
, msec
, language
, TRUE
, timerID
);
1748 static HRESULT WINAPI
HTMLWindow3_print(IHTMLWindow3
*iface
)
1750 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1751 FIXME("(%p)\n", This
);
1755 static HRESULT WINAPI
HTMLWindow3_put_onbeforeprint(IHTMLWindow3
*iface
, VARIANT v
)
1757 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1758 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1762 static HRESULT WINAPI
HTMLWindow3_get_onbeforeprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1764 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1765 FIXME("(%p)->(%p)\n", This
, p
);
1769 static HRESULT WINAPI
HTMLWindow3_put_onafterprint(IHTMLWindow3
*iface
, VARIANT v
)
1771 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1772 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1776 static HRESULT WINAPI
HTMLWindow3_get_onafterprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1778 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1779 FIXME("(%p)->(%p)\n", This
, p
);
1783 static HRESULT WINAPI
HTMLWindow3_get_clipboardData(IHTMLWindow3
*iface
, IHTMLDataTransfer
**p
)
1785 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1786 FIXME("(%p)->(%p)\n", This
, p
);
1790 static HRESULT WINAPI
HTMLWindow3_showModelessDialog(IHTMLWindow3
*iface
, BSTR url
,
1791 VARIANT
*varArgIn
, VARIANT
*options
, IHTMLWindow2
**pDialog
)
1793 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1794 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(url
), varArgIn
, options
, pDialog
);
1798 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl
= {
1799 HTMLWindow3_QueryInterface
,
1801 HTMLWindow3_Release
,
1802 HTMLWindow3_GetTypeInfoCount
,
1803 HTMLWindow3_GetTypeInfo
,
1804 HTMLWindow3_GetIDsOfNames
,
1806 HTMLWindow3_get_screenLeft
,
1807 HTMLWindow3_get_screenTop
,
1808 HTMLWindow3_attachEvent
,
1809 HTMLWindow3_detachEvent
,
1810 HTMLWindow3_setTimeout
,
1811 HTMLWindow3_setInterval
,
1813 HTMLWindow3_put_onbeforeprint
,
1814 HTMLWindow3_get_onbeforeprint
,
1815 HTMLWindow3_put_onafterprint
,
1816 HTMLWindow3_get_onafterprint
,
1817 HTMLWindow3_get_clipboardData
,
1818 HTMLWindow3_showModelessDialog
1821 static inline HTMLWindow
*impl_from_IHTMLWindow4(IHTMLWindow4
*iface
)
1823 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow4_iface
);
1826 static HRESULT WINAPI
HTMLWindow4_QueryInterface(IHTMLWindow4
*iface
, REFIID riid
, void **ppv
)
1828 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1830 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1833 static ULONG WINAPI
HTMLWindow4_AddRef(IHTMLWindow4
*iface
)
1835 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1837 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1840 static ULONG WINAPI
HTMLWindow4_Release(IHTMLWindow4
*iface
)
1842 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1844 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1847 static HRESULT WINAPI
HTMLWindow4_GetTypeInfoCount(IHTMLWindow4
*iface
, UINT
*pctinfo
)
1849 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1851 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1854 static HRESULT WINAPI
HTMLWindow4_GetTypeInfo(IHTMLWindow4
*iface
, UINT iTInfo
,
1855 LCID lcid
, ITypeInfo
**ppTInfo
)
1857 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1859 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1862 static HRESULT WINAPI
HTMLWindow4_GetIDsOfNames(IHTMLWindow4
*iface
, REFIID riid
,
1863 LPOLESTR
*rgszNames
, UINT cNames
,
1864 LCID lcid
, DISPID
*rgDispId
)
1866 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1868 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1872 static HRESULT WINAPI
HTMLWindow4_Invoke(IHTMLWindow4
*iface
, DISPID dispIdMember
,
1873 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1874 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1876 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1878 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1879 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1882 static HRESULT WINAPI
HTMLWindow4_createPopup(IHTMLWindow4
*iface
, VARIANT
*varArgIn
,
1883 IDispatch
**ppPopup
)
1885 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1886 FIXME("(%p)->(%p %p)\n", This
, varArgIn
, ppPopup
);
1890 static HRESULT WINAPI
HTMLWindow4_get_frameElement(IHTMLWindow4
*iface
, IHTMLFrameBase
**p
)
1892 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1893 TRACE("(%p)->(%p)\n", This
, p
);
1895 if(This
->outer_window
->frame_element
) {
1896 *p
= &This
->outer_window
->frame_element
->IHTMLFrameBase_iface
;
1897 IHTMLFrameBase_AddRef(*p
);
1904 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl
= {
1905 HTMLWindow4_QueryInterface
,
1907 HTMLWindow4_Release
,
1908 HTMLWindow4_GetTypeInfoCount
,
1909 HTMLWindow4_GetTypeInfo
,
1910 HTMLWindow4_GetIDsOfNames
,
1912 HTMLWindow4_createPopup
,
1913 HTMLWindow4_get_frameElement
1916 static inline HTMLWindow
*impl_from_IHTMLWindow5(IHTMLWindow5
*iface
)
1918 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow5_iface
);
1921 static HRESULT WINAPI
HTMLWindow5_QueryInterface(IHTMLWindow5
*iface
, REFIID riid
, void **ppv
)
1923 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1925 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1928 static ULONG WINAPI
HTMLWindow5_AddRef(IHTMLWindow5
*iface
)
1930 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1932 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1935 static ULONG WINAPI
HTMLWindow5_Release(IHTMLWindow5
*iface
)
1937 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1939 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1942 static HRESULT WINAPI
HTMLWindow5_GetTypeInfoCount(IHTMLWindow5
*iface
, UINT
*pctinfo
)
1944 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1946 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1949 static HRESULT WINAPI
HTMLWindow5_GetTypeInfo(IHTMLWindow5
*iface
, UINT iTInfo
,
1950 LCID lcid
, ITypeInfo
**ppTInfo
)
1952 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1954 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1957 static HRESULT WINAPI
HTMLWindow5_GetIDsOfNames(IHTMLWindow5
*iface
, REFIID riid
,
1958 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1960 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1962 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1966 static HRESULT WINAPI
HTMLWindow5_Invoke(IHTMLWindow5
*iface
, DISPID dispIdMember
,
1967 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1968 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1970 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1972 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1973 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1976 static HRESULT WINAPI
HTMLWindow5_put_XMLHttpRequest(IHTMLWindow5
*iface
, VARIANT v
)
1978 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1979 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1983 static HRESULT WINAPI
HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5
*iface
, VARIANT
*p
)
1985 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1986 HTMLInnerWindow
*window
= This
->inner_window
;
1988 TRACE("(%p)->(%p)\n", This
, p
);
1990 if(!window
->xhr_factory
) {
1993 hres
= HTMLXMLHttpRequestFactory_Create(window
, &window
->xhr_factory
);
1999 V_VT(p
) = VT_DISPATCH
;
2000 V_DISPATCH(p
) = (IDispatch
*)&window
->xhr_factory
->IHTMLXMLHttpRequestFactory_iface
;
2001 IDispatch_AddRef(V_DISPATCH(p
));
2006 static const IHTMLWindow5Vtbl HTMLWindow5Vtbl
= {
2007 HTMLWindow5_QueryInterface
,
2009 HTMLWindow5_Release
,
2010 HTMLWindow5_GetTypeInfoCount
,
2011 HTMLWindow5_GetTypeInfo
,
2012 HTMLWindow5_GetIDsOfNames
,
2014 HTMLWindow5_put_XMLHttpRequest
,
2015 HTMLWindow5_get_XMLHttpRequest
2018 static inline HTMLWindow
*impl_from_IHTMLWindow6(IHTMLWindow6
*iface
)
2020 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow6_iface
);
2023 static HRESULT WINAPI
HTMLWindow6_QueryInterface(IHTMLWindow6
*iface
, REFIID riid
, void **ppv
)
2025 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2027 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2030 static ULONG WINAPI
HTMLWindow6_AddRef(IHTMLWindow6
*iface
)
2032 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2034 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2037 static ULONG WINAPI
HTMLWindow6_Release(IHTMLWindow6
*iface
)
2039 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2041 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2044 static HRESULT WINAPI
HTMLWindow6_GetTypeInfoCount(IHTMLWindow6
*iface
, UINT
*pctinfo
)
2046 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2048 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
2051 static HRESULT WINAPI
HTMLWindow6_GetTypeInfo(IHTMLWindow6
*iface
, UINT iTInfo
,
2052 LCID lcid
, ITypeInfo
**ppTInfo
)
2054 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2056 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2059 static HRESULT WINAPI
HTMLWindow6_GetIDsOfNames(IHTMLWindow6
*iface
, REFIID riid
,
2060 LPOLESTR
*rgszNames
, UINT cNames
,
2061 LCID lcid
, DISPID
*rgDispId
)
2063 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2065 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
2069 static HRESULT WINAPI
HTMLWindow6_Invoke(IHTMLWindow6
*iface
, DISPID dispIdMember
,
2070 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2071 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2073 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2075 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
2076 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2079 static HRESULT WINAPI
HTMLWindow6_put_XDomainRequest(IHTMLWindow6
*iface
, VARIANT v
)
2081 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2082 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
2086 static HRESULT WINAPI
HTMLWindow6_get_XDomainRequest(IHTMLWindow6
*iface
, VARIANT
*p
)
2088 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2089 FIXME("(%p)->(%p)\n", This
, p
);
2093 static HRESULT WINAPI
HTMLWindow6_get_sessionStorage(IHTMLWindow6
*iface
, IHTMLStorage
**p
)
2095 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2097 FIXME("(%p)->(%p)\n", This
, p
);
2099 if(!This
->inner_window
->session_storage
) {
2102 hres
= create_storage(&This
->inner_window
->session_storage
);
2107 IHTMLStorage_AddRef(This
->inner_window
->session_storage
);
2108 *p
= This
->inner_window
->session_storage
;
2112 static HRESULT WINAPI
HTMLWindow6_get_localStorage(IHTMLWindow6
*iface
, IHTMLStorage
**p
)
2114 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2115 FIXME("(%p)->(%p)\n", This
, p
);
2119 static HRESULT WINAPI
HTMLWindow6_put_onhashchange(IHTMLWindow6
*iface
, VARIANT v
)
2121 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2122 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
2126 static HRESULT WINAPI
HTMLWindow6_get_onhashchange(IHTMLWindow6
*iface
, VARIANT
*p
)
2128 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2129 FIXME("(%p)->(%p)\n", This
, p
);
2133 static HRESULT WINAPI
HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6
*iface
, LONG
*p
)
2135 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2136 FIXME("(%p)->(%p)\n", This
, p
);
2140 static HRESULT WINAPI
HTMLWindow6_postMessage(IHTMLWindow6
*iface
, BSTR msg
, VARIANT targetOrigin
)
2142 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2144 FIXME("(%p)->(%s %s) semi-stub\n", This
, debugstr_w(msg
), debugstr_variant(&targetOrigin
));
2146 if(!This
->inner_window
->doc
) {
2147 FIXME("No document\n");
2151 fire_event(This
->inner_window
->doc
, EVENTID_MESSAGE
, TRUE
, &This
->inner_window
->doc
->node
, NULL
, NULL
);
2155 static HRESULT WINAPI
HTMLWindow6_toStaticHTML(IHTMLWindow6
*iface
, BSTR bstrHTML
, BSTR
*pbstrStaticHTML
)
2157 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2158 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrHTML
), pbstrStaticHTML
);
2162 static HRESULT WINAPI
HTMLWindow6_put_onmessage(IHTMLWindow6
*iface
, VARIANT v
)
2164 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2166 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
2168 return set_window_event(This
, EVENTID_MESSAGE
, &v
);
2171 static HRESULT WINAPI
HTMLWindow6_get_onmessage(IHTMLWindow6
*iface
, VARIANT
*p
)
2173 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2175 TRACE("(%p)->(%p)\n", This
, p
);
2177 return get_window_event(This
, EVENTID_MESSAGE
, p
);
2180 static HRESULT WINAPI
HTMLWindow6_msWriteProfilerMark(IHTMLWindow6
*iface
, BSTR bstrProfilerMark
)
2182 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2183 FIXME("(%p)->(%s)\n", This
, debugstr_w(bstrProfilerMark
));
2187 static const IHTMLWindow6Vtbl HTMLWindow6Vtbl
= {
2188 HTMLWindow6_QueryInterface
,
2190 HTMLWindow6_Release
,
2191 HTMLWindow6_GetTypeInfoCount
,
2192 HTMLWindow6_GetTypeInfo
,
2193 HTMLWindow6_GetIDsOfNames
,
2195 HTMLWindow6_put_XDomainRequest
,
2196 HTMLWindow6_get_XDomainRequest
,
2197 HTMLWindow6_get_sessionStorage
,
2198 HTMLWindow6_get_localStorage
,
2199 HTMLWindow6_put_onhashchange
,
2200 HTMLWindow6_get_onhashchange
,
2201 HTMLWindow6_get_maxConnectionsPerServer
,
2202 HTMLWindow6_postMessage
,
2203 HTMLWindow6_toStaticHTML
,
2204 HTMLWindow6_put_onmessage
,
2205 HTMLWindow6_get_onmessage
,
2206 HTMLWindow6_msWriteProfilerMark
2209 static inline HTMLWindow
*impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow
*iface
)
2211 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLPrivateWindow_iface
);
2214 static HRESULT WINAPI
HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow
*iface
, REFIID riid
, void **ppv
)
2216 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2218 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2221 static ULONG WINAPI
HTMLPrivateWindow_AddRef(IHTMLPrivateWindow
*iface
)
2223 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2225 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2228 static ULONG WINAPI
HTMLPrivateWindow_Release(IHTMLPrivateWindow
*iface
)
2230 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2232 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2235 static HRESULT WINAPI
HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow
*iface
, BSTR url
, BSTR arg2
, BSTR arg3
,
2236 BSTR arg4
, VARIANT
*post_data_var
, VARIANT
*headers_var
, ULONG flags
)
2238 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2239 HTMLOuterWindow
*window
= This
->outer_window
;
2240 OLECHAR
*translated_url
= NULL
;
2241 DWORD post_data_size
= 0;
2242 BYTE
*post_data
= NULL
;
2243 WCHAR
*headers
= NULL
;
2247 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This
, debugstr_w(url
), debugstr_w(arg2
), debugstr_w(arg3
), debugstr_w(arg4
),
2248 debugstr_variant(post_data_var
), debugstr_variant(headers_var
), flags
);
2250 if(window
->doc_obj
->hostui
) {
2251 hres
= IDocHostUIHandler_TranslateUrl(window
->doc_obj
->hostui
, 0, url
, &translated_url
);
2253 translated_url
= NULL
;
2256 hres
= create_uri(translated_url
? translated_url
: url
, 0, &uri
);
2257 CoTaskMemFree(translated_url
);
2262 if(V_VT(post_data_var
) == (VT_ARRAY
|VT_UI1
)) {
2263 SafeArrayAccessData(V_ARRAY(post_data_var
), (void**)&post_data
);
2264 post_data_size
= V_ARRAY(post_data_var
)->rgsabound
[0].cElements
;
2268 if(headers_var
&& V_VT(headers_var
) != VT_EMPTY
&& V_VT(headers_var
) != VT_ERROR
) {
2269 if(V_VT(headers_var
) != VT_BSTR
)
2270 return E_INVALIDARG
;
2272 headers
= V_BSTR(headers_var
);
2275 hres
= super_navigate(window
, uri
, BINDING_NAVIGATED
|BINDING_NOFRAG
, headers
, post_data
, post_data_size
);
2278 SafeArrayUnaccessData(V_ARRAY(post_data_var
));
2283 static HRESULT WINAPI
HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow
*iface
, BSTR
*url
)
2285 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2286 FIXME("(%p)->(%p)\n", This
, url
);
2290 static HRESULT WINAPI
HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow
*iface
, IOleCommandTarget
*cmdtrg
)
2292 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2293 FIXME("(%p)->(%p)\n", This
, cmdtrg
);
2297 static HRESULT WINAPI
HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow
*iface
, int arg
)
2299 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2300 FIXME("(%p)->(%x)\n", This
, arg
);
2304 static HRESULT WINAPI
HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow
*iface
, LPCWSTR name
, IHTMLWindow2
**ret
)
2306 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2307 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(name
), ret
);
2311 static HRESULT WINAPI
HTMLPrivateWindow_GetAddressBarUrl(IHTMLPrivateWindow
*iface
, BSTR
*url
)
2313 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2314 TRACE("(%p)->(%p)\n", This
, url
);
2317 return E_INVALIDARG
;
2319 *url
= SysAllocString(This
->outer_window
->url
);
2323 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl
= {
2324 HTMLPrivateWindow_QueryInterface
,
2325 HTMLPrivateWindow_AddRef
,
2326 HTMLPrivateWindow_Release
,
2327 HTMLPrivateWindow_SuperNavigate
,
2328 HTMLPrivateWindow_GetPendingUrl
,
2329 HTMLPrivateWindow_SetPICSTarget
,
2330 HTMLPrivateWindow_PICSComplete
,
2331 HTMLPrivateWindow_FindWindowByName
,
2332 HTMLPrivateWindow_GetAddressBarUrl
2335 static inline HTMLWindow
*impl_from_ITravelLogClient(ITravelLogClient
*iface
)
2337 return CONTAINING_RECORD(iface
, HTMLWindow
, ITravelLogClient_iface
);
2340 static HRESULT WINAPI
TravelLogClient_QueryInterface(ITravelLogClient
*iface
, REFIID riid
, void **ppv
)
2342 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2344 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2347 static ULONG WINAPI
TravelLogClient_AddRef(ITravelLogClient
*iface
)
2349 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2351 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2354 static ULONG WINAPI
TravelLogClient_Release(ITravelLogClient
*iface
)
2356 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2358 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2361 static HRESULT WINAPI
TravelLogClient_FindWindowByIndex(ITravelLogClient
*iface
, DWORD dwID
, IUnknown
**ppunk
)
2363 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2365 FIXME("(%p)->(%d %p) semi-stub\n", This
, dwID
, ppunk
);
2371 static HRESULT WINAPI
TravelLogClient_GetWindowData(ITravelLogClient
*iface
, IStream
*pStream
, LPWINDOWDATA pWinData
)
2373 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2374 FIXME("(%p)->(%p %p)\n", This
, pStream
, pWinData
);
2378 static HRESULT WINAPI
TravelLogClient_LoadHistoryPosition(ITravelLogClient
*iface
, LPWSTR pszUrlLocation
, DWORD dwPosition
)
2380 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2381 FIXME("(%p)->(%s %d)\n", This
, debugstr_w(pszUrlLocation
), dwPosition
);
2385 static const ITravelLogClientVtbl TravelLogClientVtbl
= {
2386 TravelLogClient_QueryInterface
,
2387 TravelLogClient_AddRef
,
2388 TravelLogClient_Release
,
2389 TravelLogClient_FindWindowByIndex
,
2390 TravelLogClient_GetWindowData
,
2391 TravelLogClient_LoadHistoryPosition
2394 static inline HTMLWindow
*impl_from_IObjectIdentity(IObjectIdentity
*iface
)
2396 return CONTAINING_RECORD(iface
, HTMLWindow
, IObjectIdentity_iface
);
2399 static HRESULT WINAPI
ObjectIdentity_QueryInterface(IObjectIdentity
*iface
, REFIID riid
, void **ppv
)
2401 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2403 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2406 static ULONG WINAPI
ObjectIdentity_AddRef(IObjectIdentity
*iface
)
2408 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2410 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2413 static ULONG WINAPI
ObjectIdentity_Release(IObjectIdentity
*iface
)
2415 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2417 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2420 static HRESULT WINAPI
ObjectIdentity_IsEqualObject(IObjectIdentity
*iface
, IUnknown
*unk
)
2422 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2423 IServiceProvider
*sp
;
2426 TRACE("(%p)->(%p)\n", This
, unk
);
2428 hres
= IUnknown_QueryInterface(unk
, &IID_IServiceProvider
, (void**)&sp
);
2432 hres
= &This
->inner_window
->base
.IServiceProvider_iface
==sp
||
2433 &This
->outer_window
->base
.IServiceProvider_iface
==sp
? S_OK
: S_FALSE
;
2434 IServiceProvider_Release(sp
);
2438 static const IObjectIdentityVtbl ObjectIdentityVtbl
= {
2439 ObjectIdentity_QueryInterface
,
2440 ObjectIdentity_AddRef
,
2441 ObjectIdentity_Release
,
2442 ObjectIdentity_IsEqualObject
2445 static inline HTMLWindow
*impl_from_IDispatchEx(IDispatchEx
*iface
)
2447 return CONTAINING_RECORD(iface
, HTMLWindow
, IDispatchEx_iface
);
2450 static HRESULT WINAPI
WindowDispEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
2452 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2454 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2457 static ULONG WINAPI
WindowDispEx_AddRef(IDispatchEx
*iface
)
2459 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2461 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2464 static ULONG WINAPI
WindowDispEx_Release(IDispatchEx
*iface
)
2466 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2468 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2471 static HRESULT WINAPI
WindowDispEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
2473 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2475 TRACE("(%p)->(%p)\n", This
, pctinfo
);
2477 return IDispatchEx_GetTypeInfoCount(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
2480 static HRESULT WINAPI
WindowDispEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
2481 LCID lcid
, ITypeInfo
**ppTInfo
)
2483 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2485 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
2487 return IDispatchEx_GetTypeInfo(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2490 static HRESULT WINAPI
WindowDispEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
2491 LPOLESTR
*rgszNames
, UINT cNames
,
2492 LCID lcid
, DISPID
*rgDispId
)
2494 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2498 WARN("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
2500 for(i
=0; i
< cNames
; i
++) {
2501 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
2502 hres
= IDispatchEx_GetDispID(&This
->IDispatchEx_iface
, rgszNames
[i
], 0, rgDispId
+i
);
2510 static HRESULT WINAPI
WindowDispEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
2511 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2512 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2514 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2516 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
2517 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2519 /* FIXME: Use script dispatch */
2521 return IDispatchEx_Invoke(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
2522 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2525 static global_prop_t
*alloc_global_prop(HTMLInnerWindow
*This
, global_prop_type_t type
, BSTR name
)
2527 if(This
->global_prop_cnt
== This
->global_prop_size
) {
2528 global_prop_t
*new_props
;
2531 if(This
->global_props
) {
2532 new_size
= This
->global_prop_size
*2;
2533 new_props
= heap_realloc(This
->global_props
, new_size
*sizeof(global_prop_t
));
2536 new_props
= heap_alloc(new_size
*sizeof(global_prop_t
));
2540 This
->global_props
= new_props
;
2541 This
->global_prop_size
= new_size
;
2544 This
->global_props
[This
->global_prop_cnt
].name
= heap_strdupW(name
);
2545 if(!This
->global_props
[This
->global_prop_cnt
].name
)
2548 This
->global_props
[This
->global_prop_cnt
].type
= type
;
2549 return This
->global_props
+ This
->global_prop_cnt
++;
2552 static inline DWORD
prop_to_dispid(HTMLInnerWindow
*This
, global_prop_t
*prop
)
2554 return MSHTML_DISPID_CUSTOM_MIN
+ (prop
-This
->global_props
);
2557 HRESULT
search_window_props(HTMLInnerWindow
*This
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
2560 ScriptHost
*script_host
;
2563 for(i
=0; i
< This
->global_prop_cnt
; i
++) {
2564 /* FIXME: case sensitivity */
2565 if(!strcmpW(This
->global_props
[i
].name
, bstrName
)) {
2566 *pid
= MSHTML_DISPID_CUSTOM_MIN
+i
;
2571 if(find_global_prop(This
->base
.inner_window
, bstrName
, grfdex
, &script_host
, &id
)) {
2572 global_prop_t
*prop
;
2574 prop
= alloc_global_prop(This
, GLOBAL_SCRIPTVAR
, bstrName
);
2576 return E_OUTOFMEMORY
;
2578 prop
->script_host
= script_host
;
2581 *pid
= prop_to_dispid(This
, prop
);
2585 return DISP_E_UNKNOWNNAME
;
2588 static HRESULT WINAPI
WindowDispEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
2590 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2591 HTMLInnerWindow
*window
= This
->inner_window
;
2594 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(bstrName
), grfdex
, pid
);
2596 hres
= search_window_props(window
, bstrName
, grfdex
, pid
);
2597 if(hres
!= DISP_E_UNKNOWNNAME
)
2600 hres
= IDispatchEx_GetDispID(&window
->base
.inner_window
->event_target
.dispex
.IDispatchEx_iface
, bstrName
, grfdex
, pid
);
2601 if(hres
!= DISP_E_UNKNOWNNAME
)
2604 if(This
->outer_window
) {
2605 HTMLOuterWindow
*frame
;
2607 hres
= get_frame_by_name(This
->outer_window
, bstrName
, FALSE
, &frame
);
2608 if(SUCCEEDED(hres
) && frame
) {
2609 global_prop_t
*prop
;
2611 IHTMLWindow2_Release(&frame
->base
.IHTMLWindow2_iface
);
2613 prop
= alloc_global_prop(window
, GLOBAL_FRAMEVAR
, bstrName
);
2615 return E_OUTOFMEMORY
;
2617 *pid
= prop_to_dispid(window
, prop
);
2623 global_prop_t
*prop
;
2626 hres
= IHTMLDocument3_getElementById(&window
->base
.inner_window
->doc
->basedoc
.IHTMLDocument3_iface
,
2628 if(SUCCEEDED(hres
) && elem
) {
2629 IHTMLElement_Release(elem
);
2631 prop
= alloc_global_prop(window
, GLOBAL_ELEMENTVAR
, bstrName
);
2633 return E_OUTOFMEMORY
;
2635 *pid
= prop_to_dispid(window
, prop
);
2640 return DISP_E_UNKNOWNNAME
;
2643 static HRESULT WINAPI
WindowDispEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
2644 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
2646 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2647 HTMLInnerWindow
*window
= This
->inner_window
;
2649 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2652 case DISPID_IHTMLWINDOW2_LOCATION
: {
2653 HTMLLocation
*location
;
2656 if(!(wFlags
& DISPATCH_PROPERTYPUT
))
2659 TRACE("forwarding to location.href\n");
2661 hres
= get_location(window
, &location
);
2665 hres
= IDispatchEx_InvokeEx(&location
->dispex
.IDispatchEx_iface
, DISPID_VALUE
, lcid
,
2666 wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2667 IHTMLLocation_Release(&location
->IHTMLLocation_iface
);
2670 case DISPID_IHTMLWINDOW2_SETTIMEOUT
:
2671 case DISPID_IHTMLWINDOW3_SETTIMEOUT
: {
2673 DISPPARAMS dp
= {args
, NULL
, 2, 0};
2676 * setTimeout calls should use default value 0 for the second argument if only one is provided,
2677 * but IDL file does not reflect that. We fixup arguments here instead.
2679 if(!(wFlags
& DISPATCH_METHOD
) || pdp
->cArgs
!= 1 || pdp
->cNamedArgs
)
2682 TRACE("Fixing args\n");
2686 args
[1] = *pdp
->rgvarg
;
2687 return IDispatchEx_InvokeEx(&window
->event_target
.dispex
.IDispatchEx_iface
, id
, lcid
,
2688 wFlags
, &dp
, pvarRes
, pei
, pspCaller
);
2692 return IDispatchEx_InvokeEx(&window
->event_target
.dispex
.IDispatchEx_iface
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2695 static HRESULT WINAPI
WindowDispEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
2697 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2699 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(bstrName
), grfdex
);
2701 return IDispatchEx_DeleteMemberByName(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, bstrName
, grfdex
);
2704 static HRESULT WINAPI
WindowDispEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
2706 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2708 TRACE("(%p)->(%x)\n", This
, id
);
2710 return IDispatchEx_DeleteMemberByDispID(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, id
);
2713 static HRESULT WINAPI
WindowDispEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
2715 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2717 TRACE("(%p)->(%x %x %p)\n", This
, id
, grfdexFetch
, pgrfdex
);
2719 return IDispatchEx_GetMemberProperties(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, id
, grfdexFetch
,
2723 static HRESULT WINAPI
WindowDispEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
2725 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2727 TRACE("(%p)->(%x %p)\n", This
, id
, pbstrName
);
2729 return IDispatchEx_GetMemberName(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, id
, pbstrName
);
2732 static HRESULT WINAPI
WindowDispEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
2734 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2736 TRACE("(%p)->(%x %x %p)\n", This
, grfdex
, id
, pid
);
2738 return IDispatchEx_GetNextDispID(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, grfdex
, id
, pid
);
2741 static HRESULT WINAPI
WindowDispEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
2743 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2745 TRACE("(%p)->(%p)\n", This
, ppunk
);
2751 static const IDispatchExVtbl WindowDispExVtbl
= {
2752 WindowDispEx_QueryInterface
,
2753 WindowDispEx_AddRef
,
2754 WindowDispEx_Release
,
2755 WindowDispEx_GetTypeInfoCount
,
2756 WindowDispEx_GetTypeInfo
,
2757 WindowDispEx_GetIDsOfNames
,
2758 WindowDispEx_Invoke
,
2759 WindowDispEx_GetDispID
,
2760 WindowDispEx_InvokeEx
,
2761 WindowDispEx_DeleteMemberByName
,
2762 WindowDispEx_DeleteMemberByDispID
,
2763 WindowDispEx_GetMemberProperties
,
2764 WindowDispEx_GetMemberName
,
2765 WindowDispEx_GetNextDispID
,
2766 WindowDispEx_GetNameSpaceParent
2769 static inline HTMLWindow
*impl_from_IServiceProvider(IServiceProvider
*iface
)
2771 return CONTAINING_RECORD(iface
, HTMLWindow
, IServiceProvider_iface
);
2774 static HRESULT WINAPI
HTMLWindowSP_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
2776 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2777 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2780 static ULONG WINAPI
HTMLWindowSP_AddRef(IServiceProvider
*iface
)
2782 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2783 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2786 static ULONG WINAPI
HTMLWindowSP_Release(IServiceProvider
*iface
)
2788 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2789 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2792 static HRESULT WINAPI
HTMLWindowSP_QueryService(IServiceProvider
*iface
, REFGUID guidService
, REFIID riid
, void **ppv
)
2794 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2796 if(IsEqualGUID(guidService
, &IID_IHTMLWindow2
)) {
2797 TRACE("IID_IHTMLWindow2\n");
2798 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2801 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_mshtml_guid(guidService
), debugstr_mshtml_guid(riid
), ppv
);
2803 if(!This
->outer_window
->doc_obj
)
2804 return E_NOINTERFACE
;
2806 return IServiceProvider_QueryService(&This
->outer_window
->doc_obj
->basedoc
.IServiceProvider_iface
,
2807 guidService
, riid
, ppv
);
2810 static const IServiceProviderVtbl ServiceProviderVtbl
= {
2811 HTMLWindowSP_QueryInterface
,
2812 HTMLWindowSP_AddRef
,
2813 HTMLWindowSP_Release
,
2814 HTMLWindowSP_QueryService
2817 static inline HTMLInnerWindow
*impl_from_DispatchEx(DispatchEx
*iface
)
2819 return CONTAINING_RECORD(iface
, HTMLInnerWindow
, event_target
.dispex
);
2822 static HRESULT
HTMLWindow_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2823 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2825 HTMLInnerWindow
*This
= impl_from_DispatchEx(dispex
);
2826 global_prop_t
*prop
;
2830 idx
= id
- MSHTML_DISPID_CUSTOM_MIN
;
2831 if(idx
>= This
->global_prop_cnt
)
2832 return DISP_E_MEMBERNOTFOUND
;
2834 prop
= This
->global_props
+idx
;
2836 switch(prop
->type
) {
2837 case GLOBAL_SCRIPTVAR
: {
2841 disp
= get_script_disp(prop
->script_host
);
2843 return E_UNEXPECTED
;
2845 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&iface
);
2846 if(SUCCEEDED(hres
)) {
2847 TRACE("%s >>>\n", debugstr_w(prop
->name
));
2848 hres
= IDispatchEx_InvokeEx(iface
, prop
->id
, lcid
, flags
, params
, res
, ei
, caller
);
2850 TRACE("%s <<<\n", debugstr_w(prop
->name
));
2852 WARN("%s <<< %08x\n", debugstr_w(prop
->name
), hres
);
2853 IDispatchEx_Release(iface
);
2855 FIXME("No IDispatchEx\n");
2857 IDispatch_Release(disp
);
2860 case GLOBAL_ELEMENTVAR
:
2862 case DISPATCH_PROPERTYGET
|DISPATCH_METHOD
:
2863 case DISPATCH_PROPERTYGET
: {
2866 hres
= IHTMLDocument3_getElementById(&This
->base
.inner_window
->doc
->basedoc
.IHTMLDocument3_iface
,
2872 return DISP_E_MEMBERNOTFOUND
;
2874 V_VT(res
) = VT_DISPATCH
;
2875 V_DISPATCH(res
) = (IDispatch
*)elem
;
2878 case DISPATCH_PROPERTYPUT
: {
2881 hres
= dispex_get_dynid(&This
->event_target
.dispex
, prop
->name
, &dispex_id
);
2885 prop
->type
= GLOBAL_DISPEXVAR
;
2886 prop
->id
= dispex_id
;
2887 return IDispatchEx_InvokeEx(&This
->event_target
.dispex
.IDispatchEx_iface
, dispex_id
, 0, flags
, params
, res
, ei
, caller
);
2890 FIXME("Not supported flags: %x\n", flags
);
2893 case GLOBAL_FRAMEVAR
:
2894 if(!This
->base
.outer_window
)
2895 return E_UNEXPECTED
;
2898 case DISPATCH_PROPERTYGET
: {
2899 HTMLOuterWindow
*frame
;
2901 hres
= get_frame_by_name(This
->base
.outer_window
, prop
->name
, FALSE
, &frame
);
2906 return DISP_E_MEMBERNOTFOUND
;
2908 V_VT(res
) = VT_DISPATCH
;
2909 V_DISPATCH(res
) = (IDispatch
*)&frame
->base
.inner_window
->base
.IHTMLWindow2_iface
;
2910 IDispatch_AddRef(V_DISPATCH(res
));
2914 FIXME("Not supported flags: %x\n", flags
);
2917 case GLOBAL_DISPEXVAR
:
2918 return IDispatchEx_InvokeEx(&This
->event_target
.dispex
.IDispatchEx_iface
, prop
->id
, 0, flags
, params
, res
, ei
, caller
);
2920 ERR("invalid type %d\n", prop
->type
);
2921 hres
= DISP_E_MEMBERNOTFOUND
;
2927 static event_target_t
**HTMLWindow_get_event_target_ptr(DispatchEx
*dispex
)
2929 HTMLInnerWindow
*This
= impl_from_DispatchEx(dispex
);
2930 return &This
->doc
->body_event_target
;
2933 static void HTMLWindow_bind_event(DispatchEx
*dispex
, int eid
)
2935 HTMLInnerWindow
*This
= impl_from_DispatchEx(dispex
);
2936 dispex_get_vtbl(&This
->doc
->node
.event_target
.dispex
)->bind_event(&This
->doc
->node
.event_target
.dispex
, eid
);
2939 static void HTMLWindow_init_dispex_info(dispex_data_t
*info
, compat_mode_t compat_mode
)
2941 dispex_info_add_interface(info
, IHTMLWindow5_tid
);
2944 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl
= {
2949 HTMLWindow_get_event_target_ptr
,
2950 HTMLWindow_bind_event
2953 static const tid_t HTMLWindow_iface_tids
[] = {
2961 static dispex_static_data_t HTMLWindow_dispex
= {
2962 &HTMLWindow_dispex_vtbl
,
2963 DispHTMLWindow2_tid
,
2964 HTMLWindow_iface_tids
,
2965 HTMLWindow_init_dispex_info
2968 static void *alloc_window(size_t size
)
2972 window
= heap_alloc_zero(size
);
2976 window
->IHTMLWindow2_iface
.lpVtbl
= &HTMLWindow2Vtbl
;
2977 window
->IHTMLWindow3_iface
.lpVtbl
= &HTMLWindow3Vtbl
;
2978 window
->IHTMLWindow4_iface
.lpVtbl
= &HTMLWindow4Vtbl
;
2979 window
->IHTMLWindow5_iface
.lpVtbl
= &HTMLWindow5Vtbl
;
2980 window
->IHTMLWindow6_iface
.lpVtbl
= &HTMLWindow6Vtbl
;
2981 window
->IHTMLPrivateWindow_iface
.lpVtbl
= &HTMLPrivateWindowVtbl
;
2982 window
->IDispatchEx_iface
.lpVtbl
= &WindowDispExVtbl
;
2983 window
->IServiceProvider_iface
.lpVtbl
= &ServiceProviderVtbl
;
2984 window
->ITravelLogClient_iface
.lpVtbl
= &TravelLogClientVtbl
;
2985 window
->IObjectIdentity_iface
.lpVtbl
= &ObjectIdentityVtbl
;
2991 static HRESULT
create_inner_window(HTMLOuterWindow
*outer_window
, IMoniker
*mon
, HTMLInnerWindow
**ret
)
2993 HTMLInnerWindow
*window
;
2995 window
= alloc_window(sizeof(HTMLInnerWindow
));
2997 return E_OUTOFMEMORY
;
2999 list_init(&window
->script_hosts
);
3000 list_init(&window
->bindings
);
3001 list_init(&window
->script_queue
);
3003 window
->base
.outer_window
= outer_window
;
3004 window
->base
.inner_window
= window
;
3006 init_dispex(&window
->event_target
.dispex
, (IUnknown
*)&window
->base
.IHTMLWindow2_iface
, &HTMLWindow_dispex
);
3008 window
->task_magic
= get_task_target_magic();
3011 IMoniker_AddRef(mon
);
3019 HRESULT
HTMLOuterWindow_Create(HTMLDocumentObj
*doc_obj
, nsIDOMWindow
*nswindow
,
3020 HTMLOuterWindow
*parent
, HTMLOuterWindow
**ret
)
3022 HTMLOuterWindow
*window
;
3025 window
= alloc_window(sizeof(HTMLOuterWindow
));
3027 return E_OUTOFMEMORY
;
3029 window
->base
.outer_window
= window
;
3030 window
->base
.inner_window
= NULL
;
3032 window
->window_ref
= heap_alloc(sizeof(windowref_t
));
3033 if(!window
->window_ref
) {
3035 return E_OUTOFMEMORY
;
3038 window
->doc_obj
= doc_obj
;
3040 window
->window_ref
->window
= window
;
3041 window
->window_ref
->ref
= 1;
3046 nsIDOMWindow_AddRef(nswindow
);
3047 window
->nswindow
= nswindow
;
3049 nsres
= nsIDOMWindow_QueryInterface(nswindow
, &IID_mozIDOMWindowProxy
, (void**)&window
->window_proxy
);
3050 assert(nsres
== NS_OK
);
3053 window
->scriptmode
= parent
? parent
->scriptmode
: SCRIPTMODE_GECKO
;
3054 window
->readystate
= READYSTATE_UNINITIALIZED
;
3056 hres
= create_pending_window(window
, NULL
);
3058 hres
= update_window_doc(window
->pending_window
);
3060 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
3064 hres
= CoInternetCreateSecurityManager(NULL
, &window
->secmgr
, 0);
3066 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
3070 window
->task_magic
= get_task_target_magic();
3072 list_init(&window
->children
);
3073 list_add_head(&window_list
, &window
->entry
);
3076 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
3078 window
->parent
= parent
;
3079 list_add_tail(&parent
->children
, &window
->sibling_entry
);
3082 TRACE("%p inner_window %p\n", window
, window
->base
.inner_window
);
3088 HRESULT
create_pending_window(HTMLOuterWindow
*outer_window
, nsChannelBSC
*channelbsc
)
3090 HTMLInnerWindow
*pending_window
;
3093 hres
= create_inner_window(outer_window
, outer_window
->mon
/* FIXME */, &pending_window
);
3098 IBindStatusCallback_AddRef(&channelbsc
->bsc
.IBindStatusCallback_iface
);
3099 pending_window
->bscallback
= channelbsc
;
3102 if(outer_window
->pending_window
) {
3103 abort_window_bindings(outer_window
->pending_window
);
3104 outer_window
->pending_window
->base
.outer_window
= NULL
;
3105 IHTMLWindow2_Release(&outer_window
->pending_window
->base
.IHTMLWindow2_iface
);
3108 outer_window
->pending_window
= pending_window
;
3112 HRESULT
update_window_doc(HTMLInnerWindow
*window
)
3114 HTMLOuterWindow
*outer_window
= window
->base
.outer_window
;
3115 nsIDOMHTMLDocument
*nshtmldoc
;
3116 nsIDOMDocument
*nsdoc
;
3120 assert(!window
->doc
);
3123 ERR("NULL outer window\n");
3124 return E_UNEXPECTED
;
3127 nsres
= nsIDOMWindow_GetDocument(outer_window
->nswindow
, &nsdoc
);
3128 if(NS_FAILED(nsres
) || !nsdoc
) {
3129 ERR("GetDocument failed: %08x\n", nsres
);
3133 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMHTMLDocument
, (void**)&nshtmldoc
);
3134 nsIDOMDocument_Release(nsdoc
);
3135 if(NS_FAILED(nsres
)) {
3136 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres
);
3140 hres
= create_doc_from_nsdoc(nshtmldoc
, outer_window
->doc_obj
, window
, &window
->doc
);
3141 nsIDOMHTMLDocument_Release(nshtmldoc
);
3145 if(outer_window
->doc_obj
->usermode
== EDITMODE
) {
3149 static const PRUnichar onW
[] = {'o','n',0};
3151 nsAString_InitDepend(&mode_str
, onW
);
3152 nsres
= nsIDOMHTMLDocument_SetDesignMode(window
->doc
->nsdoc
, &mode_str
);
3153 nsAString_Finish(&mode_str
);
3154 if(NS_FAILED(nsres
))
3155 ERR("SetDesignMode failed: %08x\n", nsres
);
3158 if(window
!= outer_window
->pending_window
) {
3159 ERR("not current pending window\n");
3163 if(outer_window
->base
.inner_window
)
3164 detach_inner_window(outer_window
->base
.inner_window
);
3165 outer_window
->base
.inner_window
= window
;
3166 outer_window
->pending_window
= NULL
;
3168 if(outer_window
->doc_obj
->basedoc
.window
== outer_window
|| !outer_window
->doc_obj
->basedoc
.window
) {
3169 if(outer_window
->doc_obj
->basedoc
.doc_node
)
3170 htmldoc_release(&outer_window
->doc_obj
->basedoc
.doc_node
->basedoc
);
3171 outer_window
->doc_obj
->basedoc
.doc_node
= window
->doc
;
3172 htmldoc_addref(&window
->doc
->basedoc
);
3178 HTMLOuterWindow
*mozwindow_to_window(const mozIDOMWindowProxy
*mozwindow
)
3180 HTMLOuterWindow
*iter
;
3182 LIST_FOR_EACH_ENTRY(iter
, &window_list
, HTMLOuterWindow
, entry
) {
3183 if(iter
->window_proxy
== mozwindow
)