OLD | NEW |
---|---|
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 Loading... | |
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 Loading... | |
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 Loading... | |
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 | |
490 ui::TouchSelectionController::Config tsc_config; | |
491 tsc_config.tap_timeout = base::TimeDelta::FromMilliseconds( | |
492 ui::GestureConfiguration::GetInstance()->show_press_delay_in_ms()); | |
493 tsc_config.tap_slop = ui::GestureConfiguration::GetInstance() | |
494 ->max_touch_move_in_pixels_for_click(); | |
495 tsc_config.show_on_tap_for_empty_editable = true; | |
496 tsc_config.enable_longpress_drag_selection = false; | |
497 selection_controller_.reset(new ui::TouchSelectionController( | |
498 selection_controller_client_.get(), tsc_config)); | |
483 } | 499 } |
484 | 500 |
485 //////////////////////////////////////////////////////////////////////////////// | 501 //////////////////////////////////////////////////////////////////////////////// |
486 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 502 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
487 | 503 |
488 bool RenderWidgetHostViewAura::OnMessageReceived( | 504 bool RenderWidgetHostViewAura::OnMessageReceived( |
489 const IPC::Message& message) { | 505 const IPC::Message& message) { |
490 bool handled = true; | 506 bool handled = true; |
491 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) | 507 IPC_BEGIN_MESSAGE_MAP(RenderWidgetHostViewAura, message) |
492 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC | 508 // TODO(kevers): Move to RenderWidgetHostViewImpl and consolidate IPC |
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
956 if (text_input_type_ != type || | 972 if (text_input_type_ != type || |
957 text_input_mode_ != input_mode || | 973 text_input_mode_ != input_mode || |
958 can_compose_inline_ != can_compose_inline || | 974 can_compose_inline_ != can_compose_inline || |
959 text_input_flags_ != flags) { | 975 text_input_flags_ != flags) { |
960 text_input_type_ = type; | 976 text_input_type_ = type; |
961 text_input_mode_ = input_mode; | 977 text_input_mode_ = input_mode; |
962 can_compose_inline_ = can_compose_inline; | 978 can_compose_inline_ = can_compose_inline; |
963 text_input_flags_ = flags; | 979 text_input_flags_ = flags; |
964 if (GetInputMethod()) | 980 if (GetInputMethod()) |
965 GetInputMethod()->OnTextInputTypeChanged(this); | 981 GetInputMethod()->OnTextInputTypeChanged(this); |
966 if (touch_editing_client_) | |
967 touch_editing_client_->OnTextInputTypeChanged(text_input_type_); | |
968 } | 982 } |
969 } | 983 } |
970 | 984 |
971 void RenderWidgetHostViewAura::OnTextInputStateChanged( | 985 void RenderWidgetHostViewAura::OnTextInputStateChanged( |
972 const ViewHostMsg_TextInputState_Params& params) { | 986 const ViewHostMsg_TextInputState_Params& params) { |
973 text_input_flags_ = params.flags; | 987 text_input_flags_ = params.flags; |
974 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { | 988 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { |
975 if (GetInputMethod()) | 989 if (GetInputMethod()) |
976 GetInputMethod()->ShowImeIfNeeded(); | 990 GetInputMethod()->ShowImeIfNeeded(); |
977 } | 991 } |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1074 } | 1088 } |
1075 } | 1089 } |
1076 | 1090 |
1077 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_) | 1091 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_) |
1078 return; | 1092 return; |
1079 | 1093 |
1080 selection_anchor_ = anchor_bound; | 1094 selection_anchor_ = anchor_bound; |
1081 selection_focus_ = focus_bound; | 1095 selection_focus_ = focus_bound; |
1082 if (GetInputMethod()) | 1096 if (GetInputMethod()) |
1083 GetInputMethod()->OnCaretBoundsChanged(this); | 1097 GetInputMethod()->OnCaretBoundsChanged(this); |
1084 | |
1085 if (touch_editing_client_) { | |
1086 touch_editing_client_->OnSelectionOrCursorChanged( | |
1087 anchor_bound, focus_bound); | |
1088 } | |
1089 } | 1098 } |
1090 | 1099 |
1091 void RenderWidgetHostViewAura::CopyFromCompositingSurface( | 1100 void RenderWidgetHostViewAura::CopyFromCompositingSurface( |
1092 const gfx::Rect& src_subrect, | 1101 const gfx::Rect& src_subrect, |
1093 const gfx::Size& dst_size, | 1102 const gfx::Size& dst_size, |
1094 ReadbackRequestCallback& callback, | 1103 ReadbackRequestCallback& callback, |
1095 const SkColorType preferred_color_type) { | 1104 const SkColorType preferred_color_type) { |
1096 delegated_frame_host_->CopyFromCompositingSurface( | 1105 delegated_frame_host_->CopyFromCompositingSurface( |
1097 src_subrect, dst_size, callback, preferred_color_type); | 1106 src_subrect, dst_size, callback, preferred_color_type); |
1098 } | 1107 } |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1168 scoped_ptr<cc::CompositorFrame> frame) { | 1177 scoped_ptr<cc::CompositorFrame> frame) { |
1169 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 1178 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
1170 | 1179 |
1171 last_scroll_offset_ = frame->metadata.root_scroll_offset; | 1180 last_scroll_offset_ = frame->metadata.root_scroll_offset; |
1172 if (frame->delegated_frame_data) { | 1181 if (frame->delegated_frame_data) { |
1173 delegated_frame_host_->SwapDelegatedFrame( | 1182 delegated_frame_host_->SwapDelegatedFrame( |
1174 output_surface_id, | 1183 output_surface_id, |
1175 frame->delegated_frame_data.Pass(), | 1184 frame->delegated_frame_data.Pass(), |
1176 frame->metadata.device_scale_factor, | 1185 frame->metadata.device_scale_factor, |
1177 frame->metadata.latency_info); | 1186 frame->metadata.latency_info); |
1187 SelectionUpdated(frame->metadata.selection.is_editable, | |
1188 frame->metadata.selection.is_empty_text_form_control, | |
1189 ConvertSelectionBound(frame->metadata.selection.start), | |
1190 ConvertSelectionBound(frame->metadata.selection.end)); | |
1178 return; | 1191 return; |
1179 } | 1192 } |
1180 | 1193 |
1181 if (frame->software_frame_data) { | 1194 if (frame->software_frame_data) { |
1182 DLOG(ERROR) << "Unable to use software frame in aura"; | 1195 DLOG(ERROR) << "Unable to use software frame in aura"; |
1183 bad_message::ReceivedBadMessage(host_->GetProcess(), | 1196 bad_message::ReceivedBadMessage(host_->GetProcess(), |
1184 bad_message::RWHVA_SHARED_MEMORY); | 1197 bad_message::RWHVA_SHARED_MEMORY); |
1185 return; | 1198 return; |
1186 } | 1199 } |
1187 } | 1200 } |
1188 | 1201 |
1189 void RenderWidgetHostViewAura::DidStopFlinging() { | 1202 void RenderWidgetHostViewAura::DidStopFlinging() { |
1190 if (touch_editing_client_) | 1203 selection_controller_client_->OnSelectionScrollCompleted(); |
1191 touch_editing_client_->DidStopFlinging(); | |
1192 } | 1204 } |
1193 | 1205 |
1194 #if defined(OS_WIN) | 1206 #if defined(OS_WIN) |
1195 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1207 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
1196 gfx::NativeViewAccessible accessible_parent) { | 1208 gfx::NativeViewAccessible accessible_parent) { |
1197 } | 1209 } |
1198 | 1210 |
1199 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() | 1211 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() |
1200 const { | 1212 const { |
1201 if (legacy_render_widget_host_HWND_) { | 1213 if (legacy_render_widget_host_HWND_) { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1261 InputEventAckState ack_result) { | 1273 InputEventAckState ack_result) { |
1262 if (overscroll_controller_) { | 1274 if (overscroll_controller_) { |
1263 overscroll_controller_->ReceivedEventACK( | 1275 overscroll_controller_->ReceivedEventACK( |
1264 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); | 1276 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); |
1265 } | 1277 } |
1266 } | 1278 } |
1267 | 1279 |
1268 void RenderWidgetHostViewAura::GestureEventAck( | 1280 void RenderWidgetHostViewAura::GestureEventAck( |
1269 const blink::WebGestureEvent& event, | 1281 const blink::WebGestureEvent& event, |
1270 InputEventAckState ack_result) { | 1282 InputEventAckState ack_result) { |
1271 if (touch_editing_client_) | |
1272 touch_editing_client_->GestureEventAck(event.type); | |
1273 | |
1274 if (overscroll_controller_) { | 1283 if (overscroll_controller_) { |
1275 overscroll_controller_->ReceivedEventACK( | 1284 overscroll_controller_->ReceivedEventACK( |
1276 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); | 1285 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); |
1277 } | 1286 } |
1278 } | 1287 } |
1279 | 1288 |
1280 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( | 1289 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( |
1281 const TouchEventWithLatencyInfo& touch, | 1290 const TouchEventWithLatencyInfo& touch, |
1282 InputEventAckState ack_result) { | 1291 InputEventAckState ack_result) { |
1283 ScopedVector<ui::TouchEvent> events; | 1292 ScopedVector<ui::TouchEvent> events; |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1669 return gfx::Rect(origin.x(), | 1678 return gfx::Rect(origin.x(), |
1670 origin.y(), | 1679 origin.y(), |
1671 end.x() - origin.x(), | 1680 end.x() - origin.x(), |
1672 end.y() - origin.y()); | 1681 end.y() - origin.y()); |
1673 } | 1682 } |
1674 | 1683 |
1675 return rect; | 1684 return rect; |
1676 } | 1685 } |
1677 | 1686 |
1678 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { | 1687 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { |
1679 gfx::Rect rect = | 1688 return ConvertRectToScreen( |
1680 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_); | 1689 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_)); |
1681 return ConvertRectToScreen(rect); | |
1682 } | 1690 } |
1683 | 1691 |
1684 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( | 1692 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( |
1685 uint32 index, | 1693 uint32 index, |
1686 gfx::Rect* rect) const { | 1694 gfx::Rect* rect) const { |
1687 DCHECK(rect); | 1695 DCHECK(rect); |
1688 if (index >= composition_character_bounds_.size()) | 1696 if (index >= composition_character_bounds_.size()) |
1689 return false; | 1697 return false; |
1690 *rect = ConvertRectToScreen(composition_character_bounds_[index]); | 1698 *rect = ConvertRectToScreen(composition_character_bounds_[index]); |
1691 return true; | 1699 return true; |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1862 const gfx::Point& location) { | 1870 const gfx::Point& location) { |
1863 return true; | 1871 return true; |
1864 } | 1872 } |
1865 | 1873 |
1866 bool RenderWidgetHostViewAura::CanFocus() { | 1874 bool RenderWidgetHostViewAura::CanFocus() { |
1867 return popup_type_ == blink::WebPopupTypeNone; | 1875 return popup_type_ == blink::WebPopupTypeNone; |
1868 } | 1876 } |
1869 | 1877 |
1870 void RenderWidgetHostViewAura::OnCaptureLost() { | 1878 void RenderWidgetHostViewAura::OnCaptureLost() { |
1871 host_->LostCapture(); | 1879 host_->LostCapture(); |
1872 if (touch_editing_client_) | |
1873 touch_editing_client_->EndTouchEditing(false); | |
1874 } | 1880 } |
1875 | 1881 |
1876 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) { | 1882 void RenderWidgetHostViewAura::OnPaint(const ui::PaintContext& context) { |
1877 NOTREACHED(); | 1883 NOTREACHED(); |
1878 } | 1884 } |
1879 | 1885 |
1880 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( | 1886 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( |
1881 float device_scale_factor) { | 1887 float device_scale_factor) { |
1882 if (!host_ || !window_->GetRootWindow()) | 1888 if (!host_ || !window_->GetRootWindow()) |
1883 return; | 1889 return; |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1946 } | 1952 } |
1947 | 1953 |
1948 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { | 1954 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { |
1949 } | 1955 } |
1950 | 1956 |
1951 //////////////////////////////////////////////////////////////////////////////// | 1957 //////////////////////////////////////////////////////////////////////////////// |
1952 // RenderWidgetHostViewAura, ui::EventHandler implementation: | 1958 // RenderWidgetHostViewAura, ui::EventHandler implementation: |
1953 | 1959 |
1954 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { | 1960 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { |
1955 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); | 1961 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); |
1956 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | |
1957 return; | |
1958 | 1962 |
1959 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { | 1963 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { |
1960 popup_child_host_view_->OnKeyEvent(event); | 1964 popup_child_host_view_->OnKeyEvent(event); |
1961 if (event->handled()) | 1965 if (event->handled()) |
1962 return; | 1966 return; |
1963 } | 1967 } |
1964 | 1968 |
1965 // We need to handle the Escape key for Pepper Flash. | 1969 // We need to handle the Escape key for Pepper Flash. |
1966 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { | 1970 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { |
1967 // Focus the window we were created from. | 1971 // Focus the window we were created from. |
(...skipping 26 matching lines...) Expand all Loading... | |
1994 // We don't have to communicate with an input method here. | 1998 // We don't have to communicate with an input method here. |
1995 NativeWebKeyboardEvent webkit_event(*event); | 1999 NativeWebKeyboardEvent webkit_event(*event); |
1996 ForwardKeyboardEvent(webkit_event); | 2000 ForwardKeyboardEvent(webkit_event); |
1997 } | 2001 } |
1998 event->SetHandled(); | 2002 event->SetHandled(); |
1999 } | 2003 } |
2000 | 2004 |
2001 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { | 2005 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { |
2002 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent"); | 2006 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent"); |
2003 | 2007 |
2004 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | |
2005 return; | |
2006 | |
2007 if (mouse_locked_) { | 2008 if (mouse_locked_) { |
2008 aura::client::CursorClient* cursor_client = | 2009 aura::client::CursorClient* cursor_client = |
2009 aura::client::GetCursorClient(window_->GetRootWindow()); | 2010 aura::client::GetCursorClient(window_->GetRootWindow()); |
2010 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); | 2011 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); |
2011 | 2012 |
2012 if (event->type() == ui::ET_MOUSEWHEEL) { | 2013 if (event->type() == ui::ET_MOUSEWHEEL) { |
2013 blink::WebMouseWheelEvent mouse_wheel_event = | 2014 blink::WebMouseWheelEvent mouse_wheel_event = |
2014 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); | 2015 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); |
2015 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) | 2016 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) |
2016 host_->ForwardWheelEvent(mouse_wheel_event); | 2017 host_->ForwardWheelEvent(mouse_wheel_event); |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2160 event->ConvertLocationToTarget(window_, window_->parent()); | 2161 event->ConvertLocationToTarget(window_, window_->parent()); |
2161 window_->parent()->delegate()->OnMouseEvent(event); | 2162 window_->parent()->delegate()->OnMouseEvent(event); |
2162 } | 2163 } |
2163 | 2164 |
2164 if (!IsXButtonUpEvent(event)) | 2165 if (!IsXButtonUpEvent(event)) |
2165 event->SetHandled(); | 2166 event->SetHandled(); |
2166 } | 2167 } |
2167 | 2168 |
2168 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { | 2169 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { |
2169 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); | 2170 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); |
2170 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | |
2171 return; | |
2172 | 2171 |
2173 if (event->type() == ui::ET_SCROLL) { | 2172 if (event->type() == ui::ET_SCROLL) { |
2174 #if !defined(OS_WIN) | 2173 #if !defined(OS_WIN) |
2175 // TODO(ananta) | 2174 // TODO(ananta) |
2176 // Investigate if this is true for Windows 8 Metro ASH as well. | 2175 // Investigate if this is true for Windows 8 Metro ASH as well. |
2177 if (event->finger_count() != 2) | 2176 if (event->finger_count() != 2) |
2178 return; | 2177 return; |
2179 #endif | 2178 #endif |
2180 blink::WebGestureEvent gesture_event = | 2179 blink::WebGestureEvent gesture_event = |
2181 MakeWebGestureEventFlingCancel(); | 2180 MakeWebGestureEventFlingCancel(); |
2182 host_->ForwardGestureEvent(gesture_event); | 2181 host_->ForwardGestureEvent(gesture_event); |
2183 blink::WebMouseWheelEvent mouse_wheel_event = | 2182 blink::WebMouseWheelEvent mouse_wheel_event = |
2184 MakeWebMouseWheelEvent(*event); | 2183 MakeWebMouseWheelEvent(*event); |
2185 host_->ForwardWheelEvent(mouse_wheel_event); | 2184 host_->ForwardWheelEvent(mouse_wheel_event); |
2186 RecordAction(base::UserMetricsAction("TrackpadScroll")); | 2185 RecordAction(base::UserMetricsAction("TrackpadScroll")); |
2187 } else if (event->type() == ui::ET_SCROLL_FLING_START || | 2186 } else if (event->type() == ui::ET_SCROLL_FLING_START || |
2188 event->type() == ui::ET_SCROLL_FLING_CANCEL) { | 2187 event->type() == ui::ET_SCROLL_FLING_CANCEL) { |
2189 blink::WebGestureEvent gesture_event = MakeWebGestureEvent(*event); | 2188 blink::WebGestureEvent gesture_event = MakeWebGestureEvent(*event); |
2190 host_->ForwardGestureEvent(gesture_event); | 2189 host_->ForwardGestureEvent(gesture_event); |
2191 if (event->type() == ui::ET_SCROLL_FLING_START) | 2190 if (event->type() == ui::ET_SCROLL_FLING_START) |
2192 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); | 2191 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); |
2193 } | 2192 } |
2194 | 2193 |
2195 event->SetHandled(); | 2194 event->SetHandled(); |
2196 } | 2195 } |
2197 | 2196 |
2198 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { | 2197 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { |
2199 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); | 2198 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); |
2200 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2199 |
2201 return; | 2200 bool had_no_pointer = !pointer_state_.GetPointerCount(); |
2202 | 2201 |
2203 // Update the touch event first. | 2202 // Update the touch event first. |
2204 if (!pointer_state_.OnTouch(*event)) { | 2203 if (!pointer_state_.OnTouch(*event)) { |
2205 event->StopPropagation(); | 2204 event->StopPropagation(); |
2206 return; | 2205 return; |
2207 } | 2206 } |
2208 | 2207 |
2209 blink::WebTouchEvent touch_event = ui::CreateWebTouchEventFromMotionEvent( | 2208 blink::WebTouchEvent touch_event; |
2210 pointer_state_, event->may_cause_scrolling()); | 2209 bool handled = selection_controller_->WillHandleTouchEvent(pointer_state_); |
2210 if (handled) { | |
2211 event->SetHandled(); | |
2212 } else { | |
2213 touch_event = ui::CreateWebTouchEventFromMotionEvent( | |
2214 pointer_state_, event->may_cause_scrolling()); | |
2215 } | |
2211 pointer_state_.CleanupRemovedTouchPoints(*event); | 2216 pointer_state_.CleanupRemovedTouchPoints(*event); |
jdduke (slow)
2015/07/08 15:22:42
I wonder if it's worth adding a scoped helper for
mohsen
2015/07/08 21:26:18
Added a scoped helper. How does it look like now?
| |
2212 | 2217 |
2218 if (handled) | |
2219 return; | |
2220 | |
2221 if (had_no_pointer) | |
2222 selection_controller_client_->OnTouchDown(); | |
2223 if (!pointer_state_.GetPointerCount()) | |
2224 selection_controller_client_->OnTouchUp(); | |
2225 | |
2213 // It is important to always mark events as being handled asynchronously when | 2226 // It is important to always mark events as being handled asynchronously when |
2214 // they are forwarded. This ensures that the current event does not get | 2227 // they are forwarded. This ensures that the current event does not get |
2215 // processed by the gesture recognizer before events currently awaiting | 2228 // processed by the gesture recognizer before events currently awaiting |
2216 // dispatch in the touch queue. | 2229 // dispatch in the touch queue. |
2217 event->DisableSynchronousHandling(); | 2230 event->DisableSynchronousHandling(); |
2218 | 2231 |
2219 // Set unchanged touch point to StateStationary for touchmove and | 2232 // Set unchanged touch point to StateStationary for touchmove and |
2220 // touchcancel to make sure only send one ack per WebTouchEvent. | 2233 // touchcancel to make sure only send one ack per WebTouchEvent. |
2221 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); | 2234 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); |
2222 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); | 2235 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); |
2223 } | 2236 } |
2224 | 2237 |
2225 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { | 2238 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { |
2226 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); | 2239 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); |
2240 | |
2227 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 2241 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
2228 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2242 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
2229 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { | 2243 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { |
2230 event->SetHandled(); | 2244 event->SetHandled(); |
2231 return; | 2245 return; |
2232 } | 2246 } |
2233 | 2247 |
2234 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2248 HandleGestureForTouchSelection(event); |
2249 if (event->handled()) | |
2235 return; | 2250 return; |
2236 | 2251 |
2237 // Confirm existing composition text on TAP gesture, to make sure the input | 2252 // Confirm existing composition text on TAP gesture, to make sure the input |
2238 // caret won't be moved with an ongoing composition text. | 2253 // caret won't be moved with an ongoing composition text. |
2239 if (event->type() == ui::ET_GESTURE_TAP) | 2254 if (event->type() == ui::ET_GESTURE_TAP) |
2240 FinishImeCompositionSession(); | 2255 FinishImeCompositionSession(); |
2241 | 2256 |
2242 blink::WebGestureEvent gesture = MakeWebGestureEvent(*event); | 2257 blink::WebGestureEvent gesture = MakeWebGestureEvent(*event); |
2243 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 2258 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
2244 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an | 2259 // 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 Loading... | |
2321 host_->GetRootBrowserAccessibilityManager(); | 2336 host_->GetRootBrowserAccessibilityManager(); |
2322 if (manager) | 2337 if (manager) |
2323 manager->OnWindowFocused(); | 2338 manager->OnWindowFocused(); |
2324 } else if (window_ == lost_focus) { | 2339 } else if (window_ == lost_focus) { |
2325 host_->SetActive(false); | 2340 host_->SetActive(false); |
2326 host_->Blur(); | 2341 host_->Blur(); |
2327 | 2342 |
2328 DetachFromInputMethod(); | 2343 DetachFromInputMethod(); |
2329 host_->SetInputMethodActive(false); | 2344 host_->SetInputMethodActive(false); |
2330 | 2345 |
2331 if (touch_editing_client_) | 2346 selection_controller_->HideAndDisallowShowingAutomatically(); |
2332 touch_editing_client_->EndTouchEditing(false); | |
2333 | 2347 |
2334 if (overscroll_controller_) | 2348 if (overscroll_controller_) |
2335 overscroll_controller_->Cancel(); | 2349 overscroll_controller_->Cancel(); |
2336 | 2350 |
2337 BrowserAccessibilityManager* manager = | 2351 BrowserAccessibilityManager* manager = |
2338 host_->GetRootBrowserAccessibilityManager(); | 2352 host_->GetRootBrowserAccessibilityManager(); |
2339 if (manager) | 2353 if (manager) |
2340 manager->OnWindowBlurred(); | 2354 manager->OnWindowBlurred(); |
2341 | 2355 |
2342 // If we lose the focus while fullscreen, close the window; Pepper Flash | 2356 // If we lose the focus while fullscreen, close the window; Pepper Flash |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2379 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved", | 2393 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved", |
2380 "new_origin", new_origin.ToString()); | 2394 "new_origin", new_origin.ToString()); |
2381 | 2395 |
2382 UpdateScreenInfo(window_); | 2396 UpdateScreenInfo(window_); |
2383 } | 2397 } |
2384 | 2398 |
2385 //////////////////////////////////////////////////////////////////////////////// | 2399 //////////////////////////////////////////////////////////////////////////////// |
2386 // RenderWidgetHostViewAura, private: | 2400 // RenderWidgetHostViewAura, private: |
2387 | 2401 |
2388 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { | 2402 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { |
2389 if (touch_editing_client_) | 2403 selection_controller_.reset(); |
2390 touch_editing_client_->OnViewDestroyed(); | 2404 selection_controller_client_.reset(); |
2391 | |
2392 delegated_frame_host_.reset(); | 2405 delegated_frame_host_.reset(); |
2393 window_observer_.reset(); | 2406 window_observer_.reset(); |
2394 if (window_->GetHost()) | 2407 if (window_->GetHost()) |
2395 window_->GetHost()->RemoveObserver(this); | 2408 window_->GetHost()->RemoveObserver(this); |
2396 UnlockMouse(); | 2409 UnlockMouse(); |
2397 if (popup_parent_host_view_) { | 2410 if (popup_parent_host_view_) { |
2398 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || | 2411 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || |
2399 popup_parent_host_view_->popup_child_host_view_ == this); | 2412 popup_parent_host_view_->popup_child_host_view_ == this); |
2400 popup_parent_host_view_->popup_child_host_view_ = NULL; | 2413 popup_parent_host_view_->popup_child_host_view_ = NULL; |
2401 } | 2414 } |
(...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2566 } | 2579 } |
2567 | 2580 |
2568 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { | 2581 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { |
2569 SnapToPhysicalPixelBoundary(); | 2582 SnapToPhysicalPixelBoundary(); |
2570 // Don't recursively call SetBounds if this bounds update is the result of | 2583 // Don't recursively call SetBounds if this bounds update is the result of |
2571 // a Window::SetBoundsInternal call. | 2584 // a Window::SetBoundsInternal call. |
2572 if (!in_bounds_changed_) | 2585 if (!in_bounds_changed_) |
2573 window_->SetBounds(rect); | 2586 window_->SetBounds(rect); |
2574 host_->WasResized(); | 2587 host_->WasResized(); |
2575 delegated_frame_host_->WasResized(); | 2588 delegated_frame_host_->WasResized(); |
2576 if (touch_editing_client_) { | |
2577 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_, | |
2578 selection_focus_); | |
2579 } | |
2580 #if defined(OS_WIN) | 2589 #if defined(OS_WIN) |
2581 // Create the legacy dummy window which corresponds to the bounds of the | 2590 // Create the legacy dummy window which corresponds to the bounds of the |
2582 // webcontents. This will be passed as the container window for windowless | 2591 // webcontents. This will be passed as the container window for windowless |
2583 // plugins. | 2592 // plugins. |
2584 // Plugins like Flash assume the container window which is returned via the | 2593 // Plugins like Flash assume the container window which is returned via the |
2585 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. | 2594 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. |
2586 // This is not true in Aura where we have only HWND which is the main Aura | 2595 // This is not true in Aura where we have only HWND which is the main Aura |
2587 // window. If we return this window to plugins like Flash then it causes the | 2596 // window. If we return this window to plugins like Flash then it causes the |
2588 // coordinate translations done by these plugins to break. | 2597 // coordinate translations done by these plugins to break. |
2589 // Additonally the legacy dummy window is needed for accessibility and for | 2598 // Additonally the legacy dummy window is needed for accessibility and for |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2712 NativeWebKeyboardEvent copy_event(event); | 2721 NativeWebKeyboardEvent copy_event(event); |
2713 copy_event.match_edit_command = true; | 2722 copy_event.match_edit_command = true; |
2714 host_->ForwardKeyboardEvent(copy_event); | 2723 host_->ForwardKeyboardEvent(copy_event); |
2715 return; | 2724 return; |
2716 } | 2725 } |
2717 #endif | 2726 #endif |
2718 | 2727 |
2719 host_->ForwardKeyboardEvent(event); | 2728 host_->ForwardKeyboardEvent(event); |
2720 } | 2729 } |
2721 | 2730 |
2731 void RenderWidgetHostViewAura::SelectionUpdated(bool is_editable, | |
2732 bool is_empty_text_form_control, | |
2733 const ui::SelectionBound& start, | |
2734 const ui::SelectionBound& end) { | |
2735 selection_controller_->OnSelectionEditable(is_editable); | |
2736 selection_controller_->OnSelectionEmpty(is_empty_text_form_control); | |
2737 selection_controller_->OnSelectionBoundsChanged(start, end); | |
2738 } | |
2739 | |
2740 void RenderWidgetHostViewAura::HandleGestureForTouchSelection( | |
2741 ui::GestureEvent* event) { | |
2742 switch (event->type()) { | |
2743 case ui::ET_GESTURE_LONG_PRESS: | |
2744 if (selection_controller_->WillHandleLongPressEvent( | |
2745 base::TimeTicks() + event->time_stamp(), event->location())) { | |
2746 event->SetHandled(); | |
2747 } | |
2748 break; | |
2749 case ui::ET_GESTURE_TAP: | |
2750 if (selection_controller_->WillHandleTapEvent(event->location())) | |
2751 event->SetHandled(); | |
2752 break; | |
2753 case ui::ET_GESTURE_SCROLL_BEGIN: | |
2754 selection_controller_client_->OnSelectionScrollStarted(); | |
2755 break; | |
2756 case ui::ET_GESTURE_SCROLL_END: | |
2757 selection_controller_client_->OnSelectionScrollCompleted(); | |
2758 break; | |
2759 default: | |
2760 break; | |
2761 } | |
2762 } | |
2763 | |
2722 //////////////////////////////////////////////////////////////////////////////// | 2764 //////////////////////////////////////////////////////////////////////////////// |
2723 // DelegatedFrameHost, public: | 2765 // DelegatedFrameHost, public: |
2724 | 2766 |
2725 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { | 2767 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { |
2726 return window_->layer(); | 2768 return window_->layer(); |
2727 } | 2769 } |
2728 | 2770 |
2729 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { | 2771 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { |
2730 return !host_->is_hidden(); | 2772 return !host_->is_hidden(); |
2731 } | 2773 } |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2798 | 2840 |
2799 //////////////////////////////////////////////////////////////////////////////// | 2841 //////////////////////////////////////////////////////////////////////////////// |
2800 // RenderWidgetHostViewBase, public: | 2842 // RenderWidgetHostViewBase, public: |
2801 | 2843 |
2802 // static | 2844 // static |
2803 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2845 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2804 GetScreenInfoForWindow(results, NULL); | 2846 GetScreenInfoForWindow(results, NULL); |
2805 } | 2847 } |
2806 | 2848 |
2807 } // namespace content | 2849 } // namespace content |
OLD | NEW |