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

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: Fixed test failures 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 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 last_swapped_software_frame_scale_factor_(1.f), 459 last_swapped_software_frame_scale_factor_(1.f),
456 paint_canvas_(NULL), 460 paint_canvas_(NULL),
457 synthetic_move_sent_(false), 461 synthetic_move_sent_(false),
458 cursor_visibility_state_in_renderer_(UNKNOWN), 462 cursor_visibility_state_in_renderer_(UNKNOWN),
459 #if defined(OS_WIN) 463 #if defined(OS_WIN)
460 legacy_render_widget_host_HWND_(NULL), 464 legacy_render_widget_host_HWND_(NULL),
461 legacy_window_destroyed_(false), 465 legacy_window_destroyed_(false),
462 showing_context_menu_(false), 466 showing_context_menu_(false),
463 #endif 467 #endif
464 has_snapped_to_boundary_(false), 468 has_snapped_to_boundary_(false),
465 touch_editing_client_(NULL),
466 is_guest_view_hack_(is_guest_view_hack), 469 is_guest_view_hack_(is_guest_view_hack),
467 begin_frame_observer_proxy_(this), 470 begin_frame_observer_proxy_(this),
468 weak_ptr_factory_(this) { 471 weak_ptr_factory_(this) {
469 if (!is_guest_view_hack_) 472 if (!is_guest_view_hack_)
470 host_->SetView(this); 473 host_->SetView(this);
471 474
472 window_observer_.reset(new WindowObserver(this)); 475 window_observer_.reset(new WindowObserver(this));
473 476
474 aura::client::SetTooltipText(window_, &tooltip_); 477 aura::client::SetTooltipText(window_, &tooltip_);
475 aura::client::SetActivationDelegate(window_, this); 478 aura::client::SetActivationDelegate(window_, this);
476 aura::client::SetFocusChangeObserver(window_, this); 479 aura::client::SetFocusChangeObserver(window_, this);
477 window_->set_layer_owner_delegate(delegated_frame_host_.get()); 480 window_->set_layer_owner_delegate(delegated_frame_host_.get());
478 gfx::Screen::GetScreenFor(window_)->AddObserver(this); 481 gfx::Screen::GetScreenFor(window_)->AddObserver(this);
479 482
480 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()-> 483 bool overscroll_enabled = base::CommandLine::ForCurrentProcess()->
481 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0"; 484 GetSwitchValueASCII(switches::kOverscrollHistoryNavigation) != "0";
482 SetOverscrollControllerEnabled(overscroll_enabled); 485 SetOverscrollControllerEnabled(overscroll_enabled);
486
487 selection_controller_client_.reset(
488 new TouchSelectionControllerClientAura(this));
489 CreateSelectionController();
483 } 490 }
484 491
485 //////////////////////////////////////////////////////////////////////////////// 492 ////////////////////////////////////////////////////////////////////////////////
486 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: 493 // RenderWidgetHostViewAura, RenderWidgetHostView implementation:
487 494
488 bool RenderWidgetHostViewAura::OnMessageReceived( 495 bool RenderWidgetHostViewAura::OnMessageReceived(
489 const IPC::Message& message) { 496 const IPC::Message& message) {
490 bool handled = true; 497 bool handled = true;
491 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) 498 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message)
492 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC 499 // 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 || 965 if (text_input_type_ != type ||
959 text_input_mode_ != input_mode || 966 text_input_mode_ != input_mode ||
960 can_compose_inline_ != can_compose_inline || 967 can_compose_inline_ != can_compose_inline ||
961 text_input_flags_ != flags) { 968 text_input_flags_ != flags) {
962 text_input_type_ = type; 969 text_input_type_ = type;
963 text_input_mode_ = input_mode; 970 text_input_mode_ = input_mode;
964 can_compose_inline_ = can_compose_inline; 971 can_compose_inline_ = can_compose_inline;
965 text_input_flags_ = flags; 972 text_input_flags_ = flags;
966 if (GetInputMethod()) 973 if (GetInputMethod())
967 GetInputMethod()->OnTextInputTypeChanged(this); 974 GetInputMethod()->OnTextInputTypeChanged(this);
968 if (touch_editing_client_)
969 touch_editing_client_->OnTextInputTypeChanged(text_input_type_);
970 } 975 }
971 } 976 }
972 977
973 void RenderWidgetHostViewAura::OnTextInputStateChanged( 978 void RenderWidgetHostViewAura::OnTextInputStateChanged(
974 const ViewHostMsg_TextInputState_Params& params) { 979 const ViewHostMsg_TextInputState_Params& params) {
975 text_input_flags_ = params.flags; 980 text_input_flags_ = params.flags;
976 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { 981 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) {
977 if (GetInputMethod()) 982 if (GetInputMethod())
978 GetInputMethod()->ShowImeIfNeeded(); 983 GetInputMethod()->ShowImeIfNeeded();
979 } 984 }
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
1076 } 1081 }
1077 } 1082 }
1078 1083
1079 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_) 1084 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_)
1080 return; 1085 return;
1081 1086
1082 selection_anchor_ = anchor_bound; 1087 selection_anchor_ = anchor_bound;
1083 selection_focus_ = focus_bound; 1088 selection_focus_ = focus_bound;
1084 if (GetInputMethod()) 1089 if (GetInputMethod())
1085 GetInputMethod()->OnCaretBoundsChanged(this); 1090 GetInputMethod()->OnCaretBoundsChanged(this);
1086
1087 if (touch_editing_client_) {
1088 touch_editing_client_->OnSelectionOrCursorChanged(
1089 anchor_bound, focus_bound);
1090 }
1091 } 1091 }
1092 1092
1093 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 1093 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
1094 const gfx::Rect& src_subrect, 1094 const gfx::Rect& src_subrect,
1095 const gfx::Size& dst_size, 1095 const gfx::Size& dst_size,
1096 ReadbackRequestCallback& callback, 1096 ReadbackRequestCallback& callback,
1097 const SkColorType preferred_color_type) { 1097 const SkColorType preferred_color_type) {
1098 delegated_frame_host_->CopyFromCompositingSurface( 1098 delegated_frame_host_->CopyFromCompositingSurface(
1099 src_subrect, dst_size, callback, preferred_color_type); 1099 src_subrect, dst_size, callback, preferred_color_type);
1100 } 1100 }
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); 1171 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame");
1172 1172
1173 last_scroll_offset_ = frame->metadata.root_scroll_offset; 1173 last_scroll_offset_ = frame->metadata.root_scroll_offset;
1174 if (frame->delegated_frame_data) { 1174 if (frame->delegated_frame_data) {
1175 delegated_frame_host_->SwapDelegatedFrame( 1175 delegated_frame_host_->SwapDelegatedFrame(
1176 output_surface_id, 1176 output_surface_id,
1177 frame->delegated_frame_data.Pass(), 1177 frame->delegated_frame_data.Pass(),
1178 frame->metadata.device_scale_factor, 1178 frame->metadata.device_scale_factor,
1179 frame->metadata.latency_info, 1179 frame->metadata.latency_info,
1180 &frame->metadata.satisfies_sequences); 1180 &frame->metadata.satisfies_sequences);
1181 SelectionUpdated(frame->metadata.selection.is_editable,
1182 frame->metadata.selection.is_empty_text_form_control,
1183 ConvertSelectionBound(frame->metadata.selection.start),
1184 ConvertSelectionBound(frame->metadata.selection.end));
1181 return; 1185 return;
1182 } 1186 }
1183 1187
1184 if (frame->software_frame_data) { 1188 if (frame->software_frame_data) {
1185 DLOG(ERROR) << "Unable to use software frame in aura"; 1189 DLOG(ERROR) << "Unable to use software frame in aura";
1186 bad_message::ReceivedBadMessage(host_->GetProcess(), 1190 bad_message::ReceivedBadMessage(host_->GetProcess(),
1187 bad_message::RWHVA_SHARED_MEMORY); 1191 bad_message::RWHVA_SHARED_MEMORY);
1188 return; 1192 return;
1189 } 1193 }
1190 } 1194 }
1191 1195
1192 void RenderWidgetHostViewAura::DidStopFlinging() { 1196 void RenderWidgetHostViewAura::DidStopFlinging() {
1193 if (touch_editing_client_) 1197 selection_controller_client_->OnScrollCompleted();
1194 touch_editing_client_->DidStopFlinging();
1195 } 1198 }
1196 1199
1197 #if defined(OS_WIN) 1200 #if defined(OS_WIN)
1198 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( 1201 void RenderWidgetHostViewAura::SetParentNativeViewAccessible(
1199 gfx::NativeViewAccessible accessible_parent) { 1202 gfx::NativeViewAccessible accessible_parent) {
1200 } 1203 }
1201 1204
1202 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() 1205 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin()
1203 const { 1206 const {
1204 if (legacy_render_widget_host_HWND_) { 1207 if (legacy_render_widget_host_HWND_) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1264 InputEventAckState ack_result) { 1267 InputEventAckState ack_result) {
1265 if (overscroll_controller_) { 1268 if (overscroll_controller_) {
1266 overscroll_controller_->ReceivedEventACK( 1269 overscroll_controller_->ReceivedEventACK(
1267 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); 1270 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result));
1268 } 1271 }
1269 } 1272 }
1270 1273
1271 void RenderWidgetHostViewAura::GestureEventAck( 1274 void RenderWidgetHostViewAura::GestureEventAck(
1272 const blink::WebGestureEvent& event, 1275 const blink::WebGestureEvent& event,
1273 InputEventAckState ack_result) { 1276 InputEventAckState ack_result) {
1274 if (touch_editing_client_)
1275 touch_editing_client_->GestureEventAck(event.type);
1276
1277 if (overscroll_controller_) { 1277 if (overscroll_controller_) {
1278 overscroll_controller_->ReceivedEventACK( 1278 overscroll_controller_->ReceivedEventACK(
1279 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); 1279 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result));
1280 } 1280 }
1281 } 1281 }
1282 1282
1283 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( 1283 void RenderWidgetHostViewAura::ProcessAckedTouchEvent(
1284 const TouchEventWithLatencyInfo& touch, 1284 const TouchEventWithLatencyInfo& touch,
1285 InputEventAckState ack_result) { 1285 InputEventAckState ack_result) {
1286 ScopedVector<ui::TouchEvent> events; 1286 ScopedVector<ui::TouchEvent> events;
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
1668 return gfx::Rect(origin.x(), 1668 return gfx::Rect(origin.x(),
1669 origin.y(), 1669 origin.y(),
1670 end.x() - origin.x(), 1670 end.x() - origin.x(),
1671 end.y() - origin.y()); 1671 end.y() - origin.y());
1672 } 1672 }
1673 1673
1674 return rect; 1674 return rect;
1675 } 1675 }
1676 1676
1677 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1677 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1678 gfx::Rect rect = 1678 return ConvertRectToScreen(
1679 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_); 1679 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_));
1680 return ConvertRectToScreen(rect);
1681 } 1680 }
1682 1681
1683 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( 1682 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(
1684 uint32 index, 1683 uint32 index,
1685 gfx::Rect* rect) const { 1684 gfx::Rect* rect) const {
1686 DCHECK(rect); 1685 DCHECK(rect);
1687 if (index >= composition_character_bounds_.size()) 1686 if (index >= composition_character_bounds_.size())
1688 return false; 1687 return false;
1689 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 1688 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
1690 return true; 1689 return true;
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
1857 const gfx::Point& location) { 1856 const gfx::Point& location) {
1858 return true; 1857 return true;
1859 } 1858 }
1860 1859
1861 bool RenderWidgetHostViewAura::CanFocus() { 1860 bool RenderWidgetHostViewAura::CanFocus() {
1862 return popup_type_ == blink::WebPopupTypeNone; 1861 return popup_type_ == blink::WebPopupTypeNone;
1863 } 1862 }
1864 1863
1865 void RenderWidgetHostViewAura::OnCaptureLost() { 1864 void RenderWidgetHostViewAura::OnCaptureLost() {
1866 host_->LostCapture(); 1865 host_->LostCapture();
1867 if (touch_editing_client_)
1868 touch_editing_client_->EndTouchEditing(false);
1869 } 1866 }
1870 1867
1871 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) { 1868 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) {
1872 NOTREACHED(); 1869 NOTREACHED();
1873 } 1870 }
1874 1871
1875 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( 1872 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged(
1876 float device_scale_factor) { 1873 float device_scale_factor) {
1877 if (!host_ || !window_->GetRootWindow()) 1874 if (!host_ || !window_->GetRootWindow())
1878 return; 1875 return;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1941 } 1938 }
1942 1939
1943 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { 1940 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const {
1944 } 1941 }
1945 1942
1946 //////////////////////////////////////////////////////////////////////////////// 1943 ////////////////////////////////////////////////////////////////////////////////
1947 // RenderWidgetHostViewAura, ui::EventHandler implementation: 1944 // RenderWidgetHostViewAura, ui::EventHandler implementation:
1948 1945
1949 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { 1946 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
1950 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); 1947 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent");
1951 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
1952 return;
1953 1948
1954 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { 1949 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
1955 popup_child_host_view_->OnKeyEvent(event); 1950 popup_child_host_view_->OnKeyEvent(event);
1956 if (event->handled()) 1951 if (event->handled())
1957 return; 1952 return;
1958 } 1953 }
1959 1954
1960 // We need to handle the Escape key for Pepper Flash. 1955 // We need to handle the Escape key for Pepper Flash.
1961 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { 1956 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) {
1962 // Focus the window we were created from. 1957 // Focus the window we were created from.
(...skipping 26 matching lines...) Expand all
1989 // We don't have to communicate with an input method here. 1984 // We don't have to communicate with an input method here.
1990 NativeWebKeyboardEvent webkit_event(*event); 1985 NativeWebKeyboardEvent webkit_event(*event);
1991 ForwardKeyboardEvent(webkit_event); 1986 ForwardKeyboardEvent(webkit_event);
1992 } 1987 }
1993 event->SetHandled(); 1988 event->SetHandled();
1994 } 1989 }
1995 1990
1996 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { 1991 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) {
1997 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent"); 1992 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent");
1998 1993
1999 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
2000 return;
2001
2002 if (mouse_locked_) { 1994 if (mouse_locked_) {
2003 aura::client::CursorClient* cursor_client = 1995 aura::client::CursorClient* cursor_client =
2004 aura::client::GetCursorClient(window_->GetRootWindow()); 1996 aura::client::GetCursorClient(window_->GetRootWindow());
2005 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); 1997 DCHECK(!cursor_client || !cursor_client->IsCursorVisible());
2006 1998
2007 if (event->type() == ui::ET_MOUSEWHEEL) { 1999 if (event->type() == ui::ET_MOUSEWHEEL) {
2008 blink::WebMouseWheelEvent mouse_wheel_event = 2000 blink::WebMouseWheelEvent mouse_wheel_event =
2009 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); 2001 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event));
2010 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) 2002 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0)
2011 host_->ForwardWheelEvent(mouse_wheel_event); 2003 host_->ForwardWheelEvent(mouse_wheel_event);
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
2155 event->ConvertLocationToTarget(window_, window_->parent()); 2147 event->ConvertLocationToTarget(window_, window_->parent());
2156 window_->parent()->delegate()->OnMouseEvent(event); 2148 window_->parent()->delegate()->OnMouseEvent(event);
2157 } 2149 }
2158 2150
2159 if (!IsXButtonUpEvent(event)) 2151 if (!IsXButtonUpEvent(event))
2160 event->SetHandled(); 2152 event->SetHandled();
2161 } 2153 }
2162 2154
2163 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { 2155 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
2164 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); 2156 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent");
2165 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
2166 return;
2167 2157
2168 if (event->type() == ui::ET_SCROLL) { 2158 if (event->type() == ui::ET_SCROLL) {
2169 #if !defined(OS_WIN) 2159 #if !defined(OS_WIN)
2170 // TODO(ananta) 2160 // TODO(ananta)
2171 // Investigate if this is true for Windows 8 Metro ASH as well. 2161 // Investigate if this is true for Windows 8 Metro ASH as well.
2172 if (event->finger_count() != 2) 2162 if (event->finger_count() != 2)
2173 return; 2163 return;
2174 #endif 2164 #endif
2175 blink::WebGestureEvent gesture_event = 2165 blink::WebGestureEvent gesture_event =
2176 MakeWebGestureEventFlingCancel(); 2166 MakeWebGestureEventFlingCancel();
2177 host_->ForwardGestureEvent(gesture_event); 2167 host_->ForwardGestureEvent(gesture_event);
2178 blink::WebMouseWheelEvent mouse_wheel_event = 2168 blink::WebMouseWheelEvent mouse_wheel_event =
2179 MakeWebMouseWheelEvent(*event); 2169 MakeWebMouseWheelEvent(*event);
2180 host_->ForwardWheelEvent(mouse_wheel_event); 2170 host_->ForwardWheelEvent(mouse_wheel_event);
2181 RecordAction(base::UserMetricsAction("TrackpadScroll")); 2171 RecordAction(base::UserMetricsAction("TrackpadScroll"));
2182 } else if (event->type() == ui::ET_SCROLL_FLING_START || 2172 } else if (event->type() == ui::ET_SCROLL_FLING_START ||
2183 event->type() == ui::ET_SCROLL_FLING_CANCEL) { 2173 event->type() == ui::ET_SCROLL_FLING_CANCEL) {
2184 blink::WebGestureEvent gesture_event = MakeWebGestureEvent(*event); 2174 blink::WebGestureEvent gesture_event = MakeWebGestureEvent(*event);
2185 host_->ForwardGestureEvent(gesture_event); 2175 host_->ForwardGestureEvent(gesture_event);
2186 if (event->type() == ui::ET_SCROLL_FLING_START) 2176 if (event->type() == ui::ET_SCROLL_FLING_START)
2187 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); 2177 RecordAction(base::UserMetricsAction("TrackpadScrollFling"));
2188 } 2178 }
2189 2179
2190 event->SetHandled(); 2180 event->SetHandled();
2191 } 2181 }
2192 2182
2193 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { 2183 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
2194 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); 2184 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent");
2195 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) 2185
2196 return; 2186 bool had_no_pointer = !pointer_state_.GetPointerCount();
2197 2187
2198 // Update the touch event first. 2188 // Update the touch event first.
2199 if (!pointer_state_.OnTouch(*event)) { 2189 if (!pointer_state_.OnTouch(*event)) {
2200 event->StopPropagation(); 2190 event->StopPropagation();
2201 return; 2191 return;
2202 } 2192 }
2203 2193
2204 blink::WebTouchEvent touch_event = ui::CreateWebTouchEventFromMotionEvent( 2194 blink::WebTouchEvent touch_event;
2205 pointer_state_, event->may_cause_scrolling()); 2195 bool handled = selection_controller_->WillHandleTouchEvent(pointer_state_);
2196 if (handled) {
2197 event->SetHandled();
2198 } else {
2199 touch_event = ui::CreateWebTouchEventFromMotionEvent(
2200 pointer_state_, event->may_cause_scrolling());
2201 }
2206 pointer_state_.CleanupRemovedTouchPoints(*event); 2202 pointer_state_.CleanupRemovedTouchPoints(*event);
2207 2203
2204 if (handled)
2205 return;
2206
2207 if (had_no_pointer)
2208 selection_controller_client_->OnTouchDown();
2209 if (!pointer_state_.GetPointerCount())
2210 selection_controller_client_->OnTouchUp();
2211
2208 // It is important to always mark events as being handled asynchronously when 2212 // It is important to always mark events as being handled asynchronously when
2209 // they are forwarded. This ensures that the current event does not get 2213 // they are forwarded. This ensures that the current event does not get
2210 // processed by the gesture recognizer before events currently awaiting 2214 // processed by the gesture recognizer before events currently awaiting
2211 // dispatch in the touch queue. 2215 // dispatch in the touch queue.
2212 event->DisableSynchronousHandling(); 2216 event->DisableSynchronousHandling();
2213 2217
2214 // Set unchanged touch point to StateStationary for touchmove and 2218 // Set unchanged touch point to StateStationary for touchmove and
2215 // touchcancel to make sure only send one ack per WebTouchEvent. 2219 // touchcancel to make sure only send one ack per WebTouchEvent.
2216 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); 2220 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id());
2217 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); 2221 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency());
2218 } 2222 }
2219 2223
2220 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { 2224 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
2221 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); 2225 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent");
2226
2222 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 2227 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
2223 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 2228 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
2224 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { 2229 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) {
2225 event->SetHandled(); 2230 event->SetHandled();
2226 return; 2231 return;
2227 } 2232 }
2228 2233
2229 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) 2234 HandleGestureForTouchSelection(event);
2235 if (event->handled())
2230 return; 2236 return;
2231 2237
2232 // Confirm existing composition text on TAP gesture, to make sure the input 2238 // Confirm existing composition text on TAP gesture, to make sure the input
2233 // caret won't be moved with an ongoing composition text. 2239 // caret won't be moved with an ongoing composition text.
2234 if (event->type() == ui::ET_GESTURE_TAP) 2240 if (event->type() == ui::ET_GESTURE_TAP)
2235 FinishImeCompositionSession(); 2241 FinishImeCompositionSession();
2236 2242
2237 blink::WebGestureEvent gesture = MakeWebGestureEvent(*event); 2243 blink::WebGestureEvent gesture = MakeWebGestureEvent(*event);
2238 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { 2244 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
2239 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an 2245 // 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
2316 host_->GetRootBrowserAccessibilityManager(); 2322 host_->GetRootBrowserAccessibilityManager();
2317 if (manager) 2323 if (manager)
2318 manager->OnWindowFocused(); 2324 manager->OnWindowFocused();
2319 } else if (window_ == lost_focus) { 2325 } else if (window_ == lost_focus) {
2320 host_->SetActive(false); 2326 host_->SetActive(false);
2321 host_->Blur(); 2327 host_->Blur();
2322 2328
2323 DetachFromInputMethod(); 2329 DetachFromInputMethod();
2324 host_->SetInputMethodActive(false); 2330 host_->SetInputMethodActive(false);
2325 2331
2326 if (touch_editing_client_) 2332 selection_controller_->HideAndDisallowShowingAutomatically();
2327 touch_editing_client_->EndTouchEditing(false);
2328 2333
2329 if (overscroll_controller_) 2334 if (overscroll_controller_)
2330 overscroll_controller_->Cancel(); 2335 overscroll_controller_->Cancel();
2331 2336
2332 BrowserAccessibilityManager* manager = 2337 BrowserAccessibilityManager* manager =
2333 host_->GetRootBrowserAccessibilityManager(); 2338 host_->GetRootBrowserAccessibilityManager();
2334 if (manager) 2339 if (manager)
2335 manager->OnWindowBlurred(); 2340 manager->OnWindowBlurred();
2336 2341
2337 // If we lose the focus while fullscreen, close the window; Pepper Flash 2342 // If we lose the focus while fullscreen, close the window; Pepper Flash
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved", 2379 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved",
2375 "new_origin", new_origin.ToString()); 2380 "new_origin", new_origin.ToString());
2376 2381
2377 UpdateScreenInfo(window_); 2382 UpdateScreenInfo(window_);
2378 } 2383 }
2379 2384
2380 //////////////////////////////////////////////////////////////////////////////// 2385 ////////////////////////////////////////////////////////////////////////////////
2381 // RenderWidgetHostViewAura, private: 2386 // RenderWidgetHostViewAura, private:
2382 2387
2383 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { 2388 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
2384 if (touch_editing_client_) 2389 selection_controller_.reset();
2385 touch_editing_client_->OnViewDestroyed(); 2390 selection_controller_client_.reset();
2386
2387 delegated_frame_host_.reset(); 2391 delegated_frame_host_.reset();
2388 window_observer_.reset(); 2392 window_observer_.reset();
2389 if (window_->GetHost()) 2393 if (window_->GetHost())
2390 window_->GetHost()->RemoveObserver(this); 2394 window_->GetHost()->RemoveObserver(this);
2391 UnlockMouse(); 2395 UnlockMouse();
2392 if (popup_parent_host_view_) { 2396 if (popup_parent_host_view_) {
2393 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || 2397 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL ||
2394 popup_parent_host_view_->popup_child_host_view_ == this); 2398 popup_parent_host_view_->popup_child_host_view_ == this);
2395 popup_parent_host_view_->popup_child_host_view_ = NULL; 2399 popup_parent_host_view_->popup_child_host_view_ = NULL;
2396 } 2400 }
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
2553 2557
2554 has_snapped_to_boundary_ = true; 2558 has_snapped_to_boundary_ = true;
2555 } 2559 }
2556 2560
2557 void RenderWidgetHostViewAura::OnShowContextMenu() { 2561 void RenderWidgetHostViewAura::OnShowContextMenu() {
2558 #if defined(OS_WIN) 2562 #if defined(OS_WIN)
2559 showing_context_menu_ = true; 2563 showing_context_menu_ = true;
2560 #endif 2564 #endif
2561 } 2565 }
2562 2566
2567 void RenderWidgetHostViewAura::SetSelectionControllerClientForTest(
2568 scoped_ptr<TouchSelectionControllerClientAura> client) {
2569 selection_controller_client_.swap(client);
2570 CreateSelectionController();
2571 }
2572
2563 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { 2573 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
2564 SnapToPhysicalPixelBoundary(); 2574 SnapToPhysicalPixelBoundary();
2565 // Don't recursively call SetBounds if this bounds update is the result of 2575 // Don't recursively call SetBounds if this bounds update is the result of
2566 // a Window::SetBoundsInternal call. 2576 // a Window::SetBoundsInternal call.
2567 if (!in_bounds_changed_) 2577 if (!in_bounds_changed_)
2568 window_->SetBounds(rect); 2578 window_->SetBounds(rect);
2569 host_->WasResized(); 2579 host_->WasResized();
2570 delegated_frame_host_->WasResized(); 2580 delegated_frame_host_->WasResized();
2571 if (touch_editing_client_) {
2572 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_,
2573 selection_focus_);
2574 }
2575 #if defined(OS_WIN) 2581 #if defined(OS_WIN)
2576 // Create the legacy dummy window which corresponds to the bounds of the 2582 // Create the legacy dummy window which corresponds to the bounds of the
2577 // webcontents. This will be passed as the container window for windowless 2583 // webcontents. This will be passed as the container window for windowless
2578 // plugins. 2584 // plugins.
2579 // Plugins like Flash assume the container window which is returned via the 2585 // Plugins like Flash assume the container window which is returned via the
2580 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. 2586 // NPNVnetscapeWindow property corresponds to the bounds of the webpage.
2581 // This is not true in Aura where we have only HWND which is the main Aura 2587 // This is not true in Aura where we have only HWND which is the main Aura
2582 // window. If we return this window to plugins like Flash then it causes the 2588 // window. If we return this window to plugins like Flash then it causes the
2583 // coordinate translations done by these plugins to break. 2589 // coordinate translations done by these plugins to break.
2584 // Additonally the legacy dummy window is needed for accessibility and for 2590 // Additonally the legacy dummy window is needed for accessibility and for
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2707 NativeWebKeyboardEvent copy_event(event); 2713 NativeWebKeyboardEvent copy_event(event);
2708 copy_event.match_edit_command = true; 2714 copy_event.match_edit_command = true;
2709 host_->ForwardKeyboardEvent(copy_event); 2715 host_->ForwardKeyboardEvent(copy_event);
2710 return; 2716 return;
2711 } 2717 }
2712 #endif 2718 #endif
2713 2719
2714 host_->ForwardKeyboardEvent(event); 2720 host_->ForwardKeyboardEvent(event);
2715 } 2721 }
2716 2722
2723 void RenderWidgetHostViewAura::SelectionUpdated(bool is_editable,
2724 bool is_empty_text_form_control,
2725 const ui::SelectionBound& start,
2726 const ui::SelectionBound& end) {
2727 selection_controller_->OnSelectionEditable(is_editable);
2728 selection_controller_->OnSelectionEmpty(is_empty_text_form_control);
2729 selection_controller_->OnSelectionBoundsChanged(start, end);
2730 }
2731
2732 void RenderWidgetHostViewAura::CreateSelectionController() {
2733 ui::TouchSelectionController::Config tsc_config;
2734 tsc_config.tap_timeout = base::TimeDelta::FromMilliseconds(
2735 ui::GestureConfiguration::GetInstance()->show_press_delay_in_ms());
2736 tsc_config.tap_slop = ui::GestureConfiguration::GetInstance()
2737 ->max_touch_move_in_pixels_for_click();
2738 tsc_config.show_on_tap_for_empty_editable = true;
2739 tsc_config.enable_longpress_drag_selection = false;
2740 selection_controller_.reset(new ui::TouchSelectionController(
2741 selection_controller_client_.get(), tsc_config));
2742 }
2743
2744 void RenderWidgetHostViewAura::HandleGestureForTouchSelection(
2745 ui::GestureEvent* event) {
2746 switch (event->type()) {
2747 case ui::ET_GESTURE_LONG_PRESS:
2748 if (selection_controller_->WillHandleLongPressEvent(
2749 base::TimeTicks() + event->time_stamp(), event->location_f())) {
2750 event->SetHandled();
2751 }
2752 break;
2753 case ui::ET_GESTURE_TAP:
2754 if (selection_controller_->WillHandleTapEvent(event->location_f()))
2755 event->SetHandled();
2756 break;
2757 case ui::ET_GESTURE_SCROLL_BEGIN:
2758 selection_controller_client_->OnScrollStarted();
2759 break;
2760 case ui::ET_GESTURE_SCROLL_END:
2761 selection_controller_client_->OnScrollCompleted();
2762 break;
2763 default:
2764 break;
2765 }
2766 }
2767
2717 //////////////////////////////////////////////////////////////////////////////// 2768 ////////////////////////////////////////////////////////////////////////////////
2718 // DelegatedFrameHost, public: 2769 // DelegatedFrameHost, public:
2719 2770
2720 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { 2771 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const {
2721 return window_->layer(); 2772 return window_->layer();
2722 } 2773 }
2723 2774
2724 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { 2775 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const {
2725 return !host_->is_hidden(); 2776 return !host_->is_hidden();
2726 } 2777 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2793 2844
2794 //////////////////////////////////////////////////////////////////////////////// 2845 ////////////////////////////////////////////////////////////////////////////////
2795 // RenderWidgetHostViewBase, public: 2846 // RenderWidgetHostViewBase, public:
2796 2847
2797 // static 2848 // static
2798 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2849 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2799 GetScreenInfoForWindow(results, NULL); 2850 GetScreenInfoForWindow(results, NULL);
2800 } 2851 }
2801 2852
2802 } // namespace content 2853 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698