| 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 "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 Loading... |
| 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/browser_gpu_channel_host_factory.h" | 39 #include "content/browser/gpu/browser_gpu_channel_host_factory.h" |
| 40 #include "content/browser/gpu/compositor_util.h" | 40 #include "content/browser/gpu/compositor_util.h" |
| 41 #include "content/browser/gpu/gpu_data_manager_impl.h" | 41 #include "content/browser/gpu/gpu_data_manager_impl.h" |
| 42 #include "content/browser/gpu/gpu_process_host_ui_shim.h" | 42 #include "content/browser/gpu/gpu_process_host_ui_shim.h" |
| 43 #include "content/browser/gpu/gpu_surface_tracker.h" | 43 #include "content/browser/gpu/gpu_surface_tracker.h" |
| 44 #include "content/browser/media/media_web_contents_observer.h" | 44 #include "content/browser/media/media_web_contents_observer.h" |
| 45 #include "content/browser/renderer_host/compositor_impl_android.h" | 45 #include "content/browser/renderer_host/compositor_impl_android.h" |
| 46 #include "content/browser/renderer_host/dip_util.h" | 46 #include "content/browser/renderer_host/dip_util.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/client/webgraphicscontext3d_command_buffer_impl.h" | 54 #include "content/common/gpu/client/webgraphicscontext3d_command_buffer_impl.h" |
| 56 #include "content/common/gpu/gpu_messages.h" | 55 #include "content/common/gpu/gpu_messages.h" |
| 57 #include "content/common/gpu/gpu_process_launch_causes.h" | 56 #include "content/common/gpu/gpu_process_launch_causes.h" |
| 58 #include "content/common/input/did_overscroll_params.h" | 57 #include "content/common/input/did_overscroll_params.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 74 #include "ui/base/android/window_android_compositor.h" | 73 #include "ui/base/android/window_android_compositor.h" |
| 75 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" | 74 #include "ui/events/gesture_detection/gesture_provider_config_helper.h" |
| 76 #include "ui/events/gesture_detection/motion_event.h" | 75 #include "ui/events/gesture_detection/motion_event.h" |
| 77 #include "ui/gfx/android/device_display_info.h" | 76 #include "ui/gfx/android/device_display_info.h" |
| 78 #include "ui/gfx/android/java_bitmap.h" | 77 #include "ui/gfx/android/java_bitmap.h" |
| 79 #include "ui/gfx/android/view_configuration.h" | 78 #include "ui/gfx/android/view_configuration.h" |
| 80 #include "ui/gfx/display.h" | 79 #include "ui/gfx/display.h" |
| 81 #include "ui/gfx/geometry/dip_util.h" | 80 #include "ui/gfx/geometry/dip_util.h" |
| 82 #include "ui/gfx/screen.h" | 81 #include "ui/gfx/screen.h" |
| 83 #include "ui/gfx/size_conversions.h" | 82 #include "ui/gfx/size_conversions.h" |
| 83 #include "ui/touch_selection/touch_selection_controller.h" |
| 84 | 84 |
| 85 namespace content { | 85 namespace content { |
| 86 | 86 |
| 87 namespace { | 87 namespace { |
| 88 | 88 |
| 89 const int kUndefinedOutputSurfaceId = -1; | 89 const int kUndefinedOutputSurfaceId = -1; |
| 90 | 90 |
| 91 // Used to accomodate finite precision when comparing scaled viewport and | 91 // Used to accomodate finite precision when comparing scaled viewport and |
| 92 // content widths. While this value may seem large, width=device-width on an N7 | 92 // content widths. While this value may seem large, width=device-width on an N7 |
| 93 // V1 saw errors of ~0.065 between computed window and content widths. | 93 // V1 saw errors of ~0.065 between computed window and content widths. |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 latency_info.AddLatencyNumberWithTimestamp( | 250 latency_info.AddLatencyNumberWithTimestamp( |
| 251 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, | 251 ui::INPUT_EVENT_LATENCY_ORIGINAL_COMPONENT, |
| 252 0, | 252 0, |
| 253 0, | 253 0, |
| 254 base::TimeTicks() + base::TimeDelta::FromMicroseconds(time_micros), | 254 base::TimeTicks() + base::TimeDelta::FromMicroseconds(time_micros), |
| 255 1); | 255 1); |
| 256 } | 256 } |
| 257 return latency_info; | 257 return latency_info; |
| 258 } | 258 } |
| 259 | 259 |
| 260 scoped_ptr<TouchSelectionController> CreateSelectionController( | 260 scoped_ptr<ui::TouchSelectionController> CreateSelectionController( |
| 261 TouchSelectionControllerClient* client, | 261 ui::TouchSelectionControllerClient* client, |
| 262 ContentViewCore* content_view_core) { | 262 ContentViewCore* content_view_core) { |
| 263 DCHECK(client); | 263 DCHECK(client); |
| 264 DCHECK(content_view_core); | 264 DCHECK(content_view_core); |
| 265 int tap_timeout_ms = gfx::ViewConfiguration::GetTapTimeoutInMs(); | 265 int tap_timeout_ms = gfx::ViewConfiguration::GetTapTimeoutInMs(); |
| 266 int touch_slop_pixels = gfx::ViewConfiguration::GetTouchSlopInPixels(); | 266 int touch_slop_pixels = gfx::ViewConfiguration::GetTouchSlopInPixels(); |
| 267 return make_scoped_ptr(new TouchSelectionController( | 267 return make_scoped_ptr(new ui::TouchSelectionController( |
| 268 client, | 268 client, |
| 269 base::TimeDelta::FromMilliseconds(tap_timeout_ms), | 269 base::TimeDelta::FromMilliseconds(tap_timeout_ms), |
| 270 touch_slop_pixels / content_view_core->GetDpiScale())); | 270 touch_slop_pixels / content_view_core->GetDpiScale())); |
| 271 } | 271 } |
| 272 | 272 |
| 273 scoped_ptr<OverscrollControllerAndroid> CreateOverscrollController( | 273 scoped_ptr<OverscrollControllerAndroid> CreateOverscrollController( |
| 274 ContentViewCore* content_view_core) { | 274 ContentViewCore* content_view_core) { |
| 275 DCHECK(content_view_core); | 275 DCHECK(content_view_core); |
| 276 ui::WindowAndroid* window = content_view_core->GetWindowAndroid(); | 276 ui::WindowAndroid* window = content_view_core->GetWindowAndroid(); |
| 277 DCHECK(window); | 277 DCHECK(window); |
| (...skipping 960 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1238 } | 1238 } |
| 1239 | 1239 |
| 1240 void RenderWidgetHostViewAndroid::SelectBetweenCoordinates( | 1240 void RenderWidgetHostViewAndroid::SelectBetweenCoordinates( |
| 1241 const gfx::PointF& base, | 1241 const gfx::PointF& base, |
| 1242 const gfx::PointF& extent) { | 1242 const gfx::PointF& extent) { |
| 1243 DCHECK(content_view_core_); | 1243 DCHECK(content_view_core_); |
| 1244 content_view_core_->SelectBetweenCoordinates(base, extent); | 1244 content_view_core_->SelectBetweenCoordinates(base, extent); |
| 1245 } | 1245 } |
| 1246 | 1246 |
| 1247 void RenderWidgetHostViewAndroid::OnSelectionEvent( | 1247 void RenderWidgetHostViewAndroid::OnSelectionEvent( |
| 1248 SelectionEventType event, | 1248 ui::SelectionEventType event, |
| 1249 const gfx::PointF& position) { | 1249 const gfx::PointF& position) { |
| 1250 DCHECK(content_view_core_); | 1250 DCHECK(content_view_core_); |
| 1251 // Showing the selection action bar can alter the current View coordinates in | 1251 // Showing the selection action bar can alter the current View coordinates in |
| 1252 // such a way that the current MotionEvent stream is suddenly shifted in | 1252 // such a way that the current MotionEvent stream is suddenly shifted in |
| 1253 // space. Avoid the associated scroll jump by pre-emptively cancelling gesture | 1253 // space. Avoid the associated scroll jump by pre-emptively cancelling gesture |
| 1254 // detection; scrolling after the selection is activated is unnecessary. | 1254 // detection; scrolling after the selection is activated is unnecessary. |
| 1255 if (event == SelectionEventType::SELECTION_SHOWN) | 1255 if (event == ui::SelectionEventType::SELECTION_SHOWN) |
| 1256 ResetGestureDetection(); | 1256 ResetGestureDetection(); |
| 1257 content_view_core_->OnSelectionEvent(event, position); | 1257 content_view_core_->OnSelectionEvent(event, position); |
| 1258 } | 1258 } |
| 1259 | 1259 |
| 1260 scoped_ptr<TouchHandleDrawable> RenderWidgetHostViewAndroid::CreateDrawable() { | 1260 scoped_ptr<ui::TouchHandleDrawable> |
| 1261 RenderWidgetHostViewAndroid::CreateDrawable() { |
| 1261 DCHECK(content_view_core_); | 1262 DCHECK(content_view_core_); |
| 1262 if (!using_browser_compositor_) | 1263 if (!using_browser_compositor_) |
| 1263 return content_view_core_->CreatePopupTouchHandleDrawable(); | 1264 return content_view_core_->CreatePopupTouchHandleDrawable(); |
| 1264 | 1265 |
| 1265 return scoped_ptr<TouchHandleDrawable>(new CompositedTouchHandleDrawable( | 1266 return scoped_ptr<ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( |
| 1266 content_view_core_->GetLayer().get(), | 1267 content_view_core_->GetLayer().get(), |
| 1267 content_view_core_->GetDpiScale(), | 1268 content_view_core_->GetDpiScale(), |
| 1268 // Use the activity context (instead of the application context) to ensure | 1269 // Use the activity context (instead of the application context) to ensure |
| 1269 // proper handle theming. | 1270 // proper handle theming. |
| 1270 content_view_core_->GetContext().obj())); | 1271 content_view_core_->GetContext().obj())); |
| 1271 } | 1272 } |
| 1272 | 1273 |
| 1273 void RenderWidgetHostViewAndroid::SynchronousCopyContents( | 1274 void RenderWidgetHostViewAndroid::SynchronousCopyContents( |
| 1274 const gfx::Rect& src_subrect_in_pixel, | 1275 const gfx::Rect& src_subrect_in_pixel, |
| 1275 const gfx::Size& dst_size_in_pixel, | 1276 const gfx::Size& dst_size_in_pixel, |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1309 !has_fixed_page_scale && !has_mobile_viewport); | 1310 !has_fixed_page_scale && !has_mobile_viewport); |
| 1310 | 1311 |
| 1311 if (!content_view_core_) | 1312 if (!content_view_core_) |
| 1312 return; | 1313 return; |
| 1313 | 1314 |
| 1314 if (overscroll_controller_) | 1315 if (overscroll_controller_) |
| 1315 overscroll_controller_->OnFrameMetadataUpdated(frame_metadata); | 1316 overscroll_controller_->OnFrameMetadataUpdated(frame_metadata); |
| 1316 | 1317 |
| 1317 if (selection_controller_) { | 1318 if (selection_controller_) { |
| 1318 selection_controller_->OnSelectionBoundsChanged( | 1319 selection_controller_->OnSelectionBoundsChanged( |
| 1319 frame_metadata.selection_start, frame_metadata.selection_end); | 1320 ui::SelectionBound(frame_metadata.selection_start), |
| 1321 ui::SelectionBound(frame_metadata.selection_end)); |
| 1320 } | 1322 } |
| 1321 | 1323 |
| 1322 // All offsets and sizes are in CSS pixels. | 1324 // All offsets and sizes are in CSS pixels. |
| 1323 content_view_core_->UpdateFrameInfo( | 1325 content_view_core_->UpdateFrameInfo( |
| 1324 frame_metadata.root_scroll_offset, | 1326 frame_metadata.root_scroll_offset, |
| 1325 frame_metadata.page_scale_factor, | 1327 frame_metadata.page_scale_factor, |
| 1326 gfx::Vector2dF(frame_metadata.min_page_scale_factor, | 1328 gfx::Vector2dF(frame_metadata.min_page_scale_factor, |
| 1327 frame_metadata.max_page_scale_factor), | 1329 frame_metadata.max_page_scale_factor), |
| 1328 frame_metadata.root_layer_size, | 1330 frame_metadata.root_layer_size, |
| 1329 frame_metadata.scrollable_viewport_size, | 1331 frame_metadata.scrollable_viewport_size, |
| (...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1620 | 1622 |
| 1621 void RenderWidgetHostViewAndroid::OnShowingPastePopup( | 1623 void RenderWidgetHostViewAndroid::OnShowingPastePopup( |
| 1622 const gfx::PointF& point) { | 1624 const gfx::PointF& point) { |
| 1623 if (!selection_controller_) | 1625 if (!selection_controller_) |
| 1624 return; | 1626 return; |
| 1625 | 1627 |
| 1626 // As the paste popup may be triggered *before* the bounds and editability | 1628 // As the paste popup may be triggered *before* the bounds and editability |
| 1627 // of the region have been updated, explicitly set the properties now. | 1629 // of the region have been updated, explicitly set the properties now. |
| 1628 // TODO(jdduke): Remove this workaround when auxiliary paste popup | 1630 // TODO(jdduke): Remove this workaround when auxiliary paste popup |
| 1629 // notifications are no longer required, crbug.com/398170. | 1631 // notifications are no longer required, crbug.com/398170. |
| 1630 cc::ViewportSelectionBound insertion_bound; | 1632 ui::SelectionBound insertion_bound; |
| 1631 insertion_bound.type = cc::SELECTION_BOUND_CENTER; | 1633 insertion_bound.set_type(ui::SelectionBound::CENTER); |
| 1632 insertion_bound.visible = true; | 1634 insertion_bound.set_visible(true); |
| 1633 insertion_bound.edge_top = point; | 1635 insertion_bound.SetEdge(point, point); |
| 1634 insertion_bound.edge_bottom = point; | |
| 1635 selection_controller_->HideAndDisallowShowingAutomatically(); | 1636 selection_controller_->HideAndDisallowShowingAutomatically(); |
| 1636 selection_controller_->OnSelectionEditable(true); | 1637 selection_controller_->OnSelectionEditable(true); |
| 1637 selection_controller_->OnSelectionEmpty(true); | 1638 selection_controller_->OnSelectionEmpty(true); |
| 1638 selection_controller_->OnSelectionBoundsChanged(insertion_bound, | 1639 selection_controller_->OnSelectionBoundsChanged(insertion_bound, |
| 1639 insertion_bound); | 1640 insertion_bound); |
| 1640 selection_controller_->AllowShowingFromCurrentSelection(); | 1641 selection_controller_->AllowShowingFromCurrentSelection(); |
| 1641 } | 1642 } |
| 1642 | 1643 |
| 1643 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { | 1644 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { |
| 1644 return cached_background_color_; | 1645 return cached_background_color_; |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1891 results->orientationAngle = display.RotationAsDegree(); | 1892 results->orientationAngle = display.RotationAsDegree(); |
| 1892 results->orientationType = | 1893 results->orientationType = |
| 1893 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 1894 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 1894 gfx::DeviceDisplayInfo info; | 1895 gfx::DeviceDisplayInfo info; |
| 1895 results->depth = info.GetBitsPerPixel(); | 1896 results->depth = info.GetBitsPerPixel(); |
| 1896 results->depthPerComponent = info.GetBitsPerComponent(); | 1897 results->depthPerComponent = info.GetBitsPerComponent(); |
| 1897 results->isMonochrome = (results->depthPerComponent == 0); | 1898 results->isMonochrome = (results->depthPerComponent == 0); |
| 1898 } | 1899 } |
| 1899 | 1900 |
| 1900 } // namespace content | 1901 } // namespace content |
| OLD | NEW |