reset webTextView size if focus bounds changes
When the focus bounds is changed by webkit, reflect that change on the UI side in the WebTextView. On the WebCore side, add the focus-changed state to the Draw record, which is sent whenever a new picture is recorded. On the WebView side, set a bit when receiving the Draw record, and check that bit when the picture is first drawn. This additional delay is required so that the bit isn't checked until after the new nav cache is swapped in. If the bit is set when the draw occurs, clear it, and set up the WebTextView's bounds. companion change in external/webkit fixes http://b/issue?id=2118781
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user