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
->performance_timing
->first_paint_time
)
54 This
->window
->base
.inner_window
->performance_timing
->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 if(This
->ip_window
) {
623 IOleInPlaceUIWindow_Release(This
->ip_window
);
624 This
->ip_window
= NULL
;
631 static HRESULT WINAPI
OleDocumentView_UIActivate(IOleDocumentView
*iface
, BOOL fUIActivate
)
633 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
636 TRACE("(%p)->(%x)\n", This
, fUIActivate
);
639 IOleClientSite
*cs
= This
->client
;
640 IOleInPlaceSite
*ips
;
643 WARN("this->ipsite = NULL\n");
647 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSiteWindowless
, (void**)&ips
);
651 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSiteEx
, (void**)&ips
);
655 hres
= IOleClientSite_QueryInterface(cs
, &IID_IOleInPlaceSite
, (void**)&ips
);
659 WARN("this->ipsite = NULL\n");
660 return E_NOINTERFACE
;
665 IOleInPlaceSite_AddRef(This
->ipsite
);
666 This
->request_uiactivate
= FALSE
;
667 HTMLDocument_LockContainer(This
, TRUE
);
676 if(!This
->window_active
) {
677 hres
= activate_window(This
);
683 if(This
->nscontainer
)
684 nsIWebBrowserFocus_Activate(This
->nscontainer
->focus
);
687 update_doc(This
, UPDATE_UI
);
689 hres
= IOleInPlaceSite_OnUIActivate(This
->ipsite
);
690 if(SUCCEEDED(hres
)) {
691 call_set_active_object((IOleInPlaceUIWindow
*)This
->frame
, &This
->IOleInPlaceActiveObject_iface
);
693 FIXME("OnUIActivate failed: %08lx\n", hres
);
694 IOleInPlaceFrame_Release(This
->frame
);
696 This
->ui_active
= FALSE
;
701 hres
= IDocHostUIHandler_ShowUI(This
->hostui
,
702 This
->nscontainer
->usermode
== EDITMODE
? DOCHOSTUITYPE_AUTHOR
: DOCHOSTUITYPE_BROWSE
,
703 &This
->IOleInPlaceActiveObject_iface
, &This
->IOleCommandTarget_iface
,
704 This
->frame
, This
->ip_window
);
706 IDocHostUIHandler_HideUI(This
->hostui
);
710 call_set_active_object(This
->ip_window
, &This
->IOleInPlaceActiveObject_iface
);
712 SetRectEmpty(&rcBorderWidths
);
713 IOleInPlaceFrame_SetBorderSpace(This
->frame
, &rcBorderWidths
);
715 This
->ui_active
= TRUE
;
718 nsIWebBrowserFocus_Deactivate(This
->nscontainer
->focus
);
719 if(This
->ui_active
) {
720 This
->ui_active
= FALSE
;
722 call_set_active_object(This
->ip_window
, NULL
);
724 call_set_active_object((IOleInPlaceUIWindow
*)This
->frame
, NULL
);
726 IDocHostUIHandler_HideUI(This
->hostui
);
728 IOleInPlaceSite_OnUIDeactivate(This
->ipsite
, FALSE
);
734 static HRESULT WINAPI
OleDocumentView_Open(IOleDocumentView
*iface
)
736 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
737 FIXME("(%p)\n", This
);
741 static HRESULT WINAPI
OleDocumentView_CloseView(IOleDocumentView
*iface
, DWORD dwReserved
)
743 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
744 TRACE("(%p)->(%lx)\n", This
, dwReserved
);
747 WARN("dwReserved = %ld\n", dwReserved
);
749 send_unload_events(This
);
750 IOleDocumentView_Show(iface
, FALSE
);
754 static HRESULT WINAPI
OleDocumentView_SaveViewState(IOleDocumentView
*iface
, IStream
*pstm
)
756 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
757 FIXME("(%p)->(%p)\n", This
, pstm
);
761 static HRESULT WINAPI
OleDocumentView_ApplyViewState(IOleDocumentView
*iface
, IStream
*pstm
)
763 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
764 FIXME("(%p)->(%p)\n", This
, pstm
);
768 static HRESULT WINAPI
OleDocumentView_Clone(IOleDocumentView
*iface
, IOleInPlaceSite
*pIPSiteNew
,
769 IOleDocumentView
**ppViewNew
)
771 HTMLDocumentObj
*This
= impl_from_IOleDocumentView(iface
);
772 FIXME("(%p)->(%p %p)\n", This
, pIPSiteNew
, ppViewNew
);
776 static const IOleDocumentViewVtbl OleDocumentViewVtbl
= {
777 OleDocumentView_QueryInterface
,
778 OleDocumentView_AddRef
,
779 OleDocumentView_Release
,
780 OleDocumentView_SetInPlaceSite
,
781 OleDocumentView_GetInPlaceSite
,
782 OleDocumentView_GetDocument
,
783 OleDocumentView_SetRect
,
784 OleDocumentView_GetRect
,
785 OleDocumentView_SetRectComplex
,
786 OleDocumentView_Show
,
787 OleDocumentView_UIActivate
,
788 OleDocumentView_Open
,
789 OleDocumentView_CloseView
,
790 OleDocumentView_SaveViewState
,
791 OleDocumentView_ApplyViewState
,
792 OleDocumentView_Clone
795 /**********************************************************
796 * IViewObject implementation
799 static inline HTMLDocumentObj
*impl_from_IViewObjectEx(IViewObjectEx
*iface
)
801 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IViewObjectEx_iface
);
804 static HRESULT WINAPI
ViewObject_QueryInterface(IViewObjectEx
*iface
, REFIID riid
, void **ppv
)
806 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
807 return IUnknown_QueryInterface(This
->outer_unk
, riid
, ppv
);
810 static ULONG WINAPI
ViewObject_AddRef(IViewObjectEx
*iface
)
812 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
813 return IUnknown_AddRef(This
->outer_unk
);
816 static ULONG WINAPI
ViewObject_Release(IViewObjectEx
*iface
)
818 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
819 return IUnknown_Release(This
->outer_unk
);
822 static HRESULT WINAPI
ViewObject_Draw(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
,
823 DVTARGETDEVICE
*ptd
, HDC hdcTargetDev
, HDC hdcDraw
, LPCRECTL lprcBounds
,
824 LPCRECTL lprcWBounds
, BOOL (CALLBACK
*pfnContinue
)(ULONG_PTR dwContinue
), ULONG_PTR dwContinue
)
826 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
827 FIXME("(%p)->(%ld %ld %p %p %p %p %p %p %p %Id)\n", This
, dwDrawAspect
, lindex
, pvAspect
,
828 ptd
, hdcTargetDev
, hdcDraw
, lprcBounds
, lprcWBounds
, pfnContinue
, dwContinue
);
832 static HRESULT WINAPI
ViewObject_GetColorSet(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
, void *pvAspect
,
833 DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, LOGPALETTE
**ppColorSet
)
835 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
836 FIXME("(%p)->(%ld %ld %p %p %p %p)\n", This
, dwDrawAspect
, lindex
, pvAspect
, ptd
, hicTargetDev
, ppColorSet
);
840 static HRESULT WINAPI
ViewObject_Freeze(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
,
841 void *pvAspect
, DWORD
*pdwFreeze
)
843 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
844 FIXME("(%p)->(%ld %ld %p %p)\n", This
, dwDrawAspect
, lindex
, pvAspect
, pdwFreeze
);
848 static HRESULT WINAPI
ViewObject_Unfreeze(IViewObjectEx
*iface
, DWORD dwFreeze
)
850 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
851 FIXME("(%p)->(%ld)\n", This
, dwFreeze
);
855 static HRESULT WINAPI
ViewObject_SetAdvise(IViewObjectEx
*iface
, DWORD aspects
, DWORD advf
, IAdviseSink
*pAdvSink
)
857 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
859 TRACE("(%p)->(%ld %ld %p)\n", This
, aspects
, advf
, pAdvSink
);
861 if(aspects
!= DVASPECT_CONTENT
|| advf
!= ADVF_PRIMEFIRST
)
862 FIXME("unsupported arguments\n");
865 IAdviseSink_Release(This
->view_sink
);
867 IAdviseSink_AddRef(pAdvSink
);
869 This
->view_sink
= pAdvSink
;
873 static HRESULT WINAPI
ViewObject_GetAdvise(IViewObjectEx
*iface
, DWORD
*pAspects
, DWORD
*pAdvf
, IAdviseSink
**ppAdvSink
)
875 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
876 FIXME("(%p)->(%p %p %p)\n", This
, pAspects
, pAdvf
, ppAdvSink
);
880 static HRESULT WINAPI
ViewObject_GetExtent(IViewObjectEx
*iface
, DWORD dwDrawAspect
, LONG lindex
,
881 DVTARGETDEVICE
* ptd
, LPSIZEL lpsizel
)
883 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
884 FIXME("(%p)->(%ld %ld %p %p)\n", This
, dwDrawAspect
, lindex
, ptd
, lpsizel
);
888 static HRESULT WINAPI
ViewObject_GetRect(IViewObjectEx
*iface
, DWORD dwAspect
, LPRECTL pRect
)
890 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
891 FIXME("(%p)->(%ld %p)\n", This
, dwAspect
, pRect
);
895 static HRESULT WINAPI
ViewObject_GetViewStatus(IViewObjectEx
*iface
, DWORD
*pdwStatus
)
897 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
898 FIXME("(%p)->(%p)\n", This
, pdwStatus
);
902 static HRESULT WINAPI
ViewObject_QueryHitPoint(IViewObjectEx
* iface
, DWORD dwAspect
,
903 LPCRECT pRectBounds
, POINT ptlLoc
, LONG lCloseHint
, DWORD
*pHitResult
)
905 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
906 FIXME("(%p)->(%ld %p (%ld %ld) %ld %p)\n", This
, dwAspect
, pRectBounds
, ptlLoc
.x
,
907 ptlLoc
.y
, lCloseHint
, pHitResult
);
911 static HRESULT WINAPI
ViewObject_QueryHitRect(IViewObjectEx
*iface
, DWORD dwAspect
,
912 LPCRECT pRectBounds
, LPCRECT pRectLoc
, LONG lCloseHint
, DWORD
*pHitResult
)
914 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
915 FIXME("(%p)->(%ld %p %p %ld %p)\n", This
, dwAspect
, pRectBounds
, pRectLoc
, lCloseHint
, pHitResult
);
919 static HRESULT WINAPI
ViewObject_GetNaturalExtent(IViewObjectEx
*iface
, DWORD dwAspect
, LONG lindex
,
920 DVTARGETDEVICE
*ptd
, HDC hicTargetDev
, DVEXTENTINFO
*pExtentInfo
, LPSIZEL pSizel
)
922 HTMLDocumentObj
*This
= impl_from_IViewObjectEx(iface
);
923 FIXME("(%p)->(%ld %ld %p %p %p %p\n", This
, dwAspect
,lindex
, ptd
,
924 hicTargetDev
, pExtentInfo
, pSizel
);
928 static const IViewObjectExVtbl ViewObjectVtbl
= {
929 ViewObject_QueryInterface
,
933 ViewObject_GetColorSet
,
936 ViewObject_SetAdvise
,
937 ViewObject_GetAdvise
,
938 ViewObject_GetExtent
,
940 ViewObject_GetViewStatus
,
941 ViewObject_QueryHitPoint
,
942 ViewObject_QueryHitRect
,
943 ViewObject_GetNaturalExtent
946 static inline HTMLDocumentObj
*impl_from_IWindowForBindingUI(IWindowForBindingUI
*iface
)
948 return CONTAINING_RECORD(iface
, HTMLDocumentObj
, IWindowForBindingUI_iface
);
951 static HRESULT WINAPI
WindowForBindingUI_QueryInterface(IWindowForBindingUI
*iface
, REFIID riid
, void **ppv
)
953 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
955 if(IsEqualGUID(&IID_IUnknown
, riid
)) {
956 TRACE("(%p)->(IID_IUnknown %p)\n", This
, ppv
);
957 *ppv
= &This
->IWindowForBindingUI_iface
;
958 }else if(IsEqualGUID(&IID_IWindowForBindingUI
, riid
)) {
959 TRACE("(%p)->(IID_IWindowForBindingUI %p)\n", This
, ppv
);
960 *ppv
= &This
->IWindowForBindingUI_iface
;
962 WARN("(%p)->(%s %p)\n", This
, debugstr_guid(riid
), ppv
);
964 return E_NOINTERFACE
;
967 IUnknown_AddRef((IUnknown
*)*ppv
);
971 static ULONG WINAPI
WindowForBindingUI_AddRef(IWindowForBindingUI
*iface
)
973 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
974 return IUnknown_AddRef(This
->outer_unk
);
977 static ULONG WINAPI
WindowForBindingUI_Release(IWindowForBindingUI
*iface
)
979 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
980 return IUnknown_Release(This
->outer_unk
);
983 static HRESULT WINAPI
WindowForBindingUI_GetWindow(IWindowForBindingUI
*iface
, REFGUID rguidReason
, HWND
*phwnd
)
985 HTMLDocumentObj
*This
= impl_from_IWindowForBindingUI(iface
);
987 TRACE("(%p)->(%s %p)\n", This
, debugstr_guid(rguidReason
), phwnd
);
993 static const IWindowForBindingUIVtbl WindowForBindingUIVtbl
= {
994 WindowForBindingUI_QueryInterface
,
995 WindowForBindingUI_AddRef
,
996 WindowForBindingUI_Release
,
997 WindowForBindingUI_GetWindow
1000 void HTMLDocument_View_Init(HTMLDocumentObj
*doc
)
1002 doc
->IOleDocumentView_iface
.lpVtbl
= &OleDocumentViewVtbl
;
1003 doc
->IViewObjectEx_iface
.lpVtbl
= &ViewObjectVtbl
;
1004 doc
->IWindowForBindingUI_iface
.lpVtbl
= &WindowForBindingUIVtbl
;