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/debug/trace_event.h" | 12 #include "base/debug/trace_event.h" |
13 #include "base/logging.h" | 13 #include "base/logging.h" |
14 #include "base/message_loop/message_loop.h" | 14 #include "base/message_loop/message_loop.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.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/web_input_event_util.h" |
30 #include "content/browser/renderer_host/overscroll_controller.h" | 31 #include "content/browser/renderer_host/overscroll_controller.h" |
31 #include "content/browser/renderer_host/render_view_host_delegate.h" | 32 #include "content/browser/renderer_host/render_view_host_delegate.h" |
32 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 33 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
33 #include "content/browser/renderer_host/render_view_host_impl.h" | 34 #include "content/browser/renderer_host/render_view_host_impl.h" |
34 #include "content/browser/renderer_host/render_widget_host_impl.h" | 35 #include "content/browser/renderer_host/render_widget_host_impl.h" |
35 #include "content/browser/renderer_host/ui_events_helper.h" | 36 #include "content/browser/renderer_host/ui_events_helper.h" |
36 #include "content/browser/renderer_host/web_input_event_aura.h" | 37 #include "content/browser/renderer_host/web_input_event_aura.h" |
37 #include "content/common/gpu/client/gl_helper.h" | 38 #include "content/common/gpu/client/gl_helper.h" |
38 #include "content/common/gpu/gpu_messages.h" | 39 #include "content/common/gpu/gpu_messages.h" |
39 #include "content/common/view_messages.h" | 40 #include "content/common/view_messages.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 const HWND owner = ::GetWindow(window, GW_OWNER); | 224 const HWND owner = ::GetWindow(window, GW_OWNER); |
224 if (toplevel_hwnd == owner) { | 225 if (toplevel_hwnd == owner) { |
225 ::PostMessage(window, WM_CANCELMODE, 0, 0); | 226 ::PostMessage(window, WM_CANCELMODE, 0, 0); |
226 } | 227 } |
227 } | 228 } |
228 | 229 |
229 return TRUE; | 230 return TRUE; |
230 } | 231 } |
231 #endif | 232 #endif |
232 | 233 |
233 void UpdateWebTouchEventAfterDispatch(blink::WebTouchEvent* event, | |
234 blink::WebTouchPoint* point) { | |
235 if (point->state != blink::WebTouchPoint::StateReleased && | |
236 point->state != blink::WebTouchPoint::StateCancelled) | |
237 return; | |
238 | |
239 const unsigned new_length = event->touchesLength - 1; | |
240 // Work around a gcc 4.9 bug. crbug.com/392872 | |
241 if (new_length >= event->touchesLengthCap) | |
242 return; | |
243 | |
244 for (unsigned i = point - event->touches; i < new_length; ++i) | |
245 event->touches[i] = event->touches[i + 1]; | |
246 event->touchesLength = new_length; | |
247 } | |
248 | |
249 bool CanRendererHandleEvent(const ui::MouseEvent* event) { | 234 bool CanRendererHandleEvent(const ui::MouseEvent* event) { |
250 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) | 235 if (event->type() == ui::ET_MOUSE_CAPTURE_CHANGED) |
251 return false; | 236 return false; |
252 | 237 |
253 #if defined(OS_WIN) | 238 #if defined(OS_WIN) |
254 // Renderer cannot handle WM_XBUTTON or NC events. | 239 // Renderer cannot handle WM_XBUTTON or NC events. |
255 switch (event->native_event().message) { | 240 switch (event->native_event().message) { |
256 case WM_XBUTTONDOWN: | 241 case WM_XBUTTONDOWN: |
257 case WM_XBUTTONUP: | 242 case WM_XBUTTONUP: |
258 case WM_XBUTTONDBLCLK: | 243 case WM_XBUTTONDBLCLK: |
(...skipping 1789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2048 | 2033 |
2049 event->SetHandled(); | 2034 event->SetHandled(); |
2050 } | 2035 } |
2051 | 2036 |
2052 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { | 2037 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { |
2053 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); | 2038 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); |
2054 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2039 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) |
2055 return; | 2040 return; |
2056 | 2041 |
2057 // Update the touch event first. | 2042 // Update the touch event first. |
2058 blink::WebTouchPoint* point = | 2043 if (!pointer_state_.OnTouch(*event)) { |
2059 UpdateWebTouchEventFromUIEvent(*event, &touch_event_); | |
2060 | |
2061 if (!point) { | |
2062 event->StopPropagation(); | 2044 event->StopPropagation(); |
2063 return; | 2045 return; |
2064 } | 2046 } |
2065 | 2047 |
| 2048 blink::WebTouchEvent touch_event = CreateWebTouchEventFromMotionEvent( |
| 2049 pointer_state_, event->may_cause_scrolling()); |
| 2050 pointer_state_.CleanupRemovedTouchPoints(*event); |
| 2051 |
2066 // Forward the touch event only if a touch point was updated, and | 2052 // Forward the touch event only if a touch point was updated, and |
2067 // there's a touch-event handler in the page, and no other | 2053 // there's a touch-event handler in the page, and no other |
2068 // touch-event is in the queue. It is important to always mark | 2054 // touch-event is in the queue. It is important to always mark |
2069 // events as being handled asynchronously if there is a touch-event | 2055 // events as being handled asynchronously if there is a touch-event |
2070 // handler in the page, or some touch-event is already in the queue, | 2056 // handler in the page, or some touch-event is already in the queue, |
2071 // even if no point has been updated. This ensures that this event | 2057 // even if no point has been updated. This ensures that this event |
2072 // does not get processed by the gesture recognizer before events | 2058 // does not get processed by the gesture recognizer before events |
2073 // currently awaiting dispatch in the touch queue. | 2059 // currently awaiting dispatch in the touch queue. |
2074 if (host_->ShouldForwardTouchEvent()) { | 2060 if (host_->ShouldForwardTouchEvent()) { |
2075 event->DisableSynchronousHandling(); | 2061 event->DisableSynchronousHandling(); |
2076 host_->ForwardTouchEventWithLatencyInfo(touch_event_, *event->latency()); | 2062 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); |
2077 } | 2063 } |
2078 UpdateWebTouchEventAfterDispatch(&touch_event_, point); | |
2079 } | 2064 } |
2080 | 2065 |
2081 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { | 2066 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { |
2082 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); | 2067 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); |
2083 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 2068 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
2084 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2069 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
2085 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { | 2070 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { |
2086 event->SetHandled(); | 2071 event->SetHandled(); |
2087 return; | 2072 return; |
2088 } | 2073 } |
(...skipping 561 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2650 | 2635 |
2651 //////////////////////////////////////////////////////////////////////////////// | 2636 //////////////////////////////////////////////////////////////////////////////// |
2652 // RenderWidgetHostViewBase, public: | 2637 // RenderWidgetHostViewBase, public: |
2653 | 2638 |
2654 // static | 2639 // static |
2655 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2640 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2656 GetScreenInfoForWindow(results, NULL); | 2641 GetScreenInfoForWindow(results, NULL); |
2657 } | 2642 } |
2658 | 2643 |
2659 } // namespace content | 2644 } // namespace content |
OLD | NEW |