| 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.app.Activity; | 7 import android.app.Activity; |
| 8 import android.app.SearchManager; | 8 import android.app.SearchManager; |
| 9 import android.content.ContentResolver; | 9 import android.content.ContentResolver; |
| 10 import android.content.Context; | 10 import android.content.Context; |
| (...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 // Only valid when focused on a text / password field. | 370 // Only valid when focused on a text / password field. |
| 371 private ImeAdapter mImeAdapter; | 371 private ImeAdapter mImeAdapter; |
| 372 private ImeAdapter.AdapterInputConnectionFactory mAdapterInputConnectionFact
ory; | 372 private ImeAdapter.AdapterInputConnectionFactory mAdapterInputConnectionFact
ory; |
| 373 private AdapterInputConnection mInputConnection; | 373 private AdapterInputConnection mInputConnection; |
| 374 | 374 |
| 375 private SelectionHandleController mSelectionHandleController; | 375 private SelectionHandleController mSelectionHandleController; |
| 376 private InsertionHandleController mInsertionHandleController; | 376 private InsertionHandleController mInsertionHandleController; |
| 377 | 377 |
| 378 private Runnable mDeferredHandleFadeInRunnable; | 378 private Runnable mDeferredHandleFadeInRunnable; |
| 379 | 379 |
| 380 private PositionObserver mPositionObserver; |
| 381 |
| 380 // Size of the viewport in physical pixels as set from onSizeChanged. | 382 // Size of the viewport in physical pixels as set from onSizeChanged. |
| 381 private int mViewportWidthPix; | 383 private int mViewportWidthPix; |
| 382 private int mViewportHeightPix; | 384 private int mViewportHeightPix; |
| 383 private int mPhysicalBackingWidthPix; | 385 private int mPhysicalBackingWidthPix; |
| 384 private int mPhysicalBackingHeightPix; | 386 private int mPhysicalBackingHeightPix; |
| 385 private int mOverdrawBottomHeightPix; | 387 private int mOverdrawBottomHeightPix; |
| 386 private int mViewportSizeOffsetWidthPix; | 388 private int mViewportSizeOffsetWidthPix; |
| 387 private int mViewportSizeOffsetHeightPix; | 389 private int mViewportSizeOffsetHeightPix; |
| 388 | 390 |
| 389 // Cached copy of all positions and scales as reported by the renderer. | 391 // Cached copy of all positions and scales as reported by the renderer. |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 // necessarily mean we're going to *get* hardware acceleration -- that's | 712 // necessarily mean we're going to *get* hardware acceleration -- that's |
| 711 // up to the Android framework. | 713 // up to the Android framework. |
| 712 // | 714 // |
| 713 // TODO(husky): Once the native code has been updated so that the | 715 // TODO(husky): Once the native code has been updated so that the |
| 714 // HW acceleration flag can be set dynamically (Grace is doing this), | 716 // HW acceleration flag can be set dynamically (Grace is doing this), |
| 715 // move this check into onAttachedToWindow(), where we can test for | 717 // move this check into onAttachedToWindow(), where we can test for |
| 716 // HW support directly. | 718 // HW support directly. |
| 717 mHardwareAccelerated = hasHardwareAcceleration(mContext); | 719 mHardwareAccelerated = hasHardwareAcceleration(mContext); |
| 718 | 720 |
| 719 mContainerView = containerView; | 721 mContainerView = containerView; |
| 722 mPositionObserver = new ViewPositionObserver(mContainerView); |
| 720 | 723 |
| 721 int windowNativePointer = windowAndroid != null ? windowAndroid.getNativ
ePointer() : 0; | 724 int windowNativePointer = windowAndroid != null ? windowAndroid.getNativ
ePointer() : 0; |
| 722 | 725 |
| 723 int viewAndroidNativePointer = 0; | 726 int viewAndroidNativePointer = 0; |
| 724 if (windowNativePointer != 0) { | 727 if (windowNativePointer != 0) { |
| 725 mViewAndroid = new ViewAndroid(windowAndroid, getViewAndroidDelegate
()); | 728 mViewAndroid = new ViewAndroid(windowAndroid, getViewAndroidDelegate
()); |
| 726 viewAndroidNativePointer = mViewAndroid.getNativePointer(); | 729 viewAndroidNativePointer = mViewAndroid.getNativePointer(); |
| 727 } | 730 } |
| 728 | 731 |
| 729 mNativeContentViewCore = nativeInit(mHardwareAccelerated, | 732 mNativeContentViewCore = nativeInit(mHardwareAccelerated, |
| (...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1992 mDownloadDelegate = delegate; | 1995 mDownloadDelegate = delegate; |
| 1993 } | 1996 } |
| 1994 | 1997 |
| 1995 // Called by DownloadController. | 1998 // Called by DownloadController. |
| 1996 ContentViewDownloadDelegate getDownloadDelegate() { | 1999 ContentViewDownloadDelegate getDownloadDelegate() { |
| 1997 return mDownloadDelegate; | 2000 return mDownloadDelegate; |
| 1998 } | 2001 } |
| 1999 | 2002 |
| 2000 private SelectionHandleController getSelectionHandleController() { | 2003 private SelectionHandleController getSelectionHandleController() { |
| 2001 if (mSelectionHandleController == null) { | 2004 if (mSelectionHandleController == null) { |
| 2002 mSelectionHandleController = new SelectionHandleController(getContai
nerView()) { | 2005 mSelectionHandleController = new SelectionHandleController( |
| 2006 getContainerView(), mPositionObserver) { |
| 2003 @Override | 2007 @Override |
| 2004 public void selectBetweenCoordinates(int x1, int y1, int x2, int
y2) { | 2008 public void selectBetweenCoordinates(int x1, int y1, int x2, int
y2) { |
| 2005 if (mNativeContentViewCore != 0 && !(x1 == x2 && y1 == y2))
{ | 2009 if (mNativeContentViewCore != 0 && !(x1 == x2 && y1 == y2))
{ |
| 2006 nativeSelectBetweenCoordinates(mNativeContentViewCore, | 2010 nativeSelectBetweenCoordinates(mNativeContentViewCore, |
| 2007 x1, y1 - mRenderCoordinates.getContentOffsetYPix
(), | 2011 x1, y1 - mRenderCoordinates.getContentOffsetYPix
(), |
| 2008 x2, y2 - mRenderCoordinates.getContentOffsetYPix
()); | 2012 x2, y2 - mRenderCoordinates.getContentOffsetYPix
()); |
| 2009 } | 2013 } |
| 2010 } | 2014 } |
| 2011 | 2015 |
| 2012 @Override | 2016 @Override |
| 2013 public void showHandles(int startDir, int endDir) { | 2017 public void showHandles(int startDir, int endDir) { |
| 2014 super.showHandles(startDir, endDir); | 2018 super.showHandles(startDir, endDir); |
| 2015 showSelectActionBar(); | 2019 showSelectActionBar(); |
| 2016 } | 2020 } |
| 2017 | 2021 |
| 2018 }; | 2022 }; |
| 2019 | 2023 |
| 2020 mSelectionHandleController.hideAndDisallowAutomaticShowing(); | 2024 mSelectionHandleController.hideAndDisallowAutomaticShowing(); |
| 2021 } | 2025 } |
| 2022 | 2026 |
| 2023 return mSelectionHandleController; | 2027 return mSelectionHandleController; |
| 2024 } | 2028 } |
| 2025 | 2029 |
| 2026 private InsertionHandleController getInsertionHandleController() { | 2030 private InsertionHandleController getInsertionHandleController() { |
| 2027 if (mInsertionHandleController == null) { | 2031 if (mInsertionHandleController == null) { |
| 2028 mInsertionHandleController = new InsertionHandleController(getContai
nerView()) { | 2032 mInsertionHandleController = new InsertionHandleController( |
| 2033 getContainerView(), mPositionObserver) { |
| 2029 private static final int AVERAGE_LINE_HEIGHT = 14; | 2034 private static final int AVERAGE_LINE_HEIGHT = 14; |
| 2030 | 2035 |
| 2031 @Override | 2036 @Override |
| 2032 public void setCursorPosition(int x, int y) { | 2037 public void setCursorPosition(int x, int y) { |
| 2033 if (mNativeContentViewCore != 0) { | 2038 if (mNativeContentViewCore != 0) { |
| 2034 nativeMoveCaret(mNativeContentViewCore, | 2039 nativeMoveCaret(mNativeContentViewCore, |
| 2035 x, y - mRenderCoordinates.getContentOffsetYPix()
); | 2040 x, y - mRenderCoordinates.getContentOffsetYPix()
); |
| 2036 } | 2041 } |
| 2037 } | 2042 } |
| 2038 | 2043 |
| (...skipping 1220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3259 | 3264 |
| 3260 private native void nativeAttachExternalVideoSurface( | 3265 private native void nativeAttachExternalVideoSurface( |
| 3261 int nativeContentViewCoreImpl, int playerId, Surface surface); | 3266 int nativeContentViewCoreImpl, int playerId, Surface surface); |
| 3262 | 3267 |
| 3263 private native void nativeDetachExternalVideoSurface( | 3268 private native void nativeDetachExternalVideoSurface( |
| 3264 int nativeContentViewCoreImpl, int playerId); | 3269 int nativeContentViewCoreImpl, int playerId); |
| 3265 | 3270 |
| 3266 private native void nativeSetAccessibilityEnabled( | 3271 private native void nativeSetAccessibilityEnabled( |
| 3267 int nativeContentViewCoreImpl, boolean enabled); | 3272 int nativeContentViewCoreImpl, boolean enabled); |
| 3268 } | 3273 } |
| OLD | NEW |