@@ -507,7 +507,7 @@ public void onTrimMemory(int level) {
507507 private float mLastVelY ;
508508
509509 // The id of the native layer being scrolled.
510- private int mScrollingLayer ;
510+ private int mCurrentScrollingLayerId ;
511511 private Rect mScrollingLayerRect = new Rect ();
512512
513513 // only trigger accelerated fling if the new velocity is at least
@@ -3665,7 +3665,7 @@ private void scrollLayerTo(int x, int y) {
36653665 if (x == mScrollingLayerRect .left && y == mScrollingLayerRect .top ) {
36663666 return ;
36673667 }
3668- nativeScrollLayer (mScrollingLayer , x , y );
3668+ nativeScrollLayer (mCurrentScrollingLayerId , x , y );
36693669 mScrollingLayerRect .left = x ;
36703670 mScrollingLayerRect .top = y ;
36713671 onScrollChanged (mScrollX , mScrollY , mScrollX , mScrollY );
@@ -4470,6 +4470,7 @@ private boolean didUpdateWebTextViewDimensions(int intersection) {
44704470 Rect vBox = contentToViewRect (contentBounds );
44714471 Rect visibleRect = new Rect ();
44724472 calcOurVisibleRect (visibleRect );
4473+ offsetByLayerScrollPosition (vBox );
44734474 // If the textfield is on screen, place the WebTextView in
44744475 // its new place, accounting for our new scroll/zoom values,
44754476 // and adjust its textsize.
@@ -4505,6 +4506,14 @@ private boolean didUpdateWebTextViewDimensions(int intersection) {
45054506 }
45064507 }
45074508
4509+ private void offsetByLayerScrollPosition (Rect box ) {
4510+ if ((mCurrentScrollingLayerId != 0 )
4511+ && (mCurrentScrollingLayerId == nativeFocusCandidateLayerId ())) {
4512+ box .offsetTo (box .left - mScrollingLayerRect .left ,
4513+ box .top - mScrollingLayerRect .top );
4514+ }
4515+ }
4516+
45084517 void setBaseLayer (int layer , Region invalRegion , boolean showVisualIndicator ,
45094518 boolean isPictureAfterFirstLayout , boolean registerPageSwapCallback ) {
45104519 if (mNativeClass == 0 )
@@ -4923,6 +4932,7 @@ private void updateWebTextViewPosition() {
49234932 // should be in content coordinates.
49244933 Rect bounds = nativeFocusCandidateNodeBounds ();
49254934 Rect vBox = contentToViewRect (bounds );
4935+ offsetByLayerScrollPosition (vBox );
49264936 mWebTextView .setRect (vBox .left , vBox .top , vBox .width (), vBox .height ());
49274937 if (!Rect .intersects (bounds , visibleRect )) {
49284938 revealSelection ();
@@ -5514,10 +5524,10 @@ private boolean setUpSelect(boolean selectWord, int x, int y) {
55145524 mMaxAutoScrollX = getViewWidth ();
55155525 mMinAutoScrollY = 0 ;
55165526 mMaxAutoScrollY = getViewHeightWithTitle ();
5517- mScrollingLayer = nativeScrollableLayer (viewToContentX (mSelectX ),
5527+ mCurrentScrollingLayerId = nativeScrollableLayer (viewToContentX (mSelectX ),
55185528 viewToContentY (mSelectY ), mScrollingLayerRect ,
55195529 mScrollingLayerBounds );
5520- if (mScrollingLayer != 0 ) {
5530+ if (mCurrentScrollingLayerId != 0 ) {
55215531 if (mScrollingLayerRect .left != mScrollingLayerRect .right ) {
55225532 mMinAutoScrollX = Math .max (mMinAutoScrollX ,
55235533 contentToViewX (mScrollingLayerBounds .left ));
@@ -6003,9 +6013,9 @@ void onPinchToZoomAnimationEnd(ScaleGestureDetector detector) {
60036013 private void startScrollingLayer (float x , float y ) {
60046014 int contentX = viewToContentX ((int ) x + mScrollX );
60056015 int contentY = viewToContentY ((int ) y + mScrollY );
6006- mScrollingLayer = nativeScrollableLayer (contentX , contentY ,
6016+ mCurrentScrollingLayerId = nativeScrollableLayer (contentX , contentY ,
60076017 mScrollingLayerRect , mScrollingLayerBounds );
6008- if (mScrollingLayer != 0 ) {
6018+ if (mCurrentScrollingLayerId != 0 ) {
60096019 mTouchMode = TOUCH_DRAG_LAYER_MODE ;
60106020 }
60116021 }
@@ -6236,7 +6246,7 @@ public void run() {
62366246 ted .mPointsInView [0 ] = new Point (x , y );
62376247 ted .mMetaState = ev .getMetaState ();
62386248 ted .mReprocess = mDeferTouchProcess ;
6239- ted .mNativeLayer = mScrollingLayer ;
6249+ ted .mNativeLayer = mCurrentScrollingLayerId ;
62406250 ted .mNativeLayerRect .set (mScrollingLayerRect );
62416251 ted .mSequence = mTouchEventQueue .nextTouchSequence ();
62426252 mTouchEventQueue .preQueueTouchEventData (ted );
@@ -6427,7 +6437,7 @@ public void run() {
64276437 ted .mPointsInView [0 ] = new Point (x , y );
64286438 ted .mMetaState = ev .getMetaState ();
64296439 ted .mReprocess = mDeferTouchProcess ;
6430- ted .mNativeLayer = mScrollingLayer ;
6440+ ted .mNativeLayer = mCurrentScrollingLayerId ;
64316441 ted .mNativeLayerRect .set (mScrollingLayerRect );
64326442 ted .mSequence = mTouchEventQueue .nextTouchSequence ();
64336443 mTouchEventQueue .preQueueTouchEventData (ted );
@@ -6736,7 +6746,7 @@ private void doDrag(int deltaX, int deltaY) {
67366746 // directions. mTouchMode might be TOUCH_DRAG_MODE if we have
67376747 // reached the edge of a layer but mScrollingLayer will be non-zero
67386748 // if we initiated the drag on a layer.
6739- if (mScrollingLayer != 0 ) {
6749+ if (mCurrentScrollingLayerId != 0 ) {
67406750 final int contentX = viewToContentDimension (deltaX );
67416751 final int contentY = viewToContentDimension (deltaY );
67426752
@@ -7258,7 +7268,7 @@ private void doFling() {
72587268 + " vx=" + vx + " vy=" + vy
72597269 + " maxX=" + maxX + " maxY=" + maxY
72607270 + " scrollX=" + scrollX + " scrollY=" + scrollY
7261- + " layer=" + mScrollingLayer );
7271+ + " layer=" + mCurrentScrollingLayerId );
72627272 }
72637273
72647274 // Allow sloppy flings without overscrolling at the edges.
@@ -8367,7 +8377,7 @@ public void handleMessage(Message msg) {
83678377 mSentAutoScrollMessage = false ;
83688378 break ;
83698379 }
8370- if (mScrollingLayer == 0 ) {
8380+ if (mCurrentScrollingLayerId == 0 ) {
83718381 pinScrollBy (mAutoScrollX , mAutoScrollY , true , 0 );
83728382 } else {
83738383 scrollLayerTo (mScrollingLayerRect .left + mAutoScrollX ,
@@ -9581,6 +9591,7 @@ private native int nativeFindAll(String findLower, String findUpper,
95819591 * See WebTextView.setType()
95829592 */
95839593 private native int nativeFocusCandidateType ();
9594+ private native int nativeFocusCandidateLayerId ();
95849595 private native boolean nativeFocusIsPlugin ();
95859596 private native Rect nativeFocusNodeBounds ();
95869597 /* package */ native int nativeFocusNodePointer ();
0 commit comments