|
1 /* |
|
2 * Copyright (C) 2010 Apple Inc. All rights reserved. |
|
3 * |
|
4 * Redistribution and use in source and binary forms, with or without |
|
5 * modification, are permitted provided that the following conditions |
|
6 * are met: |
|
7 * 1. Redistributions of source code must retain the above copyright |
|
8 * notice, this list of conditions and the following disclaimer. |
|
9 * 2. Redistributions in binary form must reproduce the above copyright |
|
10 * notice, this list of conditions and the following disclaimer in the |
|
11 * documentation and/or other materials provided with the distribution. |
|
12 * |
|
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' |
|
14 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, |
|
15 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
|
16 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS |
|
17 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
|
18 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
|
19 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
|
20 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
|
21 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
|
22 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF |
|
23 * THE POSSIBILITY OF SUCH DAMAGE. |
|
24 */ |
|
25 |
|
26 #ifndef WebView_h |
|
27 #define WebView_h |
|
28 |
|
29 #include "PageClient.h" |
|
30 #include "WebPageProxy.h" |
|
31 #include <WebCore/WindowMessageListener.h> |
|
32 #include <wtf/PassRefPtr.h> |
|
33 #include <wtf/RefCounted.h> |
|
34 #include <wtf/RefPtr.h> |
|
35 |
|
36 namespace WebCore { |
|
37 class String; |
|
38 } |
|
39 |
|
40 namespace WebKit { |
|
41 |
|
42 class DrawingAreaProxy; |
|
43 class WebPageNamespace; |
|
44 |
|
45 class WebView : public RefCounted<WebView>, public PageClient, WebCore::WindowMessageListener { |
|
46 public: |
|
47 static PassRefPtr<WebView> create(RECT rect, WebPageNamespace* pageNamespace, HWND hostWindow) |
|
48 { |
|
49 return adoptRef(new WebView(rect, pageNamespace, hostWindow)); |
|
50 } |
|
51 ~WebView(); |
|
52 |
|
53 RECT rect() const { return m_rect; } |
|
54 |
|
55 HWND window() const { return m_window; } |
|
56 HWND hostWindow() const { return m_hostWindow; } |
|
57 void setHostWindow(HWND); |
|
58 void windowAncestryDidChange(); |
|
59 |
|
60 WebPageProxy* page() const { return m_page.get(); } |
|
61 |
|
62 private: |
|
63 WebView(RECT, WebPageNamespace*, HWND hostWindow); |
|
64 |
|
65 static bool registerWebViewWindowClass(); |
|
66 static LRESULT CALLBACK WebViewWndProc(HWND, UINT, WPARAM, LPARAM); |
|
67 LRESULT wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam); |
|
68 |
|
69 LRESULT onMouseEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); |
|
70 LRESULT onWheelEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); |
|
71 LRESULT onKeyEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); |
|
72 LRESULT onPaintEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); |
|
73 LRESULT onSizeEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); |
|
74 LRESULT onWindowPositionChangedEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); |
|
75 LRESULT onSetFocusEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); |
|
76 LRESULT onKillFocusEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); |
|
77 LRESULT onTimerEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); |
|
78 LRESULT onShowWindowEvent(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); |
|
79 LRESULT onSetCursor(HWND hWnd, UINT message, WPARAM, LPARAM, bool& handled); |
|
80 |
|
81 bool isActive(); |
|
82 void updateActiveState(); |
|
83 void updateActiveStateSoon(); |
|
84 |
|
85 void initializeToolTipWindow(); |
|
86 |
|
87 void startTrackingMouseLeave(); |
|
88 void stopTrackingMouseLeave(); |
|
89 |
|
90 void close(); |
|
91 |
|
92 // PageClient |
|
93 virtual void processDidExit(); |
|
94 virtual void processDidRevive(); |
|
95 virtual void takeFocus(bool direction); |
|
96 virtual void toolTipChanged(const WebCore::String&, const WebCore::String&); |
|
97 virtual void setCursor(const WebCore::Cursor&); |
|
98 #if USE(ACCELERATED_COMPOSITING) |
|
99 virtual void pageDidEnterAcceleratedCompositing(); |
|
100 virtual void pageDidLeaveAcceleratedCompositing(); |
|
101 #endif |
|
102 |
|
103 // WebCore::WindowMessageListener |
|
104 virtual void windowReceivedMessage(HWND, UINT message, WPARAM, LPARAM); |
|
105 |
|
106 RECT m_rect; |
|
107 HWND m_window; |
|
108 HWND m_hostWindow; |
|
109 HWND m_topLevelParentWindow; |
|
110 HWND m_toolTipWindow; |
|
111 |
|
112 HCURSOR m_lastCursorSet; |
|
113 |
|
114 bool m_trackingMouseLeave; |
|
115 bool m_isBeingDestroyed; |
|
116 |
|
117 RefPtr<WebPageProxy> m_page; |
|
118 }; |
|
119 |
|
120 } // namespace WebKit |
|
121 |
|
122 #endif // WebView_h |