OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/renderer_host/render_widget_host.h" | 5 #include "chrome/browser/renderer_host/render_widget_host.h" |
6 | 6 |
7 #include "base/histogram.h" | 7 #include "base/histogram.h" |
8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
9 #include "base/keyboard_codes.h" | 9 #include "base/keyboard_codes.h" |
10 #include "chrome/browser/renderer_host/backing_store.h" | 10 #include "chrome/browser/renderer_host/backing_store.h" |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
294 // Avoid spamming the renderer with mouse move events. It is important | 294 // Avoid spamming the renderer with mouse move events. It is important |
295 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our | 295 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our |
296 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way | 296 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way |
297 // more WM_MOUSEMOVE events than we wish to send to the renderer. | 297 // more WM_MOUSEMOVE events than we wish to send to the renderer. |
298 if (mouse_event.type == WebInputEvent::MouseMove) { | 298 if (mouse_event.type == WebInputEvent::MouseMove) { |
299 if (mouse_move_pending_) { | 299 if (mouse_move_pending_) { |
300 next_mouse_move_.reset(new WebMouseEvent(mouse_event)); | 300 next_mouse_move_.reset(new WebMouseEvent(mouse_event)); |
301 return; | 301 return; |
302 } | 302 } |
303 mouse_move_pending_ = true; | 303 mouse_move_pending_ = true; |
| 304 } else if (mouse_event.type == WebInputEvent::MouseDown) { |
| 305 OnUserGesture(); |
304 } | 306 } |
305 | 307 |
306 ForwardInputEvent(mouse_event, sizeof(WebMouseEvent)); | 308 ForwardInputEvent(mouse_event, sizeof(WebMouseEvent)); |
307 } | 309 } |
308 | 310 |
309 void RenderWidgetHost::ForwardWheelEvent( | 311 void RenderWidgetHost::ForwardWheelEvent( |
310 const WebMouseWheelEvent& wheel_event) { | 312 const WebMouseWheelEvent& wheel_event) { |
311 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent)); | 313 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent)); |
312 } | 314 } |
313 | 315 |
314 void RenderWidgetHost::ForwardKeyboardEvent( | 316 void RenderWidgetHost::ForwardKeyboardEvent( |
315 const NativeWebKeyboardEvent& key_event) { | 317 const NativeWebKeyboardEvent& key_event) { |
316 if (key_event.type == WebKeyboardEvent::Char && | 318 if (key_event.type == WebKeyboardEvent::Char && |
317 (key_event.windowsKeyCode == base::VKEY_RETURN || | 319 (key_event.windowsKeyCode == base::VKEY_RETURN || |
318 key_event.windowsKeyCode == base::VKEY_SPACE)) { | 320 key_event.windowsKeyCode == base::VKEY_SPACE)) { |
319 OnEnterOrSpace(); | 321 OnUserGesture(); |
320 } | 322 } |
321 | 323 |
322 // Double check the type to make sure caller hasn't sent us nonsense that | 324 // Double check the type to make sure caller hasn't sent us nonsense that |
323 // will mess up our key queue. | 325 // will mess up our key queue. |
324 if (WebInputEvent::isKeyboardEventType(key_event.type)) { | 326 if (WebInputEvent::isKeyboardEventType(key_event.type)) { |
325 // Don't add this key to the queue if we have no way to send the message... | 327 // Don't add this key to the queue if we have no way to send the message... |
326 if (!process_->channel()) | 328 if (!process_->channel()) |
327 return; | 329 return; |
328 | 330 |
329 // Put all WebKeyboardEvent objects in a queue since we can't trust the | 331 // Put all WebKeyboardEvent objects in a queue since we can't trust the |
(...skipping 399 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
729 | 731 |
730 // TODO(darin): do we need to do something else if our backing store is not | 732 // TODO(darin): do we need to do something else if our backing store is not |
731 // the same size as the advertised view? maybe we just assume there is a | 733 // the same size as the advertised view? maybe we just assume there is a |
732 // full paint on its way? | 734 // full paint on its way? |
733 BackingStore* backing_store = BackingStoreManager::Lookup(this); | 735 BackingStore* backing_store = BackingStoreManager::Lookup(this); |
734 if (!backing_store || (backing_store->size() != view_size)) | 736 if (!backing_store || (backing_store->size() != view_size)) |
735 return; | 737 return; |
736 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, | 738 backing_store->ScrollRect(process_->process().handle(), bitmap, bitmap_rect, |
737 dx, dy, clip_rect, view_size); | 739 dx, dy, clip_rect, view_size); |
738 } | 740 } |
OLD | NEW |