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

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: Added scoped helper for MotionEventAura Created 5 years, 5 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_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/auto_reset.h" 9 #include "base/auto_reset.h"
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 12 matching lines...) Expand all
23 #include "content/browser/accessibility/browser_accessibility_manager.h" 23 #include "content/browser/accessibility/browser_accessibility_manager.h"
24 #include "content/browser/accessibility/browser_accessibility_state_impl.h" 24 #include "content/browser/accessibility/browser_accessibility_state_impl.h"
25 #include "content/browser/bad_message.h" 25 #include "content/browser/bad_message.h"
26 #include "content/browser/frame_host/frame_tree.h" 26 #include "content/browser/frame_host/frame_tree.h"
27 #include "content/browser/frame_host/frame_tree_node.h" 27 #include "content/browser/frame_host/frame_tree_node.h"
28 #include "content/browser/frame_host/render_frame_host_impl.h" 28 #include "content/browser/frame_host/render_frame_host_impl.h"
29 #include "content/browser/gpu/compositor_util.h" 29 #include "content/browser/gpu/compositor_util.h"
30 #include "content/browser/renderer_host/compositor_resize_lock_aura.h" 30 #include "content/browser/renderer_host/compositor_resize_lock_aura.h"
31 #include "content/browser/renderer_host/dip_util.h" 31 #include "content/browser/renderer_host/dip_util.h"
32 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" 32 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h"
33 #include "content/browser/renderer_host/input/touch_selection_controller_client_ aura.h"
34 #include "content/browser/renderer_host/input/ui_touch_selection_helper.h"
33 #include "content/browser/renderer_host/input/web_input_event_util.h" 35 #include "content/browser/renderer_host/input/web_input_event_util.h"
34 #include "content/browser/renderer_host/overscroll_controller.h" 36 #include "content/browser/renderer_host/overscroll_controller.h"
35 #include "content/browser/renderer_host/render_view_host_delegate.h" 37 #include "content/browser/renderer_host/render_view_host_delegate.h"
36 #include "content/browser/renderer_host/render_view_host_delegate_view.h" 38 #include "content/browser/renderer_host/render_view_host_delegate_view.h"
37 #include "content/browser/renderer_host/render_view_host_impl.h" 39 #include "content/browser/renderer_host/render_view_host_impl.h"
38 #include "content/browser/renderer_host/render_widget_host_impl.h" 40 #include "content/browser/renderer_host/render_widget_host_impl.h"
39 #include "content/browser/renderer_host/ui_events_helper.h" 41 #include "content/browser/renderer_host/ui_events_helper.h"
40 #include "content/browser/renderer_host/web_input_event_aura.h" 42 #include "content/browser/renderer_host/web_input_event_aura.h"
41 #include "content/common/gpu/client/gl_helper.h" 43 #include "content/common/gpu/client/gl_helper.h"
42 #include "content/common/gpu/gpu_messages.h" 44 #include "content/common/gpu/gpu_messages.h"
(...skipping 21 matching lines...) Expand all
64 #include "ui/aura/window_tree_host.h" 66 #include "ui/aura/window_tree_host.h"
65 #include "ui/base/clipboard/scoped_clipboard_writer.h" 67 #include "ui/base/clipboard/scoped_clipboard_writer.h"
66 #include "ui/base/hit_test.h" 68 #include "ui/base/hit_test.h"
67 #include "ui/base/ime/input_method.h" 69 #include "ui/base/ime/input_method.h"
68 #include "ui/base/ui_base_types.h" 70 #include "ui/base/ui_base_types.h"
69 #include "ui/compositor/compositor_vsync_manager.h" 71 #include "ui/compositor/compositor_vsync_manager.h"
70 #include "ui/compositor/dip_util.h" 72 #include "ui/compositor/dip_util.h"
71 #include "ui/events/blink/blink_event_util.h" 73 #include "ui/events/blink/blink_event_util.h"
72 #include "ui/events/event.h" 74 #include "ui/events/event.h"
73 #include "ui/events/event_utils.h" 75 #include "ui/events/event_utils.h"
76 #include "ui/events/gesture_detection/gesture_configuration.h"
74 #include "ui/events/gestures/gesture_recognizer.h" 77 #include "ui/events/gestures/gesture_recognizer.h"
75 #include "ui/gfx/canvas.h" 78 #include "ui/gfx/canvas.h"
76 #include "ui/gfx/display.h" 79 #include "ui/gfx/display.h"
77 #include "ui/gfx/geometry/rect_conversions.h" 80 #include "ui/gfx/geometry/rect_conversions.h"
78 #include "ui/gfx/geometry/size_conversions.h" 81 #include "ui/gfx/geometry/size_conversions.h"
79 #include "ui/gfx/screen.h" 82 #include "ui/gfx/screen.h"
80 #include "ui/gfx/skia_util.h" 83 #include "ui/gfx/skia_util.h"
84 #include "ui/touch_selection/touch_selection_controller.h"
81 #include "ui/wm/public/activation_client.h" 85 #include "ui/wm/public/activation_client.h"
82 #include "ui/wm/public/scoped_tooltip_disabler.h" 86 #include "ui/wm/public/scoped_tooltip_disabler.h"
83 #include "ui/wm/public/tooltip_client.h" 87 #include "ui/wm/public/tooltip_client.h"
84 #include "ui/wm/public/transient_window_client.h" 88 #include "ui/wm/public/transient_window_client.h"
85 #include "ui/wm/public/window_types.h" 89 #include "ui/wm/public/window_types.h"
86 90
87 #if defined(OS_WIN) 91 #if defined(OS_WIN)
88 #include "content/browser/accessibility/browser_accessibility_manager_win.h" 92 #include "content/browser/accessibility/browser_accessibility_manager_win.h"
89 #include "content/browser/accessibility/browser_accessibility_win.h" 93 #include "content/browser/accessibility/browser_accessibility_win.h"
90 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" 94 #include "content/browser/renderer_host/legacy_render_widget_host_win.h"
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 int changed_touch_id) { 288 int changed_touch_id) {
285 if (event->type == blink::WebInputEvent::TouchMove || 289 if (event->type == blink::WebInputEvent::TouchMove ||
286 event->type == blink::WebInputEvent::TouchCancel) { 290 event->type == blink::WebInputEvent::TouchCancel) {
287 for (size_t i = 0; i < event->touchesLength; ++i) { 291 for (size_t i = 0; i < event->touchesLength; ++i) {
288 if (event->touches[i].id != changed_touch_id) 292 if (event->touches[i].id != changed_touch_id)
289 event->touches[i].state = blink::WebTouchPoint::StateStationary; 293 event->touches[i].state = blink::WebTouchPoint::StateStationary;
290 } 294 }
291 } 295 }
292 } 296 }
293 297
298 class ScopedMotionEventAuraCleanup {
299 public:
300 ScopedMotionEventAuraCleanup(ui::MotionEventAura* motion_event,
301 const ui::TouchEvent& event);
302 virtual ~ScopedMotionEventAuraCleanup();
303
304 private:
305 ui::MotionEventAura* motion_event_;
306 const ui::TouchEvent& event_;
307
308 DISALLOW_COPY_AND_ASSIGN(ScopedMotionEventAuraCleanup);
jdduke (slow) 2015/07/08 22:19:43 This looks good, but let's add it in a separate pa
mohsen 2015/07/08 22:45:14 Yeah, if that would useful in other places, then w
309 };
310
311 ScopedMotionEventAuraCleanup::ScopedMotionEventAuraCleanup(
312 ui::MotionEventAura* mouse_event,
jdduke (slow) 2015/07/08 22:19:43 motion_event
mohsen 2015/07/08 22:45:14 Acknowledged.
313 const ui::TouchEvent& event)
314 : motion_event_(mouse_event), event_(event) {
315 }
316
317 ScopedMotionEventAuraCleanup::~ScopedMotionEventAuraCleanup() {
318 motion_event_->CleanupRemovedTouchPoints(event_);
319 }
320
294 } // namespace 321 } // namespace
295 322
296 // We need to watch for mouse events outside a Web Popup or its parent 323 // We need to watch for mouse events outside a Web Popup or its parent
297 // and dismiss the popup for certain events. 324 // and dismiss the popup for certain events.
298 class RenderWidgetHostViewAura::EventFilterForPopupExit 325 class RenderWidgetHostViewAura::EventFilterForPopupExit
299 : public ui::EventHandler { 326 : public ui::EventHandler {
300 public: 327 public:
301 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) 328 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva)
302 : rwhva_(rwhva) { 329 : rwhva_(rwhva) {
303 DCHECK(rwhva_); 330 DCHECK(rwhva_);
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 last_swapped_software_frame_scale_factor_(1.f), 482 last_swapped_software_frame_scale_factor_(1.f),
456 paint_canvas_(NULL), 483 paint_canvas_(NULL),
457 synthetic_move_sent_(false), 484 synthetic_move_sent_(false),
458 cursor_visibility_state_in_renderer_(UNKNOWN), 485 cursor_visibility_state_in_renderer_(UNKNOWN),
459 #if defined(OS_WIN) 486 #if defined(OS_WIN)
460 legacy_render_widget_host_HWND_(NULL), 487 legacy_render_widget_host_HWND_(NULL),
461 legacy_window_destroyed_(false), 488 legacy_window_destroyed_(false),
462 showing_context_menu_(false), 489 showing_context_menu_(false),
463 #endif 490 #endif
464 has_snapped_to_boundary_(false), 491 has_snapped_to_boundary_(false),
465 touch_editing_client_(NULL),
466 is_guest_view_hack_(is_guest_view_hack), 492 is_guest_view_hack_(is_guest_view_hack),
467 begin_frame_observer_proxy_(this), 493 begin_frame_observer_proxy_(this),
468 weak_ptr_factory_(this) { 494 weak_ptr_factory_(this) {
469 if (!is_guest_view_hack_) 495 if (!is_guest_view_hack_)
470 host_->SetView(this); 496 host_->SetView(this);
471 497
472 window_observer_.reset(new WindowObserver(this)); 498 window_observer_.reset(new WindowObserver(this));
473 499
474 aura::client::SetTooltipText(window_, &tooltip_); 500 aura::client::SetTooltipText(window_, &tooltip_);
475 aura::client::SetActivationDelegate(window_, this); 501 aura::client::SetActivationDelegate(window_, this);
476 aura::client::SetFocusChangeObserver(window_, this); 502 aura::client::SetFocusChangeObserver(window_, this);
477 window_->set_layer_owner_delegate(delegated_frame_host_.get()); 503 window_->set_layer_owner_delegate(delegated_frame_host_.get());
478 gfx::Screen::GetScreenFor(window_)->AddObserver(this); 504 gfx::Screen::GetScreenFor(window_)->AddObserver(this);
479 505
480 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> 506 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()->
481 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; 507 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0";
482 SetOverscrollControllerEnabled(overscroll_enabled); 508 SetOverscrollControllerEnabled(overscroll_enabled);
509
510 selection_controller_client_.reset(
511 new TouchSelectionControllerClientAura(this));
512
513 ui::TouchSelectionController::Config tsc_config;
514 tsc_config.tap_timeout = base::TimeDelta::FromMilliseconds(
515 ui::GestureConfiguration::GetInstance()->show_press_delay_in_ms());
516 tsc_config.tap_slop = ui::GestureConfiguration::GetInstance()
517 ->max_touch_move_in_pixels_for_click();
518 tsc_config.show_on_tap_for_empty_editable = true;
519 tsc_config.enable_longpress_drag_selection = false;
520 selection_controller_.reset(new ui::TouchSelectionController(
521 selection_controller_client_.get(), tsc_config));
483 } 522 }
484 523
485 //////////////////////////////////////////////////////////////////////////////// 524 ////////////////////////////////////////////////////////////////////////////////
486 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: 525 // RenderWidgetHostViewAura, RenderWidgetHostView implementation:
487 526
488 bool RenderWidgetHostViewAura::OnMessageReceived( 527 bool RenderWidgetHostViewAura::OnMessageReceived(
489 const IPC::Message& message) { 528 const IPC::Message& message) {
490 bool handled = true; 529 bool handled = true;
491 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) 530 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message)
492 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC 531 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after
958 if (text_input_type_ != type || 997 if (text_input_type_ != type ||
959 text_input_mode_ != input_mode || 998 text_input_mode_ != input_mode ||
960 can_compose_inline_ != can_compose_inline || 999 can_compose_inline_ != can_compose_inline ||
961 text_input_flags_ != flags) { 1000 text_input_flags_ != flags) {
962 text_input_type_ = type; 1001 text_input_type_ = type;
963 text_input_mode_ = input_mode; 1002 text_input_mode_ = input_mode;
964 can_compose_inline_ = can_compose_inline; 1003 can_compose_inline_ = can_compose_inline;
965 text_input_flags_ = flags; 1004 text_input_flags_ = flags;
966 if (GetInputMethod()) 1005 if (GetInputMethod())
967 GetInputMethod()->OnTextInputTypeChanged(this); 1006 GetInputMethod()->OnTextInputTypeChanged(this);
968 if (touch_editing_client_)
969 touch_editing_client_->OnTextInputTypeChanged(text_input_type_);
970 } 1007 }
971 } 1008 }
972 1009
973 void RenderWidgetHostViewAura::OnTextInputStateChanged( 1010 void RenderWidgetHostViewAura::OnTextInputStateChanged(
974 const ViewHostMsg_TextInputState_Params& params) { 1011 const ViewHostMsg_TextInputState_Params& params) {
975 text_input_flags_ = params.flags; 1012 text_input_flags_ = params.flags;
976 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { 1013 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) {
977 if (GetInputMethod()) 1014 if (GetInputMethod())
978 GetInputMethod()->ShowImeIfNeeded(); 1015 GetInputMethod()->ShowImeIfNeeded();
979 } 1016 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 } 1113 }
1077 } 1114 }
1078 1115
1079 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_) 1116 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_)
1080 return; 1117 return;
1081 1118
1082 selection_anchor_ = anchor_bound; 1119 selection_anchor_ = anchor_bound;
1083 selection_focus_ = focus_bound; 1120 selection_focus_ = focus_bound;
1084 if (GetInputMethod()) 1121 if (GetInputMethod())
1085 GetInputMethod()->OnCaretBoundsChanged(this); 1122 GetInputMethod()->OnCaretBoundsChanged(this);
1086
1087 if (touch_editing_client_) {
1088 touch_editing_client_->OnSelectionOrCursorChanged(
1089 anchor_bound, focus_bound);
1090 }
1091 } 1123 }
1092 1124
1093 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 1125 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
1094 const gfx::Rect& src_subrect, 1126 const gfx::Rect& src_subrect,
1095 const gfx::Size& dst_size, 1127 const gfx::Size& dst_size,
1096 ReadbackRequestCallback& callback, 1128 ReadbackRequestCallback& callback,
1097 const SkColorType preferred_color_type) { 1129 const SkColorType preferred_color_type) {
1098 delegated_frame_host_->CopyFromCompositingSurface( 1130 delegated_frame_host_->CopyFromCompositingSurface(
1099 src_subrect, dst_size, callback, preferred_color_type); 1131 src_subrect, dst_size, callback, preferred_color_type);
1100 } 1132 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1170 scoped_ptr<cc::CompositorFrame> frame) { 1202 scoped_ptr<cc::CompositorFrame> frame) {
1171 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); 1203 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame");
1172 1204
1173 last_scroll_offset_ = frame->metadata.root_scroll_offset; 1205 last_scroll_offset_ = frame->metadata.root_scroll_offset;
1174 if (frame->delegated_frame_data) { 1206 if (frame->delegated_frame_data) {
1175 delegated_frame_host_->SwapDelegatedFrame( 1207 delegated_frame_host_->SwapDelegatedFrame(
1176 output_surface_id, 1208 output_surface_id,
1177 frame->delegated_frame_data.Pass(), 1209 frame->delegated_frame_data.Pass(),
1178 frame->metadata.device_scale_factor, 1210 frame->metadata.device_scale_factor,
1179 frame->metadata.latency_info); 1211 frame->metadata.latency_info);
1212 SelectionUpdated(frame->metadata.selection.is_editable,
1213 frame->metadata.selection.is_empty_text_form_control,
1214 ConvertSelectionBound(frame->metadata.selection.start),
1215 ConvertSelectionBound(frame->metadata.selection.end));
1180 return; 1216 return;
1181 } 1217 }
1182 1218
1183 if (frame->software_frame_data) { 1219 if (frame->software_frame_data) {
1184 DLOG(ERROR) << "Unable to use software frame in aura"; 1220 DLOG(ERROR) << "Unable to use software frame in aura";
1185 bad_message::ReceivedBadMessage(host_->GetProcess(), 1221 bad_message::ReceivedBadMessage(host_->GetProcess(),
1186 bad_message::RWHVA_SHARED_MEMORY); 1222 bad_message::RWHVA_SHARED_MEMORY);
1187 return; 1223 return;
1188 } 1224 }
1189 } 1225 }
1190 1226
1191 void RenderWidgetHostViewAura::DidStopFlinging() { 1227 void RenderWidgetHostViewAura::DidStopFlinging() {
1192 if (touch_editing_client_) 1228 selection_controller_client_->OnSelectionScrollCompleted();
1193 touch_editing_client_->DidStopFlinging();
1194 } 1229 }
1195 1230
1196 #if defined(OS_WIN) 1231 #if defined(OS_WIN)
1197 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( 1232 void RenderWidgetHostViewAura::SetParentNativeViewAccessible(
1198 gfx::NativeViewAccessible accessible_parent) { 1233 gfx::NativeViewAccessible accessible_parent) {
1199 } 1234 }
1200 1235
1201 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() 1236 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin()
1202 const { 1237 const {
1203 if (legacy_render_widget_host_HWND_) { 1238 if (legacy_render_widget_host_HWND_) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1263 InputEventAckState ack_result) { 1298 InputEventAckState ack_result) {
1264 if (overscroll_controller_) { 1299 if (overscroll_controller_) {
1265 overscroll_controller_->ReceivedEventACK( 1300 overscroll_controller_->ReceivedEventACK(
1266 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); 1301 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result));
1267 } 1302 }
1268 } 1303 }
1269 1304
1270 void RenderWidgetHostViewAura::GestureEventAck( 1305 void RenderWidgetHostViewAura::GestureEventAck(
1271 const blink::WebGestureEvent& event, 1306 const blink::WebGestureEvent& event,
1272 InputEventAckState ack_result) { 1307 InputEventAckState ack_result) {
1273 if (touch_editing_client_)
1274 touch_editing_client_->GestureEventAck(event.type);
1275
1276 if (overscroll_controller_) { 1308 if (overscroll_controller_) {
1277 overscroll_controller_->ReceivedEventACK( 1309 overscroll_controller_->ReceivedEventACK(
1278 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); 1310 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result));
1279 } 1311 }
1280 } 1312 }
1281 1313
1282 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( 1314 void RenderWidgetHostViewAura::ProcessAckedTouchEvent(
1283 const TouchEventWithLatencyInfo& touch, 1315 const TouchEventWithLatencyInfo& touch,
1284 InputEventAckState ack_result) { 1316 InputEventAckState ack_result) {
1285 ScopedVector<ui::TouchEvent> events; 1317 ScopedVector<ui::TouchEvent> events;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1667 return gfx::Rect(origin.x(), 1699 return gfx::Rect(origin.x(),
1668 origin.y(), 1700 origin.y(),
1669 end.x() - origin.x(), 1701 end.x() - origin.x(),
1670 end.y() - origin.y()); 1702 end.y() - origin.y());
1671 } 1703 }
1672 1704
1673 return rect; 1705 return rect;
1674 } 1706 }
1675 1707
1676 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1708 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1677 gfx::Rect rect = 1709 return ConvertRectToScreen(
1678 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_); 1710 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_));
1679 return ConvertRectToScreen(rect);
1680 } 1711 }
1681 1712
1682 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( 1713 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(
1683 uint32 index, 1714 uint32 index,
1684 gfx::Rect* rect) const { 1715 gfx::Rect* rect) const {
1685 DCHECK(rect); 1716 DCHECK(rect);
1686 if (index >= composition_character_bounds_.size()) 1717 if (index >= composition_character_bounds_.size())
1687 return false; 1718 return false;
1688 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 1719 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
1689 return true; 1720 return true;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1856 const gfx::Point& location) { 1887 const gfx::Point& location) {
1857 return true; 1888 return true;
1858 } 1889 }
1859 1890
1860 bool RenderWidgetHostViewAura::CanFocus() { 1891 bool RenderWidgetHostViewAura::CanFocus() {
1861 return popup_type_ == blink::WebPopupTypeNone; 1892 return popup_type_ == blink::WebPopupTypeNone;
1862 } 1893 }
1863 1894
1864 void RenderWidgetHostViewAura::OnCaptureLost() { 1895 void RenderWidgetHostViewAura::OnCaptureLost() {
1865 host_->LostCapture(); 1896 host_->LostCapture();
1866 if (touch_editing_client_)
1867 touch_editing_client_->EndTouchEditing(false);
1868 } 1897 }
1869 1898
1870 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) { 1899 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) {
1871 NOTREACHED(); 1900 NOTREACHED();
1872 } 1901 }
1873 1902
1874 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( 1903 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged(
1875 float device_scale_factor) { 1904 float device_scale_factor) {
1876 if (!host_ || !window_->GetRootWindow()) 1905 if (!host_ || !window_->GetRootWindow())
1877 return; 1906 return;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1940 } 1969 }
1941 1970
1942 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { 1971 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const {
1943 } 1972 }
1944 1973
1945 //////////////////////////////////////////////////////////////////////////////// 1974 ////////////////////////////////////////////////////////////////////////////////
1946 // RenderWidgetHostViewAura, ui::EventHandler implementation: 1975 // RenderWidgetHostViewAura, ui::EventHandler implementation:
1947 1976
1948 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { 1977 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
1949 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); 1978 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent");
1950 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
1951 return;
1952 1979
1953 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { 1980 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
1954 popup_child_host_view_->OnKeyEvent(event); 1981 popup_child_host_view_->OnKeyEvent(event);
1955 if (event->handled()) 1982 if (event->handled())
1956 return; 1983 return;
1957 } 1984 }
1958 1985
1959 // We need to handle the Escape key for Pepper Flash. 1986 // We need to handle the Escape key for Pepper Flash.
1960 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { 1987 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) {
1961 // Focus the window we were created from. 1988 // Focus the window we were created from.
(...skipping 26 matching lines...) Expand all
1988 // We don't have to communicate with an input method here. 2015 // We don't have to communicate with an input method here.
1989 NativeWebKeyboardEvent webkit_event(*event); 2016 NativeWebKeyboardEvent webkit_event(*event);
1990 ForwardKeyboardEvent(webkit_event); 2017 ForwardKeyboardEvent(webkit_event);
1991 } 2018 }
1992 event->SetHandled(); 2019 event->SetHandled();
1993 } 2020 }
1994 2021
1995 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { 2022 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) {
1996 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent"); 2023 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent");
1997 2024
1998 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
1999 return;
2000
2001 if (mouse_locked_) { 2025 if (mouse_locked_) {
2002 aura::client::CursorClient* cursor_client = 2026 aura::client::CursorClient* cursor_client =
2003 aura::client::GetCursorClient(window_->GetRootWindow()); 2027 aura::client::GetCursorClient(window_->GetRootWindow());
2004 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); 2028 DCHECK(!cursor_client || !cursor_client->IsCursorVisible());
2005 2029
2006 if (event->type() == ui::ET_MOUSEWHEEL) { 2030 if (event->type() == ui::ET_MOUSEWHEEL) {
2007 blink::WebMouseWheelEvent mouse_wheel_event = 2031 blink::WebMouseWheelEvent mouse_wheel_event =
2008 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); 2032 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event));
2009 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) 2033 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0)
2010 host_->ForwardWheelEvent(mouse_wheel_event); 2034 host_->ForwardWheelEvent(mouse_wheel_event);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2154 event->ConvertLocationToTarget(window_, window_->parent()); 2178 event->ConvertLocationToTarget(window_, window_->parent());
2155 window_->parent()->delegate()->OnMouseEvent(event); 2179 window_->parent()->delegate()->OnMouseEvent(event);
2156 } 2180 }
2157 2181
2158 if (!IsXButtonUpEvent(event)) 2182 if (!IsXButtonUpEvent(event))
2159 event->SetHandled(); 2183 event->SetHandled();
2160 } 2184 }
2161 2185
2162 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { 2186 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
2163 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); 2187 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent");
2164 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
2165 return;
2166 2188
2167 if (event->type() == ui::ET_SCROLL) { 2189 if (event->type() == ui::ET_SCROLL) {
2168 #if !defined(OS_WIN) 2190 #if !defined(OS_WIN)
2169 // TODO(ananta) 2191 // TODO(ananta)
2170 // Investigate if this is true for Windows 8 Metro ASH as well. 2192 // Investigate if this is true for Windows 8 Metro ASH as well.
2171 if (event->finger_count() != 2) 2193 if (event->finger_count() != 2)
2172 return; 2194 return;
2173 #endif 2195 #endif
2174 blink::WebGestureEvent gesture_event = 2196 blink::WebGestureEvent gesture_event =
2175 MakeWebGestureEventFlingCancel(); 2197 MakeWebGestureEventFlingCancel();
2176 host_->ForwardGestureEvent(gesture_event); 2198 host_->ForwardGestureEvent(gesture_event);
2177 blink::WebMouseWheelEvent mouse_wheel_event = 2199 blink::WebMouseWheelEvent mouse_wheel_event =
2178 MakeWebMouseWheelEvent(*event); 2200 MakeWebMouseWheelEvent(*event);
2179 host_->ForwardWheelEvent(mouse_wheel_event); 2201 host_->ForwardWheelEvent(mouse_wheel_event);
2180 RecordAction(base::UserMetricsAction("TrackpadScroll")); 2202 RecordAction(base::UserMetricsAction("TrackpadScroll"));
2181 } else if (event->type() == ui::ET_SCROLL_FLING_START || 2203 } else if (event->type() == ui::ET_SCROLL_FLING_START ||
2182 event->type() == ui::ET_SCROLL_FLING_CANCEL) { 2204 event->type() == ui::ET_SCROLL_FLING_CANCEL) {
2183 blink::WebGestureEvent gesture_event = MakeWebGestureEvent(*event); 2205 blink::WebGestureEvent gesture_event = MakeWebGestureEvent(*event);
2184 host_->ForwardGestureEvent(gesture_event); 2206 host_->ForwardGestureEvent(gesture_event);
2185 if (event->type() == ui::ET_SCROLL_FLING_START) 2207 if (event->type() == ui::ET_SCROLL_FLING_START)
2186 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); 2208 RecordAction(base::UserMetricsAction("TrackpadScrollFling"));
2187 } 2209 }
2188 2210
2189 event->SetHandled(); 2211 event->SetHandled();
2190 } 2212 }
2191 2213
2192 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { 2214 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
2193 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); 2215 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent");
2194 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) 2216
2195 return; 2217 bool had_no_pointer = !pointer_state_.GetPointerCount();
2196 2218
2197 // Update the touch event first. 2219 // Update the touch event first.
2198 if (!pointer_state_.OnTouch(*event)) { 2220 if (!pointer_state_.OnTouch(*event)) {
2199 event->StopPropagation(); 2221 event->StopPropagation();
2200 return; 2222 return;
2201 } 2223 }
2202 2224
2203 blink::WebTouchEvent touch_event = ui::CreateWebTouchEventFromMotionEvent( 2225 blink::WebTouchEvent touch_event;
2204 pointer_state_, event->may_cause_scrolling()); 2226
2205 pointer_state_.CleanupRemovedTouchPoints(*event); 2227 {
2228 ScopedMotionEventAuraCleanup motion_event_cleanup(&pointer_state_, *event);
2229 if (selection_controller_->WillHandleTouchEvent(pointer_state_)) {
2230 event->SetHandled();
2231 return;
2232 }
2233 touch_event = ui::CreateWebTouchEventFromMotionEvent(
2234 pointer_state_, event->may_cause_scrolling());
2235 }
2236
2237 if (had_no_pointer)
2238 selection_controller_client_->OnTouchDown();
2239 if (!pointer_state_.GetPointerCount())
2240 selection_controller_client_->OnTouchUp();
2206 2241
2207 // It is important to always mark events as being handled asynchronously when 2242 // It is important to always mark events as being handled asynchronously when
2208 // they are forwarded. This ensures that the current event does not get 2243 // they are forwarded. This ensures that the current event does not get
2209 // processed by the gesture recognizer before events currently awaiting 2244 // processed by the gesture recognizer before events currently awaiting
2210 // dispatch in the touch queue. 2245 // dispatch in the touch queue.
2211 event->DisableSynchronousHandling(); 2246 event->DisableSynchronousHandling();
2212 2247
2213 // Set unchanged touch point to StateStationary for touchmove and 2248 // Set unchanged touch point to StateStationary for touchmove and
2214 // touchcancel to make sure only send one ack per WebTouchEvent. 2249 // touchcancel to make sure only send one ack per WebTouchEvent.
2215 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); 2250 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id());
2216 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); 2251 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency());
2217 } 2252 }
2218 2253
2219 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { 2254 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
2220 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); 2255 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent");
2256
2221 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 2257 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
2222 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 2258 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
2223 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { 2259 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) {
2224 event->SetHandled(); 2260 event->SetHandled();
2225 return; 2261 return;
2226 } 2262 }
2227 2263
2228 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) 2264 HandleGestureForTouchSelection(event);
2265 if (event->handled())
2229 return; 2266 return;
2230 2267
2231 // Confirm existing composition text on TAP gesture, to make sure the input 2268 // Confirm existing composition text on TAP gesture, to make sure the input
2232 // caret won't be moved with an ongoing composition text. 2269 // caret won't be moved with an ongoing composition text.
2233 if (event->type() == ui::ET_GESTURE_TAP) 2270 if (event->type() == ui::ET_GESTURE_TAP)
2234 FinishImeCompositionSession(); 2271 FinishImeCompositionSession();
2235 2272
2236 blink::WebGestureEvent gesture = MakeWebGestureEvent(*event); 2273 blink::WebGestureEvent gesture = MakeWebGestureEvent(*event);
2237 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { 2274 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
2238 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an 2275 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
2315 host_->GetRootBrowserAccessibilityManager(); 2352 host_->GetRootBrowserAccessibilityManager();
2316 if (manager) 2353 if (manager)
2317 manager->OnWindowFocused(); 2354 manager->OnWindowFocused();
2318 } else if (window_ == lost_focus) { 2355 } else if (window_ == lost_focus) {
2319 host_->SetActive(false); 2356 host_->SetActive(false);
2320 host_->Blur(); 2357 host_->Blur();
2321 2358
2322 DetachFromInputMethod(); 2359 DetachFromInputMethod();
2323 host_->SetInputMethodActive(false); 2360 host_->SetInputMethodActive(false);
2324 2361
2325 if (touch_editing_client_) 2362 selection_controller_->HideAndDisallowShowingAutomatically();
2326 touch_editing_client_->EndTouchEditing(false);
2327 2363
2328 if (overscroll_controller_) 2364 if (overscroll_controller_)
2329 overscroll_controller_->Cancel(); 2365 overscroll_controller_->Cancel();
2330 2366
2331 BrowserAccessibilityManager* manager = 2367 BrowserAccessibilityManager* manager =
2332 host_->GetRootBrowserAccessibilityManager(); 2368 host_->GetRootBrowserAccessibilityManager();
2333 if (manager) 2369 if (manager)
2334 manager->OnWindowBlurred(); 2370 manager->OnWindowBlurred();
2335 2371
2336 // If we lose the focus while fullscreen, close the window; Pepper Flash 2372 // If we lose the focus while fullscreen, close the window; Pepper Flash
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2373 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved", 2409 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved",
2374 "new_origin", new_origin.ToString()); 2410 "new_origin", new_origin.ToString());
2375 2411
2376 UpdateScreenInfo(window_); 2412 UpdateScreenInfo(window_);
2377 } 2413 }
2378 2414
2379 //////////////////////////////////////////////////////////////////////////////// 2415 ////////////////////////////////////////////////////////////////////////////////
2380 // RenderWidgetHostViewAura, private: 2416 // RenderWidgetHostViewAura, private:
2381 2417
2382 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { 2418 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
2383 if (touch_editing_client_) 2419 selection_controller_.reset();
2384 touch_editing_client_->OnViewDestroyed(); 2420 selection_controller_client_.reset();
2385
2386 delegated_frame_host_.reset(); 2421 delegated_frame_host_.reset();
2387 window_observer_.reset(); 2422 window_observer_.reset();
2388 if (window_->GetHost()) 2423 if (window_->GetHost())
2389 window_->GetHost()->RemoveObserver(this); 2424 window_->GetHost()->RemoveObserver(this);
2390 UnlockMouse(); 2425 UnlockMouse();
2391 if (popup_parent_host_view_) { 2426 if (popup_parent_host_view_) {
2392 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || 2427 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL ||
2393 popup_parent_host_view_->popup_child_host_view_ == this); 2428 popup_parent_host_view_->popup_child_host_view_ == this);
2394 popup_parent_host_view_->popup_child_host_view_ = NULL; 2429 popup_parent_host_view_->popup_child_host_view_ = NULL;
2395 } 2430 }
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after
2560 } 2595 }
2561 2596
2562 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { 2597 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
2563 SnapToPhysicalPixelBoundary(); 2598 SnapToPhysicalPixelBoundary();
2564 // Don't recursively call SetBounds if this bounds update is the result of 2599 // Don't recursively call SetBounds if this bounds update is the result of
2565 // a Window::SetBoundsInternal call. 2600 // a Window::SetBoundsInternal call.
2566 if (!in_bounds_changed_) 2601 if (!in_bounds_changed_)
2567 window_->SetBounds(rect); 2602 window_->SetBounds(rect);
2568 host_->WasResized(); 2603 host_->WasResized();
2569 delegated_frame_host_->WasResized(); 2604 delegated_frame_host_->WasResized();
2570 if (touch_editing_client_) {
2571 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_,
2572 selection_focus_);
2573 }
2574 #if defined(OS_WIN) 2605 #if defined(OS_WIN)
2575 // Create the legacy dummy window which corresponds to the bounds of the 2606 // Create the legacy dummy window which corresponds to the bounds of the
2576 // webcontents. This will be passed as the container window for windowless 2607 // webcontents. This will be passed as the container window for windowless
2577 // plugins. 2608 // plugins.
2578 // Plugins like Flash assume the container window which is returned via the 2609 // Plugins like Flash assume the container window which is returned via the
2579 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. 2610 // NPNVnetscapeWindow property corresponds to the bounds of the webpage.
2580 // This is not true in Aura where we have only HWND which is the main Aura 2611 // This is not true in Aura where we have only HWND which is the main Aura
2581 // window. If we return this window to plugins like Flash then it causes the 2612 // window. If we return this window to plugins like Flash then it causes the
2582 // coordinate translations done by these plugins to break. 2613 // coordinate translations done by these plugins to break.
2583 // Additonally the legacy dummy window is needed for accessibility and for 2614 // Additonally the legacy dummy window is needed for accessibility and for
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2706 NativeWebKeyboardEvent copy_event(event); 2737 NativeWebKeyboardEvent copy_event(event);
2707 copy_event.match_edit_command = true; 2738 copy_event.match_edit_command = true;
2708 host_->ForwardKeyboardEvent(copy_event); 2739 host_->ForwardKeyboardEvent(copy_event);
2709 return; 2740 return;
2710 } 2741 }
2711 #endif 2742 #endif
2712 2743
2713 host_->ForwardKeyboardEvent(event); 2744 host_->ForwardKeyboardEvent(event);
2714 } 2745 }
2715 2746
2747 void RenderWidgetHostViewAura::SelectionUpdated(bool is_editable,
2748 bool is_empty_text_form_control,
2749 const ui::SelectionBound& start,
2750 const ui::SelectionBound& end) {
2751 selection_controller_->OnSelectionEditable(is_editable);
2752 selection_controller_->OnSelectionEmpty(is_empty_text_form_control);
2753 selection_controller_->OnSelectionBoundsChanged(start, end);
2754 }
2755
2756 void RenderWidgetHostViewAura::HandleGestureForTouchSelection(
2757 ui::GestureEvent* event) {
2758 switch (event->type()) {
2759 case ui::ET_GESTURE_LONG_PRESS:
2760 if (selection_controller_->WillHandleLongPressEvent(
2761 base::TimeTicks() + event->time_stamp(), event->location())) {
2762 event->SetHandled();
2763 }
2764 break;
2765 case ui::ET_GESTURE_TAP:
2766 if (selection_controller_->WillHandleTapEvent(event->location()))
2767 event->SetHandled();
2768 break;
2769 case ui::ET_GESTURE_SCROLL_BEGIN:
2770 selection_controller_client_->OnSelectionScrollStarted();
2771 break;
2772 case ui::ET_GESTURE_SCROLL_END:
2773 selection_controller_client_->OnSelectionScrollCompleted();
2774 break;
2775 default:
2776 break;
2777 }
2778 }
2779
2716 //////////////////////////////////////////////////////////////////////////////// 2780 ////////////////////////////////////////////////////////////////////////////////
2717 // DelegatedFrameHost, public: 2781 // DelegatedFrameHost, public:
2718 2782
2719 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { 2783 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const {
2720 return window_->layer(); 2784 return window_->layer();
2721 } 2785 }
2722 2786
2723 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { 2787 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const {
2724 return !host_->is_hidden(); 2788 return !host_->is_hidden();
2725 } 2789 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2792 2856
2793 //////////////////////////////////////////////////////////////////////////////// 2857 ////////////////////////////////////////////////////////////////////////////////
2794 // RenderWidgetHostViewBase, public: 2858 // RenderWidgetHostViewBase, public:
2795 2859
2796 // static 2860 // static
2797 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2861 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2798 GetScreenInfoForWindow(results, NULL); 2862 GetScreenInfoForWindow(results, NULL);
2799 } 2863 }
2800 2864
2801 } // namespace content 2865 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698