diff options
-rw-r--r-- | WebKit/android/jni/WebViewCore.cpp | 2 | ||||
-rw-r--r-- | WebKit/android/nav/CachedDebug.h | 21 | ||||
-rw-r--r-- | WebKit/android/nav/CachedFrame.cpp | 4 | ||||
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 36 | ||||
-rw-r--r-- | WebKit/android/plugins/PluginWidgetAndroid.cpp | 56 |
5 files changed, 84 insertions, 35 deletions
diff --git a/WebKit/android/jni/WebViewCore.cpp b/WebKit/android/jni/WebViewCore.cpp index ac3bcc4..2340f99 100644 --- a/WebKit/android/jni/WebViewCore.cpp +++ b/WebKit/android/jni/WebViewCore.cpp @@ -972,7 +972,7 @@ void WebViewCore::needTouchEvents(bool need) void WebViewCore::requestKeyboard(bool showKeyboard) { - DEBUG_NAV_UI_LOGD("%s", __FUNCTION__); + DBG_NAV_LOGD("showKeyboard=%d", showKeyboard); LOG_ASSERT(m_javaGlue->m_obj, "A Java widget was not associated with this view bridge!"); JNIEnv* env = JSC::Bindings::getJNIEnv(); diff --git a/WebKit/android/nav/CachedDebug.h b/WebKit/android/nav/CachedDebug.h index 3127112..2947f3d 100644 --- a/WebKit/android/nav/CachedDebug.h +++ b/WebKit/android/nav/CachedDebug.h @@ -26,21 +26,9 @@ #ifndef CachedDebug_H #define CachedDebug_H -#ifndef DUMP_NAV_CACHE -#ifdef NDEBUG #define DUMP_NAV_CACHE 0 -#else -#define DUMP_NAV_CACHE 1 -#endif -#endif - -#ifndef DEBUG_NAV_UI -#ifdef NDEBUG #define DEBUG_NAV_UI 0 -#else -#define DEBUG_NAV_UI 1 -#endif -#endif +#define DEBUG_NAV_UI_VERBOSE 0 #if DEBUG_NAV_UI #define DBG_NAV_LOG(message) LOGD("%s %s", __FUNCTION__, message) @@ -49,10 +37,15 @@ #else #define DBG_NAV_LOG(message) ((void)0) #define DBG_NAV_LOGD(format, ...) ((void)0) -#define DBG_NAV_LOGD_THROTTLE(format, ...) ((void)0) #define DEBUG_NAV_UI_LOGD(...) ((void)0) #endif +#if DEBUG_NAV_UI_VERBOSE +#define DBG_NAV_LOGV(format, ...) LOGD("%s " format, __FUNCTION__, __VA_ARGS__) +#else +#define DBG_NAV_LOGV(format, ...) ((void)0) +#endif + #if DUMP_NAV_CACHE != 0 && !defined DUMP_NAV_CACHE_USING_PRINTF && defined NDEBUG #define DUMP_NAV_CACHE_USING_PRINTF #endif diff --git a/WebKit/android/nav/CachedFrame.cpp b/WebKit/android/nav/CachedFrame.cpp index 955a439..27f724d 100644 --- a/WebKit/android/nav/CachedFrame.cpp +++ b/WebKit/android/nav/CachedFrame.cpp @@ -402,7 +402,7 @@ const CachedNode* CachedFrame::findBestAt(const WebCore::IntRect& rect, int dx = testCenter.x() - center.x(); int dy = testCenter.y() - center.y(); int distance = dx * dx + dy * dy; - if ((!*inside && testInside) || *best > distance) { + if ((!*inside && testInside) || *best >= distance) { *best = distance; *inside = testInside; result = test; @@ -465,7 +465,7 @@ const CachedNode* CachedFrame::findBestHitAt(const WebCore::IntRect& rect, int dx = testCenter.x() - center.x(); int dy = testCenter.y() - center.y(); int distance = dx * dx + dy * dy; - if (*best <= distance) + if (*best < distance) continue; *best = distance; result = test; diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index cc11746..37342d2 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -419,7 +419,6 @@ void drawMatches(SkCanvas* canvas) void resetCursorRing() { m_followedLink = false; - setPluginReceivesEvents(false); m_viewImpl->m_hasCursorBounds = false; } @@ -434,7 +433,7 @@ void drawCursorRing(SkCanvas* canvas) const CachedFrame* frame; const CachedNode* node = root->currentCursor(&frame); if (!node) { - DBG_NAV_LOG("!node"); + DBG_NAV_LOGV("%s", "!node"); resetCursorRing(); return; } @@ -609,7 +608,7 @@ void fixCursor() CachedRoot* getFrameCache(FrameCachePermission allowNewer) { if (!m_viewImpl->m_updatedFrameCache) { - DBG_NAV_LOG("!m_viewImpl->m_updatedFrameCache"); + DBG_NAV_LOGV("%s", "!m_viewImpl->m_updatedFrameCache"); return m_frameCacheUI; } if (allowNewer == DontAllowNewer && m_viewImpl->m_lastGeneration < m_generation) { @@ -1568,12 +1567,6 @@ static bool nativeCursorIsAnchor(JNIEnv *env, jobject obj) return node ? node->isAnchor() : false; } -static bool nativeCursorIsPlugin(JNIEnv *env, jobject obj) -{ - const CachedNode* node = getCursorNode(env, obj); - return node ? node->isPlugin() : false; -} - static bool nativeCursorIsTextInput(JNIEnv *env, jobject obj) { const CachedNode* node = getCursorNode(env, obj); @@ -1674,6 +1667,19 @@ static jobject nativeImageURI(JNIEnv *env, jobject obj, jint x, jint y) return ret; } +static jint nativeFocusCandidateFramePointer(JNIEnv *env, jobject obj) +{ + WebView* view = GET_NATIVE_VIEW(env, obj); + CachedRoot* root = view->getFrameCache(WebView::DontAllowNewer); + if (!root) + return 0; + const CachedFrame* frame = 0; + const CachedNode* cursor = root->currentCursor(&frame); + if (!cursor || !cursor->wantsKeyEvents()) + (void) root->currentFocus(&frame); + return reinterpret_cast<int>(frame ? frame->framePointer() : 0); +} + static bool nativeFocusCandidateIsPassword(JNIEnv *env, jobject obj) { const CachedNode* node = getFocusCandidate(env, obj); @@ -1747,6 +1753,12 @@ static jint nativeFocusCandidateTextSize(JNIEnv *env, jobject obj) return node ? node->textSize() : 0; } +static bool nativeFocusCandidateIsPlugin(JNIEnv *env, jobject obj) +{ + const CachedNode* node = getFocusCandidate(env, obj); + return node ? node->isPlugin() : false; +} + static jint nativeFocusNodePointer(JNIEnv *env, jobject obj) { const CachedNode* node = getFocusNode(env, obj); @@ -2088,8 +2100,6 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeCursorIntersects }, { "nativeCursorIsAnchor", "()Z", (void*) nativeCursorIsAnchor }, - { "nativeCursorIsPlugin", "()Z", - (void*) nativeCursorIsPlugin }, { "nativeCursorIsTextInput", "()Z", (void*) nativeCursorIsTextInput }, { "nativeCursorPosition", "()Landroid/graphics/Point;", @@ -2116,8 +2126,12 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeFindAll }, { "nativeFindNext", "(Z)V", (void*) nativeFindNext }, + { "nativeFocusCandidateFramePointer", "()I", + (void*) nativeFocusCandidateFramePointer }, { "nativeFocusCandidateIsPassword", "()Z", (void*) nativeFocusCandidateIsPassword }, + { "nativeFocusCandidateIsPlugin", "()Z", + (void*) nativeFocusCandidateIsPlugin }, { "nativeFocusCandidateIsRtlText", "()Z", (void*) nativeFocusCandidateIsRtlText }, { "nativeFocusCandidateIsTextField", "()Z", diff --git a/WebKit/android/plugins/PluginWidgetAndroid.cpp b/WebKit/android/plugins/PluginWidgetAndroid.cpp index fdc4016..5b32259 100644 --- a/WebKit/android/plugins/PluginWidgetAndroid.cpp +++ b/WebKit/android/plugins/PluginWidgetAndroid.cpp @@ -37,6 +37,8 @@ #include "SkString.h" #include "WebViewCore.h" +#define DEBUG_VISIBLE_RECTS 1 // temporary debug printfs and fixes + PluginWidgetAndroid::PluginWidgetAndroid(WebCore::PluginView* view) : m_pluginView(view) { m_flipPixelRef = NULL; @@ -264,7 +266,10 @@ bool PluginWidgetAndroid::isAcceptingEvent(ANPEventFlag flag) { } void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float zoom) { - +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s (%d,%d,%d,%d)", __FUNCTION__, visibleDocRect.left, + visibleDocRect.top, visibleDocRect.right, visibleDocRect.bottom); +#endif // TODO update the bitmap size based on the zoom? (for kBitmap_ANPDrawingModel) int oldScreenW = m_visibleDocRect.width(); @@ -281,7 +286,9 @@ void PluginWidgetAndroid::setVisibleScreen(const ANPRectI& visibleDocRect, float } void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) { - +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s count=%d", __FUNCTION__, count); +#endif // ensure the count does not exceed our allocated space if (count > MAX_REQUESTED_RECTS) count = MAX_REQUESTED_RECTS; @@ -290,6 +297,24 @@ void PluginWidgetAndroid::setVisibleRects(const ANPRectI rects[], int32_t count) m_requestedVisibleRectCount = count; memcpy(m_requestedVisibleRect, rects, count * sizeof(rects[0])); +#if DEBUG_VISIBLE_RECTS // FIXME: this fixes bad data from the plugin + // take it out once plugin supplies better data + for (int index = 0; index < count; index++) { + SkDebugf("%s [%d](%d,%d,%d,%d)", __FUNCTION__, index, + m_requestedVisibleRect[index].left, + m_requestedVisibleRect[index].top, + m_requestedVisibleRect[index].right, + m_requestedVisibleRect[index].bottom); + if (m_requestedVisibleRect[index].left == + m_requestedVisibleRect[index].right) { + m_requestedVisibleRect[index].right += 1; + } + if (m_requestedVisibleRect[index].top == + m_requestedVisibleRect[index].bottom) { + m_requestedVisibleRect[index].bottom += 1; + } + } +#endif computeVisibleFrameRect(); } @@ -319,9 +344,18 @@ void PluginWidgetAndroid::computeVisibleFrameRect() { pluginRect.offset(m_pluginWindow->x, m_pluginWindow->y); // ensure the rect falls within the plugin's bounds - if (!pluginBounds.contains(pluginRect)) - continue; - + if (!pluginBounds.contains(pluginRect)) { +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s (%d,%d,%d,%d) !contain (%d,%d,%d,%d)", __FUNCTION__, + pluginBounds.fLeft, pluginBounds.fTop, + pluginBounds.fRight, pluginBounds.fBottom, + pluginRect.fLeft, pluginRect.fTop, + pluginRect.fRight, pluginRect.fBottom); + // FIXME: assume that the desired outcome is to clamp to the container + pluginRect.intersect(pluginBounds); +#endif + continue; + } // combine this new rect with the higher priority rects pluginRect.join(visibleRect); @@ -342,9 +376,14 @@ void PluginWidgetAndroid::computeVisibleFrameRect() { void PluginWidgetAndroid::scrollToVisibleFrameRect() { - if (!m_hasFocus || m_requestedFrameRect.isEmpty() || m_visibleDocRect.isEmpty()) + if (!m_hasFocus || m_requestedFrameRect.isEmpty() || m_visibleDocRect.isEmpty()) { +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s call m_hasFocus=%d m_requestedFrameRect.isEmpty()=%d" + " m_visibleDocRect.isEmpty()=%d", __FUNCTION__, m_hasFocus, + m_requestedFrameRect.isEmpty(), m_visibleDocRect.isEmpty()); +#endif return; - + } // if the entire rect is already visible then we don't need to scroll, which // requires converting the m_requestedFrameRect from frame to doc coordinates IntPoint pluginDocPoint = frameToDocumentCoords(m_requestedFrameRect.fLeft, @@ -371,6 +410,9 @@ void PluginWidgetAndroid::scrollToVisibleFrameRect() { ScrollView* scrollView = m_pluginView->parent(); android::WebViewCore* core = android::WebViewCore::getWebViewCore(scrollView); +#if DEBUG_VISIBLE_RECTS + SkDebugf("%s call scrollBy (%d,%d)", __FUNCTION__, deltaX, deltaY); +#endif core->scrollBy(deltaX, deltaY, true); } |