diff options
| author | Leon Scroggins <scroggo@google.com> | 2010-10-19 13:16:11 -0400 |
|---|---|---|
| committer | Leon Scroggins <scroggo@google.com> | 2010-10-19 15:56:37 -0400 |
| commit | db17cf1782eab2488aab0933add6c79b21639c08 (patch) | |
| tree | b8b9623630b9dbbe387cd7fa4efcabf4dddd38a0 /WebKit | |
| parent | 088d95174762e601cfe419066c10342fcb4d1475 (diff) | |
| download | external_webkit-db17cf1782eab2488aab0933add6c79b21639c08.zip external_webkit-db17cf1782eab2488aab0933add6c79b21639c08.tar.gz external_webkit-db17cf1782eab2488aab0933add6c79b21639c08.tar.bz2 | |
Fix for Find scrolling too often.
Bug:3108852
Do not scroll if nativeFindAll is called with the same string
and the current match location has not changed.
Requires a change to frameworks/base.
Change-Id: Id3f104d91a0061f1d007b54a8fdd188b239e7970
Diffstat (limited to 'WebKit')
| -rw-r--r-- | WebKit/android/nav/FindCanvas.h | 1 | ||||
| -rw-r--r-- | WebKit/android/nav/WebView.cpp | 30 |
2 files changed, 24 insertions, 7 deletions
diff --git a/WebKit/android/nav/FindCanvas.h b/WebKit/android/nav/FindCanvas.h index 34929ec..903279c 100644 --- a/WebKit/android/nav/FindCanvas.h +++ b/WebKit/android/nav/FindCanvas.h @@ -224,6 +224,7 @@ public: bool currentMatchIsInLayer() const; virtual void draw(SkCanvas* , LayerAndroid* ); void findNext(bool forward); + bool isCurrentLocationValid() { return m_hasCurrentLocation; } void setMatches(WTF::Vector<MatchInfo>* matches); private: void drawMatch(const SkRegion& region, SkCanvas* canvas, bool focused); diff --git a/WebKit/android/nav/WebView.cpp b/WebKit/android/nav/WebView.cpp index f422130..a9e5e10 100644 --- a/WebKit/android/nav/WebView.cpp +++ b/WebKit/android/nav/WebView.cpp @@ -1144,11 +1144,27 @@ void findNext(bool forward) // With this call, WebView takes ownership of matches, and is responsible for // deleting it. -void setMatches(WTF::Vector<MatchInfo>* matches) -{ +void setMatches(WTF::Vector<MatchInfo>* matches, jboolean sameAsLastSearch) +{ + // If this search is the same as the last one, check against the old + // location to determine whether to scroll. If the same word is found + // in the same place, then do not scroll. + IntRect oldLocation; + bool checkAgainstOldLocation; + if (sameAsLastSearch && m_findOnPage.isCurrentLocationValid()) { + oldLocation = m_findOnPage.currentMatchBounds(); + checkAgainstOldLocation = true; + } else + checkAgainstOldLocation = false; + m_findOnPage.setMatches(matches); - if (!m_findOnPage.currentMatchIsInLayer()) - scrollRectOnScreen(m_findOnPage.currentMatchBounds()); + + if (!checkAgainstOldLocation + || oldLocation != m_findOnPage.currentMatchBounds()) { + // FIXME: Need to scroll if the match is in a layer. + if (!m_findOnPage.currentMatchIsInLayer()) + scrollRectOnScreen(m_findOnPage.currentMatchBounds()); + } viewInvalidate(); } @@ -1900,7 +1916,7 @@ static jobject nativeGetCursorRingBounds(JNIEnv *env, jobject obj) } static int nativeFindAll(JNIEnv *env, jobject obj, jstring findLower, - jstring findUpper) + jstring findUpper, jboolean sameAsLastSearch) { // If one or the other is null, do not search. if (!(findLower && findUpper)) @@ -1948,7 +1964,7 @@ static int nativeFindAll(JNIEnv *env, jobject obj, jstring findLower, root->draw(canvas); WTF::Vector<MatchInfo>* matches = canvas.detachMatches(); // With setMatches, the WebView takes ownership of matches - view->setMatches(matches); + view->setMatches(matches, sameAsLastSearch); env->ReleaseStringChars(findLower, findLowerChars); env->ReleaseStringChars(findUpper, findUpperChars); @@ -2254,7 +2270,7 @@ static JNINativeMethod gJavaWebViewMethods[] = { (void*) nativeEvaluateLayersAnimations }, { "nativeExtendSelection", "(II)V", (void*) nativeExtendSelection }, - { "nativeFindAll", "(Ljava/lang/String;Ljava/lang/String;)I", + { "nativeFindAll", "(Ljava/lang/String;Ljava/lang/String;Z)I", (void*) nativeFindAll }, { "nativeFindNext", "(Z)V", (void*) nativeFindNext }, |
