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 #define HTMLPRIVWINDOW(x) ((IHTMLPrivateWindow*) &(x)->lpIHTMLPrivateWindowVtbl)
40 static struct list window_list
= LIST_INIT(window_list
);
42 static void window_set_docnode(HTMLWindow
*window
, HTMLDocumentNode
*doc_node
)
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
->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(nsview
);
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(HTMLWINDOW2(child
));
126 static HRESULT
get_location(HTMLWindow
*This
, HTMLLocation
**ret
)
129 IHTMLLocation_AddRef(HTMLLOCATION(This
->location
));
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 #define HTMLWINDOW2_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow2, iface)
164 static HRESULT WINAPI
HTMLWindow2_QueryInterface(IHTMLWindow2
*iface
, REFIID riid
, void **ppv
)
166 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
170 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
171 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
172 *ppv
= HTMLWINDOW2(This
);
173 }else if(IsEqualGUID(&IID_IDispatch
, riid
)) {
174 TRACE("(%p)->(IID_IDispatch %p)\n", This
, ppv
);
175 *ppv
= HTMLWINDOW2(This
);
176 }else if(IsEqualGUID(&IID_IDispatchEx
, riid
)) {
177 TRACE("(%p)->(IID_IDispatchEx %p)\n", This
, ppv
);
178 *ppv
= DISPATCHEX(This
);
179 }else if(IsEqualGUID(&IID_IHTMLFramesCollection2
, riid
)) {
180 TRACE("(%p)->(IID_IHTMLFramesCollection2 %p)\n", This
, ppv
);
181 *ppv
= HTMLWINDOW2(This
);
182 }else if(IsEqualGUID(&IID_IHTMLWindow2
, riid
)) {
183 TRACE("(%p)->(IID_IHTMLWindow2 %p)\n", This
, ppv
);
184 *ppv
= HTMLWINDOW2(This
);
185 }else if(IsEqualGUID(&IID_IHTMLWindow3
, riid
)) {
186 TRACE("(%p)->(IID_IHTMLWindow3 %p)\n", This
, ppv
);
187 *ppv
= HTMLWINDOW3(This
);
188 }else if(IsEqualGUID(&IID_IHTMLWindow4
, riid
)) {
189 TRACE("(%p)->(IID_IHTMLWindow4 %p)\n", This
, ppv
);
190 *ppv
= HTMLWINDOW4(This
);
191 }else if(IsEqualGUID(&IID_IHTMLPrivateWindow
, riid
)) {
192 TRACE("(%p)->(IID_IHTMLPrivateWindow %p)\n", This
, ppv
);
193 *ppv
= HTMLPRIVWINDOW(This
);
194 }else if(dispex_query_interface(&This
->dispex
, riid
, ppv
)) {
195 return *ppv
? S_OK
: E_NOINTERFACE
;
199 IUnknown_AddRef((IUnknown
*)*ppv
);
203 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
204 return E_NOINTERFACE
;
207 static ULONG WINAPI
HTMLWindow2_AddRef(IHTMLWindow2
*iface
)
209 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
210 LONG ref
= InterlockedIncrement(&This
->ref
);
212 TRACE("(%p) ref=%d\n", This
, ref
);
217 static ULONG WINAPI
HTMLWindow2_Release(IHTMLWindow2
*iface
)
219 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
220 LONG ref
= InterlockedDecrement(&This
->ref
);
222 TRACE("(%p) ref=%d\n", This
, ref
);
227 remove_target_tasks(This
->task_magic
);
228 set_window_bscallback(This
, NULL
);
229 set_current_mon(This
, NULL
);
230 window_set_docnode(This
, NULL
);
231 release_children(This
);
233 if(This
->frame_element
)
234 This
->frame_element
->content_window
= NULL
;
236 if(This
->option_factory
) {
237 This
->option_factory
->window
= NULL
;
238 IHTMLOptionElementFactory_Release(HTMLOPTFACTORY(This
->option_factory
));
241 if(This
->image_factory
) {
242 This
->image_factory
->window
= NULL
;
243 IHTMLImageElementFactory_Release(HTMLIMGFACTORY(This
->image_factory
));
247 This
->location
->window
= NULL
;
248 IHTMLLocation_Release(HTMLLOCATION(This
->location
));
252 IHTMLScreen_Release(This
->screen
);
254 for(i
=0; i
< This
->global_prop_cnt
; i
++)
255 heap_free(This
->global_props
[i
].name
);
257 This
->window_ref
->window
= NULL
;
258 windowref_release(This
->window_ref
);
260 heap_free(This
->global_props
);
261 release_script_hosts(This
);
264 nsIDOMWindow_Release(This
->nswindow
);
266 list_remove(&This
->entry
);
267 release_dispex(&This
->dispex
);
274 static HRESULT WINAPI
HTMLWindow2_GetTypeInfoCount(IHTMLWindow2
*iface
, UINT
*pctinfo
)
276 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
278 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This
), pctinfo
);
281 static HRESULT WINAPI
HTMLWindow2_GetTypeInfo(IHTMLWindow2
*iface
, UINT iTInfo
,
282 LCID lcid
, ITypeInfo
**ppTInfo
)
284 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
286 return IDispatchEx_GetTypeInfo(DISPATCHEX(This
), iTInfo
, lcid
, ppTInfo
);
289 static HRESULT WINAPI
HTMLWindow2_GetIDsOfNames(IHTMLWindow2
*iface
, REFIID riid
,
290 LPOLESTR
*rgszNames
, UINT cNames
,
291 LCID lcid
, DISPID
*rgDispId
)
293 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
295 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
298 static HRESULT WINAPI
HTMLWindow2_Invoke(IHTMLWindow2
*iface
, DISPID dispIdMember
,
299 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
300 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
302 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
304 return IDispatchEx_Invoke(DISPATCHEX(This
), dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
305 pVarResult
, pExcepInfo
, puArgErr
);
308 static HRESULT
get_frame_by_index(nsIDOMWindowCollection
*nsFrames
, PRUint32 index
, HTMLWindow
**ret
)
311 nsIDOMWindow
*nsWindow
;
314 nsres
= nsIDOMWindowCollection_GetLength(nsFrames
, &length
);
315 if(NS_FAILED(nsres
)) {
316 FIXME("nsIDOMWindowCollection_GetLength failed: 0x%08x\n", nsres
);
321 return DISP_E_MEMBERNOTFOUND
;
323 nsres
= nsIDOMWindowCollection_Item(nsFrames
, index
, &nsWindow
);
324 if(NS_FAILED(nsres
)) {
325 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
329 *ret
= nswindow_to_window(nsWindow
);
331 nsIDOMWindow_Release(nsWindow
);
336 static HRESULT WINAPI
HTMLWindow2_item(IHTMLWindow2
*iface
, VARIANT
*pvarIndex
, VARIANT
*pvarResult
)
338 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
339 nsIDOMWindowCollection
*nsFrames
;
344 TRACE("(%p)->(%p %p)\n", This
, pvarIndex
, pvarResult
);
346 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nsFrames
);
347 if(NS_FAILED(nsres
)) {
348 FIXME("nsIDOMWindow_GetFrames failed: 0x%08x\n", nsres
);
352 if(V_VT(pvarIndex
) == VT_I4
) {
353 int index
= V_I4(pvarIndex
);
354 TRACE("Getting index %d\n", index
);
356 hres
= DISP_E_MEMBERNOTFOUND
;
359 hres
= get_frame_by_index(nsFrames
, index
, &window
);
362 }else if(V_VT(pvarIndex
) == VT_UINT
) {
363 unsigned int index
= V_UINT(pvarIndex
);
364 TRACE("Getting index %u\n", index
);
365 hres
= get_frame_by_index(nsFrames
, index
, &window
);
368 }else if(V_VT(pvarIndex
) == VT_BSTR
) {
369 BSTR str
= V_BSTR(pvarIndex
);
372 TRACE("Getting name %s\n", wine_dbgstr_w(str
));
374 nsres
= nsIDOMWindowCollection_GetLength(nsFrames
, &length
);
377 for(i
= 0; i
< length
&& !window
; ++i
) {
378 HTMLWindow
*cur_window
;
379 nsIDOMWindow
*nsWindow
;
382 nsres
= nsIDOMWindowCollection_Item(nsFrames
, i
, &nsWindow
);
383 if(NS_FAILED(nsres
)) {
384 FIXME("nsIDOMWindowCollection_Item failed: 0x%08x\n", nsres
);
389 cur_window
= nswindow_to_window(nsWindow
);
391 nsIDOMWindow_Release(nsWindow
);
393 hres
= IHTMLElement_get_id(HTMLELEM(&cur_window
->frame_element
->element
), &id
);
395 FIXME("IHTMLElement_get_id failed: 0x%08x\n", hres
);
399 if(!strcmpW(id
, str
))
406 hres
= DISP_E_MEMBERNOTFOUND
;
414 IHTMLWindow2_AddRef(HTMLWINDOW2(window
));
415 V_VT(pvarResult
) = VT_DISPATCH
;
416 V_DISPATCH(pvarResult
) = (IDispatch
*)window
;
421 nsIDOMWindowCollection_Release(nsFrames
);
426 static HRESULT WINAPI
HTMLWindow2_get_length(IHTMLWindow2
*iface
, LONG
*p
)
428 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
429 nsIDOMWindowCollection
*nscollection
;
433 TRACE("(%p)->(%p)\n", This
, p
);
435 nsres
= nsIDOMWindow_GetFrames(This
->nswindow
, &nscollection
);
436 if(NS_FAILED(nsres
)) {
437 ERR("GetFrames failed: %08x\n", nsres
);
441 nsres
= nsIDOMWindowCollection_GetLength(nscollection
, &length
);
442 nsIDOMWindowCollection_Release(nscollection
);
443 if(NS_FAILED(nsres
)) {
444 ERR("GetLength failed: %08x\n", nsres
);
452 static HRESULT WINAPI
HTMLWindow2_get_frames(IHTMLWindow2
*iface
, IHTMLFramesCollection2
**p
)
454 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
455 FIXME("(%p)->(%p): semi-stub\n", This
, p
);
457 /* FIXME: Should return a separate Window object */
458 *p
= (IHTMLFramesCollection2
*)HTMLWINDOW2(This
);
459 HTMLWindow2_AddRef(iface
);
463 static HRESULT WINAPI
HTMLWindow2_put_defaultStatus(IHTMLWindow2
*iface
, BSTR v
)
465 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
466 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
470 static HRESULT WINAPI
HTMLWindow2_get_defaultStatus(IHTMLWindow2
*iface
, BSTR
*p
)
472 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
473 FIXME("(%p)->(%p)\n", This
, p
);
477 static HRESULT WINAPI
HTMLWindow2_put_status(IHTMLWindow2
*iface
, BSTR v
)
479 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
480 FIXME("(%p)->(%s)\n", This
, debugstr_w(v
));
484 static HRESULT WINAPI
HTMLWindow2_get_status(IHTMLWindow2
*iface
, BSTR
*p
)
486 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
487 FIXME("(%p)->(%p)\n", This
, p
);
491 static HRESULT WINAPI
HTMLWindow2_setTimeout(IHTMLWindow2
*iface
, BSTR expression
,
492 LONG msec
, VARIANT
*language
, LONG
*timerID
)
494 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
497 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
499 V_VT(&expr_var
) = VT_BSTR
;
500 V_BSTR(&expr_var
) = expression
;
502 return IHTMLWindow3_setTimeout(HTMLWINDOW3(This
), &expr_var
, msec
, language
, timerID
);
505 static HRESULT WINAPI
HTMLWindow2_clearTimeout(IHTMLWindow2
*iface
, LONG timerID
)
507 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
509 TRACE("(%p)->(%d)\n", This
, timerID
);
511 return clear_task_timer(&This
->doc
->basedoc
, FALSE
, timerID
);
514 static HRESULT WINAPI
HTMLWindow2_alert(IHTMLWindow2
*iface
, BSTR message
)
516 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
519 TRACE("(%p)->(%s)\n", This
, debugstr_w(message
));
521 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
522 sizeof(wszTitle
)/sizeof(WCHAR
))) {
523 WARN("Could not load message box title: %d\n", GetLastError());
527 MessageBoxW(This
->doc_obj
->hwnd
, message
, wszTitle
, MB_ICONWARNING
);
531 static HRESULT WINAPI
HTMLWindow2_confirm(IHTMLWindow2
*iface
, BSTR message
,
532 VARIANT_BOOL
*confirmed
)
534 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
537 TRACE("(%p)->(%s %p)\n", This
, debugstr_w(message
), confirmed
);
539 if(!confirmed
) return E_INVALIDARG
;
541 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
542 sizeof(wszTitle
)/sizeof(WCHAR
))) {
543 WARN("Could not load message box title: %d\n", GetLastError());
544 *confirmed
= VARIANT_TRUE
;
548 if(MessageBoxW(This
->doc_obj
->hwnd
, message
, wszTitle
,
549 MB_OKCANCEL
|MB_ICONQUESTION
)==IDOK
)
550 *confirmed
= VARIANT_TRUE
;
551 else *confirmed
= VARIANT_FALSE
;
563 static INT_PTR CALLBACK
prompt_dlgproc(HWND hwnd
, UINT msg
,
564 WPARAM wparam
, LPARAM lparam
)
570 prompt_arg
*arg
= (prompt_arg
*)lparam
;
573 if(!LoadStringW(get_shdoclc(), IDS_MESSAGE_BOX_TITLE
, wszTitle
,
574 sizeof(wszTitle
)/sizeof(WCHAR
))) {
575 WARN("Could not load message box title: %d\n", GetLastError());
576 EndDialog(hwnd
, wparam
);
580 SetWindowLongPtrW(hwnd
, DWLP_USER
, lparam
);
581 SetWindowTextW(hwnd
, wszTitle
);
582 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_PROMPT
), arg
->message
);
583 SetWindowTextW(GetDlgItem(hwnd
, ID_PROMPT_EDIT
), arg
->dststr
);
589 case MAKEWPARAM(IDCANCEL
, BN_CLICKED
):
590 EndDialog(hwnd
, wparam
);
592 case MAKEWPARAM(IDOK
, BN_CLICKED
):
595 (prompt_arg
*)GetWindowLongPtrW(hwnd
, DWLP_USER
);
596 HWND hwndPrompt
= GetDlgItem(hwnd
, ID_PROMPT_EDIT
);
597 INT len
= GetWindowTextLengthW(hwndPrompt
);
601 EndDialog(hwnd
, wparam
);
605 V_VT(arg
->textdata
) = VT_BSTR
;
606 if(!len
&& !arg
->dststr
)
607 V_BSTR(arg
->textdata
) = NULL
;
610 V_BSTR(arg
->textdata
) = SysAllocStringLen(NULL
, len
);
611 GetWindowTextW(hwndPrompt
, V_BSTR(arg
->textdata
), len
+1);
613 EndDialog(hwnd
, wparam
);
619 EndDialog(hwnd
, IDCANCEL
);
626 static HRESULT WINAPI
HTMLWindow2_prompt(IHTMLWindow2
*iface
, BSTR message
,
627 BSTR dststr
, VARIANT
*textdata
)
629 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
632 TRACE("(%p)->(%s %s %p)\n", This
, debugstr_w(message
), debugstr_w(dststr
), textdata
);
634 if(textdata
) V_VT(textdata
) = VT_NULL
;
636 arg
.message
= message
;
638 arg
.textdata
= textdata
;
640 DialogBoxParamW(hInst
, MAKEINTRESOURCEW(ID_PROMPT_DIALOG
),
641 This
->doc_obj
->hwnd
, prompt_dlgproc
, (LPARAM
)&arg
);
645 static HRESULT WINAPI
HTMLWindow2_get_Image(IHTMLWindow2
*iface
, IHTMLImageElementFactory
**p
)
647 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
649 TRACE("(%p)->(%p)\n", This
, p
);
651 if(!This
->image_factory
)
652 This
->image_factory
= HTMLImageElementFactory_Create(This
);
654 *p
= HTMLIMGFACTORY(This
->image_factory
);
655 IHTMLImageElementFactory_AddRef(*p
);
660 static HRESULT WINAPI
HTMLWindow2_get_location(IHTMLWindow2
*iface
, IHTMLLocation
**p
)
662 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
663 HTMLLocation
*location
;
666 TRACE("(%p)->(%p)\n", This
, p
);
668 hres
= get_location(This
, &location
);
672 *p
= HTMLLOCATION(location
);
676 static HRESULT WINAPI
HTMLWindow2_get_history(IHTMLWindow2
*iface
, IOmHistory
**p
)
678 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
679 FIXME("(%p)->(%p)\n", This
, p
);
683 static HRESULT WINAPI
HTMLWindow2_close(IHTMLWindow2
*iface
)
685 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
686 FIXME("(%p)->()\n", This
);
690 static HRESULT WINAPI
HTMLWindow2_put_opener(IHTMLWindow2
*iface
, VARIANT v
)
692 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
693 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
697 static HRESULT WINAPI
HTMLWindow2_get_opener(IHTMLWindow2
*iface
, VARIANT
*p
)
699 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
700 FIXME("(%p)->(%p)\n", This
, p
);
704 static HRESULT WINAPI
HTMLWindow2_get_navigator(IHTMLWindow2
*iface
, IOmNavigator
**p
)
706 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
708 TRACE("(%p)->(%p)\n", This
, p
);
710 *p
= OmNavigator_Create();
714 static HRESULT WINAPI
HTMLWindow2_put_name(IHTMLWindow2
*iface
, BSTR v
)
716 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
720 TRACE("(%p)->(%s)\n", This
, debugstr_w(v
));
722 nsAString_InitDepend(&name_str
, v
);
723 nsres
= nsIDOMWindow_SetName(This
->nswindow
, &name_str
);
724 nsAString_Finish(&name_str
);
726 ERR("SetName failed: %08x\n", nsres
);
731 static HRESULT WINAPI
HTMLWindow2_get_name(IHTMLWindow2
*iface
, BSTR
*p
)
733 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
738 TRACE("(%p)->(%p)\n", This
, p
);
740 nsAString_Init(&name_str
, NULL
);
741 nsres
= nsIDOMWindow_GetName(This
->nswindow
, &name_str
);
742 if(NS_SUCCEEDED(nsres
)) {
743 const PRUnichar
*name
;
745 nsAString_GetData(&name_str
, &name
);
747 *p
= SysAllocString(name
);
748 hres
= *p
? S_OK
: E_OUTOFMEMORY
;
754 ERR("GetName failed: %08x\n", nsres
);
757 nsAString_Finish(&name_str
);
762 static HRESULT WINAPI
HTMLWindow2_get_parent(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
764 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
765 TRACE("(%p)->(%p)\n", This
, p
);
768 *p
= HTMLWINDOW2(This
->parent
);
769 IHTMLWindow2_AddRef(*p
);
776 static HRESULT WINAPI
HTMLWindow2_open(IHTMLWindow2
*iface
, BSTR url
, BSTR name
,
777 BSTR features
, VARIANT_BOOL replace
, IHTMLWindow2
**pomWindowResult
)
779 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
780 FIXME("(%p)->(%s %s %s %x %p)\n", This
, debugstr_w(url
), debugstr_w(name
),
781 debugstr_w(features
), replace
, pomWindowResult
);
785 static HRESULT WINAPI
HTMLWindow2_get_self(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
787 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
789 TRACE("(%p)->(%p)\n", This
, p
);
791 /* FIXME: We should return kind of proxy window here. */
792 IHTMLWindow2_AddRef(HTMLWINDOW2(This
));
793 *p
= HTMLWINDOW2(This
);
797 static HRESULT WINAPI
HTMLWindow2_get_top(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
799 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
), *curr
;
800 TRACE("(%p)->(%p)\n", This
, p
);
805 *p
= HTMLWINDOW2(curr
);
806 IHTMLWindow2_AddRef(*p
);
811 static HRESULT WINAPI
HTMLWindow2_get_window(IHTMLWindow2
*iface
, IHTMLWindow2
**p
)
813 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
815 TRACE("(%p)->(%p)\n", This
, p
);
817 /* FIXME: We should return kind of proxy window here. */
818 IHTMLWindow2_AddRef(HTMLWINDOW2(This
));
819 *p
= HTMLWINDOW2(This
);
823 static HRESULT WINAPI
HTMLWindow2_navigate(IHTMLWindow2
*iface
, BSTR url
)
825 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
826 FIXME("(%p)->(%s)\n", This
, debugstr_w(url
));
830 static HRESULT WINAPI
HTMLWindow2_put_onfocus(IHTMLWindow2
*iface
, VARIANT v
)
832 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
833 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
837 static HRESULT WINAPI
HTMLWindow2_get_onfocus(IHTMLWindow2
*iface
, VARIANT
*p
)
839 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
840 FIXME("(%p)->(%p)\n", This
, p
);
844 static HRESULT WINAPI
HTMLWindow2_put_onblur(IHTMLWindow2
*iface
, VARIANT v
)
846 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
847 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
851 static HRESULT WINAPI
HTMLWindow2_get_onblur(IHTMLWindow2
*iface
, VARIANT
*p
)
853 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
854 FIXME("(%p)->(%p)\n", This
, p
);
858 static HRESULT WINAPI
HTMLWindow2_put_onload(IHTMLWindow2
*iface
, VARIANT v
)
860 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
862 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
864 return set_window_event(This
, EVENTID_LOAD
, &v
);
867 static HRESULT WINAPI
HTMLWindow2_get_onload(IHTMLWindow2
*iface
, VARIANT
*p
)
869 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
871 TRACE("(%p)->(%p)\n", This
, p
);
873 return get_window_event(This
, EVENTID_LOAD
, p
);
876 static HRESULT WINAPI
HTMLWindow2_put_onbeforeunload(IHTMLWindow2
*iface
, VARIANT v
)
878 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
880 TRACE("(%p)->(v(%d))\n", This
, V_VT(&v
));
882 return set_window_event(This
, EVENTID_BEFOREUNLOAD
, &v
);
885 static HRESULT WINAPI
HTMLWindow2_get_onbeforeunload(IHTMLWindow2
*iface
, VARIANT
*p
)
887 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
889 TRACE("(%p)->(%p)\n", This
, p
);
891 return get_window_event(This
, EVENTID_BEFOREUNLOAD
, p
);
894 static HRESULT WINAPI
HTMLWindow2_put_onunload(IHTMLWindow2
*iface
, VARIANT v
)
896 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
897 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
901 static HRESULT WINAPI
HTMLWindow2_get_onunload(IHTMLWindow2
*iface
, VARIANT
*p
)
903 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
904 FIXME("(%p)->(%p)\n", This
, p
);
908 static HRESULT WINAPI
HTMLWindow2_put_onhelp(IHTMLWindow2
*iface
, VARIANT v
)
910 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
911 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
915 static HRESULT WINAPI
HTMLWindow2_get_onhelp(IHTMLWindow2
*iface
, VARIANT
*p
)
917 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
918 FIXME("(%p)->(%p)\n", This
, p
);
922 static HRESULT WINAPI
HTMLWindow2_put_onerror(IHTMLWindow2
*iface
, VARIANT v
)
924 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
925 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
929 static HRESULT WINAPI
HTMLWindow2_get_onerror(IHTMLWindow2
*iface
, VARIANT
*p
)
931 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
932 FIXME("(%p)->(%p)\n", This
, p
);
936 static HRESULT WINAPI
HTMLWindow2_put_onresize(IHTMLWindow2
*iface
, VARIANT v
)
938 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
940 TRACE("(%p)->(%s)\n", This
, debugstr_variant(&v
));
942 return set_window_event(This
, EVENTID_RESIZE
, &v
);
945 static HRESULT WINAPI
HTMLWindow2_get_onresize(IHTMLWindow2
*iface
, VARIANT
*p
)
947 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
949 TRACE("(%p)->(%p)\n", This
, p
);
951 return get_window_event(This
, EVENTID_RESIZE
, p
);
954 static HRESULT WINAPI
HTMLWindow2_put_onscroll(IHTMLWindow2
*iface
, VARIANT v
)
956 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
957 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
961 static HRESULT WINAPI
HTMLWindow2_get_onscroll(IHTMLWindow2
*iface
, VARIANT
*p
)
963 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
964 FIXME("(%p)->(%p)\n", This
, p
);
968 static HRESULT WINAPI
HTMLWindow2_get_document(IHTMLWindow2
*iface
, IHTMLDocument2
**p
)
970 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
972 TRACE("(%p)->(%p)\n", This
, p
);
975 /* FIXME: We should return a wrapper object here */
976 *p
= HTMLDOC(&This
->doc
->basedoc
);
977 IHTMLDocument2_AddRef(*p
);
985 static HRESULT WINAPI
HTMLWindow2_get_event(IHTMLWindow2
*iface
, IHTMLEventObj
**p
)
987 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
989 TRACE("(%p)->(%p)\n", This
, p
);
992 IHTMLEventObj_AddRef(This
->event
);
997 static HRESULT WINAPI
HTMLWindow2_get__newEnum(IHTMLWindow2
*iface
, IUnknown
**p
)
999 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1000 FIXME("(%p)->(%p)\n", This
, p
);
1004 static HRESULT WINAPI
HTMLWindow2_showModalDialog(IHTMLWindow2
*iface
, BSTR dialog
,
1005 VARIANT
*varArgIn
, VARIANT
*varOptions
, VARIANT
*varArgOut
)
1007 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1008 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(dialog
), varArgIn
, varOptions
, varArgOut
);
1012 static HRESULT WINAPI
HTMLWindow2_showHelp(IHTMLWindow2
*iface
, BSTR helpURL
, VARIANT helpArg
,
1015 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1016 FIXME("(%p)->(%s v(%d) %s)\n", This
, debugstr_w(helpURL
), V_VT(&helpArg
), debugstr_w(features
));
1020 static HRESULT WINAPI
HTMLWindow2_get_screen(IHTMLWindow2
*iface
, IHTMLScreen
**p
)
1022 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1024 TRACE("(%p)->(%p)\n", This
, p
);
1029 hres
= HTMLScreen_Create(&This
->screen
);
1035 IHTMLScreen_AddRef(This
->screen
);
1039 static HRESULT WINAPI
HTMLWindow2_get_Option(IHTMLWindow2
*iface
, IHTMLOptionElementFactory
**p
)
1041 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1043 TRACE("(%p)->(%p)\n", This
, p
);
1045 if(!This
->option_factory
)
1046 This
->option_factory
= HTMLOptionElementFactory_Create(This
);
1048 *p
= HTMLOPTFACTORY(This
->option_factory
);
1049 IHTMLOptionElementFactory_AddRef(*p
);
1054 static HRESULT WINAPI
HTMLWindow2_focus(IHTMLWindow2
*iface
)
1056 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1057 FIXME("(%p)->()\n", This
);
1061 static HRESULT WINAPI
HTMLWindow2_get_closed(IHTMLWindow2
*iface
, VARIANT_BOOL
*p
)
1063 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1064 FIXME("(%p)->(%p)\n", This
, p
);
1068 static HRESULT WINAPI
HTMLWindow2_blur(IHTMLWindow2
*iface
)
1070 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1071 FIXME("(%p)->()\n", This
);
1075 static HRESULT WINAPI
HTMLWindow2_scroll(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1077 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1078 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1082 static HRESULT WINAPI
HTMLWindow2_get_clientInformation(IHTMLWindow2
*iface
, IOmNavigator
**p
)
1084 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1085 FIXME("(%p)->(%p)\n", This
, p
);
1089 static HRESULT WINAPI
HTMLWindow2_setInterval(IHTMLWindow2
*iface
, BSTR expression
,
1090 LONG msec
, VARIANT
*language
, LONG
*timerID
)
1092 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1095 TRACE("(%p)->(%s %d %p %p)\n", This
, debugstr_w(expression
), msec
, language
, timerID
);
1097 V_VT(&expr
) = VT_BSTR
;
1098 V_BSTR(&expr
) = expression
;
1099 return IHTMLWindow3_setInterval(HTMLWINDOW3(This
), &expr
, msec
, language
, timerID
);
1102 static HRESULT WINAPI
HTMLWindow2_clearInterval(IHTMLWindow2
*iface
, LONG timerID
)
1104 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1106 TRACE("(%p)->(%d)\n", This
, timerID
);
1108 return clear_task_timer(&This
->doc
->basedoc
, TRUE
, timerID
);
1111 static HRESULT WINAPI
HTMLWindow2_put_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT v
)
1113 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1114 FIXME("(%p)->(v(%d))\n", This
, V_VT(&v
));
1118 static HRESULT WINAPI
HTMLWindow2_get_offscreenBuffering(IHTMLWindow2
*iface
, VARIANT
*p
)
1120 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1121 FIXME("(%p)->(%p)\n", This
, p
);
1125 static HRESULT WINAPI
HTMLWindow2_execScript(IHTMLWindow2
*iface
, BSTR scode
, BSTR language
,
1128 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1129 FIXME("(%p)->(%s %s %p)\n", This
, debugstr_w(scode
), debugstr_w(language
), pvarRet
);
1133 static HRESULT WINAPI
HTMLWindow2_toString(IHTMLWindow2
*iface
, BSTR
*String
)
1135 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1137 static const WCHAR objectW
[] = {'[','o','b','j','e','c','t',']',0};
1139 TRACE("(%p)->(%p)\n", This
, String
);
1142 return E_INVALIDARG
;
1144 *String
= SysAllocString(objectW
);
1145 return *String
? S_OK
: E_OUTOFMEMORY
;
1148 static HRESULT WINAPI
HTMLWindow2_scrollBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1150 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1153 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1155 nsres
= nsIDOMWindow_ScrollBy(This
->nswindow
, x
, y
);
1156 if(NS_FAILED(nsres
))
1157 ERR("ScrollBy failed: %08x\n", nsres
);
1162 static HRESULT WINAPI
HTMLWindow2_scrollTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1164 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1167 TRACE("(%p)->(%d %d)\n", This
, x
, y
);
1169 nsres
= nsIDOMWindow_ScrollTo(This
->nswindow
, x
, y
);
1170 if(NS_FAILED(nsres
))
1171 ERR("ScrollTo failed: %08x\n", nsres
);
1176 static HRESULT WINAPI
HTMLWindow2_moveTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1178 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1179 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1183 static HRESULT WINAPI
HTMLWindow2_moveBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1185 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1186 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1190 static HRESULT WINAPI
HTMLWindow2_resizeTo(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1192 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1193 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1197 static HRESULT WINAPI
HTMLWindow2_resizeBy(IHTMLWindow2
*iface
, LONG x
, LONG y
)
1199 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1200 FIXME("(%p)->(%d %d)\n", This
, x
, y
);
1204 static HRESULT WINAPI
HTMLWindow2_get_external(IHTMLWindow2
*iface
, IDispatch
**p
)
1206 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1208 TRACE("(%p)->(%p)\n", This
, p
);
1212 if(!This
->doc_obj
->hostui
)
1215 return IDocHostUIHandler_GetExternal(This
->doc_obj
->hostui
, p
);
1218 static HRESULT
HTMLWindow_invoke(IUnknown
*iface
, DISPID id
, LCID lcid
, WORD flags
, DISPPARAMS
*params
,
1219 VARIANT
*res
, EXCEPINFO
*ei
, IServiceProvider
*caller
)
1221 HTMLWindow
*This
= HTMLWINDOW2_THIS(iface
);
1222 global_prop_t
*prop
;
1226 idx
= id
- MSHTML_DISPID_CUSTOM_MIN
;
1227 if(idx
>= This
->global_prop_cnt
)
1228 return DISP_E_MEMBERNOTFOUND
;
1230 prop
= This
->global_props
+idx
;
1232 switch(prop
->type
) {
1233 case GLOBAL_SCRIPTVAR
: {
1234 IDispatchEx
*dispex
;
1237 disp
= get_script_disp(prop
->script_host
);
1239 return E_UNEXPECTED
;
1241 hres
= IDispatch_QueryInterface(disp
, &IID_IDispatchEx
, (void**)&dispex
);
1242 if(SUCCEEDED(hres
)) {
1243 TRACE("%s >>>\n", debugstr_w(prop
->name
));
1244 hres
= IDispatchEx_InvokeEx(dispex
, prop
->id
, lcid
, flags
, params
, res
, ei
, caller
);
1246 TRACE("%s <<<\n", debugstr_w(prop
->name
));
1248 WARN("%s <<< %08x\n", debugstr_w(prop
->name
), hres
);
1249 IDispatchEx_Release(dispex
);
1251 FIXME("No IDispatchEx\n");
1253 IDispatch_Release(disp
);
1256 case GLOBAL_ELEMENTVAR
: {
1259 hres
= IHTMLDocument3_getElementById(HTMLDOC3(&This
->doc
->basedoc
), prop
->name
, &elem
);
1264 return DISP_E_MEMBERNOTFOUND
;
1266 V_VT(res
) = VT_DISPATCH
;
1267 V_DISPATCH(res
) = (IDispatch
*)elem
;
1271 ERR("invalid type %d\n", prop
->type
);
1272 hres
= DISP_E_MEMBERNOTFOUND
;
1278 #undef HTMLWINDOW2_THIS
1280 static const IHTMLWindow2Vtbl HTMLWindow2Vtbl
= {
1281 HTMLWindow2_QueryInterface
,
1283 HTMLWindow2_Release
,
1284 HTMLWindow2_GetTypeInfoCount
,
1285 HTMLWindow2_GetTypeInfo
,
1286 HTMLWindow2_GetIDsOfNames
,
1289 HTMLWindow2_get_length
,
1290 HTMLWindow2_get_frames
,
1291 HTMLWindow2_put_defaultStatus
,
1292 HTMLWindow2_get_defaultStatus
,
1293 HTMLWindow2_put_status
,
1294 HTMLWindow2_get_status
,
1295 HTMLWindow2_setTimeout
,
1296 HTMLWindow2_clearTimeout
,
1298 HTMLWindow2_confirm
,
1300 HTMLWindow2_get_Image
,
1301 HTMLWindow2_get_location
,
1302 HTMLWindow2_get_history
,
1304 HTMLWindow2_put_opener
,
1305 HTMLWindow2_get_opener
,
1306 HTMLWindow2_get_navigator
,
1307 HTMLWindow2_put_name
,
1308 HTMLWindow2_get_name
,
1309 HTMLWindow2_get_parent
,
1311 HTMLWindow2_get_self
,
1312 HTMLWindow2_get_top
,
1313 HTMLWindow2_get_window
,
1314 HTMLWindow2_navigate
,
1315 HTMLWindow2_put_onfocus
,
1316 HTMLWindow2_get_onfocus
,
1317 HTMLWindow2_put_onblur
,
1318 HTMLWindow2_get_onblur
,
1319 HTMLWindow2_put_onload
,
1320 HTMLWindow2_get_onload
,
1321 HTMLWindow2_put_onbeforeunload
,
1322 HTMLWindow2_get_onbeforeunload
,
1323 HTMLWindow2_put_onunload
,
1324 HTMLWindow2_get_onunload
,
1325 HTMLWindow2_put_onhelp
,
1326 HTMLWindow2_get_onhelp
,
1327 HTMLWindow2_put_onerror
,
1328 HTMLWindow2_get_onerror
,
1329 HTMLWindow2_put_onresize
,
1330 HTMLWindow2_get_onresize
,
1331 HTMLWindow2_put_onscroll
,
1332 HTMLWindow2_get_onscroll
,
1333 HTMLWindow2_get_document
,
1334 HTMLWindow2_get_event
,
1335 HTMLWindow2_get__newEnum
,
1336 HTMLWindow2_showModalDialog
,
1337 HTMLWindow2_showHelp
,
1338 HTMLWindow2_get_screen
,
1339 HTMLWindow2_get_Option
,
1341 HTMLWindow2_get_closed
,
1344 HTMLWindow2_get_clientInformation
,
1345 HTMLWindow2_setInterval
,
1346 HTMLWindow2_clearInterval
,
1347 HTMLWindow2_put_offscreenBuffering
,
1348 HTMLWindow2_get_offscreenBuffering
,
1349 HTMLWindow2_execScript
,
1350 HTMLWindow2_toString
,
1351 HTMLWindow2_scrollBy
,
1352 HTMLWindow2_scrollTo
,
1355 HTMLWindow2_resizeTo
,
1356 HTMLWindow2_resizeBy
,
1357 HTMLWindow2_get_external
1360 #define HTMLWINDOW3_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow3, iface)
1362 static HRESULT WINAPI
HTMLWindow3_QueryInterface(IHTMLWindow3
*iface
, REFIID riid
, void **ppv
)
1364 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1366 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This
), riid
, ppv
);
1369 static ULONG WINAPI
HTMLWindow3_AddRef(IHTMLWindow3
*iface
)
1371 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1373 return IHTMLWindow2_AddRef(HTMLWINDOW2(This
));
1376 static ULONG WINAPI
HTMLWindow3_Release(IHTMLWindow3
*iface
)
1378 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1380 return IHTMLWindow2_Release(HTMLWINDOW2(This
));
1383 static HRESULT WINAPI
HTMLWindow3_GetTypeInfoCount(IHTMLWindow3
*iface
, UINT
*pctinfo
)
1385 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1387 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This
), pctinfo
);
1390 static HRESULT WINAPI
HTMLWindow3_GetTypeInfo(IHTMLWindow3
*iface
, UINT iTInfo
,
1391 LCID lcid
, ITypeInfo
**ppTInfo
)
1393 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1395 return IDispatchEx_GetTypeInfo(DISPATCHEX(This
), iTInfo
, lcid
, ppTInfo
);
1398 static HRESULT WINAPI
HTMLWindow3_GetIDsOfNames(IHTMLWindow3
*iface
, REFIID riid
,
1399 LPOLESTR
*rgszNames
, UINT cNames
,
1400 LCID lcid
, DISPID
*rgDispId
)
1402 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1404 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1407 static HRESULT WINAPI
HTMLWindow3_Invoke(IHTMLWindow3
*iface
, DISPID dispIdMember
,
1408 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1409 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1411 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1413 return IDispatchEx_Invoke(DISPATCHEX(This
), dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1414 pVarResult
, pExcepInfo
, puArgErr
);
1417 static HRESULT WINAPI
HTMLWindow3_get_screenLeft(IHTMLWindow3
*iface
, LONG
*p
)
1419 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1420 FIXME("(%p)->(%p)\n", This
, p
);
1424 static HRESULT WINAPI
HTMLWindow3_get_screenTop(IHTMLWindow3
*iface
, LONG
*p
)
1426 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1427 FIXME("(%p)->(%p)\n", This
, p
);
1431 static HRESULT WINAPI
HTMLWindow3_attachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
, VARIANT_BOOL
*pfResult
)
1433 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1435 TRACE("(%p)->(%s %p %p)\n", This
, debugstr_w(event
), pDisp
, pfResult
);
1438 FIXME("No document\n");
1442 return attach_event(&This
->doc
->body_event_target
, NULL
, &This
->doc
->basedoc
, event
, pDisp
, pfResult
);
1445 static HRESULT WINAPI
HTMLWindow3_detachEvent(IHTMLWindow3
*iface
, BSTR event
, IDispatch
*pDisp
)
1447 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1448 FIXME("(%p)->()\n", This
);
1452 static HRESULT
window_set_timer(HTMLWindow
*This
, VARIANT
*expr
, LONG msec
, VARIANT
*language
,
1453 BOOL interval
, LONG
*timer_id
)
1455 IDispatch
*disp
= NULL
;
1457 switch(V_VT(expr
)) {
1459 disp
= V_DISPATCH(expr
);
1460 IDispatch_AddRef(disp
);
1464 disp
= script_parse_event(This
, V_BSTR(expr
));
1468 FIXME("unimplemented vt=%d\n", V_VT(expr
));
1475 *timer_id
= set_task_timer(&This
->doc
->basedoc
, msec
, interval
, disp
);
1476 IDispatch_Release(disp
);
1481 static HRESULT WINAPI
HTMLWindow3_setTimeout(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1482 VARIANT
*language
, LONG
*timerID
)
1484 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1486 TRACE("(%p)->(%p(%d) %d %p %p)\n", This
, expression
, V_VT(expression
), msec
, language
, timerID
);
1488 return window_set_timer(This
, expression
, msec
, language
, FALSE
, timerID
);
1491 static HRESULT WINAPI
HTMLWindow3_setInterval(IHTMLWindow3
*iface
, VARIANT
*expression
, LONG msec
,
1492 VARIANT
*language
, LONG
*timerID
)
1494 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1496 TRACE("(%p)->(%p %d %p %p)\n", This
, expression
, msec
, language
, timerID
);
1498 return window_set_timer(This
, expression
, msec
, language
, TRUE
, timerID
);
1501 static HRESULT WINAPI
HTMLWindow3_print(IHTMLWindow3
*iface
)
1503 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1504 FIXME("(%p)\n", This
);
1508 static HRESULT WINAPI
HTMLWindow3_put_onbeforeprint(IHTMLWindow3
*iface
, VARIANT v
)
1510 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1511 FIXME("(%p)->()\n", This
);
1515 static HRESULT WINAPI
HTMLWindow3_get_onbeforeprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1517 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1518 FIXME("(%p)->(%p)\n", This
, p
);
1522 static HRESULT WINAPI
HTMLWindow3_put_onafterprint(IHTMLWindow3
*iface
, VARIANT v
)
1524 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1525 FIXME("(%p)->()\n", This
);
1529 static HRESULT WINAPI
HTMLWindow3_get_onafterprint(IHTMLWindow3
*iface
, VARIANT
*p
)
1531 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1532 FIXME("(%p)->(%p)\n", This
, p
);
1536 static HRESULT WINAPI
HTMLWindow3_get_clipboardData(IHTMLWindow3
*iface
, IHTMLDataTransfer
**p
)
1538 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1539 FIXME("(%p)->(%p)\n", This
, p
);
1543 static HRESULT WINAPI
HTMLWindow3_showModelessDialog(IHTMLWindow3
*iface
, BSTR url
,
1544 VARIANT
*varArgIn
, VARIANT
*options
, IHTMLWindow2
**pDialog
)
1546 HTMLWindow
*This
= HTMLWINDOW3_THIS(iface
);
1547 FIXME("(%p)->(%s %p %p %p)\n", This
, debugstr_w(url
), varArgIn
, options
, pDialog
);
1551 #undef HTMLWINDOW3_THIS
1553 static const IHTMLWindow3Vtbl HTMLWindow3Vtbl
= {
1554 HTMLWindow3_QueryInterface
,
1556 HTMLWindow3_Release
,
1557 HTMLWindow3_GetTypeInfoCount
,
1558 HTMLWindow3_GetTypeInfo
,
1559 HTMLWindow3_GetIDsOfNames
,
1561 HTMLWindow3_get_screenLeft
,
1562 HTMLWindow3_get_screenTop
,
1563 HTMLWindow3_attachEvent
,
1564 HTMLWindow3_detachEvent
,
1565 HTMLWindow3_setTimeout
,
1566 HTMLWindow3_setInterval
,
1568 HTMLWindow3_put_onbeforeprint
,
1569 HTMLWindow3_get_onbeforeprint
,
1570 HTMLWindow3_put_onafterprint
,
1571 HTMLWindow3_get_onafterprint
,
1572 HTMLWindow3_get_clipboardData
,
1573 HTMLWindow3_showModelessDialog
1576 #define HTMLWINDOW4_THIS(iface) DEFINE_THIS(HTMLWindow, HTMLWindow4, iface)
1578 static HRESULT WINAPI
HTMLWindow4_QueryInterface(IHTMLWindow4
*iface
, REFIID riid
, void **ppv
)
1580 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1582 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This
), riid
, ppv
);
1585 static ULONG WINAPI
HTMLWindow4_AddRef(IHTMLWindow4
*iface
)
1587 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1589 return IHTMLWindow2_AddRef(HTMLWINDOW2(This
));
1592 static ULONG WINAPI
HTMLWindow4_Release(IHTMLWindow4
*iface
)
1594 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1596 return IHTMLWindow2_Release(HTMLWINDOW2(This
));
1599 static HRESULT WINAPI
HTMLWindow4_GetTypeInfoCount(IHTMLWindow4
*iface
, UINT
*pctinfo
)
1601 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1603 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(This
), pctinfo
);
1606 static HRESULT WINAPI
HTMLWindow4_GetTypeInfo(IHTMLWindow4
*iface
, UINT iTInfo
,
1607 LCID lcid
, ITypeInfo
**ppTInfo
)
1609 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1611 return IDispatchEx_GetTypeInfo(DISPATCHEX(This
), iTInfo
, lcid
, ppTInfo
);
1614 static HRESULT WINAPI
HTMLWindow4_GetIDsOfNames(IHTMLWindow4
*iface
, REFIID riid
,
1615 LPOLESTR
*rgszNames
, UINT cNames
,
1616 LCID lcid
, DISPID
*rgDispId
)
1618 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1620 return IDispatchEx_GetIDsOfNames(DISPATCHEX(This
), riid
, rgszNames
, cNames
, lcid
, rgDispId
);
1623 static HRESULT WINAPI
HTMLWindow4_Invoke(IHTMLWindow4
*iface
, DISPID dispIdMember
,
1624 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1625 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1627 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1629 return IDispatchEx_Invoke(DISPATCHEX(This
), dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1630 pVarResult
, pExcepInfo
, puArgErr
);
1633 static HRESULT WINAPI
HTMLWindow4_createPopup(IHTMLWindow4
*iface
, VARIANT
*varArgIn
,
1634 IDispatch
**ppPopup
)
1636 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1637 FIXME("(%p)->(%p %p)\n", This
, varArgIn
, ppPopup
);
1641 static HRESULT WINAPI
HTMLWindow4_get_frameElement(IHTMLWindow4
*iface
, IHTMLFrameBase
**p
)
1643 HTMLWindow
*This
= HTMLWINDOW4_THIS(iface
);
1644 TRACE("(%p)->(%p)\n", This
, p
);
1646 if(This
->frame_element
) {
1647 *p
= HTMLFRAMEBASE(This
->frame_element
);
1648 IHTMLFrameBase_AddRef(*p
);
1655 #undef HTMLWINDOW4_THIS
1657 static const IHTMLWindow4Vtbl HTMLWindow4Vtbl
= {
1658 HTMLWindow4_QueryInterface
,
1660 HTMLWindow4_Release
,
1661 HTMLWindow4_GetTypeInfoCount
,
1662 HTMLWindow4_GetTypeInfo
,
1663 HTMLWindow4_GetIDsOfNames
,
1665 HTMLWindow4_createPopup
,
1666 HTMLWindow4_get_frameElement
1669 #define HTMLPRIVWINDOW_THIS(iface) DEFINE_THIS(HTMLWindow, IHTMLPrivateWindow, iface)
1671 static HRESULT WINAPI
HTMLPrivateWindow_QueryInterface(IHTMLPrivateWindow
*iface
, REFIID riid
, void **ppv
)
1673 HTMLWindow
*This
= HTMLPRIVWINDOW_THIS(iface
);
1675 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This
), riid
, ppv
);
1678 static ULONG WINAPI
HTMLPrivateWindow_AddRef(IHTMLPrivateWindow
*iface
)
1680 HTMLWindow
*This
= HTMLPRIVWINDOW_THIS(iface
);
1682 return IHTMLWindow2_AddRef(HTMLWINDOW2(This
));
1685 static ULONG WINAPI
HTMLPrivateWindow_Release(IHTMLPrivateWindow
*iface
)
1687 HTMLWindow
*This
= HTMLPRIVWINDOW_THIS(iface
);
1689 return IHTMLWindow2_Release(HTMLWINDOW2(This
));
1692 static HRESULT WINAPI
HTMLPrivateWindow_SuperNavigate(IHTMLPrivateWindow
*iface
, BSTR url
, BSTR arg2
, BSTR arg3
,
1693 BSTR arg4
, VARIANT
*post_data_var
, VARIANT
*headers_var
, ULONG flags
)
1695 HTMLWindow
*This
= HTMLPRIVWINDOW_THIS(iface
);
1696 DWORD post_data_size
= 0;
1697 BYTE
*post_data
= NULL
;
1698 WCHAR
*headers
= NULL
;
1704 TRACE("(%p)->(%s %s %s %s %s %s %x)\n", This
, debugstr_w(url
), debugstr_w(arg2
), debugstr_w(arg3
), debugstr_w(arg4
),
1705 debugstr_variant(post_data_var
), debugstr_variant(headers_var
), flags
);
1708 if(This
->doc_obj
->hostui
) {
1709 OLECHAR
*translated_url
= NULL
;
1711 hres
= IDocHostUIHandler_TranslateUrl(This
->doc_obj
->hostui
, 0, url
, &translated_url
);
1712 if(hres
== S_OK
&& translated_url
) {
1713 new_url
= SysAllocString(translated_url
);
1714 CoTaskMemFree(translated_url
);
1718 if(This
->doc_obj
->client
) {
1719 IOleCommandTarget
*cmdtrg
;
1721 hres
= IOleClientSite_QueryInterface(This
->doc_obj
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
1722 if(SUCCEEDED(hres
)) {
1725 V_VT(&in
) = VT_BSTR
;
1726 V_BSTR(&in
) = new_url
;
1727 V_VT(&out
) = VT_BOOL
;
1728 V_BOOL(&out
) = VARIANT_TRUE
;
1729 hres
= IOleCommandTarget_Exec(cmdtrg
, &CGID_ShellDocView
, 67, 0, &in
, &out
);
1730 IOleCommandTarget_Release(cmdtrg
);
1736 /* FIXME: Why not set_ready_state? */
1737 This
->readystate
= READYSTATE_UNINITIALIZED
;
1739 hres
= CreateURLMoniker(NULL
, new_url
, &mon
);
1741 SysFreeString(new_url
);
1746 if(V_VT(post_data_var
) == (VT_ARRAY
|VT_UI1
)) {
1747 SafeArrayAccessData(V_ARRAY(post_data_var
), (void**)&post_data
);
1748 post_data_size
= V_ARRAY(post_data_var
)->rgsabound
[0].cElements
;
1752 if(headers_var
&& V_VT(headers_var
) != VT_EMPTY
&& V_VT(headers_var
) != VT_ERROR
) {
1753 if(V_VT(headers_var
) != VT_BSTR
)
1754 return E_INVALIDARG
;
1756 headers
= V_BSTR(headers_var
);
1759 hres
= create_channelbsc(mon
, headers
, post_data
, post_data_size
, &bsc
);
1761 SafeArrayUnaccessData(V_ARRAY(post_data_var
));
1763 IMoniker_Release(mon
);
1767 hres
= set_moniker(&This
->doc_obj
->basedoc
, mon
, NULL
, bsc
, TRUE
);
1769 hres
= async_start_doc_binding(This
, bsc
);
1771 IUnknown_Release((IUnknown
*)bsc
);
1772 IMoniker_Release(mon
);
1776 static HRESULT WINAPI
HTMLPrivateWindow_GetPendingUrl(IHTMLPrivateWindow
*iface
, BSTR
*url
)
1778 HTMLWindow
*This
= HTMLPRIVWINDOW_THIS(iface
);
1779 FIXME("(%p)->(%p)\n", This
, url
);
1783 static HRESULT WINAPI
HTMLPrivateWindow_SetPICSTarget(IHTMLPrivateWindow
*iface
, IOleCommandTarget
*cmdtrg
)
1785 HTMLWindow
*This
= HTMLPRIVWINDOW_THIS(iface
);
1786 FIXME("(%p)->(%p)\n", This
, cmdtrg
);
1790 static HRESULT WINAPI
HTMLPrivateWindow_PICSComplete(IHTMLPrivateWindow
*iface
, int arg
)
1792 HTMLWindow
*This
= HTMLPRIVWINDOW_THIS(iface
);
1793 FIXME("(%p)->(%x)\n", This
, arg
);
1797 static HRESULT WINAPI
HTMLPrivateWindow_FindWindowByName(IHTMLPrivateWindow
*iface
, LPCWSTR name
, IHTMLWindow2
**ret
)
1799 HTMLWindow
*This
= HTMLPRIVWINDOW_THIS(iface
);
1800 FIXME("(%p)->(%s %p)\n", This
, debugstr_w(name
), ret
);
1804 static HRESULT WINAPI
HTMLPrivateWindow_GetAddressBar(IHTMLPrivateWindow
*iface
, BSTR
*url
)
1806 HTMLWindow
*This
= HTMLPRIVWINDOW_THIS(iface
);
1807 FIXME("(%p)->(%p)\n", This
, url
);
1811 #undef HTMLPRIVWINDOW_THIS
1813 static const IHTMLPrivateWindowVtbl HTMLPrivateWindowVtbl
= {
1814 HTMLPrivateWindow_QueryInterface
,
1815 HTMLPrivateWindow_AddRef
,
1816 HTMLPrivateWindow_Release
,
1817 HTMLPrivateWindow_SuperNavigate
,
1818 HTMLPrivateWindow_GetPendingUrl
,
1819 HTMLPrivateWindow_SetPICSTarget
,
1820 HTMLPrivateWindow_PICSComplete
,
1821 HTMLPrivateWindow_FindWindowByName
,
1822 HTMLPrivateWindow_GetAddressBar
1825 #define DISPEX_THIS(iface) DEFINE_THIS(HTMLWindow, IDispatchEx, iface)
1827 static HRESULT WINAPI
WindowDispEx_QueryInterface(IDispatchEx
*iface
, REFIID riid
, void **ppv
)
1829 HTMLWindow
*This
= DISPEX_THIS(iface
);
1831 return IHTMLWindow2_QueryInterface(HTMLWINDOW2(This
), riid
, ppv
);
1834 static ULONG WINAPI
WindowDispEx_AddRef(IDispatchEx
*iface
)
1836 HTMLWindow
*This
= DISPEX_THIS(iface
);
1838 return IHTMLWindow2_AddRef(HTMLWINDOW2(This
));
1841 static ULONG WINAPI
WindowDispEx_Release(IDispatchEx
*iface
)
1843 HTMLWindow
*This
= DISPEX_THIS(iface
);
1845 return IHTMLWindow2_Release(HTMLWINDOW2(This
));
1848 static HRESULT WINAPI
WindowDispEx_GetTypeInfoCount(IDispatchEx
*iface
, UINT
*pctinfo
)
1850 HTMLWindow
*This
= DISPEX_THIS(iface
);
1852 TRACE("(%p)->(%p)\n", This
, pctinfo
);
1854 return IDispatchEx_GetTypeInfoCount(DISPATCHEX(&This
->dispex
), pctinfo
);
1857 static HRESULT WINAPI
WindowDispEx_GetTypeInfo(IDispatchEx
*iface
, UINT iTInfo
,
1858 LCID lcid
, ITypeInfo
**ppTInfo
)
1860 HTMLWindow
*This
= DISPEX_THIS(iface
);
1862 TRACE("(%p)->(%u %u %p)\n", This
, iTInfo
, lcid
, ppTInfo
);
1864 return IDispatchEx_GetTypeInfo(DISPATCHEX(&This
->dispex
), iTInfo
, lcid
, ppTInfo
);
1867 static HRESULT WINAPI
WindowDispEx_GetIDsOfNames(IDispatchEx
*iface
, REFIID riid
,
1868 LPOLESTR
*rgszNames
, UINT cNames
,
1869 LCID lcid
, DISPID
*rgDispId
)
1871 HTMLWindow
*This
= DISPEX_THIS(iface
);
1875 WARN("(%p)->(%s %p %u %u %p)\n", This
, debugstr_guid(riid
), rgszNames
, cNames
,
1878 for(i
=0; i
< cNames
; i
++) {
1879 /* We shouldn't use script's IDispatchEx here, so we shouldn't use GetDispID */
1880 hres
= IDispatchEx_GetDispID(DISPATCHEX(This
), rgszNames
[i
], 0, rgDispId
+i
);
1888 static HRESULT WINAPI
WindowDispEx_Invoke(IDispatchEx
*iface
, DISPID dispIdMember
,
1889 REFIID riid
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pDispParams
,
1890 VARIANT
*pVarResult
, EXCEPINFO
*pExcepInfo
, UINT
*puArgErr
)
1892 HTMLWindow
*This
= DISPEX_THIS(iface
);
1894 TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This
, dispIdMember
, debugstr_guid(riid
),
1895 lcid
, wFlags
, pDispParams
, pVarResult
, pExcepInfo
, puArgErr
);
1897 /* FIXME: Use script dispatch */
1899 return IDispatchEx_Invoke(DISPATCHEX(&This
->dispex
), dispIdMember
, riid
, lcid
, wFlags
, pDispParams
,
1900 pVarResult
, pExcepInfo
, puArgErr
);
1903 static global_prop_t
*alloc_global_prop(HTMLWindow
*This
, global_prop_type_t type
, BSTR name
)
1905 if(This
->global_prop_cnt
== This
->global_prop_size
) {
1906 global_prop_t
*new_props
;
1909 if(This
->global_props
) {
1910 new_size
= This
->global_prop_size
*2;
1911 new_props
= heap_realloc(This
->global_props
, new_size
*sizeof(global_prop_t
));
1914 new_props
= heap_alloc(new_size
*sizeof(global_prop_t
));
1918 This
->global_props
= new_props
;
1919 This
->global_prop_size
= new_size
;
1922 This
->global_props
[This
->global_prop_cnt
].name
= heap_strdupW(name
);
1923 if(!This
->global_props
[This
->global_prop_cnt
].name
)
1926 This
->global_props
[This
->global_prop_cnt
].type
= type
;
1927 return This
->global_props
+ This
->global_prop_cnt
++;
1930 static inline DWORD
prop_to_dispid(HTMLWindow
*This
, global_prop_t
*prop
)
1932 return MSHTML_DISPID_CUSTOM_MIN
+ (prop
-This
->global_props
);
1935 HRESULT
search_window_props(HTMLWindow
*This
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
1938 ScriptHost
*script_host
;
1941 for(i
=0; i
< This
->global_prop_cnt
; i
++) {
1942 /* FIXME: case sensitivity */
1943 if(!strcmpW(This
->global_props
[i
].name
, bstrName
)) {
1944 *pid
= MSHTML_DISPID_CUSTOM_MIN
+i
;
1949 if(find_global_prop(This
, bstrName
, grfdex
, &script_host
, &id
)) {
1950 global_prop_t
*prop
;
1952 prop
= alloc_global_prop(This
, GLOBAL_SCRIPTVAR
, bstrName
);
1954 return E_OUTOFMEMORY
;
1956 prop
->script_host
= script_host
;
1959 *pid
= prop_to_dispid(This
, prop
);
1963 return DISP_E_UNKNOWNNAME
;
1966 static HRESULT WINAPI
WindowDispEx_GetDispID(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
, DISPID
*pid
)
1968 HTMLWindow
*This
= DISPEX_THIS(iface
);
1971 TRACE("(%p)->(%s %x %p)\n", This
, debugstr_w(bstrName
), grfdex
, pid
);
1973 hres
= search_window_props(This
, bstrName
, grfdex
, pid
);
1974 if(hres
!= DISP_E_UNKNOWNNAME
)
1977 hres
= IDispatchEx_GetDispID(DISPATCHEX(&This
->dispex
), bstrName
, grfdex
, pid
);
1978 if(hres
!= DISP_E_UNKNOWNNAME
)
1982 global_prop_t
*prop
;
1985 hres
= IHTMLDocument3_getElementById(HTMLDOC3(&This
->doc
->basedoc
), bstrName
, &elem
);
1986 if(SUCCEEDED(hres
) && elem
) {
1987 IHTMLElement_Release(elem
);
1989 prop
= alloc_global_prop(This
, GLOBAL_ELEMENTVAR
, bstrName
);
1991 return E_OUTOFMEMORY
;
1993 *pid
= prop_to_dispid(This
, prop
);
1998 return DISP_E_UNKNOWNNAME
;
2001 static HRESULT WINAPI
WindowDispEx_InvokeEx(IDispatchEx
*iface
, DISPID id
, LCID lcid
, WORD wFlags
, DISPPARAMS
*pdp
,
2002 VARIANT
*pvarRes
, EXCEPINFO
*pei
, IServiceProvider
*pspCaller
)
2004 HTMLWindow
*This
= DISPEX_THIS(iface
);
2006 TRACE("(%p)->(%x %x %x %p %p %p %p)\n", This
, id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2008 if(id
== DISPID_IHTMLWINDOW2_LOCATION
&& (wFlags
& DISPATCH_PROPERTYPUT
)) {
2009 HTMLLocation
*location
;
2012 TRACE("forwarding to location.href\n");
2014 hres
= get_location(This
, &location
);
2018 hres
= IDispatchEx_InvokeEx(DISPATCHEX(&location
->dispex
), DISPID_VALUE
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2019 IHTMLLocation_Release(HTMLLOCATION(location
));
2023 return IDispatchEx_InvokeEx(DISPATCHEX(&This
->dispex
), id
, lcid
, wFlags
, pdp
, pvarRes
, pei
, pspCaller
);
2026 static HRESULT WINAPI
WindowDispEx_DeleteMemberByName(IDispatchEx
*iface
, BSTR bstrName
, DWORD grfdex
)
2028 HTMLWindow
*This
= DISPEX_THIS(iface
);
2030 TRACE("(%p)->(%s %x)\n", This
, debugstr_w(bstrName
), grfdex
);
2032 return IDispatchEx_DeleteMemberByName(DISPATCHEX(&This
->dispex
), bstrName
, grfdex
);
2035 static HRESULT WINAPI
WindowDispEx_DeleteMemberByDispID(IDispatchEx
*iface
, DISPID id
)
2037 HTMLWindow
*This
= DISPEX_THIS(iface
);
2039 TRACE("(%p)->(%x)\n", This
, id
);
2041 return IDispatchEx_DeleteMemberByDispID(DISPATCHEX(&This
->dispex
), id
);
2044 static HRESULT WINAPI
WindowDispEx_GetMemberProperties(IDispatchEx
*iface
, DISPID id
, DWORD grfdexFetch
, DWORD
*pgrfdex
)
2046 HTMLWindow
*This
= DISPEX_THIS(iface
);
2048 TRACE("(%p)->(%x %x %p)\n", This
, id
, grfdexFetch
, pgrfdex
);
2050 return IDispatchEx_GetMemberProperties(DISPATCHEX(&This
->dispex
), id
, grfdexFetch
, pgrfdex
);
2053 static HRESULT WINAPI
WindowDispEx_GetMemberName(IDispatchEx
*iface
, DISPID id
, BSTR
*pbstrName
)
2055 HTMLWindow
*This
= DISPEX_THIS(iface
);
2057 TRACE("(%p)->(%x %p)\n", This
, id
, pbstrName
);
2059 return IDispatchEx_GetMemberName(DISPATCHEX(&This
->dispex
), id
, pbstrName
);
2062 static HRESULT WINAPI
WindowDispEx_GetNextDispID(IDispatchEx
*iface
, DWORD grfdex
, DISPID id
, DISPID
*pid
)
2064 HTMLWindow
*This
= DISPEX_THIS(iface
);
2066 TRACE("(%p)->(%x %x %p)\n", This
, grfdex
, id
, pid
);
2068 return IDispatchEx_GetNextDispID(DISPATCHEX(&This
->dispex
), grfdex
, id
, pid
);
2071 static HRESULT WINAPI
WindowDispEx_GetNameSpaceParent(IDispatchEx
*iface
, IUnknown
**ppunk
)
2073 HTMLWindow
*This
= DISPEX_THIS(iface
);
2075 TRACE("(%p)->(%p)\n", This
, ppunk
);
2083 static const IDispatchExVtbl WindowDispExVtbl
= {
2084 WindowDispEx_QueryInterface
,
2085 WindowDispEx_AddRef
,
2086 WindowDispEx_Release
,
2087 WindowDispEx_GetTypeInfoCount
,
2088 WindowDispEx_GetTypeInfo
,
2089 WindowDispEx_GetIDsOfNames
,
2090 WindowDispEx_Invoke
,
2091 WindowDispEx_GetDispID
,
2092 WindowDispEx_InvokeEx
,
2093 WindowDispEx_DeleteMemberByName
,
2094 WindowDispEx_DeleteMemberByDispID
,
2095 WindowDispEx_GetMemberProperties
,
2096 WindowDispEx_GetMemberName
,
2097 WindowDispEx_GetNextDispID
,
2098 WindowDispEx_GetNameSpaceParent
2101 static const tid_t HTMLWindow_iface_tids
[] = {
2108 static const dispex_static_data_vtbl_t HTMLWindow_dispex_vtbl
= {
2114 static dispex_static_data_t HTMLWindow_dispex
= {
2115 &HTMLWindow_dispex_vtbl
,
2116 DispHTMLWindow2_tid
,
2118 HTMLWindow_iface_tids
2121 HRESULT
HTMLWindow_Create(HTMLDocumentObj
*doc_obj
, nsIDOMWindow
*nswindow
, HTMLWindow
*parent
, HTMLWindow
**ret
)
2125 window
= heap_alloc_zero(sizeof(HTMLWindow
));
2127 return E_OUTOFMEMORY
;
2129 window
->window_ref
= heap_alloc(sizeof(windowref_t
));
2130 if(!window
->window_ref
) {
2132 return E_OUTOFMEMORY
;
2135 window
->lpHTMLWindow2Vtbl
= &HTMLWindow2Vtbl
;
2136 window
->lpHTMLWindow3Vtbl
= &HTMLWindow3Vtbl
;
2137 window
->lpHTMLWindow4Vtbl
= &HTMLWindow4Vtbl
;
2138 window
->lpIHTMLPrivateWindowVtbl
= &HTMLPrivateWindowVtbl
;
2139 window
->lpIDispatchExVtbl
= &WindowDispExVtbl
;
2141 window
->doc_obj
= doc_obj
;
2143 window
->window_ref
->window
= window
;
2144 window
->window_ref
->ref
= 1;
2146 init_dispex(&window
->dispex
, (IUnknown
*)HTMLWINDOW2(window
), &HTMLWindow_dispex
);
2149 nsIDOMWindow_AddRef(nswindow
);
2150 window
->nswindow
= nswindow
;
2153 window
->scriptmode
= parent
? parent
->scriptmode
: SCRIPTMODE_GECKO
;
2154 window
->readystate
= READYSTATE_UNINITIALIZED
;
2155 list_init(&window
->script_hosts
);
2157 window
->task_magic
= get_task_target_magic();
2158 update_window_doc(window
);
2160 list_init(&window
->children
);
2161 list_add_head(&window_list
, &window
->entry
);
2164 IHTMLWindow2_AddRef(HTMLWINDOW2(window
));
2166 window
->parent
= parent
;
2167 list_add_tail(&parent
->children
, &window
->sibling_entry
);
2174 void update_window_doc(HTMLWindow
*window
)
2176 nsIDOMHTMLDocument
*nshtmldoc
;
2177 nsIDOMDocument
*nsdoc
;
2180 nsres
= nsIDOMWindow_GetDocument(window
->nswindow
, &nsdoc
);
2181 if(NS_FAILED(nsres
) || !nsdoc
) {
2182 ERR("GetDocument failed: %08x\n", nsres
);
2186 nsres
= nsIDOMDocument_QueryInterface(nsdoc
, &IID_nsIDOMHTMLDocument
, (void**)&nshtmldoc
);
2187 nsIDOMDocument_Release(nsdoc
);
2188 if(NS_FAILED(nsres
)) {
2189 ERR("Could not get nsIDOMHTMLDocument iface: %08x\n", nsres
);
2193 if(!window
->doc
|| window
->doc
->nsdoc
!= nshtmldoc
) {
2194 HTMLDocumentNode
*doc
;
2197 hres
= create_doc_from_nsdoc(nshtmldoc
, window
->doc_obj
, window
, &doc
);
2198 if(SUCCEEDED(hres
)) {
2199 window_set_docnode(window
, doc
);
2200 htmldoc_release(&doc
->basedoc
);
2202 ERR("create_doc_from_nsdoc failed: %08x\n", hres
);
2206 nsIDOMHTMLDocument_Release(nshtmldoc
);
2209 HTMLWindow
*nswindow_to_window(const nsIDOMWindow
*nswindow
)
2213 LIST_FOR_EACH_ENTRY(iter
, &window_list
, HTMLWindow
, entry
) {
2214 if(iter
->nswindow
== nswindow
)