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