summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorMichael Kolb <kolby@google.com>2011-11-29 15:29:03 -0800
committerMichael Kolb <kolby@google.com>2011-11-30 16:15:18 -0800
commit5da91bd6740ef910350edb2ed1df127da445a785 (patch)
tree7a6fdeb7f50b5a084e4e6735589cc7096fa0451d /core
parent88f10c6ce5a97b1990934148deb8ed6aa6ef7a48 (diff)
downloadframeworks_base-5da91bd6740ef910350edb2ed1df127da445a785.zip
frameworks_base-5da91bd6740ef910350edb2ed1df127da445a785.tar.gz
frameworks_base-5da91bd6740ef910350edb2ed1df127da445a785.tar.bz2
fix position of WebTextView on scrolling layers
Bug: 5677828 depends on CL: 152845 Change-Id: Ia6fce3ef64954d99fe044e801d7f083055c8b880
Diffstat (limited to 'core')
-rw-r--r--core/java/android/webkit/WebView.java33
1 files changed, 22 insertions, 11 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index 7155159..24eebd7 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -507,7 +507,7 @@ public class WebView extends AbsoluteLayout
private float mLastVelY;
// The id of the native layer being scrolled.
- private int mScrollingLayer;
+ private int mCurrentScrollingLayerId;
private Rect mScrollingLayerRect = new Rect();
// only trigger accelerated fling if the new velocity is at least
@@ -3665,7 +3665,7 @@ public class WebView extends AbsoluteLayout
if (x == mScrollingLayerRect.left && y == mScrollingLayerRect.top) {
return;
}
- nativeScrollLayer(mScrollingLayer, x, y);
+ nativeScrollLayer(mCurrentScrollingLayerId, x, y);
mScrollingLayerRect.left = x;
mScrollingLayerRect.top = y;
onScrollChanged(mScrollX, mScrollY, mScrollX, mScrollY);
@@ -4470,6 +4470,7 @@ public class WebView extends AbsoluteLayout
Rect vBox = contentToViewRect(contentBounds);
Rect visibleRect = new Rect();
calcOurVisibleRect(visibleRect);
+ offsetByLayerScrollPosition(vBox);
// If the textfield is on screen, place the WebTextView in
// its new place, accounting for our new scroll/zoom values,
// and adjust its textsize.
@@ -4505,6 +4506,14 @@ public class WebView extends AbsoluteLayout
}
}
+ private void offsetByLayerScrollPosition(Rect box) {
+ if ((mCurrentScrollingLayerId != 0)
+ && (mCurrentScrollingLayerId == nativeFocusCandidateLayerId())) {
+ box.offsetTo(box.left - mScrollingLayerRect.left,
+ box.top - mScrollingLayerRect.top);
+ }
+ }
+
void setBaseLayer(int layer, Region invalRegion, boolean showVisualIndicator,
boolean isPictureAfterFirstLayout, boolean registerPageSwapCallback) {
if (mNativeClass == 0)
@@ -4923,6 +4932,7 @@ public class WebView extends AbsoluteLayout
// should be in content coordinates.
Rect bounds = nativeFocusCandidateNodeBounds();
Rect vBox = contentToViewRect(bounds);
+ offsetByLayerScrollPosition(vBox);
mWebTextView.setRect(vBox.left, vBox.top, vBox.width(), vBox.height());
if (!Rect.intersects(bounds, visibleRect)) {
revealSelection();
@@ -5514,10 +5524,10 @@ public class WebView extends AbsoluteLayout
mMaxAutoScrollX = getViewWidth();
mMinAutoScrollY = 0;
mMaxAutoScrollY = getViewHeightWithTitle();
- mScrollingLayer = nativeScrollableLayer(viewToContentX(mSelectX),
+ mCurrentScrollingLayerId = nativeScrollableLayer(viewToContentX(mSelectX),
viewToContentY(mSelectY), mScrollingLayerRect,
mScrollingLayerBounds);
- if (mScrollingLayer != 0) {
+ if (mCurrentScrollingLayerId != 0) {
if (mScrollingLayerRect.left != mScrollingLayerRect.right) {
mMinAutoScrollX = Math.max(mMinAutoScrollX,
contentToViewX(mScrollingLayerBounds.left));
@@ -6003,9 +6013,9 @@ public class WebView extends AbsoluteLayout
private void startScrollingLayer(float x, float y) {
int contentX = viewToContentX((int) x + mScrollX);
int contentY = viewToContentY((int) y + mScrollY);
- mScrollingLayer = nativeScrollableLayer(contentX, contentY,
+ mCurrentScrollingLayerId = nativeScrollableLayer(contentX, contentY,
mScrollingLayerRect, mScrollingLayerBounds);
- if (mScrollingLayer != 0) {
+ if (mCurrentScrollingLayerId != 0) {
mTouchMode = TOUCH_DRAG_LAYER_MODE;
}
}
@@ -6236,7 +6246,7 @@ public class WebView extends AbsoluteLayout
ted.mPointsInView[0] = new Point(x, y);
ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
- ted.mNativeLayer = mScrollingLayer;
+ ted.mNativeLayer = mCurrentScrollingLayerId;
ted.mNativeLayerRect.set(mScrollingLayerRect);
ted.mSequence = mTouchEventQueue.nextTouchSequence();
mTouchEventQueue.preQueueTouchEventData(ted);
@@ -6427,7 +6437,7 @@ public class WebView extends AbsoluteLayout
ted.mPointsInView[0] = new Point(x, y);
ted.mMetaState = ev.getMetaState();
ted.mReprocess = mDeferTouchProcess;
- ted.mNativeLayer = mScrollingLayer;
+ ted.mNativeLayer = mCurrentScrollingLayerId;
ted.mNativeLayerRect.set(mScrollingLayerRect);
ted.mSequence = mTouchEventQueue.nextTouchSequence();
mTouchEventQueue.preQueueTouchEventData(ted);
@@ -6736,7 +6746,7 @@ public class WebView extends AbsoluteLayout
// directions. mTouchMode might be TOUCH_DRAG_MODE if we have
// reached the edge of a layer but mScrollingLayer will be non-zero
// if we initiated the drag on a layer.
- if (mScrollingLayer != 0) {
+ if (mCurrentScrollingLayerId != 0) {
final int contentX = viewToContentDimension(deltaX);
final int contentY = viewToContentDimension(deltaY);
@@ -7258,7 +7268,7 @@ public class WebView extends AbsoluteLayout
+ " vx=" + vx + " vy=" + vy
+ " maxX=" + maxX + " maxY=" + maxY
+ " scrollX=" + scrollX + " scrollY=" + scrollY
- + " layer=" + mScrollingLayer);
+ + " layer=" + mCurrentScrollingLayerId);
}
// Allow sloppy flings without overscrolling at the edges.
@@ -8367,7 +8377,7 @@ public class WebView extends AbsoluteLayout
mSentAutoScrollMessage = false;
break;
}
- if (mScrollingLayer == 0) {
+ if (mCurrentScrollingLayerId == 0) {
pinScrollBy(mAutoScrollX, mAutoScrollY, true, 0);
} else {
scrollLayerTo(mScrollingLayerRect.left + mAutoScrollX,
@@ -9581,6 +9591,7 @@ public class WebView extends AbsoluteLayout
* See WebTextView.setType()
*/
private native int nativeFocusCandidateType();
+ private native int nativeFocusCandidateLayerId();
private native boolean nativeFocusIsPlugin();
private native Rect nativeFocusNodeBounds();
/* package */ native int nativeFocusNodePointer();