diff options
author | Feng Qian <fqian@google.com> | 2009-06-18 14:00:49 -0700 |
---|---|---|
committer | Feng Qian <fqian@google.com> | 2009-06-18 14:00:49 -0700 |
commit | c9c4d65c1547996ed3748026904d6e7f09aec2b4 (patch) | |
tree | 5298ee7f87a0f97f06d5b2e66c37dedd88238ccf /WebKit/android/jni | |
parent | ad9f76210e4cbae75d762b7a65b39af424879b6b (diff) | |
parent | 36747fa778285f57f2f53c047028be83e9d8776d (diff) | |
download | external_webkit-c9c4d65c1547996ed3748026904d6e7f09aec2b4.zip external_webkit-c9c4d65c1547996ed3748026904d6e7f09aec2b4.tar.gz external_webkit-c9c4d65c1547996ed3748026904d6e7f09aec2b4.tar.bz2 |
Merge commit 'goog/master' into webkit_merge
Resolved conflicts:
WebCore/Android.mk
WebCore/storage/LocalStorageArea.h
WebCore/storage/SessionStorageArea.cpp
WebCore/storage/StorageEvent.cpp
Diffstat (limited to 'WebKit/android/jni')
-rw-r--r-- | WebKit/android/jni/JavaBridge.cpp | 50 | ||||
-rw-r--r-- | WebKit/android/jni/JavaSharedClient.cpp | 11 | ||||
-rw-r--r-- | WebKit/android/jni/JavaSharedClient.h | 4 | ||||
-rw-r--r-- | WebKit/android/jni/WebSettings.cpp | 31 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 198 | ||||
-rw-r--r-- | WebKit/android/jni/WebViewCore.h | 17 |
6 files changed, 160 insertions, 151 deletions
diff --git a/WebKit/android/jni/JavaBridge.cpp b/WebKit/android/jni/JavaBridge.cpp index 98d7c43..7c4636f 100644 --- a/WebKit/android/jni/JavaBridge.cpp +++ b/WebKit/android/jni/JavaBridge.cpp @@ -31,6 +31,7 @@ #include "Cache.h" #include "CookieClient.h" #include "JavaSharedClient.h" +#include "KeyGeneratorClient.h" #include "KURL.h" #include "NetworkStateNotifier.h" #include "Page.h" @@ -58,7 +59,7 @@ static jfieldID gJavaBridge_ObjectID; // ---------------------------------------------------------------------------- -class JavaBridge : public TimerClient, public CookieClient, public PluginClient +class JavaBridge : public TimerClient, public CookieClient, public PluginClient, public KeyGeneratorClient { public: JavaBridge(JNIEnv* env, jobject obj); @@ -76,6 +77,10 @@ public: virtual WTF::Vector<WebCore::String> getPluginDirectories(); + virtual WTF::Vector<String> getSupportedKeyStrengthList(); + virtual WebCore::String getSignedPublicKeyAndChallengeString(unsigned index, + const WebCore::String& challenge, const WebCore::KURL& url); + //////////////////////////////////////////// virtual void setSharedTimerCallback(void (*f)()); @@ -103,6 +108,8 @@ private: jmethodID mCookiesEnabled; jmethodID mGetPluginDirectories; jmethodID mSignalFuncPtrQueue; + jmethodID mGetKeyStrengthList; + jmethodID mGetSignedPublicKey; }; static void (*sSharedTimerFiredCallback)(); @@ -119,16 +126,21 @@ JavaBridge::JavaBridge(JNIEnv* env, jobject obj) mCookiesEnabled = env->GetMethodID(clazz, "cookiesEnabled", "()Z"); mGetPluginDirectories = env->GetMethodID(clazz, "getPluginDirectories", "()[Ljava/lang/String;"); mSignalFuncPtrQueue = env->GetMethodID(clazz, "signalServiceFuncPtrQueue", "()V"); + mGetKeyStrengthList = env->GetMethodID(clazz, "getKeyStrengthList", "()[Ljava/lang/String;"); + mGetSignedPublicKey = env->GetMethodID(clazz, "getSignedPublicKey", "(ILjava/lang/String;Ljava/lang/String;)Ljava/lang/String;"); LOG_ASSERT(mSetSharedTimer, "Could not find method setSharedTimer"); LOG_ASSERT(mStopSharedTimer, "Could not find method stopSharedTimer"); LOG_ASSERT(mSetCookies, "Could not find method setCookies"); LOG_ASSERT(mCookies, "Could not find method cookies"); LOG_ASSERT(mCookiesEnabled, "Could not find method cookiesEnabled"); + LOG_ASSERT(mGetKeyStrengthList, "Could not find method getKeyStrengthList"); + LOG_ASSERT(mGetSignedPublicKey, "Could not find method getSignedPublicKey"); JavaSharedClient::SetTimerClient(this); JavaSharedClient::SetCookieClient(this); JavaSharedClient::SetPluginClient(this); + JavaSharedClient::SetKeyGeneratorClient(this); } JavaBridge::~JavaBridge() @@ -141,6 +153,8 @@ JavaBridge::~JavaBridge() JavaSharedClient::SetTimerClient(NULL); JavaSharedClient::SetCookieClient(NULL); + JavaSharedClient::SetPluginClient(NULL); + JavaSharedClient::SetKeyGeneratorClient(NULL); } void @@ -236,6 +250,40 @@ void JavaBridge::signalServiceFuncPtrQueue() env->CallVoidMethod(obj.get(), mSignalFuncPtrQueue); } +WTF::Vector<WebCore::String>JavaBridge::getSupportedKeyStrengthList() { + WTF::Vector<WebCore::String> list; + JNIEnv* env = JSC::Bindings::getJNIEnv(); + AutoJObject obj = getRealObject(env, mJavaObject); + jobjectArray array = (jobjectArray) env->CallObjectMethod(obj.get(), + mGetKeyStrengthList); + int count = env->GetArrayLength(array); + for (int i = 0; i < count; ++i) { + jstring keyStrength = (jstring) env->GetObjectArrayElement(array, i); + list.append(to_string(env, keyStrength)); + env->DeleteLocalRef(keyStrength); + } + env->DeleteLocalRef(array); + checkException(env); + return list; +} + +WebCore::String JavaBridge::getSignedPublicKeyAndChallengeString(unsigned index, + const WebCore::String& challenge, const WebCore::KURL& url) { + JNIEnv* env = JSC::Bindings::getJNIEnv(); + jstring jChallenge = env->NewString(challenge.characters(), + challenge.length()); + const WebCore::String& urlStr = url.string(); + jstring jUrl = env->NewString(urlStr.characters(), urlStr.length()); + AutoJObject obj = getRealObject(env, mJavaObject); + jstring key = (jstring) env->CallObjectMethod(obj.get(), + mGetSignedPublicKey, index, jChallenge, jUrl); + WebCore::String ret = to_string(env, key); + env->DeleteLocalRef(jChallenge); + env->DeleteLocalRef(jUrl); + env->DeleteLocalRef(key); + return ret; +} + // ---------------------------------------------------------------------------- void JavaBridge::Constructor(JNIEnv* env, jobject obj) diff --git a/WebKit/android/jni/JavaSharedClient.cpp b/WebKit/android/jni/JavaSharedClient.cpp index 3ddf726..2eec7b9 100644 --- a/WebKit/android/jni/JavaSharedClient.cpp +++ b/WebKit/android/jni/JavaSharedClient.cpp @@ -45,6 +45,11 @@ namespace android { return gPluginClient; } + KeyGeneratorClient* JavaSharedClient::GetKeyGeneratorClient() + { + return gKeyGeneratorClient; + } + void JavaSharedClient::SetTimerClient(TimerClient* client) { gTimerClient = client; @@ -60,9 +65,15 @@ namespace android { gPluginClient = client; } + void JavaSharedClient::SetKeyGeneratorClient(KeyGeneratorClient* client) + { + gKeyGeneratorClient = client; + } + TimerClient* JavaSharedClient::gTimerClient = NULL; CookieClient* JavaSharedClient::gCookieClient = NULL; PluginClient* JavaSharedClient::gPluginClient = NULL; + KeyGeneratorClient* JavaSharedClient::gKeyGeneratorClient = NULL; /////////////////////////////////////////////////////////////////////////// diff --git a/WebKit/android/jni/JavaSharedClient.h b/WebKit/android/jni/JavaSharedClient.h index 69c05ce..bf59969 100644 --- a/WebKit/android/jni/JavaSharedClient.h +++ b/WebKit/android/jni/JavaSharedClient.h @@ -31,6 +31,7 @@ namespace android { class TimerClient; class CookieClient; class PluginClient; + class KeyGeneratorClient; class JavaSharedClient { @@ -38,10 +39,12 @@ namespace android { static TimerClient* GetTimerClient(); static CookieClient* GetCookieClient(); static PluginClient* GetPluginClient(); + static KeyGeneratorClient* GetKeyGeneratorClient(); static void SetTimerClient(TimerClient* client); static void SetCookieClient(CookieClient* client); static void SetPluginClient(PluginClient* client); + static void SetKeyGeneratorClient(KeyGeneratorClient* client); // can be called from any thread, to be executed in webkit thread static void EnqueueFunctionPtr(void (*proc)(void*), void* payload); @@ -52,6 +55,7 @@ namespace android { static TimerClient* gTimerClient; static CookieClient* gCookieClient; static PluginClient* gPluginClient; + static KeyGeneratorClient* gKeyGeneratorClient; }; } #endif diff --git a/WebKit/android/jni/WebSettings.cpp b/WebKit/android/jni/WebSettings.cpp index 110cde0..7d2b12d 100644 --- a/WebKit/android/jni/WebSettings.cpp +++ b/WebKit/android/jni/WebSettings.cpp @@ -28,17 +28,13 @@ #include <config.h> #include <wtf/Platform.h> -#if ENABLE(DATABASE) -#include "DatabaseTracker.h" -#endif -#if ENABLE(OFFLINE_WEB_APPLICATIONS) #include "ApplicationCacheStorage.h" -#endif +#include "DatabaseTracker.h" +#include "DocLoader.h" #include "Document.h" #include "Frame.h" #include "FrameLoader.h" #include "FrameView.h" -#include "DocLoader.h" #include "Page.h" #include "RenderTable.h" #include "Settings.h" @@ -84,6 +80,13 @@ struct FieldIds { mPluginsEnabled = env->GetFieldID(clazz, "mPluginsEnabled", "Z"); #if ENABLE(DATABASE) mDatabaseEnabled = env->GetFieldID(clazz, "mDatabaseEnabled", "Z"); +#endif +#if ENABLE(DOM_STORAGE) + mDomStorageEnabled = env->GetFieldID(clazz, "mDomStorageEnabled", "Z"); +#endif +#if ENABLE(DATABASE) || ENABLE(DOM_STORAGE) + // The databases saved to disk for both the SQL and DOM Storage APIs are stored + // in the same base directory. mDatabasePath = env->GetFieldID(clazz, "mDatabasePath", "Ljava/lang/String;"); #endif #if ENABLE(OFFLINE_WEB_APPLICATIONS) @@ -173,6 +176,11 @@ struct FieldIds { #if ENABLE(DATABASE) jfieldID mDatabaseEnabled; +#endif +#if ENABLE(DOM_STORAGE) + jfieldID mDomStorageEnabled; +#endif +#if ENABLE(DATABASE) || ENABLE(DOM_STORAGE) jfieldID mDatabasePath; #endif }; @@ -312,6 +320,17 @@ public: str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath); WebCore::DatabaseTracker::tracker().setDatabaseDirectoryPath(to_string(env, str)); #endif +#if ENABLE(DOM_STORAGE) + flag = env->GetBooleanField(obj, gFieldIds->mDomStorageEnabled); + s->setLocalStorageEnabled(flag); + str = (jstring)env->GetObjectField(obj, gFieldIds->mDatabasePath); + if (str) { + WebCore::String localStorageDatabasePath = to_string(env,str); + if (localStorageDatabasePath.length()) { + s->setLocalStorageDatabasePath(localStorageDatabasePath); + } + } +#endif } }; diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index 0d5a3dd..ebe5d23 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -288,12 +288,12 @@ void WebViewCore::reset(bool fromConstructor) m_updatedFrameCache = true; m_frameCacheOutOfDate = true; m_snapAnchorNode = 0; - m_useReplay = false; m_skipContentDraw = false; m_findIsUp = false; m_domtree_version = 0; m_check_domtree_version = true; m_progressDone = false; + m_hasCursorBounds = false; } static bool layoutIfNeededRecursive(WebCore::Frame* f) @@ -489,12 +489,15 @@ void WebViewCore::recordPictureSet(PictureSet* content) bool update = m_lastFocused != oldFocusNode || m_lastFocusedBounds != oldBounds || m_findIsUp || (m_check_domtree_version && latestVersion != m_domtree_version); - if (!update && m_hasCursorBounds) { // avoid mutex when possible - bool hasCursorBounds; - void* cursorNode; + if (!update) { // avoid mutex when possible + // This block is specifically for the floating bar in gmail messages + // it has been disabled because it adversely affects the performance + // of loading all pages. + if (true || !m_hasCursorBounds) + return; gCursorBoundsMutex.lock(); - hasCursorBounds = m_hasCursorBounds; - cursorNode = m_cursorNode; + bool hasCursorBounds = m_hasCursorBounds; + void* cursorNode = m_cursorNode; IntRect bounds = m_cursorBounds; gCursorBoundsMutex.unlock(); if (hasCursorBounds && cursorNode) { @@ -502,10 +505,10 @@ void WebViewCore::recordPictureSet(PictureSet* content) bounds.y() + (bounds.height() >> 1)); HitTestResult hitTestResult = m_mainFrame->eventHandler()-> hitTestResultAtPoint(center, false); - if (m_cursorNode == hitTestResult.innerNode()) - return; // don't update DBG_NAV_LOGD("at (%d,%d) old=%p new=%p", center.x(), center.y(), - m_cursorNode, hitTestResult.innerNode()); + cursorNode, hitTestResult.innerNode()); + if (cursorNode == hitTestResult.innerNode()) + return; // don't update } } m_lastFocused = oldFocusNode; @@ -858,9 +861,10 @@ void WebViewCore::doMaxScroll(CacheBuilder::Direction dir) this->scrollBy(dx, dy, true); } -void WebViewCore::setScrollOffset(int dx, int dy) +void WebViewCore::setScrollOffset(int moveGeneration, int dx, int dy) { - DBG_NAV_LOGD("{%d,%d}", dx, dy); + DBG_NAV_LOGD("{%d,%d} m_scrollOffset=(%d,%d)", dx, dy, + m_scrollOffsetX, m_scrollOffsetY); if (m_scrollOffsetX != dx || m_scrollOffsetY != dy) { m_scrollOffsetX = dx; m_scrollOffsetY = dy; @@ -871,6 +875,14 @@ void WebViewCore::setScrollOffset(int dx, int dy) m_scrollOffsetY); m_mainFrame->eventHandler()->sendScrollEvent(); } + gCursorBoundsMutex.lock(); + bool hasCursorBounds = m_hasCursorBounds; + Frame* frame = (Frame*) m_cursorFrame; + IntPoint location = m_cursorLocation; + gCursorBoundsMutex.unlock(); + if (!hasCursorBounds) + return; + moveMouseIfLatest(moveGeneration, frame, location.x(), location.y()); } void WebViewCore::setGlobalBounds(int x, int y, int h, int v) @@ -993,11 +1005,11 @@ WebCore::String WebViewCore::retrieveHref(WebCore::Frame* frame, WebCore::Node* return anchor->href(); } -bool WebViewCore::prepareFrameCache() +void WebViewCore::updateFrameCache() { if (!m_frameCacheOutOfDate) { DBG_NAV_LOG("!m_frameCacheOutOfDate"); - return false; + return; } #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreBuildNavTimeCounter); @@ -1026,61 +1038,9 @@ bool WebViewCore::prepareFrameCache() recordPicture(m_tempPict); m_temp->setPicture(m_tempPict); m_temp->setTextGeneration(m_textGeneration); -// if (m_temp->currentFocus()) -// return true; WebCoreViewBridge* window = m_mainFrame->view()->platformWidget(); m_temp->setVisibleRect(WebCore::IntRect(m_scrollOffsetX, m_scrollOffsetY, window->width(), window->height())); - bool hasCursorBounds; - gCursorBoundsMutex.lock(); - hasCursorBounds = m_hasCursorBounds; - IntRect bounds = m_cursorBounds; - gCursorBoundsMutex.unlock(); - if (!hasCursorBounds) - return true; - int x, y; - const CachedFrame* frame; - const CachedNode* node = m_temp->findAt(bounds, &frame, &x, &y, false); - if (!node) - return true; - // require that node have approximately the same bounds (+/- 4) and the same - // center (+/- 2) - IntPoint oldCenter = IntPoint(bounds.x() + (bounds.width() >> 1), - bounds.y() + (bounds.height() >> 1)); - IntRect newBounds = node->bounds(); - IntPoint newCenter = IntPoint(newBounds.x() + (newBounds.width() >> 1), - newBounds.y() + (newBounds.height() >> 1)); - DBG_NAV_LOGD("oldCenter=(%d,%d) newCenter=(%d,%d)" - " bounds=(%d,%d,w=%d,h=%d) newBounds=(%d,%d,w=%d,h=%d)", - oldCenter.x(), oldCenter.y(), newCenter.x(), newCenter.y(), - bounds.x(), bounds.y(), bounds.width(), bounds.height(), - newBounds.x(), newBounds.y(), newBounds.width(), newBounds.height()); - if (abs(oldCenter.x() - newCenter.x()) > 2) - return true; - if (abs(oldCenter.y() - newCenter.y()) > 2) - return true; - if (abs(bounds.x() - newBounds.x()) > 4) - return true; - if (abs(bounds.y() - newBounds.y()) > 4) - return true; - if (abs(bounds.right() - newBounds.right()) > 4) - return true; - if (abs(bounds.bottom() - newBounds.bottom()) > 4) - return true; - DBG_NAV_LOGD("node=%p frame=%p x=%d y=%d bounds=(%d,%d,w=%d,h=%d)", - node, frame, x, y, bounds.x(), bounds.y(), bounds.width(), - bounds.height()); - m_temp->setCursor(const_cast<CachedFrame*>(frame), - const_cast<CachedNode*>(node)); - return true; -} - -void WebViewCore::releaseFrameCache(bool newCache) -{ - if (!newCache) { - DBG_NAV_LOG("!newCache"); - return; - } gFrameCacheMutex.lock(); delete m_frameCacheKit; delete m_navPictureKit; @@ -1088,25 +1048,12 @@ void WebViewCore::releaseFrameCache(bool newCache) m_navPictureKit = m_tempPict; m_updatedFrameCache = true; #if DEBUG_NAV_UI - const CachedNode* cachedCursorNode = m_frameCacheKit->currentCursor(); const CachedNode* cachedFocusNode = m_frameCacheKit->currentFocus(); - DBG_NAV_LOGD("cachedCursor=%d (%p) cachedFocusNode=%d (nodePointer=%p)", - cachedCursorNode ? cachedCursorNode->index() : 0, - cachedCursorNode ? cachedCursorNode->nodePointer() : 0, + DBG_NAV_LOGD("cachedFocusNode=%d (nodePointer=%p)", cachedFocusNode ? cachedFocusNode->index() : 0, cachedFocusNode ? cachedFocusNode->nodePointer() : 0); #endif gFrameCacheMutex.unlock(); - // it's tempting to send an invalidate here, but it's a bad idea - // the cache is now up to date, but the focus is not -- the event - // may need to be recomputed from the prior history. An invalidate - // will draw the stale location causing the ring to flash at the wrong place. -} - -void WebViewCore::updateFrameCache() -{ - m_useReplay = false; - releaseFrameCache(prepareFrameCache()); } /////////////////////////////////////////////////////////////////////////////// @@ -1173,30 +1120,18 @@ void WebViewCore::sendPluginEvent(const ANPEvent& evt) /////////////////////////////////////////////////////////////////////////////// void WebViewCore::moveMouseIfLatest(int moveGeneration, - WebCore::Frame* frame, WebCore::Node* node, int x, int y, - bool ignoreNullFocus) + WebCore::Frame* frame, int x, int y) { DBG_NAV_LOGD("m_moveGeneration=%d moveGeneration=%d" - " frame=%p node=%p x=%d y=%d", - m_moveGeneration, moveGeneration, frame, node, x, y); - if (m_moveGeneration > moveGeneration) { - DBG_NAV_LOGD("m_moveGeneration=%d > moveGeneration=%d", - m_moveGeneration, moveGeneration); - return; // short-circuit if a newer move has already been generated - } - m_useReplay = true; - bool newCache = prepareFrameCache(); // must wait for possible recompute before using + " frame=%p x=%d y=%d", + m_moveGeneration, moveGeneration, frame, x, y); if (m_moveGeneration > moveGeneration) { DBG_NAV_LOGD("m_moveGeneration=%d > moveGeneration=%d", m_moveGeneration, moveGeneration); - releaseFrameCache(newCache); return; // short-circuit if a newer move has already been generated } - releaseFrameCache(newCache); m_lastGeneration = moveGeneration; - if (!node && ignoreNullFocus) - return; - moveMouse(frame, node, x, y); + moveMouse(frame, x, y); } static bool nodeIsPlugin(Node* node) { @@ -1209,10 +1144,10 @@ static bool nodeIsPlugin(Node* node) { } // Update mouse position and may change focused node. -bool WebViewCore::moveMouse(WebCore::Frame* frame, WebCore::Node* node, - int x, int y) +void WebViewCore::moveMouse(WebCore::Frame* frame, int x, int y) { - DBG_NAV_LOGD("frame=%p node=%p x=%d y=%d ", frame, node, x, y); + DBG_NAV_LOGD("frame=%p x=%d y=%d scrollOffset=(%d,%d)", frame, + x, y, m_scrollOffsetX, m_scrollOffsetY); if (!frame || CacheBuilder::validNode(m_mainFrame, frame, NULL) == false) frame = m_mainFrame; // mouse event expects the position in the window coordinate @@ -1223,16 +1158,6 @@ bool WebViewCore::moveMouse(WebCore::Frame* frame, WebCore::Node* node, WebCore::NoButton, WebCore::MouseEventMoved, 1, false, false, false, false, WTF::currentTime()); frame->eventHandler()->handleMouseMoveEvent(mouseEvent); - bool valid = CacheBuilder::validNode(m_mainFrame, frame, node); - if (!node || !valid) { - DBG_NAV_LOGD("exit: node=%p valid=%s", node, valid ? "true" : "false"); - return false; - } - - // hack to give the plugin focus (for keys). better fix on the way - if (nodeIsPlugin(node)) - node->document()->setFocusedNode(node); - return true; } static int findTextBoxIndex(WebCore::Node* node, const WebCore::IntPoint& pt) @@ -1432,6 +1357,7 @@ void WebViewCore::replaceTextfieldText(int oldStart, WebCore::TypingCommand::insertText(focus->document(), replace, false); setSelection(start, end); + setFocusControllerActive(true); } void WebViewCore::passToJs( @@ -1460,6 +1386,7 @@ void WebViewCore::passToJs( WebCore::RenderObject* renderer = focus->renderer(); if (!renderer || (!renderer->isTextField() && !renderer->isTextArea())) return; + setFocusControllerActive(true); WebCore::RenderTextControl* renderText = static_cast<WebCore::RenderTextControl*>(renderer); WebCore::String test = renderText->text(); @@ -1669,6 +1596,7 @@ bool WebViewCore::key(int keyCode, UChar32 unichar, int repeatCount, bool isShif return eventHandler->keyEvent(evt); } +// For when the user clicks the trackball bool WebViewCore::click() { bool keyHandled = false; WebCore::IntPoint pt = m_mousePos; @@ -1677,9 +1605,7 @@ bool WebViewCore::click() { hitTestResultAtPoint(pt, false); WebCore::Node* focusNode = hitTestResult.innerNode(); if (focusNode) { - WebFrame::getWebFrame(m_mainFrame)->setUserInitiatedClick(true); keyHandled = handleMouseClick(focusNode->document()->frame(), focusNode); - WebFrame::getWebFrame(m_mainFrame)->setUserInitiatedClick(false); } return keyHandled; } @@ -1720,7 +1646,7 @@ void WebViewCore::touchUp(int touchGeneration, " x=%d y=%d", m_touchGeneration, touchGeneration, x, y); return; // short circuit if a newer touch has been generated } - moveMouse(frame, node, x, y); + moveMouse(frame, x, y); m_lastGeneration = touchGeneration; if (frame && CacheBuilder::validNode(m_mainFrame, frame, 0)) { frame->loader()->resetMultipleFormSubmissionProtection(); @@ -1733,6 +1659,7 @@ void WebViewCore::touchUp(int touchGeneration, client->setFromClick(false); } +// Common code for both clicking with the trackball and touchUp bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* nodePtr) { bool valid = framePtr == NULL @@ -1790,6 +1717,15 @@ bool WebViewCore::handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* node WTF::currentTime()); bool handled = framePtr->eventHandler()->handleMouseReleaseEvent(mouseUp); webFrame->setUserInitiatedClick(false); + + // If the user clicked on a textfield, make the focusController active + // so we show the blinking cursor. + WebCore::Node* focusNode = currentFocus(); + if (focusNode) { + WebCore::RenderObject* renderer = focusNode->renderer(); + if (renderer && (renderer->isTextField() || renderer->isTextArea())) + setFocusControllerActive(true); + } return handled; } @@ -2008,7 +1944,7 @@ static void SetSize(JNIEnv *env, jobject obj, jint width, jint height, realScreenWidth, screenHeight); } -static void SetScrollOffset(JNIEnv *env, jobject obj, jint dx, jint dy) +static void SetScrollOffset(JNIEnv *env, jobject obj, jint gen, jint x, jint y) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); @@ -2016,7 +1952,7 @@ static void SetScrollOffset(JNIEnv *env, jobject obj, jint dx, jint dy) WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); LOG_ASSERT(viewImpl, "need viewImpl"); - viewImpl->setScrollOffset(dx, dy); + viewImpl->setScrollOffset(gen, x, y); } static void SetGlobalBounds(JNIEnv *env, jobject obj, jint x, jint y, jint h, @@ -2100,15 +2036,15 @@ static void PassToJs(JNIEnv *env, jobject obj, generation, current, keyCode, keyValue, down, cap, fn, sym); } -static void SetFocusControllerActive(JNIEnv *env, jobject obj, jboolean active) +static void SetFocusControllerInactive(JNIEnv *env, jobject obj) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); #endif - LOGV("webviewcore::nativeSetFocusControllerActive()\n"); + LOGV("webviewcore::nativeSetFocusControllerInactive()\n"); WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); - LOG_ASSERT(viewImpl, "viewImpl not set in nativeSetFocusControllerActive"); - viewImpl->setFocusControllerActive(active); + LOG_ASSERT(viewImpl, "viewImpl not set in nativeSetFocusControllerInactive"); + viewImpl->setFocusControllerActive(false); } static void SaveDocumentState(JNIEnv *env, jobject obj, jint frame) @@ -2181,7 +2117,8 @@ static void SendListBoxChoices(JNIEnv* env, jobject obj, jbooleanArray jArray, viewImpl->popupReply(array, count); } -static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr) +static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr, + jboolean caseInsensitive) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); @@ -2194,7 +2131,7 @@ static jstring FindAddress(JNIEnv *env, jobject obj, jstring addr) const jchar* addrChars = env->GetStringChars(addr, 0); int start, end; bool success = CacheBuilder::FindAddress(addrChars, length, - &start, &end) == CacheBuilder::FOUND_COMPLETE; + &start, &end, caseInsensitive) == CacheBuilder::FOUND_COMPLETE; jstring ret = 0; if (success) { ret = env->NewString((jchar*) addrChars + start, end - start); @@ -2241,7 +2178,7 @@ static jstring RetrieveHref(JNIEnv *env, jobject obj, jint frame, return 0; } -static void MoveMouse(JNIEnv *env, jobject obj, jint frame, jint node, +static void MoveMouse(JNIEnv *env, jobject obj, jint frame, jint x, jint y) { #ifdef ANDROID_INSTRUMENT @@ -2249,13 +2186,11 @@ static void MoveMouse(JNIEnv *env, jobject obj, jint frame, jint node, #endif WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__); - viewImpl->moveMouse((WebCore::Frame*) frame, (WebCore::Node*) node, x, - y); + viewImpl->moveMouse((WebCore::Frame*) frame, x, y); } static void MoveMouseIfLatest(JNIEnv *env, jobject obj, jint moveGeneration, - jint frame, jint node, jint x, jint y, - jboolean ignoreNullFocus) + jint frame, jint x, jint y) { #ifdef ANDROID_INSTRUMENT TimeCounterAuto counter(TimeCounter::WebViewCoreTimeCounter); @@ -2263,8 +2198,7 @@ static void MoveMouseIfLatest(JNIEnv *env, jobject obj, jint moveGeneration, WebViewCore* viewImpl = GET_NATIVE_VIEW(env, obj); LOG_ASSERT(viewImpl, "viewImpl not set in %s", __FUNCTION__); viewImpl->moveMouseIfLatest(moveGeneration, - (WebCore::Frame*) frame, (WebCore::Node*) node, x, y, - ignoreNullFocus); + (WebCore::Frame*) frame, x, y); } static void UpdateFrameCache(JNIEnv *env, jobject obj) @@ -2494,7 +2428,7 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) SendListBoxChoice }, { "nativeSetSize", "(IIIFII)V", (void*) SetSize }, - { "nativeSetScrollOffset", "(II)V", + { "nativeSetScrollOffset", "(III)V", (void*) SetScrollOffset }, { "nativeSetGlobalBounds", "(IIII)V", (void*) SetGlobalBounds }, @@ -2504,17 +2438,17 @@ static JNINativeMethod gJavaWebViewCoreMethods[] = { (void*) DeleteSelection } , { "nativeReplaceTextfieldText", "(IILjava/lang/String;II)V", (void*) ReplaceTextfieldText } , - { "nativeMoveMouse", "(IIII)V", + { "nativeMoveMouse", "(III)V", (void*) MoveMouse }, - { "nativeMoveMouseIfLatest", "(IIIIIZ)V", + { "nativeMoveMouseIfLatest", "(IIII)V", (void*) MoveMouseIfLatest }, { "passToJs", "(ILjava/lang/String;IIZZZZ)V", (void*) PassToJs } , - { "nativeSetFocusControllerActive", "(Z)V", - (void*) SetFocusControllerActive }, + { "nativeSetFocusControllerInactive", "()V", + (void*) SetFocusControllerInactive }, { "nativeSaveDocumentState", "(I)V", (void*) SaveDocumentState }, - { "nativeFindAddress", "(Ljava/lang/String;)Ljava/lang/String;", + { "nativeFindAddress", "(Ljava/lang/String;Z)Ljava/lang/String;", (void*) FindAddress }, { "nativeHandleTouchEvent", "(III)Z", (void*) HandleTouchEvent }, diff --git a/WebKit/android/jni/WebViewCore.h b/WebKit/android/jni/WebViewCore.h index 7231941..4ba0074 100644 --- a/WebKit/android/jni/WebViewCore.h +++ b/WebKit/android/jni/WebViewCore.h @@ -195,14 +195,12 @@ namespace android { // Create a set of pictures to represent the drawn DOM, driven by // the invalidated region and the time required to draw (used to draw) void recordPictureSet(PictureSet* master); - bool moveMouse(WebCore::Frame* frame, WebCore::Node* node, - int x, int y); + void moveMouse(WebCore::Frame* frame, int x, int y); void moveMouseIfLatest(int moveGeneration, - WebCore::Frame* frame, WebCore::Node* node, int x, int y, - bool ignoreNullFocus); + WebCore::Frame* frame, int x, int y); // set the scroll amount that webview.java is currently showing - void setScrollOffset(int dx, int dy); + void setScrollOffset(int moveGeneration, int dx, int dy); void setGlobalBounds(int x, int y, int h, int v); @@ -327,10 +325,11 @@ namespace android { int m_touchGeneration; // copy of state in WebViewNative triggered by touch int m_lastGeneration; // last action using up to date cache bool m_updatedFrameCache; - bool m_useReplay; bool m_findIsUp; bool m_hasCursorBounds; WebCore::IntRect m_cursorBounds; + void* m_cursorFrame; + IntPoint m_cursorLocation; void* m_cursorNode; static Mutex gCursorBoundsMutex; // These two fields go together: we use the mutex to protect access to @@ -396,17 +395,11 @@ namespace android { this->drawPlugins(); } - WebCore::Frame* changedKitFocus(WebCore::Frame* frame, - WebCore::Node* node, int x, int y); void doMaxScroll(CacheBuilder::Direction dir); SkPicture* rebuildPicture(const SkIRect& inval); void rebuildPictureSet(PictureSet* ); - void sendMarkNodeInvalid(WebCore::Node* ); void sendNotifyProgressFinished(); - void sendRecomputeFocus(); bool handleMouseClick(WebCore::Frame* framePtr, WebCore::Node* nodePtr); - bool prepareFrameCache(); - void releaseFrameCache(bool newCache); #if DEBUG_NAV_UI uint32_t m_now; #endif |