Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/input/touch_action_filter.h" | 5 #include "content/browser/renderer_host/input/touch_action_filter.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "third_party/WebKit/public/web/WebInputEvent.h" | 10 #include "third_party/WebKit/public/web/WebInputEvent.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 54 if (allowed_touch_action_ == TOUCH_ACTION_PAN_Y) | 54 if (allowed_touch_action_ == TOUCH_ACTION_PAN_Y) |
| 55 gesture_event->data.flingStart.velocityX = 0; | 55 gesture_event->data.flingStart.velocityX = 0; |
| 56 } | 56 } |
| 57 return FilterScrollEndingGesture(); | 57 return FilterScrollEndingGesture(); |
| 58 | 58 |
| 59 case WebInputEvent::GestureScrollEnd: | 59 case WebInputEvent::GestureScrollEnd: |
| 60 return FilterScrollEndingGesture(); | 60 return FilterScrollEndingGesture(); |
| 61 | 61 |
| 62 case WebInputEvent::GesturePinchBegin: | 62 case WebInputEvent::GesturePinchBegin: |
| 63 DCHECK(!drop_pinch_gesture_events_); | 63 DCHECK(!drop_pinch_gesture_events_); |
| 64 if (allowed_touch_action_ == TOUCH_ACTION_AUTO) { | 64 if (allowed_touch_action_ == TOUCH_ACTION_AUTO || |
| 65 allowed_touch_action_ | TOUCH_ACTION_PINCH_ZOOM) { | |
| 65 // Pinch events are always bracketed by scroll events, and the W3C | 66 // Pinch events are always bracketed by scroll events, and the W3C |
| 66 // standard touch-action provides no way to disable scrolling without | 67 // standard touch-action provides no way to disable scrolling without |
| 67 // also disabling pinching. | 68 // also disabling pinching. |
| 68 DCHECK(!drop_scroll_gesture_events_); | 69 DCHECK(!drop_scroll_gesture_events_); |
| 69 } else { | 70 } else { |
| 70 drop_pinch_gesture_events_ = true; | 71 drop_pinch_gesture_events_ = true; |
| 71 } | 72 } |
| 72 return drop_pinch_gesture_events_; | 73 return drop_pinch_gesture_events_; |
| 73 | 74 |
| 74 case WebInputEvent::GesturePinchUpdate: | 75 case WebInputEvent::GesturePinchUpdate: |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 165 // If there's no hint or it's perfectly diagonal, then allow the scroll. | 166 // If there's no hint or it's perfectly diagonal, then allow the scroll. |
| 166 if (fabs(gesture_event.data.scrollBegin.deltaXHint) == | 167 if (fabs(gesture_event.data.scrollBegin.deltaXHint) == |
| 167 fabs(gesture_event.data.scrollBegin.deltaYHint)) | 168 fabs(gesture_event.data.scrollBegin.deltaYHint)) |
| 168 return false; | 169 return false; |
| 169 | 170 |
| 170 // Determine the primary initial axis of the scroll, and check whether | 171 // Determine the primary initial axis of the scroll, and check whether |
| 171 // panning along that axis is permitted. | 172 // panning along that axis is permitted. |
| 172 if (fabs(gesture_event.data.scrollBegin.deltaXHint) > | 173 if (fabs(gesture_event.data.scrollBegin.deltaXHint) > |
| 173 fabs(gesture_event.data.scrollBegin.deltaYHint)) | 174 fabs(gesture_event.data.scrollBegin.deltaYHint)) |
| 174 return !(allowed_touch_action_ & TOUCH_ACTION_PAN_X); | 175 return !(allowed_touch_action_ & TOUCH_ACTION_PAN_X); |
| 175 return !(allowed_touch_action_ & TOUCH_ACTION_PAN_Y); | 176 return !(allowed_touch_action_ & TOUCH_ACTION_PAN_Y); |
|
jdduke (slow)
2014/03/12 17:08:24
Hmm, I think you need to allow the GestureScroll{B
| |
| 176 } | 177 } |
| 177 | 178 |
| 178 TouchAction TouchActionFilter::Intersect(TouchAction ta1, TouchAction ta2) { | 179 TouchAction TouchActionFilter::Intersect(TouchAction ta1, TouchAction ta2) { |
| 179 if (ta1 == TOUCH_ACTION_NONE || ta2 == TOUCH_ACTION_NONE) | 180 if (ta1 == TOUCH_ACTION_NONE || ta2 == TOUCH_ACTION_NONE) |
| 180 return TOUCH_ACTION_NONE; | 181 return TOUCH_ACTION_NONE; |
| 181 if (ta1 == TOUCH_ACTION_AUTO) | 182 if (ta1 == TOUCH_ACTION_AUTO) |
| 182 return ta2; | 183 return ta2; |
| 183 if (ta2 == TOUCH_ACTION_AUTO) | 184 if (ta2 == TOUCH_ACTION_AUTO) |
| 184 return ta1; | 185 return ta1; |
| 185 | 186 |
| 186 // Only the true flags are left - take their intersection. | 187 // Only the true flags are left - take their intersection. |
| 187 if (!(ta1 & ta2)) | 188 if (!(ta1 & ta2)) |
| 188 return TOUCH_ACTION_NONE; | 189 return TOUCH_ACTION_NONE; |
| 189 return static_cast<TouchAction>(ta1 & ta2); | 190 return static_cast<TouchAction>(ta1 & ta2); |
| 190 } | 191 } |
| 191 | 192 |
| 192 } | 193 } |
| OLD | NEW |