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_view_android.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_android.h" |
6 | 6 |
7 #include <android/bitmap.h> | 7 #include <android/bitmap.h> |
8 | 8 |
9 #include <utility> | 9 #include <utility> |
10 | 10 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 #include "third_party/khronos/GLES2/gl2ext.h" | 75 #include "third_party/khronos/GLES2/gl2ext.h" |
76 #include "third_party/skia/include/core/SkCanvas.h" | 76 #include "third_party/skia/include/core/SkCanvas.h" |
77 #include "ui/android/delegated_frame_host_android.h" | 77 #include "ui/android/delegated_frame_host_android.h" |
78 #include "ui/android/window_android.h" | 78 #include "ui/android/window_android.h" |
79 #include "ui/android/window_android_compositor.h" | 79 #include "ui/android/window_android_compositor.h" |
80 #include "ui/base/layout.h" | 80 #include "ui/base/layout.h" |
81 #include "ui/display/display.h" | 81 #include "ui/display/display.h" |
82 #include "ui/display/screen.h" | 82 #include "ui/display/screen.h" |
83 #include "ui/events/blink/blink_event_util.h" | 83 #include "ui/events/blink/blink_event_util.h" |
84 #include "ui/events/blink/did_overscroll_params.h" | 84 #include "ui/events/blink/did_overscroll_params.h" |
| 85 #include "ui/events/blink/web_input_event_traits.h" |
85 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 86 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
86 #include "ui/events/gesture_detection/motion_event.h" | 87 #include "ui/events/gesture_detection/motion_event.h" |
87 #include "ui/gfx/android/device_display_info.h" | 88 #include "ui/gfx/android/device_display_info.h" |
88 #include "ui/gfx/android/java_bitmap.h" | 89 #include "ui/gfx/android/java_bitmap.h" |
89 #include "ui/gfx/android/view_configuration.h" | 90 #include "ui/gfx/android/view_configuration.h" |
90 #include "ui/gfx/geometry/dip_util.h" | 91 #include "ui/gfx/geometry/dip_util.h" |
91 #include "ui/gfx/geometry/size_conversions.h" | 92 #include "ui/gfx/geometry/size_conversions.h" |
92 #include "ui/touch_selection/touch_selection_controller.h" | 93 #include "ui/touch_selection/touch_selection_controller.h" |
93 | 94 |
94 namespace content { | 95 namespace content { |
(...skipping 595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
690 return true; | 691 return true; |
691 } | 692 } |
692 | 693 |
693 ui::FilteredGestureProvider::TouchHandlingResult result = | 694 ui::FilteredGestureProvider::TouchHandlingResult result = |
694 gesture_provider_.OnTouchEvent(event); | 695 gesture_provider_.OnTouchEvent(event); |
695 if (!result.succeeded) | 696 if (!result.succeeded) |
696 return false; | 697 return false; |
697 | 698 |
698 blink::WebTouchEvent web_event = ui::CreateWebTouchEventFromMotionEvent( | 699 blink::WebTouchEvent web_event = ui::CreateWebTouchEventFromMotionEvent( |
699 event, result.moved_beyond_slop_region); | 700 event, result.moved_beyond_slop_region); |
700 ui::LatencyInfo latency_info; | 701 ui::LatencyInfo latency_info(ui::SourceEventType::TOUCH); |
701 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 702 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
702 host_->ForwardTouchEventWithLatencyInfo(web_event, latency_info); | 703 host_->ForwardTouchEventWithLatencyInfo(web_event, latency_info); |
703 | 704 |
704 // Send a proactive BeginFrame for this vsync to reduce scroll latency for | 705 // Send a proactive BeginFrame for this vsync to reduce scroll latency for |
705 // scroll-inducing touch events. Note that Android's Choreographer ensures | 706 // scroll-inducing touch events. Note that Android's Choreographer ensures |
706 // that BeginFrame requests made during ACTION_MOVE dispatch will be honored | 707 // that BeginFrame requests made during ACTION_MOVE dispatch will be honored |
707 // in the same vsync phase. | 708 // in the same vsync phase. |
708 if (observing_root_window_ && result.moved_beyond_slop_region) | 709 if (observing_root_window_ && result.moved_beyond_slop_region) |
709 RequestVSyncUpdate(BEGIN_FRAME); | 710 RequestVSyncUpdate(BEGIN_FRAME); |
710 | 711 |
(...skipping 12 matching lines...) Expand all Loading... |
723 if (!current_down_event) { | 724 if (!current_down_event) { |
724 // A hard reset ensures prevention of any timer-based events that might fire | 725 // A hard reset ensures prevention of any timer-based events that might fire |
725 // after a touch sequence has ended. | 726 // after a touch sequence has ended. |
726 gesture_provider_.ResetDetection(); | 727 gesture_provider_.ResetDetection(); |
727 return; | 728 return; |
728 } | 729 } |
729 | 730 |
730 std::unique_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel(); | 731 std::unique_ptr<ui::MotionEvent> cancel_event = current_down_event->Cancel(); |
731 if (gesture_provider_.OnTouchEvent(*cancel_event).succeeded) { | 732 if (gesture_provider_.OnTouchEvent(*cancel_event).succeeded) { |
732 bool causes_scrolling = false; | 733 bool causes_scrolling = false; |
| 734 ui::LatencyInfo latency_info(ui::SourceEventType::TOUCH); |
| 735 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
733 host_->ForwardTouchEventWithLatencyInfo( | 736 host_->ForwardTouchEventWithLatencyInfo( |
734 ui::CreateWebTouchEventFromMotionEvent(*cancel_event, causes_scrolling), | 737 ui::CreateWebTouchEventFromMotionEvent(*cancel_event, causes_scrolling), |
735 ui::LatencyInfo()); | 738 latency_info); |
736 } | 739 } |
737 } | 740 } |
738 | 741 |
739 void RenderWidgetHostViewAndroid::OnDidNavigateMainFrameToNewPage() { | 742 void RenderWidgetHostViewAndroid::OnDidNavigateMainFrameToNewPage() { |
740 ResetGestureDetection(); | 743 ResetGestureDetection(); |
741 } | 744 } |
742 | 745 |
743 void RenderWidgetHostViewAndroid::SetDoubleTapSupportEnabled(bool enabled) { | 746 void RenderWidgetHostViewAndroid::SetDoubleTapSupportEnabled(bool enabled) { |
744 gesture_provider_.SetDoubleTapSupportForPlatformEnabled(enabled); | 747 gesture_provider_.SetDoubleTapSupportForPlatformEnabled(enabled); |
745 } | 748 } |
(...skipping 752 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1498 | 1501 |
1499 void RenderWidgetHostViewAndroid::SendMouseEvent( | 1502 void RenderWidgetHostViewAndroid::SendMouseEvent( |
1500 const blink::WebMouseEvent& event) { | 1503 const blink::WebMouseEvent& event) { |
1501 if (host_) | 1504 if (host_) |
1502 host_->ForwardMouseEvent(event); | 1505 host_->ForwardMouseEvent(event); |
1503 } | 1506 } |
1504 | 1507 |
1505 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( | 1508 void RenderWidgetHostViewAndroid::SendMouseWheelEvent( |
1506 const blink::WebMouseWheelEvent& event) { | 1509 const blink::WebMouseWheelEvent& event) { |
1507 if (host_) { | 1510 if (host_) { |
1508 ui::LatencyInfo latency_info; | 1511 ui::LatencyInfo latency_info(ui::SourceEventType::WHEEL); |
1509 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); | 1512 latency_info.AddLatencyNumber(ui::INPUT_EVENT_LATENCY_UI_COMPONENT, 0, 0); |
1510 host_->ForwardWheelEventWithLatencyInfo(event, latency_info); | 1513 host_->ForwardWheelEventWithLatencyInfo(event, latency_info); |
1511 } | 1514 } |
1512 } | 1515 } |
1513 | 1516 |
1514 void RenderWidgetHostViewAndroid::SendGestureEvent( | 1517 void RenderWidgetHostViewAndroid::SendGestureEvent( |
1515 const blink::WebGestureEvent& event) { | 1518 const blink::WebGestureEvent& event) { |
1516 // Sending a gesture that may trigger overscroll should resume the effect. | 1519 // Sending a gesture that may trigger overscroll should resume the effect. |
1517 if (overscroll_controller_) | 1520 if (overscroll_controller_) |
1518 overscroll_controller_->Enable(); | 1521 overscroll_controller_->Enable(); |
1519 | 1522 |
1520 if (host_) | 1523 if (host_) { |
1521 host_->ForwardGestureEventWithLatencyInfo(event, ui::LatencyInfo()); | 1524 ui::LatencyInfo latency_info = |
| 1525 ui::WebInputEventTraits::CreateLatencyInfoForWebGestureEvent(event); |
| 1526 host_->ForwardGestureEventWithLatencyInfo(event, latency_info); |
| 1527 } |
1522 } | 1528 } |
1523 | 1529 |
1524 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::Point& point) { | 1530 void RenderWidgetHostViewAndroid::MoveCaret(const gfx::Point& point) { |
1525 if (host_) | 1531 if (host_) |
1526 host_->MoveCaret(point); | 1532 host_->MoveCaret(point); |
1527 } | 1533 } |
1528 | 1534 |
1529 void RenderWidgetHostViewAndroid::DismissTextHandles() { | 1535 void RenderWidgetHostViewAndroid::DismissTextHandles() { |
1530 if (selection_controller_) | 1536 if (selection_controller_) |
1531 selection_controller_->HideAndDisallowShowingAutomatically(); | 1537 selection_controller_->HideAndDisallowShowingAutomatically(); |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1880 case ui::MotionEvent::ACTION_UP: | 1886 case ui::MotionEvent::ACTION_UP: |
1881 case ui::MotionEvent::ACTION_POINTER_UP: | 1887 case ui::MotionEvent::ACTION_POINTER_UP: |
1882 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", | 1888 UMA_HISTOGRAM_CUSTOM_COUNTS("Event.Latency.OS.TOUCH_RELEASED", |
1883 delta.InMicroseconds(), 1, 1000000, 50); | 1889 delta.InMicroseconds(), 1, 1000000, 50); |
1884 default: | 1890 default: |
1885 return; | 1891 return; |
1886 } | 1892 } |
1887 } | 1893 } |
1888 | 1894 |
1889 } // namespace content | 1895 } // namespace content |
OLD | NEW |