summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCary Clark <cary@android.com>2009-06-04 16:36:05 -0400
committerCary Clark <cary@android.com>2009-06-08 10:57:56 -0400
commit4ca8bc94f71466d1109bfbb9ef00da3256a0899b (patch)
treef9e33501cf7537082494018538140ae14fc8da82
parenta5ffe19691eaa28e4e2f85f34b262fe9762765e3 (diff)
downloadexternal_webkit-4ca8bc94f71466d1109bfbb9ef00da3256a0899b.zip
external_webkit-4ca8bc94f71466d1109bfbb9ef00da3256a0899b.tar.gz
external_webkit-4ca8bc94f71466d1109bfbb9ef00da3256a0899b.tar.bz2
fix cursor movement bugs in browser
Remove obsolete recomputeFocus, old moveCursor code Make sure focus is !null before using it.
-rw-r--r--WebKit/android/jni/WebViewCore.cpp18
-rw-r--r--WebKit/android/nav/WebView.cpp32
2 files changed, 9 insertions, 41 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp
index 7d32c46..f50dd1a 100644
--- a/WebKit/android/jni/WebViewCore.cpp
+++ b/WebKit/android/jni/WebViewCore.cpp
@@ -163,7 +163,6 @@ struct WebViewCore::JavaGlue {
jmethodID m_didFirstLayout;
jmethodID m_sendMarkNodeInvalid;
jmethodID m_sendNotifyProgressFinished;
- jmethodID m_sendRecomputeFocus;
jmethodID m_sendViewInvalidate;
jmethodID m_updateTextfield;
jmethodID m_restoreScale;
@@ -228,7 +227,6 @@ WebViewCore::WebViewCore(JNIEnv* env, jobject javaWebViewCore, WebCore::Frame* m
m_javaGlue->m_didFirstLayout = GetJMethod(env, clazz, "didFirstLayout", "(Z)V");
m_javaGlue->m_sendMarkNodeInvalid = GetJMethod(env, clazz, "sendMarkNodeInvalid", "(I)V");
m_javaGlue->m_sendNotifyProgressFinished = GetJMethod(env, clazz, "sendNotifyProgressFinished", "()V");
- m_javaGlue->m_sendRecomputeFocus = GetJMethod(env, clazz, "sendRecomputeFocus", "()V");
m_javaGlue->m_sendViewInvalidate = GetJMethod(env, clazz, "sendViewInvalidate", "(IIII)V");
m_javaGlue->m_updateTextfield = GetJMethod(env, clazz, "updateTextfield", "(IZLjava/lang/String;I)V");
m_javaGlue->m_restoreScale = GetJMethod(env, clazz, "restoreScale", "(I)V");
@@ -715,14 +713,6 @@ void WebViewCore::sendNotifyProgressFinished()
checkException(env);
}
-void WebViewCore::sendRecomputeFocus()
-{
- LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
- JNIEnv* env = JSC::Bindings::getJNIEnv();
- env->CallVoidMethod(m_javaGlue->object(env).get(), m_javaGlue->m_sendRecomputeFocus);
- checkException(env);
-}
-
void WebViewCore::viewInvalidate(const WebCore::IntRect& rect)
{
LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!");
@@ -1191,7 +1181,6 @@ bool WebViewCore::moveMouse(WebCore::Frame* frame, WebCore::Node* node,
DBG_NAV_LOGD("frame=%p node=%p x=%d y=%d ", frame, node, x, y);
if (!frame || CacheBuilder::validNode(m_mainFrame, frame, NULL) == false)
frame = m_mainFrame;
- WebCore::Node* oldFocusNode = currentFocus();
// mouse event expects the position in the window coordinate
m_mousePos = WebCore::IntPoint(x - m_scrollOffsetX, y - m_scrollOffsetY);
// validNode will still return true if the node is null, as long as we have
@@ -1402,8 +1391,11 @@ void WebViewCore::deleteSelection(int start, int end)
void WebViewCore::replaceTextfieldText(int oldStart,
int oldEnd, const WebCore::String& replace, int start, int end)
{
+ WebCore::Node* focus = currentFocus();
+ if (!focus)
+ return;
setSelection(oldStart, oldEnd);
- WebCore::TypingCommand::insertText(currentFocus()->document(), replace,
+ WebCore::TypingCommand::insertText(focus->document(), replace,
false);
setSelection(start, end);
}
@@ -1415,7 +1407,7 @@ void WebViewCore::passToJs(
WebCore::Node* focus = currentFocus();
if (!focus)
return;
- WebCore::Frame* frame = currentFocus()->document()->frame();
+ WebCore::Frame* frame = focus->document()->frame();
// Construct the ModifierKey value
WebCore::PlatformKeyboardEvent::ModifierKey mods =
static_cast<WebCore::PlatformKeyboardEvent::ModifierKey>
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp
index bcd3622..94c419f 100644
--- a/WebKit/android/nav/WebView.cpp
+++ b/WebKit/android/nav/WebView.cpp
@@ -632,8 +632,7 @@ bool cursorWantsKeyEvents()
}
/* returns true if the key had no effect (neither scrolled nor changed cursor) */
-bool moveCursor(int keyCode, int count, bool ignoreScroll, bool inval,
- void* lastSentCursor, const WebCore::IntRect* lastSentBounds)
+bool moveCursor(int keyCode, int count, bool ignoreScroll)
{
CachedRoot* root = getFrameCache(AllowNewer);
if (!root) {
@@ -657,7 +656,6 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll, bool inval,
int xMax = getScaledMaxXScroll();
int yMax = getScaledMaxYScroll();
root->setMaxScroll(xMax, yMax);
- CachedHistory savedHistory = *root->rootHistory();
const CachedNode* cachedNode = 0;
int dx = 0;
int dy = 0;
@@ -698,25 +696,12 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll, bool inval,
this->scrollBy(dx, dy);
m_lastDx = dx;
m_lastDxTime = SkTime::GetMSecs();
- ignoreScroll = true; // if move re-executes, don't scroll the second time
}
bool result = false;
if (cachedNode) {
- WebCore::IntPoint pos;
root->setCursor((CachedFrame*) cachedFrame, (CachedNode*) cachedNode);
- root->getSimulatedMousePosition(&pos);
- if (lastSentCursor == cachedNode->nodePointer() && lastSentBounds &&
- *lastSentBounds == cachedNode->bounds())
- {
- sendMoveMouse((WebCore::Frame*) cachedFrame->framePointer(),
- (WebCore::Node*) cachedNode->nodePointer(), pos.x(), pos.y());
- } else {
- sendMoveMouseIfLatest();
- if (inval)
- viewInvalidate();
- DBG_NAV_LOGD("history.mDidFirstLayout=%s",
- savedHistory.didFirstLayout() ? "true" : "false");
- }
+ sendMoveMouseIfLatest();
+ viewInvalidate();
} else {
int docHeight = root->documentHeight();
int docWidth = root->documentWidth();
@@ -1556,14 +1541,7 @@ static bool nativeMoveCursor(JNIEnv *env, jobject obj,
WebView* view = GET_NATIVE_VIEW(env, obj);
DBG_NAV_LOGD("env=%p obj=%p view=%p", env, obj, view);
LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
- return view->moveCursor(key, count, ignoreScroll, true, 0, 0);
-}
-
-static void nativeRecomputeFocus(JNIEnv *env, jobject obj)
-{
- WebView* view = GET_NATIVE_VIEW(env, obj);
- LOG_ASSERT(view, "view not set in %s", __FUNCTION__);
-// view->recomputeFocus();
+ return view->moveCursor(key, count, ignoreScroll);
}
static void nativeRecordButtons(JNIEnv* env, jobject obj, bool hasFocus,
@@ -1841,8 +1819,6 @@ static JNINativeMethod gJavaWebViewMethods[] = {
(void*) nativeMoveGeneration },
{ "nativeMoveSelection", "(IIZ)V",
(void*) nativeMoveSelection },
- { "nativeRecomputeFocus", "()V",
- (void*) nativeRecomputeFocus },
{ "nativeRecordButtons", "(ZZZ)V",
(void*) nativeRecordButtons },
{ "nativeSelectBestAt", "(Landroid/graphics/Rect;)V",