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

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: Rebase 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 725 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 std::string utf8_selection = base::UTF16ToUTF8(text.substr(pos, n)); 764 std::string utf8_selection = base::UTF16ToUTF8(text.substr(pos, n));
764 765
765 content_view_core_->OnSelectionChanged(utf8_selection); 766 content_view_core_->OnSelectionChanged(utf8_selection);
766 } 767 }
767 768
768 void RenderWidgetHostViewAndroid::SelectionBoundsChanged( 769 void RenderWidgetHostViewAndroid::SelectionBoundsChanged(
769 const ViewHostMsg_SelectionBounds_Params& params) { 770 const ViewHostMsg_SelectionBounds_Params& params) {
770 if (!selection_controller_) 771 if (!selection_controller_)
771 return; 772 return;
772 773
773 gfx::RectF anchor_rect(params.anchor_rect); 774 gfx::RectF start_rect(params.anchor_rect);
774 gfx::RectF focus_rect(params.focus_rect); 775 gfx::RectF end_rect(params.focus_rect);
775 if (params.is_anchor_first) 776 if (params.is_anchor_first)
776 std::swap(anchor_rect, focus_rect); 777 std::swap(start_rect, end_rect);
777 778
778 TouchHandleOrientation anchor_orientation(TOUCH_HANDLE_ORIENTATION_UNDEFINED); 779 cc::ViewportSelectionBound start_bound, end_bound;
779 TouchHandleOrientation focus_orientation(TOUCH_HANDLE_ORIENTATION_UNDEFINED); 780 start_bound.visible = true;
781 end_bound.visible = true;
782 start_bound.edge_top = start_rect.origin();
783 start_bound.edge_bottom = start_rect.bottom_left();
784 end_bound.edge_top = end_rect.origin();
785 end_bound.edge_bottom = end_rect.bottom_left();
786
780 if (params.anchor_rect == params.focus_rect) { 787 if (params.anchor_rect == params.focus_rect) {
781 if (params.anchor_rect.x() && params.anchor_rect.y()) 788 if (params.anchor_rect.x() && params.anchor_rect.y())
782 anchor_orientation = focus_orientation = TOUCH_HANDLE_CENTER; 789 start_bound.type = end_bound.type = cc::SELECTION_BOUND_CENTER;
783 } else { 790 } else {
784 anchor_orientation = params.anchor_dir == blink::WebTextDirectionRightToLeft 791 start_bound.type = params.anchor_dir == blink::WebTextDirectionRightToLeft
785 ? TOUCH_HANDLE_LEFT 792 ? cc::SELECTION_BOUND_LEFT
786 : TOUCH_HANDLE_RIGHT; 793 : cc::SELECTION_BOUND_RIGHT;
787 focus_orientation = params.focus_dir == blink::WebTextDirectionRightToLeft 794 end_bound.type = params.focus_dir == blink::WebTextDirectionRightToLeft
788 ? TOUCH_HANDLE_RIGHT 795 ? cc::SELECTION_BOUND_RIGHT
789 : TOUCH_HANDLE_LEFT; 796 : cc::SELECTION_BOUND_LEFT;
790 } 797 }
791 798
792 selection_controller_->OnSelectionBoundsChanged(anchor_rect, 799 selection_controller_->OnSelectionBoundsChanged(start_bound, end_bound);
793 anchor_orientation,
794 true,
795 focus_rect,
796 focus_orientation,
797 true);
798 } 800 }
799 801
800 void RenderWidgetHostViewAndroid::SetBackgroundOpaque(bool opaque) { 802 void RenderWidgetHostViewAndroid::SetBackgroundOpaque(bool opaque) {
801 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque); 803 RenderWidgetHostViewBase::SetBackgroundOpaque(opaque);
802 host_->SetBackgroundOpaque(opaque); 804 host_->SetBackgroundOpaque(opaque);
803 } 805 }
804 806
805 void RenderWidgetHostViewAndroid::CopyFromCompositingSurface( 807 void RenderWidgetHostViewAndroid::CopyFromCompositingSurface(
806 const gfx::Rect& src_subrect, 808 const gfx::Rect& src_subrect,
807 const gfx::Size& dst_size, 809 const gfx::Size& dst_size,
(...skipping 724 matching lines...) Expand 10 before | Expand all | Expand 10 after
1532 1534
1533 void RenderWidgetHostViewAndroid::OnShowingPastePopup( 1535 void RenderWidgetHostViewAndroid::OnShowingPastePopup(
1534 const gfx::PointF& point) { 1536 const gfx::PointF& point) {
1535 if (!selection_controller_) 1537 if (!selection_controller_)
1536 return; 1538 return;
1537 1539
1538 // As the paste popup may be triggered *before* the bounds and editability 1540 // As the paste popup may be triggered *before* the bounds and editability
1539 // of the region have been updated, explicitly set the properties now. 1541 // of the region have been updated, explicitly set the properties now.
1540 // TODO(jdduke): Remove this workaround when auxiliary paste popup 1542 // TODO(jdduke): Remove this workaround when auxiliary paste popup
1541 // notifications are no longer required, crbug.com/398170. 1543 // notifications are no longer required, crbug.com/398170.
1542 gfx::RectF rect(point, gfx::SizeF()); 1544 cc::ViewportSelectionBound insertion_bound;
1543 TouchHandleOrientation orientation = TOUCH_HANDLE_CENTER; 1545 insertion_bound.type = cc::SELECTION_BOUND_LEFT;
1544 const bool visible = true; 1546 insertion_bound.visible = true;
1547 insertion_bound.edge_top = point;
1548 insertion_bound.edge_bottom = point;
1545 HideTextHandles(); 1549 HideTextHandles();
1546 ShowSelectionHandlesAutomatically(); 1550 ShowSelectionHandlesAutomatically();
1547 selection_controller_->OnSelectionEditable(true); 1551 selection_controller_->OnSelectionEditable(true);
1548 selection_controller_->OnSelectionEmpty(true); 1552 selection_controller_->OnSelectionEmpty(true);
1549 selection_controller_->OnSelectionBoundsChanged( 1553 selection_controller_->OnSelectionBoundsChanged(insertion_bound,
1550 rect, orientation, visible, rect, orientation, visible); 1554 insertion_bound);
1551 } 1555 }
1552 1556
1553 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const { 1557 SkColor RenderWidgetHostViewAndroid::GetCachedBackgroundColor() const {
1554 return cached_background_color_; 1558 return cached_background_color_;
1555 } 1559 }
1556 1560
1557 void RenderWidgetHostViewAndroid::DidOverscroll( 1561 void RenderWidgetHostViewAndroid::DidOverscroll(
1558 const DidOverscrollParams& params) { 1562 const DidOverscrollParams& params) {
1559 if (!content_view_core_ || !layer_ || !is_showing_) 1563 if (!content_view_core_ || !layer_ || !is_showing_)
1560 return; 1564 return;
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1823 results->orientationAngle = display.RotationAsDegree(); 1827 results->orientationAngle = display.RotationAsDegree();
1824 results->orientationType = 1828 results->orientationType =
1825 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display); 1829 RenderWidgetHostViewBase::GetOrientationTypeForMobile(display);
1826 gfx::DeviceDisplayInfo info; 1830 gfx::DeviceDisplayInfo info;
1827 results->depth = info.GetBitsPerPixel(); 1831 results->depth = info.GetBitsPerPixel();
1828 results->depthPerComponent = info.GetBitsPerComponent(); 1832 results->depthPerComponent = info.GetBitsPerComponent();
1829 results->isMonochrome = (results->depthPerComponent == 0); 1833 results->isMonochrome = (results->depthPerComponent == 0);
1830 } 1834 }
1831 1835
1832 } // namespace content 1836 } // 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