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

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

Issue 698253004: Reland: Implement Aura side of unified touch text selection for contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased after SetVisible removal and Mikhail's directional handles patch Created 6 years, 1 month 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_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
(...skipping 16 matching lines...) Expand all
27 #include "content/browser/renderer_host/compositor_resize_lock_aura.h" 27 #include "content/browser/renderer_host/compositor_resize_lock_aura.h"
28 #include "content/browser/renderer_host/dip_util.h" 28 #include "content/browser/renderer_host/dip_util.h"
29 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" 29 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h"
30 #include "content/browser/renderer_host/overscroll_controller.h" 30 #include "content/browser/renderer_host/overscroll_controller.h"
31 #include "content/browser/renderer_host/render_view_host_delegate.h" 31 #include "content/browser/renderer_host/render_view_host_delegate.h"
32 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 32 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
33 #include "content/browser/renderer_host/render_view_host_impl.h" 33 #include "content/browser/renderer_host/render_view_host_impl.h"
34 #include "content/browser/renderer_host/render_widget_host_impl.h" 34 #include "content/browser/renderer_host/render_widget_host_impl.h"
35 #include "content/browser/renderer_host/ui_events_helper.h" 35 #include "content/browser/renderer_host/ui_events_helper.h"
36 #include "content/browser/renderer_host/web_input_event_aura.h" 36 #include "content/browser/renderer_host/web_input_event_aura.h"
37 #include "content/browser/web_contents/web_contents_impl.h"
37 #include "content/common/gpu/client/gl_helper.h" 38 #include "content/common/gpu/client/gl_helper.h"
38 #include "content/common/gpu/gpu_messages.h" 39 #include "content/common/gpu/gpu_messages.h"
39 #include "content/common/view_messages.h" 40 #include "content/common/view_messages.h"
40 #include "content/public/browser/content_browser_client.h" 41 #include "content/public/browser/content_browser_client.h"
41 #include "content/public/browser/overscroll_configuration.h" 42 #include "content/public/browser/overscroll_configuration.h"
42 #include "content/public/browser/render_view_host.h" 43 #include "content/public/browser/render_view_host.h"
43 #include "content/public/browser/render_widget_host_view_frame_subscriber.h" 44 #include "content/public/browser/render_widget_host_view_frame_subscriber.h"
44 #include "content/public/browser/user_metrics.h" 45 #include "content/public/browser/user_metrics.h"
46 #include "content/public/browser/web_contents.h"
45 #include "content/public/common/content_switches.h" 47 #include "content/public/common/content_switches.h"
46 #include "third_party/WebKit/public/platform/WebScreenInfo.h" 48 #include "third_party/WebKit/public/platform/WebScreenInfo.h"
47 #include "third_party/WebKit/public/web/WebCompositionUnderline.h" 49 #include "third_party/WebKit/public/web/WebCompositionUnderline.h"
48 #include "third_party/WebKit/public/web/WebInputEvent.h" 50 #include "third_party/WebKit/public/web/WebInputEvent.h"
49 #include "ui/aura/client/aura_constants.h" 51 #include "ui/aura/client/aura_constants.h"
50 #include "ui/aura/client/cursor_client.h" 52 #include "ui/aura/client/cursor_client.h"
51 #include "ui/aura/client/cursor_client_observer.h" 53 #include "ui/aura/client/cursor_client_observer.h"
52 #include "ui/aura/client/focus_client.h" 54 #include "ui/aura/client/focus_client.h"
53 #include "ui/aura/client/screen_position_client.h" 55 #include "ui/aura/client/screen_position_client.h"
54 #include "ui/aura/client/window_tree_client.h" 56 #include "ui/aura/client/window_tree_client.h"
(...skipping 11 matching lines...) Expand all
66 #include "ui/compositor/dip_util.h" 68 #include "ui/compositor/dip_util.h"
67 #include "ui/events/event.h" 69 #include "ui/events/event.h"
68 #include "ui/events/event_utils.h" 70 #include "ui/events/event_utils.h"
69 #include "ui/events/gestures/gesture_recognizer.h" 71 #include "ui/events/gestures/gesture_recognizer.h"
70 #include "ui/gfx/canvas.h" 72 #include "ui/gfx/canvas.h"
71 #include "ui/gfx/display.h" 73 #include "ui/gfx/display.h"
72 #include "ui/gfx/rect_conversions.h" 74 #include "ui/gfx/rect_conversions.h"
73 #include "ui/gfx/screen.h" 75 #include "ui/gfx/screen.h"
74 #include "ui/gfx/size_conversions.h" 76 #include "ui/gfx/size_conversions.h"
75 #include "ui/gfx/skia_util.h" 77 #include "ui/gfx/skia_util.h"
78 #include "ui/strings/grit/ui_strings.h"
76 #include "ui/wm/public/activation_client.h" 79 #include "ui/wm/public/activation_client.h"
77 #include "ui/wm/public/scoped_tooltip_disabler.h" 80 #include "ui/wm/public/scoped_tooltip_disabler.h"
78 #include "ui/wm/public/tooltip_client.h" 81 #include "ui/wm/public/tooltip_client.h"
79 #include "ui/wm/public/transient_window_client.h" 82 #include "ui/wm/public/transient_window_client.h"
80 #include "ui/wm/public/window_types.h" 83 #include "ui/wm/public/window_types.h"
81 84
82 #if defined(OS_WIN) 85 #if defined(OS_WIN)
83 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 86 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
84 #include "content/browser/accessibility/browser_accessibility_win.h" 87 #include "content/browser/accessibility/browser_accessibility_win.h"
85 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" 88 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
(...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 has_composition_text_(false), 446 has_composition_text_(false),
444 accept_return_character_(false), 447 accept_return_character_(false),
445 last_swapped_software_frame_scale_factor_(1.f), 448 last_swapped_software_frame_scale_factor_(1.f),
446 paint_canvas_(NULL), 449 paint_canvas_(NULL),
447 synthetic_move_sent_(false), 450 synthetic_move_sent_(false),
448 cursor_visibility_state_in_renderer_(UNKNOWN), 451 cursor_visibility_state_in_renderer_(UNKNOWN),
449 #if defined(OS_WIN) 452 #if defined(OS_WIN)
450 legacy_render_widget_host_HWND_(NULL), 453 legacy_render_widget_host_HWND_(NULL),
451 #endif 454 #endif
452 has_snapped_to_boundary_(false), 455 has_snapped_to_boundary_(false),
453 touch_editing_client_(NULL), 456 selection_controller_(new TouchSelectionControllerAura(this)),
454 is_guest_view_hack_(is_guest_view_hack), 457 is_guest_view_hack_(is_guest_view_hack),
455 weak_ptr_factory_(this) { 458 weak_ptr_factory_(this) {
456 if (!is_guest_view_hack_) 459 if (!is_guest_view_hack_)
457 host_->SetView(this); 460 host_->SetView(this);
458 461
459 window_observer_.reset(new WindowObserver(this)); 462 window_observer_.reset(new WindowObserver(this));
460 aura::client::SetTooltipText(window_, &tooltip_); 463 aura::client::SetTooltipText(window_, &tooltip_);
461 aura::client::SetActivationDelegate(window_, this); 464 aura::client::SetActivationDelegate(window_, this);
462 aura::client::SetActivationChangeObserver(window_, this); 465 aura::client::SetActivationChangeObserver(window_, this);
463 aura::client::SetFocusChangeObserver(window_, this); 466 aura::client::SetFocusChangeObserver(window_, this);
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
763 // Make sure we have a FocusClient before attempting to Focus(). In some 766 // Make sure we have a FocusClient before attempting to Focus(). In some
764 // situations we may not yet be in a valid Window hierarchy (such as reloading 767 // situations we may not yet be in a valid Window hierarchy (such as reloading
765 // after out of memory discarded the tab). 768 // after out of memory discarded the tab).
766 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); 769 aura::client::FocusClient* client = aura::client::GetFocusClient(window_);
767 if (client) 770 if (client)
768 window_->Focus(); 771 window_->Focus();
769 } 772 }
770 773
771 void RenderWidgetHostViewAura::Blur() { 774 void RenderWidgetHostViewAura::Blur() {
772 window_->Blur(); 775 window_->Blur();
776 selection_controller_->HideAndDisallowShowingAutomatically();
773 } 777 }
774 778
775 bool RenderWidgetHostViewAura::HasFocus() const { 779 bool RenderWidgetHostViewAura::HasFocus() const {
776 return window_->HasFocus(); 780 return window_->HasFocus();
777 } 781 }
778 782
779 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { 783 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const {
780 return delegated_frame_host_->CanCopyToBitmap(); 784 return delegated_frame_host_->CanCopyToBitmap();
781 } 785 }
782 786
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
840 if (text_input_type_ != type || 844 if (text_input_type_ != type ||
841 text_input_mode_ != input_mode || 845 text_input_mode_ != input_mode ||
842 can_compose_inline_ != can_compose_inline || 846 can_compose_inline_ != can_compose_inline ||
843 text_input_flags_ != flags) { 847 text_input_flags_ != flags) {
844 text_input_type_ = type; 848 text_input_type_ = type;
845 text_input_mode_ = input_mode; 849 text_input_mode_ = input_mode;
846 can_compose_inline_ = can_compose_inline; 850 can_compose_inline_ = can_compose_inline;
847 text_input_flags_ = flags; 851 text_input_flags_ = flags;
848 if (GetInputMethod()) 852 if (GetInputMethod())
849 GetInputMethod()->OnTextInputTypeChanged(this); 853 GetInputMethod()->OnTextInputTypeChanged(this);
850 if (touch_editing_client_) 854 const bool is_editable_node = type != ui::TEXT_INPUT_TYPE_NONE;
851 touch_editing_client_->OnTextInputTypeChanged(text_input_type_); 855 selection_controller_->OnSelectionEditable(is_editable_node);
852 } 856 }
853 } 857 }
854 858
855 void RenderWidgetHostViewAura::OnTextInputStateChanged( 859 void RenderWidgetHostViewAura::OnTextInputStateChanged(
856 const ViewHostMsg_TextInputState_Params& params) { 860 const ViewHostMsg_TextInputState_Params& params) {
857 text_input_flags_ = params.flags; 861 text_input_flags_ = params.flags;
858 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { 862 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) {
859 if (GetInputMethod()) 863 if (GetInputMethod())
860 GetInputMethod()->ShowImeIfNeeded(); 864 GetInputMethod()->ShowImeIfNeeded();
861 } 865 }
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 // Content tooltips should be visible indefinitely. 902 // Content tooltips should be visible indefinitely.
899 tooltip_client->SetTooltipShownTimeout(window_, 0); 903 tooltip_client->SetTooltipShownTimeout(window_, 0);
900 } 904 }
901 } 905 }
902 906
903 void RenderWidgetHostViewAura::SelectionChanged(const base::string16& text, 907 void RenderWidgetHostViewAura::SelectionChanged(const base::string16& text,
904 size_t offset, 908 size_t offset,
905 const gfx::Range& range) { 909 const gfx::Range& range) {
906 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); 910 RenderWidgetHostViewBase::SelectionChanged(text, offset, range);
907 911
912 selection_controller_->OnSelectionEmpty(text.empty());
913
908 #if defined(USE_X11) && !defined(OS_CHROMEOS) 914 #if defined(USE_X11) && !defined(OS_CHROMEOS)
909 if (text.empty() || range.is_empty()) 915 if (text.empty() || range.is_empty())
910 return; 916 return;
911 size_t pos = range.GetMin() - offset; 917 size_t pos = range.GetMin() - offset;
912 size_t n = range.length(); 918 size_t n = range.length();
913 919
914 DCHECK(pos + n <= text.length()) << "The text can not fully cover range."; 920 DCHECK(pos + n <= text.length()) << "The text can not fully cover range.";
915 if (pos >= text.length()) { 921 if (pos >= text.length()) {
916 NOTREACHED() << "The text can not cover range."; 922 NOTREACHED() << "The text can not cover range.";
917 return; 923 return;
918 } 924 }
919 925
920 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. 926 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard.
921 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); 927 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION);
922 clipboard_writer.WriteText(text.substr(pos, n)); 928 clipboard_writer.WriteText(text.substr(pos, n));
923 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) 929 #endif // defined(USE_X11) && !defined(OS_CHROMEOS)
924 } 930 }
925 931
926 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { 932 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const {
927 return delegated_frame_host_->GetRequestedRendererSize(); 933 return delegated_frame_host_->GetRequestedRendererSize();
928 } 934 }
929 935
930 void RenderWidgetHostViewAura::SelectionBoundsChanged( 936 void RenderWidgetHostViewAura::SelectionBoundsChanged(
931 const ViewHostMsg_SelectionBounds_Params& params) { 937 const ViewHostMsg_SelectionBounds_Params& params) {
932 ui::SelectionBound anchor_bound, focus_bound; 938 NOTREACHED() << "Selection bounds should be routed through the compositor.";
933 anchor_bound.edge_top = params.anchor_rect.origin();
934 anchor_bound.edge_bottom = params.anchor_rect.bottom_left();
935 focus_bound.edge_top = params.focus_rect.origin();
936 focus_bound.edge_bottom = params.focus_rect.bottom_left();
937
938 if (params.anchor_rect == params.focus_rect) {
939 anchor_bound.type = focus_bound.type = ui::SelectionBound::CENTER;
940 } else {
941 // Whether text is LTR at the anchor handle.
942 bool anchor_LTR = params.anchor_dir == blink::WebTextDirectionLeftToRight;
943 // Whether text is LTR at the focus handle.
944 bool focus_LTR = params.focus_dir == blink::WebTextDirectionLeftToRight;
945
946 if ((params.is_anchor_first && anchor_LTR) ||
947 (!params.is_anchor_first && !anchor_LTR)) {
948 anchor_bound.type = ui::SelectionBound::LEFT;
949 } else {
950 anchor_bound.type = ui::SelectionBound::RIGHT;
951 }
952 if ((params.is_anchor_first && focus_LTR) ||
953 (!params.is_anchor_first && !focus_LTR)) {
954 focus_bound.type = ui::SelectionBound::RIGHT;
955 } else {
956 focus_bound.type = ui::SelectionBound::LEFT;
957 }
958 }
959
960 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_)
961 return;
962
963 selection_anchor_ = anchor_bound;
964 selection_focus_ = focus_bound;
965 if (GetInputMethod())
966 GetInputMethod()->OnCaretBoundsChanged(this);
967
968 if (touch_editing_client_) {
969 touch_editing_client_->OnSelectionOrCursorChanged(
970 anchor_bound, focus_bound);
971 }
972 } 939 }
973 940
974 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 941 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
975 const gfx::Rect& src_subrect, 942 const gfx::Rect& src_subrect,
976 const gfx::Size& dst_size, 943 const gfx::Size& dst_size,
977 ReadbackRequestCallback& callback, 944 ReadbackRequestCallback& callback,
978 const SkColorType color_type) { 945 const SkColorType color_type) {
979 delegated_frame_host_->CopyFromCompositingSurface( 946 delegated_frame_host_->CopyFromCompositingSurface(
980 src_subrect, dst_size, callback, color_type); 947 src_subrect, dst_size, callback, color_type);
981 } 948 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1045 scoped_ptr<cc::CompositorFrame> frame) { 1012 scoped_ptr<cc::CompositorFrame> frame) {
1046 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); 1013 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame");
1047 1014
1048 last_scroll_offset_ = frame->metadata.root_scroll_offset; 1015 last_scroll_offset_ = frame->metadata.root_scroll_offset;
1049 if (frame->delegated_frame_data) { 1016 if (frame->delegated_frame_data) {
1050 delegated_frame_host_->SwapDelegatedFrame( 1017 delegated_frame_host_->SwapDelegatedFrame(
1051 output_surface_id, 1018 output_surface_id,
1052 frame->delegated_frame_data.Pass(), 1019 frame->delegated_frame_data.Pass(),
1053 frame->metadata.device_scale_factor, 1020 frame->metadata.device_scale_factor,
1054 frame->metadata.latency_info); 1021 frame->metadata.latency_info);
1022 SelectionBoundsUpdated(frame->metadata.selection_start,
1023 frame->metadata.selection_end);
1055 return; 1024 return;
1056 } 1025 }
1057 1026
1058 if (frame->software_frame_data) { 1027 if (frame->software_frame_data) {
1059 DLOG(ERROR) << "Unable to use software frame in aura"; 1028 DLOG(ERROR) << "Unable to use software frame in aura";
1060 RecordAction( 1029 RecordAction(
1061 base::UserMetricsAction("BadMessageTerminate_SharedMemoryAura")); 1030 base::UserMetricsAction("BadMessageTerminate_SharedMemoryAura"));
1062 host_->GetProcess()->ReceivedBadMessage(); 1031 host_->GetProcess()->ReceivedBadMessage();
1063 return; 1032 return;
1064 } 1033 }
1065 } 1034 }
1066 1035
1067 void RenderWidgetHostViewAura::DidStopFlinging() { 1036 void RenderWidgetHostViewAura::DidStopFlinging() {
1068 if (touch_editing_client_) 1037 selection_controller_->OnFlingCompleted();
1069 touch_editing_client_->DidStopFlinging();
1070 } 1038 }
1071 1039
1072 #if defined(OS_WIN) 1040 #if defined(OS_WIN)
1073 void RenderWidgetHostViewAura::SetLegacyRenderWidgetHostHWND( 1041 void RenderWidgetHostViewAura::SetLegacyRenderWidgetHostHWND(
1074 LegacyRenderWidgetHostHWND* legacy_hwnd) { 1042 LegacyRenderWidgetHostHWND* legacy_hwnd) {
1075 legacy_render_widget_host_HWND_ = legacy_hwnd; 1043 legacy_render_widget_host_HWND_ = legacy_hwnd;
1076 } 1044 }
1077 1045
1078 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( 1046 void RenderWidgetHostViewAura::SetParentNativeViewAccessible(
1079 gfx::NativeViewAccessible accessible_parent) { 1047 gfx::NativeViewAccessible accessible_parent) {
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 InputEventAckState ack_result) { 1113 InputEventAckState ack_result) {
1146 if (overscroll_controller_) { 1114 if (overscroll_controller_) {
1147 overscroll_controller_->ReceivedEventACK( 1115 overscroll_controller_->ReceivedEventACK(
1148 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); 1116 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result));
1149 } 1117 }
1150 } 1118 }
1151 1119
1152 void RenderWidgetHostViewAura::GestureEventAck( 1120 void RenderWidgetHostViewAura::GestureEventAck(
1153 const blink::WebGestureEvent& event, 1121 const blink::WebGestureEvent& event,
1154 InputEventAckState ack_result) { 1122 InputEventAckState ack_result) {
1155 if (touch_editing_client_)
1156 touch_editing_client_->GestureEventAck(event.type);
1157
1158 if (overscroll_controller_) { 1123 if (overscroll_controller_) {
1159 overscroll_controller_->ReceivedEventACK( 1124 overscroll_controller_->ReceivedEventACK(
1160 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); 1125 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result));
1161 } 1126 }
1162 } 1127 }
1163 1128
1164 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( 1129 void RenderWidgetHostViewAura::ProcessAckedTouchEvent(
1165 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) { 1130 const TouchEventWithLatencyInfo& touch, InputEventAckState ack_result) {
1166 ScopedVector<ui::TouchEvent> events; 1131 ScopedVector<ui::TouchEvent> events;
1167 if (!MakeUITouchEventsFromWebTouchEvents(touch, &events, 1132 if (!MakeUITouchEventsFromWebTouchEvents(touch, &events,
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after
1524 return gfx::Rect(origin.x(), 1489 return gfx::Rect(origin.x(),
1525 origin.y(), 1490 origin.y(),
1526 end.x() - origin.x(), 1491 end.x() - origin.x(),
1527 end.y() - origin.y()); 1492 end.y() - origin.y());
1528 } 1493 }
1529 1494
1530 return rect; 1495 return rect;
1531 } 1496 }
1532 1497
1533 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1498 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1534 gfx::Rect rect = 1499 return ConvertRectToScreen(selection_controller_->GetCaretBounds());
1535 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_);
1536 return ConvertRectToScreen(rect);
1537 } 1500 }
1538 1501
1539 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( 1502 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(
1540 uint32 index, 1503 uint32 index,
1541 gfx::Rect* rect) const { 1504 gfx::Rect* rect) const {
1542 DCHECK(rect); 1505 DCHECK(rect);
1543 if (index >= composition_character_bounds_.size()) 1506 if (index >= composition_character_bounds_.size())
1544 return false; 1507 return false;
1545 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 1508 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
1546 return true; 1509 return true;
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1725 const gfx::Point& location) { 1688 const gfx::Point& location) {
1726 return true; 1689 return true;
1727 } 1690 }
1728 1691
1729 bool RenderWidgetHostViewAura::CanFocus() { 1692 bool RenderWidgetHostViewAura::CanFocus() {
1730 return popup_type_ == blink::WebPopupTypeNone; 1693 return popup_type_ == blink::WebPopupTypeNone;
1731 } 1694 }
1732 1695
1733 void RenderWidgetHostViewAura::OnCaptureLost() { 1696 void RenderWidgetHostViewAura::OnCaptureLost() {
1734 host_->LostCapture(); 1697 host_->LostCapture();
1735 if (touch_editing_client_) 1698 selection_controller_->HideAndDisallowShowingAutomatically();
1736 touch_editing_client_->EndTouchEditing(false);
1737 } 1699 }
1738 1700
1739 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { 1701 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) {
1740 NOTREACHED(); 1702 NOTREACHED();
1741 } 1703 }
1742 1704
1743 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( 1705 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged(
1744 float device_scale_factor) { 1706 float device_scale_factor) {
1745 if (!host_ || !window_->GetRootWindow()) 1707 if (!host_ || !window_->GetRootWindow())
1746 return; 1708 return;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
1796 } 1758 }
1797 1759
1798 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { 1760 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const {
1799 } 1761 }
1800 1762
1801 //////////////////////////////////////////////////////////////////////////////// 1763 ////////////////////////////////////////////////////////////////////////////////
1802 // RenderWidgetHostViewAura, ui::EventHandler implementation: 1764 // RenderWidgetHostViewAura, ui::EventHandler implementation:
1803 1765
1804 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { 1766 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
1805 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); 1767 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent");
1806 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
1807 return;
1808 1768
1809 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { 1769 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
1810 popup_child_host_view_->OnKeyEvent(event); 1770 popup_child_host_view_->OnKeyEvent(event);
1811 if (event->handled()) 1771 if (event->handled())
1812 return; 1772 return;
1813 } 1773 }
1814 1774
1815 // We need to handle the Escape key for Pepper Flash. 1775 // We need to handle the Escape key for Pepper Flash.
1816 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { 1776 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) {
1817 // Focus the window we were created from. 1777 // Focus the window we were created from.
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
1854 NativeWebKeyboardEvent webkit_event(event); 1814 NativeWebKeyboardEvent webkit_event(event);
1855 ForwardKeyboardEvent(webkit_event); 1815 ForwardKeyboardEvent(webkit_event);
1856 } 1816 }
1857 } 1817 }
1858 event->SetHandled(); 1818 event->SetHandled();
1859 } 1819 }
1860 1820
1861 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { 1821 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) {
1862 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent"); 1822 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent");
1863 1823
1864 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
1865 return;
1866
1867 if (mouse_locked_) { 1824 if (mouse_locked_) {
1868 aura::client::CursorClient* cursor_client = 1825 aura::client::CursorClient* cursor_client =
1869 aura::client::GetCursorClient(window_->GetRootWindow()); 1826 aura::client::GetCursorClient(window_->GetRootWindow());
1870 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); 1827 DCHECK(!cursor_client || !cursor_client->IsCursorVisible());
1871 1828
1872 if (event->type() == ui::ET_MOUSEWHEEL) { 1829 if (event->type() == ui::ET_MOUSEWHEEL) {
1873 blink::WebMouseWheelEvent mouse_wheel_event = 1830 blink::WebMouseWheelEvent mouse_wheel_event =
1874 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); 1831 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event));
1875 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) 1832 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0)
1876 host_->ForwardWheelEvent(mouse_wheel_event); 1833 host_->ForwardWheelEvent(mouse_wheel_event);
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1995 event->ConvertLocationToTarget(window_, window_->parent()); 1952 event->ConvertLocationToTarget(window_, window_->parent());
1996 window_->parent()->delegate()->OnMouseEvent(event); 1953 window_->parent()->delegate()->OnMouseEvent(event);
1997 } 1954 }
1998 1955
1999 if (!IsXButtonUpEvent(event)) 1956 if (!IsXButtonUpEvent(event))
2000 event->SetHandled(); 1957 event->SetHandled();
2001 } 1958 }
2002 1959
2003 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { 1960 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
2004 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); 1961 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent");
2005 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
2006 return;
2007 1962
2008 if (event->type() == ui::ET_SCROLL) { 1963 if (event->type() == ui::ET_SCROLL) {
2009 #if !defined(OS_WIN) 1964 #if !defined(OS_WIN)
2010 // TODO(ananta) 1965 // TODO(ananta)
2011 // Investigate if this is true for Windows 8 Metro ASH as well. 1966 // Investigate if this is true for Windows 8 Metro ASH as well.
2012 if (event->finger_count() != 2) 1967 if (event->finger_count() != 2)
2013 return; 1968 return;
2014 #endif 1969 #endif
2015 blink::WebGestureEvent gesture_event = 1970 blink::WebGestureEvent gesture_event =
2016 MakeWebGestureEventFlingCancel(); 1971 MakeWebGestureEventFlingCancel();
2017 host_->ForwardGestureEvent(gesture_event); 1972 host_->ForwardGestureEvent(gesture_event);
2018 blink::WebMouseWheelEvent mouse_wheel_event = 1973 blink::WebMouseWheelEvent mouse_wheel_event =
2019 MakeWebMouseWheelEvent(event); 1974 MakeWebMouseWheelEvent(event);
2020 host_->ForwardWheelEvent(mouse_wheel_event); 1975 host_->ForwardWheelEvent(mouse_wheel_event);
2021 RecordAction(base::UserMetricsAction("TrackpadScroll")); 1976 RecordAction(base::UserMetricsAction("TrackpadScroll"));
2022 } else if (event->type() == ui::ET_SCROLL_FLING_START || 1977 } else if (event->type() == ui::ET_SCROLL_FLING_START ||
2023 event->type() == ui::ET_SCROLL_FLING_CANCEL) { 1978 event->type() == ui::ET_SCROLL_FLING_CANCEL) {
2024 blink::WebGestureEvent gesture_event = 1979 blink::WebGestureEvent gesture_event =
2025 MakeWebGestureEvent(event); 1980 MakeWebGestureEvent(event);
2026 host_->ForwardGestureEvent(gesture_event); 1981 host_->ForwardGestureEvent(gesture_event);
2027 if (event->type() == ui::ET_SCROLL_FLING_START) 1982 if (event->type() == ui::ET_SCROLL_FLING_START)
2028 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); 1983 RecordAction(base::UserMetricsAction("TrackpadScrollFling"));
2029 } 1984 }
2030 1985
2031 event->SetHandled(); 1986 event->SetHandled();
2032 } 1987 }
2033 1988
2034 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { 1989 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
2035 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); 1990 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent");
2036 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) 1991
1992 selection_controller_->HandleTouchEvent(event);
1993 if (event->handled())
2037 return; 1994 return;
2038 1995
2039 // Update the touch event first. 1996 // Update the touch event first.
2040 blink::WebTouchPoint* point = UpdateWebTouchEventFromUIEvent(*event, 1997 blink::WebTouchPoint* point = UpdateWebTouchEventFromUIEvent(*event,
2041 &touch_event_); 1998 &touch_event_);
2042 1999
2043 // Forward the touch event only if a touch point was updated, and there's a 2000 // Forward the touch event only if a touch point was updated, and there's a
2044 // touch-event handler in the page, and no other touch-event is in the queue. 2001 // touch-event handler in the page, and no other touch-event is in the queue.
2045 // It is important to always consume the event if there is a touch-event 2002 // It is important to always consume the event if there is a touch-event
2046 // handler in the page, or some touch-event is already in the queue, even if 2003 // handler in the page, or some touch-event is already in the queue, even if
2047 // no point has been updated, to make sure that this event does not get 2004 // no point has been updated, to make sure that this event does not get
2048 // processed by the gesture recognizer before the events in the queue. 2005 // processed by the gesture recognizer before the events in the queue.
2049 if (host_->ShouldForwardTouchEvent()) 2006 if (host_->ShouldForwardTouchEvent())
2050 event->StopPropagation(); 2007 event->StopPropagation();
2051 2008
2052 if (point) { 2009 if (point) {
2053 if (host_->ShouldForwardTouchEvent()) 2010 if (host_->ShouldForwardTouchEvent())
2054 host_->ForwardTouchEventWithLatencyInfo(touch_event_, *event->latency()); 2011 host_->ForwardTouchEventWithLatencyInfo(touch_event_, *event->latency());
2055 UpdateWebTouchEventAfterDispatch(&touch_event_, point); 2012 UpdateWebTouchEventAfterDispatch(&touch_event_, point);
2056 } 2013 }
2057 } 2014 }
2058 2015
2059 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { 2016 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
2060 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); 2017 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent");
2018
2019 selection_controller_->HandleGestureEvent(event);
2020 if (event->handled())
2021 return;
2022
2061 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 2023 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
2062 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 2024 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
2063 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { 2025 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) {
2064 event->SetHandled(); 2026 event->SetHandled();
2065 return; 2027 return;
2066 } 2028 }
2067 2029
2068 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
2069 return;
2070
2071 // Confirm existing composition text on TAP gesture, to make sure the input 2030 // Confirm existing composition text on TAP gesture, to make sure the input
2072 // caret won't be moved with an ongoing composition text. 2031 // caret won't be moved with an ongoing composition text.
2073 if (event->type() == ui::ET_GESTURE_TAP) 2032 if (event->type() == ui::ET_GESTURE_TAP)
2074 FinishImeCompositionSession(); 2033 FinishImeCompositionSession();
2075 2034
2076 RenderViewHostDelegate* delegate = NULL; 2035 RenderViewHostDelegate* delegate = NULL;
2077 if (host_->IsRenderView()) 2036 if (host_->IsRenderView())
2078 delegate = RenderViewHost::From(host_)->GetDelegate(); 2037 delegate = RenderViewHost::From(host_)->GetDelegate();
2079 2038
2080 if (delegate && event->type() == ui::ET_GESTURE_BEGIN && 2039 if (delegate && event->type() == ui::ET_GESTURE_BEGIN &&
(...skipping 27 matching lines...) Expand all
2108 event->details().touch_points() == 1) { 2067 event->details().touch_points() == 1) {
2109 delegate->HandleGestureEnd(); 2068 delegate->HandleGestureEnd();
2110 } 2069 }
2111 2070
2112 // If a gesture is not processed by the webpage, then WebKit processes it 2071 // If a gesture is not processed by the webpage, then WebKit processes it
2113 // (e.g. generates synthetic mouse events). 2072 // (e.g. generates synthetic mouse events).
2114 event->SetHandled(); 2073 event->SetHandled();
2115 } 2074 }
2116 2075
2117 //////////////////////////////////////////////////////////////////////////////// 2076 ////////////////////////////////////////////////////////////////////////////////
2077 // RenderWidgetHostViewAura, TouchSelectionControllerClientAura implementation:
2078
2079 float RenderWidgetHostViewAura::GetDeviceScaleFactor() {
2080 return current_device_scale_factor_;
2081 }
2082
2083 void RenderWidgetHostViewAura::MoveCaret(const gfx::PointF& position) {
2084 host_->MoveCaret(gfx::Point(position.x(), position.y()));
2085 }
2086
2087 void RenderWidgetHostViewAura::MoveRangeSelectionExtent(
2088 const gfx::PointF& extent) {
2089 RenderViewHost* rvh = RenderViewHost::From(host_);
2090 WebContentsImpl* wc =
2091 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost(rvh));
2092 wc->MoveRangeSelectionExtent(gfx::Point(extent.x(), extent.y()));
2093 }
2094
2095 void RenderWidgetHostViewAura::SelectBetweenCoordinates(
2096 const gfx::PointF& base,
2097 const gfx::PointF& extent) {
2098 RenderViewHost* rvh = RenderViewHost::From(host_);
2099 WebContentsImpl* wc =
2100 static_cast<WebContentsImpl*>(WebContents::FromRenderViewHost(rvh));
2101 gfx::Point base_point(base.x(), base.y());
2102 gfx::Point extent_point(extent.x(), extent.y());
2103 wc->SelectRange(base_point, extent_point);
2104 }
2105
2106 aura::Window* RenderWidgetHostViewAura::GetParentWindow() {
2107 return window_;
2108 }
2109
2110 bool RenderWidgetHostViewAura::IsCommandIdEnabled(int command_id) {
2111 bool editable = GetTextInputType() != ui::TEXT_INPUT_TYPE_NONE;
2112 bool readable = GetTextInputType() != ui::TEXT_INPUT_TYPE_PASSWORD;
2113 gfx::Range selection_range;
2114 GetSelectionRange(&selection_range);
2115 bool has_selection = !selection_range.is_empty();
2116 switch (command_id) {
2117 case IDS_APP_CUT:
2118 return editable && readable && has_selection;
2119 case IDS_APP_COPY:
2120 return readable && has_selection;
2121 case IDS_APP_PASTE: {
2122 base::string16 result;
2123 ui::Clipboard::GetForCurrentThread()->ReadText(
2124 ui::CLIPBOARD_TYPE_COPY_PASTE, &result);
2125 return editable && !result.empty();
2126 }
2127 case IDS_APP_DELETE:
2128 return editable && has_selection;
2129 case IDS_APP_SELECT_ALL:
2130 return true;
2131 default:
2132 return false;
2133 }
2134 }
2135
2136 void RenderWidgetHostViewAura::ExecuteCommand(int command_id, int event_flags) {
2137 RenderViewHost* rvh = RenderViewHost::From(host_);
2138 WebContents* wc = WebContents::FromRenderViewHost(rvh);
2139
2140 switch (command_id) {
2141 case IDS_APP_CUT:
2142 wc->Cut();
2143 break;
2144 case IDS_APP_COPY:
2145 wc->Copy();
2146 break;
2147 case IDS_APP_PASTE:
2148 wc->Paste();
2149 break;
2150 case IDS_APP_DELETE:
2151 wc->Delete();
2152 break;
2153 case IDS_APP_SELECT_ALL:
2154 wc->SelectAll();
2155 break;
2156 default:
2157 NOTREACHED();
2158 break;
2159 }
2160 }
2161
2162 void RenderWidgetHostViewAura::OpenContextMenu(const gfx::PointF& point) {
2163 host_->Send(new ViewMsg_ShowContextMenu(host_->GetRoutingID(),
2164 ui::MENU_SOURCE_TOUCH_EDIT_MENU,
2165 gfx::Point(point.x(), point.y())));
2166 }
2167
2168 gfx::Rect RenderWidgetHostViewAura::ConvertRectToScreen(
2169 const gfx::RectF& rect) const {
2170 gfx::Rect r(rect.x(), rect.y(), rect.width(), rect.height());
2171 return ConvertRectToScreen(r);
2172 }
2173
2174 ////////////////////////////////////////////////////////////////////////////////
2118 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: 2175 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation:
2119 2176
2120 bool RenderWidgetHostViewAura::ShouldActivate() const { 2177 bool RenderWidgetHostViewAura::ShouldActivate() const {
2121 aura::WindowTreeHost* host = window_->GetHost(); 2178 aura::WindowTreeHost* host = window_->GetHost();
2122 if (!host) 2179 if (!host)
2123 return true; 2180 return true;
2124 const ui::Event* event = host->dispatcher()->current_event(); 2181 const ui::Event* event = host->dispatcher()->current_event();
2125 if (!event) 2182 if (!event)
2126 return true; 2183 return true;
2127 return is_fullscreen_; 2184 return is_fullscreen_;
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2183 host_->GetRootBrowserAccessibilityManager(); 2240 host_->GetRootBrowserAccessibilityManager();
2184 if (manager) 2241 if (manager)
2185 manager->OnWindowFocused(); 2242 manager->OnWindowFocused();
2186 } else if (window_ == lost_focus) { 2243 } else if (window_ == lost_focus) {
2187 host_->SetActive(false); 2244 host_->SetActive(false);
2188 host_->Blur(); 2245 host_->Blur();
2189 2246
2190 DetachFromInputMethod(); 2247 DetachFromInputMethod();
2191 host_->SetInputMethodActive(false); 2248 host_->SetInputMethodActive(false);
2192 2249
2193 if (touch_editing_client_) 2250 selection_controller_->HideAndDisallowShowingAutomatically();
2194 touch_editing_client_->EndTouchEditing(false);
2195 2251
2196 if (overscroll_controller_) 2252 if (overscroll_controller_)
2197 overscroll_controller_->Cancel(); 2253 overscroll_controller_->Cancel();
2198 2254
2199 BrowserAccessibilityManager* manager = 2255 BrowserAccessibilityManager* manager =
2200 host_->GetRootBrowserAccessibilityManager(); 2256 host_->GetRootBrowserAccessibilityManager();
2201 if (manager) 2257 if (manager)
2202 manager->OnWindowBlurred(); 2258 manager->OnWindowBlurred();
2203 2259
2204 // If we lose the focus while fullscreen, close the window; Pepper Flash 2260 // If we lose the focus while fullscreen, close the window; Pepper Flash
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2241 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved", 2297 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved",
2242 "new_origin", new_origin.ToString()); 2298 "new_origin", new_origin.ToString());
2243 2299
2244 UpdateScreenInfo(window_); 2300 UpdateScreenInfo(window_);
2245 } 2301 }
2246 2302
2247 //////////////////////////////////////////////////////////////////////////////// 2303 ////////////////////////////////////////////////////////////////////////////////
2248 // RenderWidgetHostViewAura, private: 2304 // RenderWidgetHostViewAura, private:
2249 2305
2250 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { 2306 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
2251 if (touch_editing_client_)
2252 touch_editing_client_->OnViewDestroyed();
2253
2254 delegated_frame_host_.reset(); 2307 delegated_frame_host_.reset();
2255 window_observer_.reset(); 2308 window_observer_.reset();
2256 if (window_->GetHost()) 2309 if (window_->GetHost())
2257 window_->GetHost()->RemoveObserver(this); 2310 window_->GetHost()->RemoveObserver(this);
2258 UnlockMouse(); 2311 UnlockMouse();
2259 if (popup_parent_host_view_) { 2312 if (popup_parent_host_view_) {
2260 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || 2313 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL ||
2261 popup_parent_host_view_->popup_child_host_view_ == this); 2314 popup_parent_host_view_->popup_child_host_view_ == this);
2262 popup_parent_host_view_->popup_child_host_view_ = NULL; 2315 popup_parent_host_view_->popup_child_host_view_ = NULL;
2263 } 2316 }
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2407 snapped = window_->GetRootWindow(); 2460 snapped = window_->GetRootWindow();
2408 } else { 2461 } else {
2409 snapped = window_->GetToplevelWindow(); 2462 snapped = window_->GetToplevelWindow();
2410 } 2463 }
2411 if (snapped && snapped != window_) 2464 if (snapped && snapped != window_)
2412 ui::SnapLayerToPhysicalPixelBoundary(snapped->layer(), window_->layer()); 2465 ui::SnapLayerToPhysicalPixelBoundary(snapped->layer(), window_->layer());
2413 2466
2414 has_snapped_to_boundary_ = true; 2467 has_snapped_to_boundary_ = true;
2415 } 2468 }
2416 2469
2417 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { 2470 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
mfomitchev 2014/11/26 22:02:44 Don't we need to notify the touch selection contro
mohsen 2015/02/22 23:23:09 In WebContentsViewAura, we're handling a bunch of
2418 if (HasDisplayPropertyChanged(window_)) 2471 if (HasDisplayPropertyChanged(window_))
2419 host_->InvalidateScreenInfo(); 2472 host_->InvalidateScreenInfo();
2420 2473
2421 SnapToPhysicalPixelBoundary(); 2474 SnapToPhysicalPixelBoundary();
2422 // Don't recursively call SetBounds if this bounds update is the result of 2475 // Don't recursively call SetBounds if this bounds update is the result of
2423 // a Window::SetBoundsInternal call. 2476 // a Window::SetBoundsInternal call.
2424 if (!in_bounds_changed_) 2477 if (!in_bounds_changed_)
2425 window_->SetBounds(rect); 2478 window_->SetBounds(rect);
2426 host_->WasResized(); 2479 host_->WasResized();
2427 delegated_frame_host_->WasResized(); 2480 delegated_frame_host_->WasResized();
2428 if (touch_editing_client_) {
2429 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_,
2430 selection_focus_);
2431 }
2432 #if defined(OS_WIN) 2481 #if defined(OS_WIN)
2433 if (mouse_locked_) 2482 if (mouse_locked_)
2434 UpdateMouseLockRegion(); 2483 UpdateMouseLockRegion();
2435 #endif 2484 #endif
2436 } 2485 }
2437 2486
2438 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip( 2487 void RenderWidgetHostViewAura::SchedulePaintIfNotInClip(
2439 const gfx::Rect& rect, 2488 const gfx::Rect& rect,
2440 const gfx::Rect& clip) { 2489 const gfx::Rect& clip) {
2441 if (!clip.IsEmpty()) { 2490 if (!clip.IsEmpty()) {
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
2522 } 2571 }
2523 #endif 2572 #endif
2524 2573
2525 host_->ForwardKeyboardEvent(event); 2574 host_->ForwardKeyboardEvent(event);
2526 } 2575 }
2527 2576
2528 SkColorType RenderWidgetHostViewAura::PreferredReadbackFormat() { 2577 SkColorType RenderWidgetHostViewAura::PreferredReadbackFormat() {
2529 return kN32_SkColorType; 2578 return kN32_SkColorType;
2530 } 2579 }
2531 2580
2581 void RenderWidgetHostViewAura::SelectionBoundsUpdated(
2582 const cc::ViewportSelectionBound& start,
2583 const cc::ViewportSelectionBound& end) {
2584 selection_controller_->OnSelectionBoundsChanged(start, end);
2585 if (GetInputMethod())
2586 GetInputMethod()->OnCaretBoundsChanged(this);
2587 }
2588
2532 //////////////////////////////////////////////////////////////////////////////// 2589 ////////////////////////////////////////////////////////////////////////////////
2533 // DelegatedFrameHost, public: 2590 // DelegatedFrameHost, public:
2534 2591
2535 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const { 2592 ui::Compositor* RenderWidgetHostViewAura::GetCompositor() const {
2536 aura::WindowTreeHost* host = window_->GetHost(); 2593 aura::WindowTreeHost* host = window_->GetHost();
2537 return host ? host->compositor() : NULL; 2594 return host ? host->compositor() : NULL;
2538 } 2595 }
2539 2596
2540 ui::Layer* RenderWidgetHostViewAura::GetLayer() { 2597 ui::Layer* RenderWidgetHostViewAura::GetLayer() {
2541 return window_->layer(); 2598 return window_->layer();
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2578 2635
2579 //////////////////////////////////////////////////////////////////////////////// 2636 ////////////////////////////////////////////////////////////////////////////////
2580 // RenderWidgetHostViewBase, public: 2637 // RenderWidgetHostViewBase, public:
2581 2638
2582 // static 2639 // static
2583 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2640 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2584 GetScreenInfoForWindow(results, NULL); 2641 GetScreenInfoForWindow(results, NULL);
2585 } 2642 }
2586 2643
2587 } // namespace content 2644 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698