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 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2026 | 2011 |
2027 event->SetHandled(); | 2012 event->SetHandled(); |
2028 } | 2013 } |
2029 | 2014 |
2030 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { | 2015 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { |
2031 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); | 2016 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); |
2032 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2017 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) |
2033 return; | 2018 return; |
2034 | 2019 |
2035 // Update the touch event first. | 2020 // Update the touch event first. |
2036 blink::WebTouchPoint* point = | 2021 if (!pointer_state_.OnTouch(*event)) { |
2037 UpdateWebTouchEventFromUIEvent(*event, &touch_event_); | |
2038 | |
2039 if (!point) { | |
2040 event->StopPropagation(); | 2022 event->StopPropagation(); |
2041 return; | 2023 return; |
2042 } | 2024 } |
2043 | 2025 |
| 2026 touch_event_ = CreateWebTouchEventFromMotionEvent(pointer_state_); |
| 2027 pointer_state_.CleanupRemovedTouchPoints(*event); |
| 2028 |
2044 // Forward the touch event only if a touch point was updated, and | 2029 // Forward the touch event only if a touch point was updated, and |
2045 // there's a touch-event handler in the page, and no other | 2030 // there's a touch-event handler in the page, and no other |
2046 // touch-event is in the queue. It is important to always mark | 2031 // touch-event is in the queue. It is important to always mark |
2047 // events as being handled asynchronously if there is a touch-event | 2032 // events as being handled asynchronously if there is a touch-event |
2048 // handler in the page, or some touch-event is already in the queue, | 2033 // handler in the page, or some touch-event is already in the queue, |
2049 // even if no point has been updated. This ensures that this event | 2034 // even if no point has been updated. This ensures that this event |
2050 // does not get processed by the gesture recognizer before events | 2035 // does not get processed by the gesture recognizer before events |
2051 // currently awaiting dispatch in the touch queue. | 2036 // currently awaiting dispatch in the touch queue. |
2052 if (host_->ShouldForwardTouchEvent()) { | 2037 if (host_->ShouldForwardTouchEvent()) { |
2053 event->DisableSynchronousHandling(); | 2038 event->DisableSynchronousHandling(); |
2054 host_->ForwardTouchEventWithLatencyInfo(touch_event_, *event->latency()); | 2039 host_->ForwardTouchEventWithLatencyInfo(touch_event_, *event->latency()); |
2055 } | 2040 } |
2056 UpdateWebTouchEventAfterDispatch(&touch_event_, point); | |
2057 } | 2041 } |
2058 | 2042 |
2059 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { | 2043 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { |
2060 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); | 2044 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); |
2061 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 2045 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
2062 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2046 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
2063 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { | 2047 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { |
2064 event->SetHandled(); | 2048 event->SetHandled(); |
2065 return; | 2049 return; |
2066 } | 2050 } |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2578 | 2562 |
2579 //////////////////////////////////////////////////////////////////////////////// | 2563 //////////////////////////////////////////////////////////////////////////////// |
2580 // RenderWidgetHostViewBase, public: | 2564 // RenderWidgetHostViewBase, public: |
2581 | 2565 |
2582 // static | 2566 // static |
2583 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2567 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2584 GetScreenInfoForWindow(results, NULL); | 2568 GetScreenInfoForWindow(results, NULL); |
2585 } | 2569 } |
2586 | 2570 |
2587 } // namespace content | 2571 } // namespace content |
OLD | NEW |