@@ -914,7 +914,7 @@ public void onTrimMemory(int level) {
914914 static final int REPLACE_BASE_CONTENT = 123 ;
915915 static final int FORM_DID_BLUR = 124 ;
916916 static final int RETURN_LABEL = 125 ;
917- static final int FIND_AGAIN = 126 ;
917+ static final int UPDATE_MATCH_COUNT = 126 ;
918918 static final int CENTER_FIT_RECT = 127 ;
919919 static final int REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID = 128 ;
920920 static final int SET_SCROLLBAR_MODES = 129 ;
@@ -979,7 +979,7 @@ public void onTrimMemory(int level) {
979979 "REPLACE_BASE_CONTENT" , // = 123;
980980 "FORM_DID_BLUR" , // = 124;
981981 "RETURN_LABEL" , // = 125;
982- "FIND_AGAIN " , // = 126;
982+ "UPDATE_MATCH_COUNT " , // = 126;
983983 "CENTER_FIT_RECT" , // = 127;
984984 "REQUEST_KEYBOARD_WITH_SELECTION_MSG_ID" , // = 128;
985985 "SET_SCROLLBAR_MODES" , // = 129;
@@ -1021,9 +1021,8 @@ public void onTrimMemory(int level) {
10211021
10221022 // keep these in sync with their counterparts in WebView.cpp
10231023 private static final int DRAW_EXTRAS_NONE = 0 ;
1024- private static final int DRAW_EXTRAS_FIND = 1 ;
1025- private static final int DRAW_EXTRAS_SELECTION = 2 ;
1026- private static final int DRAW_EXTRAS_CURSOR_RING = 3 ;
1024+ private static final int DRAW_EXTRAS_SELECTION = 1 ;
1025+ private static final int DRAW_EXTRAS_CURSOR_RING = 2 ;
10271026
10281027 // keep this in sync with WebCore:ScrollbarMode in WebKit
10291028 private static final int SCROLLBAR_AUTO = 0 ;
@@ -3711,7 +3710,7 @@ public WebBackForwardList copyBackForwardList() {
37113710 public void findNext (boolean forward ) {
37123711 checkThread ();
37133712 if (0 == mNativeClass ) return ; // client isn't initialized
3714- nativeFindNext ( forward );
3713+ mWebViewCore . sendMessage ( EventHub . FIND_NEXT , forward ? 1 : 0 );
37153714 }
37163715
37173716 /*
@@ -3721,13 +3720,40 @@ public void findNext(boolean forward) {
37213720 * that were found.
37223721 */
37233722 public int findAll (String find ) {
3723+ return findAllBody (find , false );
3724+ }
3725+
3726+ /**
3727+ * @hide
3728+ */
3729+ public void findAllAsync (String find ) {
3730+ findAllBody (find , true );
3731+ }
3732+
3733+ private int findAllBody (String find , boolean isAsync ) {
37243734 checkThread ();
37253735 if (0 == mNativeClass ) return 0 ; // client isn't initialized
3726- int result = find != null ? nativeFindAll (find .toLowerCase (),
3727- find .toUpperCase (), find .equalsIgnoreCase (mLastFind )) : 0 ;
3728- invalidate ();
37293736 mLastFind = find ;
3730- return result ;
3737+ mWebViewCore .removeMessages (EventHub .FIND_ALL );
3738+ WebViewCore .FindAllRequest request = new
3739+ WebViewCore .FindAllRequest (find );
3740+ if (isAsync ) {
3741+ mWebViewCore .sendMessage (EventHub .FIND_ALL , request );
3742+ return 0 ; // no need to wait for response
3743+ }
3744+ synchronized (request ) {
3745+ try {
3746+ mWebViewCore .sendMessageAtFrontOfQueue (EventHub .FIND_ALL ,
3747+ request );
3748+ while (request .mMatchCount == -1 ) {
3749+ request .wait ();
3750+ }
3751+ }
3752+ catch (InterruptedException e ) {
3753+ return 0 ;
3754+ }
3755+ }
3756+ return request .mMatchCount ;
37313757 }
37323758
37333759 /**
@@ -3763,6 +3789,7 @@ public boolean showFindDialog(String text, boolean showIme) {
37633789 }
37643790 if (text != null ) {
37653791 mFindCallback .setText (text );
3792+ mFindCallback .findAll ();
37663793 }
37673794 return true ;
37683795 }
@@ -3782,14 +3809,6 @@ private void setFindIsUp(boolean isUp) {
37823809 nativeSetFindIsUp (isUp );
37833810 }
37843811
3785- /**
3786- * Return the index of the currently highlighted match.
3787- */
3788- int findIndex () {
3789- if (0 == mNativeClass ) return -1 ;
3790- return nativeFindIndex ();
3791- }
3792-
37933812 // Used to know whether the find dialog is open. Affects whether
37943813 // or not we draw the highlights for matches.
37953814 private boolean mFindIsUp ;
@@ -3856,10 +3875,11 @@ public void clearMatches() {
38563875 checkThread ();
38573876 if (mNativeClass == 0 )
38583877 return ;
3859- nativeSetFindIsEmpty ( );
3860- invalidate ( );
3878+ mWebViewCore . removeMessages ( EventHub . FIND_ALL );
3879+ mWebViewCore . sendMessage ( EventHub . FIND_ALL , null );
38613880 }
38623881
3882+
38633883 /**
38643884 * Called when the find ActionMode ends.
38653885 */
@@ -4954,12 +4974,12 @@ && nativeEvaluateLayersAnimations(mNativeClass)) {
49544974
49554975 // decide which adornments to draw
49564976 int extras = DRAW_EXTRAS_NONE ;
4957- if (mFindIsUp ) {
4958- extras = DRAW_EXTRAS_FIND ;
4959- } else if ( mSelectingText ) {
4960- extras = DRAW_EXTRAS_SELECTION ;
4961- } else if ( drawCursorRing ) {
4962- extras = DRAW_EXTRAS_CURSOR_RING ;
4977+ if (! mFindIsUp ) {
4978+ if ( mSelectingText ) {
4979+ extras = DRAW_EXTRAS_SELECTION ;
4980+ } else if ( drawCursorRing ) {
4981+ extras = DRAW_EXTRAS_CURSOR_RING ;
4982+ }
49634983 }
49644984 if (DebugFlags .WEB_VIEW ) {
49654985 Log .v (LOGTAG , "mFindIsUp=" + mFindIsUp
@@ -8884,13 +8904,6 @@ public void handleMessage(Message msg) {
88848904 }
88858905 break ;
88868906
8887- case FIND_AGAIN :
8888- // Ignore if find has been dismissed.
8889- if (mFindIsUp && mFindCallback != null ) {
8890- mFindCallback .findAll ();
8891- }
8892- break ;
8893-
88948907 case DRAG_HELD_MOTIONLESS :
88958908 mHeldMotionless = MOTIONLESS_TRUE ;
88968909 invalidate ();
@@ -9095,6 +9108,14 @@ public void handleMessage(Message msg) {
90959108 break ;
90969109 }
90979110
9111+ case UPDATE_MATCH_COUNT : {
9112+ if (mFindCallback != null ) {
9113+ mFindCallback .updateMatchCount (msg .arg1 , msg .arg2 ,
9114+ (String ) msg .obj );
9115+ }
9116+ break ;
9117+ }
9118+
90989119 default :
90999120 super .handleMessage (msg );
91009121 break ;
@@ -9931,9 +9952,6 @@ private native int nativeGetDrawGLFunction(int nativeInstance, Rect rect,
99319952 private native void nativeUpdateDrawGLFunction (Rect rect , Rect viewRect ,
99329953 RectF visibleRect , float scale );
99339954 private native void nativeExtendSelection (int x , int y );
9934- private native int nativeFindAll (String findLower , String findUpper ,
9935- boolean sameAsLastSearch );
9936- private native void nativeFindNext (boolean forward );
99379955 /* package */ native int nativeFocusCandidateFramePointer ();
99389956 /* package */ native boolean nativeFocusCandidateHasNextTextfield ();
99399957 /* package */ native boolean nativeFocusCandidateIsPassword ();
@@ -9991,9 +10009,7 @@ private native boolean nativeMoveCursor(int keyCode, int count,
999110009 private native boolean nativePointInNavCache (int x , int y , int slop );
999210010 private native void nativeSelectBestAt (Rect rect );
999310011 private native void nativeSelectAt (int x , int y );
9994- private native int nativeFindIndex ();
999510012 private native void nativeSetExtendSelection ();
9996- private native void nativeSetFindIsEmpty ();
999710013 private native void nativeSetFindIsUp (boolean isUp );
999810014 private native void nativeSetHeightCanMeasure (boolean measure );
999910015 private native boolean nativeSetBaseLayer (int nativeInstance ,
0 commit comments