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
+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.
- (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;
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
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;
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);
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);
+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.
[[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
// 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;
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;
// 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);
// 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;