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" |
(...skipping 2015 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2026 | 2026 |
2027 event->SetHandled(); | 2027 event->SetHandled(); |
2028 } | 2028 } |
2029 | 2029 |
2030 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { | 2030 void RenderWidgetHostViewAura::OnTouchEvent(ui::TouchEvent* event) { |
2031 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); | 2031 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnTouchEvent"); |
2032 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) | 2032 if (touch_editing_client_ && touch_editing_client_->HandleInputEvent(event)) |
2033 return; | 2033 return; |
2034 | 2034 |
2035 // Update the touch event first. | 2035 // Update the touch event first. |
2036 blink::WebTouchPoint* point = UpdateWebTouchEventFromUIEvent(*event, | 2036 blink::WebTouchPoint* point = |
2037 &touch_event_); | 2037 UpdateWebTouchEventFromUIEvent(*event, &touch_event_); |
2038 | 2038 |
2039 // Forward the touch event only if a touch point was updated, and there's a | 2039 if (!point) { |
2040 // touch-event handler in the page, and no other touch-event is in the queue. | 2040 event->DisableSynchronousHandling(); |
2041 // It is important to always consume the event if there is a touch-event | 2041 // Mark the most recent touch event as handled, as it wasn't valid. |
2042 // handler in the page, or some touch-event is already in the queue, even if | 2042 ui::GestureRecognizer::Get()->AckSyncTouchEvent(*event, ui::ER_HANDLED, |
2043 // no point has been updated, to make sure that this event does not get | 2043 window_); |
2044 // processed by the gesture recognizer before the events in the queue. | 2044 return; |
2045 if (host_->ShouldForwardTouchEvent()) | 2045 } |
2046 event->StopPropagation(); | |
2047 | 2046 |
2048 if (point) { | 2047 // Forward the touch event only if a touch point was updated, and |
2049 if (host_->ShouldForwardTouchEvent()) | 2048 // there's a touch-event handler in the page, and no other |
2050 host_->ForwardTouchEventWithLatencyInfo(touch_event_, *event->latency()); | 2049 // touch-event is in the queue. It is important to always mark |
2051 UpdateWebTouchEventAfterDispatch(&touch_event_, point); | 2050 // events as being handled asynchronously if there is a touch-event |
| 2051 // handler in the page, or some touch-event is already in the queue, |
| 2052 // even if no point has been updated. This ensures that this event |
| 2053 // does not get processed by the gesture recognizer before events |
| 2054 // currently awaiting dispatch in the touch queue. |
| 2055 if (host_->ShouldForwardTouchEvent()) { |
| 2056 event->DisableSynchronousHandling(); |
| 2057 host_->ForwardTouchEventWithLatencyInfo(touch_event_, *event->latency()); |
2052 } | 2058 } |
| 2059 UpdateWebTouchEventAfterDispatch(&touch_event_, point); |
2053 } | 2060 } |
2054 | 2061 |
2055 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { | 2062 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { |
2056 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); | 2063 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); |
2057 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 2064 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
2058 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2065 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
2059 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { | 2066 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { |
2060 event->SetHandled(); | 2067 event->SetHandled(); |
2061 return; | 2068 return; |
2062 } | 2069 } |
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2574 | 2581 |
2575 //////////////////////////////////////////////////////////////////////////////// | 2582 //////////////////////////////////////////////////////////////////////////////// |
2576 // RenderWidgetHostViewBase, public: | 2583 // RenderWidgetHostViewBase, public: |
2577 | 2584 |
2578 // static | 2585 // static |
2579 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2586 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2580 GetScreenInfoForWindow(results, NULL); | 2587 GetScreenInfoForWindow(results, NULL); |
2581 } | 2588 } |
2582 | 2589 |
2583 } // namespace content | 2590 } // namespace content |
OLD | NEW |