Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.app.Activity; | 8 import android.app.Activity; |
| 9 import android.app.SearchManager; | 9 import android.app.SearchManager; |
| 10 import android.content.ContentResolver; | 10 import android.content.ContentResolver; |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 316 // Accessibility touch exploration state. | 316 // Accessibility touch exploration state. |
| 317 private boolean mTouchExplorationEnabled; | 317 private boolean mTouchExplorationEnabled; |
| 318 | 318 |
| 319 // Allows us to dynamically respond when the accessibility script injection flag changes. | 319 // Allows us to dynamically respond when the accessibility script injection flag changes. |
| 320 private ContentObserver mAccessibilityScriptInjectionObserver; | 320 private ContentObserver mAccessibilityScriptInjectionObserver; |
| 321 | 321 |
| 322 // Temporary notification to tell onSizeChanged to focus a form element, | 322 // Temporary notification to tell onSizeChanged to focus a form element, |
| 323 // because the OSK was just brought up. | 323 // because the OSK was just brought up. |
| 324 private final Rect mFocusPreOSKViewportRect = new Rect(); | 324 private final Rect mFocusPreOSKViewportRect = new Rect(); |
| 325 | 325 |
| 326 // Whether Keyboard state has been changed (hidden/shown) | |
| 327 private boolean mIsKeyboardStateChanged = false; | |
| 328 | |
| 326 // On tap this will store the x, y coordinates of the touch. | 329 // On tap this will store the x, y coordinates of the touch. |
| 327 private int mLastTapX; | 330 private int mLastTapX; |
| 328 private int mLastTapY; | 331 private int mLastTapY; |
| 329 | 332 |
| 330 // Whether a touch scroll sequence is active, used to hide text selection | 333 // Whether a touch scroll sequence is active, used to hide text selection |
| 331 // handles. Note that a scroll sequence will *always* bound a pinch | 334 // handles. Note that a scroll sequence will *always* bound a pinch |
| 332 // sequence, so this will also be true for the duration of a pinch gesture. | 335 // sequence, so this will also be true for the duration of a pinch gesture. |
| 333 private boolean mTouchScrollInProgress; | 336 private boolean mTouchScrollInProgress; |
| 334 | 337 |
| 335 // The outstanding fling start events that hasn't got fling end yet. It may be > 1 because | 338 // The outstanding fling start events that hasn't got fling end yet. It may be > 1 because |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 566 resultCode == InputMethodManager.RESULT_ SHOWN || | 569 resultCode == InputMethodManager.RESULT_ SHOWN || |
| 567 resultCode == InputMethodManager.RESULT_ UNCHANGED_SHOWN); | 570 resultCode == InputMethodManager.RESULT_ UNCHANGED_SHOWN); |
| 568 if (resultCode == InputMethodManager.RESULT_SHOW N) { | 571 if (resultCode == InputMethodManager.RESULT_SHOW N) { |
| 569 // If OSK is newly shown, delay the form foc us until | 572 // If OSK is newly shown, delay the form foc us until |
| 570 // the onSizeChanged (in order to adjust rel ative to the | 573 // the onSizeChanged (in order to adjust rel ative to the |
| 571 // new size). | 574 // new size). |
| 572 // TODO(jdduke): We should not assume that o nSizeChanged will | 575 // TODO(jdduke): We should not assume that o nSizeChanged will |
| 573 // always be called, crbug.com/294908. | 576 // always be called, crbug.com/294908. |
| 574 getContainerView().getWindowVisibleDisplayFr ame( | 577 getContainerView().getWindowVisibleDisplayFr ame( |
| 575 mFocusPreOSKViewportRect); | 578 mFocusPreOSKViewportRect); |
| 579 mIsKeyboardStateChanged = true; | |
| 576 } else if (hasFocus() && resultCode == | 580 } else if (hasFocus() && resultCode == |
| 577 InputMethodManager.RESULT_UNCHANGED_SHOW N) { | 581 InputMethodManager.RESULT_UNCHANGED_SHOW N) { |
| 578 // If the OSK was already there, focus the f orm immediately. | 582 // If the OSK was already there, focus the f orm immediately. |
| 579 scrollFocusedEditableNodeIntoView(); | 583 scrollFocusedEditableNodeIntoView(); |
| 580 } | 584 } |
| 581 } | 585 } |
| 582 }; | 586 }; |
| 583 } | 587 } |
| 584 } | 588 } |
| 585 ); | 589 ); |
| (...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1121 } | 1125 } |
| 1122 | 1126 |
| 1123 // End FrameLayout overrides. | 1127 // End FrameLayout overrides. |
| 1124 | 1128 |
| 1125 /** | 1129 /** |
| 1126 * @see View#onTouchEvent(MotionEvent) | 1130 * @see View#onTouchEvent(MotionEvent) |
| 1127 */ | 1131 */ |
| 1128 public boolean onTouchEvent(MotionEvent event) { | 1132 public boolean onTouchEvent(MotionEvent event) { |
| 1129 TraceEvent.begin("onTouchEvent"); | 1133 TraceEvent.begin("onTouchEvent"); |
| 1130 try { | 1134 try { |
| 1131 cancelRequestToScrollFocusedEditableNodeIntoView(); | 1135 cancelRequestToScrollFocusedEditableNodeIntoView(); |
|
jdduke (slow)
2014/07/15 15:36:58
I think we can achieve the same result by simply m
AviD
2014/07/15 15:58:02
Agree.
It was my initial thought, but wasn't sure
| |
| 1132 | 1136 |
| 1133 final int eventAction = event.getActionMasked(); | 1137 final int eventAction = event.getActionMasked(); |
| 1134 | 1138 |
| 1135 // Only these actions have any effect on gesture detection. Other | 1139 // Only these actions have any effect on gesture detection. Other |
| 1136 // actions have no corresponding WebTouchEvent type and may confuse the | 1140 // actions have no corresponding WebTouchEvent type and may confuse the |
| 1137 // touch pipline, so we ignore them entirely. | 1141 // touch pipline, so we ignore them entirely. |
| 1138 if (eventAction != MotionEvent.ACTION_DOWN | 1142 if (eventAction != MotionEvent.ACTION_DOWN |
| 1139 && eventAction != MotionEvent.ACTION_UP | 1143 && eventAction != MotionEvent.ACTION_UP |
| 1140 && eventAction != MotionEvent.ACTION_CANCEL | 1144 && eventAction != MotionEvent.ACTION_CANCEL |
| 1141 && eventAction != MotionEvent.ACTION_MOVE | 1145 && eventAction != MotionEvent.ACTION_MOVE |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1594 if (!mFocusPreOSKViewportRect.isEmpty()) { | 1598 if (!mFocusPreOSKViewportRect.isEmpty()) { |
| 1595 Rect rect = new Rect(); | 1599 Rect rect = new Rect(); |
| 1596 getContainerView().getWindowVisibleDisplayFrame(rect); | 1600 getContainerView().getWindowVisibleDisplayFrame(rect); |
| 1597 if (!rect.equals(mFocusPreOSKViewportRect)) { | 1601 if (!rect.equals(mFocusPreOSKViewportRect)) { |
| 1598 // Only assume the OSK triggered the onSizeChanged if width was preserved. | 1602 // Only assume the OSK triggered the onSizeChanged if width was preserved. |
| 1599 if (rect.width() == mFocusPreOSKViewportRect.width()) { | 1603 if (rect.width() == mFocusPreOSKViewportRect.width()) { |
| 1600 scrollFocusedEditableNodeIntoView(); | 1604 scrollFocusedEditableNodeIntoView(); |
| 1601 } | 1605 } |
| 1602 cancelRequestToScrollFocusedEditableNodeIntoView(); | 1606 cancelRequestToScrollFocusedEditableNodeIntoView(); |
| 1603 } | 1607 } |
| 1608 mIsKeyboardStateChanged = false; | |
| 1604 } | 1609 } |
| 1605 } | 1610 } |
| 1606 | 1611 |
| 1607 private void cancelRequestToScrollFocusedEditableNodeIntoView() { | 1612 private void cancelRequestToScrollFocusedEditableNodeIntoView() { |
| 1613 // Ignore if onTouchEvent triggerred this call after IME state is update d | |
| 1614 if (mIsKeyboardStateChanged == true) return; | |
| 1615 | |
| 1608 // Zero-ing the rect will prevent |updateAfterSizeChanged()| from | 1616 // Zero-ing the rect will prevent |updateAfterSizeChanged()| from |
| 1609 // issuing the delayed form focus event. | 1617 // issuing the delayed form focus event. |
| 1610 mFocusPreOSKViewportRect.setEmpty(); | 1618 mFocusPreOSKViewportRect.setEmpty(); |
| 1611 } | 1619 } |
| 1612 | 1620 |
| 1613 private void scrollFocusedEditableNodeIntoView() { | 1621 private void scrollFocusedEditableNodeIntoView() { |
| 1614 if (mNativeContentViewCore == 0) return; | 1622 if (mNativeContentViewCore == 0) return; |
| 1615 // The native side keeps track of whether the zoom and scroll actually o ccurred. It is | 1623 // The native side keeps track of whether the zoom and scroll actually o ccurred. It is |
| 1616 // more efficient to do it this way and sometimes fire an unnecessary me ssage rather | 1624 // more efficient to do it this way and sometimes fire an unnecessary me ssage rather |
| 1617 // than synchronize with the renderer and always have an additional mess age. | 1625 // than synchronize with the renderer and always have an additional mess age. |
| (...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3346 | 3354 |
| 3347 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, | 3355 private native void nativeExtractSmartClipData(long nativeContentViewCoreImp l, |
| 3348 int x, int y, int w, int h); | 3356 int x, int y, int w, int h); |
| 3349 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); | 3357 private native void nativeSetBackgroundOpaque(long nativeContentViewCoreImpl , boolean opaque); |
| 3350 | 3358 |
| 3351 private native void nativeResumeResponseDeferredAtStart( | 3359 private native void nativeResumeResponseDeferredAtStart( |
| 3352 long nativeContentViewCoreImpl); | 3360 long nativeContentViewCoreImpl); |
| 3353 private native void nativeSetHasPendingNavigationTransitionForTesting( | 3361 private native void nativeSetHasPendingNavigationTransitionForTesting( |
| 3354 long nativeContentViewCoreImpl); | 3362 long nativeContentViewCoreImpl); |
| 3355 } | 3363 } |
| OLD | NEW |