Skip to content

Commit 39036ac

Browse files
author
Michael Kolb
committed
Remove flicker from WebTextView
Bug: 5522186 Update LayoutParams when position changed only Change-Id: I54beb489c261090d7ba258354449501b771fd98e
1 parent ea50748 commit 39036ac

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

core/java/android/webkit/WebTextView.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,9 @@
1616

1717
package android.webkit;
1818

19-
import com.android.internal.widget.EditableInputConnection;
20-
2119
import android.content.Context;
22-
import android.graphics.Canvas;
2320
import android.graphics.Color;
24-
import android.graphics.ColorFilter;
2521
import android.graphics.Paint;
26-
import android.graphics.PixelFormat;
2722
import android.graphics.Rect;
2823
import android.graphics.drawable.ColorDrawable;
2924
import android.os.Bundle;
@@ -60,12 +55,12 @@
6055
import android.widget.AutoCompleteTextView;
6156
import android.widget.TextView;
6257

58+
import junit.framework.Assert;
59+
6360
import java.net.MalformedURLException;
6461
import java.net.URL;
6562
import java.util.ArrayList;
6663

67-
import junit.framework.Assert;
68-
6964
/**
7065
* WebTextView is a specialized version of EditText used by WebView
7166
* to overlay html textfields (and textareas) to use our standard
@@ -926,18 +921,23 @@ private void setMaxLength(int maxLength) {
926921
*/
927922
/* package */ void setRect(int x, int y, int width, int height) {
928923
LayoutParams lp = (LayoutParams) getLayoutParams();
924+
boolean needsUpdate = false;
929925
if (null == lp) {
930926
lp = new LayoutParams(width, height, x, y);
931927
} else {
932-
lp.x = x;
933-
lp.y = y;
934-
lp.width = width;
935-
lp.height = height;
928+
if ((lp.x != x) || (lp.y != y) || (lp.width != width)
929+
|| (lp.height != height)) {
930+
needsUpdate = true;
931+
lp.x = x;
932+
lp.y = y;
933+
lp.width = width;
934+
lp.height = height;
935+
}
936936
}
937937
if (getParent() == null) {
938938
// Insert the view so that it's drawn first (at index 0)
939939
mWebView.addView(this, 0, lp);
940-
} else {
940+
} else if (needsUpdate) {
941941
setLayoutParams(lp);
942942
}
943943
// Set up a measure spec so a layout can always be recreated.

0 commit comments

Comments
 (0)