diff options
Diffstat (limited to 'WebKit/android/nav/WebView.cpp')
| -rw-r--r-- | WebKit/android/nav/WebView.cpp | 169 |
1 files changed, 146 insertions, 23 deletions
diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index 2ed6148..3dafaff 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -946,7 +946,7 @@ String getSelection() return m_selectText.getSelection(); } -void moveSelection(int x, int y, bool extendSelection) +void moveSelection(int x, int y) { const CachedRoot* root = getFrameCache(DontAllowNewer); if (!root) @@ -957,26 +957,81 @@ void moveSelection(int x, int y, bool extendSelection) IntRect visibleRect; getVisibleRect(&visibleRect); m_selectText.setVisibleRect(visibleRect); - m_selectText.moveSelection(picture, x, y, extendSelection); + m_selectText.moveSelection(picture, x, y); } -void setSelectionPointer(bool set, float scale, int x, int y, - bool extendSelection) +void selectAll() +{ + const CachedRoot* root = getFrameCache(DontAllowNewer); + if (!root) + return; + SkPicture* picture = root->pictureAt(0, 0); + m_selectText.selectAll(picture); +} + +int selectionX() +{ + return m_selectText.selectionX(); +} + +int selectionY() +{ + return m_selectText.selectionY(); +} + +void resetSelection() +{ + m_selectText.reset(); +} + +bool startSelection(int x, int y) +{ + return m_selectText.startSelection(x, y); +} + +bool wordSelection(int x, int y) +{ + startSelection(x, y); + if (!extendSelection(x, y)) + return false; + m_selectText.setDrawPointer(false); + SkPicture* picture = getFrameCache(DontAllowNewer)->pictureAt(x, y); + return m_selectText.wordSelection(picture); +} + +bool extendSelection(int x, int y) +{ + const CachedRoot* root = getFrameCache(DontAllowNewer); + if (!root) + return false; + SkPicture* picture = root->pictureAt(x, y); + IntRect visibleRect; + getVisibleRect(&visibleRect); + m_selectText.setVisibleRect(visibleRect); + m_selectText.extendSelection(picture, x, y); + return true; +} + +bool hitSelection(int x, int y) +{ + return m_selectText.hitSelection(x, y); +} + +void setExtendSelection() +{ + m_selectText.setExtendSelection(true); +} + +void setSelectionPointer(bool set, float scale, int x, int y) { m_selectText.setDrawPointer(set); if (!set) return; - m_selectText.m_extendSelection = extendSelection; m_selectText.m_inverseScale = scale; m_selectText.m_selectX = x; m_selectText.m_selectY = y; } -void setSelectionRegion(bool set) -{ - m_selectText.setDrawRegion(set); -} - void sendMoveFocus(WebCore::Frame* framePtr, WebCore::Node* nodePtr) { DBG_NAV_LOGD("framePtr=%p nodePtr=%p", framePtr, nodePtr); @@ -1035,6 +1090,11 @@ void setMatches(WTF::Vector<MatchInfo>* matches) viewInvalidate(); } +int currentMatchIndex() +{ + return m_findOnPage.currentMatchIndex(); +} + bool scrollBy(int dx, int dy) { LOG_ASSERT(m_javaGlue.m_obj, "A java object was not associated with this native WebView!"); @@ -1735,6 +1795,13 @@ static void nativeFindNext(JNIEnv *env, jobject obj, bool forward) view->findNext(forward); } +static int nativeFindIndex(JNIEnv *env, jobject obj) +{ + WebView* view = GET_NATIVE_VIEW(env, obj); + LOG_ASSERT(view, "view not set in nativeFindIndex"); + return view->currentMatchIndex(); +} + static void nativeUpdateCachedTextfield(JNIEnv *env, jobject obj, jstring updatedText, jint generation) { WebView* view = GET_NATIVE_VIEW(env, obj); @@ -1805,11 +1872,39 @@ static int nativeMoveGeneration(JNIEnv *env, jobject obj) return view->moveGeneration(); } -static void nativeMoveSelection(JNIEnv *env, jobject obj, int x, int y, bool ex) +static void nativeMoveSelection(JNIEnv *env, jobject obj, int x, int y) { - WebView* view = GET_NATIVE_VIEW(env, obj); - LOG_ASSERT(view, "view not set in %s", __FUNCTION__); - view->moveSelection(x, y, ex); + GET_NATIVE_VIEW(env, obj)->moveSelection(x, y); +} + +static void nativeResetSelection(JNIEnv *env, jobject obj) +{ + return GET_NATIVE_VIEW(env, obj)->resetSelection(); +} + +static void nativeSelectAll(JNIEnv* env, jobject obj) +{ + GET_NATIVE_VIEW(env, obj)->selectAll(); +} + +static void nativeSetExtendSelection(JNIEnv *env, jobject obj) +{ + GET_NATIVE_VIEW(env, obj)->setExtendSelection(); +} + +static jboolean nativeStartSelection(JNIEnv *env, jobject obj, int x, int y) +{ + return GET_NATIVE_VIEW(env, obj)->startSelection(x, y); +} + +static jboolean nativeWordSelection(JNIEnv *env, jobject obj, int x, int y) +{ + return GET_NATIVE_VIEW(env, obj)->wordSelection(x, y); +} + +static void nativeExtendSelection(JNIEnv *env, jobject obj, int x, int y) +{ + GET_NATIVE_VIEW(env, obj)->extendSelection(x, y); } static jobject nativeGetSelection(JNIEnv *env, jobject obj) @@ -1820,15 +1915,25 @@ static jobject nativeGetSelection(JNIEnv *env, jobject obj) return env->NewString((jchar*)selection.characters(), selection.length()); } -static void nativeSetSelectionPointer(JNIEnv *env, jobject obj, jboolean set, - jfloat scale, jint x, jint y, bool ex) +static jboolean nativeHitSelection(JNIEnv *env, jobject obj, int x, int y) +{ + return GET_NATIVE_VIEW(env, obj)->hitSelection(x, y); +} + +static jint nativeSelectionX(JNIEnv *env, jobject obj) { - GET_NATIVE_VIEW(env, obj)->setSelectionPointer(set, scale, x, y, ex); + return GET_NATIVE_VIEW(env, obj)->selectionX(); } -static void nativeSetSelectionRegion(JNIEnv *env, jobject obj, jboolean set) +static jint nativeSelectionY(JNIEnv *env, jobject obj) +{ + return GET_NATIVE_VIEW(env, obj)->selectionY(); +} + +static void nativeSetSelectionPointer(JNIEnv *env, jobject obj, jboolean set, + jfloat scale, jint x, jint y) { - GET_NATIVE_VIEW(env, obj)->setSelectionRegion(set); + GET_NATIVE_VIEW(env, obj)->setSelectionPointer(set, scale, x, y); } #ifdef ANDROID_DUMP_DISPLAY_TREE @@ -1935,10 +2040,14 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeDumpDisplayTree }, { "nativeEvaluateLayersAnimations", "()Z", (void*) nativeEvaluateLayersAnimations }, + { "nativeExtendSelection", "(II)V", + (void*) nativeExtendSelection }, { "nativeFindAll", "(Ljava/lang/String;Ljava/lang/String;)I", (void*) nativeFindAll }, { "nativeFindNext", "(Z)V", (void*) nativeFindNext }, + { "nativeFindIndex", "()I", + (void*) nativeFindIndex}, { "nativeFocusCandidateFramePointer", "()I", (void*) nativeFocusCandidateFramePointer }, { "nativeFocusCandidateHasNextTextfield", "()Z", @@ -1979,6 +2088,8 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeHasFocusNode }, { "nativeHideCursor", "()V", (void*) nativeHideCursor }, + { "nativeHitSelection", "(II)Z", + (void*) nativeHitSelection }, { "nativeImageURI", "(II)Ljava/lang/String;", (void*) nativeImageURI }, { "nativeInstrumentReport", "()V", @@ -1991,14 +2102,24 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeMoveCursorToNextTextInput }, { "nativeMoveGeneration", "()I", (void*) nativeMoveGeneration }, - { "nativeMoveSelection", "(IIZ)V", + { "nativeMoveSelection", "(II)V", (void*) nativeMoveSelection }, { "nativePointInNavCache", "(III)Z", (void*) nativePointInNavCache }, { "nativeRecordButtons", "(ZZZ)V", (void*) nativeRecordButtons }, + { "nativeResetSelection", "()V", + (void*) nativeResetSelection }, + { "nativeSelectAll", "()V", + (void*) nativeSelectAll }, { "nativeSelectBestAt", "(Landroid/graphics/Rect;)V", (void*) nativeSelectBestAt }, + { "nativeSelectionX", "()I", + (void*) nativeSelectionX }, + { "nativeSelectionY", "()I", + (void*) nativeSelectionY }, + { "nativeSetExtendSelection", "()V", + (void*) nativeSetExtendSelection }, { "nativeSetFindIsEmpty", "()V", (void*) nativeSetFindIsEmpty }, { "nativeSetFindIsUp", "(Z)V", @@ -2009,16 +2130,18 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeSetHeightCanMeasure }, { "nativeSetRootLayer", "(I)V", (void*) nativeSetRootLayer }, - { "nativeSetSelectionPointer", "(ZFIIZ)V", + { "nativeSetSelectionPointer", "(ZFII)V", (void*) nativeSetSelectionPointer }, - { "nativeSetSelectionRegion", "(Z)V", - (void*) nativeSetSelectionRegion }, + { "nativeStartSelection", "(II)Z", + (void*) nativeStartSelection }, { "nativeSubtractLayers", "(Landroid/graphics/Rect;)Landroid/graphics/Rect;", (void*) nativeSubtractLayers }, { "nativeTextGeneration", "()I", (void*) nativeTextGeneration }, { "nativeUpdateCachedTextfield", "(Ljava/lang/String;I)V", (void*) nativeUpdateCachedTextfield }, + { "nativeWordSelection", "(II)Z", + (void*) nativeWordSelection }, { "nativeGetBlockLeftEdge", "(IIF)I", (void*) nativeGetBlockLeftEdge }, }; |
