OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 /* |
2 // Use of this source code is governed by a BSD-style license that can be | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
3 // found in the LICENSE file. | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are |
| 6 * met: |
| 7 * |
| 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above |
| 11 * copyright notice, this list of conditions and the following disclaimer |
| 12 * in the documentation and/or other materials provided with the |
| 13 * distribution. |
| 14 * * Neither the name of Google Inc. nor the names of its |
| 15 * contributors may be used to endorse or promote products derived from |
| 16 * this software without specific prior written permission. |
| 17 * |
| 18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ |
4 | 30 |
5 #ifndef WEBKIT_GLUE_WEBVIEW_IMPL_H_ | 31 #ifndef WebViewImpl_h |
6 #define WEBKIT_GLUE_WEBVIEW_IMPL_H_ | 32 #define WebViewImpl_h |
7 | 33 |
| 34 #include "BackForwardListClientImpl.h" |
| 35 #include "ChromeClientImpl.h" |
| 36 #include "ContextMenuClientImpl.h" |
| 37 #include "DragClientImpl.h" |
| 38 #include "EditorClientImpl.h" |
| 39 #include "InspectorClientImpl.h" |
| 40 #include "NotificationPresenterImpl.h" |
| 41 // FIXME: remove this relative path once consumers from glue are removed. |
| 42 #include "../public/WebNavigationPolicy.h" |
| 43 #include "../public/WebPoint.h" |
| 44 #include "../public/WebSize.h" |
| 45 #include "../public/WebString.h" |
| 46 #include "../public/WebView.h" |
8 #include <wtf/OwnPtr.h> | 47 #include <wtf/OwnPtr.h> |
9 #include <wtf/RefCounted.h> | 48 #include <wtf/RefCounted.h> |
10 | 49 |
11 #include "webkit/api/public/WebPoint.h" | |
12 #include "webkit/api/public/WebSize.h" | |
13 #include "webkit/api/public/WebString.h" | |
14 #include "webkit/api/public/WebView.h" | |
15 #include "webkit/api/src/BackForwardListClientImpl.h" | |
16 #include "webkit/api/src/ChromeClientImpl.h" | |
17 #include "webkit/api/src/ContextMenuClientImpl.h" | |
18 #include "webkit/api/src/DragClientImpl.h" | |
19 #include "webkit/api/src/EditorClientImpl.h" | |
20 #include "webkit/api/src/InspectorClientImpl.h" | |
21 #include "webkit/api/src/NotificationPresenterImpl.h" | |
22 #include "webkit/glue/webframe_impl.h" | |
23 | |
24 namespace WebCore { | 50 namespace WebCore { |
25 class ChromiumDataObject; | 51 class ChromiumDataObject; |
26 class Frame; | 52 class Frame; |
27 class HistoryItem; | 53 class HistoryItem; |
28 class HitTestResult; | 54 class HitTestResult; |
29 class KeyboardEvent; | 55 class KeyboardEvent; |
30 class Page; | 56 class Page; |
31 class PlatformKeyboardEvent; | 57 class PlatformKeyboardEvent; |
32 class PopupContainer; | 58 class PopupContainer; |
33 class Range; | 59 class Range; |
34 class RenderTheme; | 60 class RenderTheme; |
35 class Widget; | 61 class Widget; |
36 } | 62 } |
37 | 63 |
| 64 class WebDevToolsAgentImpl; |
| 65 |
38 namespace WebKit { | 66 namespace WebKit { |
| 67 class AutocompletePopupMenuClient; |
39 class ContextMenuClientImpl; | 68 class ContextMenuClientImpl; |
40 class WebAccessibilityObject; | 69 class WebAccessibilityObject; |
| 70 class WebFrameImpl; |
41 class WebKeyboardEvent; | 71 class WebKeyboardEvent; |
42 class WebMouseEvent; | 72 class WebMouseEvent; |
43 class WebMouseWheelEvent; | 73 class WebMouseWheelEvent; |
44 class WebSettingsImpl; | 74 class WebSettingsImpl; |
45 } | 75 |
46 | 76 class WebViewImpl : public WebView, public RefCounted<WebViewImpl> { |
47 namespace webkit_glue { | 77 public: |
48 class ImageResourceFetcher; | 78 // WebWidget methods: |
49 } | 79 virtual void close(); |
50 | 80 virtual WebSize size() { return m_size; } |
51 class AutocompletePopupMenuClient; | 81 virtual void resize(const WebSize&); |
52 class WebHistoryItemImpl; | 82 virtual void layout(); |
53 class WebDevToolsAgentImpl; | 83 virtual void paint(WebCanvas*, const WebRect&); |
54 | 84 virtual bool handleInputEvent(const WebInputEvent&); |
55 class WebViewImpl : public WebKit::WebView, public RefCounted<WebViewImpl> { | 85 virtual void mouseCaptureLost(); |
56 public: | 86 virtual void setFocus(bool enable); |
57 // WebWidget methods: | 87 virtual bool handleCompositionEvent(WebCompositionCommand command, |
58 virtual void close(); | 88 int cursorPosition, |
59 virtual WebKit::WebSize size() { return size_; } | 89 int targetStart, |
60 virtual void resize(const WebKit::WebSize& new_size); | 90 int targetEnd, |
61 virtual void layout(); | 91 const WebString& text); |
62 virtual void paint(WebKit::WebCanvas* canvas, | 92 virtual bool queryCompositionStatus(bool* enabled, |
63 const WebKit::WebRect& rect); | 93 WebRect* caretRect); |
64 virtual bool handleInputEvent(const WebKit::WebInputEvent& input_event); | 94 virtual void setTextDirection(WebTextDirection direction); |
65 virtual void mouseCaptureLost(); | 95 |
66 virtual void setFocus(bool enable); | 96 // WebView methods: |
67 virtual bool handleCompositionEvent(WebKit::WebCompositionCommand command, | 97 virtual void initializeMainFrame(WebFrameClient*); |
68 int cursor_position, | 98 virtual WebSettings* settings(); |
69 int target_start, | 99 virtual WebString pageEncoding() const; |
70 int target_end, | 100 virtual void setPageEncoding(const WebString& encoding); |
71 const WebKit::WebString& text); | 101 virtual bool isTransparent() const; |
72 virtual bool queryCompositionStatus(bool* enabled, | 102 virtual void setIsTransparent(bool value); |
73 WebKit::WebRect* caret_rect); | 103 virtual bool tabsToLinks() const; |
74 virtual void setTextDirection(WebKit::WebTextDirection direction); | 104 virtual void setTabsToLinks(bool value); |
75 | 105 virtual bool tabKeyCyclesThroughElements() const; |
76 // WebView methods: | 106 virtual void setTabKeyCyclesThroughElements(bool value); |
77 virtual void initializeMainFrame(WebKit::WebFrameClient*); | 107 virtual bool isActive() const; |
78 virtual WebKit::WebSettings* settings(); | 108 virtual void setIsActive(bool value); |
79 virtual WebKit::WebString pageEncoding() const; | 109 virtual bool dispatchBeforeUnloadEvent(); |
80 virtual void setPageEncoding(const WebKit::WebString& encoding); | 110 virtual void dispatchUnloadEvent(); |
81 virtual bool isTransparent() const; | 111 virtual WebFrame* mainFrame(); |
82 virtual void setIsTransparent(bool value); | 112 virtual WebFrame* findFrameByName( |
83 virtual bool tabsToLinks() const; | 113 const WebString& name, WebFrame* relativeToFrame); |
84 virtual void setTabsToLinks(bool value); | 114 virtual WebFrame* focusedFrame(); |
85 virtual bool tabKeyCyclesThroughElements() const; | 115 virtual void setFocusedFrame(WebFrame* frame); |
86 virtual void setTabKeyCyclesThroughElements(bool value); | 116 virtual void setInitialFocus(bool reverse); |
87 virtual bool isActive() const; | 117 virtual void clearFocusedNode(); |
88 virtual void setIsActive(bool value); | 118 virtual void zoomIn(bool textOnly); |
89 virtual bool dispatchBeforeUnloadEvent(); | 119 virtual void zoomOut(bool textOnly); |
90 virtual void dispatchUnloadEvent(); | 120 virtual void zoomDefault(); |
91 virtual WebKit::WebFrame* mainFrame(); | 121 virtual void performMediaPlayerAction( |
92 virtual WebKit::WebFrame* findFrameByName( | 122 const WebMediaPlayerAction& action, |
93 const WebKit::WebString& name, WebKit::WebFrame* relative_to_frame); | 123 const WebPoint& location); |
94 virtual WebKit::WebFrame* focusedFrame(); | 124 virtual void copyImageAt(const WebPoint& point); |
95 virtual void setFocusedFrame(WebKit::WebFrame* frame); | 125 virtual void dragSourceEndedAt( |
96 virtual void setInitialFocus(bool reverse); | 126 const WebPoint& clientPoint, |
97 virtual void clearFocusedNode(); | 127 const WebPoint& screenPoint, |
98 virtual void zoomIn(bool text_only); | 128 WebDragOperation operation); |
99 virtual void zoomOut(bool text_only); | 129 virtual void dragSourceMovedTo( |
100 virtual void zoomDefault(); | 130 const WebPoint& clientPoint, |
101 virtual void performMediaPlayerAction( | 131 const WebPoint& screenPoint); |
102 const WebKit::WebMediaPlayerAction& action, | 132 virtual void dragSourceSystemDragEnded(); |
103 const WebKit::WebPoint& location); | 133 virtual WebDragOperation dragTargetDragEnter( |
104 virtual void copyImageAt(const WebKit::WebPoint& point); | 134 const WebDragData& dragData, int identity, |
105 virtual void dragSourceEndedAt( | 135 const WebPoint& clientPoint, |
106 const WebKit::WebPoint& client_point, | 136 const WebPoint& screenPoint, |
107 const WebKit::WebPoint& screen_point, | 137 WebDragOperationsMask operationsAllowed); |
108 WebKit::WebDragOperation operation); | 138 virtual WebDragOperation dragTargetDragOver( |
109 virtual void dragSourceMovedTo( | 139 const WebPoint& clientPoint, |
110 const WebKit::WebPoint& client_point, | 140 const WebPoint& screenPoint, |
111 const WebKit::WebPoint& screen_point); | 141 WebDragOperationsMask operationsAllowed); |
112 virtual void dragSourceSystemDragEnded(); | 142 virtual void dragTargetDragLeave(); |
113 virtual WebKit::WebDragOperation dragTargetDragEnter( | 143 virtual void dragTargetDrop( |
114 const WebKit::WebDragData& drag_data, int identity, | 144 const WebPoint& clientPoint, |
115 const WebKit::WebPoint& client_point, | 145 const WebPoint& screenPoint); |
116 const WebKit::WebPoint& screen_point, | 146 virtual int dragIdentity(); |
117 WebKit::WebDragOperationsMask operations_allowed); | 147 virtual bool setDropEffect(bool accept); |
118 virtual WebKit::WebDragOperation dragTargetDragOver( | 148 virtual void inspectElementAt(const WebPoint& point); |
119 const WebKit::WebPoint& client_point, | 149 virtual WebString inspectorSettings() const; |
120 const WebKit::WebPoint& screen_point, | 150 virtual void setInspectorSettings(const WebString& settings); |
121 WebKit::WebDragOperationsMask operations_allowed); | 151 virtual WebDevToolsAgent* devToolsAgent(); |
122 virtual void dragTargetDragLeave(); | 152 virtual WebAccessibilityObject accessibilityObject(); |
123 virtual void dragTargetDrop( | 153 virtual void applyAutofillSuggestions( |
124 const WebKit::WebPoint& client_point, | 154 const WebNode&, |
125 const WebKit::WebPoint& screen_point); | 155 const WebVector<WebString>& suggestions, |
126 virtual int dragIdentity(); | 156 int defaultSuggestionIndex); |
127 virtual bool setDropEffect(bool accept); | 157 virtual void hideAutofillPopup(); |
128 virtual void inspectElementAt(const WebKit::WebPoint& point); | 158 |
129 virtual WebKit::WebString inspectorSettings() const; | 159 // WebViewImpl |
130 virtual void setInspectorSettings(const WebKit::WebString& settings); | 160 |
131 virtual WebKit::WebDevToolsAgent* devToolsAgent(); | 161 void setIgnoreInputEvents(bool newValue); |
132 virtual WebKit::WebAccessibilityObject accessibilityObject(); | 162 WebDevToolsAgentImpl* devToolsAgentImpl(); |
133 virtual void applyAutofillSuggestions( | 163 |
134 const WebKit::WebNode&, | 164 const WebPoint& lastMouseDownPoint() const |
135 const WebKit::WebVector<WebKit::WebString>& suggestions, | 165 { |
136 int defaultSuggestionIndex); | 166 return m_lastMouseDownPoint; |
137 virtual void hideAutofillPopup(); | 167 } |
138 | 168 |
139 // WebViewImpl | 169 WebCore::Frame* focusedWebCoreFrame(); |
140 | 170 |
141 void SetIgnoreInputEvents(bool new_value); | 171 // Returns the currently focused Node or null if no node has focus. |
142 WebDevToolsAgentImpl* GetWebDevToolsAgentImpl(); | 172 WebCore::Node* focusedWebCoreNode(); |
143 | 173 |
144 const WebKit::WebPoint& last_mouse_down_point() const { | 174 static WebViewImpl* fromPage(WebCore::Page*); |
145 return last_mouse_down_point_; | 175 |
146 } | 176 WebViewClient* client() |
147 | 177 { |
148 WebCore::Frame* GetFocusedWebCoreFrame(); | 178 return m_client; |
149 | 179 } |
150 // Returns the currently focused Node or NULL if no node has focus. | 180 |
151 WebCore::Node* GetFocusedNode(); | 181 // Returns the page object associated with this view. This may be null when |
152 | 182 // the page is shutting down, but will be valid at all other times. |
153 static WebViewImpl* FromPage(WebCore::Page* page); | 183 WebCore::Page* page() const |
154 | 184 { |
155 WebKit::WebViewClient* client() { | 185 return m_page.get(); |
156 return client_; | 186 } |
157 } | 187 |
158 | 188 WebCore::RenderTheme* theme() const; |
159 // Returns the page object associated with this view. This may be NULL when | 189 |
160 // the page is shutting down, but will be valid at all other times. | 190 // Returns the main frame associated with this view. This may be null when |
161 WebCore::Page* page() const { | 191 // the page is shutting down, but will be valid at all other times. |
162 return page_.get(); | 192 WebFrameImpl* mainFrameImpl(); |
163 } | 193 |
164 | 194 // History related methods: |
165 WebCore::RenderTheme* theme() const; | 195 void setCurrentHistoryItem(WebCore::HistoryItem*); |
166 | 196 WebCore::HistoryItem* previousHistoryItem(); |
167 // Returns the main frame associated with this view. This may be NULL when | 197 void observeNewNavigation(); |
168 // the page is shutting down, but will be valid at all other times. | 198 |
169 WebFrameImpl* main_frame() { | 199 // Event related methods: |
170 return page_.get() ? WebFrameImpl::FromFrame(page_->mainFrame()) : NULL; | 200 void mouseMove(const WebMouseEvent&); |
171 } | 201 void mouseLeave(const WebMouseEvent&); |
172 | 202 void mouseDown(const WebMouseEvent&); |
173 // History related methods: | 203 void mouseUp(const WebMouseEvent&); |
174 void SetCurrentHistoryItem(WebCore::HistoryItem* item); | 204 void mouseContextMenu(const WebMouseEvent&); |
175 WebCore::HistoryItem* GetPreviousHistoryItem(); | 205 void mouseDoubleClick(const WebMouseEvent&); |
176 void ObserveNewNavigation(); | 206 void mouseWheel(const WebMouseWheelEvent&); |
177 | 207 bool keyEvent(const WebKeyboardEvent&); |
178 // Event related methods: | 208 bool charEvent(const WebKeyboardEvent&); |
179 void MouseMove(const WebKit::WebMouseEvent& mouse_event); | 209 |
180 void MouseLeave(const WebKit::WebMouseEvent& mouse_event); | 210 // Handles context menu events orignated via the the keyboard. These |
181 void MouseDown(const WebKit::WebMouseEvent& mouse_event); | 211 // include the VK_APPS virtual key and the Shift+F10 combine. Code is |
182 void MouseUp(const WebKit::WebMouseEvent& mouse_event); | 212 // based on the Webkit function bool WebView::handleContextMenuEvent(WPARAM |
183 void MouseContextMenu(const WebKit::WebMouseEvent& mouse_event); | 213 // wParam, LPARAM lParam) in webkit\webkit\win\WebView.cpp. The only |
184 void MouseDoubleClick(const WebKit::WebMouseEvent& mouse_event); | 214 // significant change in this function is the code to convert from a |
185 void MouseWheel(const WebKit::WebMouseWheelEvent& wheel_event); | 215 // Keyboard event to the Right Mouse button down event. |
186 bool KeyEvent(const WebKit::WebKeyboardEvent& key_event); | 216 bool sendContextMenuEvent(const WebKeyboardEvent&); |
187 bool CharEvent(const WebKit::WebKeyboardEvent& key_event); | 217 |
188 | 218 // Notifies the WebView that a load has been committed. isNewNavigation |
189 // Handles context menu events orignated via the the keyboard. These | 219 // will be true if a new session history item should be created for that |
190 // include the VK_APPS virtual key and the Shift+F10 combine. | 220 // load. |
191 // Code is based on the Webkit function | 221 void didCommitLoad(bool* isNewNavigation); |
192 // bool WebView::handleContextMenuEvent(WPARAM wParam, LPARAM lParam) in | 222 |
193 // webkit\webkit\win\WebView.cpp. The only significant change in this | 223 bool contextMenuAllowed() const |
194 // function is the code to convert from a Keyboard event to the Right | 224 { |
195 // Mouse button down event. | 225 return m_contextMenuAllowed; |
196 bool SendContextMenuEvent(const WebKit::WebKeyboardEvent& event); | 226 } |
197 | 227 |
198 // Notifies the WebView that a load has been committed. | 228 // Set the disposition for how this webview is to be initially shown. |
199 // is_new_navigation will be true if a new session history item should be | 229 void setInitialNavigationPolicy(WebNavigationPolicy policy) |
200 // created for that load. | 230 { |
201 void DidCommitLoad(bool* is_new_navigation); | 231 m_initialNavigationPolicy = policy; |
202 | 232 } |
203 bool context_menu_allowed() const { | 233 WebNavigationPolicy initialNavigationPolicy() const |
204 return context_menu_allowed_; | 234 { |
205 } | 235 return m_initialNavigationPolicy; |
206 | 236 } |
207 // Set the disposition for how this webview is to be initially shown. | 237 |
208 void set_initial_navigation_policy(WebKit::WebNavigationPolicy policy) { | 238 // Determines whether a page should e.g. be opened in a background tab. |
209 initial_navigation_policy_ = policy; | 239 // Returns false if it has no opinion, in which case it doesn't set *policy. |
210 } | 240 static bool navigationPolicyFromMouseEvent( |
211 WebKit::WebNavigationPolicy initial_navigation_policy() const { | 241 unsigned short button, |
212 return initial_navigation_policy_; | 242 bool ctrl, |
213 } | 243 bool shift, |
214 | 244 bool alt, |
215 // Determines whether a page should e.g. be opened in a background tab. | 245 bool meta, |
216 // Returns false if it has no opinion, in which case it doesn't set *policy. | 246 WebNavigationPolicy*); |
217 static bool NavigationPolicyFromMouseEvent( | 247 |
218 unsigned short button, | 248 // Start a system drag and drop operation. |
219 bool ctrl, | 249 void startDragging( |
220 bool shift, | 250 const WebPoint& eventPos, |
221 bool alt, | 251 const WebDragData& dragData, |
222 bool meta, | 252 WebDragOperationsMask dragSourceOperationMask); |
223 WebKit::WebNavigationPolicy* policy); | 253 |
224 | 254 // Hides the autocomplete popup if it is showing. |
225 // Start a system drag and drop operation. | 255 void hideAutoCompletePopup(); |
226 void StartDragging( | 256 void autoCompletePopupDidHide(); |
227 const WebKit::WebPoint& event_pos, | |
228 const WebKit::WebDragData& drag_data, | |
229 WebKit::WebDragOperationsMask drag_source_operation_mask); | |
230 | |
231 // Hides the autocomplete popup if it is showing. | |
232 void HideAutoCompletePopup(); | |
233 void AutoCompletePopupDidHide(); | |
234 | 257 |
235 #if ENABLE(NOTIFICATIONS) | 258 #if ENABLE(NOTIFICATIONS) |
236 // Returns the provider of desktop notifications. | 259 // Returns the provider of desktop notifications. |
237 WebKit::NotificationPresenterImpl* GetNotificationPresenter(); | 260 NotificationPresenterImpl* notificationPresenterImpl(); |
238 #endif | 261 #endif |
239 | 262 |
240 // Tries to scroll a frame or any parent of a frame. Returns true if the view | 263 // Tries to scroll a frame or any parent of a frame. Returns true if the view |
241 // was scrolled. | 264 // was scrolled. |
242 bool PropagateScroll(WebCore::ScrollDirection scroll_direction, | 265 bool propagateScroll(WebCore::ScrollDirection, WebCore::ScrollGranularity); |
243 WebCore::ScrollGranularity scroll_granularity); | 266 |
244 | 267 // HACK: currentInputEvent() is for ChromeClientImpl::show(), until we can |
245 protected: | 268 // fix WebKit to pass enough information up into ChromeClient::show() so we |
246 friend class WebKit::WebView; // So WebView::Create can call our constructor | 269 // can decide if the window.open event was caused by a middle-mouse click |
247 friend class WTF::RefCounted<WebViewImpl>; | 270 static const WebInputEvent* currentInputEvent() |
248 | 271 { |
249 WebViewImpl(WebKit::WebViewClient* client); | 272 return m_currentInputEvent; |
250 ~WebViewImpl(); | 273 } |
251 | 274 |
252 void ModifySelection(uint32 message, | 275 private: |
253 WebCore::Frame* frame, | 276 friend class WebView; // So WebView::Create can call our constructor |
254 const WebCore::PlatformKeyboardEvent& e); | 277 friend class WTF::RefCounted<WebViewImpl>; |
255 | 278 |
256 WebKit::WebViewClient* client_; | 279 WebViewImpl(WebViewClient* client); |
257 | 280 ~WebViewImpl(); |
258 WebKit::BackForwardListClientImpl back_forward_list_client_impl_; | 281 |
259 WebKit::ChromeClientImpl chrome_client_impl_; | 282 void modifySelection(uint32 message, WebCore::Frame*, const WebCore::PlatformKeyboardEvent&); |
260 WebKit::ContextMenuClientImpl context_menu_client_impl_; | 283 |
261 WebKit::DragClientImpl drag_client_impl_; | 284 // Returns true if the event was actually processed. |
262 WebKit::EditorClientImpl editor_client_impl_; | 285 bool keyEventDefault(const WebKeyboardEvent&); |
263 WebKit::InspectorClientImpl inspector_client_impl_; | 286 |
264 | 287 // Returns true if the autocomple has consumed the event. |
265 WebKit::WebSize size_; | 288 bool autocompleteHandleKeyEvent(const WebKeyboardEvent&); |
266 | 289 |
267 WebKit::WebPoint last_mouse_position_; | 290 // Repaints the autofill popup. Should be called when the suggestions have |
268 OwnPtr<WebCore::Page> page_; | 291 // changed. Note that this should only be called when the autofill popup is |
269 | 292 // showing. |
270 // This flag is set when a new navigation is detected. It is used to satisfy | 293 void refreshAutofillPopup(); |
271 // the corresponding argument to WebFrameClient::didCommitProvisionalLoad. | 294 |
272 bool observed_new_navigation_; | 295 // Returns true if the view was scrolled. |
| 296 bool scrollViewWithKeyboard(int keyCode, int modifiers); |
| 297 |
| 298 // Converts |pos| from window coordinates to contents coordinates and gets |
| 299 // the HitTestResult for it. |
| 300 WebCore::HitTestResult hitTestResultForWindowPos(const WebCore::IntPoint&); |
| 301 |
| 302 WebViewClient* m_client; |
| 303 |
| 304 BackForwardListClientImpl m_backForwardListClientImpl; |
| 305 ChromeClientImpl m_chromeClientImpl; |
| 306 ContextMenuClientImpl m_contextMenuClientImpl; |
| 307 DragClientImpl m_dragClientImpl; |
| 308 EditorClientImpl m_editorClientImpl; |
| 309 InspectorClientImpl m_inspectorClientImpl; |
| 310 |
| 311 WebSize m_size; |
| 312 |
| 313 WebPoint m_lastMousePosition; |
| 314 OwnPtr<WebCore::Page> m_page; |
| 315 |
| 316 // This flag is set when a new navigation is detected. It is used to satisfy |
| 317 // the corresponding argument to WebFrameClient::didCommitProvisionalLoad. |
| 318 bool m_observedNewNavigation; |
273 #ifndef NDEBUG | 319 #ifndef NDEBUG |
274 // Used to assert that the new navigation we observed is the same navigation | 320 // Used to assert that the new navigation we observed is the same navigation |
275 // when we make use of observed_new_navigation_. | 321 // when we make use of m_observedNewNavigation. |
276 const WebCore::DocumentLoader* new_navigation_loader_; | 322 const WebCore::DocumentLoader* m_newNavigationLoader; |
277 #endif | 323 #endif |
278 | 324 |
279 // An object that can be used to manipulate page_->settings() without linking | 325 // An object that can be used to manipulate m_page->settings() without linking |
280 // against WebCore. This is lazily allocated the first time GetWebSettings() | 326 // against WebCore. This is lazily allocated the first time GetWebSettings() |
281 // is called. | 327 // is called. |
282 OwnPtr<WebKit::WebSettingsImpl> web_settings_; | 328 OwnPtr<WebSettingsImpl> m_webSettings; |
283 | 329 |
284 // A copy of the web drop data object we received from the browser. | 330 // A copy of the web drop data object we received from the browser. |
285 RefPtr<WebCore::ChromiumDataObject> current_drag_data_; | 331 RefPtr<WebCore::ChromiumDataObject> m_currentDragData; |
286 | 332 |
287 private: | 333 // The point relative to the client area where the mouse was last pressed |
288 // Returns true if the event was actually processed. | 334 // down. This is used by the drag client to determine what was under the |
289 bool KeyEventDefault(const WebKit::WebKeyboardEvent& event); | 335 // mouse when the drag was initiated. We need to track this here in |
290 | 336 // WebViewImpl since DragClient::startDrag does not pass the position the |
291 // Returns true if the autocomple has consumed the event. | 337 // mouse was at when the drag was initiated, only the current point, which |
292 bool AutocompleteHandleKeyEvent(const WebKit::WebKeyboardEvent& event); | 338 // can be misleading as it is usually not over the element the user actually |
293 | 339 // dragged by the time a drag is initiated. |
294 // Repaints the autofill popup. Should be called when the suggestions have | 340 WebPoint m_lastMouseDownPoint; |
295 // changed. Note that this should only be called when the autofill popup is | 341 |
296 // showing. | 342 // Keeps track of the current text zoom level. 0 means no zoom, positive |
297 void RefreshAutofillPopup(); | 343 // values mean larger text, negative numbers mean smaller. |
298 | 344 int m_zoomLevel; |
299 // Returns true if the view was scrolled. | 345 |
300 bool ScrollViewWithKeyboard(int key_code, int modifiers); | 346 bool m_contextMenuAllowed; |
301 | 347 |
302 // Converts |pos| from window coordinates to contents coordinates and gets | 348 bool m_doingDragAndDrop; |
303 // the HitTestResult for it. | 349 |
304 WebCore::HitTestResult HitTestResultForWindowPos( | 350 bool m_ignoreInputEvents; |
305 const WebCore::IntPoint& pos); | 351 |
306 | 352 // Webkit expects keyPress events to be suppressed if the associated keyDown |
307 // The point relative to the client area where the mouse was last pressed | 353 // event was handled. Safari implements this behavior by peeking out the |
308 // down. This is used by the drag client to determine what was under the | 354 // associated WM_CHAR event if the keydown was handled. We emulate |
309 // mouse when the drag was initiated. We need to track this here in | 355 // this behavior by setting this flag if the keyDown was handled. |
310 // WebViewImpl since DragClient::startDrag does not pass the position the | 356 bool m_suppressNextKeypressEvent; |
311 // mouse was at when the drag was initiated, only the current point, which | 357 |
312 // can be misleading as it is usually not over the element the user actually | 358 // The policy for how this webview is to be initially shown. |
313 // dragged by the time a drag is initiated. | 359 WebNavigationPolicy m_initialNavigationPolicy; |
314 WebKit::WebPoint last_mouse_down_point_; | 360 |
315 | 361 // Represents whether or not this object should process incoming IME events. |
316 // Keeps track of the current text zoom level. 0 means no zoom, positive | 362 bool m_imeAcceptEvents; |
317 // values mean larger text, negative numbers mean smaller. | 363 |
318 int zoom_level_; | 364 // True while dispatching system drag and drop events to drag/drop targets |
319 | 365 // within this WebView. |
320 bool context_menu_allowed_; | 366 bool m_dragTargetDispatch; |
321 | 367 |
322 bool doing_drag_and_drop_; | 368 // Valid when m_dragTargetDispatch is true; the identity of the drag data |
323 | 369 // copied from the WebDropData object sent from the browser process. |
324 bool ignore_input_events_; | 370 int32 m_dragIdentity; |
325 | 371 |
326 // Webkit expects keyPress events to be suppressed if the associated keyDown | 372 // Valid when m_dragTargetDispatch is true. Used to override the default |
327 // event was handled. Safari implements this behavior by peeking out the | 373 // browser drop effect with the effects "none" or "copy". |
328 // associated WM_CHAR event if the keydown was handled. We emulate | 374 enum DragTargetDropEffect { |
329 // this behavior by setting this flag if the keyDown was handled. | 375 DropEffectDefault = -1, |
330 bool suppress_next_keypress_event_; | 376 DropEffectNone, |
331 | 377 DropEffectCopy |
332 // The policy for how this webview is to be initially shown. | 378 } m_dropEffect; |
333 WebKit::WebNavigationPolicy initial_navigation_policy_; | 379 |
334 | 380 // The available drag operations (copy, move link...) allowed by the source. |
335 // Represents whether or not this object should process incoming IME events. | 381 WebDragOperation m_operationsAllowed; |
336 bool ime_accept_events_; | 382 |
337 | 383 // The current drag operation as negotiated by the source and destination. |
338 // True while dispatching system drag and drop events to drag/drop targets | 384 // When not equal to DragOperationNone, the drag data can be dropped onto the |
339 // within this WebView. | 385 // current drop target in this WebView (the drop target can accept the drop). |
340 bool drag_target_dispatch_; | 386 WebDragOperation m_dragOperation; |
341 | 387 |
342 // Valid when drag_target_dispatch_ is true; the identity of the drag data | 388 // The autocomplete popup. Kept around and reused every-time new suggestions |
343 // copied from the WebDropData object sent from the browser process. | 389 // should be shown. |
344 int32 drag_identity_; | 390 RefPtr<WebCore::PopupContainer> m_autocompletePopup; |
345 | 391 |
346 // Valid when drag_target_dispatch_ is true. Used to override the default | 392 // Whether the autocomplete popup is currently showing. |
347 // browser drop effect with the effects "none" or "copy". | 393 bool m_autocompletePopupShowing; |
348 enum DragTargetDropEffect { | 394 |
349 DROP_EFFECT_DEFAULT = -1, | 395 // The autocomplete client. |
350 DROP_EFFECT_NONE, | 396 OwnPtr<AutocompletePopupMenuClient> m_autocompletePopupClient; |
351 DROP_EFFECT_COPY | 397 |
352 } drop_effect_; | 398 OwnPtr<WebDevToolsAgentImpl> m_devToolsAgent; |
353 | 399 |
354 // The available drag operations (copy, move link...) allowed by the source. | 400 // Whether the webview is rendering transparently. |
355 WebKit::WebDragOperation operations_allowed_; | 401 bool m_isTransparent; |
356 | 402 |
357 // The current drag operation as negotiated by the source and destination. | 403 // Whether the user can press tab to focus links. |
358 // When not equal to DragOperationNone, the drag data can be dropped onto the | 404 bool m_tabsToLinks; |
359 // current drop target in this WebView (the drop target can accept the drop). | 405 |
360 WebKit::WebDragOperation drag_operation_; | 406 // Inspector settings. |
361 | 407 WebString m_inspectorSettings; |
362 // The autocomplete popup. Kept around and reused every-time new suggestions | |
363 // should be shown. | |
364 RefPtr<WebCore::PopupContainer> autocomplete_popup_; | |
365 | |
366 // Whether the autocomplete popup is currently showing. | |
367 bool autocomplete_popup_showing_; | |
368 | |
369 // The autocomplete client. | |
370 OwnPtr<AutocompletePopupMenuClient> autocomplete_popup_client_; | |
371 | |
372 OwnPtr<WebDevToolsAgentImpl> devtools_agent_; | |
373 | |
374 // Whether the webview is rendering transparently. | |
375 bool is_transparent_; | |
376 | |
377 // Whether the user can press tab to focus links. | |
378 bool tabs_to_links_; | |
379 | |
380 // Inspector settings. | |
381 WebKit::WebString inspector_settings_; | |
382 | 408 |
383 #if ENABLE(NOTIFICATIONS) | 409 #if ENABLE(NOTIFICATIONS) |
384 // The provider of desktop notifications; | 410 // The provider of desktop notifications; |
385 WebKit::NotificationPresenterImpl notification_presenter_; | 411 NotificationPresenterImpl m_notificationPresenter; |
386 #endif | 412 #endif |
387 | 413 |
388 // HACK: current_input_event is for ChromeClientImpl::show(), until we can fix | 414 static const WebInputEvent* m_currentInputEvent; |
389 // WebKit to pass enough information up into ChromeClient::show() so we can | |
390 // decide if the window.open event was caused by a middle-mouse click | |
391 public: | |
392 static const WebKit::WebInputEvent* current_input_event() { | |
393 return g_current_input_event; | |
394 } | |
395 private: | |
396 static const WebKit::WebInputEvent* g_current_input_event; | |
397 | |
398 DISALLOW_COPY_AND_ASSIGN(WebViewImpl); | |
399 }; | 415 }; |
400 | 416 |
401 #endif // WEBKIT_GLUE_WEBVIEW_IMPL_H_ | 417 } // namespace WebKit |
| 418 |
| 419 #endif |
OLD | NEW |