diff options
Diffstat (limited to 'WebKit/android/nav')
-rw-r--r-- | WebKit/android/nav/WebView.cpp | 161 |
1 files changed, 36 insertions, 125 deletions
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 8fff1b9..4b32516 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -98,7 +98,6 @@ struct JavaGlue { jobject m_obj; jmethodID m_clearTextEntry; jmethodID m_overrideLoading; - jmethodID m_sendPluginState; jmethodID m_scrollBy; jmethodID m_sendMoveMouse; jmethodID m_sendMoveMouseIfLatest; @@ -128,7 +127,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) m_javaGlue.m_scrollBy = GetJMethod(env, clazz, "setContentScrollBy", "(IIZ)Z"); m_javaGlue.m_clearTextEntry = GetJMethod(env, clazz, "clearTextEntry", "()V"); m_javaGlue.m_overrideLoading = GetJMethod(env, clazz, "overrideLoading", "(Ljava/lang/String;)V"); - m_javaGlue.m_sendPluginState = GetJMethod(env, clazz, "sendPluginState", "(I)V"); m_javaGlue.m_sendMoveMouse = GetJMethod(env, clazz, "sendMoveMouse", "(IIII)V"); m_javaGlue.m_sendMoveMouseIfLatest = GetJMethod(env, clazz, "sendMoveMouseIfLatest", "(Z)V"); m_javaGlue.m_sendMotionUp = GetJMethod(env, clazz, "sendMotionUp", "(IIIII)V"); @@ -163,10 +161,6 @@ WebView(JNIEnv* env, jobject javaWebView, int viewImpl) m_matches = 0; m_hasCurrentLocation = false; m_isFindPaintSetUp = false; - m_pluginReceivesEvents = false; // initialization is the only time this - // variable should be set directly, all - // other changes should be made through - // setPluginReceivesEvents(bool) } ~WebView() @@ -483,10 +477,9 @@ void drawCursorRing(SkCanvas* canvas) " bounds=(%d,%d,w=%d,h=%d)", node->index(), node->nodePointer(), bounds.x(), bounds.y(), bounds.width(), bounds.height()); m_followedLink = false; - setPluginReceivesEvents(false); return; } - if (!node->hasCursorRing() || (m_pluginReceivesEvents && node->isPlugin())) + if (!node->hasCursorRing() || (node->isPlugin() && node->isFocus())) return; CursorRing::Flavor flavor = CursorRing::NORMAL_FLAVOR; if (!isButton) { @@ -499,13 +492,12 @@ void drawCursorRing(SkCanvas* canvas) #if DEBUG_NAV_UI const WebCore::IntRect& ring = (*rings)[0]; DBG_NAV_LOGD("cursorNode=%d (nodePointer=%p) flavor=%s rings=%d" - " (%d, %d, %d, %d) pluginReceivesEvents=%s isPlugin=%s", + " (%d, %d, %d, %d) isPlugin=%s", node->index(), node->nodePointer(), flavor == CursorRing::FAKE_FLAVOR ? "FAKE_FLAVOR" : flavor == CursorRing::NORMAL_ANIMATING ? "NORMAL_ANIMATING" : flavor == CursorRing::FAKE_ANIMATING ? "FAKE_ANIMATING" : "NORMAL_FLAVOR", rings->size(), ring.x(), ring.y(), ring.width(), ring.height(), - m_pluginReceivesEvents ? "true" : "false", node->isPlugin() ? "true" : "false"); #endif } @@ -756,7 +748,6 @@ void updateCursorBounds(const CachedRoot* root, const CachedFrame* cachedFrame, /* returns true if the key had no effect (neither scrolled nor changed cursor) */ bool moveCursor(int keyCode, int count, bool ignoreScroll) { - setPluginReceivesEvents(false); CachedRoot* root = getFrameCache(AllowNewer); if (!root) { DBG_NAV_LOG("!root"); @@ -841,21 +832,6 @@ bool moveCursor(int keyCode, int count, bool ignoreScroll) return result; } -bool pluginEatsNavKey() -{ - CachedRoot* root = getFrameCache(DontAllowNewer); - if (!root) { - DBG_NAV_LOG("!root"); - return false; - } - const CachedNode* cursor = root->currentCursor(); - DBG_NAV_LOGD("cursor=%p isPlugin=%s pluginReceivesEvents=%s", - cursor, cursor && cursor->isPlugin() ? "true" : "false", - m_pluginReceivesEvents ? "true" : "false"); - // FIXME: check to see if plugin wants keys - return cursor && cursor->isPlugin() && m_pluginReceivesEvents; -} - void notifyProgressFinished() { DBG_NAV_LOGD("cursorIsTextInput=%d", cursorIsTextInput(DontAllowNewer)); @@ -975,7 +951,6 @@ bool motionUp(int x, int y, int slop) 0, x, y); viewInvalidate(); clearTextEntry(); - setPluginReceivesEvents(false); return pageScrolled; } DBG_NAV_LOGD("CachedNode:%p (%d) x=%d y=%d rx=%d ry=%d", result, @@ -984,7 +959,6 @@ bool motionUp(int x, int y, int slop) updateCursorBounds(root, frame, result); root->setCursor(const_cast<CachedFrame*>(frame), const_cast<CachedNode*>(result)); - updatePluginReceivesEvents(); CachedNodeType type = result->type(); if (type == NORMAL_CACHEDNODETYPE) { sendMotionUp( @@ -1034,35 +1008,6 @@ void setFindIsUp(bool up) m_hasCurrentLocation = false; } -void setPluginReceivesEvents(bool value) -{ - if (value == m_pluginReceivesEvents) - return; - - //send message to plugin in webkit - JNIEnv* env = JSC::Bindings::getJNIEnv(); - AutoJObject obj = m_javaGlue.object(env); - // if it is called during or after DESTROY is handled, the real object of - // WebView can be gone. Check before using it. - if (!obj.get()) - return; - env->CallVoidMethod(obj.get(), m_javaGlue.m_sendPluginState, - value ? kGainFocus_PluginState : kLoseFocus_PluginState); - checkException(env); - m_pluginReceivesEvents = value; -} - -void updatePluginReceivesEvents() -{ - CachedRoot* root = getFrameCache(DontAllowNewer); - if (!root) - return; - const CachedNode* cursor = root->currentCursor(); - setPluginReceivesEvents(cursor && cursor->isPlugin()); - DBG_NAV_LOGD("m_pluginReceivesEvents=%s cursor=%p", m_pluginReceivesEvents - ? "true" : "false", cursor); -} - void setFollowedLink(bool followed) { if ((m_followedLink = followed) != false) { @@ -1104,17 +1049,6 @@ const SkRegion& getSelection() return m_selRegion; } -void drawSelection(SkCanvas* canvas, float scale, int offset, int x, int y, - bool extendSelection) -{ - if (!extendSelection) { - drawSelectionArrow(canvas, scale, x, y - offset); - } else { - drawSelectionRegion(canvas); - drawSelectionPointer(canvas, scale, offset, x, y, false); - } -} - void drawSelectionRegion(SkCanvas* canvas) { CachedRoot* root = getFrameCache(DontAllowNewer); @@ -1134,46 +1068,31 @@ void drawSelectionRegion(SkCanvas* canvas) canvas->drawPath(path, paint); } -void drawSelectionPointer(SkCanvas* canvas, float scale, int offset, - int x, int y, bool gridded) +void drawSelectionPointer(SkCanvas* canvas, float scale, int x, int y, bool ex) { SkPath path; - getSelectionCaret(&path); + if (ex) + getSelectionCaret(&path); + else + getSelectionArrow(&path); SkPaint paint; paint.setAntiAlias(true); paint.setStyle(SkPaint::kStroke_Style); paint.setColor(SK_ColorBLACK); SkPixelXorXfermode xorMode(SK_ColorWHITE); - paint.setXfermode(&xorMode); - int sc = canvas->save(); - canvas->scale(scale, scale); - canvas->translate(0, -SkIntToScalar(offset)); - if (gridded) { - bool useLeft = x <= (m_selStart.fLeft + m_selStart.fRight) >> 1; - canvas->translate(SkIntToScalar(useLeft ? m_selStart.fLeft : - m_selStart.fRight), SkIntToScalar(m_selStart.fTop)); - } else - canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); - canvas->drawPath(path, paint); - canvas->restoreToCount(sc); -} - -void drawSelectionArrow(SkCanvas* canvas, float scale, int x, int y) -{ - SkPath path; - getSelectionArrow(&path); - SkPaint paint; - paint.setAntiAlias(true); - paint.setStyle(SkPaint::kStroke_Style); - paint.setColor(SK_ColorBLACK); - paint.setStrokeWidth(SK_Scalar1 * 2); + if (ex) + paint.setXfermode(&xorMode); + else + paint.setStrokeWidth(SK_Scalar1 * 2); int sc = canvas->save(); canvas->scale(scale, scale); canvas->translate(SkIntToScalar(x), SkIntToScalar(y)); canvas->drawPath(path, paint); - paint.setStyle(SkPaint::kFill_Style); - paint.setColor(SK_ColorWHITE); - canvas->drawPath(path, paint); + if (!ex) { + paint.setStyle(SkPaint::kFill_Style); + paint.setColor(SK_ColorWHITE); + canvas->drawPath(path, paint); + } canvas->restoreToCount(sc); } @@ -1191,14 +1110,13 @@ void getSelectionCaret(SkPath* path) { SkScalar height = SkIntToScalar(m_selStart.fBottom - m_selStart.fTop); SkScalar dist = height / 4; - path->lineTo(0, height); - SkScalar bottom = height + dist; - path->lineTo(-dist, bottom); - SkScalar edge = bottom - SK_Scalar1/2; - path->moveTo(-dist, edge); - path->lineTo(dist, edge); - path->moveTo(dist, bottom); - path->lineTo(0, height); + path->moveTo(0, -height / 2); + path->rLineTo(0, height); + path->rLineTo(-dist, dist); + path->rMoveTo(0, -SK_Scalar1/2); + path->rLineTo(dist * 2, 0); + path->rMoveTo(0, SK_Scalar1/2); + path->rLineTo(-dist, -dist); } void sendMoveMouse(WebCore::Frame* framePtr, WebCore::Node* nodePtr, int x, int y) @@ -1423,7 +1341,6 @@ private: // local state for WebView int m_generation; // associate unique ID with sent kit focus to match with ui SkPicture* m_navPictureUI; bool m_followedLink; - bool m_pluginReceivesEvents; SkMSec m_ringAnimationEnd; // Corresponds to the same-named boolean on the java side. bool m_heightCanMeasure; @@ -1626,8 +1543,8 @@ static void nativeDrawCursorRing(JNIEnv *env, jobject obj, jobject canv) view->drawCursorRing(canvas); } -static void nativeDrawSelection(JNIEnv *env, jobject obj, - jobject canv, jfloat scale, jint offset, jint x, jint y, bool ex) +static void nativeDrawSelectionPointer(JNIEnv *env, jobject obj, + jobject canv, jfloat scale, jint x, jint y, bool ex) { SkCanvas* canvas = GraphicsJNI::getNativeCanvas(env, canv); if (!canv) { @@ -1639,7 +1556,7 @@ static void nativeDrawSelection(JNIEnv *env, jobject obj, DBG_NAV_LOG("!view"); return; } - view->drawSelection(canvas, scale, offset, x, y, ex); + view->drawSelectionPointer(canvas, scale, x, y, ex); } static void nativeDrawSelectionRegion(JNIEnv *env, jobject obj, jobject canv) @@ -1763,6 +1680,12 @@ static bool nativeFocusCandidateIsPlugin(JNIEnv *env, jobject obj) return node ? node->isPlugin() : false; } +static bool nativeFocusIsPlugin(JNIEnv *env, jobject obj) +{ + const CachedNode* node = getFocusNode(env, obj); + return node ? node->isPlugin() : false; +} + static jint nativeFocusNodePointer(JNIEnv *env, jobject obj) { const CachedNode* node = getFocusNode(env, obj); @@ -1852,11 +1775,6 @@ static void nativeSetFindIsDown(JNIEnv *env, jobject obj) view->setFindIsUp(false); } -static void nativeUpdatePluginReceivesEvents(JNIEnv *env, jobject obj) -{ - GET_NATIVE_VIEW(env, obj)->updatePluginReceivesEvents(); -} - static void nativeSetFollowedLink(JNIEnv *env, jobject obj, bool followed) { WebView* view = GET_NATIVE_VIEW(env, obj); @@ -2035,11 +1953,6 @@ static void nativeMoveSelection(JNIEnv *env, jobject obj, int x, int y, bool ex) view->moveSelection(x, y, ex); } -static bool nativePluginEatsNavKey(JNIEnv *env, jobject obj) -{ - return GET_NATIVE_VIEW(env, obj)->pluginEatsNavKey(); -} - static jobject nativeGetSelection(JNIEnv *env, jobject obj) { WebView* view = GET_NATIVE_VIEW(env, obj); @@ -2122,8 +2035,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeDrawCursorRing }, { "nativeDrawMatches", "(Landroid/graphics/Canvas;)V", (void*) nativeDrawMatches }, - { "nativeDrawSelection", "(Landroid/graphics/Canvas;FIIIZ)V", - (void*) nativeDrawSelection }, + { "nativeDrawSelectionPointer", "(Landroid/graphics/Canvas;FIIZ)V", + (void*) nativeDrawSelectionPointer }, { "nativeDrawSelectionRegion", "(Landroid/graphics/Canvas;)V", (void*) nativeDrawSelectionRegion }, { "nativeDumpDisplayTree", "(Ljava/lang/String;)V", @@ -2156,6 +2069,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeFocusCandidateText }, { "nativeFocusCandidateTextSize", "()I", (void*) nativeFocusCandidateTextSize }, + { "nativeFocusIsPlugin", "()Z", + (void*) nativeFocusIsPlugin }, { "nativeFocusNodePointer", "()I", (void*) nativeFocusNodePointer }, { "nativeGetCursorRingBounds", "()Landroid/graphics/Rect;", @@ -2184,8 +2099,6 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeMoveGeneration }, { "nativeMoveSelection", "(IIZ)V", (void*) nativeMoveSelection }, - { "nativePluginEatsNavKey", "()Z", - (void*) nativePluginEatsNavKey }, { "nativeRecordButtons", "(ZZZ)V", (void*) nativeRecordButtons }, { "nativeSelectBestAt", "(Landroid/graphics/Rect;)V", @@ -2204,8 +2117,6 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeUpdateCachedTextfield }, { "nativeGetBlockLeftEdge", "(IIF)I", (void*) nativeGetBlockLeftEdge }, - { "nativeUpdatePluginReceivesEvents", "()V", - (void*) nativeUpdatePluginReceivesEvents } }; int register_webview(JNIEnv* env) |