am 5da9aeb4: reset webTextView size if focus bounds changes

Merge commit '5da9aeb4351ed02b05f15c11e34673ab38103dd8' into eclair-mr2-plus-aosp

* commit '5da9aeb4351ed02b05f15c11e34673ab38103dd8':
  reset webTextView size if focus bounds changes
This commit is contained in:
Cary Clark
2009-10-07 08:27:42 -07:00
committed by Android Git Automerger
2 changed files with 31 additions and 10 deletions

View File

@@ -2836,6 +2836,21 @@ public class WebView extends AbsoluteLayout
*/ */
private boolean mNeedToAdjustWebTextView; private boolean mNeedToAdjustWebTextView;
private boolean didUpdateTextViewBounds(boolean allowIntersect) {
Rect contentBounds = nativeFocusCandidateNodeBounds();
Rect vBox = contentToViewRect(contentBounds);
Rect visibleRect = new Rect();
calcOurVisibleRect(visibleRect);
if (allowIntersect ? Rect.intersects(visibleRect, vBox) :
visibleRect.contains(vBox)) {
mWebTextView.setRect(vBox.left, vBox.top, vBox.width(),
vBox.height());
return true;
} else {
return false;
}
}
private void drawCoreAndCursorRing(Canvas canvas, int color, private void drawCoreAndCursorRing(Canvas canvas, int color,
boolean drawCursorRing) { boolean drawCursorRing) {
if (mDrawHistory) { if (mDrawHistory) {
@@ -2863,19 +2878,13 @@ public class WebView extends AbsoluteLayout
invalidate(); invalidate();
if (mNeedToAdjustWebTextView) { if (mNeedToAdjustWebTextView) {
mNeedToAdjustWebTextView = false; mNeedToAdjustWebTextView = false;
Rect contentBounds = nativeFocusCandidateNodeBounds(); // As a result of the zoom, the textfield is now on
Rect vBox = contentToViewRect(contentBounds); // screen. Place the WebTextView in its new place,
Rect visibleRect = new Rect(); // accounting for our new scroll/zoom values.
calcOurVisibleRect(visibleRect); if (didUpdateTextViewBounds(false)) {
if (visibleRect.contains(vBox)) {
// As a result of the zoom, the textfield is now on
// screen. Place the WebTextView in its new place,
// accounting for our new scroll/zoom values.
mWebTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX, mWebTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
contentToViewDimension( contentToViewDimension(
nativeFocusCandidateTextSize())); nativeFocusCandidateTextSize()));
mWebTextView.setRect(vBox.left, vBox.top, vBox.width(),
vBox.height());
// If it is a password field, start drawing the // If it is a password field, start drawing the
// WebTextView once again. // WebTextView once again.
if (nativeFocusCandidateIsPassword()) { if (nativeFocusCandidateIsPassword()) {
@@ -2951,6 +2960,10 @@ public class WebView extends AbsoluteLayout
if (mFindIsUp && !animateScroll) { if (mFindIsUp && !animateScroll) {
nativeDrawMatches(canvas); nativeDrawMatches(canvas);
} }
if (mFocusSizeChanged) {
mFocusSizeChanged = false;
didUpdateTextViewBounds(true);
}
} }
// draw history // draw history
@@ -4039,6 +4052,7 @@ public class WebView extends AbsoluteLayout
private static final int SELECT_CURSOR_OFFSET = 16; private static final int SELECT_CURSOR_OFFSET = 16;
private int mSelectX = 0; private int mSelectX = 0;
private int mSelectY = 0; private int mSelectY = 0;
private boolean mFocusSizeChanged = false;
private boolean mShiftIsPressed = false; private boolean mShiftIsPressed = false;
private boolean mTrackballDown = false; private boolean mTrackballDown = false;
private long mTrackballUpTime = 0; private long mTrackballUpTime = 0;
@@ -5037,6 +5051,9 @@ public class WebView extends AbsoluteLayout
/ mZoomOverviewWidth, false); / mZoomOverviewWidth, false);
} }
} }
if (draw.mFocusSizeChanged && inEditingMode()) {
mFocusSizeChanged = true;
}
break; break;
} }
case WEBCORE_INITIALIZED_MSG_ID: case WEBCORE_INITIALIZED_MSG_ID:

View File

@@ -422,6 +422,8 @@ final class WebViewCore {
*/ */
private native boolean nativeRecordContent(Region invalRegion, Point wh); private native boolean nativeRecordContent(Region invalRegion, Point wh);
private native boolean nativeFocusBoundsChanged();
/** /**
* Splits slow parts of the picture set. Called from the webkit * Splits slow parts of the picture set. Called from the webkit
* thread after nativeDrawContent returns true. * thread after nativeDrawContent returns true.
@@ -1593,6 +1595,7 @@ final class WebViewCore {
int mMinPrefWidth; int mMinPrefWidth;
RestoreState mRestoreState; // only non-null if it is for the first RestoreState mRestoreState; // only non-null if it is for the first
// picture set after the first layout // picture set after the first layout
boolean mFocusSizeChanged;
} }
private void webkitDraw() { private void webkitDraw() {
@@ -1607,6 +1610,7 @@ final class WebViewCore {
if (mWebView != null) { if (mWebView != null) {
// Send the native view size that was used during the most recent // Send the native view size that was used during the most recent
// layout. // layout.
draw.mFocusSizeChanged = nativeFocusBoundsChanged();
draw.mViewPoint = new Point(mCurrentViewWidth, mCurrentViewHeight); draw.mViewPoint = new Point(mCurrentViewWidth, mCurrentViewHeight);
if (mSettings.getUseWideViewPort()) { if (mSettings.getUseWideViewPort()) {
draw.mMinPrefWidth = Math.max( draw.mMinPrefWidth = Math.max(