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