| 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 "base/auto_reset.h" | 7 #include "base/auto_reset.h" |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" |
| 11 #include "base/command_line.h" | 11 #include "base/command_line.h" |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/message_loop/message_loop.h" | 13 #include "base/message_loop/message_loop.h" |
| 14 #include "base/strings/string_number_conversions.h" | 14 #include "base/strings/string_number_conversions.h" |
| 15 #include "base/trace_event/trace_event.h" | 15 #include "base/trace_event/trace_event.h" |
| 16 #include "cc/layers/layer.h" | 16 #include "cc/layers/layer.h" |
| 17 #include "cc/output/copy_output_request.h" | 17 #include "cc/output/copy_output_request.h" |
| 18 #include "cc/output/copy_output_result.h" | 18 #include "cc/output/copy_output_result.h" |
| 19 #include "cc/resources/texture_mailbox.h" | 19 #include "cc/resources/texture_mailbox.h" |
| 20 #include "cc/trees/layer_tree_settings.h" | 20 #include "cc/trees/layer_tree_settings.h" |
| 21 #include "content/browser/accessibility/browser_accessibility_manager.h" | 21 #include "content/browser/accessibility/browser_accessibility_manager.h" |
| 22 #include "content/browser/accessibility/browser_accessibility_state_impl.h" | 22 #include "content/browser/accessibility/browser_accessibility_state_impl.h" |
| 23 #include "content/browser/frame_host/frame_tree.h" | 23 #include "content/browser/frame_host/frame_tree.h" |
| 24 #include "content/browser/frame_host/frame_tree_node.h" | 24 #include "content/browser/frame_host/frame_tree_node.h" |
| 25 #include "content/browser/frame_host/render_frame_host_impl.h" | 25 #include "content/browser/frame_host/render_frame_host_impl.h" |
| 26 #include "content/browser/gpu/compositor_util.h" | 26 #include "content/browser/gpu/compositor_util.h" |
| 27 #include "content/browser/renderer_host/compositor_resize_lock_aura.h" | 27 #include "content/browser/renderer_host/compositor_resize_lock_aura.h" |
| 28 #include "content/browser/renderer_host/dip_util.h" | 28 #include "content/browser/renderer_host/dip_util.h" |
| 29 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" | 29 #include "content/browser/renderer_host/input/synthetic_gesture_target_aura.h" |
| 30 #include "content/browser/renderer_host/input/ui_touch_selection_helper.h" |
| 30 #include "content/browser/renderer_host/input/web_input_event_util.h" | 31 #include "content/browser/renderer_host/input/web_input_event_util.h" |
| 31 #include "content/browser/renderer_host/overscroll_controller.h" | 32 #include "content/browser/renderer_host/overscroll_controller.h" |
| 32 #include "content/browser/renderer_host/render_view_host_delegate.h" | 33 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 33 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 34 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
| 34 #include "content/browser/renderer_host/render_view_host_impl.h" | 35 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 35 #include "content/browser/renderer_host/render_widget_host_impl.h" | 36 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 36 #include "content/browser/renderer_host/ui_events_helper.h" | 37 #include "content/browser/renderer_host/ui_events_helper.h" |
| 37 #include "content/browser/renderer_host/web_input_event_aura.h" | 38 #include "content/browser/renderer_host/web_input_event_aura.h" |
| 38 #include "content/common/gpu/client/gl_helper.h" | 39 #include "content/common/gpu/client/gl_helper.h" |
| 39 #include "content/common/gpu/gpu_messages.h" | 40 #include "content/common/gpu/gpu_messages.h" |
| (...skipping 27 matching lines...) Expand all Loading... |
| 67 #include "ui/compositor/dip_util.h" | 68 #include "ui/compositor/dip_util.h" |
| 68 #include "ui/events/event.h" | 69 #include "ui/events/event.h" |
| 69 #include "ui/events/event_utils.h" | 70 #include "ui/events/event_utils.h" |
| 70 #include "ui/events/gestures/gesture_recognizer.h" | 71 #include "ui/events/gestures/gesture_recognizer.h" |
| 71 #include "ui/gfx/canvas.h" | 72 #include "ui/gfx/canvas.h" |
| 72 #include "ui/gfx/display.h" | 73 #include "ui/gfx/display.h" |
| 73 #include "ui/gfx/geometry/rect_conversions.h" | 74 #include "ui/gfx/geometry/rect_conversions.h" |
| 74 #include "ui/gfx/geometry/size_conversions.h" | 75 #include "ui/gfx/geometry/size_conversions.h" |
| 75 #include "ui/gfx/screen.h" | 76 #include "ui/gfx/screen.h" |
| 76 #include "ui/gfx/skia_util.h" | 77 #include "ui/gfx/skia_util.h" |
| 78 #include "ui/touch_selection/touch_selection_controller_aura.h" |
| 77 #include "ui/wm/public/activation_client.h" | 79 #include "ui/wm/public/activation_client.h" |
| 78 #include "ui/wm/public/scoped_tooltip_disabler.h" | 80 #include "ui/wm/public/scoped_tooltip_disabler.h" |
| 79 #include "ui/wm/public/tooltip_client.h" | 81 #include "ui/wm/public/tooltip_client.h" |
| 80 #include "ui/wm/public/transient_window_client.h" | 82 #include "ui/wm/public/transient_window_client.h" |
| 81 #include "ui/wm/public/window_types.h" | 83 #include "ui/wm/public/window_types.h" |
| 82 | 84 |
| 83 #if defined(OS_WIN) | 85 #if defined(OS_WIN) |
| 84 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 86 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
| 85 #include "content/browser/accessibility/browser_accessibility_win.h" | 87 #include "content/browser/accessibility/browser_accessibility_win.h" |
| 86 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" | 88 #include "content/browser/renderer_host/legacy_render_widget_host_win.h" |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 429 accept_return_character_(false), | 431 accept_return_character_(false), |
| 430 last_swapped_software_frame_scale_factor_(1.f), | 432 last_swapped_software_frame_scale_factor_(1.f), |
| 431 paint_canvas_(NULL), | 433 paint_canvas_(NULL), |
| 432 synthetic_move_sent_(false), | 434 synthetic_move_sent_(false), |
| 433 cursor_visibility_state_in_renderer_(UNKNOWN), | 435 cursor_visibility_state_in_renderer_(UNKNOWN), |
| 434 #if defined(OS_WIN) | 436 #if defined(OS_WIN) |
| 435 legacy_render_widget_host_HWND_(NULL), | 437 legacy_render_widget_host_HWND_(NULL), |
| 436 legacy_window_destroyed_(false), | 438 legacy_window_destroyed_(false), |
| 437 #endif | 439 #endif |
| 438 has_snapped_to_boundary_(false), | 440 has_snapped_to_boundary_(false), |
| 439 touch_editing_client_(NULL), | |
| 440 is_guest_view_hack_(is_guest_view_hack), | 441 is_guest_view_hack_(is_guest_view_hack), |
| 441 weak_ptr_factory_(this) { | 442 weak_ptr_factory_(this) { |
| 442 if (!is_guest_view_hack_) | 443 if (!is_guest_view_hack_) |
| 443 host_->SetView(this); | 444 host_->SetView(this); |
| 444 | 445 |
| 445 window_observer_.reset(new WindowObserver(this)); | 446 window_observer_.reset(new WindowObserver(this)); |
| 446 aura::client::SetTooltipText(window_, &tooltip_); | 447 aura::client::SetTooltipText(window_, &tooltip_); |
| 447 aura::client::SetActivationDelegate(window_, this); | 448 aura::client::SetActivationDelegate(window_, this); |
| 448 aura::client::SetActivationChangeObserver(window_, this); | 449 aura::client::SetActivationChangeObserver(window_, this); |
| 449 aura::client::SetFocusChangeObserver(window_, this); | 450 aura::client::SetFocusChangeObserver(window_, this); |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 // Make sure we have a FocusClient before attempting to Focus(). In some | 775 // Make sure we have a FocusClient before attempting to Focus(). In some |
| 775 // situations we may not yet be in a valid Window hierarchy (such as reloading | 776 // situations we may not yet be in a valid Window hierarchy (such as reloading |
| 776 // after out of memory discarded the tab). | 777 // after out of memory discarded the tab). |
| 777 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); | 778 aura::client::FocusClient* client = aura::client::GetFocusClient(window_); |
| 778 if (client) | 779 if (client) |
| 779 window_->Focus(); | 780 window_->Focus(); |
| 780 } | 781 } |
| 781 | 782 |
| 782 void RenderWidgetHostViewAura::Blur() { | 783 void RenderWidgetHostViewAura::Blur() { |
| 783 window_->Blur(); | 784 window_->Blur(); |
| 785 if (selection_controller_) |
| 786 selection_controller_->HideAndDisallowShowingAutomatically(); |
| 784 } | 787 } |
| 785 | 788 |
| 786 bool RenderWidgetHostViewAura::HasFocus() const { | 789 bool RenderWidgetHostViewAura::HasFocus() const { |
| 787 return window_->HasFocus(); | 790 return window_->HasFocus(); |
| 788 } | 791 } |
| 789 | 792 |
| 790 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { | 793 bool RenderWidgetHostViewAura::IsSurfaceAvailableForCopy() const { |
| 791 return delegated_frame_host_->CanCopyToBitmap(); | 794 return delegated_frame_host_->CanCopyToBitmap(); |
| 792 } | 795 } |
| 793 | 796 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 841 if (text_input_type_ != type || | 844 if (text_input_type_ != type || |
| 842 text_input_mode_ != input_mode || | 845 text_input_mode_ != input_mode || |
| 843 can_compose_inline_ != can_compose_inline || | 846 can_compose_inline_ != can_compose_inline || |
| 844 text_input_flags_ != flags) { | 847 text_input_flags_ != flags) { |
| 845 text_input_type_ = type; | 848 text_input_type_ = type; |
| 846 text_input_mode_ = input_mode; | 849 text_input_mode_ = input_mode; |
| 847 can_compose_inline_ = can_compose_inline; | 850 can_compose_inline_ = can_compose_inline; |
| 848 text_input_flags_ = flags; | 851 text_input_flags_ = flags; |
| 849 if (GetInputMethod()) | 852 if (GetInputMethod()) |
| 850 GetInputMethod()->OnTextInputTypeChanged(this); | 853 GetInputMethod()->OnTextInputTypeChanged(this); |
| 851 if (touch_editing_client_) | 854 if (selection_controller_) { |
| 852 touch_editing_client_->OnTextInputTypeChanged(text_input_type_); | 855 const bool is_editable_node = type != ui::TEXT_INPUT_TYPE_NONE; |
| 856 selection_controller_->OnSelectionEditable(is_editable_node); |
| 857 } |
| 853 } | 858 } |
| 854 } | 859 } |
| 855 | 860 |
| 856 void RenderWidgetHostViewAura::OnTextInputStateChanged( | 861 void RenderWidgetHostViewAura::OnTextInputStateChanged( |
| 857 const ViewHostMsg_TextInputState_Params& params) { | 862 const ViewHostMsg_TextInputState_Params& params) { |
| 858 text_input_flags_ = params.flags; | 863 text_input_flags_ = params.flags; |
| 859 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { | 864 if (params.show_ime_if_needed && params.type != ui::TEXT_INPUT_TYPE_NONE) { |
| 860 if (GetInputMethod()) | 865 if (GetInputMethod()) |
| 861 GetInputMethod()->ShowImeIfNeeded(); | 866 GetInputMethod()->ShowImeIfNeeded(); |
| 862 } | 867 } |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 899 // Content tooltips should be visible indefinitely. | 904 // Content tooltips should be visible indefinitely. |
| 900 tooltip_client->SetTooltipShownTimeout(window_, 0); | 905 tooltip_client->SetTooltipShownTimeout(window_, 0); |
| 901 } | 906 } |
| 902 } | 907 } |
| 903 | 908 |
| 904 void RenderWidgetHostViewAura::SelectionChanged(const base::string16& text, | 909 void RenderWidgetHostViewAura::SelectionChanged(const base::string16& text, |
| 905 size_t offset, | 910 size_t offset, |
| 906 const gfx::Range& range) { | 911 const gfx::Range& range) { |
| 907 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); | 912 RenderWidgetHostViewBase::SelectionChanged(text, offset, range); |
| 908 | 913 |
| 914 if (selection_controller_) |
| 915 selection_controller_->OnSelectionEmpty(text.empty()); |
| 916 |
| 909 #if defined(USE_X11) && !defined(OS_CHROMEOS) | 917 #if defined(USE_X11) && !defined(OS_CHROMEOS) |
| 910 if (text.empty() || range.is_empty()) | 918 if (text.empty() || range.is_empty()) |
| 911 return; | 919 return; |
| 912 size_t pos = range.GetMin() - offset; | 920 size_t pos = range.GetMin() - offset; |
| 913 size_t n = range.length(); | 921 size_t n = range.length(); |
| 914 | 922 |
| 915 DCHECK(pos + n <= text.length()) << "The text can not fully cover range."; | 923 DCHECK(pos + n <= text.length()) << "The text can not fully cover range."; |
| 916 if (pos >= text.length()) { | 924 if (pos >= text.length()) { |
| 917 NOTREACHED() << "The text can not cover range."; | 925 NOTREACHED() << "The text can not cover range."; |
| 918 return; | 926 return; |
| 919 } | 927 } |
| 920 | 928 |
| 921 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. | 929 // Set the CLIPBOARD_TYPE_SELECTION to the ui::Clipboard. |
| 922 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); | 930 ui::ScopedClipboardWriter clipboard_writer(ui::CLIPBOARD_TYPE_SELECTION); |
| 923 clipboard_writer.WriteText(text.substr(pos, n)); | 931 clipboard_writer.WriteText(text.substr(pos, n)); |
| 924 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) | 932 #endif // defined(USE_X11) && !defined(OS_CHROMEOS) |
| 925 } | 933 } |
| 926 | 934 |
| 927 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { | 935 gfx::Size RenderWidgetHostViewAura::GetRequestedRendererSize() const { |
| 928 return delegated_frame_host_->GetRequestedRendererSize(); | 936 return delegated_frame_host_->GetRequestedRendererSize(); |
| 929 } | 937 } |
| 930 | 938 |
| 931 void RenderWidgetHostViewAura::SelectionBoundsChanged( | 939 void RenderWidgetHostViewAura::SelectionBoundsChanged( |
| 932 const ViewHostMsg_SelectionBounds_Params& params) { | 940 const ViewHostMsg_SelectionBounds_Params& params) { |
| 933 ui::SelectionBound anchor_bound, focus_bound; | 941 NOTREACHED() << "Selection bounds should be routed through the compositor."; |
| 934 anchor_bound.SetEdge(params.anchor_rect.origin(), | |
| 935 params.anchor_rect.bottom_left()); | |
| 936 focus_bound.SetEdge(params.focus_rect.origin(), | |
| 937 params.focus_rect.bottom_left()); | |
| 938 | |
| 939 if (params.anchor_rect == params.focus_rect) { | |
| 940 anchor_bound.set_type(ui::SelectionBound::CENTER); | |
| 941 focus_bound.set_type(ui::SelectionBound::CENTER); | |
| 942 } else { | |
| 943 // Whether text is LTR at the anchor handle. | |
| 944 bool anchor_LTR = params.anchor_dir == blink::WebTextDirectionLeftToRight; | |
| 945 // Whether text is LTR at the focus handle. | |
| 946 bool focus_LTR = params.focus_dir == blink::WebTextDirectionLeftToRight; | |
| 947 | |
| 948 if ((params.is_anchor_first && anchor_LTR) || | |
| 949 (!params.is_anchor_first && !anchor_LTR)) { | |
| 950 anchor_bound.set_type(ui::SelectionBound::LEFT); | |
| 951 } else { | |
| 952 anchor_bound.set_type(ui::SelectionBound::RIGHT); | |
| 953 } | |
| 954 if ((params.is_anchor_first && focus_LTR) || | |
| 955 (!params.is_anchor_first && !focus_LTR)) { | |
| 956 focus_bound.set_type(ui::SelectionBound::RIGHT); | |
| 957 } else { | |
| 958 focus_bound.set_type(ui::SelectionBound::LEFT); | |
| 959 } | |
| 960 } | |
| 961 | |
| 962 if (anchor_bound == selection_anchor_ && focus_bound == selection_focus_) | |
| 963 return; | |
| 964 | |
| 965 selection_anchor_ = anchor_bound; | |
| 966 selection_focus_ = focus_bound; | |
| 967 if (GetInputMethod()) | |
| 968 GetInputMethod()->OnCaretBoundsChanged(this); | |
| 969 | |
| 970 if (touch_editing_client_) { | |
| 971 touch_editing_client_->OnSelectionOrCursorChanged( | |
| 972 anchor_bound, focus_bound); | |
| 973 } | |
| 974 } | 942 } |
| 975 | 943 |
| 976 void RenderWidgetHostViewAura::CopyFromCompositingSurface( | 944 void RenderWidgetHostViewAura::CopyFromCompositingSurface( |
| 977 const gfx::Rect& src_subrect, | 945 const gfx::Rect& src_subrect, |
| 978 const gfx::Size& dst_size, | 946 const gfx::Size& dst_size, |
| 979 ReadbackRequestCallback& callback, | 947 ReadbackRequestCallback& callback, |
| 980 const SkColorType color_type) { | 948 const SkColorType color_type) { |
| 981 delegated_frame_host_->CopyFromCompositingSurface( | 949 delegated_frame_host_->CopyFromCompositingSurface( |
| 982 src_subrect, dst_size, callback, color_type); | 950 src_subrect, dst_size, callback, color_type); |
| 983 } | 951 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1052 scoped_ptr<cc::CompositorFrame> frame) { | 1020 scoped_ptr<cc::CompositorFrame> frame) { |
| 1053 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); | 1021 TRACE_EVENT0("content", "RenderWidgetHostViewAura::OnSwapCompositorFrame"); |
| 1054 | 1022 |
| 1055 last_scroll_offset_ = frame->metadata.root_scroll_offset; | 1023 last_scroll_offset_ = frame->metadata.root_scroll_offset; |
| 1056 if (frame->delegated_frame_data) { | 1024 if (frame->delegated_frame_data) { |
| 1057 delegated_frame_host_->SwapDelegatedFrame( | 1025 delegated_frame_host_->SwapDelegatedFrame( |
| 1058 output_surface_id, | 1026 output_surface_id, |
| 1059 frame->delegated_frame_data.Pass(), | 1027 frame->delegated_frame_data.Pass(), |
| 1060 frame->metadata.device_scale_factor, | 1028 frame->metadata.device_scale_factor, |
| 1061 frame->metadata.latency_info); | 1029 frame->metadata.latency_info); |
| 1030 SelectionBoundsUpdated( |
| 1031 ConvertSelectionBound(frame->metadata.selection_start), |
| 1032 ConvertSelectionBound(frame->metadata.selection_end)); |
| 1062 return; | 1033 return; |
| 1063 } | 1034 } |
| 1064 | 1035 |
| 1065 if (frame->software_frame_data) { | 1036 if (frame->software_frame_data) { |
| 1066 DLOG(ERROR) << "Unable to use software frame in aura"; | 1037 DLOG(ERROR) << "Unable to use software frame in aura"; |
| 1067 RecordAction( | 1038 RecordAction( |
| 1068 base::UserMetricsAction("BadMessageTerminate_SharedMemoryAura")); | 1039 base::UserMetricsAction("BadMessageTerminate_SharedMemoryAura")); |
| 1069 host_->GetProcess()->ReceivedBadMessage(); | 1040 host_->GetProcess()->ReceivedBadMessage(); |
| 1070 return; | 1041 return; |
| 1071 } | 1042 } |
| 1072 } | 1043 } |
| 1073 | 1044 |
| 1074 void RenderWidgetHostViewAura::DidStopFlinging() { | 1045 void RenderWidgetHostViewAura::DidStopFlinging() { |
| 1075 if (touch_editing_client_) | 1046 if (selection_controller_) |
| 1076 touch_editing_client_->DidStopFlinging(); | 1047 selection_controller_->OnFlingCompleted(); |
| 1077 } | 1048 } |
| 1078 | 1049 |
| 1079 #if defined(OS_WIN) | 1050 #if defined(OS_WIN) |
| 1080 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( | 1051 void RenderWidgetHostViewAura::SetParentNativeViewAccessible( |
| 1081 gfx::NativeViewAccessible accessible_parent) { | 1052 gfx::NativeViewAccessible accessible_parent) { |
| 1082 } | 1053 } |
| 1083 | 1054 |
| 1084 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() | 1055 gfx::NativeViewId RenderWidgetHostViewAura::GetParentForWindowlessPlugin() |
| 1085 const { | 1056 const { |
| 1086 if (legacy_render_widget_host_HWND_) { | 1057 if (legacy_render_widget_host_HWND_) { |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1146 InputEventAckState ack_result) { | 1117 InputEventAckState ack_result) { |
| 1147 if (overscroll_controller_) { | 1118 if (overscroll_controller_) { |
| 1148 overscroll_controller_->ReceivedEventACK( | 1119 overscroll_controller_->ReceivedEventACK( |
| 1149 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); | 1120 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); |
| 1150 } | 1121 } |
| 1151 } | 1122 } |
| 1152 | 1123 |
| 1153 void RenderWidgetHostViewAura::GestureEventAck( | 1124 void RenderWidgetHostViewAura::GestureEventAck( |
| 1154 const blink::WebGestureEvent& event, | 1125 const blink::WebGestureEvent& event, |
| 1155 InputEventAckState ack_result) { | 1126 InputEventAckState ack_result) { |
| 1156 if (touch_editing_client_) | |
| 1157 touch_editing_client_->GestureEventAck(event.type); | |
| 1158 | |
| 1159 if (overscroll_controller_) { | 1127 if (overscroll_controller_) { |
| 1160 overscroll_controller_->ReceivedEventACK( | 1128 overscroll_controller_->ReceivedEventACK( |
| 1161 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); | 1129 event, (INPUT_EVENT_ACK_STATE_CONSUMED == ack_result)); |
| 1162 } | 1130 } |
| 1163 } | 1131 } |
| 1164 | 1132 |
| 1165 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( | 1133 void RenderWidgetHostViewAura::ProcessAckedTouchEvent( |
| 1166 const TouchEventWithLatencyInfo& touch, | 1134 const TouchEventWithLatencyInfo& touch, |
| 1167 InputEventAckState ack_result) { | 1135 InputEventAckState ack_result) { |
| 1168 ScopedVector<ui::TouchEvent> events; | 1136 ScopedVector<ui::TouchEvent> events; |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1539 return gfx::Rect(origin.x(), | 1507 return gfx::Rect(origin.x(), |
| 1540 origin.y(), | 1508 origin.y(), |
| 1541 end.x() - origin.x(), | 1509 end.x() - origin.x(), |
| 1542 end.y() - origin.y()); | 1510 end.y() - origin.y()); |
| 1543 } | 1511 } |
| 1544 | 1512 |
| 1545 return rect; | 1513 return rect; |
| 1546 } | 1514 } |
| 1547 | 1515 |
| 1548 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { | 1516 gfx::Rect RenderWidgetHostViewAura::GetCaretBounds() const { |
| 1549 gfx::Rect rect = | 1517 return ConvertRectToScreen(ui::RectBetweenSelectionBounds(selection_start_, |
| 1550 ui::RectBetweenSelectionBounds(selection_anchor_, selection_focus_); | 1518 selection_end_)); |
| 1551 return ConvertRectToScreen(rect); | |
| 1552 } | 1519 } |
| 1553 | 1520 |
| 1554 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( | 1521 bool RenderWidgetHostViewAura::GetCompositionCharacterBounds( |
| 1555 uint32 index, | 1522 uint32 index, |
| 1556 gfx::Rect* rect) const { | 1523 gfx::Rect* rect) const { |
| 1557 DCHECK(rect); | 1524 DCHECK(rect); |
| 1558 if (index >= composition_character_bounds_.size()) | 1525 if (index >= composition_character_bounds_.size()) |
| 1559 return false; | 1526 return false; |
| 1560 *rect = ConvertRectToScreen(composition_character_bounds_[index]); | 1527 *rect = ConvertRectToScreen(composition_character_bounds_[index]); |
| 1561 return true; | 1528 return true; |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1744 const gfx::Point& location) { | 1711 const gfx::Point& location) { |
| 1745 return true; | 1712 return true; |
| 1746 } | 1713 } |
| 1747 | 1714 |
| 1748 bool RenderWidgetHostViewAura::CanFocus() { | 1715 bool RenderWidgetHostViewAura::CanFocus() { |
| 1749 return popup_type_ == blink::WebPopupTypeNone; | 1716 return popup_type_ == blink::WebPopupTypeNone; |
| 1750 } | 1717 } |
| 1751 | 1718 |
| 1752 void RenderWidgetHostViewAura::OnCaptureLost() { | 1719 void RenderWidgetHostViewAura::OnCaptureLost() { |
| 1753 host_->LostCapture(); | 1720 host_->LostCapture(); |
| 1754 if (touch_editing_client_) | 1721 if (selection_controller_) |
| 1755 touch_editing_client_->EndTouchEditing(false); | 1722 selection_controller_->HideAndDisallowShowingAutomatically(); |
| 1756 } | 1723 } |
| 1757 | 1724 |
| 1758 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { | 1725 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { |
| 1759 NOTREACHED(); | 1726 NOTREACHED(); |
| 1760 } | 1727 } |
| 1761 | 1728 |
| 1762 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( | 1729 void RenderWidgetHostViewAura::OnDeviceScaleFactorChanged( |
| 1763 float device_scale_factor) { | 1730 float device_scale_factor) { |
| 1764 if (!host_ || !window_->GetRootWindow()) | 1731 if (!host_ || !window_->GetRootWindow()) |
| 1765 return; | 1732 return; |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1828 } | 1795 } |
| 1829 | 1796 |
| 1830 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { | 1797 void RenderWidgetHostViewAura::GetHitTestMask(gfx::Path* mask) const { |
| 1831 } | 1798 } |
| 1832 | 1799 |
| 1833 //////////////////////////////////////////////////////////////////////////////// | 1800 //////////////////////////////////////////////////////////////////////////////// |
| 1834 // RenderWidgetHostViewAura, ui::EventHandler implementation: | 1801 // RenderWidgetHostViewAura, ui::EventHandler implementation: |
| 1835 | 1802 |
| 1836 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { | 1803 void RenderWidgetHostViewAura::OnKeyEvent(ui::KeyEvent* event) { |
| 1837 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); | 1804 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnKeyEvent"); |
| 1838 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | |
| 1839 return; | |
| 1840 | 1805 |
| 1841 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { | 1806 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { |
| 1842 popup_child_host_view_->OnKeyEvent(event); | 1807 popup_child_host_view_->OnKeyEvent(event); |
| 1843 if (event->handled()) | 1808 if (event->handled()) |
| 1844 return; | 1809 return; |
| 1845 } | 1810 } |
| 1846 | 1811 |
| 1847 // We need to handle the Escape key for Pepper Flash. | 1812 // We need to handle the Escape key for Pepper Flash. |
| 1848 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { | 1813 if (is_fullscreen_ && event->key_code() == ui::VKEY_ESCAPE) { |
| 1849 // Focus the window we were created from. | 1814 // Focus the window we were created from. |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1876 // We don't have to communicate with an input method here. | 1841 // We don't have to communicate with an input method here. |
| 1877 NativeWebKeyboardEvent webkit_event(*event); | 1842 NativeWebKeyboardEvent webkit_event(*event); |
| 1878 ForwardKeyboardEvent(webkit_event); | 1843 ForwardKeyboardEvent(webkit_event); |
| 1879 } | 1844 } |
| 1880 event->SetHandled(); | 1845 event->SetHandled(); |
| 1881 } | 1846 } |
| 1882 | 1847 |
| 1883 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { | 1848 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { |
| 1884 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent"); | 1849 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnMouseEvent"); |
| 1885 | 1850 |
| 1886 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | |
| 1887 return; | |
| 1888 | |
| 1889 if (mouse_locked_) { | 1851 if (mouse_locked_) { |
| 1890 aura::client::CursorClient* cursor_client = | 1852 aura::client::CursorClient* cursor_client = |
| 1891 aura::client::GetCursorClient(window_->GetRootWindow()); | 1853 aura::client::GetCursorClient(window_->GetRootWindow()); |
| 1892 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); | 1854 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); |
| 1893 | 1855 |
| 1894 if (event->type() == ui::ET_MOUSEWHEEL) { | 1856 if (event->type() == ui::ET_MOUSEWHEEL) { |
| 1895 blink::WebMouseWheelEvent mouse_wheel_event = | 1857 blink::WebMouseWheelEvent mouse_wheel_event = |
| 1896 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); | 1858 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent&>(*event)); |
| 1897 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) | 1859 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) |
| 1898 host_->ForwardWheelEvent(mouse_wheel_event); | 1860 host_->ForwardWheelEvent(mouse_wheel_event); |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2017 event->ConvertLocationToTarget(window_, window_->parent()); | 1979 event->ConvertLocationToTarget(window_, window_->parent()); |
| 2018 window_->parent()->delegate()->OnMouseEvent(event); | 1980 window_->parent()->delegate()->OnMouseEvent(event); |
| 2019 } | 1981 } |
| 2020 | 1982 |
| 2021 if (!IsXButtonUpEvent(event)) | 1983 if (!IsXButtonUpEvent(event)) |
| 2022 event->SetHandled(); | 1984 event->SetHandled(); |
| 2023 } | 1985 } |
| 2024 | 1986 |
| 2025 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { | 1987 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { |
| 2026 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); | 1988 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); |
| 2027 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | |
| 2028 return; | |
| 2029 | 1989 |
| 2030 if (event->type() == ui::ET_SCROLL) { | 1990 if (event->type() == ui::ET_SCROLL) { |
| 2031 #if !defined(OS_WIN) | 1991 #if !defined(OS_WIN) |
| 2032 // TODO(ananta) | 1992 // TODO(ananta) |
| 2033 // Investigate if this is true for Windows 8 Metro ASH as well. | 1993 // Investigate if this is true for Windows 8 Metro ASH as well. |
| 2034 if (event->finger_count() != 2) | 1994 if (event->finger_count() != 2) |
| 2035 return; | 1995 return; |
| 2036 #endif | 1996 #endif |
| 2037 blink::WebGestureEvent gesture_event = | 1997 blink::WebGestureEvent gesture_event = |
| 2038 MakeWebGestureEventFlingCancel(); | 1998 MakeWebGestureEventFlingCancel(); |
| 2039 host_->ForwardGestureEvent(gesture_event); | 1999 host_->ForwardGestureEvent(gesture_event); |
| 2040 blink::WebMouseWheelEvent mouse_wheel_event = | 2000 blink::WebMouseWheelEvent mouse_wheel_event = |
| 2041 MakeWebMouseWheelEvent(*event); | 2001 MakeWebMouseWheelEvent(*event); |
| 2042 host_->ForwardWheelEvent(mouse_wheel_event); | 2002 host_->ForwardWheelEvent(mouse_wheel_event); |
| 2043 RecordAction(base::UserMetricsAction("TrackpadScroll")); | 2003 RecordAction(base::UserMetricsAction("TrackpadScroll")); |
| 2044 } else if (event->type() == ui::ET_SCROLL_FLING_START || | 2004 } else if (event->type() == ui::ET_SCROLL_FLING_START || |
| 2045 event->type() == ui::ET_SCROLL_FLING_CANCEL) { | 2005 event->type() == ui::ET_SCROLL_FLING_CANCEL) { |
| 2046 blink::WebGestureEvent gesture_event = MakeWebGestureEvent(*event); | 2006 blink::WebGestureEvent gesture_event = MakeWebGestureEvent(*event); |
| 2047 host_->ForwardGestureEvent(gesture_event); | 2007 host_->ForwardGestureEvent(gesture_event); |
| 2048 if (event->type() == ui::ET_SCROLL_FLING_START) | 2008 if (event->type() == ui::ET_SCROLL_FLING_START) |
| 2049 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); | 2009 RecordAction(base::UserMetricsAction("TrackpadScrollFling")); |
| 2050 } | 2010 } |
| 2051 | 2011 |
| 2052 event->SetHandled(); | 2012 event->SetHandled(); |
| 2053 } | 2013 } |
| 2054 | 2014 |
| 2055 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { | 2015 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { |
| 2056 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); | 2016 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); |
| 2057 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2017 |
| 2058 return; | 2018 if (selection_controller_) { |
| 2019 selection_controller_->HandleTouchEvent(event); |
| 2020 if (event->handled()) |
| 2021 return; |
| 2022 } |
| 2059 | 2023 |
| 2060 // Update the touch event first. | 2024 // Update the touch event first. |
| 2061 if (!pointer_state_.OnTouch(*event)) { | 2025 if (!pointer_state_.OnTouch(*event)) { |
| 2062 event->StopPropagation(); | 2026 event->StopPropagation(); |
| 2063 return; | 2027 return; |
| 2064 } | 2028 } |
| 2065 | 2029 |
| 2066 blink::WebTouchEvent touch_event = CreateWebTouchEventFromMotionEvent( | 2030 blink::WebTouchEvent touch_event = CreateWebTouchEventFromMotionEvent( |
| 2067 pointer_state_, event->may_cause_scrolling()); | 2031 pointer_state_, event->may_cause_scrolling()); |
| 2068 pointer_state_.CleanupRemovedTouchPoints(*event); | 2032 pointer_state_.CleanupRemovedTouchPoints(*event); |
| 2069 | 2033 |
| 2070 // Forward the touch event only if a touch point was updated, and | 2034 // Forward the touch event only if a touch point was updated, and |
| 2071 // there's a touch-event handler in the page, and no other | 2035 // there's a touch-event handler in the page, and no other |
| 2072 // touch-event is in the queue. It is important to always mark | 2036 // touch-event is in the queue. It is important to always mark |
| 2073 // events as being handled asynchronously if there is a touch-event | 2037 // events as being handled asynchronously if there is a touch-event |
| 2074 // handler in the page, or some touch-event is already in the queue, | 2038 // handler in the page, or some touch-event is already in the queue, |
| 2075 // even if no point has been updated. This ensures that this event | 2039 // even if no point has been updated. This ensures that this event |
| 2076 // does not get processed by the gesture recognizer before events | 2040 // does not get processed by the gesture recognizer before events |
| 2077 // currently awaiting dispatch in the touch queue. | 2041 // currently awaiting dispatch in the touch queue. |
| 2078 if (host_->ShouldForwardTouchEvent()) { | 2042 if (host_->ShouldForwardTouchEvent()) { |
| 2079 event->DisableSynchronousHandling(); | 2043 event->DisableSynchronousHandling(); |
| 2080 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); | 2044 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); |
| 2081 } | 2045 } |
| 2082 } | 2046 } |
| 2083 | 2047 |
| 2084 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { | 2048 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { |
| 2085 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); | 2049 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); |
| 2050 |
| 2051 if (selection_controller_) { |
| 2052 selection_controller_->HandleGestureEvent(event); |
| 2053 if (event->handled()) |
| 2054 return; |
| 2055 } |
| 2056 |
| 2086 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 2057 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
| 2087 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2058 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
| 2088 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { | 2059 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { |
| 2089 event->SetHandled(); | 2060 event->SetHandled(); |
| 2090 return; | 2061 return; |
| 2091 } | 2062 } |
| 2092 | 2063 |
| 2093 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | |
| 2094 return; | |
| 2095 | |
| 2096 // Confirm existing composition text on TAP gesture, to make sure the input | 2064 // Confirm existing composition text on TAP gesture, to make sure the input |
| 2097 // caret won't be moved with an ongoing composition text. | 2065 // caret won't be moved with an ongoing composition text. |
| 2098 if (event->type() == ui::ET_GESTURE_TAP) | 2066 if (event->type() == ui::ET_GESTURE_TAP) |
| 2099 FinishImeCompositionSession(); | 2067 FinishImeCompositionSession(); |
| 2100 | 2068 |
| 2101 RenderViewHostDelegate* delegate = NULL; | 2069 RenderViewHostDelegate* delegate = NULL; |
| 2102 if (host_->IsRenderView()) | 2070 if (host_->IsRenderView()) |
| 2103 delegate = RenderViewHost::From(host_)->GetDelegate(); | 2071 delegate = RenderViewHost::From(host_)->GetDelegate(); |
| 2104 | 2072 |
| 2105 if (delegate && event->type() == ui::ET_GESTURE_BEGIN && | 2073 if (delegate && event->type() == ui::ET_GESTURE_BEGIN && |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2208 host_->GetRootBrowserAccessibilityManager(); | 2176 host_->GetRootBrowserAccessibilityManager(); |
| 2209 if (manager) | 2177 if (manager) |
| 2210 manager->OnWindowFocused(); | 2178 manager->OnWindowFocused(); |
| 2211 } else if (window_ == lost_focus) { | 2179 } else if (window_ == lost_focus) { |
| 2212 host_->SetActive(false); | 2180 host_->SetActive(false); |
| 2213 host_->Blur(); | 2181 host_->Blur(); |
| 2214 | 2182 |
| 2215 DetachFromInputMethod(); | 2183 DetachFromInputMethod(); |
| 2216 host_->SetInputMethodActive(false); | 2184 host_->SetInputMethodActive(false); |
| 2217 | 2185 |
| 2218 if (touch_editing_client_) | 2186 if (selection_controller_) |
| 2219 touch_editing_client_->EndTouchEditing(false); | 2187 selection_controller_->HideAndDisallowShowingAutomatically(); |
| 2220 | 2188 |
| 2221 if (overscroll_controller_) | 2189 if (overscroll_controller_) |
| 2222 overscroll_controller_->Cancel(); | 2190 overscroll_controller_->Cancel(); |
| 2223 | 2191 |
| 2224 BrowserAccessibilityManager* manager = | 2192 BrowserAccessibilityManager* manager = |
| 2225 host_->GetRootBrowserAccessibilityManager(); | 2193 host_->GetRootBrowserAccessibilityManager(); |
| 2226 if (manager) | 2194 if (manager) |
| 2227 manager->OnWindowBlurred(); | 2195 manager->OnWindowBlurred(); |
| 2228 | 2196 |
| 2229 // If we lose the focus while fullscreen, close the window; Pepper Flash | 2197 // 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... |
| 2266 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved", | 2234 TRACE_EVENT1("ui", "RenderWidgetHostViewAura::OnHostMoved", |
| 2267 "new_origin", new_origin.ToString()); | 2235 "new_origin", new_origin.ToString()); |
| 2268 | 2236 |
| 2269 UpdateScreenInfo(window_); | 2237 UpdateScreenInfo(window_); |
| 2270 } | 2238 } |
| 2271 | 2239 |
| 2272 //////////////////////////////////////////////////////////////////////////////// | 2240 //////////////////////////////////////////////////////////////////////////////// |
| 2273 // RenderWidgetHostViewAura, private: | 2241 // RenderWidgetHostViewAura, private: |
| 2274 | 2242 |
| 2275 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { | 2243 RenderWidgetHostViewAura::~RenderWidgetHostViewAura() { |
| 2276 if (touch_editing_client_) | 2244 selection_controller_.reset(); |
| 2277 touch_editing_client_->OnViewDestroyed(); | 2245 selection_controller_client_.reset(); |
| 2278 | |
| 2279 delegated_frame_host_.reset(); | 2246 delegated_frame_host_.reset(); |
| 2280 window_observer_.reset(); | 2247 window_observer_.reset(); |
| 2281 if (window_->GetHost()) | 2248 if (window_->GetHost()) |
| 2282 window_->GetHost()->RemoveObserver(this); | 2249 window_->GetHost()->RemoveObserver(this); |
| 2283 UnlockMouse(); | 2250 UnlockMouse(); |
| 2284 if (popup_parent_host_view_) { | 2251 if (popup_parent_host_view_) { |
| 2285 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || | 2252 DCHECK(popup_parent_host_view_->popup_child_host_view_ == NULL || |
| 2286 popup_parent_host_view_->popup_child_host_view_ == this); | 2253 popup_parent_host_view_->popup_child_host_view_ == this); |
| 2287 popup_parent_host_view_->popup_child_host_view_ = NULL; | 2254 popup_parent_host_view_->popup_child_host_view_ = NULL; |
| 2288 } | 2255 } |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2418 host_->SendCursorVisibilityState(is_visible); | 2385 host_->SendCursorVisibilityState(is_visible); |
| 2419 } | 2386 } |
| 2420 | 2387 |
| 2421 void RenderWidgetHostViewAura::SetOverscrollControllerEnabled(bool enabled) { | 2388 void RenderWidgetHostViewAura::SetOverscrollControllerEnabled(bool enabled) { |
| 2422 if (!enabled) | 2389 if (!enabled) |
| 2423 overscroll_controller_.reset(); | 2390 overscroll_controller_.reset(); |
| 2424 else if (!overscroll_controller_) | 2391 else if (!overscroll_controller_) |
| 2425 overscroll_controller_.reset(new OverscrollController()); | 2392 overscroll_controller_.reset(new OverscrollController()); |
| 2426 } | 2393 } |
| 2427 | 2394 |
| 2395 void RenderWidgetHostViewAura::InitSelectionController( |
| 2396 ui::TouchSelectionControllerAuraClient* selection_controller_client) { |
| 2397 DCHECK(!selection_controller_client_); |
| 2398 selection_controller_client_.reset(selection_controller_client); |
| 2399 selection_controller_.reset( |
| 2400 new ui::TouchSelectionControllerAura(selection_controller_client)); |
| 2401 } |
| 2402 |
| 2428 void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() { | 2403 void RenderWidgetHostViewAura::SnapToPhysicalPixelBoundary() { |
| 2429 // The top left corner of our view in window coordinates might not land on a | 2404 // The top left corner of our view in window coordinates might not land on a |
| 2430 // device pixel boundary if we have a non-integer device scale. In that case, | 2405 // device pixel boundary if we have a non-integer device scale. In that case, |
| 2431 // to avoid the web contents area looking blurry we translate the web contents | 2406 // to avoid the web contents area looking blurry we translate the web contents |
| 2432 // in the +x, +y direction to land on the nearest pixel boundary. This may | 2407 // in the +x, +y direction to land on the nearest pixel boundary. This may |
| 2433 // cause the bottom and right edges to be clipped slightly, but that's ok. | 2408 // cause the bottom and right edges to be clipped slightly, but that's ok. |
| 2434 aura::Window* snapped = NULL; | 2409 aura::Window* snapped = NULL; |
| 2435 // On desktop, use the root window. On alternative environment (ash), | 2410 // On desktop, use the root window. On alternative environment (ash), |
| 2436 // use the toplevel window which must be already snapped. | 2411 // use the toplevel window which must be already snapped. |
| 2437 if (gfx::Screen::GetScreenFor(window_) != | 2412 if (gfx::Screen::GetScreenFor(window_) != |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2450 if (HasDisplayPropertyChanged(window_)) | 2425 if (HasDisplayPropertyChanged(window_)) |
| 2451 host_->InvalidateScreenInfo(); | 2426 host_->InvalidateScreenInfo(); |
| 2452 | 2427 |
| 2453 SnapToPhysicalPixelBoundary(); | 2428 SnapToPhysicalPixelBoundary(); |
| 2454 // Don't recursively call SetBounds if this bounds update is the result of | 2429 // Don't recursively call SetBounds if this bounds update is the result of |
| 2455 // a Window::SetBoundsInternal call. | 2430 // a Window::SetBoundsInternal call. |
| 2456 if (!in_bounds_changed_) | 2431 if (!in_bounds_changed_) |
| 2457 window_->SetBounds(rect); | 2432 window_->SetBounds(rect); |
| 2458 host_->WasResized(); | 2433 host_->WasResized(); |
| 2459 delegated_frame_host_->WasResized(); | 2434 delegated_frame_host_->WasResized(); |
| 2460 if (touch_editing_client_) { | |
| 2461 touch_editing_client_->OnSelectionOrCursorChanged(selection_anchor_, | |
| 2462 selection_focus_); | |
| 2463 } | |
| 2464 #if defined(OS_WIN) | 2435 #if defined(OS_WIN) |
| 2465 // Create the legacy dummy window which corresponds to the bounds of the | 2436 // Create the legacy dummy window which corresponds to the bounds of the |
| 2466 // webcontents. This will be passed as the container window for windowless | 2437 // webcontents. This will be passed as the container window for windowless |
| 2467 // plugins. | 2438 // plugins. |
| 2468 // Plugins like Flash assume the container window which is returned via the | 2439 // Plugins like Flash assume the container window which is returned via the |
| 2469 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. | 2440 // NPNVnetscapeWindow property corresponds to the bounds of the webpage. |
| 2470 // This is not true in Aura where we have only HWND which is the main Aura | 2441 // This is not true in Aura where we have only HWND which is the main Aura |
| 2471 // window. If we return this window to plugins like Flash then it causes the | 2442 // window. If we return this window to plugins like Flash then it causes the |
| 2472 // coordinate translations done by these plugins to break. | 2443 // coordinate translations done by these plugins to break. |
| 2473 // Additonally the legacy dummy window is needed for accessibility and for | 2444 // Additonally the legacy dummy window is needed for accessibility and for |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2597 } | 2568 } |
| 2598 #endif | 2569 #endif |
| 2599 | 2570 |
| 2600 host_->ForwardKeyboardEvent(event); | 2571 host_->ForwardKeyboardEvent(event); |
| 2601 } | 2572 } |
| 2602 | 2573 |
| 2603 SkColorType RenderWidgetHostViewAura::PreferredReadbackFormat() { | 2574 SkColorType RenderWidgetHostViewAura::PreferredReadbackFormat() { |
| 2604 return kN32_SkColorType; | 2575 return kN32_SkColorType; |
| 2605 } | 2576 } |
| 2606 | 2577 |
| 2578 void RenderWidgetHostViewAura::SelectionBoundsUpdated( |
| 2579 const ui::SelectionBound& start, |
| 2580 const ui::SelectionBound& end) { |
| 2581 if (selection_start_ == start && selection_end_ == end) |
| 2582 return; |
| 2583 |
| 2584 selection_start_ = start; |
| 2585 selection_end_ = end; |
| 2586 |
| 2587 if (GetInputMethod()) |
| 2588 GetInputMethod()->OnCaretBoundsChanged(this); |
| 2589 |
| 2590 if (selection_controller_) |
| 2591 selection_controller_->OnSelectionBoundsUpdated(start, end); |
| 2592 } |
| 2593 |
| 2607 //////////////////////////////////////////////////////////////////////////////// | 2594 //////////////////////////////////////////////////////////////////////////////// |
| 2608 // DelegatedFrameHost, public: | 2595 // DelegatedFrameHost, public: |
| 2609 | 2596 |
| 2610 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { | 2597 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { |
| 2611 return window_->layer(); | 2598 return window_->layer(); |
| 2612 } | 2599 } |
| 2613 | 2600 |
| 2614 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { | 2601 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { |
| 2615 return !host_->is_hidden(); | 2602 return !host_->is_hidden(); |
| 2616 } | 2603 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2679 | 2666 |
| 2680 //////////////////////////////////////////////////////////////////////////////// | 2667 //////////////////////////////////////////////////////////////////////////////// |
| 2681 // RenderWidgetHostViewBase, public: | 2668 // RenderWidgetHostViewBase, public: |
| 2682 | 2669 |
| 2683 // static | 2670 // static |
| 2684 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2671 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 2685 GetScreenInfoForWindow(results, NULL); | 2672 GetScreenInfoForWindow(results, NULL); |
| 2686 } | 2673 } |
| 2687 | 2674 |
| 2688 } // namespace content | 2675 } // namespace content |
| OLD | NEW |