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

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 blink issue fixed: r200194 Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/browser/renderer_host/render_widget_host_view_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 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames, 499 IPC_MESSAGE_HANDLER(ViewHostMsg_SetNeedsBeginFrames,
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 if (text_input_type_ != params.type || 957 if (text_input_type_ != params.type ||
951 text_input_mode_ != params.mode || 958 text_input_mode_ != params.mode ||
952 can_compose_inline_ != params.can_compose_inline || 959 can_compose_inline_ != params.can_compose_inline ||
953 text_input_flags_ != params.flags) { 960 text_input_flags_ != params.flags) {
954 text_input_type_ = params.type; 961 text_input_type_ = params.type;
955 text_input_mode_ = params.mode; 962 text_input_mode_ = params.mode;
956 can_compose_inline_ = params.can_compose_inline; 963 can_compose_inline_ = params.can_compose_inline;
957 text_input_flags_ = params.flags; 964 text_input_flags_ = params.flags;
958 if (GetInputMethod()) 965 if (GetInputMethod())
959 GetInputMethod()->OnTextInputTypeChanged(this); 966 GetInputMethod()->OnTextInputTypeChanged(this);
960 if (touch_editing_client_)
961 touch_editing_client_->OnTextInputTypeChanged(text_input_type_);
962 } 967 }
963 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { 968 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) {
964 if (GetInputMethod()) 969 if (GetInputMethod())
965 GetInputMethod()->ShowImeIfNeeded(); 970 GetInputMethod()->ShowImeIfNeeded();
966 } 971 }
967 } 972 }
968 973
969 void RenderWidgetHostViewAura::ImeCancelComposition() { 974 void RenderWidgetHostViewAura::ImeCancelComposition() {
970 if (GetInputMethod()) 975 if (GetInputMethod())
971 GetInputMethod()->CancelComposition(this); 976 GetInputMethod()->CancelComposition(this);
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
1063 } 1068 }
1064 } 1069 }
1065 1070
1066 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_) 1071 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_)
1067 return; 1072 return;
1068 1073
1069 selection_anchor_ = anchor_bound; 1074 selection_anchor_ = anchor_bound;
1070 selection_focus_ = focus_bound; 1075 selection_focus_ = focus_bound;
1071 if (GetInputMethod()) 1076 if (GetInputMethod())
1072 GetInputMethod()->OnCaretBoundsChanged(this); 1077 GetInputMethod()->OnCaretBoundsChanged(this);
1073
1074 if (touch_editing_client_) {
1075 touch_editing_client_->OnSelectionOrCursorChanged(
1076 anchor_bound, focus_bound);
1077 }
1078 } 1078 }
1079 1079
1080 void RenderWidgetHostViewAura::CopyFromCompositingSurface( 1080 void RenderWidgetHostViewAura::CopyFromCompositingSurface(
1081 const gfx::Rect& src_subrect, 1081 const gfx::Rect& src_subrect,
1082 const gfx::Size& dst_size, 1082 const gfx::Size& dst_size,
1083 ReadbackRequestCallback& callback, 1083 ReadbackRequestCallback& callback,
1084 const SkColorType preferred_color_type) { 1084 const SkColorType preferred_color_type) {
1085 delegated_frame_host_->CopyFromCompositingSurface( 1085 delegated_frame_host_->CopyFromCompositingSurface(
1086 src_subrect, dst_size, callback, preferred_color_type); 1086 src_subrect, dst_size, callback, preferred_color_type);
1087 } 1087 }
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
1157 scoped_ptr<cc::CompositorFrame> frame) { 1157 scoped_ptr<cc::CompositorFrame> frame) {
1158 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); 1158 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame");
1159 1159
1160 last_scroll_offset_ = frame->metadata.root_scroll_offset; 1160 last_scroll_offset_ = frame->metadata.root_scroll_offset;
1161 if (!frame->delegated_frame_data) 1161 if (!frame->delegated_frame_data)
1162 return; 1162 return;
1163 delegated_frame_host_->SwapDelegatedFrame( 1163 delegated_frame_host_->SwapDelegatedFrame(
1164 output_surface_id, frame->delegated_frame_data.Pass(), 1164 output_surface_id, frame->delegated_frame_data.Pass(),
1165 frame->metadata.device_scale_factor, frame->metadata.latency_info, 1165 frame->metadata.device_scale_factor, frame->metadata.latency_info,
1166 &frame->metadata.satisfies_sequences); 1166 &frame->metadata.satisfies_sequences);
1167 SelectionUpdated(frame->metadata.selection.is_editable,
1168 frame->metadata.selection.is_empty_text_form_control,
1169 ConvertSelectionBound(frame->metadata.selection.start),
1170 ConvertSelectionBound(frame->metadata.selection.end));
1167 } 1171 }
1168 1172
1169 void RenderWidgetHostViewAura::DidStopFlinging() { 1173 void RenderWidgetHostViewAura::DidStopFlinging() {
1170 if (touch_editing_client_) 1174 selection_controller_client_->OnScrollCompleted();
1171 touch_editing_client_->DidStopFlinging();
1172 } 1175 }
1173 1176
1174 #if defined(OS_WIN) 1177 #if defined(OS_WIN)
1175 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( 1178 void RenderWidgetHostViewAura::SetParentNativeViewAccessible(
1176 gfx::NativeViewAccessible accessible_parent) { 1179 gfx::NativeViewAccessible accessible_parent) {
1177 } 1180 }
1178 1181
1179 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() 1182 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin()
1180 const { 1183 const {
1181 if (legacy_render_widget_host_HWND_) { 1184 if (legacy_render_widget_host_HWND_) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
1241 InputEventAckState ack_result) { 1244 InputEventAckState ack_result) {
1242 if (overscroll_controller_) { 1245 if (overscroll_controller_) {
1243 overscroll_controller_->ReceivedEventACK( 1246 overscroll_controller_->ReceivedEventACK(
1244 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); 1247 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result));
1245 } 1248 }
1246 } 1249 }
1247 1250
1248 void RenderWidgetHostViewAura::GestureEventAck( 1251 void RenderWidgetHostViewAura::GestureEventAck(
1249 const blink::WebGestureEvent& event, 1252 const blink::WebGestureEvent& event,
1250 InputEventAckState ack_result) { 1253 InputEventAckState ack_result) {
1251 if (touch_editing_client_)
1252 touch_editing_client_->GestureEventAck(event.type);
1253
1254 if (overscroll_controller_) { 1254 if (overscroll_controller_) {
1255 overscroll_controller_->ReceivedEventACK( 1255 overscroll_controller_->ReceivedEventACK(
1256 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); 1256 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result));
1257 } 1257 }
1258 } 1258 }
1259 1259
1260 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( 1260 void RenderWidgetHostViewAura::ProcessAckedTouchEvent(
1261 const TouchEventWithLatencyInfo& touch, 1261 const TouchEventWithLatencyInfo& touch,
1262 InputEventAckState ack_result) { 1262 InputEventAckState ack_result) {
1263 ScopedVector<ui::TouchEvent> events; 1263 ScopedVector<ui::TouchEvent> events;
(...skipping 380 matching lines...) Expand 10 before | Expand all | Expand 10 after
1644 return gfx::Rect(origin.x(), 1644 return gfx::Rect(origin.x(),
1645 origin.y(), 1645 origin.y(),
1646 end.x() - origin.x(), 1646 end.x() - origin.x(),
1647 end.y() - origin.y()); 1647 end.y() - origin.y());
1648 } 1648 }
1649 1649
1650 return rect; 1650 return rect;
1651 } 1651 }
1652 1652
1653 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { 1653 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const {
1654 gfx::Rect rect = 1654 return ConvertRectToScreen(
1655 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_); 1655 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_));
1656 return ConvertRectToScreen(rect);
1657 } 1656 }
1658 1657
1659 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( 1658 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds(
1660 uint32 index, 1659 uint32 index,
1661 gfx::Rect* rect) const { 1660 gfx::Rect* rect) const {
1662 DCHECK(rect); 1661 DCHECK(rect);
1663 if (index >= composition_character_bounds_.size()) 1662 if (index >= composition_character_bounds_.size())
1664 return false; 1663 return false;
1665 *rect = ConvertRectToScreen(composition_character_bounds_[index]); 1664 *rect = ConvertRectToScreen(composition_character_bounds_[index]);
1666 return true; 1665 return true;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1830 const gfx::Point& location) { 1829 const gfx::Point& location) {
1831 return true; 1830 return true;
1832 } 1831 }
1833 1832
1834 bool RenderWidgetHostViewAura::CanFocus() { 1833 bool RenderWidgetHostViewAura::CanFocus() {
1835 return popup_type_ == blink::WebPopupTypeNone; 1834 return popup_type_ == blink::WebPopupTypeNone;
1836 } 1835 }
1837 1836
1838 void RenderWidgetHostViewAura::OnCaptureLost() { 1837 void RenderWidgetHostViewAura::OnCaptureLost() {
1839 host_->LostCapture(); 1838 host_->LostCapture();
1840 if (touch_editing_client_)
1841 touch_editing_client_->EndTouchEditing(false);
1842 } 1839 }
1843 1840
1844 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) { 1841 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) {
1845 NOTREACHED(); 1842 NOTREACHED();
1846 } 1843 }
1847 1844
1848 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( 1845 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged(
1849 float device_scale_factor) { 1846 float device_scale_factor) {
1850 if (!host_ || !window_->GetRootWindow()) 1847 if (!host_ || !window_->GetRootWindow())
1851 return; 1848 return;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 } 1911 }
1915 1912
1916 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { 1913 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const {
1917 } 1914 }
1918 1915
1919 //////////////////////////////////////////////////////////////////////////////// 1916 ////////////////////////////////////////////////////////////////////////////////
1920 // RenderWidgetHostViewAura, ui::EventHandler implementation: 1917 // RenderWidgetHostViewAura, ui::EventHandler implementation:
1921 1918
1922 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { 1919 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) {
1923 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); 1920 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent");
1924 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
1925 return;
1926 1921
1927 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { 1922 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) {
1928 popup_child_host_view_->OnKeyEvent(event); 1923 popup_child_host_view_->OnKeyEvent(event);
1929 if (event->handled()) 1924 if (event->handled())
1930 return; 1925 return;
1931 } 1926 }
1932 1927
1933 // We need to handle the Escape key for Pepper Flash. 1928 // We need to handle the Escape key for Pepper Flash.
1934 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { 1929 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) {
1935 // Focus the window we were created from. 1930 // Focus the window we were created from.
(...skipping 26 matching lines...) Expand all
1962 // We don't have to communicate with an input method here. 1957 // We don't have to communicate with an input method here.
1963 NativeWebKeyboardEvent webkit_event(*event); 1958 NativeWebKeyboardEvent webkit_event(*event);
1964 ForwardKeyboardEvent(webkit_event); 1959 ForwardKeyboardEvent(webkit_event);
1965 } 1960 }
1966 event->SetHandled(); 1961 event->SetHandled();
1967 } 1962 }
1968 1963
1969 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { 1964 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) {
1970 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent"); 1965 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent");
1971 1966
1972 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
1973 return;
1974
1975 if (mouse_locked_) { 1967 if (mouse_locked_) {
1976 aura::client::CursorClient* cursor_client = 1968 aura::client::CursorClient* cursor_client =
1977 aura::client::GetCursorClient(window_->GetRootWindow()); 1969 aura::client::GetCursorClient(window_->GetRootWindow());
1978 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); 1970 DCHECK(!cursor_client || !cursor_client->IsCursorVisible());
1979 1971
1980 if (event->type() == ui::ET_MOUSEWHEEL) { 1972 if (event->type() == ui::ET_MOUSEWHEEL) {
1981 blink::WebMouseWheelEvent mouse_wheel_event = 1973 blink::WebMouseWheelEvent mouse_wheel_event =
1982 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); 1974 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event));
1983 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) 1975 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0)
1984 host_->ForwardWheelEvent(mouse_wheel_event); 1976 host_->ForwardWheelEvent(mouse_wheel_event);
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
2135 2127
2136 uint32_t RenderWidgetHostViewAura::SurfaceIdNamespaceAtPoint( 2128 uint32_t RenderWidgetHostViewAura::SurfaceIdNamespaceAtPoint(
2137 const gfx::Point& point, 2129 const gfx::Point& point,
2138 gfx::Point* transformed_point) { 2130 gfx::Point* transformed_point) {
2139 return cc::SurfaceIdAllocator::NamespaceForId( 2131 return cc::SurfaceIdAllocator::NamespaceForId(
2140 delegated_frame_host_->SurfaceIdAtPoint(point, transformed_point)); 2132 delegated_frame_host_->SurfaceIdAtPoint(point, transformed_point));
2141 } 2133 }
2142 2134
2143 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { 2135 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) {
2144 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); 2136 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent");
2145 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event))
2146 return;
2147 2137
2148 if (event->type() == ui::ET_SCROLL) { 2138 if (event->type() == ui::ET_SCROLL) {
2149 #if !defined(OS_WIN) 2139 #if !defined(OS_WIN)
2150 // TODO(ananta) 2140 // TODO(ananta)
2151 // Investigate if this is true for Windows 8 Metro ASH as well. 2141 // Investigate if this is true for Windows 8 Metro ASH as well.
2152 if (event->finger_count() != 2) 2142 if (event->finger_count() != 2)
2153 return; 2143 return;
2154 #endif 2144 #endif
2155 blink::WebGestureEvent gesture_event = 2145 blink::WebGestureEvent gesture_event =
2156 MakeWebGestureEventFlingCancel(); 2146 MakeWebGestureEventFlingCancel();
2157 host_->ForwardGestureEvent(gesture_event); 2147 host_->ForwardGestureEvent(gesture_event);
2158 blink::WebMouseWheelEvent mouse_wheel_event = 2148 blink::WebMouseWheelEvent mouse_wheel_event =
2159 MakeWebMouseWheelEvent(*event); 2149 MakeWebMouseWheelEvent(*event);
2160 host_->ForwardWheelEvent(mouse_wheel_event); 2150 host_->ForwardWheelEvent(mouse_wheel_event);
2161 RecordAction(base::UserMetricsAction("TrackpadScroll")); 2151 RecordAction(base::UserMetricsAction("TrackpadScroll"));
2162 } else if (event->type() == ui::ET_SCROLL_FLING_START || 2152 } else if (event->type() == ui::ET_SCROLL_FLING_START ||
2163 event->type() == ui::ET_SCROLL_FLING_CANCEL) { 2153 event->type() == ui::ET_SCROLL_FLING_CANCEL) {
2164 blink::WebGestureEvent gesture_event = MakeWebGestureEvent(*event); 2154 blink::WebGestureEvent gesture_event = MakeWebGestureEvent(*event);
2165 host_->ForwardGestureEvent(gesture_event); 2155 host_->ForwardGestureEvent(gesture_event);
2166 if (event->type() == ui::ET_SCROLL_FLING_START) 2156 if (event->type() == ui::ET_SCROLL_FLING_START)
2167 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); 2157 RecordAction(base::UserMetricsAction("TrackpadScrollFling"));
2168 } 2158 }
2169 2159
2170 event->SetHandled(); 2160 event->SetHandled();
2171 } 2161 }
2172 2162
2173 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { 2163 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) {
2174 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); 2164 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent");
2175 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) 2165
2176 return; 2166 bool had_no_pointer = !pointer_state_.GetPointerCount();
2177 2167
2178 // Update the touch event first. 2168 // Update the touch event first.
2179 if (!pointer_state_.OnTouch(*event)) { 2169 if (!pointer_state_.OnTouch(*event)) {
2180 event->StopPropagation(); 2170 event->StopPropagation();
2181 return; 2171 return;
2182 } 2172 }
2183 2173
2184 blink::WebTouchEvent touch_event = ui::CreateWebTouchEventFromMotionEvent( 2174 blink::WebTouchEvent touch_event;
2185 pointer_state_, event->may_cause_scrolling()); 2175 bool handled = selection_controller_->WillHandleTouchEvent(pointer_state_);
2176 if (handled) {
2177 event->SetHandled();
2178 } else {
2179 touch_event = ui::CreateWebTouchEventFromMotionEvent(
2180 pointer_state_, event->may_cause_scrolling());
2181 }
2186 pointer_state_.CleanupRemovedTouchPoints(*event); 2182 pointer_state_.CleanupRemovedTouchPoints(*event);
2187 2183
2184 if (handled)
2185 return;
2186
2187 if (had_no_pointer)
2188 selection_controller_client_->OnTouchDown();
2189 if (!pointer_state_.GetPointerCount())
2190 selection_controller_client_->OnTouchUp();
2191
2188 // It is important to always mark events as being handled asynchronously when 2192 // It is important to always mark events as being handled asynchronously when
2189 // they are forwarded. This ensures that the current event does not get 2193 // they are forwarded. This ensures that the current event does not get
2190 // processed by the gesture recognizer before events currently awaiting 2194 // processed by the gesture recognizer before events currently awaiting
2191 // dispatch in the touch queue. 2195 // dispatch in the touch queue.
2192 event->DisableSynchronousHandling(); 2196 event->DisableSynchronousHandling();
2193 2197
2194 // Set unchanged touch point to StateStationary for touchmove and 2198 // Set unchanged touch point to StateStationary for touchmove and
2195 // touchcancel to make sure only send one ack per WebTouchEvent. 2199 // touchcancel to make sure only send one ack per WebTouchEvent.
2196 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); 2200 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id());
2197 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); 2201 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency());
2198 } 2202 }
2199 2203
2200 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { 2204 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) {
2201 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); 2205 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent");
2206
2202 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || 2207 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN ||
2203 event->type() == ui::ET_GESTURE_PINCH_UPDATE || 2208 event->type() == ui::ET_GESTURE_PINCH_UPDATE ||
2204 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { 2209 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) {
2205 event->SetHandled(); 2210 event->SetHandled();
2206 return; 2211 return;
2207 } 2212 }
2208 2213
2209 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) 2214 HandleGestureForTouchSelection(event);
2215 if (event->handled())
2210 return; 2216 return;
2211 2217
2212 // Confirm existing composition text on TAP gesture, to make sure the input 2218 // Confirm existing composition text on TAP gesture, to make sure the input
2213 // caret won't be moved with an ongoing composition text. 2219 // caret won't be moved with an ongoing composition text.
2214 if (event->type() == ui::ET_GESTURE_TAP) 2220 if (event->type() == ui::ET_GESTURE_TAP)
2215 FinishImeCompositionSession(); 2221 FinishImeCompositionSession();
2216 2222
2217 blink::WebGestureEvent gesture = MakeWebGestureEvent(*event); 2223 blink::WebGestureEvent gesture = MakeWebGestureEvent(*event);
2218 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { 2224 if (event->type() == ui::ET_GESTURE_TAP_DOWN) {
2219 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an 2225 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
2292 BrowserAccessibilityManager* manager = 2298 BrowserAccessibilityManager* manager =
2293 host_->GetRootBrowserAccessibilityManager(); 2299 host_->GetRootBrowserAccessibilityManager();
2294 if (manager) 2300 if (manager)
2295 manager->OnWindowFocused(); 2301 manager->OnWindowFocused();
2296 } else if (window_ == lost_focus) { 2302 } else if (window_ == lost_focus) {
2297 host_->SetActive(false); 2303 host_->SetActive(false);
2298 host_->Blur(); 2304 host_->Blur();
2299 2305
2300 DetachFromInputMethod(); 2306 DetachFromInputMethod();
2301 2307
2302 if (touch_editing_client_) 2308 selection_controller_->HideAndDisallowShowingAutomatically();
2303 touch_editing_client_->EndTouchEditing(false);
2304 2309
2305 if (overscroll_controller_) 2310 if (overscroll_controller_)
2306 overscroll_controller_->Cancel(); 2311 overscroll_controller_->Cancel();
2307 2312
2308 BrowserAccessibilityManager* manager = 2313 BrowserAccessibilityManager* manager =
2309 host_->GetRootBrowserAccessibilityManager(); 2314 host_->GetRootBrowserAccessibilityManager();
2310 if (manager) 2315 if (manager)
2311 manager->OnWindowBlurred(); 2316 manager->OnWindowBlurred();
2312 2317
2313 // If we lose the focus while fullscreen, close the window; Pepper Flash 2318 // If we lose the focus while fullscreen, close the window; Pepper Flash
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
2350 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved", 2355 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved",
2351 "new_origin", new_origin.ToString()); 2356 "new_origin", new_origin.ToString());
2352 2357
2353 UpdateScreenInfo(window_); 2358 UpdateScreenInfo(window_);
2354 } 2359 }
2355 2360
2356 //////////////////////////////////////////////////////////////////////////////// 2361 ////////////////////////////////////////////////////////////////////////////////
2357 // RenderWidgetHostViewAura, private: 2362 // RenderWidgetHostViewAura, private:
2358 2363
2359 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { 2364 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() {
2360 if (touch_editing_client_) 2365 selection_controller_.reset();
2361 touch_editing_client_->OnViewDestroyed(); 2366 selection_controller_client_.reset();
2362
2363 delegated_frame_host_.reset(); 2367 delegated_frame_host_.reset();
2364 window_observer_.reset(); 2368 window_observer_.reset();
2365 if (window_->GetHost()) 2369 if (window_->GetHost())
2366 window_->GetHost()->RemoveObserver(this); 2370 window_->GetHost()->RemoveObserver(this);
2367 UnlockMouse(); 2371 UnlockMouse();
2368 if (popup_parent_host_view_) { 2372 if (popup_parent_host_view_) {
2369 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || 2373 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL ||
2370 popup_parent_host_view_->popup_child_host_view_ == this); 2374 popup_parent_host_view_->popup_child_host_view_ == this);
2371 popup_parent_host_view_->popup_child_host_view_ = NULL; 2375 popup_parent_host_view_->popup_child_host_view_ = NULL;
2372 } 2376 }
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
2528 2532
2529 has_snapped_to_boundary_ = true; 2533 has_snapped_to_boundary_ = true;
2530 } 2534 }
2531 2535
2532 void RenderWidgetHostViewAura::OnShowContextMenu() { 2536 void RenderWidgetHostViewAura::OnShowContextMenu() {
2533 #if defined(OS_WIN) 2537 #if defined(OS_WIN)
2534 showing_context_menu_ = true; 2538 showing_context_menu_ = true;
2535 #endif 2539 #endif
2536 } 2540 }
2537 2541
2542 void RenderWidgetHostViewAura::SetSelectionControllerClientForTest(
2543 scoped_ptr<TouchSelectionControllerClientAura> client) {
2544 selection_controller_client_.swap(client);
2545 CreateSelectionController();
2546 }
2547
2538 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { 2548 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
2539 SnapToPhysicalPixelBoundary(); 2549 SnapToPhysicalPixelBoundary();
2540 // Don't recursively call SetBounds if this bounds update is the result of 2550 // Don't recursively call SetBounds if this bounds update is the result of
2541 // a Window::SetBoundsInternal call. 2551 // a Window::SetBoundsInternal call.
2542 if (!in_bounds_changed_) 2552 if (!in_bounds_changed_)
2543 window_->SetBounds(rect); 2553 window_->SetBounds(rect);
2544 host_->WasResized(); 2554 host_->WasResized();
2545 delegated_frame_host_->WasResized(); 2555 delegated_frame_host_->WasResized();
2546 if (touch_editing_client_) {
2547 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_,
2548 selection_focus_);
2549 }
2550 #if defined(OS_WIN) 2556 #if defined(OS_WIN)
2551 // Create the legacy dummy window which corresponds to the bounds of the 2557 // Create the legacy dummy window which corresponds to the bounds of the
2552 // webcontents. This will be passed as the container window for windowless 2558 // webcontents. This will be passed as the container window for windowless
2553 // plugins. 2559 // plugins.
2554 // Plugins like Flash assume the container window which is returned via the 2560 // Plugins like Flash assume the container window which is returned via the
2555 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. 2561 // NPNVnetscapeWindow property corresponds to the bounds of the webpage.
2556 // This is not true in Aura where we have only HWND which is the main Aura 2562 // This is not true in Aura where we have only HWND which is the main Aura
2557 // window. If we return this window to plugins like Flash then it causes the 2563 // window. If we return this window to plugins like Flash then it causes the
2558 // coordinate translations done by these plugins to break. 2564 // coordinate translations done by these plugins to break.
2559 // Additonally the legacy dummy window is needed for accessibility and for 2565 // Additonally the legacy dummy window is needed for accessibility and for
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
2682 NativeWebKeyboardEvent copy_event(event); 2688 NativeWebKeyboardEvent copy_event(event);
2683 copy_event.match_edit_command = true; 2689 copy_event.match_edit_command = true;
2684 host_->ForwardKeyboardEvent(copy_event); 2690 host_->ForwardKeyboardEvent(copy_event);
2685 return; 2691 return;
2686 } 2692 }
2687 #endif 2693 #endif
2688 2694
2689 host_->ForwardKeyboardEvent(event); 2695 host_->ForwardKeyboardEvent(event);
2690 } 2696 }
2691 2697
2698 void RenderWidgetHostViewAura::SelectionUpdated(bool is_editable,
2699 bool is_empty_text_form_control,
2700 const ui::SelectionBound& start,
2701 const ui::SelectionBound& end) {
2702 selection_controller_->OnSelectionEditable(is_editable);
2703 selection_controller_->OnSelectionEmpty(is_empty_text_form_control);
2704 selection_controller_->OnSelectionBoundsChanged(start, end);
2705 }
2706
2707 void RenderWidgetHostViewAura::CreateSelectionController() {
2708 ui::TouchSelectionController::Config tsc_config;
2709 tsc_config.tap_timeout = base::TimeDelta::FromMilliseconds(
2710 ui::GestureConfiguration::GetInstance()->show_press_delay_in_ms());
2711 tsc_config.tap_slop = ui::GestureConfiguration::GetInstance()
2712 ->max_touch_move_in_pixels_for_click();
2713 tsc_config.show_on_tap_for_empty_editable = true;
2714 tsc_config.enable_longpress_drag_selection = false;
2715 selection_controller_.reset(new ui::TouchSelectionController(
2716 selection_controller_client_.get(), tsc_config));
2717 }
2718
2719 void RenderWidgetHostViewAura::HandleGestureForTouchSelection(
2720 ui::GestureEvent* event) {
2721 switch (event->type()) {
2722 case ui::ET_GESTURE_LONG_PRESS:
2723 if (selection_controller_->WillHandleLongPressEvent(
2724 base::TimeTicks() + event->time_stamp(), event->location_f())) {
2725 event->SetHandled();
2726 }
2727 break;
2728 case ui::ET_GESTURE_TAP:
2729 if (selection_controller_->WillHandleTapEvent(event->location_f()))
2730 event->SetHandled();
2731 break;
2732 case ui::ET_GESTURE_SCROLL_BEGIN:
2733 selection_controller_client_->OnScrollStarted();
2734 break;
2735 case ui::ET_GESTURE_SCROLL_END:
2736 selection_controller_client_->OnScrollCompleted();
2737 break;
2738 default:
2739 break;
2740 }
2741 }
2742
2692 //////////////////////////////////////////////////////////////////////////////// 2743 ////////////////////////////////////////////////////////////////////////////////
2693 // DelegatedFrameHost, public: 2744 // DelegatedFrameHost, public:
2694 2745
2695 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { 2746 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const {
2696 return window_->layer(); 2747 return window_->layer();
2697 } 2748 }
2698 2749
2699 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { 2750 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const {
2700 return !host_->is_hidden(); 2751 return !host_->is_hidden();
2701 } 2752 }
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2768 2819
2769 //////////////////////////////////////////////////////////////////////////////// 2820 ////////////////////////////////////////////////////////////////////////////////
2770 // RenderWidgetHostViewBase, public: 2821 // RenderWidgetHostViewBase, public:
2771 2822
2772 // static 2823 // static
2773 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 2824 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
2774 GetScreenInfoForWindow(results, NULL); 2825 GetScreenInfoForWindow(results, NULL);
2775 } 2826 }
2776 2827
2777 } // namespace content 2828 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | content/browser/web_contents/touch_editable_impl_aura.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698