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

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

Issue 494823002: Plumb selection edge points through the compositor (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Order tweak Created 6 years, 4 months 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"
11 #include "base/bind.h" 11 #include "base/bind.h"
12 #include "base/callback_helpers.h" 12 #include "base/callback_helpers.h"
13 #include "base/command_line.h" 13 #include "base/command_line.h"
14 #include "base/logging.h" 14 #include "base/logging.h"
15 #include "base/message_loop/message_loop.h" 15 #include "base/message_loop/message_loop.h"
16 #include "base/metrics/histogram.h" 16 #include "base/metrics/histogram.h"
17 #include "base/strings/utf_string_conversions.h" 17 #include "base/strings/utf_string_conversions.h"
18 #include "base/sys_info.h" 18 #include "base/sys_info.h"
19 #include "base/threading/worker_pool.h" 19 #include "base/threading/worker_pool.h"
20 #include "cc/base/latency_info_swap_promise.h" 20 #include "cc/base/latency_info_swap_promise.h"
21 #include "cc/layers/delegated_frame_provider.h" 21 #include "cc/layers/delegated_frame_provider.h"
22 #include "cc/layers/delegated_renderer_layer.h" 22 #include "cc/layers/delegated_renderer_layer.h"
23 #include "cc/layers/layer.h" 23 #include "cc/layers/layer.h"
24 #include "cc/output/compositor_frame.h" 24 #include "cc/output/compositor_frame.h"
25 #include "cc/output/compositor_frame_ack.h" 25 #include "cc/output/compositor_frame_ack.h"
26 #include "cc/output/copy_output_request.h" 26 #include "cc/output/copy_output_request.h"
27 #include "cc/output/copy_output_result.h" 27 #include "cc/output/copy_output_result.h"
28 #include "cc/output/viewport_selection_bound.h"
28 #include "cc/resources/single_release_callback.h" 29 #include "cc/resources/single_release_callback.h"
29 #include "cc/trees/layer_tree_host.h" 30 #include "cc/trees/layer_tree_host.h"
30 #include "content/browser/accessibility/browser_accessibility_manager_android.h" 31 #include "content/browser/accessibility/browser_accessibility_manager_android.h"
31 #include "content/browser/android/composited_touch_handle_drawable.h" 32 #include "content/browser/android/composited_touch_handle_drawable.h"
32 #include "content/browser/android/content_view_core_impl.h" 33 #include "content/browser/android/content_view_core_impl.h"
33 #include "content/browser/android/edge_effect.h" 34 #include "content/browser/android/edge_effect.h"
34 #include "content/browser/android/edge_effect_l.h" 35 #include "content/browser/android/edge_effect_l.h"
35 #include "content/browser/android/in_process/synchronous_compositor_impl.h" 36 #include "content/browser/android/in_process/synchronous_compositor_impl.h"
36 #include "content/browser/android/overscroll_glow.h" 37 #include "content/browser/android/overscroll_glow.h"
37 #include "content/browser/devtools/render_view_devtools_agent_host.h" 38 #include "content/browser/devtools/render_view_devtools_agent_host.h"
(...skipping 731 matching lines...) Expand 10 before | Expand all | Expand 10 after
769 std::string utf8_selection = base::UTF16ToUTF8(text.substr(pos, n)); 770 std::string utf8_selection = base::UTF16ToUTF8(text.substr(pos, n));
770 771
771 content_view_core_->OnSelectionChanged(utf8_selection); 772 content_view_core_->OnSelectionChanged(utf8_selection);
772 } 773 }
773 774
774 void RenderWidgetHostViewAndroid::SelectionBoundsChanged( 775 void RenderWidgetHostViewAndroid::SelectionBoundsChanged(
775 const ViewHostMsg_SelectionBounds_Params& params) { 776 const ViewHostMsg_SelectionBounds_Params& params) {
776 if (!selection_controller_) 777 if (!selection_controller_)
777 return; 778 return;
778 779
779 gfx::RectF anchor_rect(params.anchor_rect); 780 gfx::RectF start_rect(params.anchor_rect);
aelias_OOO_until_Jul13 2014/08/20 21:41:03 Can you go ahead and change ViewHostMsg_SelectionB
jdduke (slow) 2014/08/20 21:58:43 I could, except there's a good amount of dependent
780 gfx::RectF focus_rect(params.focus_rect); 781 gfx::RectF end_rect(params.focus_rect);
781 if (params.is_anchor_first) 782 if (params.is_anchor_first)
782 std::swap(anchor_rect, focus_rect); 783 std::swap(start_rect, end_rect);
783 784
784 TouchHandleOrientation anchor_orientation(TOUCH_HANDLE_ORIENTATION_UNDEFINED); 785 cc::ViewportSelectionBound start_bound, end_bound;
785 TouchHandleOrientation focus_orientation(TOUCH_HANDLE_ORIENTATION_UNDEFINED); 786 start_bound.visible = true;
787 end_bound.visible = true;
788 start_bound.edge_top = start_rect.origin();
789 start_bound.edge_bottom = start_rect.bottom_left();
aelias_OOO_until_Jul13 2014/08/20 21:41:03 If we have to stay with the rect for some reason,
jdduke (slow) 2014/08/20 21:58:44 This code will all be ripped out in https://codere
790 end_bound.edge_top = end_rect.origin();
791 end_bound.edge_bottom = end_rect.bottom_left();
792
786 if (params.anchor_rect == params.focus_rect) { 793 if (params.anchor_rect == params.focus_rect) {
787 if (params.anchor_rect.x() && params.anchor_rect.y()) 794 if (params.anchor_rect.x() && params.anchor_rect.y())
788 anchor_orientation = focus_orientation = TOUCH_HANDLE_CENTER; 795 start_bound.type = end_bound.type = cc::SELECTION_BOUND_CENTER;
789 } else { 796 } else {
790 anchor_orientation = params.anchor_dir == blink::WebTextDirectionRightToLeft 797 start_bound.type = params.anchor_dir == blink::WebTextDirectionRightToLeft
791 ? TOUCH_HANDLE_LEFT 798 ? cc::SELECTION_BOUND_LEFT
792 : TOUCH_HANDLE_RIGHT; 799 : cc::SELECTION_BOUND_RIGHT;
793 focus_orientation = params.focus_dir == blink::WebTextDirectionRightToLeft 800 end_bound.type = params.focus_dir == blink::WebTextDirectionRightToLeft
794 ? TOUCH_HANDLE_RIGHT 801 ? cc::SELECTION_BOUND_RIGHT
795 : TOUCH_HANDLE_LEFT; 802 : cc::SELECTION_BOUND_LEFT;
796 } 803 }
797 804
798 selection_controller_->OnSelectionBoundsChanged(anchor_rect, 805 selection_controller_->OnSelectionBoundsChanged(start_bound, end_bound);
799 anchor_orientation,
800 true,
801 focus_rect,
802 focus_orientation,
803 true);
804 } 806 }
805 807
806 void RenderWidgetHostViewAndroid::SetBackgroundOpaque(bool opaque) { 808 void RenderWidgetHostViewAndroid::SetBackgroundOpaque(bool opaque) {
807 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); 809 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque);
808 host_->SetBackgroundOpaque(opaque); 810 host_->SetBackgroundOpaque(opaque);
809 } 811 }
810 812
811 void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( 813 void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
812 const gfx::Rect& src_subrect, 814 const gfx::Rect& src_subrect,
813 const gfx::Size& dst_size, 815 const gfx::Size& dst_size,
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
1489 1491
1490 void RenderWidgetHostViewAndroid::OnShowingPastePopup( 1492 void RenderWidgetHostViewAndroid::OnShowingPastePopup(
1491 const gfx::PointF& point) { 1493 const gfx::PointF& point) {
1492 if (!selection_controller_) 1494 if (!selection_controller_)
1493 return; 1495 return;
1494 1496
1495 // As the paste popup may be triggered *before* the bounds and editability 1497 // As the paste popup may be triggered *before* the bounds and editability
1496 // of the region have been updated, explicitly set the properties now. 1498 // of the region have been updated, explicitly set the properties now.
1497 // TODO(jdduke): Remove this workaround when auxiliary paste popup 1499 // TODO(jdduke): Remove this workaround when auxiliary paste popup
1498 // notifications are no longer required, crbug.com/398170. 1500 // notifications are no longer required, crbug.com/398170.
1499 gfx::RectF rect(point, gfx::SizeF()); 1501 cc::ViewportSelectionBound insertion_bound;
1500 TouchHandleOrientation orientation = TOUCH_HANDLE_CENTER; 1502 insertion_bound.type = cc::SELECTION_BOUND_LEFT;
1501 const bool visible = true; 1503 insertion_bound.visible = true;
1504 insertion_bound.edge_top = point;
1505 insertion_bound.edge_bottom = point;
1502 HideTextHandles(); 1506 HideTextHandles();
1503 ShowSelectionHandlesAutomatically(); 1507 ShowSelectionHandlesAutomatically();
1504 selection_controller_->OnSelectionEditable(true); 1508 selection_controller_->OnSelectionEditable(true);
1505 selection_controller_->OnSelectionEmpty(true); 1509 selection_controller_->OnSelectionEmpty(true);
1506 selection_controller_->OnSelectionBoundsChanged( 1510 selection_controller_->OnSelectionBoundsChanged(insertion_bound,
1507 rect, orientation, visible, rect, orientation, visible); 1511 insertion_bound);
1508 } 1512 }
1509 1513
1510 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { 1514 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const {
1511 return cached_background_color_; 1515 return cached_background_color_;
1512 } 1516 }
1513 1517
1514 void RenderWidgetHostViewAndroid::DidOverscroll( 1518 void RenderWidgetHostViewAndroid::DidOverscroll(
1515 const DidOverscrollParams& params) { 1519 const DidOverscrollParams& params) {
1516 if (!content_view_core_ || !layer_ || !is_showing_) 1520 if (!content_view_core_ || !layer_ || !is_showing_)
1517 return; 1521 return;
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 results->orientationAngle = display.RotationAsDegree(); 1800 results->orientationAngle = display.RotationAsDegree();
1797 results->orientationType = 1801 results->orientationType =
1798 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 1802 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
1799 gfx::DeviceDisplayInfo info; 1803 gfx::DeviceDisplayInfo info;
1800 results->depth = info.GetBitsPerPixel(); 1804 results->depth = info.GetBitsPerPixel();
1801 results->depthPerComponent = info.GetBitsPerComponent(); 1805 results->depthPerComponent = info.GetBitsPerComponent();
1802 results->isMonochrome = (results->depthPerComponent == 0); 1806 results->isMonochrome = (results->depthPerComponent == 0);
1803 } 1807 }
1804 1808
1805 } // namespace content 1809 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/input/touch_selection_controller_unittest.cc ('k') | content/common/cc_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698