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/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 #include "content/browser/accessibility/browser_accessibility_manager_win.h" | 81 #include "content/browser/accessibility/browser_accessibility_manager_win.h" |
82 #include "content/browser/accessibility/browser_accessibility_win.h" | 82 #include "content/browser/accessibility/browser_accessibility_win.h" |
83 #include "ui/base/win/hidden_window.h" | 83 #include "ui/base/win/hidden_window.h" |
84 #include "ui/gfx/gdi_util.h" | 84 #include "ui/gfx/gdi_util.h" |
85 #include "ui/gfx/win/dpi.h" | 85 #include "ui/gfx/win/dpi.h" |
86 #endif | 86 #endif |
87 | 87 |
88 using gfx::RectToSkIRect; | 88 using gfx::RectToSkIRect; |
89 using gfx::SkIRectToRect; | 89 using gfx::SkIRectToRect; |
90 | 90 |
91 using WebKit::WebScreenInfo; | 91 using blink::WebScreenInfo; |
92 using WebKit::WebTouchEvent; | 92 using blink::WebTouchEvent; |
93 | 93 |
94 namespace content { | 94 namespace content { |
95 | 95 |
96 namespace { | 96 namespace { |
97 | 97 |
98 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, | 98 void MailboxReleaseCallback(scoped_ptr<base::SharedMemory> shared_memory, |
99 unsigned sync_point, bool lost_resource) { | 99 unsigned sync_point, bool lost_resource) { |
100 // NOTE: shared_memory will get released when we go out of scope. | 100 // NOTE: shared_memory will get released when we go out of scope. |
101 } | 101 } |
102 | 102 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
213 const HWND owner = ::GetWindow(window, GW_OWNER); | 213 const HWND owner = ::GetWindow(window, GW_OWNER); |
214 if (toplevel_hwnd == owner) { | 214 if (toplevel_hwnd == owner) { |
215 ::PostMessage(window, WM_CANCELMODE, 0, 0); | 215 ::PostMessage(window, WM_CANCELMODE, 0, 0); |
216 } | 216 } |
217 } | 217 } |
218 | 218 |
219 return TRUE; | 219 return TRUE; |
220 } | 220 } |
221 #endif | 221 #endif |
222 | 222 |
223 void UpdateWebTouchEventAfterDispatch(WebKit::WebTouchEvent* event, | 223 void UpdateWebTouchEventAfterDispatch(blink::WebTouchEvent* event, |
224 WebKit::WebTouchPoint* point) { | 224 blink::WebTouchPoint* point) { |
225 if (point->state != WebKit::WebTouchPoint::StateReleased && | 225 if (point->state != blink::WebTouchPoint::StateReleased && |
226 point->state != WebKit::WebTouchPoint::StateCancelled) | 226 point->state != blink::WebTouchPoint::StateCancelled) |
227 return; | 227 return; |
228 --event->touchesLength; | 228 --event->touchesLength; |
229 for (unsigned i = point - event->touches; | 229 for (unsigned i = point - event->touches; |
230 i < event->touchesLength; | 230 i < event->touchesLength; |
231 ++i) { | 231 ++i) { |
232 event->touches[i] = event->touches[i + 1]; | 232 event->touches[i] = event->touches[i + 1]; |
233 } | 233 } |
234 } | 234 } |
235 | 235 |
236 bool CanRendererHandleEvent(const ui::MouseEvent* event) { | 236 bool CanRendererHandleEvent(const ui::MouseEvent* event) { |
(...skipping 1988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2225 } | 2225 } |
2226 | 2226 |
2227 //////////////////////////////////////////////////////////////////////////////// | 2227 //////////////////////////////////////////////////////////////////////////////// |
2228 // RenderWidgetHostViewAura, ui::TextInputClient implementation: | 2228 // RenderWidgetHostViewAura, ui::TextInputClient implementation: |
2229 void RenderWidgetHostViewAura::SetCompositionText( | 2229 void RenderWidgetHostViewAura::SetCompositionText( |
2230 const ui::CompositionText& composition) { | 2230 const ui::CompositionText& composition) { |
2231 if (!host_) | 2231 if (!host_) |
2232 return; | 2232 return; |
2233 | 2233 |
2234 // ui::CompositionUnderline should be identical to | 2234 // ui::CompositionUnderline should be identical to |
2235 // WebKit::WebCompositionUnderline, so that we can do reinterpret_cast safely. | 2235 // blink::WebCompositionUnderline, so that we can do reinterpret_cast safely. |
2236 COMPILE_ASSERT(sizeof(ui::CompositionUnderline) == | 2236 COMPILE_ASSERT(sizeof(ui::CompositionUnderline) == |
2237 sizeof(WebKit::WebCompositionUnderline), | 2237 sizeof(blink::WebCompositionUnderline), |
2238 ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); | 2238 ui_CompositionUnderline__WebKit_WebCompositionUnderline_diff); |
2239 | 2239 |
2240 // TODO(suzhe): convert both renderer_host and renderer to use | 2240 // TODO(suzhe): convert both renderer_host and renderer to use |
2241 // ui::CompositionText. | 2241 // ui::CompositionText. |
2242 const std::vector<WebKit::WebCompositionUnderline>& underlines = | 2242 const std::vector<blink::WebCompositionUnderline>& underlines = |
2243 reinterpret_cast<const std::vector<WebKit::WebCompositionUnderline>&>( | 2243 reinterpret_cast<const std::vector<blink::WebCompositionUnderline>&>( |
2244 composition.underlines); | 2244 composition.underlines); |
2245 | 2245 |
2246 // TODO(suzhe): due to a bug of webkit, we can't use selection range with | 2246 // TODO(suzhe): due to a bug of webkit, we can't use selection range with |
2247 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 | 2247 // composition string. See: https://bugs.webkit.org/show_bug.cgi?id=37788 |
2248 host_->ImeSetComposition(composition.text, underlines, | 2248 host_->ImeSetComposition(composition.text, underlines, |
2249 composition.selection.end(), | 2249 composition.selection.end(), |
2250 composition.selection.end()); | 2250 composition.selection.end()); |
2251 | 2251 |
2252 has_composition_text_ = !composition.text.empty(); | 2252 has_composition_text_ = !composition.text.empty(); |
2253 } | 2253 } |
(...skipping 18 matching lines...) Expand all Loading... |
2272 } | 2272 } |
2273 | 2273 |
2274 void RenderWidgetHostViewAura::InsertChar(char16 ch, int flags) { | 2274 void RenderWidgetHostViewAura::InsertChar(char16 ch, int flags) { |
2275 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { | 2275 if (popup_child_host_view_ && popup_child_host_view_->NeedsInputGrab()) { |
2276 popup_child_host_view_->InsertChar(ch, flags); | 2276 popup_child_host_view_->InsertChar(ch, flags); |
2277 return; | 2277 return; |
2278 } | 2278 } |
2279 | 2279 |
2280 if (host_) { | 2280 if (host_) { |
2281 double now = ui::EventTimeForNow().InSecondsF(); | 2281 double now = ui::EventTimeForNow().InSecondsF(); |
2282 // Send a WebKit::WebInputEvent::Char event to |host_|. | 2282 // Send a blink::WebInputEvent::Char event to |host_|. |
2283 NativeWebKeyboardEvent webkit_event(ui::ET_KEY_PRESSED, | 2283 NativeWebKeyboardEvent webkit_event(ui::ET_KEY_PRESSED, |
2284 true /* is_char */, | 2284 true /* is_char */, |
2285 ch, | 2285 ch, |
2286 flags, | 2286 flags, |
2287 now); | 2287 now); |
2288 host_->ForwardKeyboardEvent(webkit_event); | 2288 host_->ForwardKeyboardEvent(webkit_event); |
2289 } | 2289 } |
2290 } | 2290 } |
2291 | 2291 |
2292 gfx::NativeWindow RenderWidgetHostViewAura::GetAttachedWindow() const { | 2292 gfx::NativeWindow RenderWidgetHostViewAura::GetAttachedWindow() const { |
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2427 // TODO(suzhe): implement the newly added “locale” property of HTML DOM | 2427 // TODO(suzhe): implement the newly added “locale” property of HTML DOM |
2428 // TextEvent. | 2428 // TextEvent. |
2429 } | 2429 } |
2430 | 2430 |
2431 bool RenderWidgetHostViewAura::ChangeTextDirectionAndLayoutAlignment( | 2431 bool RenderWidgetHostViewAura::ChangeTextDirectionAndLayoutAlignment( |
2432 base::i18n::TextDirection direction) { | 2432 base::i18n::TextDirection direction) { |
2433 if (!host_) | 2433 if (!host_) |
2434 return false; | 2434 return false; |
2435 host_->UpdateTextDirection( | 2435 host_->UpdateTextDirection( |
2436 direction == base::i18n::RIGHT_TO_LEFT ? | 2436 direction == base::i18n::RIGHT_TO_LEFT ? |
2437 WebKit::WebTextDirectionRightToLeft : | 2437 blink::WebTextDirectionRightToLeft : |
2438 WebKit::WebTextDirectionLeftToRight); | 2438 blink::WebTextDirectionLeftToRight); |
2439 host_->NotifyTextDirection(); | 2439 host_->NotifyTextDirection(); |
2440 return true; | 2440 return true; |
2441 } | 2441 } |
2442 | 2442 |
2443 void RenderWidgetHostViewAura::ExtendSelectionAndDelete( | 2443 void RenderWidgetHostViewAura::ExtendSelectionAndDelete( |
2444 size_t before, size_t after) { | 2444 size_t before, size_t after) { |
2445 if (host_) | 2445 if (host_) |
2446 host_->ExtendSelectionAndDelete(before, after); | 2446 host_->ExtendSelectionAndDelete(before, after); |
2447 } | 2447 } |
2448 | 2448 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2509 return HTCLIENT; | 2509 return HTCLIENT; |
2510 } | 2510 } |
2511 | 2511 |
2512 bool RenderWidgetHostViewAura::ShouldDescendIntoChildForEventHandling( | 2512 bool RenderWidgetHostViewAura::ShouldDescendIntoChildForEventHandling( |
2513 aura::Window* child, | 2513 aura::Window* child, |
2514 const gfx::Point& location) { | 2514 const gfx::Point& location) { |
2515 return true; | 2515 return true; |
2516 } | 2516 } |
2517 | 2517 |
2518 bool RenderWidgetHostViewAura::CanFocus() { | 2518 bool RenderWidgetHostViewAura::CanFocus() { |
2519 return popup_type_ == WebKit::WebPopupTypeNone; | 2519 return popup_type_ == blink::WebPopupTypeNone; |
2520 } | 2520 } |
2521 | 2521 |
2522 void RenderWidgetHostViewAura::OnCaptureLost() { | 2522 void RenderWidgetHostViewAura::OnCaptureLost() { |
2523 host_->LostCapture(); | 2523 host_->LostCapture(); |
2524 if (touch_editing_client_) | 2524 if (touch_editing_client_) |
2525 touch_editing_client_->EndTouchEditing(); | 2525 touch_editing_client_->EndTouchEditing(); |
2526 } | 2526 } |
2527 | 2527 |
2528 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { | 2528 void RenderWidgetHostViewAura::OnPaint(gfx::Canvas* canvas) { |
2529 bool has_backing_store = !!host_->GetBackingStore(false); | 2529 bool has_backing_store = !!host_->GetBackingStore(false); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2613 scoped_refptr<ui::Texture> old_texture = old_layer->external_texture(); | 2613 scoped_refptr<ui::Texture> old_texture = old_layer->external_texture(); |
2614 // The new_layer is the one that will be used by our Window, so that's the one | 2614 // The new_layer is the one that will be used by our Window, so that's the one |
2615 // that should keep our texture. old_layer will be returned to the | 2615 // that should keep our texture. old_layer will be returned to the |
2616 // RecreateLayer caller, and should have a copy. | 2616 // RecreateLayer caller, and should have a copy. |
2617 if (old_texture.get()) { | 2617 if (old_texture.get()) { |
2618 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); | 2618 ImageTransportFactory* factory = ImageTransportFactory::GetInstance(); |
2619 GLHelper* gl_helper = factory->GetGLHelper(); | 2619 GLHelper* gl_helper = factory->GetGLHelper(); |
2620 scoped_refptr<ui::Texture> new_texture; | 2620 scoped_refptr<ui::Texture> new_texture; |
2621 if (host_->is_accelerated_compositing_active() && | 2621 if (host_->is_accelerated_compositing_active() && |
2622 gl_helper && current_surface_.get()) { | 2622 gl_helper && current_surface_.get()) { |
2623 WebKit::WebGLId texture_id = | 2623 blink::WebGLId texture_id = |
2624 gl_helper->CopyTexture(current_surface_->PrepareTexture(), | 2624 gl_helper->CopyTexture(current_surface_->PrepareTexture(), |
2625 current_surface_->size()); | 2625 current_surface_->size()); |
2626 if (texture_id) { | 2626 if (texture_id) { |
2627 new_texture = factory->CreateOwnedTexture( | 2627 new_texture = factory->CreateOwnedTexture( |
2628 current_surface_->size(), | 2628 current_surface_->size(), |
2629 current_surface_->device_scale_factor(), texture_id); | 2629 current_surface_->device_scale_factor(), texture_id); |
2630 } | 2630 } |
2631 } | 2631 } |
2632 if (new_texture.get()) | 2632 if (new_texture.get()) |
2633 old_layer->SetExternalTexture(new_texture.get()); | 2633 old_layer->SetExternalTexture(new_texture.get()); |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2719 | 2719 |
2720 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2720 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) |
2721 return; | 2721 return; |
2722 | 2722 |
2723 if (mouse_locked_) { | 2723 if (mouse_locked_) { |
2724 aura::client::CursorClient* cursor_client = | 2724 aura::client::CursorClient* cursor_client = |
2725 aura::client::GetCursorClient(window_->GetRootWindow()); | 2725 aura::client::GetCursorClient(window_->GetRootWindow()); |
2726 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); | 2726 DCHECK(!cursor_client || !cursor_client->IsCursorVisible()); |
2727 | 2727 |
2728 if (event->type() == ui::ET_MOUSEWHEEL) { | 2728 if (event->type() == ui::ET_MOUSEWHEEL) { |
2729 WebKit::WebMouseWheelEvent mouse_wheel_event = | 2729 blink::WebMouseWheelEvent mouse_wheel_event = |
2730 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); | 2730 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); |
2731 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) | 2731 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) |
2732 host_->ForwardWheelEvent(mouse_wheel_event); | 2732 host_->ForwardWheelEvent(mouse_wheel_event); |
2733 return; | 2733 return; |
2734 } | 2734 } |
2735 | 2735 |
2736 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); | 2736 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); |
2737 | 2737 |
2738 // If we receive non client mouse messages while we are in the locked state | 2738 // If we receive non client mouse messages while we are in the locked state |
2739 // it probably means that the mouse left the borders of our window and | 2739 // it probably means that the mouse left the borders of our window and |
2740 // needs to be moved back to the center. | 2740 // needs to be moved back to the center. |
2741 if (event->flags() & ui::EF_IS_NON_CLIENT) { | 2741 if (event->flags() & ui::EF_IS_NON_CLIENT) { |
2742 synthetic_move_sent_ = true; | 2742 synthetic_move_sent_ = true; |
2743 window_->MoveCursorTo(center); | 2743 window_->MoveCursorTo(center); |
2744 return; | 2744 return; |
2745 } | 2745 } |
2746 | 2746 |
2747 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); | 2747 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(event); |
2748 | 2748 |
2749 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || | 2749 bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || |
2750 event->type() == ui::ET_MOUSE_DRAGGED) && | 2750 event->type() == ui::ET_MOUSE_DRAGGED) && |
2751 mouse_event.x == center.x() && mouse_event.y == center.y(); | 2751 mouse_event.x == center.x() && mouse_event.y == center.y(); |
2752 | 2752 |
2753 ModifyEventMovementAndCoords(&mouse_event); | 2753 ModifyEventMovementAndCoords(&mouse_event); |
2754 | 2754 |
2755 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; | 2755 bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; |
2756 if (should_not_forward) { | 2756 if (should_not_forward) { |
2757 synthetic_move_sent_ = false; | 2757 synthetic_move_sent_ = false; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2792 // dismiss them. | 2792 // dismiss them. |
2793 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); | 2793 aura::WindowEventDispatcher* dispatcher = window_->GetDispatcher(); |
2794 if (dispatcher) { | 2794 if (dispatcher) { |
2795 HWND parent = dispatcher->GetAcceleratedWidget(); | 2795 HWND parent = dispatcher->GetAcceleratedWidget(); |
2796 HWND toplevel_hwnd = ::GetAncestor(parent, GA_ROOT); | 2796 HWND toplevel_hwnd = ::GetAncestor(parent, GA_ROOT); |
2797 EnumThreadWindows(GetCurrentThreadId(), | 2797 EnumThreadWindows(GetCurrentThreadId(), |
2798 DismissOwnedPopups, | 2798 DismissOwnedPopups, |
2799 reinterpret_cast<LPARAM>(toplevel_hwnd)); | 2799 reinterpret_cast<LPARAM>(toplevel_hwnd)); |
2800 } | 2800 } |
2801 #endif | 2801 #endif |
2802 WebKit::WebMouseWheelEvent mouse_wheel_event = | 2802 blink::WebMouseWheelEvent mouse_wheel_event = |
2803 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); | 2803 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); |
2804 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) | 2804 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) |
2805 host_->ForwardWheelEvent(mouse_wheel_event); | 2805 host_->ForwardWheelEvent(mouse_wheel_event); |
2806 } else if (CanRendererHandleEvent(event) && | 2806 } else if (CanRendererHandleEvent(event) && |
2807 !(event->flags() & ui::EF_FROM_TOUCH)) { | 2807 !(event->flags() & ui::EF_FROM_TOUCH)) { |
2808 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); | 2808 blink::WebMouseEvent mouse_event = MakeWebMouseEvent(event); |
2809 ModifyEventMovementAndCoords(&mouse_event); | 2809 ModifyEventMovementAndCoords(&mouse_event); |
2810 host_->ForwardMouseEvent(mouse_event); | 2810 host_->ForwardMouseEvent(mouse_event); |
2811 } | 2811 } |
2812 | 2812 |
2813 switch (event->type()) { | 2813 switch (event->type()) { |
2814 case ui::ET_MOUSE_PRESSED: | 2814 case ui::ET_MOUSE_PRESSED: |
2815 window_->SetCapture(); | 2815 window_->SetCapture(); |
2816 // Confirm existing composition text on mouse click events, to make sure | 2816 // Confirm existing composition text on mouse click events, to make sure |
2817 // the input caret won't be moved with an ongoing composition text. | 2817 // the input caret won't be moved with an ongoing composition text. |
2818 FinishImeCompositionSession(); | 2818 FinishImeCompositionSession(); |
(...skipping 19 matching lines...) Expand all Loading... |
2838 } | 2838 } |
2839 | 2839 |
2840 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { | 2840 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { |
2841 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); | 2841 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnScrollEvent"); |
2842 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2842 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) |
2843 return; | 2843 return; |
2844 | 2844 |
2845 if (event->type() == ui::ET_SCROLL) { | 2845 if (event->type() == ui::ET_SCROLL) { |
2846 if (event->finger_count() != 2) | 2846 if (event->finger_count() != 2) |
2847 return; | 2847 return; |
2848 WebKit::WebGestureEvent gesture_event = | 2848 blink::WebGestureEvent gesture_event = |
2849 MakeWebGestureEventFlingCancel(); | 2849 MakeWebGestureEventFlingCancel(); |
2850 host_->ForwardGestureEvent(gesture_event); | 2850 host_->ForwardGestureEvent(gesture_event); |
2851 WebKit::WebMouseWheelEvent mouse_wheel_event = | 2851 blink::WebMouseWheelEvent mouse_wheel_event = |
2852 MakeWebMouseWheelEvent(event); | 2852 MakeWebMouseWheelEvent(event); |
2853 host_->ForwardWheelEvent(mouse_wheel_event); | 2853 host_->ForwardWheelEvent(mouse_wheel_event); |
2854 RecordAction(UserMetricsAction("TrackpadScroll")); | 2854 RecordAction(UserMetricsAction("TrackpadScroll")); |
2855 } else if (event->type() == ui::ET_SCROLL_FLING_START || | 2855 } else if (event->type() == ui::ET_SCROLL_FLING_START || |
2856 event->type() == ui::ET_SCROLL_FLING_CANCEL) { | 2856 event->type() == ui::ET_SCROLL_FLING_CANCEL) { |
2857 WebKit::WebGestureEvent gesture_event = | 2857 blink::WebGestureEvent gesture_event = |
2858 MakeWebGestureEvent(event); | 2858 MakeWebGestureEvent(event); |
2859 host_->ForwardGestureEvent(gesture_event); | 2859 host_->ForwardGestureEvent(gesture_event); |
2860 if (event->type() == ui::ET_SCROLL_FLING_START) | 2860 if (event->type() == ui::ET_SCROLL_FLING_START) |
2861 RecordAction(UserMetricsAction("TrackpadScrollFling")); | 2861 RecordAction(UserMetricsAction("TrackpadScrollFling")); |
2862 } | 2862 } |
2863 | 2863 |
2864 event->SetHandled(); | 2864 event->SetHandled(); |
2865 } | 2865 } |
2866 | 2866 |
2867 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { | 2867 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { |
2868 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); | 2868 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); |
2869 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2869 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) |
2870 return; | 2870 return; |
2871 | 2871 |
2872 // Update the touch event first. | 2872 // Update the touch event first. |
2873 WebKit::WebTouchPoint* point = UpdateWebTouchEventFromUIEvent(*event, | 2873 blink::WebTouchPoint* point = UpdateWebTouchEventFromUIEvent(*event, |
2874 &touch_event_); | 2874 &touch_event_); |
2875 | 2875 |
2876 // Forward the touch event only if a touch point was updated, and there's a | 2876 // Forward the touch event only if a touch point was updated, and there's a |
2877 // touch-event handler in the page, and no other touch-event is in the queue. | 2877 // touch-event handler in the page, and no other touch-event is in the queue. |
2878 // It is important to always consume the event if there is a touch-event | 2878 // It is important to always consume the event if there is a touch-event |
2879 // handler in the page, or some touch-event is already in the queue, even if | 2879 // handler in the page, or some touch-event is already in the queue, even if |
2880 // no point has been updated, to make sure that this event does not get | 2880 // no point has been updated, to make sure that this event does not get |
2881 // processed by the gesture recognizer before the events in the queue. | 2881 // processed by the gesture recognizer before the events in the queue. |
2882 if (host_->ShouldForwardTouchEvent()) | 2882 if (host_->ShouldForwardTouchEvent()) |
2883 event->StopPropagation(); | 2883 event->StopPropagation(); |
(...skipping 12 matching lines...) Expand all Loading... |
2896 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2896 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
2897 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { | 2897 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { |
2898 event->SetHandled(); | 2898 event->SetHandled(); |
2899 return; | 2899 return; |
2900 } | 2900 } |
2901 | 2901 |
2902 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2902 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) |
2903 return; | 2903 return; |
2904 | 2904 |
2905 RenderViewHostDelegate* delegate = NULL; | 2905 RenderViewHostDelegate* delegate = NULL; |
2906 if (popup_type_ == WebKit::WebPopupTypeNone && !is_fullscreen_) | 2906 if (popup_type_ == blink::WebPopupTypeNone && !is_fullscreen_) |
2907 delegate = RenderViewHost::From(host_)->GetDelegate(); | 2907 delegate = RenderViewHost::From(host_)->GetDelegate(); |
2908 | 2908 |
2909 if (delegate && event->type() == ui::ET_GESTURE_BEGIN && | 2909 if (delegate && event->type() == ui::ET_GESTURE_BEGIN && |
2910 event->details().touch_points() == 1) { | 2910 event->details().touch_points() == 1) { |
2911 delegate->HandleGestureBegin(); | 2911 delegate->HandleGestureBegin(); |
2912 } | 2912 } |
2913 | 2913 |
2914 WebKit::WebGestureEvent gesture = MakeWebGestureEvent(event); | 2914 blink::WebGestureEvent gesture = MakeWebGestureEvent(event); |
2915 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 2915 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
2916 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an | 2916 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an |
2917 // event to stop any in-progress flings. | 2917 // event to stop any in-progress flings. |
2918 WebKit::WebGestureEvent fling_cancel = gesture; | 2918 blink::WebGestureEvent fling_cancel = gesture; |
2919 fling_cancel.type = WebKit::WebInputEvent::GestureFlingCancel; | 2919 fling_cancel.type = blink::WebInputEvent::GestureFlingCancel; |
2920 fling_cancel.sourceDevice = WebKit::WebGestureEvent::Touchscreen; | 2920 fling_cancel.sourceDevice = blink::WebGestureEvent::Touchscreen; |
2921 host_->ForwardGestureEvent(fling_cancel); | 2921 host_->ForwardGestureEvent(fling_cancel); |
2922 } | 2922 } |
2923 | 2923 |
2924 if (gesture.type != WebKit::WebInputEvent::Undefined) { | 2924 if (gesture.type != blink::WebInputEvent::Undefined) { |
2925 host_->ForwardGestureEventWithLatencyInfo(gesture, *event->latency()); | 2925 host_->ForwardGestureEventWithLatencyInfo(gesture, *event->latency()); |
2926 | 2926 |
2927 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || | 2927 if (event->type() == ui::ET_GESTURE_SCROLL_BEGIN || |
2928 event->type() == ui::ET_GESTURE_SCROLL_UPDATE || | 2928 event->type() == ui::ET_GESTURE_SCROLL_UPDATE || |
2929 event->type() == ui::ET_GESTURE_SCROLL_END) { | 2929 event->type() == ui::ET_GESTURE_SCROLL_END) { |
2930 RecordAction(UserMetricsAction("TouchscreenScroll")); | 2930 RecordAction(UserMetricsAction("TouchscreenScroll")); |
2931 } else if (event->type() == ui::ET_SCROLL_FLING_START) { | 2931 } else if (event->type() == ui::ET_SCROLL_FLING_START) { |
2932 RecordAction(UserMetricsAction("TouchscreenScrollFling")); | 2932 RecordAction(UserMetricsAction("TouchscreenScrollFling")); |
2933 } | 2933 } |
2934 } | 2934 } |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3272 } | 3272 } |
3273 | 3273 |
3274 ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const { | 3274 ui::InputMethod* RenderWidgetHostViewAura::GetInputMethod() const { |
3275 aura::Window* root_window = window_->GetRootWindow(); | 3275 aura::Window* root_window = window_->GetRootWindow(); |
3276 if (!root_window) | 3276 if (!root_window) |
3277 return NULL; | 3277 return NULL; |
3278 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); | 3278 return root_window->GetProperty(aura::client::kRootWindowInputMethodKey); |
3279 } | 3279 } |
3280 | 3280 |
3281 bool RenderWidgetHostViewAura::NeedsInputGrab() { | 3281 bool RenderWidgetHostViewAura::NeedsInputGrab() { |
3282 return popup_type_ == WebKit::WebPopupTypeSelect; | 3282 return popup_type_ == blink::WebPopupTypeSelect; |
3283 } | 3283 } |
3284 | 3284 |
3285 void RenderWidgetHostViewAura::FinishImeCompositionSession() { | 3285 void RenderWidgetHostViewAura::FinishImeCompositionSession() { |
3286 if (!has_composition_text_) | 3286 if (!has_composition_text_) |
3287 return; | 3287 return; |
3288 if (host_) | 3288 if (host_) |
3289 host_->ImeConfirmComposition(string16(), gfx::Range::InvalidRange(), false); | 3289 host_->ImeConfirmComposition(string16(), gfx::Range::InvalidRange(), false); |
3290 ImeCancelComposition(); | 3290 ImeCancelComposition(); |
3291 } | 3291 } |
3292 | 3292 |
3293 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords( | 3293 void RenderWidgetHostViewAura::ModifyEventMovementAndCoords( |
3294 WebKit::WebMouseEvent* event) { | 3294 blink::WebMouseEvent* event) { |
3295 // If the mouse has just entered, we must report zero movementX/Y. Hence we | 3295 // If the mouse has just entered, we must report zero movementX/Y. Hence we |
3296 // reset any global_mouse_position set previously. | 3296 // reset any global_mouse_position set previously. |
3297 if (event->type == WebKit::WebInputEvent::MouseEnter || | 3297 if (event->type == blink::WebInputEvent::MouseEnter || |
3298 event->type == WebKit::WebInputEvent::MouseLeave) | 3298 event->type == blink::WebInputEvent::MouseLeave) |
3299 global_mouse_position_.SetPoint(event->globalX, event->globalY); | 3299 global_mouse_position_.SetPoint(event->globalX, event->globalY); |
3300 | 3300 |
3301 // Movement is computed by taking the difference of the new cursor position | 3301 // Movement is computed by taking the difference of the new cursor position |
3302 // and the previous. Under mouse lock the cursor will be warped back to the | 3302 // and the previous. Under mouse lock the cursor will be warped back to the |
3303 // center so that we are not limited by clipping boundaries. | 3303 // center so that we are not limited by clipping boundaries. |
3304 // We do not measure movement as the delta from cursor to center because | 3304 // We do not measure movement as the delta from cursor to center because |
3305 // we may receive more mouse movement events before our warp has taken | 3305 // we may receive more mouse movement events before our warp has taken |
3306 // effect. | 3306 // effect. |
3307 event->movementX = event->globalX - global_mouse_position_.x(); | 3307 event->movementX = event->globalX - global_mouse_position_.x(); |
3308 event->movementY = event->globalY - global_mouse_position_.y(); | 3308 event->movementY = event->globalY - global_mouse_position_.y(); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3377 compositor->AddObserver(this); | 3377 compositor->AddObserver(this); |
3378 | 3378 |
3379 can_lock_compositor_ = NO_PENDING_COMMIT; | 3379 can_lock_compositor_ = NO_PENDING_COMMIT; |
3380 on_compositing_did_commit_callbacks_.push_back(callback); | 3380 on_compositing_did_commit_callbacks_.push_back(callback); |
3381 } | 3381 } |
3382 | 3382 |
3383 void RenderWidgetHostViewAura::AddedToRootWindow() { | 3383 void RenderWidgetHostViewAura::AddedToRootWindow() { |
3384 window_->GetDispatcher()->AddRootWindowObserver(this); | 3384 window_->GetDispatcher()->AddRootWindowObserver(this); |
3385 host_->ParentChanged(GetNativeViewId()); | 3385 host_->ParentChanged(GetNativeViewId()); |
3386 UpdateScreenInfo(window_); | 3386 UpdateScreenInfo(window_); |
3387 if (popup_type_ != WebKit::WebPopupTypeNone) | 3387 if (popup_type_ != blink::WebPopupTypeNone) |
3388 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); | 3388 event_filter_for_popup_exit_.reset(new EventFilterForPopupExit(this)); |
3389 | 3389 |
3390 aura::client::CursorClient* cursor_client = | 3390 aura::client::CursorClient* cursor_client = |
3391 aura::client::GetCursorClient(window_->GetRootWindow()); | 3391 aura::client::GetCursorClient(window_->GetRootWindow()); |
3392 if (cursor_client) { | 3392 if (cursor_client) { |
3393 cursor_client->AddObserver(this); | 3393 cursor_client->AddObserver(this); |
3394 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); | 3394 NotifyRendererOfCursorVisibilityState(cursor_client->IsCursorVisible()); |
3395 } | 3395 } |
3396 if (current_surface_.get()) | 3396 if (current_surface_.get()) |
3397 UpdateExternalTexture(); | 3397 UpdateExternalTexture(); |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3441 RenderWidgetHost* widget) { | 3441 RenderWidgetHost* widget) { |
3442 return new RenderWidgetHostViewAura(widget); | 3442 return new RenderWidgetHostViewAura(widget); |
3443 } | 3443 } |
3444 | 3444 |
3445 // static | 3445 // static |
3446 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 3446 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
3447 GetScreenInfoForWindow(results, NULL); | 3447 GetScreenInfoForWindow(results, NULL); |
3448 } | 3448 } |
3449 | 3449 |
3450 } // namespace content | 3450 } // namespace content |
OLD | NEW |