Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(553)

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 24449007: [Android] Allow text handles to observe position of "parent" view (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 import android.view.inputmethod.EditorInfo; 48 import android.view.inputmethod.EditorInfo;
49 import android.view.inputmethod.InputConnection; 49 import android.view.inputmethod.InputConnection;
50 import android.view.inputmethod.InputMethodManager; 50 import android.view.inputmethod.InputMethodManager;
51 import android.widget.AbsoluteLayout; 51 import android.widget.AbsoluteLayout;
52 import android.widget.FrameLayout; 52 import android.widget.FrameLayout;
53 53
54 import com.google.common.annotations.VisibleForTesting; 54 import com.google.common.annotations.VisibleForTesting;
55 55
56 import org.chromium.base.CalledByNative; 56 import org.chromium.base.CalledByNative;
57 import org.chromium.base.JNINamespace; 57 import org.chromium.base.JNINamespace;
58 import org.chromium.base.PositionObserver;
58 import org.chromium.base.WeakContext; 59 import org.chromium.base.WeakContext;
59 import org.chromium.content.R; 60 import org.chromium.content.R;
60 import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegat e; 61 import org.chromium.content.browser.ContentViewGestureHandler.MotionEventDelegat e;
61 import org.chromium.content.browser.accessibility.AccessibilityInjector; 62 import org.chromium.content.browser.accessibility.AccessibilityInjector;
62 import org.chromium.content.browser.accessibility.BrowserAccessibilityManager; 63 import org.chromium.content.browser.accessibility.BrowserAccessibilityManager;
63 import org.chromium.content.browser.input.AdapterInputConnection; 64 import org.chromium.content.browser.input.AdapterInputConnection;
64 import org.chromium.content.browser.input.HandleView; 65 import org.chromium.content.browser.input.HandleView;
65 import org.chromium.content.browser.input.ImeAdapter; 66 import org.chromium.content.browser.input.ImeAdapter;
66 import org.chromium.content.browser.input.ImeAdapter.AdapterInputConnectionFacto ry; 67 import org.chromium.content.browser.input.ImeAdapter.AdapterInputConnectionFacto ry;
67 import org.chromium.content.browser.input.InputMethodManagerWrapper; 68 import org.chromium.content.browser.input.InputMethodManagerWrapper;
(...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after
370 // Only valid when focused on a text / password field. 371 // Only valid when focused on a text / password field.
371 private ImeAdapter mImeAdapter; 372 private ImeAdapter mImeAdapter;
372 private ImeAdapter.AdapterInputConnectionFactory mAdapterInputConnectionFact ory; 373 private ImeAdapter.AdapterInputConnectionFactory mAdapterInputConnectionFact ory;
373 private AdapterInputConnection mInputConnection; 374 private AdapterInputConnection mInputConnection;
374 375
375 private SelectionHandleController mSelectionHandleController; 376 private SelectionHandleController mSelectionHandleController;
376 private InsertionHandleController mInsertionHandleController; 377 private InsertionHandleController mInsertionHandleController;
377 378
378 private Runnable mDeferredHandleFadeInRunnable; 379 private Runnable mDeferredHandleFadeInRunnable;
379 380
381 private PositionObserver mPositionObserver;
382
380 // Size of the viewport in physical pixels as set from onSizeChanged. 383 // Size of the viewport in physical pixels as set from onSizeChanged.
381 private int mViewportWidthPix; 384 private int mViewportWidthPix;
382 private int mViewportHeightPix; 385 private int mViewportHeightPix;
383 private int mPhysicalBackingWidthPix; 386 private int mPhysicalBackingWidthPix;
384 private int mPhysicalBackingHeightPix; 387 private int mPhysicalBackingHeightPix;
385 private int mOverdrawBottomHeightPix; 388 private int mOverdrawBottomHeightPix;
386 private int mViewportSizeOffsetWidthPix; 389 private int mViewportSizeOffsetWidthPix;
387 private int mViewportSizeOffsetHeightPix; 390 private int mViewportSizeOffsetHeightPix;
388 391
389 // Cached copy of all positions and scales as reported by the renderer. 392 // Cached copy of all positions and scales as reported by the renderer.
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after
710 // necessarily mean we're going to *get* hardware acceleration -- that's 713 // necessarily mean we're going to *get* hardware acceleration -- that's
711 // up to the Android framework. 714 // up to the Android framework.
712 // 715 //
713 // TODO(husky): Once the native code has been updated so that the 716 // TODO(husky): Once the native code has been updated so that the
714 // HW acceleration flag can be set dynamically (Grace is doing this), 717 // HW acceleration flag can be set dynamically (Grace is doing this),
715 // move this check into onAttachedToWindow(), where we can test for 718 // move this check into onAttachedToWindow(), where we can test for
716 // HW support directly. 719 // HW support directly.
717 mHardwareAccelerated = hasHardwareAcceleration(mContext); 720 mHardwareAccelerated = hasHardwareAcceleration(mContext);
718 721
719 mContainerView = containerView; 722 mContainerView = containerView;
723 mPositionObserver = new PositionObserver(mContainerView);
720 724
721 int windowNativePointer = windowAndroid != null ? windowAndroid.getNativ ePointer() : 0; 725 int windowNativePointer = windowAndroid != null ? windowAndroid.getNativ ePointer() : 0;
722 726
723 int viewAndroidNativePointer = 0; 727 int viewAndroidNativePointer = 0;
724 if (windowNativePointer != 0) { 728 if (windowNativePointer != 0) {
725 mViewAndroid = new ViewAndroid(windowAndroid, getViewAndroidDelegate ()); 729 mViewAndroid = new ViewAndroid(windowAndroid, getViewAndroidDelegate ());
726 viewAndroidNativePointer = mViewAndroid.getNativePointer(); 730 viewAndroidNativePointer = mViewAndroid.getNativePointer();
727 } 731 }
728 732
729 mNativeContentViewCore = nativeInit(mHardwareAccelerated, 733 mNativeContentViewCore = nativeInit(mHardwareAccelerated,
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 mDownloadDelegate = delegate; 2014 mDownloadDelegate = delegate;
2011 } 2015 }
2012 2016
2013 // Called by DownloadController. 2017 // Called by DownloadController.
2014 ContentViewDownloadDelegate getDownloadDelegate() { 2018 ContentViewDownloadDelegate getDownloadDelegate() {
2015 return mDownloadDelegate; 2019 return mDownloadDelegate;
2016 } 2020 }
2017 2021
2018 private SelectionHandleController getSelectionHandleController() { 2022 private SelectionHandleController getSelectionHandleController() {
2019 if (mSelectionHandleController == null) { 2023 if (mSelectionHandleController == null) {
2020 mSelectionHandleController = new SelectionHandleController(getContai nerView()) { 2024 mSelectionHandleController = new SelectionHandleController(
2025 getContainerView(), mPositionObserver) {
2021 @Override 2026 @Override
2022 public void selectBetweenCoordinates(int x1, int y1, int x2, int y2) { 2027 public void selectBetweenCoordinates(int x1, int y1, int x2, int y2) {
2023 if (mNativeContentViewCore != 0 && !(x1 == x2 && y1 == y2)) { 2028 if (mNativeContentViewCore != 0 && !(x1 == x2 && y1 == y2)) {
2024 nativeSelectBetweenCoordinates(mNativeContentViewCore, 2029 nativeSelectBetweenCoordinates(mNativeContentViewCore,
2025 x1, y1 - mRenderCoordinates.getContentOffsetYPix (), 2030 x1, y1 - mRenderCoordinates.getContentOffsetYPix (),
2026 x2, y2 - mRenderCoordinates.getContentOffsetYPix ()); 2031 x2, y2 - mRenderCoordinates.getContentOffsetYPix ());
2027 } 2032 }
2028 } 2033 }
2029 2034
2030 @Override 2035 @Override
2031 public void showHandles(int startDir, int endDir) { 2036 public void showHandles(int startDir, int endDir) {
2032 super.showHandles(startDir, endDir); 2037 super.showHandles(startDir, endDir);
2033 showSelectActionBar(); 2038 showSelectActionBar();
2034 } 2039 }
2035 2040
2036 }; 2041 };
2037 2042
2038 mSelectionHandleController.hideAndDisallowAutomaticShowing(); 2043 mSelectionHandleController.hideAndDisallowAutomaticShowing();
2039 } 2044 }
2040 2045
2041 return mSelectionHandleController; 2046 return mSelectionHandleController;
2042 } 2047 }
2043 2048
2044 private InsertionHandleController getInsertionHandleController() { 2049 private InsertionHandleController getInsertionHandleController() {
2045 if (mInsertionHandleController == null) { 2050 if (mInsertionHandleController == null) {
2046 mInsertionHandleController = new InsertionHandleController(getContai nerView()) { 2051 mInsertionHandleController = new InsertionHandleController(
2052 getContainerView(), mPositionObserver) {
2047 private static final int AVERAGE_LINE_HEIGHT = 14; 2053 private static final int AVERAGE_LINE_HEIGHT = 14;
2048 2054
2049 @Override 2055 @Override
2050 public void setCursorPosition(int x, int y) { 2056 public void setCursorPosition(int x, int y) {
2051 if (mNativeContentViewCore != 0) { 2057 if (mNativeContentViewCore != 0) {
2052 nativeMoveCaret(mNativeContentViewCore, 2058 nativeMoveCaret(mNativeContentViewCore,
2053 x, y - mRenderCoordinates.getContentOffsetYPix() ); 2059 x, y - mRenderCoordinates.getContentOffsetYPix() );
2054 } 2060 }
2055 } 2061 }
2056 2062
(...skipping 1238 matching lines...) Expand 10 before | Expand all | Expand 10 after
3295 3301
3296 private native void nativeAttachExternalVideoSurface( 3302 private native void nativeAttachExternalVideoSurface(
3297 int nativeContentViewCoreImpl, int playerId, Surface surface); 3303 int nativeContentViewCoreImpl, int playerId, Surface surface);
3298 3304
3299 private native void nativeDetachExternalVideoSurface( 3305 private native void nativeDetachExternalVideoSurface(
3300 int nativeContentViewCoreImpl, int playerId); 3306 int nativeContentViewCoreImpl, int playerId);
3301 3307
3302 private native void nativeSetAccessibilityEnabled( 3308 private native void nativeSetAccessibilityEnabled(
3303 int nativeContentViewCoreImpl, boolean enabled); 3309 int nativeContentViewCoreImpl, boolean enabled);
3304 } 3310 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698