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
);
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
->event_target
.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
);
267 if(This
->session_storage
)
268 IHTMLStorage_Release(This
->session_storage
);
271 IMoniker_Release(This
->mon
);
276 static ULONG WINAPI
HTMLWindow2_Release(IHTMLWindow2
*iface
)
278 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
279 LONG ref
= InterlockedDecrement(&This
->ref
);
281 TRACE("(%p) ref=%d\n", This
, ref
);
284 if(is_outer_window(This
))
285 release_outer_window(This
->outer_window
);
287 release_inner_window(This
->inner_window
);
293 static HRESULT WINAPI
HTMLWindow2_GetTypeInfoCount(IHTMLWindow2
*iface
, UINT
*pctinfo
)
295 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
297 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
300 static HRESULT WINAPI
HTMLWindow2_GetTypeInfo(IHTMLWindow2
*iface
, UINT iTInfo
,
301 LCID lcid
, ITypeInfo
**ppTInfo
)
303 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
305 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
308 static HRESULT WINAPI
HTMLWindow2_GetIDsOfNames(IHTMLWindow2
*iface
, REFIID riid
,
309 LPOLESTR
*rgszNames
, UINT cNames
,
310 LCID lcid
, DISPID
*rgDispId
)
312 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
314 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
318 static HRESULT WINAPI
HTMLWindow2_Invoke(IHTMLWindow2
*iface
, DISPID dispIdMember
,
319 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
320 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
322 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
324 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
325 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
328 static HRESULT
get_frame_by_index(HTMLOuterWindow
*This
, UINT32 index
, HTMLOuterWindow
**ret
)
330 nsIDOMWindowCollection
*nsframes
;
331 nsIDOMWindow
*nswindow
;
335 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nsframes
);
336 if(NS_FAILED(nsres
)) {
337 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres
);
341 nsres
= nsIDOMWindowCollection_GetLength(nsframes
, &length
);
342 assert(nsres
== NS_OK
);
344 if(index
>= length
) {
345 nsIDOMWindowCollection_Release(nsframes
);
346 return DISP_E_MEMBERNOTFOUND
;
349 nsres
= nsIDOMWindowCollection_Item(nsframes
, index
, &nswindow
);
350 nsIDOMWindowCollection_Release(nsframes
);
351 if(NS_FAILED(nsres
)) {
352 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
356 *ret
= nswindow_to_window(nswindow
);
358 nsIDOMWindow_Release(nswindow
);
362 HRESULT
get_frame_by_name(HTMLOuterWindow
*This
, const WCHAR
*name
, BOOL deep
, HTMLOuterWindow
**ret
)
364 nsIDOMWindowCollection
*nsframes
;
365 HTMLOuterWindow
*window
= NULL
;
366 nsIDOMWindow
*nswindow
;
372 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nsframes
);
373 if(NS_FAILED(nsres
)) {
374 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres
);
378 nsAString_InitDepend(&name_str
, name
);
379 nsres
= nsIDOMWindowCollection_NamedItem(nsframes
, &name_str
, &nswindow
);
380 nsAString_Finish(&name_str
);
381 if(NS_FAILED(nsres
)) {
382 nsIDOMWindowCollection_Release(nsframes
);
387 *ret
= nswindow_to_window(nswindow
);
391 nsres
= nsIDOMWindowCollection_GetLength(nsframes
, &length
);
392 assert(nsres
== NS_OK
);
394 for(i
= 0; i
< length
&& !window
; ++i
) {
395 HTMLOuterWindow
*window_iter
;
398 nsres
= nsIDOMWindowCollection_Item(nsframes
, i
, &nswindow
);
399 if(NS_FAILED(nsres
)) {
400 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
405 window_iter
= nswindow_to_window(nswindow
);
407 nsIDOMWindow_Release(nswindow
);
410 WARN("nsIDOMWindow without HTMLOuterWindow: %p\n", nswindow
);
414 hres
= IHTMLElement_get_id(&window_iter
->frame_element
->element
.IHTMLElement_iface
, &id
);
416 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres
);
420 if(id
&& !strcmpiW(id
, name
))
421 window
= window_iter
;
426 get_frame_by_name(window_iter
, name
, TRUE
, &window
);
429 nsIDOMWindowCollection_Release(nsframes
);
437 static HRESULT WINAPI
HTMLWindow2_item(IHTMLWindow2
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
439 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
440 HTMLOuterWindow
*window
= NULL
;
443 TRACE("(%p)->(%p %p)\n", This
, pvarIndex
, pvarResult
);
445 switch(V_VT(pvarIndex
)) {
447 int index
= V_I4(pvarIndex
);
448 TRACE("Getting index %d\n", index
);
450 return DISP_E_MEMBERNOTFOUND
;
451 hres
= get_frame_by_index(This
->outer_window
, index
, &window
);
455 unsigned int index
= V_UINT(pvarIndex
);
456 TRACE("Getting index %u\n", index
);
457 hres
= get_frame_by_index(This
->outer_window
, index
, &window
);
461 BSTR str
= V_BSTR(pvarIndex
);
462 TRACE("Getting name %s\n", wine_dbgstr_w(str
));
463 hres
= get_frame_by_name(This
->outer_window
, str
, FALSE
, &window
);
467 WARN("Invalid index %s\n", debugstr_variant(pvarIndex
));
474 return DISP_E_MEMBERNOTFOUND
;
476 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
477 V_VT(pvarResult
) = VT_DISPATCH
;
478 V_DISPATCH(pvarResult
) = (IDispatch
*)window
;
482 static HRESULT WINAPI
HTMLWindow2_get_length(IHTMLWindow2
*iface
, LONG
*p
)
484 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
485 nsIDOMWindowCollection
*nscollection
;
489 TRACE("(%p)->(%p)\n", This
, p
);
491 nsres
= nsIDOMWindow_GetFrames(This
->outer_window
->nswindow
, &nscollection
);
492 if(NS_FAILED(nsres
)) {
493 ERR("GetFrames failed: %08x\n", nsres
);
497 nsres
= nsIDOMWindowCollection_GetLength(nscollection
, &length
);
498 nsIDOMWindowCollection_Release(nscollection
);
499 if(NS_FAILED(nsres
)) {
500 ERR("GetLength failed: %08x\n", nsres
);
508 static HRESULT WINAPI
HTMLWindow2_get_frames(IHTMLWindow2
*iface
, IHTMLFramesCollection2
**p
)
510 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
511 FIXME("(%p)->(%p): semi-stub\n", This
, p
);
513 /* FIXME: Should return a separate Window object */
514 *p
= (IHTMLFramesCollection2
*)&This
->IHTMLWindow2_iface
;
515 HTMLWindow2_AddRef(iface
);
519 static HRESULT WINAPI
HTMLWindow2_put_defaultStatus(IHTMLWindow2
*iface
, BSTR v
)
521 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
522 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
526 static HRESULT WINAPI
HTMLWindow2_get_defaultStatus(IHTMLWindow2
*iface
, BSTR
*p
)
528 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
529 FIXME("(%p)->(%p)\n", This
, p
);
533 static HRESULT WINAPI
HTMLWindow2_put_status(IHTMLWindow2
*iface
, BSTR v
)
535 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
537 WARN("(%p)->(%s)\n", This
, debugstr_w(v
));
540 * FIXME: Since IE7, setting status is blocked, but still possible in certain circumstances.
541 * Ignoring the call should be enough for us.
546 static HRESULT WINAPI
HTMLWindow2_get_status(IHTMLWindow2
*iface
, BSTR
*p
)
548 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
550 TRACE("(%p)->(%p)\n", This
, p
);
557 static HRESULT WINAPI
HTMLWindow2_setTimeout(IHTMLWindow2
*iface
, BSTR expression
,
558 LONG msec
, VARIANT
*language
, LONG
*timerID
)
560 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
563 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
565 V_VT(&expr_var
) = VT_BSTR
;
566 V_BSTR(&expr_var
) = expression
;
568 return IHTMLWindow3_setTimeout(&This
->IHTMLWindow3_iface
, &expr_var
, msec
, language
, timerID
);
571 static HRESULT WINAPI
HTMLWindow2_clearTimeout(IHTMLWindow2
*iface
, LONG timerID
)
573 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
575 TRACE("(%p)->(%d)\n", This
, timerID
);
577 return clear_task_timer(This
->inner_window
, FALSE
, timerID
);
580 #define MAX_MESSAGE_LEN 2000
582 static HRESULT WINAPI
HTMLWindow2_alert(IHTMLWindow2
*iface
, BSTR message
)
584 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
585 WCHAR title
[100], *msg
= message
;
588 TRACE("(%p)->(%s)\n", This
, debugstr_w(message
));
590 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, title
,
591 sizeof(title
)/sizeof(WCHAR
))) {
592 WARN("Could not load message box title: %d\n", GetLastError());
596 len
= SysStringLen(message
);
597 if(len
> MAX_MESSAGE_LEN
) {
598 msg
= heap_alloc((MAX_MESSAGE_LEN
+1)*sizeof(WCHAR
));
600 return E_OUTOFMEMORY
;
601 memcpy(msg
, message
, MAX_MESSAGE_LEN
*sizeof(WCHAR
));
602 msg
[MAX_MESSAGE_LEN
] = 0;
605 MessageBoxW(This
->outer_window
->doc_obj
->hwnd
, msg
, title
, MB_ICONWARNING
);
611 static HRESULT WINAPI
HTMLWindow2_confirm(IHTMLWindow2
*iface
, BSTR message
,
612 VARIANT_BOOL
*confirmed
)
614 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
617 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(message
), confirmed
);
619 if(!confirmed
) return E_INVALIDARG
;
621 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
622 sizeof(wszTitle
)/sizeof(WCHAR
))) {
623 WARN("Could not load message box title: %d\n", GetLastError());
624 *confirmed
= VARIANT_TRUE
;
628 if(MessageBoxW(This
->outer_window
->doc_obj
->hwnd
, message
, wszTitle
,
629 MB_OKCANCEL
|MB_ICONQUESTION
)==IDOK
)
630 *confirmed
= VARIANT_TRUE
;
631 else *confirmed
= VARIANT_FALSE
;
643 static INT_PTR CALLBACK
prompt_dlgproc(HWND hwnd
, UINT msg
,
644 WPARAM wparam
, LPARAM lparam
)
650 prompt_arg
*arg
= (prompt_arg
*)lparam
;
653 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
654 sizeof(wszTitle
)/sizeof(WCHAR
))) {
655 WARN("Could not load message box title: %d\n", GetLastError());
656 EndDialog(hwnd
, wparam
);
660 SetWindowLongPtrW(hwnd
, DWLP_USER
, lparam
);
661 SetWindowTextW(hwnd
, wszTitle
);
662 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_PROMPT
), arg
->message
);
663 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_EDIT
), arg
->dststr
);
669 case MAKEWPARAM(IDCANCEL
, BN_CLICKED
):
670 EndDialog(hwnd
, wparam
);
672 case MAKEWPARAM(IDOK
, BN_CLICKED
):
675 (prompt_arg
*)GetWindowLongPtrW(hwnd
, DWLP_USER
);
676 HWND hwndPrompt
= GetDlgItem(hwnd
, ID_PROMPT_EDIT
);
677 INT len
= GetWindowTextLengthW(hwndPrompt
);
681 EndDialog(hwnd
, wparam
);
685 V_VT(arg
->textdata
) = VT_BSTR
;
686 if(!len
&& !arg
->dststr
)
687 V_BSTR(arg
->textdata
) = NULL
;
690 V_BSTR(arg
->textdata
) = SysAllocStringLen(NULL
, len
);
691 GetWindowTextW(hwndPrompt
, V_BSTR(arg
->textdata
), len
+1);
693 EndDialog(hwnd
, wparam
);
699 EndDialog(hwnd
, IDCANCEL
);
706 static HRESULT WINAPI
HTMLWindow2_prompt(IHTMLWindow2
*iface
, BSTR message
,
707 BSTR dststr
, VARIANT
*textdata
)
709 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
712 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(message
), debugstr_w(dststr
), textdata
);
714 if(textdata
) V_VT(textdata
) = VT_NULL
;
716 arg
.message
= message
;
718 arg
.textdata
= textdata
;
720 DialogBoxParamW(hInst
, MAKEINTRESOURCEW(ID_PROMPT_DIALOG
),
721 This
->outer_window
->doc_obj
->hwnd
, prompt_dlgproc
, (LPARAM
)&arg
);
725 static HRESULT WINAPI
HTMLWindow2_get_Image(IHTMLWindow2
*iface
, IHTMLImageElementFactory
**p
)
727 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
728 HTMLInnerWindow
*window
= This
->inner_window
;
730 TRACE("(%p)->(%p)\n", This
, p
);
732 if(!window
->image_factory
) {
735 hres
= HTMLImageElementFactory_Create(window
, &window
->image_factory
);
740 *p
= &window
->image_factory
->IHTMLImageElementFactory_iface
;
741 IHTMLImageElementFactory_AddRef(*p
);
746 static HRESULT WINAPI
HTMLWindow2_get_location(IHTMLWindow2
*iface
, IHTMLLocation
**p
)
748 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
749 HTMLLocation
*location
;
752 TRACE("(%p)->(%p)\n", This
, p
);
754 hres
= get_location(This
->inner_window
, &location
);
758 *p
= &location
->IHTMLLocation_iface
;
762 static HRESULT WINAPI
HTMLWindow2_get_history(IHTMLWindow2
*iface
, IOmHistory
**p
)
764 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
765 HTMLInnerWindow
*window
= This
->inner_window
;
767 TRACE("(%p)->(%p)\n", This
, p
);
769 if(!window
->history
) {
772 hres
= create_history(window
, &window
->history
);
777 IOmHistory_AddRef(&window
->history
->IOmHistory_iface
);
778 *p
= &window
->history
->IOmHistory_iface
;
782 static BOOL
notify_webbrowser_close(HTMLOuterWindow
*window
, HTMLDocumentObj
*doc
)
784 IConnectionPointContainer
*cp_container
;
785 VARIANT_BOOL cancel
= VARIANT_FALSE
;
786 IEnumConnections
*enum_conn
;
788 DISPPARAMS dp
= {args
, NULL
, 2, 0};
789 CONNECTDATA conn_data
;
790 IConnectionPoint
*cp
;
798 hres
= IUnknown_QueryInterface(doc
->webbrowser
, &IID_IConnectionPointContainer
, (void**)&cp_container
);
802 hres
= IConnectionPointContainer_FindConnectionPoint(cp_container
, &DIID_DWebBrowserEvents2
, &cp
);
803 IConnectionPointContainer_Release(cp_container
);
807 hres
= IConnectionPoint_EnumConnections(cp
, &enum_conn
);
808 IConnectionPoint_Release(cp
);
813 conn_data
.pUnk
= NULL
;
814 conn_data
.dwCookie
= 0;
816 hres
= IEnumConnections_Next(enum_conn
, 1, &conn_data
, &fetched
);
820 hres
= IUnknown_QueryInterface(conn_data
.pUnk
, &IID_IDispatch
, (void**)&disp
);
821 IUnknown_Release(conn_data
.pUnk
);
825 V_VT(args
) = VT_BYREF
|VT_BOOL
;
826 V_BOOLREF(args
) = &cancel
;
827 V_VT(args
+1) = VT_BOOL
;
828 V_BOOL(args
+1) = window
->parent
? VARIANT_TRUE
: VARIANT_FALSE
;
829 hres
= IDispatch_Invoke(disp
, DISPID_WINDOWCLOSING
, &IID_NULL
, 0, DISPATCH_METHOD
, &dp
, NULL
, NULL
, NULL
);
830 IDispatch_Release(disp
);
832 cancel
= VARIANT_FALSE
;
835 IEnumConnections_Release(enum_conn
);
839 static HRESULT WINAPI
HTMLWindow2_close(IHTMLWindow2
*iface
)
841 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
842 HTMLOuterWindow
*window
= This
->outer_window
;
844 TRACE("(%p)\n", This
);
846 if(!window
->doc_obj
) {
847 FIXME("No document object\n");
851 if(!notify_webbrowser_close(window
, window
->doc_obj
))
854 FIXME("default action not implemented\n");
858 static HRESULT WINAPI
HTMLWindow2_put_opener(IHTMLWindow2
*iface
, VARIANT v
)
860 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
861 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
865 static HRESULT WINAPI
HTMLWindow2_get_opener(IHTMLWindow2
*iface
, VARIANT
*p
)
867 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
869 FIXME("(%p)->(%p) returning empty\n", This
, p
);
875 static HRESULT WINAPI
HTMLWindow2_get_navigator(IHTMLWindow2
*iface
, IOmNavigator
**p
)
877 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
879 TRACE("(%p)->(%p)\n", This
, p
);
881 *p
= OmNavigator_Create();
882 return *p
? S_OK
: E_OUTOFMEMORY
;
885 static HRESULT WINAPI
HTMLWindow2_put_name(IHTMLWindow2
*iface
, BSTR v
)
887 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
891 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
893 nsAString_InitDepend(&name_str
, v
);
894 nsres
= nsIDOMWindow_SetName(This
->outer_window
->nswindow
, &name_str
);
895 nsAString_Finish(&name_str
);
897 ERR("SetName failed: %08x\n", nsres
);
902 static HRESULT WINAPI
HTMLWindow2_get_name(IHTMLWindow2
*iface
, BSTR
*p
)
904 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
908 TRACE("(%p)->(%p)\n", This
, p
);
910 nsAString_Init(&name_str
, NULL
);
911 nsres
= nsIDOMWindow_GetName(This
->outer_window
->nswindow
, &name_str
);
912 return return_nsstr(nsres
, &name_str
, p
);
915 static HRESULT WINAPI
HTMLWindow2_get_parent(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
917 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
918 HTMLOuterWindow
*window
= This
->outer_window
;
920 TRACE("(%p)->(%p)\n", This
, p
);
923 return IHTMLWindow2_get_self(&This
->IHTMLWindow2_iface
, p
);
925 *p
= &window
->parent
->base
.IHTMLWindow2_iface
;
926 IHTMLWindow2_AddRef(*p
);
930 static HRESULT WINAPI
HTMLWindow2_open(IHTMLWindow2
*iface
, BSTR url
, BSTR name
,
931 BSTR features
, VARIANT_BOOL replace
, IHTMLWindow2
**pomWindowResult
)
933 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
934 HTMLOuterWindow
*window
= This
->outer_window
;
935 INewWindowManager
*new_window_mgr
;
940 static const WCHAR _selfW
[] = {'_','s','e','l','f',0};
942 TRACE("(%p)->(%s %s %s %x %p)\n", This
, debugstr_w(url
), debugstr_w(name
),
943 debugstr_w(features
), replace
, pomWindowResult
);
945 if(!window
->doc_obj
|| !window
->uri_nofrag
)
948 if(name
&& *name
== '_') {
949 if(!strcmpW(name
, _selfW
)) {
950 if((features
&& *features
) || replace
)
951 FIXME("Unsupported arguments for _self target\n");
953 hres
= IHTMLWindow2_navigate(&This
->IHTMLWindow2_iface
, url
);
957 if(pomWindowResult
) {
958 FIXME("Returning this window for _self target\n");
959 *pomWindowResult
= &This
->IHTMLWindow2_iface
;
960 IHTMLWindow2_AddRef(*pomWindowResult
);
966 FIXME("Unsupported name %s\n", debugstr_w(name
));
970 hres
= do_query_service((IUnknown
*)window
->doc_obj
->client
, &SID_SNewWindowManager
, &IID_INewWindowManager
,
971 (void**)&new_window_mgr
);
973 FIXME("No INewWindowManager\n");
977 hres
= IUri_GetDisplayUri(window
->uri_nofrag
, &uri_str
);
978 if(SUCCEEDED(hres
)) {
979 hres
= INewWindowManager_EvaluateNewWindow(new_window_mgr
, url
, name
, uri_str
,
980 features
, !!replace
, window
->doc_obj
->has_popup
? 0 : NWMF_FIRST
, 0);
981 window
->doc_obj
->has_popup
= TRUE
;
982 SysFreeString(uri_str
);
984 INewWindowManager_Release(new_window_mgr
);
986 *pomWindowResult
= NULL
;
990 hres
= create_relative_uri(window
, url
, &uri
);
994 hres
= navigate_new_window(window
, uri
, name
, NULL
, pomWindowResult
);
999 static HRESULT WINAPI
HTMLWindow2_get_self(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
1001 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1003 TRACE("(%p)->(%p)\n", This
, p
);
1005 /* FIXME: We should return kind of proxy window here. */
1006 IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1007 *p
= &This
->IHTMLWindow2_iface
;
1011 static HRESULT WINAPI
HTMLWindow2_get_top(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
1013 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1014 HTMLOuterWindow
*top
;
1016 TRACE("(%p)->(%p)\n", This
, p
);
1018 get_top_window(This
->outer_window
, &top
);
1019 *p
= &top
->base
.IHTMLWindow2_iface
;
1020 IHTMLWindow2_AddRef(*p
);
1025 static HRESULT WINAPI
HTMLWindow2_get_window(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
1027 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1029 TRACE("(%p)->(%p)\n", This
, p
);
1031 /* FIXME: We should return kind of proxy window here. */
1032 IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1033 *p
= &This
->IHTMLWindow2_iface
;
1037 static HRESULT WINAPI
HTMLWindow2_navigate(IHTMLWindow2
*iface
, BSTR url
)
1039 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1041 TRACE("(%p)->(%s)\n", This
, debugstr_w(url
));
1043 return navigate_url(This
->outer_window
, url
, This
->outer_window
->uri
, BINDING_NAVIGATED
);
1046 static HRESULT WINAPI
HTMLWindow2_put_onfocus(IHTMLWindow2
*iface
, VARIANT v
)
1048 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1050 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1052 return set_window_event(This
, EVENTID_FOCUS
, &v
);
1055 static HRESULT WINAPI
HTMLWindow2_get_onfocus(IHTMLWindow2
*iface
, VARIANT
*p
)
1057 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1059 TRACE("(%p)->(%p)\n", This
, p
);
1061 return get_window_event(This
, EVENTID_FOCUS
, p
);
1064 static HRESULT WINAPI
HTMLWindow2_put_onblur(IHTMLWindow2
*iface
, VARIANT v
)
1066 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1068 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1070 return set_window_event(This
, EVENTID_BLUR
, &v
);
1073 static HRESULT WINAPI
HTMLWindow2_get_onblur(IHTMLWindow2
*iface
, VARIANT
*p
)
1075 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1077 TRACE("(%p)->(%p)\n", This
, p
);
1079 return get_window_event(This
, EVENTID_BLUR
, p
);
1082 static HRESULT WINAPI
HTMLWindow2_put_onload(IHTMLWindow2
*iface
, VARIANT v
)
1084 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1086 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1088 return set_window_event(This
, EVENTID_LOAD
, &v
);
1091 static HRESULT WINAPI
HTMLWindow2_get_onload(IHTMLWindow2
*iface
, VARIANT
*p
)
1093 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1095 TRACE("(%p)->(%p)\n", This
, p
);
1097 return get_window_event(This
, EVENTID_LOAD
, p
);
1100 static HRESULT WINAPI
HTMLWindow2_put_onbeforeunload(IHTMLWindow2
*iface
, VARIANT v
)
1102 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1104 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1106 return set_window_event(This
, EVENTID_BEFOREUNLOAD
, &v
);
1109 static HRESULT WINAPI
HTMLWindow2_get_onbeforeunload(IHTMLWindow2
*iface
, VARIANT
*p
)
1111 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1113 TRACE("(%p)->(%p)\n", This
, p
);
1115 return get_window_event(This
, EVENTID_BEFOREUNLOAD
, p
);
1118 static HRESULT WINAPI
HTMLWindow2_put_onunload(IHTMLWindow2
*iface
, VARIANT v
)
1120 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1121 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1125 static HRESULT WINAPI
HTMLWindow2_get_onunload(IHTMLWindow2
*iface
, VARIANT
*p
)
1127 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1128 FIXME("(%p)->(%p)\n", This
, p
);
1132 static HRESULT WINAPI
HTMLWindow2_put_onhelp(IHTMLWindow2
*iface
, VARIANT v
)
1134 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1136 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1138 return set_window_event(This
, EVENTID_HELP
, &v
);
1141 static HRESULT WINAPI
HTMLWindow2_get_onhelp(IHTMLWindow2
*iface
, VARIANT
*p
)
1143 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1145 TRACE("(%p)->(%p)\n", This
, p
);
1147 return get_window_event(This
, EVENTID_HELP
, p
);
1150 static HRESULT WINAPI
HTMLWindow2_put_onerror(IHTMLWindow2
*iface
, VARIANT v
)
1152 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1154 FIXME("(%p)->(%s) semi-stub\n", This
, debugstr_variant(&v
));
1156 return set_window_event(This
, EVENTID_ERROR
, &v
);
1159 static HRESULT WINAPI
HTMLWindow2_get_onerror(IHTMLWindow2
*iface
, VARIANT
*p
)
1161 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1163 TRACE("(%p)->(%p)\n", This
, p
);
1165 return get_window_event(This
, EVENTID_ERROR
, p
);
1168 static HRESULT WINAPI
HTMLWindow2_put_onresize(IHTMLWindow2
*iface
, VARIANT v
)
1170 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1172 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1174 return set_window_event(This
, EVENTID_RESIZE
, &v
);
1177 static HRESULT WINAPI
HTMLWindow2_get_onresize(IHTMLWindow2
*iface
, VARIANT
*p
)
1179 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1181 TRACE("(%p)->(%p)\n", This
, p
);
1183 return get_window_event(This
, EVENTID_RESIZE
, p
);
1186 static HRESULT WINAPI
HTMLWindow2_put_onscroll(IHTMLWindow2
*iface
, VARIANT v
)
1188 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1190 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1192 return set_window_event(This
, EVENTID_SCROLL
, &v
);
1195 static HRESULT WINAPI
HTMLWindow2_get_onscroll(IHTMLWindow2
*iface
, VARIANT
*p
)
1197 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1199 TRACE("(%p)->(%p)\n", This
, p
);
1201 return get_window_event(This
, EVENTID_SCROLL
, p
);
1204 static HRESULT WINAPI
HTMLWindow2_get_document(IHTMLWindow2
*iface
, IHTMLDocument2
**p
)
1206 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1208 TRACE("(%p)->(%p)\n", This
, p
);
1210 if(This
->inner_window
->doc
) {
1211 /* FIXME: We should return a wrapper object here */
1212 *p
= &This
->inner_window
->doc
->basedoc
.IHTMLDocument2_iface
;
1213 IHTMLDocument2_AddRef(*p
);
1221 static HRESULT WINAPI
HTMLWindow2_get_event(IHTMLWindow2
*iface
, IHTMLEventObj
**p
)
1223 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1224 HTMLInnerWindow
*window
= This
->inner_window
;
1226 TRACE("(%p)->(%p)\n", This
, p
);
1229 IHTMLEventObj_AddRef(window
->event
);
1234 static HRESULT WINAPI
HTMLWindow2_get__newEnum(IHTMLWindow2
*iface
, IUnknown
**p
)
1236 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1237 FIXME("(%p)->(%p)\n", This
, p
);
1241 static HRESULT WINAPI
HTMLWindow2_showModalDialog(IHTMLWindow2
*iface
, BSTR dialog
,
1242 VARIANT
*varArgIn
, VARIANT
*varOptions
, VARIANT
*varArgOut
)
1244 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1245 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(dialog
), varArgIn
, varOptions
, varArgOut
);
1249 static HRESULT WINAPI
HTMLWindow2_showHelp(IHTMLWindow2
*iface
, BSTR helpURL
, VARIANT helpArg
,
1252 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1253 FIXME("(%p)->(%s %s %s)\n", This
, debugstr_w(helpURL
), debugstr_variant(&helpArg
), debugstr_w(features
));
1257 static HRESULT WINAPI
HTMLWindow2_get_screen(IHTMLWindow2
*iface
, IHTMLScreen
**p
)
1259 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1260 HTMLInnerWindow
*window
= This
->inner_window
;
1262 TRACE("(%p)->(%p)\n", This
, p
);
1264 if(!window
->screen
) {
1267 hres
= HTMLScreen_Create(&window
->screen
);
1272 *p
= window
->screen
;
1273 IHTMLScreen_AddRef(window
->screen
);
1277 static HRESULT WINAPI
HTMLWindow2_get_Option(IHTMLWindow2
*iface
, IHTMLOptionElementFactory
**p
)
1279 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1280 HTMLInnerWindow
*window
= This
->inner_window
;
1282 TRACE("(%p)->(%p)\n", This
, p
);
1284 if(!window
->option_factory
) {
1287 hres
= HTMLOptionElementFactory_Create(window
, &window
->option_factory
);
1292 *p
= &window
->option_factory
->IHTMLOptionElementFactory_iface
;
1293 IHTMLOptionElementFactory_AddRef(*p
);
1298 static HRESULT WINAPI
HTMLWindow2_focus(IHTMLWindow2
*iface
)
1300 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1302 TRACE("(%p)->()\n", This
);
1304 if(This
->outer_window
->doc_obj
)
1305 SetFocus(This
->outer_window
->doc_obj
->hwnd
);
1309 static HRESULT WINAPI
HTMLWindow2_get_closed(IHTMLWindow2
*iface
, VARIANT_BOOL
*p
)
1311 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1312 FIXME("(%p)->(%p)\n", This
, p
);
1316 static HRESULT WINAPI
HTMLWindow2_blur(IHTMLWindow2
*iface
)
1318 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1319 FIXME("(%p)->()\n", This
);
1323 static HRESULT WINAPI
HTMLWindow2_scroll(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1325 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1328 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1330 nsres
= nsIDOMWindow_Scroll(This
->outer_window
->nswindow
, x
, y
);
1331 if(NS_FAILED(nsres
)) {
1332 ERR("ScrollBy failed: %08x\n", nsres
);
1339 static HRESULT WINAPI
HTMLWindow2_get_clientInformation(IHTMLWindow2
*iface
, IOmNavigator
**p
)
1341 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1342 FIXME("(%p)->(%p)\n", This
, p
);
1346 static HRESULT WINAPI
HTMLWindow2_setInterval(IHTMLWindow2
*iface
, BSTR expression
,
1347 LONG msec
, VARIANT
*language
, LONG
*timerID
)
1349 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1352 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
1354 V_VT(&expr
) = VT_BSTR
;
1355 V_BSTR(&expr
) = expression
;
1356 return IHTMLWindow3_setInterval(&This
->IHTMLWindow3_iface
, &expr
, msec
, language
, timerID
);
1359 static HRESULT WINAPI
HTMLWindow2_clearInterval(IHTMLWindow2
*iface
, LONG timerID
)
1361 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1363 TRACE("(%p)->(%d)\n", This
, timerID
);
1365 return clear_task_timer(This
->inner_window
, TRUE
, timerID
);
1368 static HRESULT WINAPI
HTMLWindow2_put_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT v
)
1370 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1371 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1375 static HRESULT WINAPI
HTMLWindow2_get_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT
*p
)
1377 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1378 FIXME("(%p)->(%p)\n", This
, p
);
1382 static HRESULT WINAPI
HTMLWindow2_execScript(IHTMLWindow2
*iface
, BSTR scode
, BSTR language
,
1385 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1387 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(scode
), debugstr_w(language
), pvarRet
);
1389 return exec_script(This
->inner_window
, scode
, language
, pvarRet
);
1392 static HRESULT WINAPI
HTMLWindow2_toString(IHTMLWindow2
*iface
, BSTR
*String
)
1394 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1396 static const WCHAR objectW
[] = {'[','o','b','j','e','c','t',']',0};
1398 TRACE("(%p)->(%p)\n", This
, String
);
1401 return E_INVALIDARG
;
1403 *String
= SysAllocString(objectW
);
1404 return *String
? S_OK
: E_OUTOFMEMORY
;
1407 static HRESULT WINAPI
HTMLWindow2_scrollBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1409 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1412 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1414 nsres
= nsIDOMWindow_ScrollBy(This
->outer_window
->nswindow
, x
, y
);
1415 if(NS_FAILED(nsres
))
1416 ERR("ScrollBy failed: %08x\n", nsres
);
1421 static HRESULT WINAPI
HTMLWindow2_scrollTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1423 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1426 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1428 nsres
= nsIDOMWindow_ScrollTo(This
->outer_window
->nswindow
, x
, y
);
1429 if(NS_FAILED(nsres
))
1430 ERR("ScrollTo failed: %08x\n", nsres
);
1435 static HRESULT WINAPI
HTMLWindow2_moveTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1437 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1438 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1442 static HRESULT WINAPI
HTMLWindow2_moveBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1444 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1445 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1449 static HRESULT WINAPI
HTMLWindow2_resizeTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1451 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1452 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1456 static HRESULT WINAPI
HTMLWindow2_resizeBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1458 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1459 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1463 static HRESULT WINAPI
HTMLWindow2_get_external(IHTMLWindow2
*iface
, IDispatch
**p
)
1465 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1467 TRACE("(%p)->(%p)\n", This
, p
);
1471 if(!This
->outer_window
->doc_obj
->hostui
)
1474 return IDocHostUIHandler_GetExternal(This
->outer_window
->doc_obj
->hostui
, p
);
1477 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl
= {
1478 HTMLWindow2_QueryInterface
,
1480 HTMLWindow2_Release
,
1481 HTMLWindow2_GetTypeInfoCount
,
1482 HTMLWindow2_GetTypeInfo
,
1483 HTMLWindow2_GetIDsOfNames
,
1486 HTMLWindow2_get_length
,
1487 HTMLWindow2_get_frames
,
1488 HTMLWindow2_put_defaultStatus
,
1489 HTMLWindow2_get_defaultStatus
,
1490 HTMLWindow2_put_status
,
1491 HTMLWindow2_get_status
,
1492 HTMLWindow2_setTimeout
,
1493 HTMLWindow2_clearTimeout
,
1495 HTMLWindow2_confirm
,
1497 HTMLWindow2_get_Image
,
1498 HTMLWindow2_get_location
,
1499 HTMLWindow2_get_history
,
1501 HTMLWindow2_put_opener
,
1502 HTMLWindow2_get_opener
,
1503 HTMLWindow2_get_navigator
,
1504 HTMLWindow2_put_name
,
1505 HTMLWindow2_get_name
,
1506 HTMLWindow2_get_parent
,
1508 HTMLWindow2_get_self
,
1509 HTMLWindow2_get_top
,
1510 HTMLWindow2_get_window
,
1511 HTMLWindow2_navigate
,
1512 HTMLWindow2_put_onfocus
,
1513 HTMLWindow2_get_onfocus
,
1514 HTMLWindow2_put_onblur
,
1515 HTMLWindow2_get_onblur
,
1516 HTMLWindow2_put_onload
,
1517 HTMLWindow2_get_onload
,
1518 HTMLWindow2_put_onbeforeunload
,
1519 HTMLWindow2_get_onbeforeunload
,
1520 HTMLWindow2_put_onunload
,
1521 HTMLWindow2_get_onunload
,
1522 HTMLWindow2_put_onhelp
,
1523 HTMLWindow2_get_onhelp
,
1524 HTMLWindow2_put_onerror
,
1525 HTMLWindow2_get_onerror
,
1526 HTMLWindow2_put_onresize
,
1527 HTMLWindow2_get_onresize
,
1528 HTMLWindow2_put_onscroll
,
1529 HTMLWindow2_get_onscroll
,
1530 HTMLWindow2_get_document
,
1531 HTMLWindow2_get_event
,
1532 HTMLWindow2_get__newEnum
,
1533 HTMLWindow2_showModalDialog
,
1534 HTMLWindow2_showHelp
,
1535 HTMLWindow2_get_screen
,
1536 HTMLWindow2_get_Option
,
1538 HTMLWindow2_get_closed
,
1541 HTMLWindow2_get_clientInformation
,
1542 HTMLWindow2_setInterval
,
1543 HTMLWindow2_clearInterval
,
1544 HTMLWindow2_put_offscreenBuffering
,
1545 HTMLWindow2_get_offscreenBuffering
,
1546 HTMLWindow2_execScript
,
1547 HTMLWindow2_toString
,
1548 HTMLWindow2_scrollBy
,
1549 HTMLWindow2_scrollTo
,
1552 HTMLWindow2_resizeTo
,
1553 HTMLWindow2_resizeBy
,
1554 HTMLWindow2_get_external
1557 static inline HTMLWindow
*impl_from_IHTMLWindow3(IHTMLWindow3
*iface
)
1559 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow3_iface
);
1562 static HRESULT WINAPI
HTMLWindow3_QueryInterface(IHTMLWindow3
*iface
, REFIID riid
, void **ppv
)
1564 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1566 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1569 static ULONG WINAPI
HTMLWindow3_AddRef(IHTMLWindow3
*iface
)
1571 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1573 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1576 static ULONG WINAPI
HTMLWindow3_Release(IHTMLWindow3
*iface
)
1578 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1580 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1583 static HRESULT WINAPI
HTMLWindow3_GetTypeInfoCount(IHTMLWindow3
*iface
, UINT
*pctinfo
)
1585 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1587 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1590 static HRESULT WINAPI
HTMLWindow3_GetTypeInfo(IHTMLWindow3
*iface
, UINT iTInfo
,
1591 LCID lcid
, ITypeInfo
**ppTInfo
)
1593 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1595 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1598 static HRESULT WINAPI
HTMLWindow3_GetIDsOfNames(IHTMLWindow3
*iface
, REFIID riid
,
1599 LPOLESTR
*rgszNames
, UINT cNames
,
1600 LCID lcid
, DISPID
*rgDispId
)
1602 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1604 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1608 static HRESULT WINAPI
HTMLWindow3_Invoke(IHTMLWindow3
*iface
, DISPID dispIdMember
,
1609 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1610 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1612 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1614 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1615 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1618 static HRESULT WINAPI
HTMLWindow3_get_screenLeft(IHTMLWindow3
*iface
, LONG
*p
)
1620 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1623 TRACE("(%p)->(%p)\n", This
, p
);
1625 nsres
= nsIDOMWindow_GetScreenX(This
->outer_window
->nswindow
, p
);
1626 if(NS_FAILED(nsres
)) {
1627 ERR("GetScreenX failed: %08x\n", nsres
);
1634 static HRESULT WINAPI
HTMLWindow3_get_screenTop(IHTMLWindow3
*iface
, LONG
*p
)
1636 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1639 TRACE("(%p)->(%p)\n", This
, p
);
1641 nsres
= nsIDOMWindow_GetScreenY(This
->outer_window
->nswindow
, p
);
1642 if(NS_FAILED(nsres
)) {
1643 ERR("GetScreenY failed: %08x\n", nsres
);
1650 static HRESULT WINAPI
HTMLWindow3_attachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
, VARIANT_BOOL
*pfResult
)
1652 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1653 HTMLInnerWindow
*window
= This
->inner_window
;
1655 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(event
), pDisp
, pfResult
);
1658 FIXME("No document\n");
1662 return attach_event(&window
->event_target
, event
, pDisp
, pfResult
);
1665 static HRESULT WINAPI
HTMLWindow3_detachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
)
1667 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1668 HTMLInnerWindow
*window
= This
->inner_window
;
1670 TRACE("(%p)->()\n", This
);
1673 FIXME("No document\n");
1677 return detach_event(&window
->event_target
, event
, pDisp
);
1680 static HRESULT
window_set_timer(HTMLInnerWindow
*This
, VARIANT
*expr
, LONG msec
, VARIANT
*language
,
1681 BOOL interval
, LONG
*timer_id
)
1683 IDispatch
*disp
= NULL
;
1686 switch(V_VT(expr
)) {
1688 disp
= V_DISPATCH(expr
);
1689 IDispatch_AddRef(disp
);
1693 disp
= script_parse_event(This
->base
.inner_window
, V_BSTR(expr
));
1697 FIXME("unimplemented expr %s\n", debugstr_variant(expr
));
1704 hres
= set_task_timer(This
, msec
, interval
, disp
, timer_id
);
1705 IDispatch_Release(disp
);
1710 static HRESULT WINAPI
HTMLWindow3_setTimeout(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1711 VARIANT
*language
, LONG
*timerID
)
1713 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1715 TRACE("(%p)->(%s %d %s %p)\n", This
, debugstr_variant(expression
), msec
, debugstr_variant(language
), timerID
);
1717 return window_set_timer(This
->inner_window
, expression
, msec
, language
, FALSE
, timerID
);
1720 static HRESULT WINAPI
HTMLWindow3_setInterval(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1721 VARIANT
*language
, LONG
*timerID
)
1723 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1725 TRACE("(%p)->(%p %d %p %p)\n", This
, expression
, msec
, language
, timerID
);
1727 return window_set_timer(This
->inner_window
, expression
, msec
, language
, TRUE
, timerID
);
1730 static HRESULT WINAPI
HTMLWindow3_print(IHTMLWindow3
*iface
)
1732 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1733 FIXME("(%p)\n", This
);
1737 static HRESULT WINAPI
HTMLWindow3_put_onbeforeprint(IHTMLWindow3
*iface
, VARIANT v
)
1739 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1740 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1744 static HRESULT WINAPI
HTMLWindow3_get_onbeforeprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1746 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1747 FIXME("(%p)->(%p)\n", This
, p
);
1751 static HRESULT WINAPI
HTMLWindow3_put_onafterprint(IHTMLWindow3
*iface
, VARIANT v
)
1753 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1754 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1758 static HRESULT WINAPI
HTMLWindow3_get_onafterprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1760 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1761 FIXME("(%p)->(%p)\n", This
, p
);
1765 static HRESULT WINAPI
HTMLWindow3_get_clipboardData(IHTMLWindow3
*iface
, IHTMLDataTransfer
**p
)
1767 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1768 FIXME("(%p)->(%p)\n", This
, p
);
1772 static HRESULT WINAPI
HTMLWindow3_showModelessDialog(IHTMLWindow3
*iface
, BSTR url
,
1773 VARIANT
*varArgIn
, VARIANT
*options
, IHTMLWindow2
**pDialog
)
1775 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1776 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(url
), varArgIn
, options
, pDialog
);
1780 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl
= {
1781 HTMLWindow3_QueryInterface
,
1783 HTMLWindow3_Release
,
1784 HTMLWindow3_GetTypeInfoCount
,
1785 HTMLWindow3_GetTypeInfo
,
1786 HTMLWindow3_GetIDsOfNames
,
1788 HTMLWindow3_get_screenLeft
,
1789 HTMLWindow3_get_screenTop
,
1790 HTMLWindow3_attachEvent
,
1791 HTMLWindow3_detachEvent
,
1792 HTMLWindow3_setTimeout
,
1793 HTMLWindow3_setInterval
,
1795 HTMLWindow3_put_onbeforeprint
,
1796 HTMLWindow3_get_onbeforeprint
,
1797 HTMLWindow3_put_onafterprint
,
1798 HTMLWindow3_get_onafterprint
,
1799 HTMLWindow3_get_clipboardData
,
1800 HTMLWindow3_showModelessDialog
1803 static inline HTMLWindow
*impl_from_IHTMLWindow4(IHTMLWindow4
*iface
)
1805 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow4_iface
);
1808 static HRESULT WINAPI
HTMLWindow4_QueryInterface(IHTMLWindow4
*iface
, REFIID riid
, void **ppv
)
1810 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1812 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1815 static ULONG WINAPI
HTMLWindow4_AddRef(IHTMLWindow4
*iface
)
1817 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1819 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1822 static ULONG WINAPI
HTMLWindow4_Release(IHTMLWindow4
*iface
)
1824 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1826 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1829 static HRESULT WINAPI
HTMLWindow4_GetTypeInfoCount(IHTMLWindow4
*iface
, UINT
*pctinfo
)
1831 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1833 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1836 static HRESULT WINAPI
HTMLWindow4_GetTypeInfo(IHTMLWindow4
*iface
, UINT iTInfo
,
1837 LCID lcid
, ITypeInfo
**ppTInfo
)
1839 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1841 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1844 static HRESULT WINAPI
HTMLWindow4_GetIDsOfNames(IHTMLWindow4
*iface
, REFIID riid
,
1845 LPOLESTR
*rgszNames
, UINT cNames
,
1846 LCID lcid
, DISPID
*rgDispId
)
1848 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1850 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1854 static HRESULT WINAPI
HTMLWindow4_Invoke(IHTMLWindow4
*iface
, DISPID dispIdMember
,
1855 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1856 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1858 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1860 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1861 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1864 static HRESULT WINAPI
HTMLWindow4_createPopup(IHTMLWindow4
*iface
, VARIANT
*varArgIn
,
1865 IDispatch
**ppPopup
)
1867 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1868 FIXME("(%p)->(%p %p)\n", This
, varArgIn
, ppPopup
);
1872 static HRESULT WINAPI
HTMLWindow4_get_frameElement(IHTMLWindow4
*iface
, IHTMLFrameBase
**p
)
1874 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1875 TRACE("(%p)->(%p)\n", This
, p
);
1877 if(This
->outer_window
->frame_element
) {
1878 *p
= &This
->outer_window
->frame_element
->IHTMLFrameBase_iface
;
1879 IHTMLFrameBase_AddRef(*p
);
1886 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl
= {
1887 HTMLWindow4_QueryInterface
,
1889 HTMLWindow4_Release
,
1890 HTMLWindow4_GetTypeInfoCount
,
1891 HTMLWindow4_GetTypeInfo
,
1892 HTMLWindow4_GetIDsOfNames
,
1894 HTMLWindow4_createPopup
,
1895 HTMLWindow4_get_frameElement
1898 static inline HTMLWindow
*impl_from_IHTMLWindow5(IHTMLWindow5
*iface
)
1900 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow5_iface
);
1903 static HRESULT WINAPI
HTMLWindow5_QueryInterface(IHTMLWindow5
*iface
, REFIID riid
, void **ppv
)
1905 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1907 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1910 static ULONG WINAPI
HTMLWindow5_AddRef(IHTMLWindow5
*iface
)
1912 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1914 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1917 static ULONG WINAPI
HTMLWindow5_Release(IHTMLWindow5
*iface
)
1919 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1921 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1924 static HRESULT WINAPI
HTMLWindow5_GetTypeInfoCount(IHTMLWindow5
*iface
, UINT
*pctinfo
)
1926 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1928 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1931 static HRESULT WINAPI
HTMLWindow5_GetTypeInfo(IHTMLWindow5
*iface
, UINT iTInfo
,
1932 LCID lcid
, ITypeInfo
**ppTInfo
)
1934 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1936 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1939 static HRESULT WINAPI
HTMLWindow5_GetIDsOfNames(IHTMLWindow5
*iface
, REFIID riid
,
1940 LPOLESTR
*rgszNames
, UINT cNames
, LCID lcid
, DISPID
*rgDispId
)
1942 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1944 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1948 static HRESULT WINAPI
HTMLWindow5_Invoke(IHTMLWindow5
*iface
, DISPID dispIdMember
,
1949 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1950 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1952 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1954 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1955 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1958 static HRESULT WINAPI
HTMLWindow5_put_XMLHttpRequest(IHTMLWindow5
*iface
, VARIANT v
)
1960 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1961 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
1965 static HRESULT WINAPI
HTMLWindow5_get_XMLHttpRequest(IHTMLWindow5
*iface
, VARIANT
*p
)
1967 HTMLWindow
*This
= impl_from_IHTMLWindow5(iface
);
1968 FIXME("(%p)->(%p)\n", This
, p
);
1972 static const IHTMLWindow5Vtbl HTMLWindow5Vtbl
= {
1973 HTMLWindow5_QueryInterface
,
1975 HTMLWindow5_Release
,
1976 HTMLWindow5_GetTypeInfoCount
,
1977 HTMLWindow5_GetTypeInfo
,
1978 HTMLWindow5_GetIDsOfNames
,
1980 HTMLWindow5_put_XMLHttpRequest
,
1981 HTMLWindow5_get_XMLHttpRequest
1984 static inline HTMLWindow
*impl_from_IHTMLWindow6(IHTMLWindow6
*iface
)
1986 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow6_iface
);
1989 static HRESULT WINAPI
HTMLWindow6_QueryInterface(IHTMLWindow6
*iface
, REFIID riid
, void **ppv
)
1991 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
1993 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1996 static ULONG WINAPI
HTMLWindow6_AddRef(IHTMLWindow6
*iface
)
1998 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2000 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2003 static ULONG WINAPI
HTMLWindow6_Release(IHTMLWindow6
*iface
)
2005 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2007 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2010 static HRESULT WINAPI
HTMLWindow6_GetTypeInfoCount(IHTMLWindow6
*iface
, UINT
*pctinfo
)
2012 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2014 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
2017 static HRESULT WINAPI
HTMLWindow6_GetTypeInfo(IHTMLWindow6
*iface
, UINT iTInfo
,
2018 LCID lcid
, ITypeInfo
**ppTInfo
)
2020 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2022 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2025 static HRESULT WINAPI
HTMLWindow6_GetIDsOfNames(IHTMLWindow6
*iface
, REFIID riid
,
2026 LPOLESTR
*rgszNames
, UINT cNames
,
2027 LCID lcid
, DISPID
*rgDispId
)
2029 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2031 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
2035 static HRESULT WINAPI
HTMLWindow6_Invoke(IHTMLWindow6
*iface
, DISPID dispIdMember
,
2036 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2037 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2039 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2041 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
2042 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2045 static HRESULT WINAPI
HTMLWindow6_put_XDomainRequest(IHTMLWindow6
*iface
, VARIANT v
)
2047 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2048 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
2052 static HRESULT WINAPI
HTMLWindow6_get_XDomainRequest(IHTMLWindow6
*iface
, VARIANT
*p
)
2054 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2055 FIXME("(%p)->(%p)\n", This
, p
);
2059 static HRESULT WINAPI
HTMLWindow6_get_sessionStorage(IHTMLWindow6
*iface
, IHTMLStorage
**p
)
2061 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2063 FIXME("(%p)->(%p)\n", This
, p
);
2065 if(!This
->inner_window
->session_storage
) {
2068 hres
= create_storage(&This
->inner_window
->session_storage
);
2073 IHTMLStorage_AddRef(This
->inner_window
->session_storage
);
2074 *p
= This
->inner_window
->session_storage
;
2078 static HRESULT WINAPI
HTMLWindow6_get_localStorage(IHTMLWindow6
*iface
, IHTMLStorage
**p
)
2080 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2081 FIXME("(%p)->(%p)\n", This
, p
);
2085 static HRESULT WINAPI
HTMLWindow6_put_onhashchange(IHTMLWindow6
*iface
, VARIANT v
)
2087 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2088 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
2092 static HRESULT WINAPI
HTMLWindow6_get_onhashchange(IHTMLWindow6
*iface
, VARIANT
*p
)
2094 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2095 FIXME("(%p)->(%p)\n", This
, p
);
2099 static HRESULT WINAPI
HTMLWindow6_get_maxConnectionsPerServer(IHTMLWindow6
*iface
, LONG
*p
)
2101 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2102 FIXME("(%p)->(%p)\n", This
, p
);
2106 static HRESULT WINAPI
HTMLWindow6_postMessage(IHTMLWindow6
*iface
, BSTR msg
, VARIANT targetOrigin
)
2108 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2109 FIXME("(%p)->(%s %s)\n", This
, debugstr_w(msg
), debugstr_variant(&targetOrigin
));
2113 static HRESULT WINAPI
HTMLWindow6_toStaticHTML(IHTMLWindow6
*iface
, BSTR bstrHTML
, BSTR
*pbstrStaticHTML
)
2115 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2116 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(bstrHTML
), pbstrStaticHTML
);
2120 static HRESULT WINAPI
HTMLWindow6_put_onmessage(IHTMLWindow6
*iface
, VARIANT v
)
2122 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2123 FIXME("(%p)->(%s)\n", This
, debugstr_variant(&v
));
2127 static HRESULT WINAPI
HTMLWindow6_get_onmessage(IHTMLWindow6
*iface
, VARIANT
*p
)
2129 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2130 FIXME("(%p)->(%p)\n", This
, p
);
2134 static HRESULT WINAPI
HTMLWindow6_msWriteProfilerMark(IHTMLWindow6
*iface
, BSTR bstrProfilerMark
)
2136 HTMLWindow
*This
= impl_from_IHTMLWindow6(iface
);
2137 FIXME("(%p)->(%s)\n", This
, debugstr_w(bstrProfilerMark
));
2141 static const IHTMLWindow6Vtbl HTMLWindow6Vtbl
= {
2142 HTMLWindow6_QueryInterface
,
2144 HTMLWindow6_Release
,
2145 HTMLWindow6_GetTypeInfoCount
,
2146 HTMLWindow6_GetTypeInfo
,
2147 HTMLWindow6_GetIDsOfNames
,
2149 HTMLWindow6_put_XDomainRequest
,
2150 HTMLWindow6_get_XDomainRequest
,
2151 HTMLWindow6_get_sessionStorage
,
2152 HTMLWindow6_get_localStorage
,
2153 HTMLWindow6_put_onhashchange
,
2154 HTMLWindow6_get_onhashchange
,
2155 HTMLWindow6_get_maxConnectionsPerServer
,
2156 HTMLWindow6_postMessage
,
2157 HTMLWindow6_toStaticHTML
,
2158 HTMLWindow6_put_onmessage
,
2159 HTMLWindow6_get_onmessage
,
2160 HTMLWindow6_msWriteProfilerMark
2163 static inline HTMLWindow
*impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow
*iface
)
2165 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLPrivateWindow_iface
);
2168 static HRESULT WINAPI
HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow
*iface
, REFIID riid
, void **ppv
)
2170 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2172 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2175 static ULONG WINAPI
HTMLPrivateWindow_AddRef(IHTMLPrivateWindow
*iface
)
2177 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2179 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2182 static ULONG WINAPI
HTMLPrivateWindow_Release(IHTMLPrivateWindow
*iface
)
2184 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2186 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2189 static HRESULT WINAPI
HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow
*iface
, BSTR url
, BSTR arg2
, BSTR arg3
,
2190 BSTR arg4
, VARIANT
*post_data_var
, VARIANT
*headers_var
, ULONG flags
)
2192 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2193 HTMLOuterWindow
*window
= This
->outer_window
;
2194 OLECHAR
*translated_url
= NULL
;
2195 DWORD post_data_size
= 0;
2196 BYTE
*post_data
= NULL
;
2197 WCHAR
*headers
= NULL
;
2201 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This
, debugstr_w(url
), debugstr_w(arg2
), debugstr_w(arg3
), debugstr_w(arg4
),
2202 debugstr_variant(post_data_var
), debugstr_variant(headers_var
), flags
);
2204 if(window
->doc_obj
->hostui
) {
2205 hres
= IDocHostUIHandler_TranslateUrl(window
->doc_obj
->hostui
, 0, url
, &translated_url
);
2207 translated_url
= NULL
;
2210 hres
= create_uri(translated_url
? translated_url
: url
, 0, &uri
);
2211 CoTaskMemFree(translated_url
);
2216 if(V_VT(post_data_var
) == (VT_ARRAY
|VT_UI1
)) {
2217 SafeArrayAccessData(V_ARRAY(post_data_var
), (void**)&post_data
);
2218 post_data_size
= V_ARRAY(post_data_var
)->rgsabound
[0].cElements
;
2222 if(headers_var
&& V_VT(headers_var
) != VT_EMPTY
&& V_VT(headers_var
) != VT_ERROR
) {
2223 if(V_VT(headers_var
) != VT_BSTR
)
2224 return E_INVALIDARG
;
2226 headers
= V_BSTR(headers_var
);
2229 hres
= super_navigate(window
, uri
, BINDING_NAVIGATED
|BINDING_NOFRAG
, headers
, post_data
, post_data_size
);
2232 SafeArrayUnaccessData(V_ARRAY(post_data_var
));
2237 static HRESULT WINAPI
HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow
*iface
, BSTR
*url
)
2239 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2240 FIXME("(%p)->(%p)\n", This
, url
);
2244 static HRESULT WINAPI
HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow
*iface
, IOleCommandTarget
*cmdtrg
)
2246 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2247 FIXME("(%p)->(%p)\n", This
, cmdtrg
);
2251 static HRESULT WINAPI
HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow
*iface
, int arg
)
2253 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2254 FIXME("(%p)->(%x)\n", This
, arg
);
2258 static HRESULT WINAPI
HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow
*iface
, LPCWSTR name
, IHTMLWindow2
**ret
)
2260 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2261 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(name
), ret
);
2265 static HRESULT WINAPI
HTMLPrivateWindow_GetAddressBarUrl(IHTMLPrivateWindow
*iface
, BSTR
*url
)
2267 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
2268 TRACE("(%p)->(%p)\n", This
, url
);
2271 return E_INVALIDARG
;
2273 *url
= SysAllocString(This
->outer_window
->url
);
2277 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl
= {
2278 HTMLPrivateWindow_QueryInterface
,
2279 HTMLPrivateWindow_AddRef
,
2280 HTMLPrivateWindow_Release
,
2281 HTMLPrivateWindow_SuperNavigate
,
2282 HTMLPrivateWindow_GetPendingUrl
,
2283 HTMLPrivateWindow_SetPICSTarget
,
2284 HTMLPrivateWindow_PICSComplete
,
2285 HTMLPrivateWindow_FindWindowByName
,
2286 HTMLPrivateWindow_GetAddressBarUrl
2289 static inline HTMLWindow
*impl_from_ITravelLogClient(ITravelLogClient
*iface
)
2291 return CONTAINING_RECORD(iface
, HTMLWindow
, ITravelLogClient_iface
);
2294 static HRESULT WINAPI
TravelLogClient_QueryInterface(ITravelLogClient
*iface
, REFIID riid
, void **ppv
)
2296 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2298 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2301 static ULONG WINAPI
TravelLogClient_AddRef(ITravelLogClient
*iface
)
2303 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2305 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2308 static ULONG WINAPI
TravelLogClient_Release(ITravelLogClient
*iface
)
2310 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2312 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2315 static HRESULT WINAPI
TravelLogClient_FindWindowByIndex(ITravelLogClient
*iface
, DWORD dwID
, IUnknown
**ppunk
)
2317 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2319 FIXME("(%p)->(%d %p) semi-stub\n", This
, dwID
, ppunk
);
2325 static HRESULT WINAPI
TravelLogClient_GetWindowData(ITravelLogClient
*iface
, IStream
*pStream
, LPWINDOWDATA pWinData
)
2327 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2328 FIXME("(%p)->(%p %p)\n", This
, pStream
, pWinData
);
2332 static HRESULT WINAPI
TravelLogClient_LoadHistoryPosition(ITravelLogClient
*iface
, LPWSTR pszUrlLocation
, DWORD dwPosition
)
2334 HTMLWindow
*This
= impl_from_ITravelLogClient(iface
);
2335 FIXME("(%p)->(%s %d)\n", This
, debugstr_w(pszUrlLocation
), dwPosition
);
2339 static const ITravelLogClientVtbl TravelLogClientVtbl
= {
2340 TravelLogClient_QueryInterface
,
2341 TravelLogClient_AddRef
,
2342 TravelLogClient_Release
,
2343 TravelLogClient_FindWindowByIndex
,
2344 TravelLogClient_GetWindowData
,
2345 TravelLogClient_LoadHistoryPosition
2348 static inline HTMLWindow
*impl_from_IObjectIdentity(IObjectIdentity
*iface
)
2350 return CONTAINING_RECORD(iface
, HTMLWindow
, IObjectIdentity_iface
);
2353 static HRESULT WINAPI
ObjectIdentity_QueryInterface(IObjectIdentity
*iface
, REFIID riid
, void **ppv
)
2355 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2357 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2360 static ULONG WINAPI
ObjectIdentity_AddRef(IObjectIdentity
*iface
)
2362 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2364 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2367 static ULONG WINAPI
ObjectIdentity_Release(IObjectIdentity
*iface
)
2369 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2371 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2374 static HRESULT WINAPI
ObjectIdentity_IsEqualObject(IObjectIdentity
*iface
, IUnknown
*unk
)
2376 HTMLWindow
*This
= impl_from_IObjectIdentity(iface
);
2377 IServiceProvider
*sp
;
2380 TRACE("(%p)->(%p)\n", This
, unk
);
2382 hres
= IUnknown_QueryInterface(unk
, &IID_IServiceProvider
, (void**)&sp
);
2386 hres
= &This
->inner_window
->base
.IServiceProvider_iface
==sp
||
2387 &This
->outer_window
->base
.IServiceProvider_iface
==sp
? S_OK
: S_FALSE
;
2388 IServiceProvider_Release(sp
);
2392 static const IObjectIdentityVtbl ObjectIdentityVtbl
= {
2393 ObjectIdentity_QueryInterface
,
2394 ObjectIdentity_AddRef
,
2395 ObjectIdentity_Release
,
2396 ObjectIdentity_IsEqualObject
2399 static inline HTMLWindow
*impl_from_IDispatchEx(IDispatchEx
*iface
)
2401 return CONTAINING_RECORD(iface
, HTMLWindow
, IDispatchEx_iface
);
2404 static HRESULT WINAPI
WindowDispEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
2406 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2408 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2411 static ULONG WINAPI
WindowDispEx_AddRef(IDispatchEx
*iface
)
2413 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2415 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2418 static ULONG WINAPI
WindowDispEx_Release(IDispatchEx
*iface
)
2420 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2422 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2425 static HRESULT WINAPI
WindowDispEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
2427 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2429 TRACE("(%p)->(%p)\n", This
, pctinfo
);
2431 return IDispatchEx_GetTypeInfoCount(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, pctinfo
);
2434 static HRESULT WINAPI
WindowDispEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
2435 LCID lcid
, ITypeInfo
**ppTInfo
)
2437 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2439 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
2441 return IDispatchEx_GetTypeInfo(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
2444 static HRESULT WINAPI
WindowDispEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
2445 LPOLESTR
*rgszNames
, UINT cNames
,
2446 LCID lcid
, DISPID
*rgDispId
)
2448 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2452 WARN("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
, lcid
, rgDispId
);
2454 for(i
=0; i
< cNames
; i
++) {
2455 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
2456 hres
= IDispatchEx_GetDispID(&This
->IDispatchEx_iface
, rgszNames
[i
], 0, rgDispId
+i
);
2464 static HRESULT WINAPI
WindowDispEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
2465 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
2466 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
2468 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2470 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
2471 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2473 /* FIXME: Use script dispatch */
2475 return IDispatchEx_Invoke(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
2476 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
2479 static global_prop_t
*alloc_global_prop(HTMLInnerWindow
*This
, global_prop_type_t type
, BSTR name
)
2481 if(This
->global_prop_cnt
== This
->global_prop_size
) {
2482 global_prop_t
*new_props
;
2485 if(This
->global_props
) {
2486 new_size
= This
->global_prop_size
*2;
2487 new_props
= heap_realloc(This
->global_props
, new_size
*sizeof(global_prop_t
));
2490 new_props
= heap_alloc(new_size
*sizeof(global_prop_t
));
2494 This
->global_props
= new_props
;
2495 This
->global_prop_size
= new_size
;
2498 This
->global_props
[This
->global_prop_cnt
].name
= heap_strdupW(name
);
2499 if(!This
->global_props
[This
->global_prop_cnt
].name
)
2502 This
->global_props
[This
->global_prop_cnt
].type
= type
;
2503 return This
->global_props
+ This
->global_prop_cnt
++;
2506 static inline DWORD
prop_to_dispid(HTMLInnerWindow
*This
, global_prop_t
*prop
)
2508 return MSHTML_DISPID_CUSTOM_MIN
+ (prop
-This
->global_props
);
2511 HRESULT
search_window_props(HTMLInnerWindow
*This
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
2514 ScriptHost
*script_host
;
2517 for(i
=0; i
< This
->global_prop_cnt
; i
++) {
2518 /* FIXME: case sensitivity */
2519 if(!strcmpW(This
->global_props
[i
].name
, bstrName
)) {
2520 *pid
= MSHTML_DISPID_CUSTOM_MIN
+i
;
2525 if(find_global_prop(This
->base
.inner_window
, bstrName
, grfdex
, &script_host
, &id
)) {
2526 global_prop_t
*prop
;
2528 prop
= alloc_global_prop(This
, GLOBAL_SCRIPTVAR
, bstrName
);
2530 return E_OUTOFMEMORY
;
2532 prop
->script_host
= script_host
;
2535 *pid
= prop_to_dispid(This
, prop
);
2539 return DISP_E_UNKNOWNNAME
;
2542 static HRESULT WINAPI
WindowDispEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
2544 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2545 HTMLInnerWindow
*window
= This
->inner_window
;
2548 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(bstrName
), grfdex
, pid
);
2550 hres
= search_window_props(window
, bstrName
, grfdex
, pid
);
2551 if(hres
!= DISP_E_UNKNOWNNAME
)
2554 hres
= IDispatchEx_GetDispID(&window
->base
.inner_window
->event_target
.dispex
.IDispatchEx_iface
, bstrName
, grfdex
, pid
);
2555 if(hres
!= DISP_E_UNKNOWNNAME
)
2558 if(This
->outer_window
) {
2559 HTMLOuterWindow
*frame
;
2561 hres
= get_frame_by_name(This
->outer_window
, bstrName
, FALSE
, &frame
);
2562 if(SUCCEEDED(hres
) && frame
) {
2563 global_prop_t
*prop
;
2565 IHTMLWindow2_Release(&frame
->base
.IHTMLWindow2_iface
);
2567 prop
= alloc_global_prop(window
, GLOBAL_FRAMEVAR
, bstrName
);
2569 return E_OUTOFMEMORY
;
2571 *pid
= prop_to_dispid(window
, prop
);
2577 global_prop_t
*prop
;
2580 hres
= IHTMLDocument3_getElementById(&window
->base
.inner_window
->doc
->basedoc
.IHTMLDocument3_iface
,
2582 if(SUCCEEDED(hres
) && elem
) {
2583 IHTMLElement_Release(elem
);
2585 prop
= alloc_global_prop(window
, GLOBAL_ELEMENTVAR
, bstrName
);
2587 return E_OUTOFMEMORY
;
2589 *pid
= prop_to_dispid(window
, prop
);
2594 return DISP_E_UNKNOWNNAME
;
2597 static HRESULT WINAPI
WindowDispEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
2598 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
2600 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2601 HTMLInnerWindow
*window
= This
->inner_window
;
2603 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2605 if(id
== DISPID_IHTMLWINDOW2_LOCATION
&& (wFlags
& DISPATCH_PROPERTYPUT
)) {
2606 HTMLLocation
*location
;
2609 TRACE("forwarding to location.href\n");
2611 hres
= get_location(window
, &location
);
2615 hres
= IDispatchEx_InvokeEx(&location
->dispex
.IDispatchEx_iface
, DISPID_VALUE
, lcid
,
2616 wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2617 IHTMLLocation_Release(&location
->IHTMLLocation_iface
);
2621 return IDispatchEx_InvokeEx(&window
->event_target
.dispex
.IDispatchEx_iface
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2624 static HRESULT WINAPI
WindowDispEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
2626 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2628 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(bstrName
), grfdex
);
2630 return IDispatchEx_DeleteMemberByName(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, bstrName
, grfdex
);
2633 static HRESULT WINAPI
WindowDispEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
2635 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2637 TRACE("(%p)->(%x)\n", This
, id
);
2639 return IDispatchEx_DeleteMemberByDispID(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, id
);
2642 static HRESULT WINAPI
WindowDispEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
2644 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2646 TRACE("(%p)->(%x %x %p)\n", This
, id
, grfdexFetch
, pgrfdex
);
2648 return IDispatchEx_GetMemberProperties(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, id
, grfdexFetch
,
2652 static HRESULT WINAPI
WindowDispEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
2654 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2656 TRACE("(%p)->(%x %p)\n", This
, id
, pbstrName
);
2658 return IDispatchEx_GetMemberName(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, id
, pbstrName
);
2661 static HRESULT WINAPI
WindowDispEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
2663 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2665 TRACE("(%p)->(%x %x %p)\n", This
, grfdex
, id
, pid
);
2667 return IDispatchEx_GetNextDispID(&This
->inner_window
->event_target
.dispex
.IDispatchEx_iface
, grfdex
, id
, pid
);
2670 static HRESULT WINAPI
WindowDispEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
2672 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2674 TRACE("(%p)->(%p)\n", This
, ppunk
);
2680 static const IDispatchExVtbl WindowDispExVtbl
= {
2681 WindowDispEx_QueryInterface
,
2682 WindowDispEx_AddRef
,
2683 WindowDispEx_Release
,
2684 WindowDispEx_GetTypeInfoCount
,
2685 WindowDispEx_GetTypeInfo
,
2686 WindowDispEx_GetIDsOfNames
,
2687 WindowDispEx_Invoke
,
2688 WindowDispEx_GetDispID
,
2689 WindowDispEx_InvokeEx
,
2690 WindowDispEx_DeleteMemberByName
,
2691 WindowDispEx_DeleteMemberByDispID
,
2692 WindowDispEx_GetMemberProperties
,
2693 WindowDispEx_GetMemberName
,
2694 WindowDispEx_GetNextDispID
,
2695 WindowDispEx_GetNameSpaceParent
2698 static inline HTMLWindow
*impl_from_IServiceProvider(IServiceProvider
*iface
)
2700 return CONTAINING_RECORD(iface
, HTMLWindow
, IServiceProvider_iface
);
2703 static HRESULT WINAPI
HTMLWindowSP_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
2705 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2706 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2709 static ULONG WINAPI
HTMLWindowSP_AddRef(IServiceProvider
*iface
)
2711 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2712 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2715 static ULONG WINAPI
HTMLWindowSP_Release(IServiceProvider
*iface
)
2717 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2718 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2721 static HRESULT WINAPI
HTMLWindowSP_QueryService(IServiceProvider
*iface
, REFGUID guidService
, REFIID riid
, void **ppv
)
2723 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2725 if(IsEqualGUID(guidService
, &IID_IHTMLWindow2
)) {
2726 TRACE("IID_IHTMLWindow2\n");
2727 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2730 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_mshtml_guid(guidService
), debugstr_mshtml_guid(riid
), ppv
);
2732 if(!This
->outer_window
->doc_obj
)
2733 return E_NOINTERFACE
;
2735 return IServiceProvider_QueryService(&This
->outer_window
->doc_obj
->basedoc
.IServiceProvider_iface
,
2736 guidService
, riid
, ppv
);
2739 static const IServiceProviderVtbl ServiceProviderVtbl
= {
2740 HTMLWindowSP_QueryInterface
,
2741 HTMLWindowSP_AddRef
,
2742 HTMLWindowSP_Release
,
2743 HTMLWindowSP_QueryService
2746 static inline HTMLInnerWindow
*impl_from_DispatchEx(DispatchEx
*iface
)
2748 return CONTAINING_RECORD(iface
, HTMLInnerWindow
, event_target
.dispex
);
2751 static HRESULT
HTMLWindow_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2752 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2754 HTMLInnerWindow
*This
= impl_from_DispatchEx(dispex
);
2755 global_prop_t
*prop
;
2759 idx
= id
- MSHTML_DISPID_CUSTOM_MIN
;
2760 if(idx
>= This
->global_prop_cnt
)
2761 return DISP_E_MEMBERNOTFOUND
;
2763 prop
= This
->global_props
+idx
;
2765 switch(prop
->type
) {
2766 case GLOBAL_SCRIPTVAR
: {
2770 disp
= get_script_disp(prop
->script_host
);
2772 return E_UNEXPECTED
;
2774 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&iface
);
2775 if(SUCCEEDED(hres
)) {
2776 TRACE("%s >>>\n", debugstr_w(prop
->name
));
2777 hres
= IDispatchEx_InvokeEx(iface
, prop
->id
, lcid
, flags
, params
, res
, ei
, caller
);
2779 TRACE("%s <<<\n", debugstr_w(prop
->name
));
2781 WARN("%s <<< %08x\n", debugstr_w(prop
->name
), hres
);
2782 IDispatchEx_Release(iface
);
2784 FIXME("No IDispatchEx\n");
2786 IDispatch_Release(disp
);
2789 case GLOBAL_ELEMENTVAR
:
2791 case DISPATCH_PROPERTYGET
|DISPATCH_METHOD
:
2792 case DISPATCH_PROPERTYGET
: {
2795 hres
= IHTMLDocument3_getElementById(&This
->base
.inner_window
->doc
->basedoc
.IHTMLDocument3_iface
,
2801 return DISP_E_MEMBERNOTFOUND
;
2803 V_VT(res
) = VT_DISPATCH
;
2804 V_DISPATCH(res
) = (IDispatch
*)elem
;
2807 case DISPATCH_PROPERTYPUT
: {
2810 hres
= dispex_get_dynid(&This
->event_target
.dispex
, prop
->name
, &dispex_id
);
2814 prop
->type
= GLOBAL_DISPEXVAR
;
2815 prop
->id
= dispex_id
;
2816 return IDispatchEx_InvokeEx(&This
->event_target
.dispex
.IDispatchEx_iface
, dispex_id
, 0, flags
, params
, res
, ei
, caller
);
2819 FIXME("Not supported flags: %x\n", flags
);
2822 case GLOBAL_FRAMEVAR
:
2823 if(!This
->base
.outer_window
)
2824 return E_UNEXPECTED
;
2827 case DISPATCH_PROPERTYGET
: {
2828 HTMLOuterWindow
*frame
;
2830 hres
= get_frame_by_name(This
->base
.outer_window
, prop
->name
, FALSE
, &frame
);
2835 return DISP_E_MEMBERNOTFOUND
;
2837 V_VT(res
) = VT_DISPATCH
;
2838 V_DISPATCH(res
) = (IDispatch
*)&frame
->base
.inner_window
->base
.IHTMLWindow2_iface
;
2839 IDispatch_AddRef(V_DISPATCH(res
));
2843 FIXME("Not supported flags: %x\n", flags
);
2846 case GLOBAL_DISPEXVAR
:
2847 return IDispatchEx_InvokeEx(&This
->event_target
.dispex
.IDispatchEx_iface
, prop
->id
, 0, flags
, params
, res
, ei
, caller
);
2849 ERR("invalid type %d\n", prop
->type
);
2850 hres
= DISP_E_MEMBERNOTFOUND
;
2856 static event_target_t
**HTMLWindow_get_event_target_ptr(DispatchEx
*dispex
)
2858 HTMLInnerWindow
*This
= impl_from_DispatchEx(dispex
);
2859 return &This
->doc
->body_event_target
;
2862 static void HTMLWindow_bind_event(DispatchEx
*dispex
, int eid
)
2864 HTMLInnerWindow
*This
= impl_from_DispatchEx(dispex
);
2865 This
->doc
->node
.event_target
.dispex
.data
->vtbl
->bind_event(&This
->doc
->node
.event_target
.dispex
, eid
);
2868 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl
= {
2873 HTMLWindow_get_event_target_ptr
,
2874 HTMLWindow_bind_event
2877 static const tid_t HTMLWindow_iface_tids
[] = {
2885 static dispex_static_data_t HTMLWindow_dispex
= {
2886 &HTMLWindow_dispex_vtbl
,
2887 DispHTMLWindow2_tid
,
2889 HTMLWindow_iface_tids
2892 static void *alloc_window(size_t size
)
2896 window
= heap_alloc_zero(size
);
2900 window
->IHTMLWindow2_iface
.lpVtbl
= &HTMLWindow2Vtbl
;
2901 window
->IHTMLWindow3_iface
.lpVtbl
= &HTMLWindow3Vtbl
;
2902 window
->IHTMLWindow4_iface
.lpVtbl
= &HTMLWindow4Vtbl
;
2903 window
->IHTMLWindow5_iface
.lpVtbl
= &HTMLWindow5Vtbl
;
2904 window
->IHTMLWindow6_iface
.lpVtbl
= &HTMLWindow6Vtbl
;
2905 window
->IHTMLPrivateWindow_iface
.lpVtbl
= &HTMLPrivateWindowVtbl
;
2906 window
->IDispatchEx_iface
.lpVtbl
= &WindowDispExVtbl
;
2907 window
->IServiceProvider_iface
.lpVtbl
= &ServiceProviderVtbl
;
2908 window
->ITravelLogClient_iface
.lpVtbl
= &TravelLogClientVtbl
;
2909 window
->IObjectIdentity_iface
.lpVtbl
= &ObjectIdentityVtbl
;
2915 static HRESULT
create_inner_window(HTMLOuterWindow
*outer_window
, IMoniker
*mon
, HTMLInnerWindow
**ret
)
2917 HTMLInnerWindow
*window
;
2919 window
= alloc_window(sizeof(HTMLInnerWindow
));
2921 return E_OUTOFMEMORY
;
2923 list_init(&window
->script_hosts
);
2924 list_init(&window
->bindings
);
2925 list_init(&window
->script_queue
);
2927 window
->base
.outer_window
= outer_window
;
2928 window
->base
.inner_window
= window
;
2930 init_dispex(&window
->event_target
.dispex
, (IUnknown
*)&window
->base
.IHTMLWindow2_iface
, &HTMLWindow_dispex
);
2932 window
->task_magic
= get_task_target_magic();
2935 IMoniker_AddRef(mon
);
2943 HRESULT
HTMLOuterWindow_Create(HTMLDocumentObj
*doc_obj
, nsIDOMWindow
*nswindow
,
2944 HTMLOuterWindow
*parent
, HTMLOuterWindow
**ret
)
2946 HTMLOuterWindow
*window
;
2949 window
= alloc_window(sizeof(HTMLOuterWindow
));
2951 return E_OUTOFMEMORY
;
2953 window
->base
.outer_window
= window
;
2954 window
->base
.inner_window
= NULL
;
2956 window
->window_ref
= heap_alloc(sizeof(windowref_t
));
2957 if(!window
->window_ref
) {
2959 return E_OUTOFMEMORY
;
2962 window
->doc_obj
= doc_obj
;
2964 window
->window_ref
->window
= window
;
2965 window
->window_ref
->ref
= 1;
2968 nsIDOMWindow_AddRef(nswindow
);
2969 window
->nswindow
= nswindow
;
2972 window
->scriptmode
= parent
? parent
->scriptmode
: SCRIPTMODE_GECKO
;
2973 window
->readystate
= READYSTATE_UNINITIALIZED
;
2975 hres
= create_pending_window(window
, NULL
);
2977 hres
= update_window_doc(window
->pending_window
);
2979 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
2983 hres
= CoInternetCreateSecurityManager(NULL
, &window
->secmgr
, 0);
2985 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
2989 window
->task_magic
= get_task_target_magic();
2991 list_init(&window
->children
);
2992 list_add_head(&window_list
, &window
->entry
);
2995 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
2997 window
->parent
= parent
;
2998 list_add_tail(&parent
->children
, &window
->sibling_entry
);
3001 TRACE("%p inner_window %p\n", window
, window
->base
.inner_window
);
3007 HRESULT
create_pending_window(HTMLOuterWindow
*outer_window
, nsChannelBSC
*channelbsc
)
3009 HTMLInnerWindow
*pending_window
;
3012 hres
= create_inner_window(outer_window
, outer_window
->mon
/* FIXME */, &pending_window
);
3017 IBindStatusCallback_AddRef(&channelbsc
->bsc
.IBindStatusCallback_iface
);
3018 pending_window
->bscallback
= channelbsc
;
3021 if(outer_window
->pending_window
) {
3022 abort_window_bindings(outer_window
->pending_window
);
3023 outer_window
->pending_window
->base
.outer_window
= NULL
;
3024 IHTMLWindow2_Release(&outer_window
->pending_window
->base
.IHTMLWindow2_iface
);
3027 outer_window
->pending_window
= pending_window
;
3031 HRESULT
update_window_doc(HTMLInnerWindow
*window
)
3033 HTMLOuterWindow
*outer_window
= window
->base
.outer_window
;
3034 nsIDOMHTMLDocument
*nshtmldoc
;
3035 nsIDOMDocument
*nsdoc
;
3039 assert(!window
->doc
);
3042 ERR("NULL outer window\n");
3043 return E_UNEXPECTED
;
3046 nsres
= nsIDOMWindow_GetDocument(outer_window
->nswindow
, &nsdoc
);
3047 if(NS_FAILED(nsres
) || !nsdoc
) {
3048 ERR("GetDocument failed: %08x\n", nsres
);
3052 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMHTMLDocument
, (void**)&nshtmldoc
);
3053 nsIDOMDocument_Release(nsdoc
);
3054 if(NS_FAILED(nsres
)) {
3055 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres
);
3059 hres
= create_doc_from_nsdoc(nshtmldoc
, outer_window
->doc_obj
, window
, &window
->doc
);
3060 nsIDOMHTMLDocument_Release(nshtmldoc
);
3064 if(outer_window
->doc_obj
->usermode
== EDITMODE
) {
3068 static const PRUnichar onW
[] = {'o','n',0};
3070 nsAString_InitDepend(&mode_str
, onW
);
3071 nsres
= nsIDOMHTMLDocument_SetDesignMode(window
->doc
->nsdoc
, &mode_str
);
3072 nsAString_Finish(&mode_str
);
3073 if(NS_FAILED(nsres
))
3074 ERR("SetDesignMode failed: %08x\n", nsres
);
3077 if(window
!= outer_window
->pending_window
) {
3078 ERR("not current pending window\n");
3082 if(outer_window
->base
.inner_window
)
3083 detach_inner_window(outer_window
->base
.inner_window
);
3084 outer_window
->base
.inner_window
= window
;
3085 outer_window
->pending_window
= NULL
;
3087 if(outer_window
->doc_obj
->basedoc
.window
== outer_window
|| !outer_window
->doc_obj
->basedoc
.window
) {
3088 if(outer_window
->doc_obj
->basedoc
.doc_node
)
3089 htmldoc_release(&outer_window
->doc_obj
->basedoc
.doc_node
->basedoc
);
3090 outer_window
->doc_obj
->basedoc
.doc_node
= window
->doc
;
3091 htmldoc_addref(&window
->doc
->basedoc
);
3097 HTMLOuterWindow
*nswindow_to_window(const nsIDOMWindow
*nswindow
)
3099 HTMLOuterWindow
*iter
;
3101 LIST_FOR_EACH_ENTRY(iter
, &window_list
, HTMLOuterWindow
, entry
) {
3102 if(iter
->nswindow
== nswindow
)