Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_android.cc

Issue 759433002: Reland: Move TouchSelectionController from content to ui (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed reviewers' comments Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 "base/android/build_info.h" 9 #include "base/android/build_info.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 27 matching lines...) Expand all
38 #include "content/browser/devtools/render_view_devtools_agent_host.h" 38 #include "content/browser/devtools/render_view_devtools_agent_host.h"
39 #include "content/browser/gpu/compositor_util.h" 39 #include "content/browser/gpu/compositor_util.h"
40 #include "content/browser/gpu/gpu_data_manager_impl.h" 40 #include "content/browser/gpu/gpu_data_manager_impl.h"
41 #include "content/browser/gpu/gpu_process_host_ui_shim.h" 41 #include "content/browser/gpu/gpu_process_host_ui_shim.h"
42 #include "content/browser/gpu/gpu_surface_tracker.h" 42 #include "content/browser/gpu/gpu_surface_tracker.h"
43 #include "content/browser/media/media_web_contents_observer.h" 43 #include "content/browser/media/media_web_contents_observer.h"
44 #include "content/browser/renderer_host/compositor_impl_android.h" 44 #include "content/browser/renderer_host/compositor_impl_android.h"
45 #include "content/browser/renderer_host/dip_util.h" 45 #include "content/browser/renderer_host/dip_util.h"
46 #include "content/browser/renderer_host/image_transport_factory_android.h" 46 #include "content/browser/renderer_host/image_transport_factory_android.h"
47 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h " 47 #include "content/browser/renderer_host/input/synthetic_gesture_target_android.h "
48 #include "content/browser/renderer_host/input/touch_selection_controller.h"
49 #include "content/browser/renderer_host/input/web_input_event_builders_android.h " 48 #include "content/browser/renderer_host/input/web_input_event_builders_android.h "
50 #include "content/browser/renderer_host/input/web_input_event_util.h" 49 #include "content/browser/renderer_host/input/web_input_event_util.h"
51 #include "content/browser/renderer_host/render_process_host_impl.h" 50 #include "content/browser/renderer_host/render_process_host_impl.h"
52 #include "content/browser/renderer_host/render_view_host_impl.h" 51 #include "content/browser/renderer_host/render_view_host_impl.h"
53 #include "content/browser/renderer_host/render_widget_host_impl.h" 52 #include "content/browser/renderer_host/render_widget_host_impl.h"
54 #include "content/common/gpu/client/gl_helper.h" 53 #include "content/common/gpu/client/gl_helper.h"
55 #include "content/common/gpu/gpu_messages.h" 54 #include "content/common/gpu/gpu_messages.h"
56 #include "content/common/input/did_overscroll_params.h" 55 #include "content/common/input/did_overscroll_params.h"
57 #include "content/common/input_messages.h" 56 #include "content/common/input_messages.h"
58 #include "content/common/view_messages.h" 57 #include "content/common/view_messages.h"
(...skipping 11 matching lines...) Expand all
70 #include "ui/base/android/window_android_compositor.h" 69 #include "ui/base/android/window_android_compositor.h"
71 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" 70 #include "ui/events/gesture_detection/gesture_provider_config_helper.h"
72 #include "ui/events/gesture_detection/motion_event.h" 71 #include "ui/events/gesture_detection/motion_event.h"
73 #include "ui/gfx/android/device_display_info.h" 72 #include "ui/gfx/android/device_display_info.h"
74 #include "ui/gfx/android/java_bitmap.h" 73 #include "ui/gfx/android/java_bitmap.h"
75 #include "ui/gfx/android/view_configuration.h" 74 #include "ui/gfx/android/view_configuration.h"
76 #include "ui/gfx/display.h" 75 #include "ui/gfx/display.h"
77 #include "ui/gfx/geometry/dip_util.h" 76 #include "ui/gfx/geometry/dip_util.h"
78 #include "ui/gfx/screen.h" 77 #include "ui/gfx/screen.h"
79 #include "ui/gfx/size_conversions.h" 78 #include "ui/gfx/size_conversions.h"
79 #include "ui/touch_selection/touch_selection_controller.h"
80 80
81 namespace content { 81 namespace content {
82 82
83 namespace { 83 namespace {
84 84
85 const int kUndefinedOutputSurfaceId = -1; 85 const int kUndefinedOutputSurfaceId = -1;
86 86
87 // Used to accomodate finite precision when comparing scaled viewport and 87 // Used to accomodate finite precision when comparing scaled viewport and
88 // content widths. While this value may seem large, width=device-width on an N7 88 // content widths. While this value may seem large, width=device-width on an N7
89 // V1 saw errors of ~0.065 between computed window and content widths. 89 // V1 saw errors of ~0.065 between computed window and content widths.
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 latency_info.AddLatencyNumberWithTimestamp( 130 latency_info.AddLatencyNumberWithTimestamp(
131 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, 131 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT,
132 0, 132 0,
133 0, 133 0,
134 base::TimeTicks() + base::TimeDelta::FromMicroseconds(time_micros), 134 base::TimeTicks() + base::TimeDelta::FromMicroseconds(time_micros),
135 1); 135 1);
136 } 136 }
137 return latency_info; 137 return latency_info;
138 } 138 }
139 139
140 scoped_ptr<TouchSelectionController> CreateSelectionController( 140 scoped_ptr<ui::TouchSelectionController> CreateSelectionController(
141 TouchSelectionControllerClient* client, 141 ui::TouchSelectionControllerClient* client,
142 ContentViewCore* content_view_core) { 142 ContentViewCore* content_view_core) {
143 DCHECK(client); 143 DCHECK(client);
144 DCHECK(content_view_core); 144 DCHECK(content_view_core);
145 int tap_timeout_ms = gfx::ViewConfiguration::GetTapTimeoutInMs(); 145 int tap_timeout_ms = gfx::ViewConfiguration::GetTapTimeoutInMs();
146 int touch_slop_pixels = gfx::ViewConfiguration::GetTouchSlopInPixels(); 146 int touch_slop_pixels = gfx::ViewConfiguration::GetTouchSlopInPixels();
147 return make_scoped_ptr(new TouchSelectionController( 147 return make_scoped_ptr(new ui::TouchSelectionController(
148 client, 148 client,
149 base::TimeDelta::FromMilliseconds(tap_timeout_ms), 149 base::TimeDelta::FromMilliseconds(tap_timeout_ms),
150 touch_slop_pixels / content_view_core->GetDpiScale())); 150 touch_slop_pixels / content_view_core->GetDpiScale()));
151 } 151 }
152 152
153 scoped_ptr<OverscrollControllerAndroid> CreateOverscrollController( 153 scoped_ptr<OverscrollControllerAndroid> CreateOverscrollController(
154 ContentViewCore* content_view_core) { 154 ContentViewCore* content_view_core) {
155 DCHECK(content_view_core); 155 DCHECK(content_view_core);
156 ui::WindowAndroid* window = content_view_core->GetWindowAndroid(); 156 ui::WindowAndroid* window = content_view_core->GetWindowAndroid();
157 DCHECK(window); 157 DCHECK(window);
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
1102 } 1102 }
1103 1103
1104 void RenderWidgetHostViewAndroid::SelectBetweenCoordinates( 1104 void RenderWidgetHostViewAndroid::SelectBetweenCoordinates(
1105 const gfx::PointF& base, 1105 const gfx::PointF& base,
1106 const gfx::PointF& extent) { 1106 const gfx::PointF& extent) {
1107 DCHECK(content_view_core_); 1107 DCHECK(content_view_core_);
1108 content_view_core_->SelectBetweenCoordinates(base, extent); 1108 content_view_core_->SelectBetweenCoordinates(base, extent);
1109 } 1109 }
1110 1110
1111 void RenderWidgetHostViewAndroid::OnSelectionEvent( 1111 void RenderWidgetHostViewAndroid::OnSelectionEvent(
1112 SelectionEventType event, 1112 ui::SelectionEventType event,
1113 const gfx::PointF& position) { 1113 const gfx::PointF& position) {
1114 DCHECK(content_view_core_); 1114 DCHECK(content_view_core_);
1115 // Showing the selection action bar can alter the current View coordinates in 1115 // Showing the selection action bar can alter the current View coordinates in
1116 // such a way that the current MotionEvent stream is suddenly shifted in 1116 // such a way that the current MotionEvent stream is suddenly shifted in
1117 // space. Avoid the associated scroll jump by pre-emptively cancelling gesture 1117 // space. Avoid the associated scroll jump by pre-emptively cancelling gesture
1118 // detection; scrolling after the selection is activated is unnecessary. 1118 // detection; scrolling after the selection is activated is unnecessary.
1119 if (event == SelectionEventType::SELECTION_SHOWN) 1119 if (event == ui::SelectionEventType::SELECTION_SHOWN)
1120 ResetGestureDetection(); 1120 ResetGestureDetection();
1121 content_view_core_->OnSelectionEvent(event, position); 1121 content_view_core_->OnSelectionEvent(event, position);
1122 } 1122 }
1123 1123
1124 scoped_ptr<TouchHandleDrawable> RenderWidgetHostViewAndroid::CreateDrawable() { 1124 scoped_ptr<ui::TouchHandleDrawable>
1125 RenderWidgetHostViewAndroid::CreateDrawable() {
1125 DCHECK(content_view_core_); 1126 DCHECK(content_view_core_);
1126 if (using_synchronous_compositor_) 1127 if (using_synchronous_compositor_)
1127 return content_view_core_->CreatePopupTouchHandleDrawable(); 1128 return content_view_core_->CreatePopupTouchHandleDrawable();
1128 1129
1129 return scoped_ptr<TouchHandleDrawable>(new CompositedTouchHandleDrawable( 1130 return scoped_ptr<ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable(
1130 content_view_core_->GetLayer().get(), 1131 content_view_core_->GetLayer().get(),
1131 content_view_core_->GetDpiScale(), 1132 content_view_core_->GetDpiScale(),
1132 // Use the activity context (instead of the application context) to ensure 1133 // Use the activity context (instead of the application context) to ensure
1133 // proper handle theming. 1134 // proper handle theming.
1134 content_view_core_->GetContext().obj())); 1135 content_view_core_->GetContext().obj()));
1135 } 1136 }
1136 1137
1137 void RenderWidgetHostViewAndroid::SynchronousCopyContents( 1138 void RenderWidgetHostViewAndroid::SynchronousCopyContents(
1138 const gfx::Rect& src_subrect_in_pixel, 1139 const gfx::Rect& src_subrect_in_pixel,
1139 const gfx::Size& dst_size_in_pixel, 1140 const gfx::Size& dst_size_in_pixel,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1173 !has_fixed_page_scale && !has_mobile_viewport); 1174 !has_fixed_page_scale && !has_mobile_viewport);
1174 1175
1175 if (!content_view_core_) 1176 if (!content_view_core_)
1176 return; 1177 return;
1177 1178
1178 if (overscroll_controller_) 1179 if (overscroll_controller_)
1179 overscroll_controller_->OnFrameMetadataUpdated(frame_metadata); 1180 overscroll_controller_->OnFrameMetadataUpdated(frame_metadata);
1180 1181
1181 if (selection_controller_) { 1182 if (selection_controller_) {
1182 selection_controller_->OnSelectionBoundsChanged( 1183 selection_controller_->OnSelectionBoundsChanged(
1183 frame_metadata.selection_start, frame_metadata.selection_end); 1184 ui::SelectionBound(frame_metadata.selection_start),
1185 ui::SelectionBound(frame_metadata.selection_end));
1184 } 1186 }
1185 1187
1186 // All offsets and sizes are in CSS pixels. 1188 // All offsets and sizes are in CSS pixels.
1187 content_view_core_->UpdateFrameInfo( 1189 content_view_core_->UpdateFrameInfo(
1188 frame_metadata.root_scroll_offset, 1190 frame_metadata.root_scroll_offset,
1189 frame_metadata.page_scale_factor, 1191 frame_metadata.page_scale_factor,
1190 gfx::Vector2dF(frame_metadata.min_page_scale_factor, 1192 gfx::Vector2dF(frame_metadata.min_page_scale_factor,
1191 frame_metadata.max_page_scale_factor), 1193 frame_metadata.max_page_scale_factor),
1192 frame_metadata.root_layer_size, 1194 frame_metadata.root_layer_size,
1193 frame_metadata.scrollable_viewport_size, 1195 frame_metadata.scrollable_viewport_size,
(...skipping 558 matching lines...) Expand 10 before | Expand all | Expand 10 after
1752 results->orientationAngle = display.RotationAsDegree(); 1754 results->orientationAngle = display.RotationAsDegree();
1753 results->orientationType = 1755 results->orientationType =
1754 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 1756 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
1755 gfx::DeviceDisplayInfo info; 1757 gfx::DeviceDisplayInfo info;
1756 results->depth = info.GetBitsPerPixel(); 1758 results->depth = info.GetBitsPerPixel();
1757 results->depthPerComponent = info.GetBitsPerComponent(); 1759 results->depthPerComponent = info.GetBitsPerComponent();
1758 results->isMonochrome = (results->depthPerComponent == 0); 1760 results->isMonochrome = (results->depthPerComponent == 0);
1759 } 1761 }
1760 1762
1761 } // namespace content 1763 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698