2 * Copyright 2006-2010 Jacek Caban for CodeWeavers
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
30 #include "wine/debug.h"
32 #include "mshtml_private.h"
33 #include "htmlevent.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 static struct list window_list
= LIST_INIT(window_list
);
40 static void window_set_docnode(HTMLWindow
*window
, HTMLDocumentNode
*doc_node
)
43 if(window
->doc_obj
&& window
== window
->doc_obj
->basedoc
.window
)
44 window
->doc
->basedoc
.cp_container
.forward_container
= NULL
;
45 abort_document_bindings(window
->doc
);
46 window
->doc
->basedoc
.window
= NULL
;
47 htmldoc_release(&window
->doc
->basedoc
);
49 window
->doc
= doc_node
;
51 htmldoc_addref(&doc_node
->basedoc
);
53 if(window
->doc_obj
&& window
->doc_obj
->basedoc
.window
== window
) {
54 if(window
->doc_obj
->basedoc
.doc_node
)
55 htmldoc_release(&window
->doc_obj
->basedoc
.doc_node
->basedoc
);
56 window
->doc_obj
->basedoc
.doc_node
= doc_node
;
58 htmldoc_addref(&doc_node
->basedoc
);
61 if(doc_node
&& window
->doc_obj
&& window
->doc_obj
->usermode
== EDITMODE
) {
62 nsIDOMNSHTMLDocument
*nshtmldoc
;
66 static const PRUnichar onW
[] = {'o','n',0};
68 nsres
= nsIDOMHTMLDocument_QueryInterface(doc_node
->nsdoc
, &IID_nsIDOMNSHTMLDocument
, (void**)&nshtmldoc
);
69 if(NS_SUCCEEDED(nsres
)) {
70 nsAString_Init(&mode_str
, onW
);
71 nsres
= nsIDOMNSHTMLDocument_SetDesignMode(nshtmldoc
, &mode_str
);
72 nsAString_Finish(&mode_str
);
73 nsIDOMNSHTMLDocument_Release(nshtmldoc
);
75 ERR("SetDesignMode failed: %08x\n", nsres
);
77 ERR("Could not get nsIDOMNSHTMLDocument interface: %08x\n", nsres
);
82 nsIDOMWindow
*get_nsdoc_window(nsIDOMDocument
*nsdoc
)
84 nsIDOMDocumentView
*nsdocview
;
85 nsIDOMAbstractView
*nsview
;
86 nsIDOMWindow
*nswindow
;
89 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMDocumentView
, (void**)&nsdocview
);
90 nsIDOMDocument_Release(nsdoc
);
91 if(NS_FAILED(nsres
)) {
92 ERR("Could not get nsIDOMDocumentView iface: %08x\n", nsres
);
96 nsres
= nsIDOMDocumentView_GetDefaultView(nsdocview
, &nsview
);
97 nsIDOMDocumentView_Release(nsdocview
);
98 if(NS_FAILED(nsres
)) {
99 ERR("GetDefaultView failed: %08x\n", nsres
);
103 nsres
= nsIDOMAbstractView_QueryInterface(nsview
, &IID_nsIDOMWindow
, (void**)&nswindow
);
104 nsIDOMAbstractView_Release(nsview
);
105 if(NS_FAILED(nsres
)) {
106 ERR("Coult not get nsIDOMWindow iface: %08x\n", nsres
);
113 static void release_children(HTMLWindow
*This
)
117 while(!list_empty(&This
->children
)) {
118 child
= LIST_ENTRY(list_tail(&This
->children
), HTMLWindow
, sibling_entry
);
120 list_remove(&child
->sibling_entry
);
121 child
->parent
= NULL
;
122 IHTMLWindow2_Release(&child
->IHTMLWindow2_iface
);
126 static HRESULT
get_location(HTMLWindow
*This
, HTMLLocation
**ret
)
129 IHTMLLocation_AddRef(&This
->location
->IHTMLLocation_iface
);
133 hres
= HTMLLocation_Create(This
, &This
->location
);
138 *ret
= This
->location
;
142 static inline HRESULT
set_window_event(HTMLWindow
*window
, eventid_t eid
, VARIANT
*var
)
145 FIXME("No document\n");
149 return set_event_handler(&window
->doc
->body_event_target
, NULL
, window
->doc
, eid
, var
);
152 static inline HRESULT
get_window_event(HTMLWindow
*window
, eventid_t eid
, VARIANT
*var
)
155 FIXME("No document\n");
159 return get_event_handler(&window
->doc
->body_event_target
, eid
, var
);
162 static inline HTMLWindow
*impl_from_IHTMLWindow2(IHTMLWindow2
*iface
)
164 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow2_iface
);
167 static HRESULT WINAPI
HTMLWindow2_QueryInterface(IHTMLWindow2
*iface
, REFIID riid
, void **ppv
)
169 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
173 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
174 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
175 *ppv
= &This
->IHTMLWindow2_iface
;
176 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
177 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
178 *ppv
= &This
->IHTMLWindow2_iface
;
179 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
180 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
181 *ppv
= &This
->IDispatchEx_iface
;
182 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2
, riid
)) {
183 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This
, ppv
);
184 *ppv
= &This
->IHTMLWindow2_iface
;
185 }else if(IsEqualGUID(&IID_IHTMLWindow2
, riid
)) {
186 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This
, ppv
);
187 *ppv
= &This
->IHTMLWindow2_iface
;
188 }else if(IsEqualGUID(&IID_IHTMLWindow3
, riid
)) {
189 TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This
, ppv
);
190 *ppv
= &This
->IHTMLWindow3_iface
;
191 }else if(IsEqualGUID(&IID_IHTMLWindow4
, riid
)) {
192 TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This
, ppv
);
193 *ppv
= &This
->IHTMLWindow4_iface
;
194 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow
, riid
)) {
195 TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This
, ppv
);
196 *ppv
= &This
->IHTMLPrivateWindow_iface
;
197 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
198 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
199 *ppv
= &This
->IServiceProvider_iface
;
200 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
201 return *ppv
? S_OK
: E_NOINTERFACE
;
205 IUnknown_AddRef((IUnknown
*)*ppv
);
209 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
210 return E_NOINTERFACE
;
213 static ULONG WINAPI
HTMLWindow2_AddRef(IHTMLWindow2
*iface
)
215 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
216 LONG ref
= InterlockedIncrement(&This
->ref
);
218 TRACE("(%p) ref=%d\n", This
, ref
);
223 static ULONG WINAPI
HTMLWindow2_Release(IHTMLWindow2
*iface
)
225 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
226 LONG ref
= InterlockedDecrement(&This
->ref
);
228 TRACE("(%p) ref=%d\n", This
, ref
);
233 remove_target_tasks(This
->task_magic
);
234 set_window_bscallback(This
, NULL
);
235 set_current_mon(This
, NULL
);
236 window_set_docnode(This
, NULL
);
237 release_children(This
);
240 IInternetSecurityManager_Release(This
->secmgr
);
242 if(This
->frame_element
)
243 This
->frame_element
->content_window
= NULL
;
245 if(This
->option_factory
) {
246 This
->option_factory
->window
= NULL
;
247 IHTMLOptionElementFactory_Release(&This
->option_factory
->IHTMLOptionElementFactory_iface
);
250 if(This
->image_factory
) {
251 This
->image_factory
->window
= NULL
;
252 IHTMLImageElementFactory_Release(&This
->image_factory
->IHTMLImageElementFactory_iface
);
256 This
->location
->window
= NULL
;
257 IHTMLLocation_Release(&This
->location
->IHTMLLocation_iface
);
261 IHTMLScreen_Release(This
->screen
);
263 for(i
=0; i
< This
->global_prop_cnt
; i
++)
264 heap_free(This
->global_props
[i
].name
);
266 This
->window_ref
->window
= NULL
;
267 windowref_release(This
->window_ref
);
269 heap_free(This
->global_props
);
270 release_script_hosts(This
);
273 nsIDOMWindow_Release(This
->nswindow
);
275 list_remove(&This
->entry
);
276 release_dispex(&This
->dispex
);
283 static HRESULT WINAPI
HTMLWindow2_GetTypeInfoCount(IHTMLWindow2
*iface
, UINT
*pctinfo
)
285 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
287 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
290 static HRESULT WINAPI
HTMLWindow2_GetTypeInfo(IHTMLWindow2
*iface
, UINT iTInfo
,
291 LCID lcid
, ITypeInfo
**ppTInfo
)
293 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
295 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
298 static HRESULT WINAPI
HTMLWindow2_GetIDsOfNames(IHTMLWindow2
*iface
, REFIID riid
,
299 LPOLESTR
*rgszNames
, UINT cNames
,
300 LCID lcid
, DISPID
*rgDispId
)
302 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
304 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
308 static HRESULT WINAPI
HTMLWindow2_Invoke(IHTMLWindow2
*iface
, DISPID dispIdMember
,
309 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
310 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
312 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
314 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
315 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
318 static HRESULT
get_frame_by_index(nsIDOMWindowCollection
*nsFrames
, PRUint32 index
, HTMLWindow
**ret
)
321 nsIDOMWindow
*nsWindow
;
324 nsres
= nsIDOMWindowCollection_GetLength(nsFrames
, &length
);
325 if(NS_FAILED(nsres
)) {
326 FIXME("nsIDOMWindowCollection_GetLength failed: 0x%08x\n", nsres
);
331 return DISP_E_MEMBERNOTFOUND
;
333 nsres
= nsIDOMWindowCollection_Item(nsFrames
, index
, &nsWindow
);
334 if(NS_FAILED(nsres
)) {
335 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
339 *ret
= nswindow_to_window(nsWindow
);
341 nsIDOMWindow_Release(nsWindow
);
346 static HRESULT WINAPI
HTMLWindow2_item(IHTMLWindow2
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
348 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
349 nsIDOMWindowCollection
*nsFrames
;
354 TRACE("(%p)->(%p %p)\n", This
, pvarIndex
, pvarResult
);
356 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nsFrames
);
357 if(NS_FAILED(nsres
)) {
358 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres
);
362 if(V_VT(pvarIndex
) == VT_I4
) {
363 int index
= V_I4(pvarIndex
);
364 TRACE("Getting index %d\n", index
);
366 hres
= DISP_E_MEMBERNOTFOUND
;
369 hres
= get_frame_by_index(nsFrames
, index
, &window
);
372 }else if(V_VT(pvarIndex
) == VT_UINT
) {
373 unsigned int index
= V_UINT(pvarIndex
);
374 TRACE("Getting index %u\n", index
);
375 hres
= get_frame_by_index(nsFrames
, index
, &window
);
378 }else if(V_VT(pvarIndex
) == VT_BSTR
) {
379 BSTR str
= V_BSTR(pvarIndex
);
382 TRACE("Getting name %s\n", wine_dbgstr_w(str
));
384 nsres
= nsIDOMWindowCollection_GetLength(nsFrames
, &length
);
387 for(i
= 0; i
< length
&& !window
; ++i
) {
388 HTMLWindow
*cur_window
;
389 nsIDOMWindow
*nsWindow
;
392 nsres
= nsIDOMWindowCollection_Item(nsFrames
, i
, &nsWindow
);
393 if(NS_FAILED(nsres
)) {
394 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
399 cur_window
= nswindow_to_window(nsWindow
);
401 nsIDOMWindow_Release(nsWindow
);
403 hres
= IHTMLElement_get_id(&cur_window
->frame_element
->element
.IHTMLElement_iface
, &id
);
405 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres
);
409 if(!strcmpW(id
, str
))
416 hres
= DISP_E_MEMBERNOTFOUND
;
424 IHTMLWindow2_AddRef(&window
->IHTMLWindow2_iface
);
425 V_VT(pvarResult
) = VT_DISPATCH
;
426 V_DISPATCH(pvarResult
) = (IDispatch
*)window
;
431 nsIDOMWindowCollection_Release(nsFrames
);
436 static HRESULT WINAPI
HTMLWindow2_get_length(IHTMLWindow2
*iface
, LONG
*p
)
438 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
439 nsIDOMWindowCollection
*nscollection
;
443 TRACE("(%p)->(%p)\n", This
, p
);
445 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nscollection
);
446 if(NS_FAILED(nsres
)) {
447 ERR("GetFrames failed: %08x\n", nsres
);
451 nsres
= nsIDOMWindowCollection_GetLength(nscollection
, &length
);
452 nsIDOMWindowCollection_Release(nscollection
);
453 if(NS_FAILED(nsres
)) {
454 ERR("GetLength failed: %08x\n", nsres
);
462 static HRESULT WINAPI
HTMLWindow2_get_frames(IHTMLWindow2
*iface
, IHTMLFramesCollection2
**p
)
464 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
465 FIXME("(%p)->(%p): semi-stub\n", This
, p
);
467 /* FIXME: Should return a separate Window object */
468 *p
= (IHTMLFramesCollection2
*)&This
->IHTMLWindow2_iface
;
469 HTMLWindow2_AddRef(iface
);
473 static HRESULT WINAPI
HTMLWindow2_put_defaultStatus(IHTMLWindow2
*iface
, BSTR v
)
475 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
476 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
480 static HRESULT WINAPI
HTMLWindow2_get_defaultStatus(IHTMLWindow2
*iface
, BSTR
*p
)
482 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
483 FIXME("(%p)->(%p)\n", This
, p
);
487 static HRESULT WINAPI
HTMLWindow2_put_status(IHTMLWindow2
*iface
, BSTR v
)
489 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
490 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
494 static HRESULT WINAPI
HTMLWindow2_get_status(IHTMLWindow2
*iface
, BSTR
*p
)
496 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
497 FIXME("(%p)->(%p)\n", This
, p
);
501 static HRESULT WINAPI
HTMLWindow2_setTimeout(IHTMLWindow2
*iface
, BSTR expression
,
502 LONG msec
, VARIANT
*language
, LONG
*timerID
)
504 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
507 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
509 V_VT(&expr_var
) = VT_BSTR
;
510 V_BSTR(&expr_var
) = expression
;
512 return IHTMLWindow3_setTimeout(&This
->IHTMLWindow3_iface
, &expr_var
, msec
, language
, timerID
);
515 static HRESULT WINAPI
HTMLWindow2_clearTimeout(IHTMLWindow2
*iface
, LONG timerID
)
517 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
519 TRACE("(%p)->(%d)\n", This
, timerID
);
521 return clear_task_timer(&This
->doc
->basedoc
, FALSE
, timerID
);
524 #define MAX_MESSAGE_LEN 2000
526 static HRESULT WINAPI
HTMLWindow2_alert(IHTMLWindow2
*iface
, BSTR message
)
528 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
529 WCHAR title
[100], *msg
= message
;
532 TRACE("(%p)->(%s)\n", This
, debugstr_w(message
));
534 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, title
,
535 sizeof(title
)/sizeof(WCHAR
))) {
536 WARN("Could not load message box title: %d\n", GetLastError());
540 len
= SysStringLen(message
);
541 if(len
> MAX_MESSAGE_LEN
) {
542 msg
= heap_alloc((MAX_MESSAGE_LEN
+1)*sizeof(WCHAR
));
544 return E_OUTOFMEMORY
;
545 memcpy(msg
, message
, MAX_MESSAGE_LEN
*sizeof(WCHAR
));
546 msg
[MAX_MESSAGE_LEN
] = 0;
549 MessageBoxW(This
->doc_obj
->hwnd
, msg
, title
, MB_ICONWARNING
);
555 static HRESULT WINAPI
HTMLWindow2_confirm(IHTMLWindow2
*iface
, BSTR message
,
556 VARIANT_BOOL
*confirmed
)
558 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
561 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(message
), confirmed
);
563 if(!confirmed
) return E_INVALIDARG
;
565 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
566 sizeof(wszTitle
)/sizeof(WCHAR
))) {
567 WARN("Could not load message box title: %d\n", GetLastError());
568 *confirmed
= VARIANT_TRUE
;
572 if(MessageBoxW(This
->doc_obj
->hwnd
, message
, wszTitle
,
573 MB_OKCANCEL
|MB_ICONQUESTION
)==IDOK
)
574 *confirmed
= VARIANT_TRUE
;
575 else *confirmed
= VARIANT_FALSE
;
587 static INT_PTR CALLBACK
prompt_dlgproc(HWND hwnd
, UINT msg
,
588 WPARAM wparam
, LPARAM lparam
)
594 prompt_arg
*arg
= (prompt_arg
*)lparam
;
597 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
598 sizeof(wszTitle
)/sizeof(WCHAR
))) {
599 WARN("Could not load message box title: %d\n", GetLastError());
600 EndDialog(hwnd
, wparam
);
604 SetWindowLongPtrW(hwnd
, DWLP_USER
, lparam
);
605 SetWindowTextW(hwnd
, wszTitle
);
606 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_PROMPT
), arg
->message
);
607 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_EDIT
), arg
->dststr
);
613 case MAKEWPARAM(IDCANCEL
, BN_CLICKED
):
614 EndDialog(hwnd
, wparam
);
616 case MAKEWPARAM(IDOK
, BN_CLICKED
):
619 (prompt_arg
*)GetWindowLongPtrW(hwnd
, DWLP_USER
);
620 HWND hwndPrompt
= GetDlgItem(hwnd
, ID_PROMPT_EDIT
);
621 INT len
= GetWindowTextLengthW(hwndPrompt
);
625 EndDialog(hwnd
, wparam
);
629 V_VT(arg
->textdata
) = VT_BSTR
;
630 if(!len
&& !arg
->dststr
)
631 V_BSTR(arg
->textdata
) = NULL
;
634 V_BSTR(arg
->textdata
) = SysAllocStringLen(NULL
, len
);
635 GetWindowTextW(hwndPrompt
, V_BSTR(arg
->textdata
), len
+1);
637 EndDialog(hwnd
, wparam
);
643 EndDialog(hwnd
, IDCANCEL
);
650 static HRESULT WINAPI
HTMLWindow2_prompt(IHTMLWindow2
*iface
, BSTR message
,
651 BSTR dststr
, VARIANT
*textdata
)
653 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
656 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(message
), debugstr_w(dststr
), textdata
);
658 if(textdata
) V_VT(textdata
) = VT_NULL
;
660 arg
.message
= message
;
662 arg
.textdata
= textdata
;
664 DialogBoxParamW(hInst
, MAKEINTRESOURCEW(ID_PROMPT_DIALOG
),
665 This
->doc_obj
->hwnd
, prompt_dlgproc
, (LPARAM
)&arg
);
669 static HRESULT WINAPI
HTMLWindow2_get_Image(IHTMLWindow2
*iface
, IHTMLImageElementFactory
**p
)
671 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
673 TRACE("(%p)->(%p)\n", This
, p
);
675 if(!This
->image_factory
)
676 This
->image_factory
= HTMLImageElementFactory_Create(This
);
678 *p
= &This
->image_factory
->IHTMLImageElementFactory_iface
;
679 IHTMLImageElementFactory_AddRef(*p
);
684 static HRESULT WINAPI
HTMLWindow2_get_location(IHTMLWindow2
*iface
, IHTMLLocation
**p
)
686 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
687 HTMLLocation
*location
;
690 TRACE("(%p)->(%p)\n", This
, p
);
692 hres
= get_location(This
, &location
);
696 *p
= &location
->IHTMLLocation_iface
;
700 static HRESULT WINAPI
HTMLWindow2_get_history(IHTMLWindow2
*iface
, IOmHistory
**p
)
702 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
703 FIXME("(%p)->(%p)\n", This
, p
);
707 static HRESULT WINAPI
HTMLWindow2_close(IHTMLWindow2
*iface
)
709 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
710 FIXME("(%p)->()\n", This
);
714 static HRESULT WINAPI
HTMLWindow2_put_opener(IHTMLWindow2
*iface
, VARIANT v
)
716 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
717 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
721 static HRESULT WINAPI
HTMLWindow2_get_opener(IHTMLWindow2
*iface
, VARIANT
*p
)
723 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
724 FIXME("(%p)->(%p)\n", This
, p
);
728 static HRESULT WINAPI
HTMLWindow2_get_navigator(IHTMLWindow2
*iface
, IOmNavigator
**p
)
730 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
732 TRACE("(%p)->(%p)\n", This
, p
);
734 *p
= OmNavigator_Create();
738 static HRESULT WINAPI
HTMLWindow2_put_name(IHTMLWindow2
*iface
, BSTR v
)
740 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
744 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
746 nsAString_InitDepend(&name_str
, v
);
747 nsres
= nsIDOMWindow_SetName(This
->nswindow
, &name_str
);
748 nsAString_Finish(&name_str
);
750 ERR("SetName failed: %08x\n", nsres
);
755 static HRESULT WINAPI
HTMLWindow2_get_name(IHTMLWindow2
*iface
, BSTR
*p
)
757 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
762 TRACE("(%p)->(%p)\n", This
, p
);
764 nsAString_Init(&name_str
, NULL
);
765 nsres
= nsIDOMWindow_GetName(This
->nswindow
, &name_str
);
766 if(NS_SUCCEEDED(nsres
)) {
767 const PRUnichar
*name
;
769 nsAString_GetData(&name_str
, &name
);
771 *p
= SysAllocString(name
);
772 hres
= *p
? S_OK
: E_OUTOFMEMORY
;
778 ERR("GetName failed: %08x\n", nsres
);
781 nsAString_Finish(&name_str
);
786 static HRESULT WINAPI
HTMLWindow2_get_parent(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
788 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
789 TRACE("(%p)->(%p)\n", This
, p
);
792 *p
= &This
->parent
->IHTMLWindow2_iface
;
793 IHTMLWindow2_AddRef(*p
);
800 static HRESULT WINAPI
HTMLWindow2_open(IHTMLWindow2
*iface
, BSTR url
, BSTR name
,
801 BSTR features
, VARIANT_BOOL replace
, IHTMLWindow2
**pomWindowResult
)
803 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
804 FIXME("(%p)->(%s %s %s %x %p)\n", This
, debugstr_w(url
), debugstr_w(name
),
805 debugstr_w(features
), replace
, pomWindowResult
);
809 static HRESULT WINAPI
HTMLWindow2_get_self(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
811 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
813 TRACE("(%p)->(%p)\n", This
, p
);
815 /* FIXME: We should return kind of proxy window here. */
816 IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
817 *p
= &This
->IHTMLWindow2_iface
;
821 static HRESULT WINAPI
HTMLWindow2_get_top(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
823 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
825 TRACE("(%p)->(%p)\n", This
, p
);
830 *p
= &curr
->IHTMLWindow2_iface
;
831 IHTMLWindow2_AddRef(*p
);
836 static HRESULT WINAPI
HTMLWindow2_get_window(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
838 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
840 TRACE("(%p)->(%p)\n", This
, p
);
842 /* FIXME: We should return kind of proxy window here. */
843 IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
844 *p
= &This
->IHTMLWindow2_iface
;
848 static HRESULT WINAPI
HTMLWindow2_navigate(IHTMLWindow2
*iface
, BSTR url
)
850 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
851 FIXME("(%p)->(%s)\n", This
, debugstr_w(url
));
855 static HRESULT WINAPI
HTMLWindow2_put_onfocus(IHTMLWindow2
*iface
, VARIANT v
)
857 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
858 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
862 static HRESULT WINAPI
HTMLWindow2_get_onfocus(IHTMLWindow2
*iface
, VARIANT
*p
)
864 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
865 FIXME("(%p)->(%p)\n", This
, p
);
869 static HRESULT WINAPI
HTMLWindow2_put_onblur(IHTMLWindow2
*iface
, VARIANT v
)
871 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
872 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
876 static HRESULT WINAPI
HTMLWindow2_get_onblur(IHTMLWindow2
*iface
, VARIANT
*p
)
878 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
879 FIXME("(%p)->(%p)\n", This
, p
);
883 static HRESULT WINAPI
HTMLWindow2_put_onload(IHTMLWindow2
*iface
, VARIANT v
)
885 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
887 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
889 return set_window_event(This
, EVENTID_LOAD
, &v
);
892 static HRESULT WINAPI
HTMLWindow2_get_onload(IHTMLWindow2
*iface
, VARIANT
*p
)
894 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
896 TRACE("(%p)->(%p)\n", This
, p
);
898 return get_window_event(This
, EVENTID_LOAD
, p
);
901 static HRESULT WINAPI
HTMLWindow2_put_onbeforeunload(IHTMLWindow2
*iface
, VARIANT v
)
903 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
905 TRACE("(%p)->(v(%d))\n", This
, V_VT(&v
));
907 return set_window_event(This
, EVENTID_BEFOREUNLOAD
, &v
);
910 static HRESULT WINAPI
HTMLWindow2_get_onbeforeunload(IHTMLWindow2
*iface
, VARIANT
*p
)
912 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
914 TRACE("(%p)->(%p)\n", This
, p
);
916 return get_window_event(This
, EVENTID_BEFOREUNLOAD
, p
);
919 static HRESULT WINAPI
HTMLWindow2_put_onunload(IHTMLWindow2
*iface
, VARIANT v
)
921 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
922 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
926 static HRESULT WINAPI
HTMLWindow2_get_onunload(IHTMLWindow2
*iface
, VARIANT
*p
)
928 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
929 FIXME("(%p)->(%p)\n", This
, p
);
933 static HRESULT WINAPI
HTMLWindow2_put_onhelp(IHTMLWindow2
*iface
, VARIANT v
)
935 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
936 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
940 static HRESULT WINAPI
HTMLWindow2_get_onhelp(IHTMLWindow2
*iface
, VARIANT
*p
)
942 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
943 FIXME("(%p)->(%p)\n", This
, p
);
947 static HRESULT WINAPI
HTMLWindow2_put_onerror(IHTMLWindow2
*iface
, VARIANT v
)
949 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
950 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
954 static HRESULT WINAPI
HTMLWindow2_get_onerror(IHTMLWindow2
*iface
, VARIANT
*p
)
956 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
957 FIXME("(%p)->(%p)\n", This
, p
);
961 static HRESULT WINAPI
HTMLWindow2_put_onresize(IHTMLWindow2
*iface
, VARIANT v
)
963 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
965 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
967 return set_window_event(This
, EVENTID_RESIZE
, &v
);
970 static HRESULT WINAPI
HTMLWindow2_get_onresize(IHTMLWindow2
*iface
, VARIANT
*p
)
972 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
974 TRACE("(%p)->(%p)\n", This
, p
);
976 return get_window_event(This
, EVENTID_RESIZE
, p
);
979 static HRESULT WINAPI
HTMLWindow2_put_onscroll(IHTMLWindow2
*iface
, VARIANT v
)
981 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
982 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
986 static HRESULT WINAPI
HTMLWindow2_get_onscroll(IHTMLWindow2
*iface
, VARIANT
*p
)
988 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
989 FIXME("(%p)->(%p)\n", This
, p
);
993 static HRESULT WINAPI
HTMLWindow2_get_document(IHTMLWindow2
*iface
, IHTMLDocument2
**p
)
995 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
997 TRACE("(%p)->(%p)\n", This
, p
);
1000 /* FIXME: We should return a wrapper object here */
1001 *p
= &This
->doc
->basedoc
.IHTMLDocument2_iface
;
1002 IHTMLDocument2_AddRef(*p
);
1010 static HRESULT WINAPI
HTMLWindow2_get_event(IHTMLWindow2
*iface
, IHTMLEventObj
**p
)
1012 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1014 TRACE("(%p)->(%p)\n", This
, p
);
1017 IHTMLEventObj_AddRef(This
->event
);
1022 static HRESULT WINAPI
HTMLWindow2_get__newEnum(IHTMLWindow2
*iface
, IUnknown
**p
)
1024 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1025 FIXME("(%p)->(%p)\n", This
, p
);
1029 static HRESULT WINAPI
HTMLWindow2_showModalDialog(IHTMLWindow2
*iface
, BSTR dialog
,
1030 VARIANT
*varArgIn
, VARIANT
*varOptions
, VARIANT
*varArgOut
)
1032 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1033 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(dialog
), varArgIn
, varOptions
, varArgOut
);
1037 static HRESULT WINAPI
HTMLWindow2_showHelp(IHTMLWindow2
*iface
, BSTR helpURL
, VARIANT helpArg
,
1040 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1041 FIXME("(%p)->(%s v(%d) %s)\n", This
, debugstr_w(helpURL
), V_VT(&helpArg
), debugstr_w(features
));
1045 static HRESULT WINAPI
HTMLWindow2_get_screen(IHTMLWindow2
*iface
, IHTMLScreen
**p
)
1047 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1049 TRACE("(%p)->(%p)\n", This
, p
);
1054 hres
= HTMLScreen_Create(&This
->screen
);
1060 IHTMLScreen_AddRef(This
->screen
);
1064 static HRESULT WINAPI
HTMLWindow2_get_Option(IHTMLWindow2
*iface
, IHTMLOptionElementFactory
**p
)
1066 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1068 TRACE("(%p)->(%p)\n", This
, p
);
1070 if(!This
->option_factory
)
1071 This
->option_factory
= HTMLOptionElementFactory_Create(This
);
1073 *p
= &This
->option_factory
->IHTMLOptionElementFactory_iface
;
1074 IHTMLOptionElementFactory_AddRef(*p
);
1079 static HRESULT WINAPI
HTMLWindow2_focus(IHTMLWindow2
*iface
)
1081 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1083 TRACE("(%p)->()\n", This
);
1086 SetFocus(This
->doc_obj
->hwnd
);
1090 static HRESULT WINAPI
HTMLWindow2_get_closed(IHTMLWindow2
*iface
, VARIANT_BOOL
*p
)
1092 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1093 FIXME("(%p)->(%p)\n", This
, p
);
1097 static HRESULT WINAPI
HTMLWindow2_blur(IHTMLWindow2
*iface
)
1099 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1100 FIXME("(%p)->()\n", This
);
1104 static HRESULT WINAPI
HTMLWindow2_scroll(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1106 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1107 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1111 static HRESULT WINAPI
HTMLWindow2_get_clientInformation(IHTMLWindow2
*iface
, IOmNavigator
**p
)
1113 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1114 FIXME("(%p)->(%p)\n", This
, p
);
1118 static HRESULT WINAPI
HTMLWindow2_setInterval(IHTMLWindow2
*iface
, BSTR expression
,
1119 LONG msec
, VARIANT
*language
, LONG
*timerID
)
1121 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1124 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
1126 V_VT(&expr
) = VT_BSTR
;
1127 V_BSTR(&expr
) = expression
;
1128 return IHTMLWindow3_setInterval(&This
->IHTMLWindow3_iface
, &expr
, msec
, language
, timerID
);
1131 static HRESULT WINAPI
HTMLWindow2_clearInterval(IHTMLWindow2
*iface
, LONG timerID
)
1133 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1135 TRACE("(%p)->(%d)\n", This
, timerID
);
1137 return clear_task_timer(&This
->doc
->basedoc
, TRUE
, timerID
);
1140 static HRESULT WINAPI
HTMLWindow2_put_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT v
)
1142 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1143 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
1147 static HRESULT WINAPI
HTMLWindow2_get_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT
*p
)
1149 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1150 FIXME("(%p)->(%p)\n", This
, p
);
1154 static HRESULT WINAPI
HTMLWindow2_execScript(IHTMLWindow2
*iface
, BSTR scode
, BSTR language
,
1157 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1159 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(scode
), debugstr_w(language
), pvarRet
);
1161 return exec_script(This
, scode
, language
, pvarRet
);
1164 static HRESULT WINAPI
HTMLWindow2_toString(IHTMLWindow2
*iface
, BSTR
*String
)
1166 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1168 static const WCHAR objectW
[] = {'[','o','b','j','e','c','t',']',0};
1170 TRACE("(%p)->(%p)\n", This
, String
);
1173 return E_INVALIDARG
;
1175 *String
= SysAllocString(objectW
);
1176 return *String
? S_OK
: E_OUTOFMEMORY
;
1179 static HRESULT WINAPI
HTMLWindow2_scrollBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1181 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1184 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1186 nsres
= nsIDOMWindow_ScrollBy(This
->nswindow
, x
, y
);
1187 if(NS_FAILED(nsres
))
1188 ERR("ScrollBy failed: %08x\n", nsres
);
1193 static HRESULT WINAPI
HTMLWindow2_scrollTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1195 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1198 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1200 nsres
= nsIDOMWindow_ScrollTo(This
->nswindow
, x
, y
);
1201 if(NS_FAILED(nsres
))
1202 ERR("ScrollTo failed: %08x\n", nsres
);
1207 static HRESULT WINAPI
HTMLWindow2_moveTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1209 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1210 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1214 static HRESULT WINAPI
HTMLWindow2_moveBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1216 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1217 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1221 static HRESULT WINAPI
HTMLWindow2_resizeTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1223 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1224 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1228 static HRESULT WINAPI
HTMLWindow2_resizeBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1230 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1231 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1235 static HRESULT WINAPI
HTMLWindow2_get_external(IHTMLWindow2
*iface
, IDispatch
**p
)
1237 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1239 TRACE("(%p)->(%p)\n", This
, p
);
1243 if(!This
->doc_obj
->hostui
)
1246 return IDocHostUIHandler_GetExternal(This
->doc_obj
->hostui
, p
);
1249 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl
= {
1250 HTMLWindow2_QueryInterface
,
1252 HTMLWindow2_Release
,
1253 HTMLWindow2_GetTypeInfoCount
,
1254 HTMLWindow2_GetTypeInfo
,
1255 HTMLWindow2_GetIDsOfNames
,
1258 HTMLWindow2_get_length
,
1259 HTMLWindow2_get_frames
,
1260 HTMLWindow2_put_defaultStatus
,
1261 HTMLWindow2_get_defaultStatus
,
1262 HTMLWindow2_put_status
,
1263 HTMLWindow2_get_status
,
1264 HTMLWindow2_setTimeout
,
1265 HTMLWindow2_clearTimeout
,
1267 HTMLWindow2_confirm
,
1269 HTMLWindow2_get_Image
,
1270 HTMLWindow2_get_location
,
1271 HTMLWindow2_get_history
,
1273 HTMLWindow2_put_opener
,
1274 HTMLWindow2_get_opener
,
1275 HTMLWindow2_get_navigator
,
1276 HTMLWindow2_put_name
,
1277 HTMLWindow2_get_name
,
1278 HTMLWindow2_get_parent
,
1280 HTMLWindow2_get_self
,
1281 HTMLWindow2_get_top
,
1282 HTMLWindow2_get_window
,
1283 HTMLWindow2_navigate
,
1284 HTMLWindow2_put_onfocus
,
1285 HTMLWindow2_get_onfocus
,
1286 HTMLWindow2_put_onblur
,
1287 HTMLWindow2_get_onblur
,
1288 HTMLWindow2_put_onload
,
1289 HTMLWindow2_get_onload
,
1290 HTMLWindow2_put_onbeforeunload
,
1291 HTMLWindow2_get_onbeforeunload
,
1292 HTMLWindow2_put_onunload
,
1293 HTMLWindow2_get_onunload
,
1294 HTMLWindow2_put_onhelp
,
1295 HTMLWindow2_get_onhelp
,
1296 HTMLWindow2_put_onerror
,
1297 HTMLWindow2_get_onerror
,
1298 HTMLWindow2_put_onresize
,
1299 HTMLWindow2_get_onresize
,
1300 HTMLWindow2_put_onscroll
,
1301 HTMLWindow2_get_onscroll
,
1302 HTMLWindow2_get_document
,
1303 HTMLWindow2_get_event
,
1304 HTMLWindow2_get__newEnum
,
1305 HTMLWindow2_showModalDialog
,
1306 HTMLWindow2_showHelp
,
1307 HTMLWindow2_get_screen
,
1308 HTMLWindow2_get_Option
,
1310 HTMLWindow2_get_closed
,
1313 HTMLWindow2_get_clientInformation
,
1314 HTMLWindow2_setInterval
,
1315 HTMLWindow2_clearInterval
,
1316 HTMLWindow2_put_offscreenBuffering
,
1317 HTMLWindow2_get_offscreenBuffering
,
1318 HTMLWindow2_execScript
,
1319 HTMLWindow2_toString
,
1320 HTMLWindow2_scrollBy
,
1321 HTMLWindow2_scrollTo
,
1324 HTMLWindow2_resizeTo
,
1325 HTMLWindow2_resizeBy
,
1326 HTMLWindow2_get_external
1329 static inline HTMLWindow
*impl_from_IHTMLWindow3(IHTMLWindow3
*iface
)
1331 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow3_iface
);
1334 static HRESULT WINAPI
HTMLWindow3_QueryInterface(IHTMLWindow3
*iface
, REFIID riid
, void **ppv
)
1336 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1338 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1341 static ULONG WINAPI
HTMLWindow3_AddRef(IHTMLWindow3
*iface
)
1343 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1345 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1348 static ULONG WINAPI
HTMLWindow3_Release(IHTMLWindow3
*iface
)
1350 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1352 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1355 static HRESULT WINAPI
HTMLWindow3_GetTypeInfoCount(IHTMLWindow3
*iface
, UINT
*pctinfo
)
1357 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1359 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1362 static HRESULT WINAPI
HTMLWindow3_GetTypeInfo(IHTMLWindow3
*iface
, UINT iTInfo
,
1363 LCID lcid
, ITypeInfo
**ppTInfo
)
1365 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1367 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1370 static HRESULT WINAPI
HTMLWindow3_GetIDsOfNames(IHTMLWindow3
*iface
, REFIID riid
,
1371 LPOLESTR
*rgszNames
, UINT cNames
,
1372 LCID lcid
, DISPID
*rgDispId
)
1374 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1376 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1380 static HRESULT WINAPI
HTMLWindow3_Invoke(IHTMLWindow3
*iface
, DISPID dispIdMember
,
1381 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1382 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1384 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1386 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1387 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1390 static HRESULT WINAPI
HTMLWindow3_get_screenLeft(IHTMLWindow3
*iface
, LONG
*p
)
1392 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1393 FIXME("(%p)->(%p)\n", This
, p
);
1397 static HRESULT WINAPI
HTMLWindow3_get_screenTop(IHTMLWindow3
*iface
, LONG
*p
)
1399 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1400 FIXME("(%p)->(%p)\n", This
, p
);
1404 static HRESULT WINAPI
HTMLWindow3_attachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
, VARIANT_BOOL
*pfResult
)
1406 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1408 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(event
), pDisp
, pfResult
);
1411 FIXME("No document\n");
1415 return attach_event(&This
->doc
->body_event_target
, NULL
, &This
->doc
->basedoc
, event
, pDisp
, pfResult
);
1418 static HRESULT WINAPI
HTMLWindow3_detachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
)
1420 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1421 FIXME("(%p)->()\n", This
);
1425 static HRESULT
window_set_timer(HTMLWindow
*This
, VARIANT
*expr
, LONG msec
, VARIANT
*language
,
1426 BOOL interval
, LONG
*timer_id
)
1428 IDispatch
*disp
= NULL
;
1430 switch(V_VT(expr
)) {
1432 disp
= V_DISPATCH(expr
);
1433 IDispatch_AddRef(disp
);
1437 disp
= script_parse_event(This
, V_BSTR(expr
));
1441 FIXME("unimplemented vt=%d\n", V_VT(expr
));
1448 *timer_id
= set_task_timer(&This
->doc
->basedoc
, msec
, interval
, disp
);
1449 IDispatch_Release(disp
);
1454 static HRESULT WINAPI
HTMLWindow3_setTimeout(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1455 VARIANT
*language
, LONG
*timerID
)
1457 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1459 TRACE("(%p)->(%p(%d) %d %p %p)\n", This
, expression
, V_VT(expression
), msec
, language
, timerID
);
1461 return window_set_timer(This
, expression
, msec
, language
, FALSE
, timerID
);
1464 static HRESULT WINAPI
HTMLWindow3_setInterval(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1465 VARIANT
*language
, LONG
*timerID
)
1467 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1469 TRACE("(%p)->(%p %d %p %p)\n", This
, expression
, msec
, language
, timerID
);
1471 return window_set_timer(This
, expression
, msec
, language
, TRUE
, timerID
);
1474 static HRESULT WINAPI
HTMLWindow3_print(IHTMLWindow3
*iface
)
1476 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1477 FIXME("(%p)\n", This
);
1481 static HRESULT WINAPI
HTMLWindow3_put_onbeforeprint(IHTMLWindow3
*iface
, VARIANT v
)
1483 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1484 FIXME("(%p)->()\n", This
);
1488 static HRESULT WINAPI
HTMLWindow3_get_onbeforeprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1490 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1491 FIXME("(%p)->(%p)\n", This
, p
);
1495 static HRESULT WINAPI
HTMLWindow3_put_onafterprint(IHTMLWindow3
*iface
, VARIANT v
)
1497 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1498 FIXME("(%p)->()\n", This
);
1502 static HRESULT WINAPI
HTMLWindow3_get_onafterprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1504 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1505 FIXME("(%p)->(%p)\n", This
, p
);
1509 static HRESULT WINAPI
HTMLWindow3_get_clipboardData(IHTMLWindow3
*iface
, IHTMLDataTransfer
**p
)
1511 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1512 FIXME("(%p)->(%p)\n", This
, p
);
1516 static HRESULT WINAPI
HTMLWindow3_showModelessDialog(IHTMLWindow3
*iface
, BSTR url
,
1517 VARIANT
*varArgIn
, VARIANT
*options
, IHTMLWindow2
**pDialog
)
1519 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1520 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(url
), varArgIn
, options
, pDialog
);
1524 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl
= {
1525 HTMLWindow3_QueryInterface
,
1527 HTMLWindow3_Release
,
1528 HTMLWindow3_GetTypeInfoCount
,
1529 HTMLWindow3_GetTypeInfo
,
1530 HTMLWindow3_GetIDsOfNames
,
1532 HTMLWindow3_get_screenLeft
,
1533 HTMLWindow3_get_screenTop
,
1534 HTMLWindow3_attachEvent
,
1535 HTMLWindow3_detachEvent
,
1536 HTMLWindow3_setTimeout
,
1537 HTMLWindow3_setInterval
,
1539 HTMLWindow3_put_onbeforeprint
,
1540 HTMLWindow3_get_onbeforeprint
,
1541 HTMLWindow3_put_onafterprint
,
1542 HTMLWindow3_get_onafterprint
,
1543 HTMLWindow3_get_clipboardData
,
1544 HTMLWindow3_showModelessDialog
1547 static inline HTMLWindow
*impl_from_IHTMLWindow4(IHTMLWindow4
*iface
)
1549 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow4_iface
);
1552 static HRESULT WINAPI
HTMLWindow4_QueryInterface(IHTMLWindow4
*iface
, REFIID riid
, void **ppv
)
1554 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1556 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1559 static ULONG WINAPI
HTMLWindow4_AddRef(IHTMLWindow4
*iface
)
1561 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1563 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1566 static ULONG WINAPI
HTMLWindow4_Release(IHTMLWindow4
*iface
)
1568 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1570 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1573 static HRESULT WINAPI
HTMLWindow4_GetTypeInfoCount(IHTMLWindow4
*iface
, UINT
*pctinfo
)
1575 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1577 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1580 static HRESULT WINAPI
HTMLWindow4_GetTypeInfo(IHTMLWindow4
*iface
, UINT iTInfo
,
1581 LCID lcid
, ITypeInfo
**ppTInfo
)
1583 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1585 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1588 static HRESULT WINAPI
HTMLWindow4_GetIDsOfNames(IHTMLWindow4
*iface
, REFIID riid
,
1589 LPOLESTR
*rgszNames
, UINT cNames
,
1590 LCID lcid
, DISPID
*rgDispId
)
1592 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1594 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1598 static HRESULT WINAPI
HTMLWindow4_Invoke(IHTMLWindow4
*iface
, DISPID dispIdMember
,
1599 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1600 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1602 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1604 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1605 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1608 static HRESULT WINAPI
HTMLWindow4_createPopup(IHTMLWindow4
*iface
, VARIANT
*varArgIn
,
1609 IDispatch
**ppPopup
)
1611 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1612 FIXME("(%p)->(%p %p)\n", This
, varArgIn
, ppPopup
);
1616 static HRESULT WINAPI
HTMLWindow4_get_frameElement(IHTMLWindow4
*iface
, IHTMLFrameBase
**p
)
1618 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1619 TRACE("(%p)->(%p)\n", This
, p
);
1621 if(This
->frame_element
) {
1622 *p
= &This
->frame_element
->IHTMLFrameBase_iface
;
1623 IHTMLFrameBase_AddRef(*p
);
1630 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl
= {
1631 HTMLWindow4_QueryInterface
,
1633 HTMLWindow4_Release
,
1634 HTMLWindow4_GetTypeInfoCount
,
1635 HTMLWindow4_GetTypeInfo
,
1636 HTMLWindow4_GetIDsOfNames
,
1638 HTMLWindow4_createPopup
,
1639 HTMLWindow4_get_frameElement
1642 static inline HTMLWindow
*impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow
*iface
)
1644 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLPrivateWindow_iface
);
1647 static HRESULT WINAPI
HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow
*iface
, REFIID riid
, void **ppv
)
1649 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1651 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1654 static ULONG WINAPI
HTMLPrivateWindow_AddRef(IHTMLPrivateWindow
*iface
)
1656 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1658 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1661 static ULONG WINAPI
HTMLPrivateWindow_Release(IHTMLPrivateWindow
*iface
)
1663 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1665 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1668 static HRESULT WINAPI
HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow
*iface
, BSTR url
, BSTR arg2
, BSTR arg3
,
1669 BSTR arg4
, VARIANT
*post_data_var
, VARIANT
*headers_var
, ULONG flags
)
1671 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1672 DWORD post_data_size
= 0;
1673 BYTE
*post_data
= NULL
;
1674 WCHAR
*headers
= NULL
;
1680 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This
, debugstr_w(url
), debugstr_w(arg2
), debugstr_w(arg3
), debugstr_w(arg4
),
1681 debugstr_variant(post_data_var
), debugstr_variant(headers_var
), flags
);
1684 if(This
->doc_obj
->hostui
) {
1685 OLECHAR
*translated_url
= NULL
;
1687 hres
= IDocHostUIHandler_TranslateUrl(This
->doc_obj
->hostui
, 0, url
, &translated_url
);
1688 if(hres
== S_OK
&& translated_url
) {
1689 new_url
= SysAllocString(translated_url
);
1690 CoTaskMemFree(translated_url
);
1694 if(This
->doc_obj
->client
) {
1695 IOleCommandTarget
*cmdtrg
;
1697 hres
= IOleClientSite_QueryInterface(This
->doc_obj
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1698 if(SUCCEEDED(hres
)) {
1701 V_VT(&in
) = VT_BSTR
;
1702 V_BSTR(&in
) = new_url
;
1703 V_VT(&out
) = VT_BOOL
;
1704 V_BOOL(&out
) = VARIANT_TRUE
;
1705 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 67, 0, &in
, &out
);
1706 IOleCommandTarget_Release(cmdtrg
);
1712 /* FIXME: Why not set_ready_state? */
1713 This
->readystate
= READYSTATE_UNINITIALIZED
;
1715 hres
= CreateURLMoniker(NULL
, new_url
, &mon
);
1717 SysFreeString(new_url
);
1722 if(V_VT(post_data_var
) == (VT_ARRAY
|VT_UI1
)) {
1723 SafeArrayAccessData(V_ARRAY(post_data_var
), (void**)&post_data
);
1724 post_data_size
= V_ARRAY(post_data_var
)->rgsabound
[0].cElements
;
1728 if(headers_var
&& V_VT(headers_var
) != VT_EMPTY
&& V_VT(headers_var
) != VT_ERROR
) {
1729 if(V_VT(headers_var
) != VT_BSTR
)
1730 return E_INVALIDARG
;
1732 headers
= V_BSTR(headers_var
);
1735 hres
= create_channelbsc(mon
, headers
, post_data
, post_data_size
, &bsc
);
1737 SafeArrayUnaccessData(V_ARRAY(post_data_var
));
1739 IMoniker_Release(mon
);
1743 hres
= set_moniker(&This
->doc_obj
->basedoc
, mon
, NULL
, bsc
, TRUE
);
1745 hres
= async_start_doc_binding(This
, bsc
);
1747 IUnknown_Release((IUnknown
*)bsc
);
1748 IMoniker_Release(mon
);
1752 static HRESULT WINAPI
HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow
*iface
, BSTR
*url
)
1754 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1755 FIXME("(%p)->(%p)\n", This
, url
);
1759 static HRESULT WINAPI
HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow
*iface
, IOleCommandTarget
*cmdtrg
)
1761 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1762 FIXME("(%p)->(%p)\n", This
, cmdtrg
);
1766 static HRESULT WINAPI
HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow
*iface
, int arg
)
1768 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1769 FIXME("(%p)->(%x)\n", This
, arg
);
1773 static HRESULT WINAPI
HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow
*iface
, LPCWSTR name
, IHTMLWindow2
**ret
)
1775 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1776 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(name
), ret
);
1780 static HRESULT WINAPI
HTMLPrivateWindow_GetAddressBar(IHTMLPrivateWindow
*iface
, BSTR
*url
)
1782 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1783 TRACE("(%p)->(%p)\n", This
, url
);
1786 return E_INVALIDARG
;
1788 *url
= SysAllocString(This
->url
);
1792 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl
= {
1793 HTMLPrivateWindow_QueryInterface
,
1794 HTMLPrivateWindow_AddRef
,
1795 HTMLPrivateWindow_Release
,
1796 HTMLPrivateWindow_SuperNavigate
,
1797 HTMLPrivateWindow_GetPendingUrl
,
1798 HTMLPrivateWindow_SetPICSTarget
,
1799 HTMLPrivateWindow_PICSComplete
,
1800 HTMLPrivateWindow_FindWindowByName
,
1801 HTMLPrivateWindow_GetAddressBar
1804 static inline HTMLWindow
*impl_from_IDispatchEx(IDispatchEx
*iface
)
1806 return CONTAINING_RECORD(iface
, HTMLWindow
, IDispatchEx_iface
);
1809 static HRESULT WINAPI
WindowDispEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
1811 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1813 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1816 static ULONG WINAPI
WindowDispEx_AddRef(IDispatchEx
*iface
)
1818 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1820 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1823 static ULONG WINAPI
WindowDispEx_Release(IDispatchEx
*iface
)
1825 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1827 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1830 static HRESULT WINAPI
WindowDispEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
1832 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1834 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1836 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
1839 static HRESULT WINAPI
WindowDispEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
1840 LCID lcid
, ITypeInfo
**ppTInfo
)
1842 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1844 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1846 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1849 static HRESULT WINAPI
WindowDispEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
1850 LPOLESTR
*rgszNames
, UINT cNames
,
1851 LCID lcid
, DISPID
*rgDispId
)
1853 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1857 WARN("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1860 for(i
=0; i
< cNames
; i
++) {
1861 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
1862 hres
= IDispatchEx_GetDispID(&This
->IDispatchEx_iface
, rgszNames
[i
], 0, rgDispId
+i
);
1870 static HRESULT WINAPI
WindowDispEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
1871 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1872 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1874 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1876 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1877 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1879 /* FIXME: Use script dispatch */
1881 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1882 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1885 static global_prop_t
*alloc_global_prop(HTMLWindow
*This
, global_prop_type_t type
, BSTR name
)
1887 if(This
->global_prop_cnt
== This
->global_prop_size
) {
1888 global_prop_t
*new_props
;
1891 if(This
->global_props
) {
1892 new_size
= This
->global_prop_size
*2;
1893 new_props
= heap_realloc(This
->global_props
, new_size
*sizeof(global_prop_t
));
1896 new_props
= heap_alloc(new_size
*sizeof(global_prop_t
));
1900 This
->global_props
= new_props
;
1901 This
->global_prop_size
= new_size
;
1904 This
->global_props
[This
->global_prop_cnt
].name
= heap_strdupW(name
);
1905 if(!This
->global_props
[This
->global_prop_cnt
].name
)
1908 This
->global_props
[This
->global_prop_cnt
].type
= type
;
1909 return This
->global_props
+ This
->global_prop_cnt
++;
1912 static inline DWORD
prop_to_dispid(HTMLWindow
*This
, global_prop_t
*prop
)
1914 return MSHTML_DISPID_CUSTOM_MIN
+ (prop
-This
->global_props
);
1917 HRESULT
search_window_props(HTMLWindow
*This
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
1920 ScriptHost
*script_host
;
1923 for(i
=0; i
< This
->global_prop_cnt
; i
++) {
1924 /* FIXME: case sensitivity */
1925 if(!strcmpW(This
->global_props
[i
].name
, bstrName
)) {
1926 *pid
= MSHTML_DISPID_CUSTOM_MIN
+i
;
1931 if(find_global_prop(This
, bstrName
, grfdex
, &script_host
, &id
)) {
1932 global_prop_t
*prop
;
1934 prop
= alloc_global_prop(This
, GLOBAL_SCRIPTVAR
, bstrName
);
1936 return E_OUTOFMEMORY
;
1938 prop
->script_host
= script_host
;
1941 *pid
= prop_to_dispid(This
, prop
);
1945 return DISP_E_UNKNOWNNAME
;
1948 static HRESULT WINAPI
WindowDispEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
1950 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1953 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(bstrName
), grfdex
, pid
);
1955 hres
= search_window_props(This
, bstrName
, grfdex
, pid
);
1956 if(hres
!= DISP_E_UNKNOWNNAME
)
1959 hres
= IDispatchEx_GetDispID(&This
->dispex
.IDispatchEx_iface
, bstrName
, grfdex
, pid
);
1960 if(hres
!= DISP_E_UNKNOWNNAME
)
1964 global_prop_t
*prop
;
1967 hres
= IHTMLDocument3_getElementById(&This
->doc
->basedoc
.IHTMLDocument3_iface
,
1969 if(SUCCEEDED(hres
) && elem
) {
1970 IHTMLElement_Release(elem
);
1972 prop
= alloc_global_prop(This
, GLOBAL_ELEMENTVAR
, bstrName
);
1974 return E_OUTOFMEMORY
;
1976 *pid
= prop_to_dispid(This
, prop
);
1981 return DISP_E_UNKNOWNNAME
;
1984 static HRESULT WINAPI
WindowDispEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1985 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1987 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1989 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1991 if(id
== DISPID_IHTMLWINDOW2_LOCATION
&& (wFlags
& DISPATCH_PROPERTYPUT
)) {
1992 HTMLLocation
*location
;
1995 TRACE("forwarding to location.href\n");
1997 hres
= get_location(This
, &location
);
2001 hres
= IDispatchEx_InvokeEx(&location
->dispex
.IDispatchEx_iface
, DISPID_VALUE
, lcid
,
2002 wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2003 IHTMLLocation_Release(&location
->IHTMLLocation_iface
);
2007 return IDispatchEx_InvokeEx(&This
->dispex
.IDispatchEx_iface
, id
, lcid
, wFlags
, pdp
, pvarRes
,
2011 static HRESULT WINAPI
WindowDispEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
2013 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2015 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(bstrName
), grfdex
);
2017 return IDispatchEx_DeleteMemberByName(&This
->dispex
.IDispatchEx_iface
, bstrName
, grfdex
);
2020 static HRESULT WINAPI
WindowDispEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
2022 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2024 TRACE("(%p)->(%x)\n", This
, id
);
2026 return IDispatchEx_DeleteMemberByDispID(&This
->dispex
.IDispatchEx_iface
, id
);
2029 static HRESULT WINAPI
WindowDispEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
2031 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2033 TRACE("(%p)->(%x %x %p)\n", This
, id
, grfdexFetch
, pgrfdex
);
2035 return IDispatchEx_GetMemberProperties(&This
->dispex
.IDispatchEx_iface
, id
, grfdexFetch
,
2039 static HRESULT WINAPI
WindowDispEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
2041 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2043 TRACE("(%p)->(%x %p)\n", This
, id
, pbstrName
);
2045 return IDispatchEx_GetMemberName(&This
->dispex
.IDispatchEx_iface
, id
, pbstrName
);
2048 static HRESULT WINAPI
WindowDispEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
2050 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2052 TRACE("(%p)->(%x %x %p)\n", This
, grfdex
, id
, pid
);
2054 return IDispatchEx_GetNextDispID(&This
->dispex
.IDispatchEx_iface
, grfdex
, id
, pid
);
2057 static HRESULT WINAPI
WindowDispEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
2059 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2061 TRACE("(%p)->(%p)\n", This
, ppunk
);
2067 static const IDispatchExVtbl WindowDispExVtbl
= {
2068 WindowDispEx_QueryInterface
,
2069 WindowDispEx_AddRef
,
2070 WindowDispEx_Release
,
2071 WindowDispEx_GetTypeInfoCount
,
2072 WindowDispEx_GetTypeInfo
,
2073 WindowDispEx_GetIDsOfNames
,
2074 WindowDispEx_Invoke
,
2075 WindowDispEx_GetDispID
,
2076 WindowDispEx_InvokeEx
,
2077 WindowDispEx_DeleteMemberByName
,
2078 WindowDispEx_DeleteMemberByDispID
,
2079 WindowDispEx_GetMemberProperties
,
2080 WindowDispEx_GetMemberName
,
2081 WindowDispEx_GetNextDispID
,
2082 WindowDispEx_GetNameSpaceParent
2085 static inline HTMLWindow
*impl_from_IServiceProvider(IServiceProvider
*iface
)
2087 return CONTAINING_RECORD(iface
, HTMLWindow
, IServiceProvider_iface
);
2090 static HRESULT WINAPI
HTMLWindowSP_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
2092 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2093 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2096 static ULONG WINAPI
HTMLWindowSP_AddRef(IServiceProvider
*iface
)
2098 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2099 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2102 static ULONG WINAPI
HTMLWindowSP_Release(IServiceProvider
*iface
)
2104 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2105 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2108 static HRESULT WINAPI
HTMLWindowSP_QueryService(IServiceProvider
*iface
, REFGUID guidService
, REFIID riid
, void **ppv
)
2110 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2112 if(IsEqualGUID(guidService
, &IID_IHTMLWindow2
)) {
2113 TRACE("IID_IHTMLWindow2\n");
2114 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2117 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
2120 return E_NOINTERFACE
;
2122 return IServiceProvider_QueryService(&This
->doc_obj
->basedoc
.IServiceProvider_iface
,
2123 guidService
, riid
, ppv
);
2126 static const IServiceProviderVtbl ServiceProviderVtbl
= {
2127 HTMLWindowSP_QueryInterface
,
2128 HTMLWindowSP_AddRef
,
2129 HTMLWindowSP_Release
,
2130 HTMLWindowSP_QueryService
2133 static inline HTMLWindow
*impl_from_DispatchEx(DispatchEx
*iface
)
2135 return CONTAINING_RECORD(iface
, HTMLWindow
, dispex
);
2138 static HRESULT
HTMLWindow_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2139 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2141 HTMLWindow
*This
= impl_from_DispatchEx(dispex
);
2142 global_prop_t
*prop
;
2146 idx
= id
- MSHTML_DISPID_CUSTOM_MIN
;
2147 if(idx
>= This
->global_prop_cnt
)
2148 return DISP_E_MEMBERNOTFOUND
;
2150 prop
= This
->global_props
+idx
;
2152 switch(prop
->type
) {
2153 case GLOBAL_SCRIPTVAR
: {
2157 disp
= get_script_disp(prop
->script_host
);
2159 return E_UNEXPECTED
;
2161 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&iface
);
2162 if(SUCCEEDED(hres
)) {
2163 TRACE("%s >>>\n", debugstr_w(prop
->name
));
2164 hres
= IDispatchEx_InvokeEx(iface
, prop
->id
, lcid
, flags
, params
, res
, ei
, caller
);
2166 TRACE("%s <<<\n", debugstr_w(prop
->name
));
2168 WARN("%s <<< %08x\n", debugstr_w(prop
->name
), hres
);
2169 IDispatchEx_Release(iface
);
2171 FIXME("No IDispatchEx\n");
2173 IDispatch_Release(disp
);
2176 case GLOBAL_ELEMENTVAR
: {
2179 hres
= IHTMLDocument3_getElementById(&This
->doc
->basedoc
.IHTMLDocument3_iface
,
2185 return DISP_E_MEMBERNOTFOUND
;
2187 V_VT(res
) = VT_DISPATCH
;
2188 V_DISPATCH(res
) = (IDispatch
*)elem
;
2192 ERR("invalid type %d\n", prop
->type
);
2193 hres
= DISP_E_MEMBERNOTFOUND
;
2200 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl
= {
2206 static const tid_t HTMLWindow_iface_tids
[] = {
2213 static dispex_static_data_t HTMLWindow_dispex
= {
2214 &HTMLWindow_dispex_vtbl
,
2215 DispHTMLWindow2_tid
,
2217 HTMLWindow_iface_tids
2220 HRESULT
HTMLWindow_Create(HTMLDocumentObj
*doc_obj
, nsIDOMWindow
*nswindow
, HTMLWindow
*parent
, HTMLWindow
**ret
)
2225 window
= heap_alloc_zero(sizeof(HTMLWindow
));
2227 return E_OUTOFMEMORY
;
2229 window
->window_ref
= heap_alloc(sizeof(windowref_t
));
2230 if(!window
->window_ref
) {
2232 return E_OUTOFMEMORY
;
2235 window
->IHTMLWindow2_iface
.lpVtbl
= &HTMLWindow2Vtbl
;
2236 window
->IHTMLWindow3_iface
.lpVtbl
= &HTMLWindow3Vtbl
;
2237 window
->IHTMLWindow4_iface
.lpVtbl
= &HTMLWindow4Vtbl
;
2238 window
->IHTMLPrivateWindow_iface
.lpVtbl
= &HTMLPrivateWindowVtbl
;
2239 window
->IDispatchEx_iface
.lpVtbl
= &WindowDispExVtbl
;
2240 window
->IServiceProvider_iface
.lpVtbl
= &ServiceProviderVtbl
;
2242 window
->doc_obj
= doc_obj
;
2244 window
->window_ref
->window
= window
;
2245 window
->window_ref
->ref
= 1;
2247 init_dispex(&window
->dispex
, (IUnknown
*)&window
->IHTMLWindow2_iface
, &HTMLWindow_dispex
);
2250 nsIDOMWindow_AddRef(nswindow
);
2251 window
->nswindow
= nswindow
;
2254 window
->scriptmode
= parent
? parent
->scriptmode
: SCRIPTMODE_GECKO
;
2255 window
->readystate
= READYSTATE_UNINITIALIZED
;
2256 list_init(&window
->script_hosts
);
2258 hres
= CoInternetCreateSecurityManager(NULL
, &window
->secmgr
, 0);
2260 IHTMLWindow2_Release(&window
->IHTMLWindow2_iface
);
2264 window
->task_magic
= get_task_target_magic();
2265 update_window_doc(window
);
2267 list_init(&window
->children
);
2268 list_add_head(&window_list
, &window
->entry
);
2271 IHTMLWindow2_AddRef(&window
->IHTMLWindow2_iface
);
2273 window
->parent
= parent
;
2274 list_add_tail(&parent
->children
, &window
->sibling_entry
);
2281 void update_window_doc(HTMLWindow
*window
)
2283 nsIDOMHTMLDocument
*nshtmldoc
;
2284 nsIDOMDocument
*nsdoc
;
2287 nsres
= nsIDOMWindow_GetDocument(window
->nswindow
, &nsdoc
);
2288 if(NS_FAILED(nsres
) || !nsdoc
) {
2289 ERR("GetDocument failed: %08x\n", nsres
);
2293 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMHTMLDocument
, (void**)&nshtmldoc
);
2294 nsIDOMDocument_Release(nsdoc
);
2295 if(NS_FAILED(nsres
)) {
2296 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres
);
2300 if(!window
->doc
|| window
->doc
->nsdoc
!= nshtmldoc
) {
2301 HTMLDocumentNode
*doc
;
2304 hres
= create_doc_from_nsdoc(nshtmldoc
, window
->doc_obj
, window
, &doc
);
2305 if(SUCCEEDED(hres
)) {
2306 window_set_docnode(window
, doc
);
2307 htmldoc_release(&doc
->basedoc
);
2309 ERR("create_doc_from_nsdoc failed: %08x\n", hres
);
2313 nsIDOMHTMLDocument_Release(nshtmldoc
);
2316 HTMLWindow
*nswindow_to_window(const nsIDOMWindow
*nswindow
)
2320 LIST_FOR_EACH_ENTRY(iter
, &window_list
, HTMLWindow
, entry
) {
2321 if(iter
->nswindow
== nswindow
)