| 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 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 333 ui::SelectionBound ConvertSelectionBound( | 333 ui::SelectionBound ConvertSelectionBound( |
| 334 const cc::ViewportSelectionBound& bound) { | 334 const cc::ViewportSelectionBound& bound) { |
| 335 ui::SelectionBound ui_bound; | 335 ui::SelectionBound ui_bound; |
| 336 ui_bound.set_type(ConvertSelectionBoundType(bound.type)); | 336 ui_bound.set_type(ConvertSelectionBoundType(bound.type)); |
| 337 ui_bound.set_visible(bound.visible); | 337 ui_bound.set_visible(bound.visible); |
| 338 if (ui_bound.type() != ui::SelectionBound::EMPTY) | 338 if (ui_bound.type() != ui::SelectionBound::EMPTY) |
| 339 ui_bound.SetEdge(bound.edge_top, bound.edge_bottom); | 339 ui_bound.SetEdge(bound.edge_top, bound.edge_bottom); |
| 340 return ui_bound; | 340 return ui_bound; |
| 341 } | 341 } |
| 342 | 342 |
| 343 gfx::RectF GetSelectionRect(const ui::TouchSelectionController& controller) { |
| 344 gfx::RectF rect = controller.GetRectBetweenBounds(); |
| 345 if (rect.IsEmpty()) |
| 346 return rect; |
| 347 |
| 348 rect.Union(controller.GetStartHandleRect()); |
| 349 rect.Union(controller.GetEndHandleRect()); |
| 350 return rect; |
| 351 } |
| 352 |
| 343 } // anonymous namespace | 353 } // anonymous namespace |
| 344 | 354 |
| 345 ReadbackRequest::ReadbackRequest(float scale, | 355 ReadbackRequest::ReadbackRequest(float scale, |
| 346 SkColorType color_type, | 356 SkColorType color_type, |
| 347 gfx::Rect src_subrect, | 357 gfx::Rect src_subrect, |
| 348 ReadbackRequestCallback& result_callback) | 358 ReadbackRequestCallback& result_callback) |
| 349 : scale_(scale), | 359 : scale_(scale), |
| 350 color_type_(color_type), | 360 color_type_(color_type), |
| 351 src_subrect_(src_subrect), | 361 src_subrect_(src_subrect), |
| 352 result_callback_(result_callback) { | 362 result_callback_(result_callback) { |
| (...skipping 982 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1335 } | 1345 } |
| 1336 | 1346 |
| 1337 void RenderWidgetHostViewAndroid::SelectBetweenCoordinates( | 1347 void RenderWidgetHostViewAndroid::SelectBetweenCoordinates( |
| 1338 const gfx::PointF& base, | 1348 const gfx::PointF& base, |
| 1339 const gfx::PointF& extent) { | 1349 const gfx::PointF& extent) { |
| 1340 DCHECK(content_view_core_); | 1350 DCHECK(content_view_core_); |
| 1341 content_view_core_->SelectBetweenCoordinates(base, extent); | 1351 content_view_core_->SelectBetweenCoordinates(base, extent); |
| 1342 } | 1352 } |
| 1343 | 1353 |
| 1344 void RenderWidgetHostViewAndroid::OnSelectionEvent( | 1354 void RenderWidgetHostViewAndroid::OnSelectionEvent( |
| 1345 ui::SelectionEventType event, | 1355 ui::SelectionEventType event) { |
| 1346 const gfx::PointF& position) { | |
| 1347 DCHECK(content_view_core_); | 1356 DCHECK(content_view_core_); |
| 1357 DCHECK(selection_controller_); |
| 1348 // Showing the selection action bar can alter the current View coordinates in | 1358 // Showing the selection action bar can alter the current View coordinates in |
| 1349 // such a way that the current MotionEvent stream is suddenly shifted in | 1359 // such a way that the current MotionEvent stream is suddenly shifted in |
| 1350 // space. Avoid the associated scroll jump by pre-emptively cancelling gesture | 1360 // space. Avoid the associated scroll jump by pre-emptively cancelling gesture |
| 1351 // detection; scrolling after the selection is activated is unnecessary. | 1361 // detection; scrolling after the selection is activated is unnecessary. |
| 1352 if (event == ui::SelectionEventType::SELECTION_SHOWN) | 1362 if (event == ui::SelectionEventType::SELECTION_SHOWN) |
| 1353 ResetGestureDetection(); | 1363 ResetGestureDetection(); |
| 1354 content_view_core_->OnSelectionEvent(event, position); | 1364 content_view_core_->OnSelectionEvent( |
| 1365 event, selection_controller_->GetStartPosition(), |
| 1366 GetSelectionRect(*selection_controller_)); |
| 1355 } | 1367 } |
| 1356 | 1368 |
| 1357 scoped_ptr<ui::TouchHandleDrawable> | 1369 scoped_ptr<ui::TouchHandleDrawable> |
| 1358 RenderWidgetHostViewAndroid::CreateDrawable() { | 1370 RenderWidgetHostViewAndroid::CreateDrawable() { |
| 1359 DCHECK(content_view_core_); | 1371 DCHECK(content_view_core_); |
| 1360 if (!using_browser_compositor_) | 1372 if (!using_browser_compositor_) |
| 1361 return content_view_core_->CreatePopupTouchHandleDrawable(); | 1373 return content_view_core_->CreatePopupTouchHandleDrawable(); |
| 1362 | 1374 |
| 1363 return scoped_ptr<ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( | 1375 return scoped_ptr<ui::TouchHandleDrawable>(new CompositedTouchHandleDrawable( |
| 1364 content_view_core_->GetLayer().get(), | 1376 content_view_core_->GetLayer().get(), |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2112 results->orientationAngle = display.RotationAsDegree(); | 2124 results->orientationAngle = display.RotationAsDegree(); |
| 2113 results->orientationType = | 2125 results->orientationType = |
| 2114 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); | 2126 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); |
| 2115 gfx::DeviceDisplayInfo info; | 2127 gfx::DeviceDisplayInfo info; |
| 2116 results->depth = info.GetBitsPerPixel(); | 2128 results->depth = info.GetBitsPerPixel(); |
| 2117 results->depthPerComponent = info.GetBitsPerComponent(); | 2129 results->depthPerComponent = info.GetBitsPerComponent(); |
| 2118 results->isMonochrome = (results->depthPerComponent == 0); | 2130 results->isMonochrome = (results->depthPerComponent == 0); |
| 2119 } | 2131 } |
| 2120 | 2132 |
| 2121 } // namespace content | 2133 } // namespace content |
| OLD | NEW |