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 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,
boolean drawCursorRing) {
if (mDrawHistory) {
@@ -2863,19 +2878,13 @@ public class WebView extends AbsoluteLayout
invalidate();
if (mNeedToAdjustWebTextView) {
mNeedToAdjustWebTextView = false;
Rect contentBounds = nativeFocusCandidateNodeBounds();
Rect vBox = contentToViewRect(contentBounds);
Rect visibleRect = new Rect();
calcOurVisibleRect(visibleRect);
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.
// 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.
if (didUpdateTextViewBounds(false)) {
mWebTextView.setTextSize(TypedValue.COMPLEX_UNIT_PX,
contentToViewDimension(
nativeFocusCandidateTextSize()));
mWebTextView.setRect(vBox.left, vBox.top, vBox.width(),
vBox.height());
// If it is a password field, start drawing the
// WebTextView once again.
if (nativeFocusCandidateIsPassword()) {
@@ -2951,6 +2960,10 @@ public class WebView extends AbsoluteLayout
if (mFindIsUp && !animateScroll) {
nativeDrawMatches(canvas);
}
if (mFocusSizeChanged) {
mFocusSizeChanged = false;
didUpdateTextViewBounds(true);
}
}
// draw history
@@ -4039,6 +4052,7 @@ public class WebView extends AbsoluteLayout
private static final int SELECT_CURSOR_OFFSET = 16;
private int mSelectX = 0;
private int mSelectY = 0;
private boolean mFocusSizeChanged = false;
private boolean mShiftIsPressed = false;
private boolean mTrackballDown = false;
private long mTrackballUpTime = 0;
@@ -5037,6 +5051,9 @@ public class WebView extends AbsoluteLayout
/ mZoomOverviewWidth, false);
}
}
if (draw.mFocusSizeChanged && inEditingMode()) {
mFocusSizeChanged = true;
}
break;
}
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 nativeFocusBoundsChanged();
/**
* Splits slow parts of the picture set. Called from the webkit
* thread after nativeDrawContent returns true.
@@ -1593,6 +1595,7 @@ final class WebViewCore {
int mMinPrefWidth;
RestoreState mRestoreState; // only non-null if it is for the first
// picture set after the first layout
boolean mFocusSizeChanged;
}
private void webkitDraw() {
@@ -1607,6 +1610,7 @@ final class WebViewCore {
if (mWebView != null) {
// Send the native view size that was used during the most recent
// layout.
draw.mFocusSizeChanged = nativeFocusBoundsChanged();
draw.mViewPoint = new Point(mCurrentViewWidth, mCurrentViewHeight);
if (mSettings.getUseWideViewPort()) {
draw.mMinPrefWidth = Math.max(