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
->doc
->body_event_target
, window
->inner_window
->doc
, 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
->doc
->body_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
->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
);
221 list_remove(&This
->entry
);
225 static void release_inner_window(HTMLInnerWindow
*This
)
231 detach_inner_window(This
);
234 This
->doc
->window
= NULL
;
235 htmldoc_release(&This
->doc
->basedoc
);
238 release_dispex(&This
->dispex
);
240 for(i
=0; i
< This
->global_prop_cnt
; i
++)
241 heap_free(This
->global_props
[i
].name
);
242 heap_free(This
->global_props
);
245 This
->location
->window
= NULL
;
246 IHTMLLocation_Release(&This
->location
->IHTMLLocation_iface
);
249 if(This
->image_factory
) {
250 This
->image_factory
->window
= NULL
;
251 IHTMLImageElementFactory_Release(&This
->image_factory
->IHTMLImageElementFactory_iface
);
254 if(This
->option_factory
) {
255 This
->option_factory
->window
= NULL
;
256 IHTMLOptionElementFactory_Release(&This
->option_factory
->IHTMLOptionElementFactory_iface
);
260 IHTMLScreen_Release(This
->screen
);
263 This
->history
->window
= NULL
;
264 IOmHistory_Release(&This
->history
->IOmHistory_iface
);
268 IMoniker_Release(This
->mon
);
273 static ULONG WINAPI
HTMLWindow2_Release(IHTMLWindow2
*iface
)
275 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
276 LONG ref
= InterlockedDecrement(&This
->ref
);
278 TRACE("(%p) ref=%d\n", This
, ref
);
281 if(is_outer_window(This
))
282 release_outer_window(This
->outer_window
);
284 release_inner_window(This
->inner_window
);
290 static HRESULT WINAPI
HTMLWindow2_GetTypeInfoCount(IHTMLWindow2
*iface
, UINT
*pctinfo
)
292 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
294 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
297 static HRESULT WINAPI
HTMLWindow2_GetTypeInfo(IHTMLWindow2
*iface
, UINT iTInfo
,
298 LCID lcid
, ITypeInfo
**ppTInfo
)
300 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
302 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
305 static HRESULT WINAPI
HTMLWindow2_GetIDsOfNames(IHTMLWindow2
*iface
, REFIID riid
,
306 LPOLESTR
*rgszNames
, UINT cNames
,
307 LCID lcid
, DISPID
*rgDispId
)
309 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
311 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
315 static HRESULT WINAPI
HTMLWindow2_Invoke(IHTMLWindow2
*iface
, DISPID dispIdMember
,
316 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
317 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
319 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
321 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
322 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
325 static HRESULT
get_frame_by_index(HTMLOuterWindow
*This
, UINT32 index
, HTMLOuterWindow
**ret
)
327 nsIDOMWindowCollection
*nsframes
;
328 nsIDOMWindow
*nswindow
;
332 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nsframes
);
333 if(NS_FAILED(nsres
)) {
334 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres
);
338 nsres
= nsIDOMWindowCollection_GetLength(nsframes
, &length
);
339 assert(nsres
== NS_OK
);
341 if(index
>= length
) {
342 nsIDOMWindowCollection_Release(nsframes
);
343 return DISP_E_MEMBERNOTFOUND
;
346 nsres
= nsIDOMWindowCollection_Item(nsframes
, index
, &nswindow
);
347 nsIDOMWindowCollection_Release(nsframes
);
348 if(NS_FAILED(nsres
)) {
349 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
353 *ret
= nswindow_to_window(nswindow
);
355 nsIDOMWindow_Release(nswindow
);
359 HRESULT
get_frame_by_name(HTMLOuterWindow
*This
, const WCHAR
*name
, BOOL deep
, HTMLOuterWindow
**ret
)
361 nsIDOMWindowCollection
*nsframes
;
362 HTMLOuterWindow
*window
= NULL
;
363 nsIDOMWindow
*nswindow
;
369 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nsframes
);
370 if(NS_FAILED(nsres
)) {
371 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres
);
375 nsAString_InitDepend(&name_str
, name
);
376 nsres
= nsIDOMWindowCollection_NamedItem(nsframes
, &name_str
, &nswindow
);
377 nsAString_Finish(&name_str
);
378 if(NS_FAILED(nsres
)) {
379 nsIDOMWindowCollection_Release(nsframes
);
384 *ret
= nswindow_to_window(nswindow
);
388 nsres
= nsIDOMWindowCollection_GetLength(nsframes
, &length
);
389 assert(nsres
== NS_OK
);
391 for(i
= 0; i
< length
&& !window
; ++i
) {
392 HTMLOuterWindow
*window_iter
;
395 nsres
= nsIDOMWindowCollection_Item(nsframes
, i
, &nswindow
);
396 if(NS_FAILED(nsres
)) {
397 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
402 window_iter
= nswindow_to_window(nswindow
);
404 nsIDOMWindow_Release(nswindow
);
406 hres
= IHTMLElement_get_id(&window_iter
->frame_element
->element
.IHTMLElement_iface
, &id
);
408 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres
);
412 if(id
&& !strcmpiW(id
, name
))
413 window
= window_iter
;
418 get_frame_by_name(window_iter
, name
, TRUE
, &window
);
421 nsIDOMWindowCollection_Release(nsframes
);
429 static HRESULT WINAPI
HTMLWindow2_item(IHTMLWindow2
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
431 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
432 HTMLOuterWindow
*window
= NULL
;
435 TRACE("(%p)->(%p %p)\n", This
, pvarIndex
, pvarResult
);
437 switch(V_VT(pvarIndex
)) {
439 int index
= V_I4(pvarIndex
);
440 TRACE("Getting index %d\n", index
);
442 return DISP_E_MEMBERNOTFOUND
;
443 hres
= get_frame_by_index(This
->outer_window
, index
, &window
);
447 unsigned int index
= V_UINT(pvarIndex
);
448 TRACE("Getting index %u\n", index
);
449 hres
= get_frame_by_index(This
->outer_window
, index
, &window
);
453 BSTR str
= V_BSTR(pvarIndex
);
454 TRACE("Getting name %s\n", wine_dbgstr_w(str
));
455 hres
= get_frame_by_name(This
->outer_window
, str
, FALSE
, &window
);
459 WARN("Invalid index %s\n", debugstr_variant(pvarIndex
));
466 return DISP_E_MEMBERNOTFOUND
;
468 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
469 V_VT(pvarResult
) = VT_DISPATCH
;
470 V_DISPATCH(pvarResult
) = (IDispatch
*)window
;
474 static HRESULT WINAPI
HTMLWindow2_get_length(IHTMLWindow2
*iface
, LONG
*p
)
476 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
477 nsIDOMWindowCollection
*nscollection
;
481 TRACE("(%p)->(%p)\n", This
, p
);
483 nsres
= nsIDOMWindow_GetFrames(This
->outer_window
->nswindow
, &nscollection
);
484 if(NS_FAILED(nsres
)) {
485 ERR("GetFrames failed: %08x\n", nsres
);
489 nsres
= nsIDOMWindowCollection_GetLength(nscollection
, &length
);
490 nsIDOMWindowCollection_Release(nscollection
);
491 if(NS_FAILED(nsres
)) {
492 ERR("GetLength failed: %08x\n", nsres
);
500 static HRESULT WINAPI
HTMLWindow2_get_frames(IHTMLWindow2
*iface
, IHTMLFramesCollection2
**p
)
502 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
503 FIXME("(%p)->(%p): semi-stub\n", This
, p
);
505 /* FIXME: Should return a separate Window object */
506 *p
= (IHTMLFramesCollection2
*)&This
->IHTMLWindow2_iface
;
507 HTMLWindow2_AddRef(iface
);
511 static HRESULT WINAPI
HTMLWindow2_put_defaultStatus(IHTMLWindow2
*iface
, BSTR v
)
513 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
514 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
518 static HRESULT WINAPI
HTMLWindow2_get_defaultStatus(IHTMLWindow2
*iface
, BSTR
*p
)
520 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
521 FIXME("(%p)->(%p)\n", This
, p
);
525 static HRESULT WINAPI
HTMLWindow2_put_status(IHTMLWindow2
*iface
, BSTR v
)
527 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
529 WARN("(%p)->(%s)\n", This
, debugstr_w(v
));
532 * FIXME: Since IE7, setting status is blocked, but still possible in certain circumstances.
533 * Ignoring the call should be enough for us.
538 static HRESULT WINAPI
HTMLWindow2_get_status(IHTMLWindow2
*iface
, BSTR
*p
)
540 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
542 TRACE("(%p)->(%p)\n", This
, p
);
549 static HRESULT WINAPI
HTMLWindow2_setTimeout(IHTMLWindow2
*iface
, BSTR expression
,
550 LONG msec
, VARIANT
*language
, LONG
*timerID
)
552 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
555 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
557 V_VT(&expr_var
) = VT_BSTR
;
558 V_BSTR(&expr_var
) = expression
;
560 return IHTMLWindow3_setTimeout(&This
->IHTMLWindow3_iface
, &expr_var
, msec
, language
, timerID
);
563 static HRESULT WINAPI
HTMLWindow2_clearTimeout(IHTMLWindow2
*iface
, LONG timerID
)
565 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
567 TRACE("(%p)->(%d)\n", This
, timerID
);
569 return clear_task_timer(This
->inner_window
, FALSE
, timerID
);
572 #define MAX_MESSAGE_LEN 2000
574 static HRESULT WINAPI
HTMLWindow2_alert(IHTMLWindow2
*iface
, BSTR message
)
576 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
577 WCHAR title
[100], *msg
= message
;
580 TRACE("(%p)->(%s)\n", This
, debugstr_w(message
));
582 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, title
,
583 sizeof(title
)/sizeof(WCHAR
))) {
584 WARN("Could not load message box title: %d\n", GetLastError());
588 len
= SysStringLen(message
);
589 if(len
> MAX_MESSAGE_LEN
) {
590 msg
= heap_alloc((MAX_MESSAGE_LEN
+1)*sizeof(WCHAR
));
592 return E_OUTOFMEMORY
;
593 memcpy(msg
, message
, MAX_MESSAGE_LEN
*sizeof(WCHAR
));
594 msg
[MAX_MESSAGE_LEN
] = 0;
597 MessageBoxW(This
->outer_window
->doc_obj
->hwnd
, msg
, title
, MB_ICONWARNING
);
603 static HRESULT WINAPI
HTMLWindow2_confirm(IHTMLWindow2
*iface
, BSTR message
,
604 VARIANT_BOOL
*confirmed
)
606 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
609 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(message
), confirmed
);
611 if(!confirmed
) return E_INVALIDARG
;
613 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
614 sizeof(wszTitle
)/sizeof(WCHAR
))) {
615 WARN("Could not load message box title: %d\n", GetLastError());
616 *confirmed
= VARIANT_TRUE
;
620 if(MessageBoxW(This
->outer_window
->doc_obj
->hwnd
, message
, wszTitle
,
621 MB_OKCANCEL
|MB_ICONQUESTION
)==IDOK
)
622 *confirmed
= VARIANT_TRUE
;
623 else *confirmed
= VARIANT_FALSE
;
635 static INT_PTR CALLBACK
prompt_dlgproc(HWND hwnd
, UINT msg
,
636 WPARAM wparam
, LPARAM lparam
)
642 prompt_arg
*arg
= (prompt_arg
*)lparam
;
645 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
646 sizeof(wszTitle
)/sizeof(WCHAR
))) {
647 WARN("Could not load message box title: %d\n", GetLastError());
648 EndDialog(hwnd
, wparam
);
652 SetWindowLongPtrW(hwnd
, DWLP_USER
, lparam
);
653 SetWindowTextW(hwnd
, wszTitle
);
654 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_PROMPT
), arg
->message
);
655 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_EDIT
), arg
->dststr
);
661 case MAKEWPARAM(IDCANCEL
, BN_CLICKED
):
662 EndDialog(hwnd
, wparam
);
664 case MAKEWPARAM(IDOK
, BN_CLICKED
):
667 (prompt_arg
*)GetWindowLongPtrW(hwnd
, DWLP_USER
);
668 HWND hwndPrompt
= GetDlgItem(hwnd
, ID_PROMPT_EDIT
);
669 INT len
= GetWindowTextLengthW(hwndPrompt
);
673 EndDialog(hwnd
, wparam
);
677 V_VT(arg
->textdata
) = VT_BSTR
;
678 if(!len
&& !arg
->dststr
)
679 V_BSTR(arg
->textdata
) = NULL
;
682 V_BSTR(arg
->textdata
) = SysAllocStringLen(NULL
, len
);
683 GetWindowTextW(hwndPrompt
, V_BSTR(arg
->textdata
), len
+1);
685 EndDialog(hwnd
, wparam
);
691 EndDialog(hwnd
, IDCANCEL
);
698 static HRESULT WINAPI
HTMLWindow2_prompt(IHTMLWindow2
*iface
, BSTR message
,
699 BSTR dststr
, VARIANT
*textdata
)
701 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
704 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(message
), debugstr_w(dststr
), textdata
);
706 if(textdata
) V_VT(textdata
) = VT_NULL
;
708 arg
.message
= message
;
710 arg
.textdata
= textdata
;
712 DialogBoxParamW(hInst
, MAKEINTRESOURCEW(ID_PROMPT_DIALOG
),
713 This
->outer_window
->doc_obj
->hwnd
, prompt_dlgproc
, (LPARAM
)&arg
);
717 static HRESULT WINAPI
HTMLWindow2_get_Image(IHTMLWindow2
*iface
, IHTMLImageElementFactory
**p
)
719 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
720 HTMLInnerWindow
*window
= This
->inner_window
;
722 TRACE("(%p)->(%p)\n", This
, p
);
724 if(!window
->image_factory
) {
727 hres
= HTMLImageElementFactory_Create(window
, &window
->image_factory
);
732 *p
= &window
->image_factory
->IHTMLImageElementFactory_iface
;
733 IHTMLImageElementFactory_AddRef(*p
);
738 static HRESULT WINAPI
HTMLWindow2_get_location(IHTMLWindow2
*iface
, IHTMLLocation
**p
)
740 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
741 HTMLLocation
*location
;
744 TRACE("(%p)->(%p)\n", This
, p
);
746 hres
= get_location(This
->inner_window
, &location
);
750 *p
= &location
->IHTMLLocation_iface
;
754 static HRESULT WINAPI
HTMLWindow2_get_history(IHTMLWindow2
*iface
, IOmHistory
**p
)
756 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
757 HTMLInnerWindow
*window
= This
->inner_window
;
759 TRACE("(%p)->(%p)\n", This
, p
);
761 if(!window
->history
) {
764 hres
= create_history(window
, &window
->history
);
769 IOmHistory_AddRef(&window
->history
->IOmHistory_iface
);
770 *p
= &window
->history
->IOmHistory_iface
;
774 static BOOL
notify_webbrowser_close(HTMLOuterWindow
*window
, HTMLDocumentObj
*doc
)
776 IConnectionPointContainer
*cp_container
;
777 VARIANT_BOOL cancel
= VARIANT_FALSE
;
778 IEnumConnections
*enum_conn
;
780 DISPPARAMS dp
= {args
, NULL
, 2, 0};
781 CONNECTDATA conn_data
;
782 IConnectionPoint
*cp
;
790 hres
= IUnknown_QueryInterface(doc
->webbrowser
, &IID_IConnectionPointContainer
, (void**)&cp_container
);
794 hres
= IConnectionPointContainer_FindConnectionPoint(cp_container
, &DIID_DWebBrowserEvents2
, &cp
);
795 IConnectionPointContainer_Release(cp_container
);
799 hres
= IConnectionPoint_EnumConnections(cp
, &enum_conn
);
800 IConnectionPoint_Release(cp
);
805 conn_data
.pUnk
= NULL
;
806 conn_data
.dwCookie
= 0;
808 hres
= IEnumConnections_Next(enum_conn
, 1, &conn_data
, &fetched
);
812 hres
= IUnknown_QueryInterface(conn_data
.pUnk
, &IID_IDispatch
, (void**)&disp
);
813 IUnknown_Release(conn_data
.pUnk
);
817 V_VT(args
) = VT_BYREF
|VT_BOOL
;
818 V_BOOLREF(args
) = &cancel
;
819 V_VT(args
+1) = VT_BOOL
;
820 V_BOOL(args
+1) = window
->parent
? VARIANT_TRUE
: VARIANT_FALSE
;
821 hres
= IDispatch_Invoke(disp
, DISPID_WINDOWCLOSING
, &IID_NULL
, 0, DISPATCH_METHOD
, &dp
, NULL
, NULL
, NULL
);
822 IDispatch_Release(disp
);
824 cancel
= VARIANT_FALSE
;
827 IEnumConnections_Release(enum_conn
);
831 static HRESULT WINAPI
HTMLWindow2_close(IHTMLWindow2
*iface
)
833 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
834 HTMLOuterWindow
*window
= This
->outer_window
;
836 TRACE("(%p)\n", This
);
838 if(!window
->doc_obj
) {
839 FIXME("No document object\n");
843 if(!notify_webbrowser_close(window
, window
->doc_obj
))
846 FIXME("default action not implemented\n");
850 static HRESULT WINAPI
HTMLWindow2_put_opener(IHTMLWindow2
*iface
, VARIANT v
)
852 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
853 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
857 static HRESULT WINAPI
HTMLWindow2_get_opener(IHTMLWindow2
*iface
, VARIANT
*p
)
859 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
861 FIXME("(%p)->(%p) returning empty\n", This
, p
);
867 static HRESULT WINAPI
HTMLWindow2_get_navigator(IHTMLWindow2
*iface
, IOmNavigator
**p
)
869 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
871 TRACE("(%p)->(%p)\n", This
, p
);
873 *p
= OmNavigator_Create();
874 return *p
? S_OK
: E_OUTOFMEMORY
;
877 static HRESULT WINAPI
HTMLWindow2_put_name(IHTMLWindow2
*iface
, BSTR v
)
879 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
883 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
885 nsAString_InitDepend(&name_str
, v
);
886 nsres
= nsIDOMWindow_SetName(This
->outer_window
->nswindow
, &name_str
);
887 nsAString_Finish(&name_str
);
889 ERR("SetName failed: %08x\n", nsres
);
894 static HRESULT WINAPI
HTMLWindow2_get_name(IHTMLWindow2
*iface
, BSTR
*p
)
896 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
900 TRACE("(%p)->(%p)\n", This
, p
);
902 nsAString_Init(&name_str
, NULL
);
903 nsres
= nsIDOMWindow_GetName(This
->outer_window
->nswindow
, &name_str
);
904 return return_nsstr(nsres
, &name_str
, p
);
907 static HRESULT WINAPI
HTMLWindow2_get_parent(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
909 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
910 HTMLOuterWindow
*window
= This
->outer_window
;
912 TRACE("(%p)->(%p)\n", This
, p
);
915 return IHTMLWindow2_get_self(&This
->IHTMLWindow2_iface
, p
);
917 *p
= &window
->parent
->base
.IHTMLWindow2_iface
;
918 IHTMLWindow2_AddRef(*p
);
922 static HRESULT WINAPI
HTMLWindow2_open(IHTMLWindow2
*iface
, BSTR url
, BSTR name
,
923 BSTR features
, VARIANT_BOOL replace
, IHTMLWindow2
**pomWindowResult
)
925 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
926 HTMLOuterWindow
*window
= This
->outer_window
;
927 INewWindowManager
*new_window_mgr
;
932 TRACE("(%p)->(%s %s %s %x %p)\n", This
, debugstr_w(url
), debugstr_w(name
),
933 debugstr_w(features
), replace
, pomWindowResult
);
935 if(!window
->doc_obj
|| !window
->uri_nofrag
)
938 if(name
&& *name
== '_') {
939 FIXME("Unsupported name %s\n", debugstr_w(name
));
943 hres
= do_query_service((IUnknown
*)window
->doc_obj
->client
, &SID_SNewWindowManager
, &IID_INewWindowManager
,
944 (void**)&new_window_mgr
);
946 FIXME("No INewWindowManager\n");
950 hres
= IUri_GetDisplayUri(window
->uri_nofrag
, &uri_str
);
951 if(SUCCEEDED(hres
)) {
952 hres
= INewWindowManager_EvaluateNewWindow(new_window_mgr
, url
, name
, uri_str
,
953 features
, !!replace
, window
->doc_obj
->has_popup
? 0 : NWMF_FIRST
, 0);
954 window
->doc_obj
->has_popup
= TRUE
;
955 SysFreeString(uri_str
);
957 INewWindowManager_Release(new_window_mgr
);
959 *pomWindowResult
= NULL
;
963 hres
= create_relative_uri(window
, url
, &uri
);
967 hres
= navigate_new_window(window
, uri
, name
, pomWindowResult
);
972 static HRESULT WINAPI
HTMLWindow2_get_self(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
974 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
976 TRACE("(%p)->(%p)\n", This
, p
);
978 /* FIXME: We should return kind of proxy window here. */
979 IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
980 *p
= &This
->IHTMLWindow2_iface
;
984 static HRESULT WINAPI
HTMLWindow2_get_top(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
986 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
987 HTMLOuterWindow
*top
;
989 TRACE("(%p)->(%p)\n", This
, p
);
991 get_top_window(This
->outer_window
, &top
);
992 *p
= &top
->base
.IHTMLWindow2_iface
;
993 IHTMLWindow2_AddRef(*p
);
998 static HRESULT WINAPI
HTMLWindow2_get_window(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
1000 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1002 TRACE("(%p)->(%p)\n", This
, p
);
1004 /* FIXME: We should return kind of proxy window here. */
1005 IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1006 *p
= &This
->IHTMLWindow2_iface
;
1010 static HRESULT WINAPI
HTMLWindow2_navigate(IHTMLWindow2
*iface
, BSTR url
)
1012 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1014 TRACE("(%p)->(%s)\n", This
, debugstr_w(url
));
1016 return navigate_url(This
->outer_window
, url
, This
->outer_window
->uri
, BINDING_NAVIGATED
);
1019 static HRESULT WINAPI
HTMLWindow2_put_onfocus(IHTMLWindow2
*iface
, VARIANT v
)
1021 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1023 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1025 return set_window_event(This
, EVENTID_FOCUS
, &v
);
1028 static HRESULT WINAPI
HTMLWindow2_get_onfocus(IHTMLWindow2
*iface
, VARIANT
*p
)
1030 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1032 TRACE("(%p)->(%p)\n", This
, p
);
1034 return get_window_event(This
, EVENTID_FOCUS
, p
);
1037 static HRESULT WINAPI
HTMLWindow2_put_onblur(IHTMLWindow2
*iface
, VARIANT v
)
1039 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1041 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1043 return set_window_event(This
, EVENTID_BLUR
, &v
);
1046 static HRESULT WINAPI
HTMLWindow2_get_onblur(IHTMLWindow2
*iface
, VARIANT
*p
)
1048 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1050 TRACE("(%p)->(%p)\n", This
, p
);
1052 return get_window_event(This
, EVENTID_BLUR
, p
);
1055 static HRESULT WINAPI
HTMLWindow2_put_onload(IHTMLWindow2
*iface
, VARIANT v
)
1057 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1059 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1061 return set_window_event(This
, EVENTID_LOAD
, &v
);
1064 static HRESULT WINAPI
HTMLWindow2_get_onload(IHTMLWindow2
*iface
, VARIANT
*p
)
1066 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1068 TRACE("(%p)->(%p)\n", This
, p
);
1070 return get_window_event(This
, EVENTID_LOAD
, p
);
1073 static HRESULT WINAPI
HTMLWindow2_put_onbeforeunload(IHTMLWindow2
*iface
, VARIANT v
)
1075 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1077 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1079 return set_window_event(This
, EVENTID_BEFOREUNLOAD
, &v
);
1082 static HRESULT WINAPI
HTMLWindow2_get_onbeforeunload(IHTMLWindow2
*iface
, VARIANT
*p
)
1084 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1086 TRACE("(%p)->(%p)\n", This
, p
);
1088 return get_window_event(This
, EVENTID_BEFOREUNLOAD
, p
);
1091 static HRESULT WINAPI
HTMLWindow2_put_onunload(IHTMLWindow2
*iface
, VARIANT v
)
1093 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1094 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1098 static HRESULT WINAPI
HTMLWindow2_get_onunload(IHTMLWindow2
*iface
, VARIANT
*p
)
1100 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1101 FIXME("(%p)->(%p)\n", This
, p
);
1105 static HRESULT WINAPI
HTMLWindow2_put_onhelp(IHTMLWindow2
*iface
, VARIANT v
)
1107 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1109 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1111 return set_window_event(This
, EVENTID_HELP
, &v
);
1114 static HRESULT WINAPI
HTMLWindow2_get_onhelp(IHTMLWindow2
*iface
, VARIANT
*p
)
1116 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1118 TRACE("(%p)->(%p)\n", This
, p
);
1120 return get_window_event(This
, EVENTID_HELP
, p
);
1123 static HRESULT WINAPI
HTMLWindow2_put_onerror(IHTMLWindow2
*iface
, VARIANT v
)
1125 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1127 FIXME("(%p)->(%s) semi-stub\n", This
, debugstr_variant(&v
));
1129 return set_window_event(This
, EVENTID_ERROR
, &v
);
1132 static HRESULT WINAPI
HTMLWindow2_get_onerror(IHTMLWindow2
*iface
, VARIANT
*p
)
1134 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1136 TRACE("(%p)->(%p)\n", This
, p
);
1138 return get_window_event(This
, EVENTID_ERROR
, p
);
1141 static HRESULT WINAPI
HTMLWindow2_put_onresize(IHTMLWindow2
*iface
, VARIANT v
)
1143 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1145 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1147 return set_window_event(This
, EVENTID_RESIZE
, &v
);
1150 static HRESULT WINAPI
HTMLWindow2_get_onresize(IHTMLWindow2
*iface
, VARIANT
*p
)
1152 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1154 TRACE("(%p)->(%p)\n", This
, p
);
1156 return get_window_event(This
, EVENTID_RESIZE
, p
);
1159 static HRESULT WINAPI
HTMLWindow2_put_onscroll(IHTMLWindow2
*iface
, VARIANT v
)
1161 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1163 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1165 return set_window_event(This
, EVENTID_SCROLL
, &v
);
1168 static HRESULT WINAPI
HTMLWindow2_get_onscroll(IHTMLWindow2
*iface
, VARIANT
*p
)
1170 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1172 TRACE("(%p)->(%p)\n", This
, p
);
1174 return get_window_event(This
, EVENTID_SCROLL
, p
);
1177 static HRESULT WINAPI
HTMLWindow2_get_document(IHTMLWindow2
*iface
, IHTMLDocument2
**p
)
1179 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1181 TRACE("(%p)->(%p)\n", This
, p
);
1183 if(This
->inner_window
->doc
) {
1184 /* FIXME: We should return a wrapper object here */
1185 *p
= &This
->inner_window
->doc
->basedoc
.IHTMLDocument2_iface
;
1186 IHTMLDocument2_AddRef(*p
);
1194 static HRESULT WINAPI
HTMLWindow2_get_event(IHTMLWindow2
*iface
, IHTMLEventObj
**p
)
1196 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1197 HTMLInnerWindow
*window
= This
->inner_window
;
1199 TRACE("(%p)->(%p)\n", This
, p
);
1202 IHTMLEventObj_AddRef(window
->event
);
1207 static HRESULT WINAPI
HTMLWindow2_get__newEnum(IHTMLWindow2
*iface
, IUnknown
**p
)
1209 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1210 FIXME("(%p)->(%p)\n", This
, p
);
1214 static HRESULT WINAPI
HTMLWindow2_showModalDialog(IHTMLWindow2
*iface
, BSTR dialog
,
1215 VARIANT
*varArgIn
, VARIANT
*varOptions
, VARIANT
*varArgOut
)
1217 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1218 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(dialog
), varArgIn
, varOptions
, varArgOut
);
1222 static HRESULT WINAPI
HTMLWindow2_showHelp(IHTMLWindow2
*iface
, BSTR helpURL
, VARIANT helpArg
,
1225 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1226 FIXME("(%p)->(%s %s %s)\n", This
, debugstr_w(helpURL
), debugstr_variant(&helpArg
), debugstr_w(features
));
1230 static HRESULT WINAPI
HTMLWindow2_get_screen(IHTMLWindow2
*iface
, IHTMLScreen
**p
)
1232 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1233 HTMLInnerWindow
*window
= This
->inner_window
;
1235 TRACE("(%p)->(%p)\n", This
, p
);
1237 if(!window
->screen
) {
1240 hres
= HTMLScreen_Create(&window
->screen
);
1245 *p
= window
->screen
;
1246 IHTMLScreen_AddRef(window
->screen
);
1250 static HRESULT WINAPI
HTMLWindow2_get_Option(IHTMLWindow2
*iface
, IHTMLOptionElementFactory
**p
)
1252 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1253 HTMLInnerWindow
*window
= This
->inner_window
;
1255 TRACE("(%p)->(%p)\n", This
, p
);
1257 if(!window
->option_factory
) {
1260 hres
= HTMLOptionElementFactory_Create(window
, &window
->option_factory
);
1265 *p
= &window
->option_factory
->IHTMLOptionElementFactory_iface
;
1266 IHTMLOptionElementFactory_AddRef(*p
);
1271 static HRESULT WINAPI
HTMLWindow2_focus(IHTMLWindow2
*iface
)
1273 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1275 TRACE("(%p)->()\n", This
);
1277 if(This
->outer_window
->doc_obj
)
1278 SetFocus(This
->outer_window
->doc_obj
->hwnd
);
1282 static HRESULT WINAPI
HTMLWindow2_get_closed(IHTMLWindow2
*iface
, VARIANT_BOOL
*p
)
1284 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1285 FIXME("(%p)->(%p)\n", This
, p
);
1289 static HRESULT WINAPI
HTMLWindow2_blur(IHTMLWindow2
*iface
)
1291 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1292 FIXME("(%p)->()\n", This
);
1296 static HRESULT WINAPI
HTMLWindow2_scroll(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1298 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1301 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1303 nsres
= nsIDOMWindow_Scroll(This
->outer_window
->nswindow
, x
, y
);
1304 if(NS_FAILED(nsres
)) {
1305 ERR("ScrollBy failed: %08x\n", nsres
);
1312 static HRESULT WINAPI
HTMLWindow2_get_clientInformation(IHTMLWindow2
*iface
, IOmNavigator
**p
)
1314 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1315 FIXME("(%p)->(%p)\n", This
, p
);
1319 static HRESULT WINAPI
HTMLWindow2_setInterval(IHTMLWindow2
*iface
, BSTR expression
,
1320 LONG msec
, VARIANT
*language
, LONG
*timerID
)
1322 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1325 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
1327 V_VT(&expr
) = VT_BSTR
;
1328 V_BSTR(&expr
) = expression
;
1329 return IHTMLWindow3_setInterval(&This
->IHTMLWindow3_iface
, &expr
, msec
, language
, timerID
);
1332 static HRESULT WINAPI
HTMLWindow2_clearInterval(IHTMLWindow2
*iface
, LONG timerID
)
1334 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1336 TRACE("(%p)->(%d)\n", This
, timerID
);
1338 return clear_task_timer(This
->inner_window
, TRUE
, timerID
);
1341 static HRESULT WINAPI
HTMLWindow2_put_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT v
)
1343 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1344 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1348 static HRESULT WINAPI
HTMLWindow2_get_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT
*p
)
1350 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1351 FIXME("(%p)->(%p)\n", This
, p
);
1355 static HRESULT WINAPI
HTMLWindow2_execScript(IHTMLWindow2
*iface
, BSTR scode
, BSTR language
,
1358 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1360 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(scode
), debugstr_w(language
), pvarRet
);
1362 return exec_script(This
->inner_window
, scode
, language
, pvarRet
);
1365 static HRESULT WINAPI
HTMLWindow2_toString(IHTMLWindow2
*iface
, BSTR
*String
)
1367 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1369 static const WCHAR objectW
[] = {'[','o','b','j','e','c','t',']',0};
1371 TRACE("(%p)->(%p)\n", This
, String
);
1374 return E_INVALIDARG
;
1376 *String
= SysAllocString(objectW
);
1377 return *String
? S_OK
: E_OUTOFMEMORY
;
1380 static HRESULT WINAPI
HTMLWindow2_scrollBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1382 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1385 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1387 nsres
= nsIDOMWindow_ScrollBy(This
->outer_window
->nswindow
, x
, y
);
1388 if(NS_FAILED(nsres
))
1389 ERR("ScrollBy failed: %08x\n", nsres
);
1394 static HRESULT WINAPI
HTMLWindow2_scrollTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1396 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1399 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1401 nsres
= nsIDOMWindow_ScrollTo(This
->outer_window
->nswindow
, x
, y
);
1402 if(NS_FAILED(nsres
))
1403 ERR("ScrollTo failed: %08x\n", nsres
);
1408 static HRESULT WINAPI
HTMLWindow2_moveTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1410 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1411 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1415 static HRESULT WINAPI
HTMLWindow2_moveBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1417 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1418 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1422 static HRESULT WINAPI
HTMLWindow2_resizeTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1424 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1425 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1429 static HRESULT WINAPI
HTMLWindow2_resizeBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1431 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1432 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1436 static HRESULT WINAPI
HTMLWindow2_get_external(IHTMLWindow2
*iface
, IDispatch
**p
)
1438 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1440 TRACE("(%p)->(%p)\n", This
, p
);
1444 if(!This
->outer_window
->doc_obj
->hostui
)
1447 return IDocHostUIHandler_GetExternal(This
->outer_window
->doc_obj
->hostui
, p
);
1450 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl
= {
1451 HTMLWindow2_QueryInterface
,
1453 HTMLWindow2_Release
,
1454 HTMLWindow2_GetTypeInfoCount
,
1455 HTMLWindow2_GetTypeInfo
,
1456 HTMLWindow2_GetIDsOfNames
,
1459 HTMLWindow2_get_length
,
1460 HTMLWindow2_get_frames
,
1461 HTMLWindow2_put_defaultStatus
,
1462 HTMLWindow2_get_defaultStatus
,
1463 HTMLWindow2_put_status
,
1464 HTMLWindow2_get_status
,
1465 HTMLWindow2_setTimeout
,
1466 HTMLWindow2_clearTimeout
,
1468 HTMLWindow2_confirm
,
1470 HTMLWindow2_get_Image
,
1471 HTMLWindow2_get_location
,
1472 HTMLWindow2_get_history
,
1474 HTMLWindow2_put_opener
,
1475 HTMLWindow2_get_opener
,
1476 HTMLWindow2_get_navigator
,
1477 HTMLWindow2_put_name
,
1478 HTMLWindow2_get_name
,
1479 HTMLWindow2_get_parent
,
1481 HTMLWindow2_get_self
,
1482 HTMLWindow2_get_top
,
1483 HTMLWindow2_get_window
,
1484 HTMLWindow2_navigate
,
1485 HTMLWindow2_put_onfocus
,
1486 HTMLWindow2_get_onfocus
,
1487 HTMLWindow2_put_onblur
,
1488 HTMLWindow2_get_onblur
,
1489 HTMLWindow2_put_onload
,
1490 HTMLWindow2_get_onload
,
1491 HTMLWindow2_put_onbeforeunload
,
1492 HTMLWindow2_get_onbeforeunload
,
1493 HTMLWindow2_put_onunload
,
1494 HTMLWindow2_get_onunload
,
1495 HTMLWindow2_put_onhelp
,
1496 HTMLWindow2_get_onhelp
,
1497 HTMLWindow2_put_onerror
,
1498 HTMLWindow2_get_onerror
,
1499 HTMLWindow2_put_onresize
,
1500 HTMLWindow2_get_onresize
,
1501 HTMLWindow2_put_onscroll
,
1502 HTMLWindow2_get_onscroll
,
1503 HTMLWindow2_get_document
,
1504 HTMLWindow2_get_event
,
1505 HTMLWindow2_get__newEnum
,
1506 HTMLWindow2_showModalDialog
,
1507 HTMLWindow2_showHelp
,
1508 HTMLWindow2_get_screen
,
1509 HTMLWindow2_get_Option
,
1511 HTMLWindow2_get_closed
,
1514 HTMLWindow2_get_clientInformation
,
1515 HTMLWindow2_setInterval
,
1516 HTMLWindow2_clearInterval
,
1517 HTMLWindow2_put_offscreenBuffering
,
1518 HTMLWindow2_get_offscreenBuffering
,
1519 HTMLWindow2_execScript
,
1520 HTMLWindow2_toString
,
1521 HTMLWindow2_scrollBy
,
1522 HTMLWindow2_scrollTo
,
1525 HTMLWindow2_resizeTo
,
1526 HTMLWindow2_resizeBy
,
1527 HTMLWindow2_get_external
1530 static inline HTMLWindow
*impl_from_IHTMLWindow3(IHTMLWindow3
*iface
)
1532 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow3_iface
);
1535 static HRESULT WINAPI
HTMLWindow3_QueryInterface(IHTMLWindow3
*iface
, REFIID riid
, void **ppv
)
1537 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1539 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1542 static ULONG WINAPI
HTMLWindow3_AddRef(IHTMLWindow3
*iface
)
1544 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1546 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1549 static ULONG WINAPI
HTMLWindow3_Release(IHTMLWindow3
*iface
)
1551 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1553 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1556 static HRESULT WINAPI
HTMLWindow3_GetTypeInfoCount(IHTMLWindow3
*iface
, UINT
*pctinfo
)
1558 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1560 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1563 static HRESULT WINAPI
HTMLWindow3_GetTypeInfo(IHTMLWindow3
*iface
, UINT iTInfo
,
1564 LCID lcid
, ITypeInfo
**ppTInfo
)
1566 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1568 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1571 static HRESULT WINAPI
HTMLWindow3_GetIDsOfNames(IHTMLWindow3
*iface
, REFIID riid
,
1572 LPOLESTR
*rgszNames
, UINT cNames
,
1573 LCID lcid
, DISPID
*rgDispId
)
1575 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1577 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1581 static HRESULT WINAPI
HTMLWindow3_Invoke(IHTMLWindow3
*iface
, DISPID dispIdMember
,
1582 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1583 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1585 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1587 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1588 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1591 static HRESULT WINAPI
HTMLWindow3_get_screenLeft(IHTMLWindow3
*iface
, LONG
*p
)
1593 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1594 FIXME("(%p)->(%p)\n", This
, p
);
1598 static HRESULT WINAPI
HTMLWindow3_get_screenTop(IHTMLWindow3
*iface
, LONG
*p
)
1600 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1601 FIXME("(%p)->(%p)\n", This
, p
);
1605 static HRESULT WINAPI
HTMLWindow3_attachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
, VARIANT_BOOL
*pfResult
)
1607 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1608 HTMLInnerWindow
*window
= This
->inner_window
;
1610 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(event
), pDisp
, pfResult
);
1613 FIXME("No document\n");
1617 return attach_event(&window
->doc
->body_event_target
, &window
->doc
->basedoc
, event
, pDisp
, pfResult
);
1620 static HRESULT WINAPI
HTMLWindow3_detachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
)
1622 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1623 HTMLInnerWindow
*window
= This
->inner_window
;
1625 TRACE("(%p)->()\n", This
);
1628 FIXME("No document\n");
1632 return detach_event(window
->doc
->body_event_target
, &window
->doc
->basedoc
, event
, pDisp
);
1635 static HRESULT
window_set_timer(HTMLInnerWindow
*This
, VARIANT
*expr
, LONG msec
, VARIANT
*language
,
1636 BOOL interval
, LONG
*timer_id
)
1638 IDispatch
*disp
= NULL
;
1641 switch(V_VT(expr
)) {
1643 disp
= V_DISPATCH(expr
);
1644 IDispatch_AddRef(disp
);
1648 disp
= script_parse_event(This
->base
.inner_window
, V_BSTR(expr
));
1652 FIXME("unimplemented expr %s\n", debugstr_variant(expr
));
1659 hres
= set_task_timer(This
, msec
, interval
, disp
, timer_id
);
1660 IDispatch_Release(disp
);
1665 static HRESULT WINAPI
HTMLWindow3_setTimeout(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1666 VARIANT
*language
, LONG
*timerID
)
1668 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1670 TRACE("(%p)->(%s %d %s %p)\n", This
, debugstr_variant(expression
), msec
, debugstr_variant(language
), timerID
);
1672 return window_set_timer(This
->inner_window
, expression
, msec
, language
, FALSE
, timerID
);
1675 static HRESULT WINAPI
HTMLWindow3_setInterval(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1676 VARIANT
*language
, LONG
*timerID
)
1678 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1680 TRACE("(%p)->(%p %d %p %p)\n", This
, expression
, msec
, language
, timerID
);
1682 return window_set_timer(This
->inner_window
, expression
, msec
, language
, TRUE
, timerID
);
1685 static HRESULT WINAPI
HTMLWindow3_print(IHTMLWindow3
*iface
)
1687 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1688 FIXME("(%p)\n", This
);
1692 static HRESULT WINAPI
HTMLWindow3_put_onbeforeprint(IHTMLWindow3
*iface
, VARIANT v
)
1694 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1695 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1699 static HRESULT WINAPI
HTMLWindow3_get_onbeforeprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1701 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1702 FIXME("(%p)->(%p)\n", This
, p
);
1706 static HRESULT WINAPI
HTMLWindow3_put_onafterprint(IHTMLWindow3
*iface
, VARIANT v
)
1708 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1709 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1713 static HRESULT WINAPI
HTMLWindow3_get_onafterprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1715 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1716 FIXME("(%p)->(%p)\n", This
, p
);
1720 static HRESULT WINAPI
HTMLWindow3_get_clipboardData(IHTMLWindow3
*iface
, IHTMLDataTransfer
**p
)
1722 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1723 FIXME("(%p)->(%p)\n", This
, p
);
1727 static HRESULT WINAPI
HTMLWindow3_showModelessDialog(IHTMLWindow3
*iface
, BSTR url
,
1728 VARIANT
*varArgIn
, VARIANT
*options
, IHTMLWindow2
**pDialog
)
1730 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1731 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(url
), varArgIn
, options
, pDialog
);
1735 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl
= {
1736 HTMLWindow3_QueryInterface
,
1738 HTMLWindow3_Release
,
1739 HTMLWindow3_GetTypeInfoCount
,
1740 HTMLWindow3_GetTypeInfo
,
1741 HTMLWindow3_GetIDsOfNames
,
1743 HTMLWindow3_get_screenLeft
,
1744 HTMLWindow3_get_screenTop
,
1745 HTMLWindow3_attachEvent
,
1746 HTMLWindow3_detachEvent
,
1747 HTMLWindow3_setTimeout
,
1748 HTMLWindow3_setInterval
,
1750 HTMLWindow3_put_onbeforeprint
,
1751 HTMLWindow3_get_onbeforeprint
,
1752 HTMLWindow3_put_onafterprint
,
1753 HTMLWindow3_get_onafterprint
,
1754 HTMLWindow3_get_clipboardData
,
1755 HTMLWindow3_showModelessDialog
1758 static inline HTMLWindow
*impl_from_IHTMLWindow4(IHTMLWindow4
*iface
)
1760 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow4_iface
);
1763 static HRESULT WINAPI
HTMLWindow4_QueryInterface(IHTMLWindow4
*iface
, REFIID riid
, void **ppv
)
1765 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1767 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1770 static ULONG WINAPI
HTMLWindow4_AddRef(IHTMLWindow4
*iface
)
1772 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1774 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1777 static ULONG WINAPI
HTMLWindow4_Release(IHTMLWindow4
*iface
)
1779 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1781 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1784 static HRESULT WINAPI
HTMLWindow4_GetTypeInfoCount(IHTMLWindow4
*iface
, UINT
*pctinfo
)
1786 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1788 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1791 static HRESULT WINAPI
HTMLWindow4_GetTypeInfo(IHTMLWindow4
*iface
, UINT iTInfo
,
1792 LCID lcid
, ITypeInfo
**ppTInfo
)
1794 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1796 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1799 static HRESULT WINAPI
HTMLWindow4_GetIDsOfNames(IHTMLWindow4
*iface
, REFIID riid
,
1800 LPOLESTR
*rgszNames
, UINT cNames
,
1801 LCID lcid
, DISPID
*rgDispId
)
1803 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1805 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1809 static HRESULT WINAPI
HTMLWindow4_Invoke(IHTMLWindow4
*iface
, DISPID dispIdMember
,
1810 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1811 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1813 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1815 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1816 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1819 static HRESULT WINAPI
HTMLWindow4_createPopup(IHTMLWindow4
*iface
, VARIANT
*varArgIn
,
1820 IDispatch
**ppPopup
)
1822 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1823 FIXME("(%p)->(%p %p)\n", This
, varArgIn
, ppPopup
);
1827 static HRESULT WINAPI
HTMLWindow4_get_frameElement(IHTMLWindow4
*iface
, IHTMLFrameBase
**p
)
1829 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1830 TRACE("(%p)->(%p)\n", This
, p
);
1832 if(This
->outer_window
->frame_element
) {
1833 *p
= &This
->outer_window
->frame_element
->IHTMLFrameBase_iface
;
1834 IHTMLFrameBase_AddRef(*p
);
1841 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl
= {
1842 HTMLWindow4_QueryInterface
,
1844 HTMLWindow4_Release
,
1845 HTMLWindow4_GetTypeInfoCount
,
1846 HTMLWindow4_GetTypeInfo
,
1847 HTMLWindow4_GetIDsOfNames
,
1849 HTMLWindow4_createPopup
,
1850 HTMLWindow4_get_frameElement
1853 static inline HTMLWindow
*impl_from_IHTMLWindow5(IHTMLWindow5
*iface
)
1855 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow5_iface
);
1858 static HRESULT WINAPI
HTMLWindow5_QueryInterface(IHTMLWindow5
*iface
, REFIID riid
, void **ppv
)
1860 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1862 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1865 static ULONG WINAPI
HTMLWindow5_AddRef(IHTMLWindow5
*iface
)
1867 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1869 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1872 static ULONG WINAPI
HTMLWindow5_Release(IHTMLWindow5
*iface
)
1874 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1876 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1879 static HRESULT WINAPI
HTMLWindow5_GetTypeInfoCount(IHTMLWindow5
*iface
, UINT
*pctinfo
)
1881 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1883 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1886 static HRESULT WINAPI
HTMLWindow5_GetTypeInfo(IHTMLWindow5
*iface
, UINT iTInfo
,
1887 LCID lcid
, ITypeInfo
**ppTInfo
)
1889 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1891 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1894 static HRESULT WINAPI
HTMLWindow5_GetIDsOfNames(IHTMLWindow5
*iface
, REFIID riid
,
1895 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1897 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1899 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1903 static HRESULT WINAPI
HTMLWindow5_Invoke(IHTMLWindow5
*iface
, DISPID dispIdMember
,
1904 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1905 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1907 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1909 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1910 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1913 static HRESULT WINAPI
HTMLWindow5_put_XMLHttpRequest(IHTMLWindow5
*iface
, VARIANT v
)
1915 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1916 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1920 static HRESULT WINAPI
HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5
*iface
, VARIANT
*p
)
1922 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1923 FIXME("(%p)->(%p)\n", This
, p
);
1927 static const IHTMLWindow5Vtbl HTMLWindow5Vtbl
= {
1928 HTMLWindow5_QueryInterface
,
1930 HTMLWindow5_Release
,
1931 HTMLWindow5_GetTypeInfoCount
,
1932 HTMLWindow5_GetTypeInfo
,
1933 HTMLWindow5_GetIDsOfNames
,
1935 HTMLWindow5_put_XMLHttpRequest
,
1936 HTMLWindow5_get_XMLHttpRequest
1939 static inline HTMLWindow
*impl_from_IHTMLWindow6(IHTMLWindow6
*iface
)
1941 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow6_iface
);
1944 static HRESULT WINAPI
HTMLWindow6_QueryInterface(IHTMLWindow6
*iface
, REFIID riid
, void **ppv
)
1946 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
1948 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1951 static ULONG WINAPI
HTMLWindow6_AddRef(IHTMLWindow6
*iface
)
1953 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
1955 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1958 static ULONG WINAPI
HTMLWindow6_Release(IHTMLWindow6
*iface
)
1960 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
1962 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1965 static HRESULT WINAPI
HTMLWindow6_GetTypeInfoCount(IHTMLWindow6
*iface
, UINT
*pctinfo
)
1967 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
1969 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1972 static HRESULT WINAPI
HTMLWindow6_GetTypeInfo(IHTMLWindow6
*iface
, UINT iTInfo
,
1973 LCID lcid
, ITypeInfo
**ppTInfo
)
1975 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
1977 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1980 static HRESULT WINAPI
HTMLWindow6_GetIDsOfNames(IHTMLWindow6
*iface
, REFIID riid
,
1981 LPOLESTR
*rgszNames
, UINT cNames
,
1982 LCID lcid
, DISPID
*rgDispId
)
1984 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
1986 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1990 static HRESULT WINAPI
HTMLWindow6_Invoke(IHTMLWindow6
*iface
, DISPID dispIdMember
,
1991 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1992 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1994 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
1996 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1997 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2000 static HRESULT WINAPI
HTMLWindow6_put_XDomainRequest(IHTMLWindow6
*iface
, VARIANT v
)
2002 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2003 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
2007 static HRESULT WINAPI
HTMLWindow6_get_XDomainRequest(IHTMLWindow6
*iface
, VARIANT
*p
)
2009 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2010 FIXME("(%p)->(%p)\n", This
, p
);
2014 static HRESULT WINAPI
HTMLWindow6_get_sessionStorage(IHTMLWindow6
*iface
, IHTMLStorage
**p
)
2016 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2018 FIXME("(%p)->(%p)\n", This
, p
);
2020 if(!This
->inner_window
->session_storage
) {
2023 hres
= create_storage(&This
->inner_window
->session_storage
);
2028 IHTMLStorage_AddRef(This
->inner_window
->session_storage
);
2029 *p
= This
->inner_window
->session_storage
;
2033 static HRESULT WINAPI
HTMLWindow6_get_localStorage(IHTMLWindow6
*iface
, IHTMLStorage
**p
)
2035 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2036 FIXME("(%p)->(%p)\n", This
, p
);
2040 static HRESULT WINAPI
HTMLWindow6_put_onhashchange(IHTMLWindow6
*iface
, VARIANT v
)
2042 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2043 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
2047 static HRESULT WINAPI
HTMLWindow6_get_onhashchange(IHTMLWindow6
*iface
, VARIANT
*p
)
2049 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2050 FIXME("(%p)->(%p)\n", This
, p
);
2054 static HRESULT WINAPI
HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6
*iface
, LONG
*p
)
2056 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2057 FIXME("(%p)->(%p)\n", This
, p
);
2061 static HRESULT WINAPI
HTMLWindow6_postMessage(IHTMLWindow6
*iface
, BSTR msg
, VARIANT targetOrigin
)
2063 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2064 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(msg
), debugstr_variant(&targetOrigin
));
2068 static HRESULT WINAPI
HTMLWindow6_toStaticHTML(IHTMLWindow6
*iface
, BSTR bstrHTML
, BSTR
*pbstrStaticHTML
)
2070 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2071 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrHTML
), pbstrStaticHTML
);
2075 static HRESULT WINAPI
HTMLWindow6_put_onmessage(IHTMLWindow6
*iface
, VARIANT v
)
2077 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2078 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
2082 static HRESULT WINAPI
HTMLWindow6_get_onmessage(IHTMLWindow6
*iface
, VARIANT
*p
)
2084 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2085 FIXME("(%p)->(%p)\n", This
, p
);
2089 static HRESULT WINAPI
HTMLWindow6_msWriteProfilerMark(IHTMLWindow6
*iface
, BSTR bstrProfilerMark
)
2091 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2092 FIXME("(%p)->(%s)\n", This
, debugstr_w(bstrProfilerMark
));
2096 static const IHTMLWindow6Vtbl HTMLWindow6Vtbl
= {
2097 HTMLWindow6_QueryInterface
,
2099 HTMLWindow6_Release
,
2100 HTMLWindow6_GetTypeInfoCount
,
2101 HTMLWindow6_GetTypeInfo
,
2102 HTMLWindow6_GetIDsOfNames
,
2104 HTMLWindow6_put_XDomainRequest
,
2105 HTMLWindow6_get_XDomainRequest
,
2106 HTMLWindow6_get_sessionStorage
,
2107 HTMLWindow6_get_localStorage
,
2108 HTMLWindow6_put_onhashchange
,
2109 HTMLWindow6_get_onhashchange
,
2110 HTMLWindow6_get_maxConnectionsPerServer
,
2111 HTMLWindow6_postMessage
,
2112 HTMLWindow6_toStaticHTML
,
2113 HTMLWindow6_put_onmessage
,
2114 HTMLWindow6_get_onmessage
,
2115 HTMLWindow6_msWriteProfilerMark
2118 static inline HTMLWindow
*impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow
*iface
)
2120 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLPrivateWindow_iface
);
2123 static HRESULT WINAPI
HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow
*iface
, REFIID riid
, void **ppv
)
2125 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2127 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2130 static ULONG WINAPI
HTMLPrivateWindow_AddRef(IHTMLPrivateWindow
*iface
)
2132 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2134 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2137 static ULONG WINAPI
HTMLPrivateWindow_Release(IHTMLPrivateWindow
*iface
)
2139 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2141 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2144 static HRESULT WINAPI
HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow
*iface
, BSTR url
, BSTR arg2
, BSTR arg3
,
2145 BSTR arg4
, VARIANT
*post_data_var
, VARIANT
*headers_var
, ULONG flags
)
2147 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2148 HTMLOuterWindow
*window
= This
->outer_window
;
2149 OLECHAR
*translated_url
= NULL
;
2150 DWORD post_data_size
= 0;
2151 BYTE
*post_data
= NULL
;
2152 WCHAR
*headers
= NULL
;
2156 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This
, debugstr_w(url
), debugstr_w(arg2
), debugstr_w(arg3
), debugstr_w(arg4
),
2157 debugstr_variant(post_data_var
), debugstr_variant(headers_var
), flags
);
2159 if(window
->doc_obj
->hostui
) {
2160 hres
= IDocHostUIHandler_TranslateUrl(window
->doc_obj
->hostui
, 0, url
, &translated_url
);
2162 translated_url
= NULL
;
2165 hres
= create_uri(translated_url
? translated_url
: url
, 0, &uri
);
2166 CoTaskMemFree(translated_url
);
2171 if(V_VT(post_data_var
) == (VT_ARRAY
|VT_UI1
)) {
2172 SafeArrayAccessData(V_ARRAY(post_data_var
), (void**)&post_data
);
2173 post_data_size
= V_ARRAY(post_data_var
)->rgsabound
[0].cElements
;
2177 if(headers_var
&& V_VT(headers_var
) != VT_EMPTY
&& V_VT(headers_var
) != VT_ERROR
) {
2178 if(V_VT(headers_var
) != VT_BSTR
)
2179 return E_INVALIDARG
;
2181 headers
= V_BSTR(headers_var
);
2184 hres
= super_navigate(window
, uri
, BINDING_NAVIGATED
|BINDING_NOFRAG
, headers
, post_data
, post_data_size
);
2187 SafeArrayUnaccessData(V_ARRAY(post_data_var
));
2192 static HRESULT WINAPI
HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow
*iface
, BSTR
*url
)
2194 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2195 FIXME("(%p)->(%p)\n", This
, url
);
2199 static HRESULT WINAPI
HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow
*iface
, IOleCommandTarget
*cmdtrg
)
2201 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2202 FIXME("(%p)->(%p)\n", This
, cmdtrg
);
2206 static HRESULT WINAPI
HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow
*iface
, int arg
)
2208 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2209 FIXME("(%p)->(%x)\n", This
, arg
);
2213 static HRESULT WINAPI
HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow
*iface
, LPCWSTR name
, IHTMLWindow2
**ret
)
2215 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2216 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(name
), ret
);
2220 static HRESULT WINAPI
HTMLPrivateWindow_GetAddressBarUrl(IHTMLPrivateWindow
*iface
, BSTR
*url
)
2222 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2223 TRACE("(%p)->(%p)\n", This
, url
);
2226 return E_INVALIDARG
;
2228 *url
= SysAllocString(This
->outer_window
->url
);
2232 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl
= {
2233 HTMLPrivateWindow_QueryInterface
,
2234 HTMLPrivateWindow_AddRef
,
2235 HTMLPrivateWindow_Release
,
2236 HTMLPrivateWindow_SuperNavigate
,
2237 HTMLPrivateWindow_GetPendingUrl
,
2238 HTMLPrivateWindow_SetPICSTarget
,
2239 HTMLPrivateWindow_PICSComplete
,
2240 HTMLPrivateWindow_FindWindowByName
,
2241 HTMLPrivateWindow_GetAddressBarUrl
2244 static inline HTMLWindow
*impl_from_ITravelLogClient(ITravelLogClient
*iface
)
2246 return CONTAINING_RECORD(iface
, HTMLWindow
, ITravelLogClient_iface
);
2249 static HRESULT WINAPI
TravelLogClient_QueryInterface(ITravelLogClient
*iface
, REFIID riid
, void **ppv
)
2251 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2253 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2256 static ULONG WINAPI
TravelLogClient_AddRef(ITravelLogClient
*iface
)
2258 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2260 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2263 static ULONG WINAPI
TravelLogClient_Release(ITravelLogClient
*iface
)
2265 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2267 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2270 static HRESULT WINAPI
TravelLogClient_FindWindowByIndex(ITravelLogClient
*iface
, DWORD dwID
, IUnknown
**ppunk
)
2272 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2274 FIXME("(%p)->(%d %p) semi-stub\n", This
, dwID
, ppunk
);
2280 static HRESULT WINAPI
TravelLogClient_GetWindowData(ITravelLogClient
*iface
, IStream
*pStream
, LPWINDOWDATA pWinData
)
2282 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2283 FIXME("(%p)->(%p %p)\n", This
, pStream
, pWinData
);
2287 static HRESULT WINAPI
TravelLogClient_LoadHistoryPosition(ITravelLogClient
*iface
, LPWSTR pszUrlLocation
, DWORD dwPosition
)
2289 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2290 FIXME("(%p)->(%s %d)\n", This
, debugstr_w(pszUrlLocation
), dwPosition
);
2294 static const ITravelLogClientVtbl TravelLogClientVtbl
= {
2295 TravelLogClient_QueryInterface
,
2296 TravelLogClient_AddRef
,
2297 TravelLogClient_Release
,
2298 TravelLogClient_FindWindowByIndex
,
2299 TravelLogClient_GetWindowData
,
2300 TravelLogClient_LoadHistoryPosition
2303 static inline HTMLWindow
*impl_from_IObjectIdentity(IObjectIdentity
*iface
)
2305 return CONTAINING_RECORD(iface
, HTMLWindow
, IObjectIdentity_iface
);
2308 static HRESULT WINAPI
ObjectIdentity_QueryInterface(IObjectIdentity
*iface
, REFIID riid
, void **ppv
)
2310 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2312 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2315 static ULONG WINAPI
ObjectIdentity_AddRef(IObjectIdentity
*iface
)
2317 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2319 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2322 static ULONG WINAPI
ObjectIdentity_Release(IObjectIdentity
*iface
)
2324 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2326 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2329 static HRESULT WINAPI
ObjectIdentity_IsEqualObject(IObjectIdentity
*iface
, IUnknown
*unk
)
2331 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2332 IServiceProvider
*sp
;
2335 TRACE("(%p)->(%p)\n", This
, unk
);
2337 hres
= IUnknown_QueryInterface(unk
, &IID_IServiceProvider
, (void**)&sp
);
2341 hres
= &This
->inner_window
->base
.IServiceProvider_iface
==sp
||
2342 &This
->outer_window
->base
.IServiceProvider_iface
==sp
? S_OK
: S_FALSE
;
2343 IServiceProvider_Release(sp
);
2347 static const IObjectIdentityVtbl ObjectIdentityVtbl
= {
2348 ObjectIdentity_QueryInterface
,
2349 ObjectIdentity_AddRef
,
2350 ObjectIdentity_Release
,
2351 ObjectIdentity_IsEqualObject
2354 static inline HTMLWindow
*impl_from_IDispatchEx(IDispatchEx
*iface
)
2356 return CONTAINING_RECORD(iface
, HTMLWindow
, IDispatchEx_iface
);
2359 static HRESULT WINAPI
WindowDispEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
2361 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2363 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2366 static ULONG WINAPI
WindowDispEx_AddRef(IDispatchEx
*iface
)
2368 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2370 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2373 static ULONG WINAPI
WindowDispEx_Release(IDispatchEx
*iface
)
2375 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2377 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2380 static HRESULT WINAPI
WindowDispEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
2382 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2384 TRACE("(%p)->(%p)\n", This
, pctinfo
);
2386 return IDispatchEx_GetTypeInfoCount(&This
->inner_window
->dispex
.IDispatchEx_iface
, pctinfo
);
2389 static HRESULT WINAPI
WindowDispEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
2390 LCID lcid
, ITypeInfo
**ppTInfo
)
2392 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2394 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
2396 return IDispatchEx_GetTypeInfo(&This
->inner_window
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2399 static HRESULT WINAPI
WindowDispEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
2400 LPOLESTR
*rgszNames
, UINT cNames
,
2401 LCID lcid
, DISPID
*rgDispId
)
2403 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2407 WARN("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
2409 for(i
=0; i
< cNames
; i
++) {
2410 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
2411 hres
= IDispatchEx_GetDispID(&This
->IDispatchEx_iface
, rgszNames
[i
], 0, rgDispId
+i
);
2419 static HRESULT WINAPI
WindowDispEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
2420 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2421 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2423 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2425 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
2426 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2428 /* FIXME: Use script dispatch */
2430 return IDispatchEx_Invoke(&This
->inner_window
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
2431 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2434 static global_prop_t
*alloc_global_prop(HTMLInnerWindow
*This
, global_prop_type_t type
, BSTR name
)
2436 if(This
->global_prop_cnt
== This
->global_prop_size
) {
2437 global_prop_t
*new_props
;
2440 if(This
->global_props
) {
2441 new_size
= This
->global_prop_size
*2;
2442 new_props
= heap_realloc(This
->global_props
, new_size
*sizeof(global_prop_t
));
2445 new_props
= heap_alloc(new_size
*sizeof(global_prop_t
));
2449 This
->global_props
= new_props
;
2450 This
->global_prop_size
= new_size
;
2453 This
->global_props
[This
->global_prop_cnt
].name
= heap_strdupW(name
);
2454 if(!This
->global_props
[This
->global_prop_cnt
].name
)
2457 This
->global_props
[This
->global_prop_cnt
].type
= type
;
2458 return This
->global_props
+ This
->global_prop_cnt
++;
2461 static inline DWORD
prop_to_dispid(HTMLInnerWindow
*This
, global_prop_t
*prop
)
2463 return MSHTML_DISPID_CUSTOM_MIN
+ (prop
-This
->global_props
);
2466 HRESULT
search_window_props(HTMLInnerWindow
*This
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
2469 ScriptHost
*script_host
;
2472 for(i
=0; i
< This
->global_prop_cnt
; i
++) {
2473 /* FIXME: case sensitivity */
2474 if(!strcmpW(This
->global_props
[i
].name
, bstrName
)) {
2475 *pid
= MSHTML_DISPID_CUSTOM_MIN
+i
;
2480 if(find_global_prop(This
->base
.inner_window
, bstrName
, grfdex
, &script_host
, &id
)) {
2481 global_prop_t
*prop
;
2483 prop
= alloc_global_prop(This
, GLOBAL_SCRIPTVAR
, bstrName
);
2485 return E_OUTOFMEMORY
;
2487 prop
->script_host
= script_host
;
2490 *pid
= prop_to_dispid(This
, prop
);
2494 return DISP_E_UNKNOWNNAME
;
2497 static HRESULT WINAPI
WindowDispEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
2499 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2500 HTMLInnerWindow
*window
= This
->inner_window
;
2503 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(bstrName
), grfdex
, pid
);
2505 hres
= search_window_props(window
, bstrName
, grfdex
, pid
);
2506 if(hres
!= DISP_E_UNKNOWNNAME
)
2509 hres
= IDispatchEx_GetDispID(&window
->base
.inner_window
->dispex
.IDispatchEx_iface
, bstrName
, grfdex
, pid
);
2510 if(hres
!= DISP_E_UNKNOWNNAME
)
2513 if(This
->outer_window
) {
2514 HTMLOuterWindow
*frame
;
2516 hres
= get_frame_by_name(This
->outer_window
, bstrName
, FALSE
, &frame
);
2517 if(SUCCEEDED(hres
) && frame
) {
2518 global_prop_t
*prop
;
2520 IHTMLWindow2_Release(&frame
->base
.IHTMLWindow2_iface
);
2522 prop
= alloc_global_prop(window
, GLOBAL_FRAMEVAR
, bstrName
);
2524 return E_OUTOFMEMORY
;
2526 *pid
= prop_to_dispid(window
, prop
);
2532 global_prop_t
*prop
;
2535 hres
= IHTMLDocument3_getElementById(&window
->base
.inner_window
->doc
->basedoc
.IHTMLDocument3_iface
,
2537 if(SUCCEEDED(hres
) && elem
) {
2538 IHTMLElement_Release(elem
);
2540 prop
= alloc_global_prop(window
, GLOBAL_ELEMENTVAR
, bstrName
);
2542 return E_OUTOFMEMORY
;
2544 *pid
= prop_to_dispid(window
, prop
);
2549 return DISP_E_UNKNOWNNAME
;
2552 static HRESULT WINAPI
WindowDispEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
2553 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
2555 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2556 HTMLInnerWindow
*window
= This
->inner_window
;
2558 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2560 if(id
== DISPID_IHTMLWINDOW2_LOCATION
&& (wFlags
& DISPATCH_PROPERTYPUT
)) {
2561 HTMLLocation
*location
;
2564 TRACE("forwarding to location.href\n");
2566 hres
= get_location(window
, &location
);
2570 hres
= IDispatchEx_InvokeEx(&location
->dispex
.IDispatchEx_iface
, DISPID_VALUE
, lcid
,
2571 wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2572 IHTMLLocation_Release(&location
->IHTMLLocation_iface
);
2576 return IDispatchEx_InvokeEx(&window
->dispex
.IDispatchEx_iface
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2579 static HRESULT WINAPI
WindowDispEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
2581 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2583 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(bstrName
), grfdex
);
2585 return IDispatchEx_DeleteMemberByName(&This
->inner_window
->dispex
.IDispatchEx_iface
, bstrName
, grfdex
);
2588 static HRESULT WINAPI
WindowDispEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
2590 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2592 TRACE("(%p)->(%x)\n", This
, id
);
2594 return IDispatchEx_DeleteMemberByDispID(&This
->inner_window
->dispex
.IDispatchEx_iface
, id
);
2597 static HRESULT WINAPI
WindowDispEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
2599 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2601 TRACE("(%p)->(%x %x %p)\n", This
, id
, grfdexFetch
, pgrfdex
);
2603 return IDispatchEx_GetMemberProperties(&This
->inner_window
->dispex
.IDispatchEx_iface
, id
, grfdexFetch
,
2607 static HRESULT WINAPI
WindowDispEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
2609 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2611 TRACE("(%p)->(%x %p)\n", This
, id
, pbstrName
);
2613 return IDispatchEx_GetMemberName(&This
->inner_window
->dispex
.IDispatchEx_iface
, id
, pbstrName
);
2616 static HRESULT WINAPI
WindowDispEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
2618 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2620 TRACE("(%p)->(%x %x %p)\n", This
, grfdex
, id
, pid
);
2622 return IDispatchEx_GetNextDispID(&This
->inner_window
->dispex
.IDispatchEx_iface
, grfdex
, id
, pid
);
2625 static HRESULT WINAPI
WindowDispEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
2627 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2629 TRACE("(%p)->(%p)\n", This
, ppunk
);
2635 static const IDispatchExVtbl WindowDispExVtbl
= {
2636 WindowDispEx_QueryInterface
,
2637 WindowDispEx_AddRef
,
2638 WindowDispEx_Release
,
2639 WindowDispEx_GetTypeInfoCount
,
2640 WindowDispEx_GetTypeInfo
,
2641 WindowDispEx_GetIDsOfNames
,
2642 WindowDispEx_Invoke
,
2643 WindowDispEx_GetDispID
,
2644 WindowDispEx_InvokeEx
,
2645 WindowDispEx_DeleteMemberByName
,
2646 WindowDispEx_DeleteMemberByDispID
,
2647 WindowDispEx_GetMemberProperties
,
2648 WindowDispEx_GetMemberName
,
2649 WindowDispEx_GetNextDispID
,
2650 WindowDispEx_GetNameSpaceParent
2653 static inline HTMLWindow
*impl_from_IServiceProvider(IServiceProvider
*iface
)
2655 return CONTAINING_RECORD(iface
, HTMLWindow
, IServiceProvider_iface
);
2658 static HRESULT WINAPI
HTMLWindowSP_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
2660 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2661 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2664 static ULONG WINAPI
HTMLWindowSP_AddRef(IServiceProvider
*iface
)
2666 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2667 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2670 static ULONG WINAPI
HTMLWindowSP_Release(IServiceProvider
*iface
)
2672 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2673 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2676 static HRESULT WINAPI
HTMLWindowSP_QueryService(IServiceProvider
*iface
, REFGUID guidService
, REFIID riid
, void **ppv
)
2678 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2680 if(IsEqualGUID(guidService
, &IID_IHTMLWindow2
)) {
2681 TRACE("IID_IHTMLWindow2\n");
2682 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2685 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_mshtml_guid(guidService
), debugstr_mshtml_guid(riid
), ppv
);
2687 if(!This
->outer_window
->doc_obj
)
2688 return E_NOINTERFACE
;
2690 return IServiceProvider_QueryService(&This
->outer_window
->doc_obj
->basedoc
.IServiceProvider_iface
,
2691 guidService
, riid
, ppv
);
2694 static const IServiceProviderVtbl ServiceProviderVtbl
= {
2695 HTMLWindowSP_QueryInterface
,
2696 HTMLWindowSP_AddRef
,
2697 HTMLWindowSP_Release
,
2698 HTMLWindowSP_QueryService
2701 static inline HTMLInnerWindow
*impl_from_DispatchEx(DispatchEx
*iface
)
2703 return CONTAINING_RECORD(iface
, HTMLInnerWindow
, dispex
);
2706 static HRESULT
HTMLWindow_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2707 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2709 HTMLInnerWindow
*This
= impl_from_DispatchEx(dispex
);
2710 global_prop_t
*prop
;
2714 idx
= id
- MSHTML_DISPID_CUSTOM_MIN
;
2715 if(idx
>= This
->global_prop_cnt
)
2716 return DISP_E_MEMBERNOTFOUND
;
2718 prop
= This
->global_props
+idx
;
2720 switch(prop
->type
) {
2721 case GLOBAL_SCRIPTVAR
: {
2725 disp
= get_script_disp(prop
->script_host
);
2727 return E_UNEXPECTED
;
2729 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&iface
);
2730 if(SUCCEEDED(hres
)) {
2731 TRACE("%s >>>\n", debugstr_w(prop
->name
));
2732 hres
= IDispatchEx_InvokeEx(iface
, prop
->id
, lcid
, flags
, params
, res
, ei
, caller
);
2734 TRACE("%s <<<\n", debugstr_w(prop
->name
));
2736 WARN("%s <<< %08x\n", debugstr_w(prop
->name
), hres
);
2737 IDispatchEx_Release(iface
);
2739 FIXME("No IDispatchEx\n");
2741 IDispatch_Release(disp
);
2744 case GLOBAL_ELEMENTVAR
:
2746 case DISPATCH_PROPERTYGET
|DISPATCH_METHOD
:
2747 case DISPATCH_PROPERTYGET
: {
2750 hres
= IHTMLDocument3_getElementById(&This
->base
.inner_window
->doc
->basedoc
.IHTMLDocument3_iface
,
2756 return DISP_E_MEMBERNOTFOUND
;
2758 V_VT(res
) = VT_DISPATCH
;
2759 V_DISPATCH(res
) = (IDispatch
*)elem
;
2762 case DISPATCH_PROPERTYPUT
: {
2765 hres
= dispex_get_dynid(&This
->dispex
, prop
->name
, &dispex_id
);
2769 prop
->type
= GLOBAL_DISPEXVAR
;
2770 prop
->id
= dispex_id
;
2771 return IDispatchEx_InvokeEx(&This
->dispex
.IDispatchEx_iface
, dispex_id
, 0, flags
, params
, res
, ei
, caller
);
2774 FIXME("Not supported flags: %x\n", flags
);
2777 case GLOBAL_FRAMEVAR
:
2778 if(!This
->base
.outer_window
)
2779 return E_UNEXPECTED
;
2782 case DISPATCH_PROPERTYGET
: {
2783 HTMLOuterWindow
*frame
;
2785 hres
= get_frame_by_name(This
->base
.outer_window
, prop
->name
, FALSE
, &frame
);
2790 return DISP_E_MEMBERNOTFOUND
;
2792 V_VT(res
) = VT_DISPATCH
;
2793 V_DISPATCH(res
) = (IDispatch
*)&frame
->base
.inner_window
->base
.IHTMLWindow2_iface
;
2794 IDispatch_AddRef(V_DISPATCH(res
));
2798 FIXME("Not supported flags: %x\n", flags
);
2801 case GLOBAL_DISPEXVAR
:
2802 return IDispatchEx_InvokeEx(&This
->dispex
.IDispatchEx_iface
, prop
->id
, 0, flags
, params
, res
, ei
, caller
);
2804 ERR("invalid type %d\n", prop
->type
);
2805 hres
= DISP_E_MEMBERNOTFOUND
;
2812 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl
= {
2819 static const tid_t HTMLWindow_iface_tids
[] = {
2827 static dispex_static_data_t HTMLWindow_dispex
= {
2828 &HTMLWindow_dispex_vtbl
,
2829 DispHTMLWindow2_tid
,
2831 HTMLWindow_iface_tids
2834 static void *alloc_window(size_t size
)
2838 window
= heap_alloc_zero(size
);
2842 window
->IHTMLWindow2_iface
.lpVtbl
= &HTMLWindow2Vtbl
;
2843 window
->IHTMLWindow3_iface
.lpVtbl
= &HTMLWindow3Vtbl
;
2844 window
->IHTMLWindow4_iface
.lpVtbl
= &HTMLWindow4Vtbl
;
2845 window
->IHTMLWindow5_iface
.lpVtbl
= &HTMLWindow5Vtbl
;
2846 window
->IHTMLWindow6_iface
.lpVtbl
= &HTMLWindow6Vtbl
;
2847 window
->IHTMLPrivateWindow_iface
.lpVtbl
= &HTMLPrivateWindowVtbl
;
2848 window
->IDispatchEx_iface
.lpVtbl
= &WindowDispExVtbl
;
2849 window
->IServiceProvider_iface
.lpVtbl
= &ServiceProviderVtbl
;
2850 window
->ITravelLogClient_iface
.lpVtbl
= &TravelLogClientVtbl
;
2851 window
->IObjectIdentity_iface
.lpVtbl
= &ObjectIdentityVtbl
;
2857 static HRESULT
create_inner_window(HTMLOuterWindow
*outer_window
, IMoniker
*mon
, HTMLInnerWindow
**ret
)
2859 HTMLInnerWindow
*window
;
2861 window
= alloc_window(sizeof(HTMLInnerWindow
));
2863 return E_OUTOFMEMORY
;
2865 list_init(&window
->script_hosts
);
2866 list_init(&window
->bindings
);
2867 list_init(&window
->script_queue
);
2869 window
->base
.outer_window
= outer_window
;
2870 window
->base
.inner_window
= window
;
2872 init_dispex(&window
->dispex
, (IUnknown
*)&window
->base
.IHTMLWindow2_iface
, &HTMLWindow_dispex
);
2874 window
->task_magic
= get_task_target_magic();
2877 IMoniker_AddRef(mon
);
2885 HRESULT
HTMLOuterWindow_Create(HTMLDocumentObj
*doc_obj
, nsIDOMWindow
*nswindow
,
2886 HTMLOuterWindow
*parent
, HTMLOuterWindow
**ret
)
2888 HTMLOuterWindow
*window
;
2891 window
= alloc_window(sizeof(HTMLOuterWindow
));
2893 return E_OUTOFMEMORY
;
2895 window
->base
.outer_window
= window
;
2896 window
->base
.inner_window
= NULL
;
2898 window
->window_ref
= heap_alloc(sizeof(windowref_t
));
2899 if(!window
->window_ref
) {
2901 return E_OUTOFMEMORY
;
2904 window
->doc_obj
= doc_obj
;
2906 window
->window_ref
->window
= window
;
2907 window
->window_ref
->ref
= 1;
2910 nsIDOMWindow_AddRef(nswindow
);
2911 window
->nswindow
= nswindow
;
2914 window
->scriptmode
= parent
? parent
->scriptmode
: SCRIPTMODE_GECKO
;
2915 window
->readystate
= READYSTATE_UNINITIALIZED
;
2917 hres
= create_pending_window(window
, NULL
);
2919 hres
= update_window_doc(window
->pending_window
);
2921 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
2925 hres
= CoInternetCreateSecurityManager(NULL
, &window
->secmgr
, 0);
2927 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
2931 window
->task_magic
= get_task_target_magic();
2933 list_init(&window
->children
);
2934 list_add_head(&window_list
, &window
->entry
);
2937 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
2939 window
->parent
= parent
;
2940 list_add_tail(&parent
->children
, &window
->sibling_entry
);
2943 TRACE("%p inner_window %p\n", window
, window
->base
.inner_window
);
2949 HRESULT
create_pending_window(HTMLOuterWindow
*outer_window
, nsChannelBSC
*channelbsc
)
2951 HTMLInnerWindow
*pending_window
;
2954 hres
= create_inner_window(outer_window
, outer_window
->mon
/* FIXME */, &pending_window
);
2959 IBindStatusCallback_AddRef(&channelbsc
->bsc
.IBindStatusCallback_iface
);
2960 pending_window
->bscallback
= channelbsc
;
2963 if(outer_window
->pending_window
) {
2964 abort_window_bindings(outer_window
->pending_window
);
2965 outer_window
->pending_window
->base
.outer_window
= NULL
;
2966 IHTMLWindow2_Release(&outer_window
->pending_window
->base
.IHTMLWindow2_iface
);
2969 outer_window
->pending_window
= pending_window
;
2973 HRESULT
update_window_doc(HTMLInnerWindow
*window
)
2975 HTMLOuterWindow
*outer_window
= window
->base
.outer_window
;
2976 nsIDOMHTMLDocument
*nshtmldoc
;
2977 nsIDOMDocument
*nsdoc
;
2981 assert(!window
->doc
);
2984 ERR("NULL outer window\n");
2985 return E_UNEXPECTED
;
2988 nsres
= nsIDOMWindow_GetDocument(outer_window
->nswindow
, &nsdoc
);
2989 if(NS_FAILED(nsres
) || !nsdoc
) {
2990 ERR("GetDocument failed: %08x\n", nsres
);
2994 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMHTMLDocument
, (void**)&nshtmldoc
);
2995 nsIDOMDocument_Release(nsdoc
);
2996 if(NS_FAILED(nsres
)) {
2997 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres
);
3001 hres
= create_doc_from_nsdoc(nshtmldoc
, outer_window
->doc_obj
, window
, &window
->doc
);
3002 nsIDOMHTMLDocument_Release(nshtmldoc
);
3006 if(outer_window
->doc_obj
->usermode
== EDITMODE
) {
3010 static const PRUnichar onW
[] = {'o','n',0};
3012 nsAString_InitDepend(&mode_str
, onW
);
3013 nsres
= nsIDOMHTMLDocument_SetDesignMode(window
->doc
->nsdoc
, &mode_str
);
3014 nsAString_Finish(&mode_str
);
3015 if(NS_FAILED(nsres
))
3016 ERR("SetDesignMode failed: %08x\n", nsres
);
3019 if(window
!= outer_window
->pending_window
) {
3020 ERR("not current pending window\n");
3024 if(outer_window
->base
.inner_window
)
3025 detach_inner_window(outer_window
->base
.inner_window
);
3026 outer_window
->base
.inner_window
= window
;
3027 outer_window
->pending_window
= NULL
;
3029 if(outer_window
->doc_obj
->basedoc
.window
== outer_window
|| !outer_window
->doc_obj
->basedoc
.window
) {
3030 if(outer_window
->doc_obj
->basedoc
.doc_node
)
3031 htmldoc_release(&outer_window
->doc_obj
->basedoc
.doc_node
->basedoc
);
3032 outer_window
->doc_obj
->basedoc
.doc_node
= window
->doc
;
3033 htmldoc_addref(&window
->doc
->basedoc
);
3039 HTMLOuterWindow
*nswindow_to_window(const nsIDOMWindow
*nswindow
)
3041 HTMLOuterWindow
*iter
;
3043 LIST_FOR_EACH_ENTRY(iter
, &window_list
, HTMLOuterWindow
, entry
) {
3044 if(iter
->nswindow
== nswindow
)