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 abort_document_bindings(window
->doc
);
44 window
->doc
->basedoc
.window
= NULL
;
45 htmldoc_release(&window
->doc
->basedoc
);
47 window
->doc
= doc_node
;
49 htmldoc_addref(&doc_node
->basedoc
);
51 if(window
->doc_obj
&& window
->doc_obj
->basedoc
.window
== window
) {
52 if(window
->doc_obj
->basedoc
.doc_node
)
53 htmldoc_release(&window
->doc_obj
->basedoc
.doc_node
->basedoc
);
54 window
->doc_obj
->basedoc
.doc_node
= doc_node
;
56 htmldoc_addref(&doc_node
->basedoc
);
59 if(doc_node
&& window
->doc_obj
&& window
->doc_obj
->usermode
== EDITMODE
) {
60 nsIDOMNSHTMLDocument
*nshtmldoc
;
64 static const PRUnichar onW
[] = {'o','n',0};
66 nsres
= nsIDOMHTMLDocument_QueryInterface(doc_node
->nsdoc
, &IID_nsIDOMNSHTMLDocument
, (void**)&nshtmldoc
);
67 if(NS_SUCCEEDED(nsres
)) {
68 nsAString_Init(&mode_str
, onW
);
69 nsres
= nsIDOMNSHTMLDocument_SetDesignMode(nshtmldoc
, &mode_str
);
70 nsAString_Finish(&mode_str
);
71 nsIDOMNSHTMLDocument_Release(nshtmldoc
);
73 ERR("SetDesignMode failed: %08x\n", nsres
);
75 ERR("Could not get nsIDOMNSHTMLDocument interface: %08x\n", nsres
);
80 nsIDOMWindow
*get_nsdoc_window(nsIDOMDocument
*nsdoc
)
82 nsIDOMDocumentView
*nsdocview
;
83 nsIDOMAbstractView
*nsview
;
84 nsIDOMWindow
*nswindow
;
87 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMDocumentView
, (void**)&nsdocview
);
88 nsIDOMDocument_Release(nsdoc
);
89 if(NS_FAILED(nsres
)) {
90 ERR("Could not get nsIDOMDocumentView iface: %08x\n", nsres
);
94 nsres
= nsIDOMDocumentView_GetDefaultView(nsdocview
, &nsview
);
95 nsIDOMDocumentView_Release(nsview
);
96 if(NS_FAILED(nsres
)) {
97 ERR("GetDefaultView failed: %08x\n", nsres
);
101 nsres
= nsIDOMAbstractView_QueryInterface(nsview
, &IID_nsIDOMWindow
, (void**)&nswindow
);
102 nsIDOMAbstractView_Release(nsview
);
103 if(NS_FAILED(nsres
)) {
104 ERR("Coult not get nsIDOMWindow iface: %08x\n", nsres
);
111 static void release_children(HTMLWindow
*This
)
115 while(!list_empty(&This
->children
)) {
116 child
= LIST_ENTRY(list_tail(&This
->children
), HTMLWindow
, sibling_entry
);
118 list_remove(&child
->sibling_entry
);
119 child
->parent
= NULL
;
120 IHTMLWindow2_Release(&child
->IHTMLWindow2_iface
);
124 static HRESULT
get_location(HTMLWindow
*This
, HTMLLocation
**ret
)
127 IHTMLLocation_AddRef(&This
->location
->IHTMLLocation_iface
);
131 hres
= HTMLLocation_Create(This
, &This
->location
);
136 *ret
= This
->location
;
140 static inline HRESULT
set_window_event(HTMLWindow
*window
, eventid_t eid
, VARIANT
*var
)
143 FIXME("No document\n");
147 return set_event_handler(&window
->doc
->body_event_target
, NULL
, window
->doc
, eid
, var
);
150 static inline HRESULT
get_window_event(HTMLWindow
*window
, eventid_t eid
, VARIANT
*var
)
153 FIXME("No document\n");
157 return get_event_handler(&window
->doc
->body_event_target
, eid
, var
);
160 static inline HTMLWindow
*impl_from_IHTMLWindow2(IHTMLWindow2
*iface
)
162 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow2_iface
);
165 static HRESULT WINAPI
HTMLWindow2_QueryInterface(IHTMLWindow2
*iface
, REFIID riid
, void **ppv
)
167 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
171 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
172 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
173 *ppv
= &This
->IHTMLWindow2_iface
;
174 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
175 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
176 *ppv
= &This
->IHTMLWindow2_iface
;
177 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
178 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
179 *ppv
= &This
->IDispatchEx_iface
;
180 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2
, riid
)) {
181 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This
, ppv
);
182 *ppv
= &This
->IHTMLWindow2_iface
;
183 }else if(IsEqualGUID(&IID_IHTMLWindow2
, riid
)) {
184 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This
, ppv
);
185 *ppv
= &This
->IHTMLWindow2_iface
;
186 }else if(IsEqualGUID(&IID_IHTMLWindow3
, riid
)) {
187 TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This
, ppv
);
188 *ppv
= &This
->IHTMLWindow3_iface
;
189 }else if(IsEqualGUID(&IID_IHTMLWindow4
, riid
)) {
190 TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This
, ppv
);
191 *ppv
= &This
->IHTMLWindow4_iface
;
192 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow
, riid
)) {
193 TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This
, ppv
);
194 *ppv
= &This
->IHTMLPrivateWindow_iface
;
195 }else if(IsEqualGUID(&IID_IServiceProvider
, riid
)) {
196 TRACE("(%p)->(IID_IServiceProvider %p)\n", This
, ppv
);
197 *ppv
= &This
->IServiceProvider_iface
;
198 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
199 return *ppv
? S_OK
: E_NOINTERFACE
;
203 IUnknown_AddRef((IUnknown
*)*ppv
);
207 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
208 return E_NOINTERFACE
;
211 static ULONG WINAPI
HTMLWindow2_AddRef(IHTMLWindow2
*iface
)
213 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
214 LONG ref
= InterlockedIncrement(&This
->ref
);
216 TRACE("(%p) ref=%d\n", This
, ref
);
221 static ULONG WINAPI
HTMLWindow2_Release(IHTMLWindow2
*iface
)
223 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
224 LONG ref
= InterlockedDecrement(&This
->ref
);
226 TRACE("(%p) ref=%d\n", This
, ref
);
231 remove_target_tasks(This
->task_magic
);
232 set_window_bscallback(This
, NULL
);
233 set_current_mon(This
, NULL
);
234 window_set_docnode(This
, NULL
);
235 release_children(This
);
237 if(This
->frame_element
)
238 This
->frame_element
->content_window
= NULL
;
240 if(This
->option_factory
) {
241 This
->option_factory
->window
= NULL
;
242 IHTMLOptionElementFactory_Release(&This
->option_factory
->IHTMLOptionElementFactory_iface
);
245 if(This
->image_factory
) {
246 This
->image_factory
->window
= NULL
;
247 IHTMLImageElementFactory_Release(&This
->image_factory
->IHTMLImageElementFactory_iface
);
251 This
->location
->window
= NULL
;
252 IHTMLLocation_Release(&This
->location
->IHTMLLocation_iface
);
256 IHTMLScreen_Release(This
->screen
);
258 for(i
=0; i
< This
->global_prop_cnt
; i
++)
259 heap_free(This
->global_props
[i
].name
);
261 This
->window_ref
->window
= NULL
;
262 windowref_release(This
->window_ref
);
264 heap_free(This
->global_props
);
265 release_script_hosts(This
);
268 nsIDOMWindow_Release(This
->nswindow
);
270 list_remove(&This
->entry
);
271 release_dispex(&This
->dispex
);
278 static HRESULT WINAPI
HTMLWindow2_GetTypeInfoCount(IHTMLWindow2
*iface
, UINT
*pctinfo
)
280 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
282 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
285 static HRESULT WINAPI
HTMLWindow2_GetTypeInfo(IHTMLWindow2
*iface
, UINT iTInfo
,
286 LCID lcid
, ITypeInfo
**ppTInfo
)
288 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
290 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
293 static HRESULT WINAPI
HTMLWindow2_GetIDsOfNames(IHTMLWindow2
*iface
, REFIID riid
,
294 LPOLESTR
*rgszNames
, UINT cNames
,
295 LCID lcid
, DISPID
*rgDispId
)
297 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
299 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
303 static HRESULT WINAPI
HTMLWindow2_Invoke(IHTMLWindow2
*iface
, DISPID dispIdMember
,
304 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
305 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
307 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
309 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
310 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
313 static HRESULT
get_frame_by_index(nsIDOMWindowCollection
*nsFrames
, PRUint32 index
, HTMLWindow
**ret
)
316 nsIDOMWindow
*nsWindow
;
319 nsres
= nsIDOMWindowCollection_GetLength(nsFrames
, &length
);
320 if(NS_FAILED(nsres
)) {
321 FIXME("nsIDOMWindowCollection_GetLength failed: 0x%08x\n", nsres
);
326 return DISP_E_MEMBERNOTFOUND
;
328 nsres
= nsIDOMWindowCollection_Item(nsFrames
, index
, &nsWindow
);
329 if(NS_FAILED(nsres
)) {
330 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
334 *ret
= nswindow_to_window(nsWindow
);
336 nsIDOMWindow_Release(nsWindow
);
341 static HRESULT WINAPI
HTMLWindow2_item(IHTMLWindow2
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
343 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
344 nsIDOMWindowCollection
*nsFrames
;
349 TRACE("(%p)->(%p %p)\n", This
, pvarIndex
, pvarResult
);
351 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nsFrames
);
352 if(NS_FAILED(nsres
)) {
353 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres
);
357 if(V_VT(pvarIndex
) == VT_I4
) {
358 int index
= V_I4(pvarIndex
);
359 TRACE("Getting index %d\n", index
);
361 hres
= DISP_E_MEMBERNOTFOUND
;
364 hres
= get_frame_by_index(nsFrames
, index
, &window
);
367 }else if(V_VT(pvarIndex
) == VT_UINT
) {
368 unsigned int index
= V_UINT(pvarIndex
);
369 TRACE("Getting index %u\n", index
);
370 hres
= get_frame_by_index(nsFrames
, index
, &window
);
373 }else if(V_VT(pvarIndex
) == VT_BSTR
) {
374 BSTR str
= V_BSTR(pvarIndex
);
377 TRACE("Getting name %s\n", wine_dbgstr_w(str
));
379 nsres
= nsIDOMWindowCollection_GetLength(nsFrames
, &length
);
382 for(i
= 0; i
< length
&& !window
; ++i
) {
383 HTMLWindow
*cur_window
;
384 nsIDOMWindow
*nsWindow
;
387 nsres
= nsIDOMWindowCollection_Item(nsFrames
, i
, &nsWindow
);
388 if(NS_FAILED(nsres
)) {
389 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
394 cur_window
= nswindow_to_window(nsWindow
);
396 nsIDOMWindow_Release(nsWindow
);
398 hres
= IHTMLElement_get_id(&cur_window
->frame_element
->element
.IHTMLElement_iface
, &id
);
400 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres
);
404 if(!strcmpW(id
, str
))
411 hres
= DISP_E_MEMBERNOTFOUND
;
419 IHTMLWindow2_AddRef(&window
->IHTMLWindow2_iface
);
420 V_VT(pvarResult
) = VT_DISPATCH
;
421 V_DISPATCH(pvarResult
) = (IDispatch
*)window
;
426 nsIDOMWindowCollection_Release(nsFrames
);
431 static HRESULT WINAPI
HTMLWindow2_get_length(IHTMLWindow2
*iface
, LONG
*p
)
433 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
434 nsIDOMWindowCollection
*nscollection
;
438 TRACE("(%p)->(%p)\n", This
, p
);
440 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nscollection
);
441 if(NS_FAILED(nsres
)) {
442 ERR("GetFrames failed: %08x\n", nsres
);
446 nsres
= nsIDOMWindowCollection_GetLength(nscollection
, &length
);
447 nsIDOMWindowCollection_Release(nscollection
);
448 if(NS_FAILED(nsres
)) {
449 ERR("GetLength failed: %08x\n", nsres
);
457 static HRESULT WINAPI
HTMLWindow2_get_frames(IHTMLWindow2
*iface
, IHTMLFramesCollection2
**p
)
459 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
460 FIXME("(%p)->(%p): semi-stub\n", This
, p
);
462 /* FIXME: Should return a separate Window object */
463 *p
= (IHTMLFramesCollection2
*)&This
->IHTMLWindow2_iface
;
464 HTMLWindow2_AddRef(iface
);
468 static HRESULT WINAPI
HTMLWindow2_put_defaultStatus(IHTMLWindow2
*iface
, BSTR v
)
470 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
471 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
475 static HRESULT WINAPI
HTMLWindow2_get_defaultStatus(IHTMLWindow2
*iface
, BSTR
*p
)
477 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
478 FIXME("(%p)->(%p)\n", This
, p
);
482 static HRESULT WINAPI
HTMLWindow2_put_status(IHTMLWindow2
*iface
, BSTR v
)
484 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
485 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
489 static HRESULT WINAPI
HTMLWindow2_get_status(IHTMLWindow2
*iface
, BSTR
*p
)
491 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
492 FIXME("(%p)->(%p)\n", This
, p
);
496 static HRESULT WINAPI
HTMLWindow2_setTimeout(IHTMLWindow2
*iface
, BSTR expression
,
497 LONG msec
, VARIANT
*language
, LONG
*timerID
)
499 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
502 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
504 V_VT(&expr_var
) = VT_BSTR
;
505 V_BSTR(&expr_var
) = expression
;
507 return IHTMLWindow3_setTimeout(&This
->IHTMLWindow3_iface
, &expr_var
, msec
, language
, timerID
);
510 static HRESULT WINAPI
HTMLWindow2_clearTimeout(IHTMLWindow2
*iface
, LONG timerID
)
512 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
514 TRACE("(%p)->(%d)\n", This
, timerID
);
516 return clear_task_timer(&This
->doc
->basedoc
, FALSE
, timerID
);
519 #define MAX_MESSAGE_LEN 2000
521 static HRESULT WINAPI
HTMLWindow2_alert(IHTMLWindow2
*iface
, BSTR message
)
523 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
524 WCHAR title
[100], *msg
= message
;
527 TRACE("(%p)->(%s)\n", This
, debugstr_w(message
));
529 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, title
,
530 sizeof(title
)/sizeof(WCHAR
))) {
531 WARN("Could not load message box title: %d\n", GetLastError());
535 len
= SysStringLen(message
);
536 if(len
> MAX_MESSAGE_LEN
) {
537 msg
= heap_alloc((MAX_MESSAGE_LEN
+1)*sizeof(WCHAR
));
539 return E_OUTOFMEMORY
;
540 memcpy(msg
, message
, MAX_MESSAGE_LEN
*sizeof(WCHAR
));
541 msg
[MAX_MESSAGE_LEN
] = 0;
544 MessageBoxW(This
->doc_obj
->hwnd
, msg
, title
, MB_ICONWARNING
);
550 static HRESULT WINAPI
HTMLWindow2_confirm(IHTMLWindow2
*iface
, BSTR message
,
551 VARIANT_BOOL
*confirmed
)
553 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
556 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(message
), confirmed
);
558 if(!confirmed
) return E_INVALIDARG
;
560 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
561 sizeof(wszTitle
)/sizeof(WCHAR
))) {
562 WARN("Could not load message box title: %d\n", GetLastError());
563 *confirmed
= VARIANT_TRUE
;
567 if(MessageBoxW(This
->doc_obj
->hwnd
, message
, wszTitle
,
568 MB_OKCANCEL
|MB_ICONQUESTION
)==IDOK
)
569 *confirmed
= VARIANT_TRUE
;
570 else *confirmed
= VARIANT_FALSE
;
582 static INT_PTR CALLBACK
prompt_dlgproc(HWND hwnd
, UINT msg
,
583 WPARAM wparam
, LPARAM lparam
)
589 prompt_arg
*arg
= (prompt_arg
*)lparam
;
592 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
593 sizeof(wszTitle
)/sizeof(WCHAR
))) {
594 WARN("Could not load message box title: %d\n", GetLastError());
595 EndDialog(hwnd
, wparam
);
599 SetWindowLongPtrW(hwnd
, DWLP_USER
, lparam
);
600 SetWindowTextW(hwnd
, wszTitle
);
601 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_PROMPT
), arg
->message
);
602 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_EDIT
), arg
->dststr
);
608 case MAKEWPARAM(IDCANCEL
, BN_CLICKED
):
609 EndDialog(hwnd
, wparam
);
611 case MAKEWPARAM(IDOK
, BN_CLICKED
):
614 (prompt_arg
*)GetWindowLongPtrW(hwnd
, DWLP_USER
);
615 HWND hwndPrompt
= GetDlgItem(hwnd
, ID_PROMPT_EDIT
);
616 INT len
= GetWindowTextLengthW(hwndPrompt
);
620 EndDialog(hwnd
, wparam
);
624 V_VT(arg
->textdata
) = VT_BSTR
;
625 if(!len
&& !arg
->dststr
)
626 V_BSTR(arg
->textdata
) = NULL
;
629 V_BSTR(arg
->textdata
) = SysAllocStringLen(NULL
, len
);
630 GetWindowTextW(hwndPrompt
, V_BSTR(arg
->textdata
), len
+1);
632 EndDialog(hwnd
, wparam
);
638 EndDialog(hwnd
, IDCANCEL
);
645 static HRESULT WINAPI
HTMLWindow2_prompt(IHTMLWindow2
*iface
, BSTR message
,
646 BSTR dststr
, VARIANT
*textdata
)
648 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
651 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(message
), debugstr_w(dststr
), textdata
);
653 if(textdata
) V_VT(textdata
) = VT_NULL
;
655 arg
.message
= message
;
657 arg
.textdata
= textdata
;
659 DialogBoxParamW(hInst
, MAKEINTRESOURCEW(ID_PROMPT_DIALOG
),
660 This
->doc_obj
->hwnd
, prompt_dlgproc
, (LPARAM
)&arg
);
664 static HRESULT WINAPI
HTMLWindow2_get_Image(IHTMLWindow2
*iface
, IHTMLImageElementFactory
**p
)
666 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
668 TRACE("(%p)->(%p)\n", This
, p
);
670 if(!This
->image_factory
)
671 This
->image_factory
= HTMLImageElementFactory_Create(This
);
673 *p
= &This
->image_factory
->IHTMLImageElementFactory_iface
;
674 IHTMLImageElementFactory_AddRef(*p
);
679 static HRESULT WINAPI
HTMLWindow2_get_location(IHTMLWindow2
*iface
, IHTMLLocation
**p
)
681 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
682 HTMLLocation
*location
;
685 TRACE("(%p)->(%p)\n", This
, p
);
687 hres
= get_location(This
, &location
);
691 *p
= &location
->IHTMLLocation_iface
;
695 static HRESULT WINAPI
HTMLWindow2_get_history(IHTMLWindow2
*iface
, IOmHistory
**p
)
697 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
698 FIXME("(%p)->(%p)\n", This
, p
);
702 static HRESULT WINAPI
HTMLWindow2_close(IHTMLWindow2
*iface
)
704 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
705 FIXME("(%p)->()\n", This
);
709 static HRESULT WINAPI
HTMLWindow2_put_opener(IHTMLWindow2
*iface
, VARIANT v
)
711 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
712 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
716 static HRESULT WINAPI
HTMLWindow2_get_opener(IHTMLWindow2
*iface
, VARIANT
*p
)
718 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
719 FIXME("(%p)->(%p)\n", This
, p
);
723 static HRESULT WINAPI
HTMLWindow2_get_navigator(IHTMLWindow2
*iface
, IOmNavigator
**p
)
725 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
727 TRACE("(%p)->(%p)\n", This
, p
);
729 *p
= OmNavigator_Create();
733 static HRESULT WINAPI
HTMLWindow2_put_name(IHTMLWindow2
*iface
, BSTR v
)
735 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
739 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
741 nsAString_InitDepend(&name_str
, v
);
742 nsres
= nsIDOMWindow_SetName(This
->nswindow
, &name_str
);
743 nsAString_Finish(&name_str
);
745 ERR("SetName failed: %08x\n", nsres
);
750 static HRESULT WINAPI
HTMLWindow2_get_name(IHTMLWindow2
*iface
, BSTR
*p
)
752 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
757 TRACE("(%p)->(%p)\n", This
, p
);
759 nsAString_Init(&name_str
, NULL
);
760 nsres
= nsIDOMWindow_GetName(This
->nswindow
, &name_str
);
761 if(NS_SUCCEEDED(nsres
)) {
762 const PRUnichar
*name
;
764 nsAString_GetData(&name_str
, &name
);
766 *p
= SysAllocString(name
);
767 hres
= *p
? S_OK
: E_OUTOFMEMORY
;
773 ERR("GetName failed: %08x\n", nsres
);
776 nsAString_Finish(&name_str
);
781 static HRESULT WINAPI
HTMLWindow2_get_parent(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
783 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
784 TRACE("(%p)->(%p)\n", This
, p
);
787 *p
= &This
->parent
->IHTMLWindow2_iface
;
788 IHTMLWindow2_AddRef(*p
);
795 static HRESULT WINAPI
HTMLWindow2_open(IHTMLWindow2
*iface
, BSTR url
, BSTR name
,
796 BSTR features
, VARIANT_BOOL replace
, IHTMLWindow2
**pomWindowResult
)
798 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
799 FIXME("(%p)->(%s %s %s %x %p)\n", This
, debugstr_w(url
), debugstr_w(name
),
800 debugstr_w(features
), replace
, pomWindowResult
);
804 static HRESULT WINAPI
HTMLWindow2_get_self(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
806 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
808 TRACE("(%p)->(%p)\n", This
, p
);
810 /* FIXME: We should return kind of proxy window here. */
811 IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
812 *p
= &This
->IHTMLWindow2_iface
;
816 static HRESULT WINAPI
HTMLWindow2_get_top(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
818 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
820 TRACE("(%p)->(%p)\n", This
, p
);
825 *p
= &curr
->IHTMLWindow2_iface
;
826 IHTMLWindow2_AddRef(*p
);
831 static HRESULT WINAPI
HTMLWindow2_get_window(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
833 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
835 TRACE("(%p)->(%p)\n", This
, p
);
837 /* FIXME: We should return kind of proxy window here. */
838 IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
839 *p
= &This
->IHTMLWindow2_iface
;
843 static HRESULT WINAPI
HTMLWindow2_navigate(IHTMLWindow2
*iface
, BSTR url
)
845 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
846 FIXME("(%p)->(%s)\n", This
, debugstr_w(url
));
850 static HRESULT WINAPI
HTMLWindow2_put_onfocus(IHTMLWindow2
*iface
, VARIANT v
)
852 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
853 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
857 static HRESULT WINAPI
HTMLWindow2_get_onfocus(IHTMLWindow2
*iface
, VARIANT
*p
)
859 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
860 FIXME("(%p)->(%p)\n", This
, p
);
864 static HRESULT WINAPI
HTMLWindow2_put_onblur(IHTMLWindow2
*iface
, VARIANT v
)
866 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
867 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
871 static HRESULT WINAPI
HTMLWindow2_get_onblur(IHTMLWindow2
*iface
, VARIANT
*p
)
873 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
874 FIXME("(%p)->(%p)\n", This
, p
);
878 static HRESULT WINAPI
HTMLWindow2_put_onload(IHTMLWindow2
*iface
, VARIANT v
)
880 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
882 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
884 return set_window_event(This
, EVENTID_LOAD
, &v
);
887 static HRESULT WINAPI
HTMLWindow2_get_onload(IHTMLWindow2
*iface
, VARIANT
*p
)
889 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
891 TRACE("(%p)->(%p)\n", This
, p
);
893 return get_window_event(This
, EVENTID_LOAD
, p
);
896 static HRESULT WINAPI
HTMLWindow2_put_onbeforeunload(IHTMLWindow2
*iface
, VARIANT v
)
898 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
900 TRACE("(%p)->(v(%d))\n", This
, V_VT(&v
));
902 return set_window_event(This
, EVENTID_BEFOREUNLOAD
, &v
);
905 static HRESULT WINAPI
HTMLWindow2_get_onbeforeunload(IHTMLWindow2
*iface
, VARIANT
*p
)
907 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
909 TRACE("(%p)->(%p)\n", This
, p
);
911 return get_window_event(This
, EVENTID_BEFOREUNLOAD
, p
);
914 static HRESULT WINAPI
HTMLWindow2_put_onunload(IHTMLWindow2
*iface
, VARIANT v
)
916 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
917 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
921 static HRESULT WINAPI
HTMLWindow2_get_onunload(IHTMLWindow2
*iface
, VARIANT
*p
)
923 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
924 FIXME("(%p)->(%p)\n", This
, p
);
928 static HRESULT WINAPI
HTMLWindow2_put_onhelp(IHTMLWindow2
*iface
, VARIANT v
)
930 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
931 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
935 static HRESULT WINAPI
HTMLWindow2_get_onhelp(IHTMLWindow2
*iface
, VARIANT
*p
)
937 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
938 FIXME("(%p)->(%p)\n", This
, p
);
942 static HRESULT WINAPI
HTMLWindow2_put_onerror(IHTMLWindow2
*iface
, VARIANT v
)
944 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
945 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
949 static HRESULT WINAPI
HTMLWindow2_get_onerror(IHTMLWindow2
*iface
, VARIANT
*p
)
951 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
952 FIXME("(%p)->(%p)\n", This
, p
);
956 static HRESULT WINAPI
HTMLWindow2_put_onresize(IHTMLWindow2
*iface
, VARIANT v
)
958 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
960 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
962 return set_window_event(This
, EVENTID_RESIZE
, &v
);
965 static HRESULT WINAPI
HTMLWindow2_get_onresize(IHTMLWindow2
*iface
, VARIANT
*p
)
967 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
969 TRACE("(%p)->(%p)\n", This
, p
);
971 return get_window_event(This
, EVENTID_RESIZE
, p
);
974 static HRESULT WINAPI
HTMLWindow2_put_onscroll(IHTMLWindow2
*iface
, VARIANT v
)
976 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
977 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
981 static HRESULT WINAPI
HTMLWindow2_get_onscroll(IHTMLWindow2
*iface
, VARIANT
*p
)
983 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
984 FIXME("(%p)->(%p)\n", This
, p
);
988 static HRESULT WINAPI
HTMLWindow2_get_document(IHTMLWindow2
*iface
, IHTMLDocument2
**p
)
990 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
992 TRACE("(%p)->(%p)\n", This
, p
);
995 /* FIXME: We should return a wrapper object here */
996 *p
= &This
->doc
->basedoc
.IHTMLDocument2_iface
;
997 IHTMLDocument2_AddRef(*p
);
1005 static HRESULT WINAPI
HTMLWindow2_get_event(IHTMLWindow2
*iface
, IHTMLEventObj
**p
)
1007 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1009 TRACE("(%p)->(%p)\n", This
, p
);
1012 IHTMLEventObj_AddRef(This
->event
);
1017 static HRESULT WINAPI
HTMLWindow2_get__newEnum(IHTMLWindow2
*iface
, IUnknown
**p
)
1019 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1020 FIXME("(%p)->(%p)\n", This
, p
);
1024 static HRESULT WINAPI
HTMLWindow2_showModalDialog(IHTMLWindow2
*iface
, BSTR dialog
,
1025 VARIANT
*varArgIn
, VARIANT
*varOptions
, VARIANT
*varArgOut
)
1027 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1028 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(dialog
), varArgIn
, varOptions
, varArgOut
);
1032 static HRESULT WINAPI
HTMLWindow2_showHelp(IHTMLWindow2
*iface
, BSTR helpURL
, VARIANT helpArg
,
1035 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1036 FIXME("(%p)->(%s v(%d) %s)\n", This
, debugstr_w(helpURL
), V_VT(&helpArg
), debugstr_w(features
));
1040 static HRESULT WINAPI
HTMLWindow2_get_screen(IHTMLWindow2
*iface
, IHTMLScreen
**p
)
1042 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1044 TRACE("(%p)->(%p)\n", This
, p
);
1049 hres
= HTMLScreen_Create(&This
->screen
);
1055 IHTMLScreen_AddRef(This
->screen
);
1059 static HRESULT WINAPI
HTMLWindow2_get_Option(IHTMLWindow2
*iface
, IHTMLOptionElementFactory
**p
)
1061 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1063 TRACE("(%p)->(%p)\n", This
, p
);
1065 if(!This
->option_factory
)
1066 This
->option_factory
= HTMLOptionElementFactory_Create(This
);
1068 *p
= &This
->option_factory
->IHTMLOptionElementFactory_iface
;
1069 IHTMLOptionElementFactory_AddRef(*p
);
1074 static HRESULT WINAPI
HTMLWindow2_focus(IHTMLWindow2
*iface
)
1076 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1078 TRACE("(%p)->()\n", This
);
1081 SetFocus(This
->doc_obj
->hwnd
);
1085 static HRESULT WINAPI
HTMLWindow2_get_closed(IHTMLWindow2
*iface
, VARIANT_BOOL
*p
)
1087 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1088 FIXME("(%p)->(%p)\n", This
, p
);
1092 static HRESULT WINAPI
HTMLWindow2_blur(IHTMLWindow2
*iface
)
1094 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1095 FIXME("(%p)->()\n", This
);
1099 static HRESULT WINAPI
HTMLWindow2_scroll(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1101 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1102 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1106 static HRESULT WINAPI
HTMLWindow2_get_clientInformation(IHTMLWindow2
*iface
, IOmNavigator
**p
)
1108 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1109 FIXME("(%p)->(%p)\n", This
, p
);
1113 static HRESULT WINAPI
HTMLWindow2_setInterval(IHTMLWindow2
*iface
, BSTR expression
,
1114 LONG msec
, VARIANT
*language
, LONG
*timerID
)
1116 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1119 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
1121 V_VT(&expr
) = VT_BSTR
;
1122 V_BSTR(&expr
) = expression
;
1123 return IHTMLWindow3_setInterval(&This
->IHTMLWindow3_iface
, &expr
, msec
, language
, timerID
);
1126 static HRESULT WINAPI
HTMLWindow2_clearInterval(IHTMLWindow2
*iface
, LONG timerID
)
1128 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1130 TRACE("(%p)->(%d)\n", This
, timerID
);
1132 return clear_task_timer(&This
->doc
->basedoc
, TRUE
, timerID
);
1135 static HRESULT WINAPI
HTMLWindow2_put_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT v
)
1137 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1138 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
1142 static HRESULT WINAPI
HTMLWindow2_get_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT
*p
)
1144 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1145 FIXME("(%p)->(%p)\n", This
, p
);
1149 static HRESULT WINAPI
HTMLWindow2_execScript(IHTMLWindow2
*iface
, BSTR scode
, BSTR language
,
1152 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1154 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(scode
), debugstr_w(language
), pvarRet
);
1156 return exec_script(This
, scode
, language
, pvarRet
);
1159 static HRESULT WINAPI
HTMLWindow2_toString(IHTMLWindow2
*iface
, BSTR
*String
)
1161 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1163 static const WCHAR objectW
[] = {'[','o','b','j','e','c','t',']',0};
1165 TRACE("(%p)->(%p)\n", This
, String
);
1168 return E_INVALIDARG
;
1170 *String
= SysAllocString(objectW
);
1171 return *String
? S_OK
: E_OUTOFMEMORY
;
1174 static HRESULT WINAPI
HTMLWindow2_scrollBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1176 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1179 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1181 nsres
= nsIDOMWindow_ScrollBy(This
->nswindow
, x
, y
);
1182 if(NS_FAILED(nsres
))
1183 ERR("ScrollBy failed: %08x\n", nsres
);
1188 static HRESULT WINAPI
HTMLWindow2_scrollTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1190 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1193 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1195 nsres
= nsIDOMWindow_ScrollTo(This
->nswindow
, x
, y
);
1196 if(NS_FAILED(nsres
))
1197 ERR("ScrollTo failed: %08x\n", nsres
);
1202 static HRESULT WINAPI
HTMLWindow2_moveTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1204 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1205 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1209 static HRESULT WINAPI
HTMLWindow2_moveBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1211 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1212 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1216 static HRESULT WINAPI
HTMLWindow2_resizeTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1218 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1219 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1223 static HRESULT WINAPI
HTMLWindow2_resizeBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1225 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1226 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1230 static HRESULT WINAPI
HTMLWindow2_get_external(IHTMLWindow2
*iface
, IDispatch
**p
)
1232 HTMLWindow
*This
= impl_from_IHTMLWindow2(iface
);
1234 TRACE("(%p)->(%p)\n", This
, p
);
1238 if(!This
->doc_obj
->hostui
)
1241 return IDocHostUIHandler_GetExternal(This
->doc_obj
->hostui
, p
);
1244 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl
= {
1245 HTMLWindow2_QueryInterface
,
1247 HTMLWindow2_Release
,
1248 HTMLWindow2_GetTypeInfoCount
,
1249 HTMLWindow2_GetTypeInfo
,
1250 HTMLWindow2_GetIDsOfNames
,
1253 HTMLWindow2_get_length
,
1254 HTMLWindow2_get_frames
,
1255 HTMLWindow2_put_defaultStatus
,
1256 HTMLWindow2_get_defaultStatus
,
1257 HTMLWindow2_put_status
,
1258 HTMLWindow2_get_status
,
1259 HTMLWindow2_setTimeout
,
1260 HTMLWindow2_clearTimeout
,
1262 HTMLWindow2_confirm
,
1264 HTMLWindow2_get_Image
,
1265 HTMLWindow2_get_location
,
1266 HTMLWindow2_get_history
,
1268 HTMLWindow2_put_opener
,
1269 HTMLWindow2_get_opener
,
1270 HTMLWindow2_get_navigator
,
1271 HTMLWindow2_put_name
,
1272 HTMLWindow2_get_name
,
1273 HTMLWindow2_get_parent
,
1275 HTMLWindow2_get_self
,
1276 HTMLWindow2_get_top
,
1277 HTMLWindow2_get_window
,
1278 HTMLWindow2_navigate
,
1279 HTMLWindow2_put_onfocus
,
1280 HTMLWindow2_get_onfocus
,
1281 HTMLWindow2_put_onblur
,
1282 HTMLWindow2_get_onblur
,
1283 HTMLWindow2_put_onload
,
1284 HTMLWindow2_get_onload
,
1285 HTMLWindow2_put_onbeforeunload
,
1286 HTMLWindow2_get_onbeforeunload
,
1287 HTMLWindow2_put_onunload
,
1288 HTMLWindow2_get_onunload
,
1289 HTMLWindow2_put_onhelp
,
1290 HTMLWindow2_get_onhelp
,
1291 HTMLWindow2_put_onerror
,
1292 HTMLWindow2_get_onerror
,
1293 HTMLWindow2_put_onresize
,
1294 HTMLWindow2_get_onresize
,
1295 HTMLWindow2_put_onscroll
,
1296 HTMLWindow2_get_onscroll
,
1297 HTMLWindow2_get_document
,
1298 HTMLWindow2_get_event
,
1299 HTMLWindow2_get__newEnum
,
1300 HTMLWindow2_showModalDialog
,
1301 HTMLWindow2_showHelp
,
1302 HTMLWindow2_get_screen
,
1303 HTMLWindow2_get_Option
,
1305 HTMLWindow2_get_closed
,
1308 HTMLWindow2_get_clientInformation
,
1309 HTMLWindow2_setInterval
,
1310 HTMLWindow2_clearInterval
,
1311 HTMLWindow2_put_offscreenBuffering
,
1312 HTMLWindow2_get_offscreenBuffering
,
1313 HTMLWindow2_execScript
,
1314 HTMLWindow2_toString
,
1315 HTMLWindow2_scrollBy
,
1316 HTMLWindow2_scrollTo
,
1319 HTMLWindow2_resizeTo
,
1320 HTMLWindow2_resizeBy
,
1321 HTMLWindow2_get_external
1324 static inline HTMLWindow
*impl_from_IHTMLWindow3(IHTMLWindow3
*iface
)
1326 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow3_iface
);
1329 static HRESULT WINAPI
HTMLWindow3_QueryInterface(IHTMLWindow3
*iface
, REFIID riid
, void **ppv
)
1331 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1333 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1336 static ULONG WINAPI
HTMLWindow3_AddRef(IHTMLWindow3
*iface
)
1338 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1340 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1343 static ULONG WINAPI
HTMLWindow3_Release(IHTMLWindow3
*iface
)
1345 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1347 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1350 static HRESULT WINAPI
HTMLWindow3_GetTypeInfoCount(IHTMLWindow3
*iface
, UINT
*pctinfo
)
1352 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1354 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1357 static HRESULT WINAPI
HTMLWindow3_GetTypeInfo(IHTMLWindow3
*iface
, UINT iTInfo
,
1358 LCID lcid
, ITypeInfo
**ppTInfo
)
1360 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1362 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1365 static HRESULT WINAPI
HTMLWindow3_GetIDsOfNames(IHTMLWindow3
*iface
, REFIID riid
,
1366 LPOLESTR
*rgszNames
, UINT cNames
,
1367 LCID lcid
, DISPID
*rgDispId
)
1369 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1371 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1375 static HRESULT WINAPI
HTMLWindow3_Invoke(IHTMLWindow3
*iface
, DISPID dispIdMember
,
1376 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1377 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1379 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1381 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1382 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1385 static HRESULT WINAPI
HTMLWindow3_get_screenLeft(IHTMLWindow3
*iface
, LONG
*p
)
1387 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1388 FIXME("(%p)->(%p)\n", This
, p
);
1392 static HRESULT WINAPI
HTMLWindow3_get_screenTop(IHTMLWindow3
*iface
, LONG
*p
)
1394 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1395 FIXME("(%p)->(%p)\n", This
, p
);
1399 static HRESULT WINAPI
HTMLWindow3_attachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
, VARIANT_BOOL
*pfResult
)
1401 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1403 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(event
), pDisp
, pfResult
);
1406 FIXME("No document\n");
1410 return attach_event(&This
->doc
->body_event_target
, NULL
, &This
->doc
->basedoc
, event
, pDisp
, pfResult
);
1413 static HRESULT WINAPI
HTMLWindow3_detachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
)
1415 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1416 FIXME("(%p)->()\n", This
);
1420 static HRESULT
window_set_timer(HTMLWindow
*This
, VARIANT
*expr
, LONG msec
, VARIANT
*language
,
1421 BOOL interval
, LONG
*timer_id
)
1423 IDispatch
*disp
= NULL
;
1425 switch(V_VT(expr
)) {
1427 disp
= V_DISPATCH(expr
);
1428 IDispatch_AddRef(disp
);
1432 disp
= script_parse_event(This
, V_BSTR(expr
));
1436 FIXME("unimplemented vt=%d\n", V_VT(expr
));
1443 *timer_id
= set_task_timer(&This
->doc
->basedoc
, msec
, interval
, disp
);
1444 IDispatch_Release(disp
);
1449 static HRESULT WINAPI
HTMLWindow3_setTimeout(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1450 VARIANT
*language
, LONG
*timerID
)
1452 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1454 TRACE("(%p)->(%p(%d) %d %p %p)\n", This
, expression
, V_VT(expression
), msec
, language
, timerID
);
1456 return window_set_timer(This
, expression
, msec
, language
, FALSE
, timerID
);
1459 static HRESULT WINAPI
HTMLWindow3_setInterval(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1460 VARIANT
*language
, LONG
*timerID
)
1462 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1464 TRACE("(%p)->(%p %d %p %p)\n", This
, expression
, msec
, language
, timerID
);
1466 return window_set_timer(This
, expression
, msec
, language
, TRUE
, timerID
);
1469 static HRESULT WINAPI
HTMLWindow3_print(IHTMLWindow3
*iface
)
1471 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1472 FIXME("(%p)\n", This
);
1476 static HRESULT WINAPI
HTMLWindow3_put_onbeforeprint(IHTMLWindow3
*iface
, VARIANT v
)
1478 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1479 FIXME("(%p)->()\n", This
);
1483 static HRESULT WINAPI
HTMLWindow3_get_onbeforeprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1485 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1486 FIXME("(%p)->(%p)\n", This
, p
);
1490 static HRESULT WINAPI
HTMLWindow3_put_onafterprint(IHTMLWindow3
*iface
, VARIANT v
)
1492 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1493 FIXME("(%p)->()\n", This
);
1497 static HRESULT WINAPI
HTMLWindow3_get_onafterprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1499 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1500 FIXME("(%p)->(%p)\n", This
, p
);
1504 static HRESULT WINAPI
HTMLWindow3_get_clipboardData(IHTMLWindow3
*iface
, IHTMLDataTransfer
**p
)
1506 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1507 FIXME("(%p)->(%p)\n", This
, p
);
1511 static HRESULT WINAPI
HTMLWindow3_showModelessDialog(IHTMLWindow3
*iface
, BSTR url
,
1512 VARIANT
*varArgIn
, VARIANT
*options
, IHTMLWindow2
**pDialog
)
1514 HTMLWindow
*This
= impl_from_IHTMLWindow3(iface
);
1515 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(url
), varArgIn
, options
, pDialog
);
1519 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl
= {
1520 HTMLWindow3_QueryInterface
,
1522 HTMLWindow3_Release
,
1523 HTMLWindow3_GetTypeInfoCount
,
1524 HTMLWindow3_GetTypeInfo
,
1525 HTMLWindow3_GetIDsOfNames
,
1527 HTMLWindow3_get_screenLeft
,
1528 HTMLWindow3_get_screenTop
,
1529 HTMLWindow3_attachEvent
,
1530 HTMLWindow3_detachEvent
,
1531 HTMLWindow3_setTimeout
,
1532 HTMLWindow3_setInterval
,
1534 HTMLWindow3_put_onbeforeprint
,
1535 HTMLWindow3_get_onbeforeprint
,
1536 HTMLWindow3_put_onafterprint
,
1537 HTMLWindow3_get_onafterprint
,
1538 HTMLWindow3_get_clipboardData
,
1539 HTMLWindow3_showModelessDialog
1542 static inline HTMLWindow
*impl_from_IHTMLWindow4(IHTMLWindow4
*iface
)
1544 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLWindow4_iface
);
1547 static HRESULT WINAPI
HTMLWindow4_QueryInterface(IHTMLWindow4
*iface
, REFIID riid
, void **ppv
)
1549 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1551 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1554 static ULONG WINAPI
HTMLWindow4_AddRef(IHTMLWindow4
*iface
)
1556 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1558 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1561 static ULONG WINAPI
HTMLWindow4_Release(IHTMLWindow4
*iface
)
1563 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1565 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1568 static HRESULT WINAPI
HTMLWindow4_GetTypeInfoCount(IHTMLWindow4
*iface
, UINT
*pctinfo
)
1570 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1572 return IDispatchEx_GetTypeInfoCount(&This
->IDispatchEx_iface
, pctinfo
);
1575 static HRESULT WINAPI
HTMLWindow4_GetTypeInfo(IHTMLWindow4
*iface
, UINT iTInfo
,
1576 LCID lcid
, ITypeInfo
**ppTInfo
)
1578 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1580 return IDispatchEx_GetTypeInfo(&This
->IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1583 static HRESULT WINAPI
HTMLWindow4_GetIDsOfNames(IHTMLWindow4
*iface
, REFIID riid
,
1584 LPOLESTR
*rgszNames
, UINT cNames
,
1585 LCID lcid
, DISPID
*rgDispId
)
1587 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1589 return IDispatchEx_GetIDsOfNames(&This
->IDispatchEx_iface
, riid
, rgszNames
, cNames
, lcid
,
1593 static HRESULT WINAPI
HTMLWindow4_Invoke(IHTMLWindow4
*iface
, DISPID dispIdMember
,
1594 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1595 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1597 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1599 return IDispatchEx_Invoke(&This
->IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1600 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1603 static HRESULT WINAPI
HTMLWindow4_createPopup(IHTMLWindow4
*iface
, VARIANT
*varArgIn
,
1604 IDispatch
**ppPopup
)
1606 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1607 FIXME("(%p)->(%p %p)\n", This
, varArgIn
, ppPopup
);
1611 static HRESULT WINAPI
HTMLWindow4_get_frameElement(IHTMLWindow4
*iface
, IHTMLFrameBase
**p
)
1613 HTMLWindow
*This
= impl_from_IHTMLWindow4(iface
);
1614 TRACE("(%p)->(%p)\n", This
, p
);
1616 if(This
->frame_element
) {
1617 *p
= &This
->frame_element
->IHTMLFrameBase_iface
;
1618 IHTMLFrameBase_AddRef(*p
);
1625 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl
= {
1626 HTMLWindow4_QueryInterface
,
1628 HTMLWindow4_Release
,
1629 HTMLWindow4_GetTypeInfoCount
,
1630 HTMLWindow4_GetTypeInfo
,
1631 HTMLWindow4_GetIDsOfNames
,
1633 HTMLWindow4_createPopup
,
1634 HTMLWindow4_get_frameElement
1637 static inline HTMLWindow
*impl_from_IHTMLPrivateWindow(IHTMLPrivateWindow
*iface
)
1639 return CONTAINING_RECORD(iface
, HTMLWindow
, IHTMLPrivateWindow_iface
);
1642 static HRESULT WINAPI
HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow
*iface
, REFIID riid
, void **ppv
)
1644 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1646 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1649 static ULONG WINAPI
HTMLPrivateWindow_AddRef(IHTMLPrivateWindow
*iface
)
1651 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1653 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1656 static ULONG WINAPI
HTMLPrivateWindow_Release(IHTMLPrivateWindow
*iface
)
1658 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1660 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1663 static HRESULT WINAPI
HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow
*iface
, BSTR url
, BSTR arg2
, BSTR arg3
,
1664 BSTR arg4
, VARIANT
*post_data_var
, VARIANT
*headers_var
, ULONG flags
)
1666 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1667 DWORD post_data_size
= 0;
1668 BYTE
*post_data
= NULL
;
1669 WCHAR
*headers
= NULL
;
1675 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This
, debugstr_w(url
), debugstr_w(arg2
), debugstr_w(arg3
), debugstr_w(arg4
),
1676 debugstr_variant(post_data_var
), debugstr_variant(headers_var
), flags
);
1679 if(This
->doc_obj
->hostui
) {
1680 OLECHAR
*translated_url
= NULL
;
1682 hres
= IDocHostUIHandler_TranslateUrl(This
->doc_obj
->hostui
, 0, url
, &translated_url
);
1683 if(hres
== S_OK
&& translated_url
) {
1684 new_url
= SysAllocString(translated_url
);
1685 CoTaskMemFree(translated_url
);
1689 if(This
->doc_obj
->client
) {
1690 IOleCommandTarget
*cmdtrg
;
1692 hres
= IOleClientSite_QueryInterface(This
->doc_obj
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1693 if(SUCCEEDED(hres
)) {
1696 V_VT(&in
) = VT_BSTR
;
1697 V_BSTR(&in
) = new_url
;
1698 V_VT(&out
) = VT_BOOL
;
1699 V_BOOL(&out
) = VARIANT_TRUE
;
1700 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 67, 0, &in
, &out
);
1701 IOleCommandTarget_Release(cmdtrg
);
1707 /* FIXME: Why not set_ready_state? */
1708 This
->readystate
= READYSTATE_UNINITIALIZED
;
1710 hres
= CreateURLMoniker(NULL
, new_url
, &mon
);
1712 SysFreeString(new_url
);
1717 if(V_VT(post_data_var
) == (VT_ARRAY
|VT_UI1
)) {
1718 SafeArrayAccessData(V_ARRAY(post_data_var
), (void**)&post_data
);
1719 post_data_size
= V_ARRAY(post_data_var
)->rgsabound
[0].cElements
;
1723 if(headers_var
&& V_VT(headers_var
) != VT_EMPTY
&& V_VT(headers_var
) != VT_ERROR
) {
1724 if(V_VT(headers_var
) != VT_BSTR
)
1725 return E_INVALIDARG
;
1727 headers
= V_BSTR(headers_var
);
1730 hres
= create_channelbsc(mon
, headers
, post_data
, post_data_size
, &bsc
);
1732 SafeArrayUnaccessData(V_ARRAY(post_data_var
));
1734 IMoniker_Release(mon
);
1738 hres
= set_moniker(&This
->doc_obj
->basedoc
, mon
, NULL
, bsc
, TRUE
);
1740 hres
= async_start_doc_binding(This
, bsc
);
1742 IUnknown_Release((IUnknown
*)bsc
);
1743 IMoniker_Release(mon
);
1747 static HRESULT WINAPI
HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow
*iface
, BSTR
*url
)
1749 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1750 FIXME("(%p)->(%p)\n", This
, url
);
1754 static HRESULT WINAPI
HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow
*iface
, IOleCommandTarget
*cmdtrg
)
1756 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1757 FIXME("(%p)->(%p)\n", This
, cmdtrg
);
1761 static HRESULT WINAPI
HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow
*iface
, int arg
)
1763 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1764 FIXME("(%p)->(%x)\n", This
, arg
);
1768 static HRESULT WINAPI
HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow
*iface
, LPCWSTR name
, IHTMLWindow2
**ret
)
1770 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1771 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(name
), ret
);
1775 static HRESULT WINAPI
HTMLPrivateWindow_GetAddressBar(IHTMLPrivateWindow
*iface
, BSTR
*url
)
1777 HTMLWindow
*This
= impl_from_IHTMLPrivateWindow(iface
);
1778 FIXME("(%p)->(%p)\n", This
, url
);
1782 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl
= {
1783 HTMLPrivateWindow_QueryInterface
,
1784 HTMLPrivateWindow_AddRef
,
1785 HTMLPrivateWindow_Release
,
1786 HTMLPrivateWindow_SuperNavigate
,
1787 HTMLPrivateWindow_GetPendingUrl
,
1788 HTMLPrivateWindow_SetPICSTarget
,
1789 HTMLPrivateWindow_PICSComplete
,
1790 HTMLPrivateWindow_FindWindowByName
,
1791 HTMLPrivateWindow_GetAddressBar
1794 static inline HTMLWindow
*impl_from_IDispatchEx(IDispatchEx
*iface
)
1796 return CONTAINING_RECORD(iface
, HTMLWindow
, IDispatchEx_iface
);
1799 static HRESULT WINAPI
WindowDispEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
1801 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1803 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
1806 static ULONG WINAPI
WindowDispEx_AddRef(IDispatchEx
*iface
)
1808 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1810 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
1813 static ULONG WINAPI
WindowDispEx_Release(IDispatchEx
*iface
)
1815 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1817 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
1820 static HRESULT WINAPI
WindowDispEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
1822 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1824 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1826 return IDispatchEx_GetTypeInfoCount(&This
->dispex
.IDispatchEx_iface
, pctinfo
);
1829 static HRESULT WINAPI
WindowDispEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
1830 LCID lcid
, ITypeInfo
**ppTInfo
)
1832 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1834 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1836 return IDispatchEx_GetTypeInfo(&This
->dispex
.IDispatchEx_iface
, iTInfo
, lcid
, ppTInfo
);
1839 static HRESULT WINAPI
WindowDispEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
1840 LPOLESTR
*rgszNames
, UINT cNames
,
1841 LCID lcid
, DISPID
*rgDispId
)
1843 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1847 WARN("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1850 for(i
=0; i
< cNames
; i
++) {
1851 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
1852 hres
= IDispatchEx_GetDispID(&This
->IDispatchEx_iface
, rgszNames
[i
], 0, rgDispId
+i
);
1860 static HRESULT WINAPI
WindowDispEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
1861 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1862 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1864 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1866 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1867 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1869 /* FIXME: Use script dispatch */
1871 return IDispatchEx_Invoke(&This
->dispex
.IDispatchEx_iface
, dispIdMember
, riid
, lcid
, wFlags
,
1872 pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1875 static global_prop_t
*alloc_global_prop(HTMLWindow
*This
, global_prop_type_t type
, BSTR name
)
1877 if(This
->global_prop_cnt
== This
->global_prop_size
) {
1878 global_prop_t
*new_props
;
1881 if(This
->global_props
) {
1882 new_size
= This
->global_prop_size
*2;
1883 new_props
= heap_realloc(This
->global_props
, new_size
*sizeof(global_prop_t
));
1886 new_props
= heap_alloc(new_size
*sizeof(global_prop_t
));
1890 This
->global_props
= new_props
;
1891 This
->global_prop_size
= new_size
;
1894 This
->global_props
[This
->global_prop_cnt
].name
= heap_strdupW(name
);
1895 if(!This
->global_props
[This
->global_prop_cnt
].name
)
1898 This
->global_props
[This
->global_prop_cnt
].type
= type
;
1899 return This
->global_props
+ This
->global_prop_cnt
++;
1902 static inline DWORD
prop_to_dispid(HTMLWindow
*This
, global_prop_t
*prop
)
1904 return MSHTML_DISPID_CUSTOM_MIN
+ (prop
-This
->global_props
);
1907 HRESULT
search_window_props(HTMLWindow
*This
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
1910 ScriptHost
*script_host
;
1913 for(i
=0; i
< This
->global_prop_cnt
; i
++) {
1914 /* FIXME: case sensitivity */
1915 if(!strcmpW(This
->global_props
[i
].name
, bstrName
)) {
1916 *pid
= MSHTML_DISPID_CUSTOM_MIN
+i
;
1921 if(find_global_prop(This
, bstrName
, grfdex
, &script_host
, &id
)) {
1922 global_prop_t
*prop
;
1924 prop
= alloc_global_prop(This
, GLOBAL_SCRIPTVAR
, bstrName
);
1926 return E_OUTOFMEMORY
;
1928 prop
->script_host
= script_host
;
1931 *pid
= prop_to_dispid(This
, prop
);
1935 return DISP_E_UNKNOWNNAME
;
1938 static HRESULT WINAPI
WindowDispEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
1940 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1943 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(bstrName
), grfdex
, pid
);
1945 hres
= search_window_props(This
, bstrName
, grfdex
, pid
);
1946 if(hres
!= DISP_E_UNKNOWNNAME
)
1949 hres
= IDispatchEx_GetDispID(&This
->dispex
.IDispatchEx_iface
, bstrName
, grfdex
, pid
);
1950 if(hres
!= DISP_E_UNKNOWNNAME
)
1954 global_prop_t
*prop
;
1957 hres
= IHTMLDocument3_getElementById(&This
->doc
->basedoc
.IHTMLDocument3_iface
,
1959 if(SUCCEEDED(hres
) && elem
) {
1960 IHTMLElement_Release(elem
);
1962 prop
= alloc_global_prop(This
, GLOBAL_ELEMENTVAR
, bstrName
);
1964 return E_OUTOFMEMORY
;
1966 *pid
= prop_to_dispid(This
, prop
);
1971 return DISP_E_UNKNOWNNAME
;
1974 static HRESULT WINAPI
WindowDispEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
1975 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
1977 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
1979 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1981 if(id
== DISPID_IHTMLWINDOW2_LOCATION
&& (wFlags
& DISPATCH_PROPERTYPUT
)) {
1982 HTMLLocation
*location
;
1985 TRACE("forwarding to location.href\n");
1987 hres
= get_location(This
, &location
);
1991 hres
= IDispatchEx_InvokeEx(&location
->dispex
.IDispatchEx_iface
, DISPID_VALUE
, lcid
,
1992 wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
1993 IHTMLLocation_Release(&location
->IHTMLLocation_iface
);
1997 return IDispatchEx_InvokeEx(&This
->dispex
.IDispatchEx_iface
, id
, lcid
, wFlags
, pdp
, pvarRes
,
2001 static HRESULT WINAPI
WindowDispEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
2003 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2005 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(bstrName
), grfdex
);
2007 return IDispatchEx_DeleteMemberByName(&This
->dispex
.IDispatchEx_iface
, bstrName
, grfdex
);
2010 static HRESULT WINAPI
WindowDispEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
2012 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2014 TRACE("(%p)->(%x)\n", This
, id
);
2016 return IDispatchEx_DeleteMemberByDispID(&This
->dispex
.IDispatchEx_iface
, id
);
2019 static HRESULT WINAPI
WindowDispEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
2021 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2023 TRACE("(%p)->(%x %x %p)\n", This
, id
, grfdexFetch
, pgrfdex
);
2025 return IDispatchEx_GetMemberProperties(&This
->dispex
.IDispatchEx_iface
, id
, grfdexFetch
,
2029 static HRESULT WINAPI
WindowDispEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
2031 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2033 TRACE("(%p)->(%x %p)\n", This
, id
, pbstrName
);
2035 return IDispatchEx_GetMemberName(&This
->dispex
.IDispatchEx_iface
, id
, pbstrName
);
2038 static HRESULT WINAPI
WindowDispEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
2040 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2042 TRACE("(%p)->(%x %x %p)\n", This
, grfdex
, id
, pid
);
2044 return IDispatchEx_GetNextDispID(&This
->dispex
.IDispatchEx_iface
, grfdex
, id
, pid
);
2047 static HRESULT WINAPI
WindowDispEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
2049 HTMLWindow
*This
= impl_from_IDispatchEx(iface
);
2051 TRACE("(%p)->(%p)\n", This
, ppunk
);
2057 static const IDispatchExVtbl WindowDispExVtbl
= {
2058 WindowDispEx_QueryInterface
,
2059 WindowDispEx_AddRef
,
2060 WindowDispEx_Release
,
2061 WindowDispEx_GetTypeInfoCount
,
2062 WindowDispEx_GetTypeInfo
,
2063 WindowDispEx_GetIDsOfNames
,
2064 WindowDispEx_Invoke
,
2065 WindowDispEx_GetDispID
,
2066 WindowDispEx_InvokeEx
,
2067 WindowDispEx_DeleteMemberByName
,
2068 WindowDispEx_DeleteMemberByDispID
,
2069 WindowDispEx_GetMemberProperties
,
2070 WindowDispEx_GetMemberName
,
2071 WindowDispEx_GetNextDispID
,
2072 WindowDispEx_GetNameSpaceParent
2075 static inline HTMLWindow
*impl_from_IServiceProvider(IServiceProvider
*iface
)
2077 return CONTAINING_RECORD(iface
, HTMLWindow
, IServiceProvider_iface
);
2080 static HRESULT WINAPI
HTMLWindowSP_QueryInterface(IServiceProvider
*iface
, REFIID riid
, void **ppv
)
2082 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2083 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2086 static ULONG WINAPI
HTMLWindowSP_AddRef(IServiceProvider
*iface
)
2088 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2089 return IHTMLWindow2_AddRef(&This
->IHTMLWindow2_iface
);
2092 static ULONG WINAPI
HTMLWindowSP_Release(IServiceProvider
*iface
)
2094 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2095 return IHTMLWindow2_Release(&This
->IHTMLWindow2_iface
);
2098 static HRESULT WINAPI
HTMLWindowSP_QueryService(IServiceProvider
*iface
, REFGUID guidService
, REFIID riid
, void **ppv
)
2100 HTMLWindow
*This
= impl_from_IServiceProvider(iface
);
2102 if(IsEqualGUID(guidService
, &IID_IHTMLWindow2
)) {
2103 TRACE("IID_IHTMLWindow2\n");
2104 return IHTMLWindow2_QueryInterface(&This
->IHTMLWindow2_iface
, riid
, ppv
);
2107 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_guid(guidService
), debugstr_guid(riid
), ppv
);
2110 return E_NOINTERFACE
;
2112 return IServiceProvider_QueryService(&This
->doc_obj
->basedoc
.IServiceProvider_iface
,
2113 guidService
, riid
, ppv
);
2116 static const IServiceProviderVtbl ServiceProviderVtbl
= {
2117 HTMLWindowSP_QueryInterface
,
2118 HTMLWindowSP_AddRef
,
2119 HTMLWindowSP_Release
,
2120 HTMLWindowSP_QueryService
2123 static inline HTMLWindow
*impl_from_DispatchEx(DispatchEx
*iface
)
2125 return CONTAINING_RECORD(iface
, HTMLWindow
, dispex
);
2128 static HRESULT
HTMLWindow_invoke(DispatchEx
*dispex
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
2129 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
2131 HTMLWindow
*This
= impl_from_DispatchEx(dispex
);
2132 global_prop_t
*prop
;
2136 idx
= id
- MSHTML_DISPID_CUSTOM_MIN
;
2137 if(idx
>= This
->global_prop_cnt
)
2138 return DISP_E_MEMBERNOTFOUND
;
2140 prop
= This
->global_props
+idx
;
2142 switch(prop
->type
) {
2143 case GLOBAL_SCRIPTVAR
: {
2144 IDispatchEx
*dispex
;
2147 disp
= get_script_disp(prop
->script_host
);
2149 return E_UNEXPECTED
;
2151 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
2152 if(SUCCEEDED(hres
)) {
2153 TRACE("%s >>>\n", debugstr_w(prop
->name
));
2154 hres
= IDispatchEx_InvokeEx(dispex
, prop
->id
, lcid
, flags
, params
, res
, ei
, caller
);
2156 TRACE("%s <<<\n", debugstr_w(prop
->name
));
2158 WARN("%s <<< %08x\n", debugstr_w(prop
->name
), hres
);
2159 IDispatchEx_Release(dispex
);
2161 FIXME("No IDispatchEx\n");
2163 IDispatch_Release(disp
);
2166 case GLOBAL_ELEMENTVAR
: {
2169 hres
= IHTMLDocument3_getElementById(&This
->doc
->basedoc
.IHTMLDocument3_iface
,
2175 return DISP_E_MEMBERNOTFOUND
;
2177 V_VT(res
) = VT_DISPATCH
;
2178 V_DISPATCH(res
) = (IDispatch
*)elem
;
2182 ERR("invalid type %d\n", prop
->type
);
2183 hres
= DISP_E_MEMBERNOTFOUND
;
2190 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl
= {
2196 static const tid_t HTMLWindow_iface_tids
[] = {
2203 static dispex_static_data_t HTMLWindow_dispex
= {
2204 &HTMLWindow_dispex_vtbl
,
2205 DispHTMLWindow2_tid
,
2207 HTMLWindow_iface_tids
2210 HRESULT
HTMLWindow_Create(HTMLDocumentObj
*doc_obj
, nsIDOMWindow
*nswindow
, HTMLWindow
*parent
, HTMLWindow
**ret
)
2214 window
= heap_alloc_zero(sizeof(HTMLWindow
));
2216 return E_OUTOFMEMORY
;
2218 window
->window_ref
= heap_alloc(sizeof(windowref_t
));
2219 if(!window
->window_ref
) {
2221 return E_OUTOFMEMORY
;
2224 window
->IHTMLWindow2_iface
.lpVtbl
= &HTMLWindow2Vtbl
;
2225 window
->IHTMLWindow3_iface
.lpVtbl
= &HTMLWindow3Vtbl
;
2226 window
->IHTMLWindow4_iface
.lpVtbl
= &HTMLWindow4Vtbl
;
2227 window
->IHTMLPrivateWindow_iface
.lpVtbl
= &HTMLPrivateWindowVtbl
;
2228 window
->IDispatchEx_iface
.lpVtbl
= &WindowDispExVtbl
;
2229 window
->IServiceProvider_iface
.lpVtbl
= &ServiceProviderVtbl
;
2231 window
->doc_obj
= doc_obj
;
2233 window
->window_ref
->window
= window
;
2234 window
->window_ref
->ref
= 1;
2236 init_dispex(&window
->dispex
, (IUnknown
*)&window
->IHTMLWindow2_iface
, &HTMLWindow_dispex
);
2239 nsIDOMWindow_AddRef(nswindow
);
2240 window
->nswindow
= nswindow
;
2243 window
->scriptmode
= parent
? parent
->scriptmode
: SCRIPTMODE_GECKO
;
2244 window
->readystate
= READYSTATE_UNINITIALIZED
;
2245 list_init(&window
->script_hosts
);
2247 window
->task_magic
= get_task_target_magic();
2248 update_window_doc(window
);
2250 list_init(&window
->children
);
2251 list_add_head(&window_list
, &window
->entry
);
2254 IHTMLWindow2_AddRef(&window
->IHTMLWindow2_iface
);
2256 window
->parent
= parent
;
2257 list_add_tail(&parent
->children
, &window
->sibling_entry
);
2264 void update_window_doc(HTMLWindow
*window
)
2266 nsIDOMHTMLDocument
*nshtmldoc
;
2267 nsIDOMDocument
*nsdoc
;
2270 nsres
= nsIDOMWindow_GetDocument(window
->nswindow
, &nsdoc
);
2271 if(NS_FAILED(nsres
) || !nsdoc
) {
2272 ERR("GetDocument failed: %08x\n", nsres
);
2276 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMHTMLDocument
, (void**)&nshtmldoc
);
2277 nsIDOMDocument_Release(nsdoc
);
2278 if(NS_FAILED(nsres
)) {
2279 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres
);
2283 if(!window
->doc
|| window
->doc
->nsdoc
!= nshtmldoc
) {
2284 HTMLDocumentNode
*doc
;
2287 hres
= create_doc_from_nsdoc(nshtmldoc
, window
->doc_obj
, window
, &doc
);
2288 if(SUCCEEDED(hres
)) {
2289 window_set_docnode(window
, doc
);
2290 htmldoc_release(&doc
->basedoc
);
2292 ERR("create_doc_from_nsdoc failed: %08x\n", hres
);
2296 nsIDOMHTMLDocument_Release(nshtmldoc
);
2299 HTMLWindow
*nswindow_to_window(const nsIDOMWindow
*nswindow
)
2303 LIST_FOR_EACH_ENTRY(iter
, &window_list
, HTMLWindow
, entry
) {
2304 if(iter
->nswindow
== nswindow
)