OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "content/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 806 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent), false); | 817 ForwardInputEvent(wheel_event, sizeof(WebMouseWheelEvent), false); |
818 } | 818 } |
819 | 819 |
820 void RenderWidgetHostImpl::ForwardGestureEvent( | 820 void RenderWidgetHostImpl::ForwardGestureEvent( |
821 const WebKit::WebGestureEvent& gesture_event) { | 821 const WebKit::WebGestureEvent& gesture_event) { |
822 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardGestureEvent"); | 822 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardGestureEvent"); |
823 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 823 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
824 return; | 824 return; |
825 | 825 |
826 if (gesture_event_pending_) { | 826 if (gesture_event_pending_) { |
827 if (coalesced_gesture_events_.empty() || | 827 if (coalesced_gesture_events_.empty() || |
828 !ShouldCoalesceGestureEvents(coalesced_gesture_events_.back(), | 828 !ShouldCoalesceGestureEvents(coalesced_gesture_events_.back(), |
829 gesture_event)) { | 829 gesture_event)) { |
830 coalesced_gesture_events_.push_back(gesture_event); | 830 coalesced_gesture_events_.push_back(gesture_event); |
831 } else { | 831 } else { |
832 WebGestureEvent* last_gesture_event = | 832 WebGestureEvent* last_gesture_event = |
833 &coalesced_gesture_events_.back(); | 833 &coalesced_gesture_events_.back(); |
834 last_gesture_event->deltaX += gesture_event.deltaX; | 834 last_gesture_event->deltaX += gesture_event.deltaX; |
835 last_gesture_event->deltaY += gesture_event.deltaY; | 835 last_gesture_event->deltaY += gesture_event.deltaY; |
836 DCHECK_GE(gesture_event.timeStampSeconds, | 836 DCHECK_GE(gesture_event.timeStampSeconds, |
837 last_gesture_event->timeStampSeconds); | 837 last_gesture_event->timeStampSeconds); |
838 last_gesture_event->timeStampSeconds = gesture_event.timeStampSeconds; | 838 last_gesture_event->timeStampSeconds = gesture_event.timeStampSeconds; |
839 } | 839 } |
840 return; | 840 return; |
841 } | 841 } |
842 gesture_event_pending_ = true; | |
843 | 842 |
844 if (gesture_event.type == WebInputEvent::GestureFlingCancel) | 843 if (gesture_event.type == WebInputEvent::GestureFlingCancel) { |
| 844 // We don't throttle FlingCancel, because it usually goes right through to |
| 845 // the WebKit thread and blocking on WebKit is bad. |
845 tap_suppression_controller_->GestureFlingCancel( | 846 tap_suppression_controller_->GestureFlingCancel( |
846 gesture_event.timeStampSeconds); | 847 gesture_event.timeStampSeconds); |
| 848 } else { |
| 849 gesture_event_pending_ = true; |
| 850 } |
| 851 |
847 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false); | 852 ForwardInputEvent(gesture_event, sizeof(WebGestureEvent), false); |
848 } | 853 } |
849 | 854 |
850 void RenderWidgetHostImpl::ForwardKeyboardEvent( | 855 void RenderWidgetHostImpl::ForwardKeyboardEvent( |
851 const NativeWebKeyboardEvent& key_event) { | 856 const NativeWebKeyboardEvent& key_event) { |
852 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardKeyboardEvent"); | 857 TRACE_EVENT0("renderer_host", "RenderWidgetHostImpl::ForwardKeyboardEvent"); |
853 if (ignore_input_events_ || process_->IgnoreInputEvents()) | 858 if (ignore_input_events_ || process_->IgnoreInputEvents()) |
854 return; | 859 return; |
855 | 860 |
856 if (key_event.type == WebKeyboardEvent::Char && | 861 if (key_event.type == WebKeyboardEvent::Char && |
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 coalesced_mouse_wheel_events_.front(); | 1487 coalesced_mouse_wheel_events_.front(); |
1483 coalesced_mouse_wheel_events_.pop_front(); | 1488 coalesced_mouse_wheel_events_.pop_front(); |
1484 ForwardWheelEvent(next_wheel_event); | 1489 ForwardWheelEvent(next_wheel_event); |
1485 } | 1490 } |
1486 | 1491 |
1487 if (!processed && !is_hidden_ && view_) | 1492 if (!processed && !is_hidden_ && view_) |
1488 view_->UnhandledWheelEvent(current_wheel_event_); | 1493 view_->UnhandledWheelEvent(current_wheel_event_); |
1489 } | 1494 } |
1490 | 1495 |
1491 void RenderWidgetHostImpl::ProcessGestureAck(bool processed, int type) { | 1496 void RenderWidgetHostImpl::ProcessGestureAck(bool processed, int type) { |
1492 if (type == WebInputEvent::GestureFlingCancel) | 1497 if (type == WebInputEvent::GestureFlingCancel) { |
1493 tap_suppression_controller_->GestureFlingCancelAck(processed); | 1498 tap_suppression_controller_->GestureFlingCancelAck(processed); |
| 1499 } else { |
| 1500 gesture_event_pending_ = false; |
1494 | 1501 |
1495 gesture_event_pending_ = false; | 1502 // Now flush out the queued events until we hit one that needs another ack. |
1496 | 1503 while (!gesture_event_pending_ && !coalesced_gesture_events_.empty()) { |
1497 // Now send the next (coalesced) gesture event. | 1504 WebGestureEvent next_gesture_event = |
1498 if (!coalesced_gesture_events_.empty()) { | 1505 coalesced_gesture_events_.front(); |
1499 WebGestureEvent next_gesture_event = | 1506 coalesced_gesture_events_.pop_front(); |
1500 coalesced_gesture_events_.front(); | 1507 ForwardGestureEvent(next_gesture_event); |
1501 coalesced_gesture_events_.pop_front(); | 1508 } |
1502 ForwardGestureEvent(next_gesture_event); | |
1503 } | 1509 } |
1504 } | 1510 } |
1505 | 1511 |
1506 void RenderWidgetHostImpl::ProcessTouchAck( | 1512 void RenderWidgetHostImpl::ProcessTouchAck( |
1507 WebInputEvent::Type type, bool processed) { | 1513 WebInputEvent::Type type, bool processed) { |
1508 if (view_) | 1514 if (view_) |
1509 view_->ProcessTouchAck(type, processed); | 1515 view_->ProcessTouchAck(type, processed); |
1510 } | 1516 } |
1511 | 1517 |
1512 void RenderWidgetHostImpl::OnMsgFocus() { | 1518 void RenderWidgetHostImpl::OnMsgFocus() { |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1873 // indicate that no callback is in progress (i.e. without this line | 1879 // indicate that no callback is in progress (i.e. without this line |
1874 // DelayedAutoResized will not get called again). | 1880 // DelayedAutoResized will not get called again). |
1875 new_auto_size_.SetSize(0, 0); | 1881 new_auto_size_.SetSize(0, 0); |
1876 if (!should_auto_resize_) | 1882 if (!should_auto_resize_) |
1877 return; | 1883 return; |
1878 | 1884 |
1879 OnRenderAutoResized(new_size); | 1885 OnRenderAutoResized(new_size); |
1880 } | 1886 } |
1881 | 1887 |
1882 } // namespace content | 1888 } // namespace content |
OLD | NEW |