WebCore:
authorsullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Sep 2006 23:44:23 +0000 (23:44 +0000)
committersullivan <sullivan@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 26 Sep 2006 23:44:23 +0000 (23:44 +0000)
        Reviewed by Darin

        * bridge/mac/WebCoreFrameBridge.h:
        * bridge/mac/WebCoreFrameBridge.mm:
        (-[WebCoreFrameBridge markAllMatchesForText:caseSensitive:limit:]):
        Added limit parameter, passed down to Frame

        * page/Frame.h:
        * page/Frame.cpp:
        (WebCore::Frame::markAllMatchesForText):
        Added limit parameter. Stop the search if it hits limit.

WebKit:

        Reviewed by Darin

        * WebView/WebHTMLViewPrivate.h:
        * WebView/WebHTMLView.m:
        (-[WebHTMLView markAllMatchesForText:caseSensitive:limit:]):
        Added limit parameter, passed over the bridge. Stop the search if it hits limit.

        * WebView/WebViewPrivate.h:
        * WebView/WebView.m:
        (-[WebView markAllMatchesForText:caseSensitive:highlight:limit:]):
        Added limit parameter, passed to WebHTMLView.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@16593 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebCore/ChangeLog
WebCore/bridge/mac/WebCoreFrameBridge.h
WebCore/bridge/mac/WebCoreFrameBridge.mm
WebCore/page/Frame.cpp
WebCore/page/Frame.h
WebKit/ChangeLog
WebKit/WebView/WebHTMLView.m
WebKit/WebView/WebHTMLViewPrivate.h
WebKit/WebView/WebView.m
WebKit/WebView/WebViewPrivate.h

index 8a938660d018c2a0c1498e9ba277634c96e6ac48..a39c73a749c955cbf24eb1e39d0c0252000e0d20 100644 (file)
@@ -1,3 +1,17 @@
+2006-09-26  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Darin
+
+        * bridge/mac/WebCoreFrameBridge.h:
+        * bridge/mac/WebCoreFrameBridge.mm:
+        (-[WebCoreFrameBridge markAllMatchesForText:caseSensitive:limit:]):
+        Added limit parameter, passed down to Frame
+        
+        * page/Frame.h:
+        * page/Frame.cpp:
+        (WebCore::Frame::markAllMatchesForText):
+        Added limit parameter. Stop the search if it hits limit.
+
 2006-09-26  Sean Gies  <seangies@apple.com>
 
         Reviewed by Brady Eidson.
index b5231682e8d76e2b334a201b46841ecadcb64df7..65cbecf0421a2b3da7953d0112eae067c2f2a612 100644 (file)
@@ -309,7 +309,7 @@ typedef enum {
 - (NSString *)matchLabels:(NSArray *)labels againstElement:(DOMElement *)element;
 
 - (BOOL)searchFor:(NSString *)string direction:(BOOL)forward caseSensitive:(BOOL)caseFlag wrap:(BOOL)wrapFlag;
-- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag;
+- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(unsigned)limit;
 - (BOOL)markedTextMatchesAreHighlighted;
 - (void)setMarkedTextMatchesAreHighlighted:(BOOL)doHighlight;
 - (void)unmarkAllTextMatches;
index f5b71895dda2b850e8bf75ed9070504990fde773..ef9e18533b0fa7ce953975ee64e67874e2e7aa18 100644 (file)
@@ -1228,9 +1228,9 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
     return m_frame->findString(String(string), forward, caseFlag, wrapFlag);
 }
 
-- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag
+- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(unsigned)limit
 {
-    return m_frame->markAllMatchesForText(string, caseFlag);
+    return m_frame->markAllMatchesForText(string, caseFlag, limit);
 }
 
 - (BOOL)markedTextMatchesAreHighlighted
index 28ab0a08aa4049be9b5f9eddac0ea227a72aeb55..16273d24ef44586a3cf6e4f6e42198cce3abed6c 100644 (file)
@@ -3493,7 +3493,7 @@ bool Frame::findString(const String& target, bool forward, bool caseFlag, bool w
     return true;
 }
 
-unsigned Frame::markAllMatchesForText(const String& target, bool caseFlag)
+unsigned Frame::markAllMatchesForText(const String& target, bool caseFlag, unsigned limit)
 {
     if (target.isEmpty())
         return 0;
@@ -3514,8 +3514,13 @@ unsigned Frame::markAllMatchesForText(const String& target, bool caseFlag)
             break;
 
         ++matchCount;
+        
         document()->addMarker(resultRange.get(), DocumentMarker::TextMatch);        
         
+        // Stop looking if we hit the specified limit. A limit of 0 means no limit.
+        if (limit > 0 && matchCount >= limit)
+            break;
+        
         setStart(searchRange.get(), newStart);
     } while (true);
     
index 41ee0de9162f234af496814309de39610be6c6d3..6507021b90d628b7a5e8332a168dc81b7d3b472b 100644 (file)
@@ -732,7 +732,7 @@ private:
   const Vector<MarkedTextUnderline>& markedTextUnderlines() const;  
   bool markedTextUsesUnderlines() const;
   
-  unsigned markAllMatchesForText(const String&, bool caseFlag);
+  unsigned markAllMatchesForText(const String&, bool caseFlag, unsigned limit);
   bool markedTextMatchesAreHighlighted() const;
   void setMarkedTextMatchesAreHighlighted(bool flag);
   
index 767846d172d9c83e67acaa42985f4ede1c196e60..4976720e41810adbd729da8900e465ad478248b4 100644 (file)
@@ -1,3 +1,17 @@
+2006-09-26  John Sullivan  <sullivan@apple.com>
+
+        Reviewed by Darin
+
+        * WebView/WebHTMLViewPrivate.h:
+        * WebView/WebHTMLView.m:
+        (-[WebHTMLView markAllMatchesForText:caseSensitive:limit:]):
+        Added limit parameter, passed over the bridge. Stop the search if it hits limit.
+
+        * WebView/WebViewPrivate.h:
+        * WebView/WebView.m:
+        (-[WebView markAllMatchesForText:caseSensitive:highlight:limit:]):
+        Added limit parameter, passed to WebHTMLView.
+
 2006-09-26  David Harrison  <harrison@apple.com>
 
         Reviewed by John and TimH.
index 1358d713b6efb7736c74ef58f0e296e1467e8f1b..6f1a6dc4f9b26b6c3f1069b3e1fe0d964aee3d62 100644 (file)
@@ -1845,9 +1845,9 @@ static WebHTMLView *lastHitView = nil;
     [[self _bridge] setIsActive:isActive];
 }
 
-- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag
+- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(unsigned)limit
 {
-    return [[self _bridge] markAllMatchesForText:string caseSensitive:caseFlag];
+    return [[self _bridge] markAllMatchesForText:string caseSensitive:caseFlag limit:limit];
 }
 
 - (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue
index a5ed6c58bf89425fdf549879a220e924dae4703c..b836d8283c91479d16d86614ac365c5f6c8aec76 100644 (file)
 // These methods might end up moving into a protocol, so different document types can specify
 // whether or not they implement the protocol.
 // These methods are still in flux; don't rely on them yet.
-- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag;
+- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag limit:(unsigned)limit;
 - (void)unmarkAllTextMatches;
 - (void)setMarkedTextMatchesAreHighlighted:(BOOL)newValue;
 - (BOOL)markedTextMatchesAreHighlighted;
index 4903f6dc31564cbda940efd37ebcd4cd5d29f9b5..4ecb894b0d2b10d70a8d3f793820232d9853b4fd 100644 (file)
@@ -2862,7 +2862,7 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
     return [[[self mainFrame] _bridge] aeDescByEvaluatingJavaScriptFromString:script];
 }
 
-- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight
+- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(unsigned)limit
 {
     WebFrame *frame = [self mainFrame];
     unsigned matchCount = 0;
@@ -2871,8 +2871,14 @@ static WebFrame *incrementFrame(WebFrame *curr, BOOL forward, BOOL wrapFlag)
         // FIXME: introduce a protocol, or otherwise make this work with other types
         if ([view isKindOfClass:[WebHTMLView class]])
             [(WebHTMLView *)view setMarkedTextMatchesAreHighlighted:highlight];
-            matchCount += [(WebHTMLView *)view markAllMatchesForText:string caseSensitive:caseFlag];
+        
+        ASSERT(limit == 0 || matchCount < limit);
+        matchCount += [(WebHTMLView *)view markAllMatchesForText:string caseSensitive:caseFlag limit:limit == 0 ? 0 : limit - matchCount];
 
+        // Stop looking if we've reached the limit. A limit of 0 means no limit.
+        if (limit > 0 && matchCount >= limit)
+            break;
+        
         frame = incrementFrame(frame, YES, NO);
     } while (frame);
     
index d3b6685314fe47cceda6de5ac454dad9c5b73efc..c00afee16e913953eca6c455445b1672c4a7c4ca 100644 (file)
@@ -105,7 +105,7 @@ typedef enum {
 // These methods might end up moving into a protocol, so different document types can specify
 // whether or not they implement the protocol. For now we'll just deal with HTML.
 // These methods are still in flux; don't rely on them yet.
-- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight;
+- (unsigned)markAllMatchesForText:(NSString *)string caseSensitive:(BOOL)caseFlag highlight:(BOOL)highlight limit:(unsigned)limit;
 - (void)unmarkAllTextMatches;
 - (NSArray *)rectsForTextMatches;