summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/java/android/webkit/WebView.java46
-rw-r--r--core/java/android/webkit/WebViewCore.java17
2 files changed, 22 insertions, 41 deletions
diff --git a/core/java/android/webkit/WebView.java b/core/java/android/webkit/WebView.java
index c128efc8cd7b..e9a51dffefeb 100644
--- a/core/java/android/webkit/WebView.java
+++ b/core/java/android/webkit/WebView.java
@@ -366,10 +366,6 @@ public class WebView extends AbsoluteLayout
// take control of touch events unless it says no for touch down event.
private boolean mPreventDrag;
- // If rebuildWebTextView gets called while we are out of focus, use this
- // variable to remember to do it next time we gain focus.
- private boolean mNeedsRebuildWebTextView = false;
-
// Whether or not to draw the cursor ring.
private boolean mDrawCursorRing = true;
@@ -2951,7 +2947,6 @@ public class WebView extends AbsoluteLayout
if (!hasFocus() && (null == mWebTextView || !mWebTextView.hasFocus())
|| (mTouchMode >= FIRST_SCROLL_ZOOM
&& mTouchMode <= LAST_SCROLL_ZOOM)) {
- mNeedsRebuildWebTextView = true;
return;
}
boolean alreadyThere = inEditingMode();
@@ -3200,7 +3195,6 @@ public class WebView extends AbsoluteLayout
// TODO: should we pass all the keys to DOM or check the meta tag
if (nativeCursorWantsKeyEvents() || true) {
- mWebViewCore.sendMessage(EventHub.SET_ACTIVE, 1);
// pass the key to DOM
mWebViewCore.sendMessage(EventHub.KEY_DOWN, event);
// return true as DOM handles the key
@@ -3362,7 +3356,6 @@ public class WebView extends AbsoluteLayout
if (child == this) {
if (inEditingMode()) {
clearTextEntry();
- mNeedsRebuildWebTextView = true;
}
}
}
@@ -3383,16 +3376,11 @@ public class WebView extends AbsoluteLayout
if (hasWindowFocus) {
if (hasFocus()) {
// If our window regained focus, and we have focus, then begin
- // drawing the cursor ring, and restore the TextView if
- // necessary.
+ // drawing the cursor ring
mDrawCursorRing = true;
- if (mNeedsRebuildWebTextView) {
- rebuildWebTextView();
- }
if (mNativeClass != 0) {
nativeRecordButtons(true, false, true);
}
- setFocusControllerActive(true);
} else {
// If our window gained focus, but we do not have it, do not
// draw the cursor ring.
@@ -3418,23 +3406,23 @@ public class WebView extends AbsoluteLayout
if (mNativeClass != 0) {
nativeRecordButtons(false, false, true);
}
- setFocusControllerActive(false);
+ setFocusControllerInactive();
}
invalidate();
super.onWindowFocusChanged(hasWindowFocus);
}
/*
- * Pass a message to WebCore Thread, determining whether the WebCore::Page's
- * FocusController is "active" so that it will draw the blinking cursor.
+ * Pass a message to WebCore Thread, telling the WebCore::Page's
+ * FocusController to be "inactive" so that it will
+ * not draw the blinking cursor. It gets set to "active" to draw the cursor
+ * in WebViewCore.cpp, when the WebCore thread receives key events/clicks.
*/
- private void setFocusControllerActive(boolean active) {
+ private void setFocusControllerInactive() {
// Do not need to also check whether mWebViewCore is null, because
// mNativeClass is only set if mWebViewCore is non null
if (mNativeClass == 0) return;
- active &= nativeCursorMatchesFocus() || !nativeHasFocusNode()
- || !nativeCursorWantsKeyEvents();
- mWebViewCore.sendMessage(EventHub.SET_ACTIVE, active ? 1 : 0, 0);
+ mWebViewCore.sendMessage(EventHub.SET_INACTIVE);
}
@Override
@@ -3445,20 +3433,12 @@ public class WebView extends AbsoluteLayout
}
if (focused) {
// When we regain focus, if we have window focus, resume drawing
- // the cursor ring, and add the TextView if necessary.
+ // the cursor ring
if (hasWindowFocus()) {
mDrawCursorRing = true;
- if (mNeedsRebuildWebTextView) {
- rebuildWebTextView();
- mNeedsRebuildWebTextView = false;
- }
if (mNativeClass != 0) {
nativeRecordButtons(true, false, true);
}
- // FIXME: This is unnecessary if we are gaining focus from the
- // WebTextView. How can we tell if it was the last thing in
- // focus?
- setFocusControllerActive(true);
//} else {
// The WebView has gained focus while we do not have
// windowfocus. When our window lost focus, we should have
@@ -3472,7 +3452,7 @@ public class WebView extends AbsoluteLayout
if (mNativeClass != 0) {
nativeRecordButtons(false, false, true);
}
- setFocusControllerActive(false);
+ setFocusControllerInactive();
}
mGotKeyDown = false;
}
@@ -5076,9 +5056,9 @@ public class WebView extends AbsoluteLayout
}
// called by JNI
- private void sendMoveMouseIfLatest() {
- if (!nativeCursorMatchesFocus() && nativeCursorWantsKeyEvents()) {
- setFocusControllerActive(false);
+ private void sendMoveMouseIfLatest(boolean setFocusControllerInactive) {
+ if (setFocusControllerInactive) {
+ setFocusControllerInactive();
}
mWebViewCore.sendMessage(EventHub.SET_MOVE_MOUSE_IF_LATEST, cursorData());
}
diff --git a/core/java/android/webkit/WebViewCore.java b/core/java/android/webkit/WebViewCore.java
index d16057986197..90d0709e9149 100644
--- a/core/java/android/webkit/WebViewCore.java
+++ b/core/java/android/webkit/WebViewCore.java
@@ -375,7 +375,7 @@ final class WebViewCore {
String currentText, int keyCode, int keyValue, boolean down,
boolean cap, boolean fn, boolean sym);
- private native void nativeSetFocusControllerActive(boolean active);
+ private native void nativeSetFocusControllerInactive();
private native void nativeSaveDocumentState(int frame);
@@ -615,7 +615,7 @@ final class WebViewCore {
"LOAD_DATA", // = 139;
"TOUCH_UP", // = 140;
"TOUCH_EVENT", // = 141;
- "SET_ACTIVE", // = 142;
+ "SET_INACTIVE", // = 142;
"ON_PAUSE", // = 143
"ON_RESUME", // = 144
"FREE_MEMORY", // = 145
@@ -670,9 +670,10 @@ final class WebViewCore {
// message used to pass UI touch events to WebCore
static final int TOUCH_EVENT = 141;
- // Used to tell the focus controller whether to draw the blinking cursor
- // or not, based on whether the WebView has focus.
- static final int SET_ACTIVE = 142;
+ // Used to tell the focus controller not to draw the blinking cursor,
+ // based on whether the WebView has focus and whether the WebView's
+ // cursor matches the webpage's focus.
+ static final int SET_INACTIVE = 142;
// lifecycle activities for just this DOM (unlike pauseTimers, which
// is global)
@@ -724,7 +725,7 @@ final class WebViewCore {
public void handleMessage(Message msg) {
if (DebugFlags.WEB_VIEW_CORE) {
Log.v(LOGTAG, msg.what < LOAD_URL || msg.what
- > SET_ACTIVE ? Integer.toString(msg.what)
+ > SET_INACTIVE ? Integer.toString(msg.what)
: HandlerDebugString[msg.what - LOAD_URL]);
}
switch (msg.what) {
@@ -950,8 +951,8 @@ final class WebViewCore {
break;
}
- case SET_ACTIVE:
- nativeSetFocusControllerActive(msg.arg1 == 1);
+ case SET_INACTIVE:
+ nativeSetFocusControllerInactive();
break;
case ADD_JS_INTERFACE: