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 <math.h> | 7 #include <math.h> |
8 #include <set> | 8 #include <set> |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 946 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
957 original_component.sequence_number, | 957 original_component.sequence_number, |
958 original_component.event_time, | 958 original_component.event_time, |
959 original_component.event_count); | 959 original_component.event_count); |
960 } | 960 } |
961 } | 961 } |
962 | 962 |
963 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, latency_info); | 963 GestureEventWithLatencyInfo gesture_with_latency(gesture_event, latency_info); |
964 input_router_->SendGestureEvent(gesture_with_latency); | 964 input_router_->SendGestureEvent(gesture_with_latency); |
965 } | 965 } |
966 | 966 |
967 void RenderWidgetHostImpl::ForwardTouchEvent( | 967 void RenderWidgetHostImpl::ForwardEmulatedTouchEvent( |
968 const blink::WebTouchEvent& touch_event) { | 968 const blink::WebTouchEvent& touch_event) { |
969 ForwardTouchEventWithLatencyInfo(touch_event, ui::LatencyInfo()); | 969 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardEmulatedTouchEvent"); |
| 970 ui::LatencyInfo latency_info = |
| 971 CreateRWHLatencyInfoIfNotExist(NULL, touch_event.type); |
| 972 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); |
| 973 input_router_->SendTouchEvent(touch_with_latency); |
970 } | 974 } |
971 | 975 |
972 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( | 976 void RenderWidgetHostImpl::ForwardTouchEventWithLatencyInfo( |
973 const blink::WebTouchEvent& touch_event, | 977 const blink::WebTouchEvent& touch_event, |
974 const ui::LatencyInfo& ui_latency) { | 978 const ui::LatencyInfo& ui_latency) { |
975 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); | 979 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardTouchEvent"); |
976 | 980 |
977 // Always forward TouchEvents for touch stream consistency. They will be | 981 // Always forward TouchEvents for touch stream consistency. They will be |
978 // ignored if appropriate in FilterInputEvent(). | 982 // ignored if appropriate in FilterInputEvent(). |
979 | 983 |
980 ui::LatencyInfo latency_info = | 984 ui::LatencyInfo latency_info = |
981 CreateRWHLatencyInfoIfNotExist(&ui_latency, touch_event.type); | 985 CreateRWHLatencyInfoIfNotExist(&ui_latency, touch_event.type); |
982 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); | 986 TouchEventWithLatencyInfo touch_with_latency(touch_event, latency_info); |
| 987 |
| 988 if (touch_emulator_ && |
| 989 touch_emulator_->HandleTouchEvent(touch_with_latency.event)) { |
| 990 if (view_) { |
| 991 view_->ProcessAckedTouchEvent( |
| 992 touch_with_latency, INPUT_EVENT_ACK_STATE_CONSUMED); |
| 993 } |
| 994 return; |
| 995 } |
| 996 |
983 input_router_->SendTouchEvent(touch_with_latency); | 997 input_router_->SendTouchEvent(touch_with_latency); |
984 } | 998 } |
985 | 999 |
986 void RenderWidgetHostImpl::ForwardKeyboardEvent( | 1000 void RenderWidgetHostImpl::ForwardKeyboardEvent( |
987 const NativeWebKeyboardEvent& key_event) { | 1001 const NativeWebKeyboardEvent& key_event) { |
988 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent"); | 1002 TRACE_EVENT0("input", "RenderWidgetHostImpl::ForwardKeyboardEvent"); |
989 if (IgnoreInputEvents()) | 1003 if (IgnoreInputEvents()) |
990 return; | 1004 return; |
991 | 1005 |
992 if (!process_->HasConnection()) | 1006 if (!process_->HasConnection()) |
(...skipping 896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1889 touch_event.latency.AddLatencyNumber( | 1903 touch_event.latency.AddLatencyNumber( |
1890 ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT, 0, 0); | 1904 ui::INPUT_EVENT_LATENCY_ACKED_TOUCH_COMPONENT, 0, 0); |
1891 // TouchEvent latency ends at ack if it didn't cause any rendering. | 1905 // TouchEvent latency ends at ack if it didn't cause any rendering. |
1892 if (!touch_event.latency.FindLatency( | 1906 if (!touch_event.latency.FindLatency( |
1893 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { | 1907 ui::INPUT_EVENT_LATENCY_RENDERING_SCHEDULED_COMPONENT, 0, NULL)) { |
1894 touch_event.latency.AddLatencyNumber( | 1908 touch_event.latency.AddLatencyNumber( |
1895 ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0); | 1909 ui::INPUT_EVENT_LATENCY_TERMINATED_TOUCH_COMPONENT, 0, 0); |
1896 } | 1910 } |
1897 ComputeTouchLatency(touch_event.latency); | 1911 ComputeTouchLatency(touch_event.latency); |
1898 | 1912 |
1899 if (touch_emulator_ && touch_emulator_->HandleTouchEventAck(ack_result)) | 1913 if (touch_emulator_ && |
| 1914 touch_emulator_->HandleTouchEventAck(event.event, ack_result)) { |
1900 return; | 1915 return; |
| 1916 } |
1901 | 1917 |
1902 if (view_) | 1918 if (view_) |
1903 view_->ProcessAckedTouchEvent(touch_event, ack_result); | 1919 view_->ProcessAckedTouchEvent(touch_event, ack_result); |
1904 } | 1920 } |
1905 | 1921 |
1906 void RenderWidgetHostImpl::OnUnexpectedEventAck(UnexpectedEventAckType type) { | 1922 void RenderWidgetHostImpl::OnUnexpectedEventAck(UnexpectedEventAckType type) { |
1907 if (type == BAD_ACK_MESSAGE) { | 1923 if (type == BAD_ACK_MESSAGE) { |
1908 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH2")); | 1924 RecordAction(base::UserMetricsAction("BadMessageTerminate_RWH2")); |
1909 process_->ReceivedBadMessage(); | 1925 process_->ReceivedBadMessage(); |
1910 } else if (type == UNEXPECTED_EVENT_TYPE) { | 1926 } else if (type == UNEXPECTED_EVENT_TYPE) { |
1911 suppress_next_char_events_ = false; | 1927 suppress_next_char_events_ = false; |
1912 } | 1928 } |
1913 } | 1929 } |
1914 | 1930 |
1915 void RenderWidgetHostImpl::OnSyntheticGestureCompleted( | 1931 void RenderWidgetHostImpl::OnSyntheticGestureCompleted( |
1916 SyntheticGesture::Result result) { | 1932 SyntheticGesture::Result result) { |
1917 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID())); | 1933 Send(new InputMsg_SyntheticGestureCompleted(GetRoutingID())); |
1918 } | 1934 } |
1919 | 1935 |
1920 const gfx::Vector2d& RenderWidgetHostImpl::GetLastScrollOffset() const { | 1936 const gfx::Vector2d& RenderWidgetHostImpl::GetLastScrollOffset() const { |
1921 return last_scroll_offset_; | 1937 return last_scroll_offset_; |
1922 } | 1938 } |
1923 | 1939 |
1924 bool RenderWidgetHostImpl::IgnoreInputEvents() const { | 1940 bool RenderWidgetHostImpl::IgnoreInputEvents() const { |
1925 return ignore_input_events_ || process_->IgnoreInputEvents(); | 1941 return ignore_input_events_ || process_->IgnoreInputEvents(); |
1926 } | 1942 } |
1927 | 1943 |
1928 bool RenderWidgetHostImpl::ShouldForwardTouchEvent() const { | 1944 bool RenderWidgetHostImpl::ShouldForwardTouchEvent() const { |
| 1945 // It's important that the emulator sees a complete native touch stream, |
| 1946 // allowing it to perform touch filtering as appropriate. |
| 1947 // TODO(dgozman): Remove when touch stream forwarding issues resolved, see |
| 1948 // crbug.com/375940. |
| 1949 if (touch_emulator_ && touch_emulator_->enabled()) |
| 1950 return true; |
| 1951 |
1929 return input_router_->ShouldForwardTouchEvent(); | 1952 return input_router_->ShouldForwardTouchEvent(); |
1930 } | 1953 } |
1931 | 1954 |
1932 void RenderWidgetHostImpl::StartUserGesture() { | 1955 void RenderWidgetHostImpl::StartUserGesture() { |
1933 OnUserGesture(); | 1956 OnUserGesture(); |
1934 } | 1957 } |
1935 | 1958 |
1936 void RenderWidgetHostImpl::Stop() { | 1959 void RenderWidgetHostImpl::Stop() { |
1937 Send(new ViewMsg_Stop(GetRoutingID())); | 1960 Send(new ViewMsg_Stop(GetRoutingID())); |
1938 } | 1961 } |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2381 } | 2404 } |
2382 } | 2405 } |
2383 | 2406 |
2384 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { | 2407 SkColorType RenderWidgetHostImpl::PreferredReadbackFormat() { |
2385 if (view_) | 2408 if (view_) |
2386 return view_->PreferredReadbackFormat(); | 2409 return view_->PreferredReadbackFormat(); |
2387 return kN32_SkColorType; | 2410 return kN32_SkColorType; |
2388 } | 2411 } |
2389 | 2412 |
2390 } // namespace content | 2413 } // namespace content |
OLD | NEW |