2 * Copyright 2005-2006 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
31 #include "wine/debug.h"
33 #include "mshtml_private.h"
34 #include "htmlevent.h"
36 WINE_DEFAULT_DEBUG_CHANNEL(mshtml
);
38 #define TIMER_ID 0x1000
40 static ATOM serverwnd_class
= 0;
47 static void paint_document(HTMLDocumentObj
*This
)
53 if(This
->window
&& This
->window
->base
.inner_window
&& !This
->window
->base
.inner_window
->first_paint_time
)
54 This
->window
->base
.inner_window
->first_paint_time
= get_time_stamp();
56 GetClientRect(This
->hwnd
, &rect
);
58 hdc
= BeginPaint(This
->hwnd
, &ps
);
60 if(!(This
->hostinfo
.dwFlags
& (DOCHOSTUIFLAG_NO3DOUTERBORDER
|DOCHOSTUIFLAG_NO3DBORDER
)))
61 DrawEdge(hdc
, &rect
, EDGE_SUNKEN
, BF_RECT
|BF_ADJUST
);
63 EndPaint(This
->hwnd
, &ps
);
66 static void activate_gecko(GeckoBrowser
*This
)
68 TRACE("(%p) %p\n", This
, This
->window
);
70 SetParent(This
->hwnd
, This
->doc
->hwnd
);
71 ShowWindow(This
->hwnd
, SW_SHOW
);
73 nsIBaseWindow_SetVisibility(This
->window
, TRUE
);
74 nsIBaseWindow_SetEnabled(This
->window
, TRUE
);
77 void update_doc(HTMLDocumentObj
*This
, DWORD flags
)
79 if(!This
->update
&& This
->hwnd
)
80 SetTimer(This
->hwnd
, TIMER_ID
, 100, NULL
);
82 This
->update
|= flags
;
85 void update_title(HTMLDocumentObj
*This
)
87 IOleCommandTarget
*olecmd
;
90 if(!(This
->update
& UPDATE_TITLE
))
93 This
->update
&= ~UPDATE_TITLE
;
98 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&olecmd
);
102 V_VT(&title
) = VT_BSTR
;
103 V_BSTR(&title
) = SysAllocString(L
"");
104 IOleCommandTarget_Exec(olecmd
, NULL
, OLECMDID_SETTITLE
, OLECMDEXECOPT_DONTPROMPTUSER
,
106 SysFreeString(V_BSTR(&title
));
108 IOleCommandTarget_Release(olecmd
);
112 static LRESULT
on_timer(HTMLDocumentObj
*This
)
114 TRACE("(%p) %lx\n", This
, This
->update
);
116 KillTimer(This
->hwnd
, TIMER_ID
);
120 IUnknown_AddRef(This
->outer_unk
);
122 if(This
->update
& UPDATE_UI
) {
124 IDocHostUIHandler_UpdateUI(This
->hostui
);
127 IOleCommandTarget
*cmdtrg
;
130 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
,
132 if(SUCCEEDED(hres
)) {
133 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_UPDATECOMMANDS
,
134 OLECMDEXECOPT_DONTPROMPTUSER
, NULL
, NULL
);
135 IOleCommandTarget_Release(cmdtrg
);
143 IUnknown_Release(This
->outer_unk
);
147 void notif_focus(HTMLDocumentObj
*This
)
149 IOleControlSite
*site
;
155 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleControlSite
, (void**)&site
);
159 IOleControlSite_OnFocus(site
, This
->focus
);
160 IOleControlSite_Release(site
);
163 static LRESULT WINAPI
serverwnd_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
165 HTMLDocumentObj
*This
;
167 if(msg
== WM_CREATE
) {
168 This
= *(HTMLDocumentObj
**)lParam
;
169 SetPropW(hwnd
, L
"THIS", This
);
171 This
= GetPropW(hwnd
, L
"THIS");
179 paint_document(This
);
182 TRACE("(%p)->(WM_SIZE)\n", This
);
183 if(This
->nscontainer
) {
186 if(!(This
->hostinfo
.dwFlags
& (DOCHOSTUIFLAG_NO3DOUTERBORDER
|DOCHOSTUIFLAG_NO3DBORDER
))) {
187 ew
= GetSystemMetrics(SM_CXEDGE
);
188 eh
= GetSystemMetrics(SM_CYEDGE
);
191 SetWindowPos(This
->nscontainer
->hwnd
, NULL
, ew
, eh
,
192 LOWORD(lParam
) - 2*ew
, HIWORD(lParam
) - 2*eh
,
193 SWP_NOZORDER
| SWP_NOACTIVATE
);
197 return on_timer(This
);
199 TRACE("(%p) WM_SETFOCUS\n", This
);
200 nsIWebBrowserFocus_Activate(This
->nscontainer
->focus
);
202 case WM_MOUSEACTIVATE
:
206 return DefWindowProcW(hwnd
, msg
, wParam
, lParam
);
209 static void register_serverwnd_class(void)
211 static WNDCLASSEXW wndclass
= {
215 0, 0, NULL
, NULL
, NULL
, NULL
, NULL
,
216 L
"Internet Explorer_Server",
219 wndclass
.hInstance
= hInst
;
220 serverwnd_class
= RegisterClassExW(&wndclass
);
223 static HRESULT
activate_window(HTMLDocumentObj
*This
)
225 IOleInPlaceFrame
*pIPFrame
;
226 IOleCommandTarget
*cmdtrg
;
227 IOleInPlaceSiteEx
*ipsiteex
;
228 RECT posrect
, cliprect
;
229 OLEINPLACEFRAMEINFO frameinfo
;
234 register_serverwnd_class();
236 hres
= IOleInPlaceSite_CanInPlaceActivate(This
->ipsite
);
238 WARN("CanInPlaceActivate returned: %08lx\n", hres
);
239 return FAILED(hres
) ? hres
: E_FAIL
;
242 frameinfo
.cb
= sizeof(OLEINPLACEFRAMEINFO
);
243 hres
= IOleInPlaceSite_GetWindowContext(This
->ipsite
, &pIPFrame
, &This
->ip_window
,
244 &posrect
, &cliprect
, &frameinfo
);
246 WARN("GetWindowContext failed: %08lx\n", hres
);
250 TRACE("got window context: %p %p %s %s {%d %x %p %p %d}\n",
251 pIPFrame
, This
->ip_window
, wine_dbgstr_rect(&posrect
), wine_dbgstr_rect(&cliprect
),
252 frameinfo
.cb
, frameinfo
.fMDIApp
, frameinfo
.hwndFrame
, frameinfo
.haccel
, frameinfo
.cAccelEntries
);
254 hres
= IOleInPlaceSite_GetWindow(This
->ipsite
, &parent_hwnd
);
256 WARN("GetWindow failed: %08lx\n", hres
);
260 TRACE("got parent window %p\n", parent_hwnd
);
263 if(GetParent(This
->hwnd
) != parent_hwnd
)
264 SetParent(This
->hwnd
, parent_hwnd
);
265 SetWindowPos(This
->hwnd
, HWND_TOP
,
266 posrect
.left
, posrect
.top
, posrect
.right
-posrect
.left
, posrect
.bottom
-posrect
.top
,
267 SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
269 CreateWindowExW(0, L
"Internet Explorer_Server", NULL
,
270 WS_CHILD
| WS_CLIPSIBLINGS
| WS_CLIPCHILDREN
,
271 posrect
.left
, posrect
.top
, posrect
.right
-posrect
.left
, posrect
.bottom
-posrect
.top
,
272 parent_hwnd
, NULL
, hInst
, This
);
274 TRACE("Created window %p\n", This
->hwnd
);
276 SetWindowPos(This
->hwnd
, NULL
, 0, 0, 0, 0,
277 SWP_NOSIZE
| SWP_NOMOVE
| SWP_NOZORDER
| SWP_NOREDRAW
| SWP_NOACTIVATE
| SWP_SHOWWINDOW
);
278 RedrawWindow(This
->hwnd
, NULL
, NULL
, RDW_INVALIDATE
| RDW_NOERASE
| RDW_ALLCHILDREN
);
279 SetTimer(This
->hwnd
, TIMER_ID
, 100, NULL
);
282 if(This
->nscontainer
)
283 activate_gecko(This
->nscontainer
);
285 This
->in_place_active
= TRUE
;
286 hres
= IOleInPlaceSite_QueryInterface(This
->ipsite
, &IID_IOleInPlaceSiteEx
, (void**)&ipsiteex
);
287 if(SUCCEEDED(hres
)) {
290 hres
= IOleInPlaceSiteEx_OnInPlaceActivateEx(ipsiteex
, &redraw
, 0);
291 IOleInPlaceSiteEx_Release(ipsiteex
);
293 FIXME("unsupported redraw\n");
295 hres
= IOleInPlaceSite_OnInPlaceActivate(This
->ipsite
);
298 WARN("OnInPlaceActivate failed: %08lx\n", hres
);
299 This
->in_place_active
= FALSE
;
303 hres
= IOleClientSite_QueryInterface(This
->client
, &IID_IOleCommandTarget
, (void**)&cmdtrg
);
304 if(SUCCEEDED(hres
)) {
307 IOleInPlaceFrame_SetStatusText(pIPFrame
, NULL
);
311 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSMAX
,
312 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
313 IOleCommandTarget_Exec(cmdtrg
, NULL
, OLECMDID_SETPROGRESSPOS
,
314 OLECMDEXECOPT_DONTPROMPTUSER
, &var
, NULL
);
316 IOleCommandTarget_Release(cmdtrg
);
320 IOleInPlaceFrame_Release(This
->frame
);
321 This
->frame
= pIPFrame
;
323 if(!This
->request_uiactivate
) {
324 hres
= IOleInPlaceSite_QueryInterface(This
->ipsite
, &IID_IOleInPlaceSiteEx
, (void**)&ipsiteex
);
325 if(SUCCEEDED(hres
)) {
326 IOleInPlaceSiteEx_RequestUIActivate(ipsiteex
);
327 IOleInPlaceSiteEx_Release(ipsiteex
);
331 This
->window_active
= TRUE
;
336 static LRESULT WINAPI
tooltips_proc(HWND hwnd
, UINT msg
, WPARAM wParam
, LPARAM lParam
)
338 tooltip_data
*data
= GetPropW(hwnd
, L
"tooltip_data");
340 TRACE("%d %p\n", msg
, data
);
342 if(msg
== TTM_WINDOWFROMPOINT
) {
344 POINT
*pt
= (POINT
*)lParam
;
346 TRACE("TTM_WINDOWFROMPOINT (%ld,%ld)\n", pt
->x
, pt
->y
);
348 GetWindowRect(data
->doc
->hwnd
, &rect
);
350 if(rect
.left
<= pt
->x
&& pt
->x
<= rect
.right
351 && rect
.top
<= pt
->y
&& pt
->y
<= rect
.bottom
)
352 return (LPARAM
)data
->doc
->hwnd
;
355 return CallWindowProcW(data
->proc
, hwnd
, msg
, wParam
, lParam
);
358 static void create_tooltips_window(HTMLDocumentObj
*This
)
360 tooltip_data
*data
= malloc(sizeof(*data
));
362 This
->tooltips_hwnd
= CreateWindowExW(0, TOOLTIPS_CLASSW
, NULL
, TTS_NOPREFIX
| WS_POPUP
,
363 CW_USEDEFAULT
, CW_USEDEFAULT
, 10, 10, This
->hwnd
, NULL
, hInst
, NULL
);
366 data
->proc
= (WNDPROC
)GetWindowLongPtrW(This
->tooltips_hwnd
, GWLP_WNDPROC
);
368 SetPropW(This
->tooltips_hwnd
, L
"tooltip_data", data
);
370 SetWindowLongPtrW(This
->tooltips_hwnd
, GWLP_WNDPROC
, (LONG_PTR
)tooltips_proc
);
372 SetWindowPos(This
->tooltips_hwnd
, HWND_TOPMOST
,0, 0, 0, 0,
373 SWP_NOMOVE
| SWP_NOSIZE
| SWP_NOACTIVATE
);
377 void show_tooltip(HTMLDocumentObj
*This
, DWORD x
, DWORD y
, LPCWSTR text
)
379 TTTOOLINFOW toolinfo
= {
380 sizeof(TTTOOLINFOW
), 0, This
->hwnd
, 0xdeadbeef,
381 {x
>2 ? x
-2 : 0, y
>0 ? y
-2 : 0, x
+2, y
+2}, /* FIXME */
382 NULL
, (LPWSTR
)text
, 0};
383 MSG msg
= {This
->hwnd
, WM_MOUSEMOVE
, 0, MAKELPARAM(x
,y
), 0, {x
,y
}};
385 TRACE("(%p)->(%ld %ld %s)\n", This
, x
, y
, debugstr_w(text
));
387 if(!This
->tooltips_hwnd
)
388 create_tooltips_window(This
);
390 SendMessageW(This
->tooltips_hwnd
, TTM_ADDTOOLW
, 0, (LPARAM
)&toolinfo
);
391 SendMessageW(This
->tooltips_hwnd
, TTM_ACTIVATE
, TRUE
, 0);
392 SendMessageW(This
->tooltips_hwnd
, TTM_RELAYEVENT
, 0, (LPARAM
)&msg
);
395 void hide_tooltip(HTMLDocumentObj
*This
)
397 TTTOOLINFOW toolinfo
= {
398 sizeof(TTTOOLINFOW
), 0, This
->hwnd
, 0xdeadbeef,
399 {0,0,0,0}, NULL
, NULL
, 0};
401 TRACE("(%p)\n", This
);
403 SendMessageW(This
->tooltips_hwnd
, TTM_DELTOOLW
, 0, (LPARAM
)&toolinfo
);
404 SendMessageW(This
->tooltips_hwnd
, TTM_ACTIVATE
, FALSE
, 0);
407 HRESULT
call_set_active_object(IOleInPlaceUIWindow
*window
, IOleInPlaceActiveObject
*act_obj
)
409 static WCHAR html_documentW
[30];
411 if(act_obj
&& !html_documentW
[0])
412 LoadStringW(hInst
, IDS_HTMLDOCUMENT
, html_documentW
, ARRAY_SIZE(html_documentW
));
414 return IOleInPlaceUIWindow_SetActiveObject(window
, act_obj
, act_obj
? html_documentW
: NULL
);
417 static unsigned get_window_list_num(HTMLInnerWindow
*window
)
419 HTMLOuterWindow
*child
;
422 LIST_FOR_EACH_ENTRY(child
, &window
->children
, HTMLOuterWindow
, sibling_entry
)
423 ret
+= get_window_list_num(child
->base
.inner_window
);
427 static HTMLInnerWindow
**get_window_list(HTMLInnerWindow
*window
, HTMLInnerWindow
**output
)
429 HTMLOuterWindow
*child
;
432 IHTMLWindow2_AddRef(&window
->base
.IHTMLWindow2_iface
);
434 LIST_FOR_EACH_ENTRY(child
, &window
->children
, HTMLOuterWindow
, sibling_entry
)
435 output
= get_window_list(child
->base
.inner_window
, output
);
439 static void send_unload_events(HTMLDocumentObj
*doc
)
441 HTMLInnerWindow
**windows
, *window
;
446 if(!doc
->window
|| !doc
->doc_node
->content_ready
)
448 window
= doc
->window
->base
.inner_window
;
450 /* Grab list of all windows ahead, and keep refs,
451 since it can be detached from under our feet. */
452 num
= get_window_list_num(window
);
453 if(!(windows
= malloc(num
* sizeof(*windows
))))
455 get_window_list(window
, windows
);
457 for(i
= 0; i
< num
; i
++) {
460 if(window
->doc
&& !window
->doc
->unload_sent
) {
461 window
->doc
->unload_sent
= TRUE
;
463 /* Native sends pagehide events prior to unload on the same window
464 before it moves on to the next window, so they're interleaved. */
465 if(window
->doc
->document_mode
>= COMPAT_MODE_IE11
) {
466 hres
= create_document_event(window
->doc
, EVENTID_PAGEHIDE
, &event
);
467 if(SUCCEEDED(hres
)) {
468 dispatch_event(&window
->event_target
, event
);
469 IDOMEvent_Release(&event
->IDOMEvent_iface
);
473 hres
= create_document_event(window
->doc
, EVENTID_UNLOAD
, &event
);
474 if(SUCCEEDED(hres
)) {
475 dispatch_event(&window
->event_target
, event
);
476 IDOMEvent_Release(&event
->IDOMEvent_iface
);
480 IHTMLWindow2_Release(&window
->base
.IHTMLWindow2_iface
);
486 /**********************************************************
487 * IOleDocumentView implementation
490 static inline HTMLDocumentObj
*impl_from_IOleDocumentView(IOleDocumentView
*iface
)
492 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IOleDocumentView_iface
);
495 static HRESULT WINAPI
OleDocumentView_QueryInterface(IOleDocumentView
*iface
, REFIID riid
, void **ppvObject
)
497 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
498 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppvObject
);
501 static ULONG WINAPI
OleDocumentView_AddRef(IOleDocumentView
*iface
)
503 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
504 return IUnknown_AddRef(This
->outer_unk
);
507 static ULONG WINAPI
OleDocumentView_Release(IOleDocumentView
*iface
)
509 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
510 return IUnknown_Release(This
->outer_unk
);
513 static HRESULT WINAPI
OleDocumentView_SetInPlaceSite(IOleDocumentView
*iface
, IOleInPlaceSite
*pIPSite
)
515 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
516 TRACE("(%p)->(%p)\n", This
, pIPSite
);
519 IOleInPlaceSite_AddRef(pIPSite
);
522 IOleInPlaceSite_Release(This
->ipsite
);
524 This
->ipsite
= pIPSite
;
525 This
->request_uiactivate
= TRUE
;
529 static HRESULT WINAPI
OleDocumentView_GetInPlaceSite(IOleDocumentView
*iface
, IOleInPlaceSite
**ppIPSite
)
531 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
532 TRACE("(%p)->(%p)\n", This
, ppIPSite
);
538 IOleInPlaceSite_AddRef(This
->ipsite
);
540 *ppIPSite
= This
->ipsite
;
544 static HRESULT WINAPI
OleDocumentView_GetDocument(IOleDocumentView
*iface
, IUnknown
**ppunk
)
546 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
547 TRACE("(%p)->(%p)\n", This
, ppunk
);
552 *ppunk
= (IUnknown
*)&This
->IHTMLDocument2_iface
;
553 IUnknown_AddRef(*ppunk
);
557 static HRESULT WINAPI
OleDocumentView_SetRect(IOleDocumentView
*iface
, LPRECT prcView
)
559 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
562 TRACE("(%p)->(%p)\n", This
, prcView
);
568 GetClientRect(This
->hwnd
, &rect
);
569 if(!EqualRect(prcView
, &rect
)) {
570 InvalidateRect(This
->hwnd
, NULL
, TRUE
);
571 SetWindowPos(This
->hwnd
, NULL
, prcView
->left
, prcView
->top
, prcView
->right
- prcView
->left
,
572 prcView
->bottom
- prcView
->top
, SWP_NOZORDER
| SWP_NOACTIVATE
);
579 static HRESULT WINAPI
OleDocumentView_GetRect(IOleDocumentView
*iface
, LPRECT prcView
)
581 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
583 TRACE("(%p)->(%p)\n", This
, prcView
);
588 GetClientRect(This
->hwnd
, prcView
);
589 MapWindowPoints(This
->hwnd
, GetParent(This
->hwnd
), (POINT
*)prcView
, 2);
593 static HRESULT WINAPI
OleDocumentView_SetRectComplex(IOleDocumentView
*iface
, LPRECT prcView
,
594 LPRECT prcHScroll
, LPRECT prcVScroll
, LPRECT prcSizeBox
)
596 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
597 FIXME("(%p)->(%p %p %p %p)\n", This
, prcView
, prcHScroll
, prcVScroll
, prcSizeBox
);
601 static HRESULT WINAPI
OleDocumentView_Show(IOleDocumentView
*iface
, BOOL fShow
)
603 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
606 TRACE("(%p)->(%x)\n", This
, fShow
);
609 if(!This
->ui_active
) {
610 hres
= activate_window(This
);
614 update_doc(This
, UPDATE_UI
);
615 ShowWindow(This
->hwnd
, SW_SHOW
);
617 ShowWindow(This
->hwnd
, SW_HIDE
);
619 if(This
->in_place_active
)
620 IOleInPlaceObjectWindowless_InPlaceDeactivate(&This
->IOleInPlaceObjectWindowless_iface
);
622 unlink_ref(&This
->ip_window
);
628 static HRESULT WINAPI
OleDocumentView_UIActivate(IOleDocumentView
*iface
, BOOL fUIActivate
)
630 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
633 TRACE("(%p)->(%x)\n", This
, fUIActivate
);
636 IOleClientSite
*cs
= This
->client
;
637 IOleInPlaceSite
*ips
;
640 WARN("this->ipsite = NULL\n");
644 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSiteWindowless
, (void**)&ips
);
648 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSiteEx
, (void**)&ips
);
652 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSite
, (void**)&ips
);
656 WARN("this->ipsite = NULL\n");
657 return E_NOINTERFACE
;
662 IOleInPlaceSite_AddRef(This
->ipsite
);
663 This
->request_uiactivate
= FALSE
;
664 HTMLDocument_LockContainer(This
, TRUE
);
673 if(!This
->window_active
) {
674 hres
= activate_window(This
);
680 if(This
->nscontainer
)
681 nsIWebBrowserFocus_Activate(This
->nscontainer
->focus
);
684 update_doc(This
, UPDATE_UI
);
686 hres
= IOleInPlaceSite_OnUIActivate(This
->ipsite
);
687 if(SUCCEEDED(hres
)) {
688 call_set_active_object((IOleInPlaceUIWindow
*)This
->frame
, &This
->IOleInPlaceActiveObject_iface
);
690 FIXME("OnUIActivate failed: %08lx\n", hres
);
691 IOleInPlaceFrame_Release(This
->frame
);
693 This
->ui_active
= FALSE
;
698 hres
= IDocHostUIHandler_ShowUI(This
->hostui
,
699 This
->nscontainer
->usermode
== EDITMODE
? DOCHOSTUITYPE_AUTHOR
: DOCHOSTUITYPE_BROWSE
,
700 &This
->IOleInPlaceActiveObject_iface
, &This
->IOleCommandTarget_iface
,
701 This
->frame
, This
->ip_window
);
703 IDocHostUIHandler_HideUI(This
->hostui
);
707 call_set_active_object(This
->ip_window
, &This
->IOleInPlaceActiveObject_iface
);
709 SetRectEmpty(&rcBorderWidths
);
710 IOleInPlaceFrame_SetBorderSpace(This
->frame
, &rcBorderWidths
);
712 This
->ui_active
= TRUE
;
715 nsIWebBrowserFocus_Deactivate(This
->nscontainer
->focus
);
716 if(This
->ui_active
) {
717 This
->ui_active
= FALSE
;
719 call_set_active_object(This
->ip_window
, NULL
);
721 call_set_active_object((IOleInPlaceUIWindow
*)This
->frame
, NULL
);
723 IDocHostUIHandler_HideUI(This
->hostui
);
725 IOleInPlaceSite_OnUIDeactivate(This
->ipsite
, FALSE
);
731 static HRESULT WINAPI
OleDocumentView_Open(IOleDocumentView
*iface
)
733 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
734 FIXME("(%p)\n", This
);
738 static HRESULT WINAPI
OleDocumentView_CloseView(IOleDocumentView
*iface
, DWORD dwReserved
)
740 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
741 TRACE("(%p)->(%lx)\n", This
, dwReserved
);
744 WARN("dwReserved = %ld\n", dwReserved
);
746 send_unload_events(This
);
747 IOleDocumentView_Show(iface
, FALSE
);
751 static HRESULT WINAPI
OleDocumentView_SaveViewState(IOleDocumentView
*iface
, IStream
*pstm
)
753 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
754 FIXME("(%p)->(%p)\n", This
, pstm
);
758 static HRESULT WINAPI
OleDocumentView_ApplyViewState(IOleDocumentView
*iface
, IStream
*pstm
)
760 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
761 FIXME("(%p)->(%p)\n", This
, pstm
);
765 static HRESULT WINAPI
OleDocumentView_Clone(IOleDocumentView
*iface
, IOleInPlaceSite
*pIPSiteNew
,
766 IOleDocumentView
**ppViewNew
)
768 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
769 FIXME("(%p)->(%p %p)\n", This
, pIPSiteNew
, ppViewNew
);
773 static const IOleDocumentViewVtbl OleDocumentViewVtbl
= {
774 OleDocumentView_QueryInterface
,
775 OleDocumentView_AddRef
,
776 OleDocumentView_Release
,
777 OleDocumentView_SetInPlaceSite
,
778 OleDocumentView_GetInPlaceSite
,
779 OleDocumentView_GetDocument
,
780 OleDocumentView_SetRect
,
781 OleDocumentView_GetRect
,
782 OleDocumentView_SetRectComplex
,
783 OleDocumentView_Show
,
784 OleDocumentView_UIActivate
,
785 OleDocumentView_Open
,
786 OleDocumentView_CloseView
,
787 OleDocumentView_SaveViewState
,
788 OleDocumentView_ApplyViewState
,
789 OleDocumentView_Clone
792 /**********************************************************
793 * IViewObject implementation
796 static inline HTMLDocumentObj
*impl_from_IViewObjectEx(IViewObjectEx
*iface
)
798 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IViewObjectEx_iface
);
801 static HRESULT WINAPI
ViewObject_QueryInterface(IViewObjectEx
*iface
, REFIID riid
, void **ppv
)
803 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
804 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
807 static ULONG WINAPI
ViewObject_AddRef(IViewObjectEx
*iface
)
809 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
810 return IUnknown_AddRef(This
->outer_unk
);
813 static ULONG WINAPI
ViewObject_Release(IViewObjectEx
*iface
)
815 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
816 return IUnknown_Release(This
->outer_unk
);
819 static HRESULT WINAPI
ViewObject_Draw(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
,
820 DVTARGETDEVICE
*ptd
, HDC hdcTargetDev
, HDC hdcDraw
, LPCRECTL lprcBounds
,
821 LPCRECTL lprcWBounds
, BOOL (CALLBACK
*pfnContinue
)(ULONG_PTR dwContinue
), ULONG_PTR dwContinue
)
823 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
824 FIXME("(%p)->(%ld %ld %p %p %p %p %p %p %p %Id)\n", This
, dwDrawAspect
, lindex
, pvAspect
,
825 ptd
, hdcTargetDev
, hdcDraw
, lprcBounds
, lprcWBounds
, pfnContinue
, dwContinue
);
829 static HRESULT WINAPI
ViewObject_GetColorSet(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
,
830 DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, LOGPALETTE
**ppColorSet
)
832 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
833 FIXME("(%p)->(%ld %ld %p %p %p %p)\n", This
, dwDrawAspect
, lindex
, pvAspect
, ptd
, hicTargetDev
, ppColorSet
);
837 static HRESULT WINAPI
ViewObject_Freeze(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
,
838 void *pvAspect
, DWORD
*pdwFreeze
)
840 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
841 FIXME("(%p)->(%ld %ld %p %p)\n", This
, dwDrawAspect
, lindex
, pvAspect
, pdwFreeze
);
845 static HRESULT WINAPI
ViewObject_Unfreeze(IViewObjectEx
*iface
, DWORD dwFreeze
)
847 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
848 FIXME("(%p)->(%ld)\n", This
, dwFreeze
);
852 static HRESULT WINAPI
ViewObject_SetAdvise(IViewObjectEx
*iface
, DWORD aspects
, DWORD advf
, IAdviseSink
*pAdvSink
)
854 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
856 TRACE("(%p)->(%ld %ld %p)\n", This
, aspects
, advf
, pAdvSink
);
858 if(aspects
!= DVASPECT_CONTENT
|| advf
!= ADVF_PRIMEFIRST
)
859 FIXME("unsupported arguments\n");
862 IAdviseSink_Release(This
->view_sink
);
864 IAdviseSink_AddRef(pAdvSink
);
866 This
->view_sink
= pAdvSink
;
870 static HRESULT WINAPI
ViewObject_GetAdvise(IViewObjectEx
*iface
, DWORD
*pAspects
, DWORD
*pAdvf
, IAdviseSink
**ppAdvSink
)
872 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
873 FIXME("(%p)->(%p %p %p)\n", This
, pAspects
, pAdvf
, ppAdvSink
);
877 static HRESULT WINAPI
ViewObject_GetExtent(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
,
878 DVTARGETDEVICE
* ptd
, LPSIZEL lpsizel
)
880 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
881 FIXME("(%p)->(%ld %ld %p %p)\n", This
, dwDrawAspect
, lindex
, ptd
, lpsizel
);
885 static HRESULT WINAPI
ViewObject_GetRect(IViewObjectEx
*iface
, DWORD dwAspect
, LPRECTL pRect
)
887 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
888 FIXME("(%p)->(%ld %p)\n", This
, dwAspect
, pRect
);
892 static HRESULT WINAPI
ViewObject_GetViewStatus(IViewObjectEx
*iface
, DWORD
*pdwStatus
)
894 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
895 FIXME("(%p)->(%p)\n", This
, pdwStatus
);
899 static HRESULT WINAPI
ViewObject_QueryHitPoint(IViewObjectEx
* iface
, DWORD dwAspect
,
900 LPCRECT pRectBounds
, POINT ptlLoc
, LONG lCloseHint
, DWORD
*pHitResult
)
902 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
903 FIXME("(%p)->(%ld %p (%ld %ld) %ld %p)\n", This
, dwAspect
, pRectBounds
, ptlLoc
.x
,
904 ptlLoc
.y
, lCloseHint
, pHitResult
);
908 static HRESULT WINAPI
ViewObject_QueryHitRect(IViewObjectEx
*iface
, DWORD dwAspect
,
909 LPCRECT pRectBounds
, LPCRECT pRectLoc
, LONG lCloseHint
, DWORD
*pHitResult
)
911 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
912 FIXME("(%p)->(%ld %p %p %ld %p)\n", This
, dwAspect
, pRectBounds
, pRectLoc
, lCloseHint
, pHitResult
);
916 static HRESULT WINAPI
ViewObject_GetNaturalExtent(IViewObjectEx
*iface
, DWORD dwAspect
, LONG lindex
,
917 DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, DVEXTENTINFO
*pExtentInfo
, LPSIZEL pSizel
)
919 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
920 FIXME("(%p)->(%ld %ld %p %p %p %p\n", This
, dwAspect
,lindex
, ptd
,
921 hicTargetDev
, pExtentInfo
, pSizel
);
925 static const IViewObjectExVtbl ViewObjectVtbl
= {
926 ViewObject_QueryInterface
,
930 ViewObject_GetColorSet
,
933 ViewObject_SetAdvise
,
934 ViewObject_GetAdvise
,
935 ViewObject_GetExtent
,
937 ViewObject_GetViewStatus
,
938 ViewObject_QueryHitPoint
,
939 ViewObject_QueryHitRect
,
940 ViewObject_GetNaturalExtent
943 static inline HTMLDocumentObj
*impl_from_IWindowForBindingUI(IWindowForBindingUI
*iface
)
945 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IWindowForBindingUI_iface
);
948 static HRESULT WINAPI
WindowForBindingUI_QueryInterface(IWindowForBindingUI
*iface
, REFIID riid
, void **ppv
)
950 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
952 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
953 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
954 *ppv
= &This
->IWindowForBindingUI_iface
;
955 }else if(IsEqualGUID(&IID_IWindowForBindingUI
, riid
)) {
956 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This
, ppv
);
957 *ppv
= &This
->IWindowForBindingUI_iface
;
959 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
961 return E_NOINTERFACE
;
964 IUnknown_AddRef((IUnknown
*)*ppv
);
968 static ULONG WINAPI
WindowForBindingUI_AddRef(IWindowForBindingUI
*iface
)
970 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
971 return IUnknown_AddRef(This
->outer_unk
);
974 static ULONG WINAPI
WindowForBindingUI_Release(IWindowForBindingUI
*iface
)
976 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
977 return IUnknown_Release(This
->outer_unk
);
980 static HRESULT WINAPI
WindowForBindingUI_GetWindow(IWindowForBindingUI
*iface
, REFGUID rguidReason
, HWND
*phwnd
)
982 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
984 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(rguidReason
), phwnd
);
990 static const IWindowForBindingUIVtbl WindowForBindingUIVtbl
= {
991 WindowForBindingUI_QueryInterface
,
992 WindowForBindingUI_AddRef
,
993 WindowForBindingUI_Release
,
994 WindowForBindingUI_GetWindow
997 void HTMLDocument_View_Init(HTMLDocumentObj
*doc
)
999 doc
->IOleDocumentView_iface
.lpVtbl
= &OleDocumentViewVtbl
;
1000 doc
->IViewObjectEx_iface
.lpVtbl
= &ViewObjectVtbl
;
1001 doc
->IWindowForBindingUI_iface
.lpVtbl
= &WindowForBindingUIVtbl
;