| 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 package org.chromium.content.browser; | 5 package org.chromium.content.browser; |
| 6 | 6 |
| 7 import android.content.Context; | 7 import android.content.Context; |
| 8 import android.util.Log; | 8 import android.util.Log; |
| 9 import android.view.Gravity; | 9 import android.view.Gravity; |
| 10 import android.view.MotionEvent; | 10 import android.view.MotionEvent; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 } | 48 } |
| 49 | 49 |
| 50 void setTemporarilyIgnoreDetectorEvents(boolean value) { | 50 void setTemporarilyIgnoreDetectorEvents(boolean value) { |
| 51 mTemporarilyIgnoreDetectorEvents = value; | 51 mTemporarilyIgnoreDetectorEvents = value; |
| 52 } | 52 } |
| 53 | 53 |
| 54 @Override | 54 @Override |
| 55 public boolean onScaleBegin(ScaleGestureDetector detector) { | 55 public boolean onScaleBegin(ScaleGestureDetector detector) { |
| 56 if (ignoreDetectorEvents()) return false; | 56 if (ignoreDetectorEvents()) return false; |
| 57 mPinchEventSent = false; | 57 mPinchEventSent = false; |
| 58 mContentViewCore.setIgnoreSingleTap(true); | 58 mContentViewCore.getContentViewGestureHandler().setIgnoreSingleTap(t
rue); |
| 59 return true; | 59 return true; |
| 60 } | 60 } |
| 61 | 61 |
| 62 @Override | 62 @Override |
| 63 public void onScaleEnd(ScaleGestureDetector detector) { | 63 public void onScaleEnd(ScaleGestureDetector detector) { |
| 64 if (!mPinchEventSent || !mContentViewCore.isAlive()) return; | 64 if (!mPinchEventSent || !mContentViewCore.isAlive()) return; |
| 65 mContentViewCore.pinchEnd(detector.getEventTime()); | 65 mContentViewCore.getContentViewGestureHandler().pinchEnd(detector.ge
tEventTime()); |
| 66 mPinchEventSent = false; | 66 mPinchEventSent = false; |
| 67 } | 67 } |
| 68 | 68 |
| 69 @Override | 69 @Override |
| 70 public boolean onScale(ScaleGestureDetector detector) { | 70 public boolean onScale(ScaleGestureDetector detector) { |
| 71 if (ignoreDetectorEvents()) return false; | 71 if (ignoreDetectorEvents()) return false; |
| 72 // It is possible that pinchBegin() was never called when we reach h
ere. | 72 // It is possible that pinchBegin() was never called when we reach h
ere. |
| 73 // This happens when webkit handles the 2nd touch down event. That c
auses | 73 // This happens when webkit handles the 2nd touch down event. That c
auses |
| 74 // ContentView to ignore the onScaleBegin() call. And if webkit does
not | 74 // ContentView to ignore the onScaleBegin() call. And if webkit does
not |
| 75 // handle the touch move events afterwards, we will face a situation | 75 // handle the touch move events afterwards, we will face a situation |
| 76 // that pinchBy() is called without any pinchBegin(). | 76 // that pinchBy() is called without any pinchBegin(). |
| 77 // To solve this problem, we call pinchBegin() here if it is never c
alled. | 77 // To solve this problem, we call pinchBegin() here if it is never c
alled. |
| 78 if (!mPinchEventSent) { | 78 if (!mPinchEventSent) { |
| 79 mContentViewCore.pinchBegin(detector.getEventTime(), | 79 mContentViewCore.getContentViewGestureHandler().pinchBegin(detec
tor.getEventTime(), |
| 80 (int) detector.getFocusX(), (int) detector.getFocusY()); | 80 (int) detector.getFocusX(), (int) detector.getFocusY()); |
| 81 mPinchEventSent = true; | 81 mPinchEventSent = true; |
| 82 } | 82 } |
| 83 mContentViewCore.pinchBy( | 83 mContentViewCore.getContentViewGestureHandler().pinchBy( |
| 84 detector.getEventTime(), (int) detector.getFocusX(), (int) d
etector.getFocusY(), | 84 detector.getEventTime(), (int) detector.getFocusX(), (int) d
etector.getFocusY(), |
| 85 detector.getScaleFactor()); | 85 detector.getScaleFactor()); |
| 86 return true; | 86 return true; |
| 87 } | 87 } |
| 88 | 88 |
| 89 private boolean ignoreDetectorEvents() { | 89 private boolean ignoreDetectorEvents() { |
| 90 return mPermanentlyIgnoreDetectorEvents || | 90 return mPermanentlyIgnoreDetectorEvents || |
| 91 mTemporarilyIgnoreDetectorEvents || | 91 mTemporarilyIgnoreDetectorEvents || |
| 92 !mContentViewCore.isAlive(); | 92 !mContentViewCore.isAlive(); |
| 93 } | 93 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 if (zoomIn) { | 203 if (zoomIn) { |
| 204 mContentViewCore.zoomIn(); | 204 mContentViewCore.zoomIn(); |
| 205 } else { | 205 } else { |
| 206 mContentViewCore.zoomOut(); | 206 mContentViewCore.zoomOut(); |
| 207 } | 207 } |
| 208 // ContentView will call updateZoomControls after its current page s
cale | 208 // ContentView will call updateZoomControls after its current page s
cale |
| 209 // is got updated from the native code. | 209 // is got updated from the native code. |
| 210 } | 210 } |
| 211 } | 211 } |
| 212 } | 212 } |
| OLD | NEW |