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 <set> | 7 #include <set> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
270 results->orientationAngle = 90; | 270 results->orientationAngle = 90; |
271 | 271 |
272 results->orientationType = | 272 results->orientationType = |
273 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display); | 273 RenderWidgetHostViewBase::GetOrientationTypeForDesktop(display); |
274 } | 274 } |
275 | 275 |
276 bool IsFractionalScaleFactor(float scale_factor) { | 276 bool IsFractionalScaleFactor(float scale_factor) { |
277 return (scale_factor - static_cast<int>(scale_factor)) > 0; | 277 return (scale_factor - static_cast<int>(scale_factor)) > 0; |
278 } | 278 } |
279 | 279 |
280 // Reset unchange touch point to StateStationary for touchmove and | |
jdduke (slow)
2015/05/08 21:02:43
Nit: unchanged.
| |
281 // touchcancel. | |
282 void MarkUnchangedTouchPointsAsStationary( | |
283 blink::WebTouchEvent* event, | |
284 int changed_touch_id) { | |
285 if (event->type == blink::WebInputEvent::TouchMove || | |
286 event->type == blink::WebInputEvent::TouchCancel) { | |
287 for (size_t i = 0; i < event->touchesLength; ++i) { | |
288 if (event->touches[i].id != changed_touch_id) | |
289 event->touches[i].state = blink::WebTouchPoint::StateStationary; | |
290 } | |
291 } | |
292 } | |
293 | |
280 } // namespace | 294 } // namespace |
281 | 295 |
282 // We need to watch for mouse events outside a Web Popup or its parent | 296 // We need to watch for mouse events outside a Web Popup or its parent |
283 // and dismiss the popup for certain events. | 297 // and dismiss the popup for certain events. |
284 class RenderWidgetHostViewAura::EventFilterForPopupExit | 298 class RenderWidgetHostViewAura::EventFilterForPopupExit |
285 : public ui::EventHandler { | 299 : public ui::EventHandler { |
286 public: | 300 public: |
287 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) | 301 explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) |
288 : rwhva_(rwhva) { | 302 : rwhva_(rwhva) { |
289 DCHECK(rwhva_); | 303 DCHECK(rwhva_); |
(...skipping 985 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1275 break; | 1289 break; |
1276 case blink::WebInputEvent::TouchCancel: | 1290 case blink::WebInputEvent::TouchCancel: |
1277 required_state = blink::WebTouchPoint::StateCancelled; | 1291 required_state = blink::WebTouchPoint::StateCancelled; |
1278 break; | 1292 break; |
1279 default: | 1293 default: |
1280 required_state = blink::WebTouchPoint::StateUndefined; | 1294 required_state = blink::WebTouchPoint::StateUndefined; |
1281 NOTREACHED(); | 1295 NOTREACHED(); |
1282 break; | 1296 break; |
1283 } | 1297 } |
1284 | 1298 |
1285 // Only send acks for changed touches. | 1299 // Only send acks for one changed touch point. |
1300 bool sent_ack = false; | |
1286 for (size_t i = 0; i < touch.event.touchesLength; ++i) { | 1301 for (size_t i = 0; i < touch.event.touchesLength; ++i) { |
1287 if (touch.event.touches[i].state == required_state) | 1302 if (touch.event.touches[i].state == required_state) { |
1303 DCHECK(!sent_ack); | |
1288 host->dispatcher()->ProcessedTouchEvent(window_, result); | 1304 host->dispatcher()->ProcessedTouchEvent(window_, result); |
1305 sent_ack = true; | |
1306 } | |
1289 } | 1307 } |
1290 } | 1308 } |
1291 | 1309 |
1292 scoped_ptr<SyntheticGestureTarget> | 1310 scoped_ptr<SyntheticGestureTarget> |
1293 RenderWidgetHostViewAura::CreateSyntheticGestureTarget() { | 1311 RenderWidgetHostViewAura::CreateSyntheticGestureTarget() { |
1294 return scoped_ptr<SyntheticGestureTarget>( | 1312 return scoped_ptr<SyntheticGestureTarget>( |
1295 new SyntheticGestureTargetAura(host_)); | 1313 new SyntheticGestureTargetAura(host_)); |
1296 } | 1314 } |
1297 | 1315 |
1298 InputEventAckState RenderWidgetHostViewAura::FilterInputEvent( | 1316 InputEventAckState RenderWidgetHostViewAura::FilterInputEvent( |
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2177 | 2195 |
2178 blink::WebTouchEvent touch_event = ui::CreateWebTouchEventFromMotionEvent( | 2196 blink::WebTouchEvent touch_event = ui::CreateWebTouchEventFromMotionEvent( |
2179 pointer_state_, event->may_cause_scrolling()); | 2197 pointer_state_, event->may_cause_scrolling()); |
2180 pointer_state_.CleanupRemovedTouchPoints(*event); | 2198 pointer_state_.CleanupRemovedTouchPoints(*event); |
2181 | 2199 |
2182 // It is important to always mark events as being handled asynchronously when | 2200 // It is important to always mark events as being handled asynchronously when |
2183 // they are forwarded. This ensures that the current event does not get | 2201 // they are forwarded. This ensures that the current event does not get |
2184 // processed by the gesture recognizer before events currently awaiting | 2202 // processed by the gesture recognizer before events currently awaiting |
2185 // dispatch in the touch queue. | 2203 // dispatch in the touch queue. |
2186 event->DisableSynchronousHandling(); | 2204 event->DisableSynchronousHandling(); |
2205 | |
2206 // Set unchange touch point to StateStationary for touchmove and | |
2207 // touchcancel to make sure only send one ack per WebTouchEvent. | |
2208 MarkUnchangedTouchPointsAsStationary(&touch_event, event->touch_id()); | |
2187 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); | 2209 host_->ForwardTouchEventWithLatencyInfo(touch_event, *event->latency()); |
2188 } | 2210 } |
2189 | 2211 |
2190 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { | 2212 void RenderWidgetHostViewAura::OnGestureEvent(ui::GestureEvent* event) { |
2191 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); | 2213 TRACE_EVENT0("input", "RenderWidgetHostViewAura::OnGestureEvent"); |
2192 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 2214 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
2193 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 2215 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
2194 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { | 2216 event->type() == ui::ET_GESTURE_PINCH_END) && !pinch_zoom_enabled_) { |
2195 event->SetHandled(); | 2217 event->SetHandled(); |
2196 return; | 2218 return; |
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2764 | 2786 |
2765 //////////////////////////////////////////////////////////////////////////////// | 2787 //////////////////////////////////////////////////////////////////////////////// |
2766 // RenderWidgetHostViewBase, public: | 2788 // RenderWidgetHostViewBase, public: |
2767 | 2789 |
2768 // static | 2790 // static |
2769 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2791 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
2770 GetScreenInfoForWindow(results, NULL); | 2792 GetScreenInfoForWindow(results, NULL); |
2771 } | 2793 } |
2772 | 2794 |
2773 } // namespace content | 2795 } // namespace content |
OLD | NEW |