[webkit-changes] cvs commit: WebKit/Misc.subproj
WebSearchableTextView.m
John
sullivan at opensource.apple.com
Fri Jul 15 13:35:27 PDT 2005
sullivan 05/07/15 13:35:26
Modified: . ChangeLog
Misc.subproj WebSearchableTextView.m
Log:
Reviewed by Maciej Stachowiak.
- fixed these bugs:
<rdar://problem/4181875> Searching for text that overlaps selection works differently in WebTextView than in HTMLView
<rdar://problem/3393678> Find not finding text in plain (non-HTML) if all text is selected
* Misc.subproj/WebSearchableTextView.m:
(-[NSString findString:selectedRange:options:wrap:]):
Make search algorithm match that in WebCore: initially search inside selection, then check for the case
where the found text exactly matches the previous selection, and search from past the selection if so.
Revision Changes Path
1.3229 +13 -0 WebKit/ChangeLog
Index: ChangeLog
===================================================================
RCS file: /cvs/root/WebKit/ChangeLog,v
retrieving revision 1.3228
retrieving revision 1.3229
diff -u -r1.3228 -r1.3229
--- ChangeLog 14 Jul 2005 23:52:50 -0000 1.3228
+++ ChangeLog 15 Jul 2005 20:35:24 -0000 1.3229
@@ -1,3 +1,16 @@
+2005-07-15 John Sullivan <sullivan at apple.com>
+
+ Reviewed by Maciej Stachowiak.
+
+ - fixed these bugs:
+ <rdar://problem/4181875> Searching for text that overlaps selection works differently in WebTextView than in HTMLView
+ <rdar://problem/3393678> Find not finding text in plain (non-HTML) if all text is selected
+
+ * Misc.subproj/WebSearchableTextView.m:
+ (-[NSString findString:selectedRange:options:wrap:]):
+ Make search algorithm match that in WebCore: initially search inside selection, then check for the case
+ where the found text exactly matches the previous selection, and search from past the selection if so.
+
2005-07-14 John Sullivan <sullivan at apple.com>
Reviewed by Dave Hyatt.
1.6 +24 -2 WebKit/Misc.subproj/WebSearchableTextView.m
Index: WebSearchableTextView.m
===================================================================
RCS file: /cvs/root/WebKit/Misc.subproj/WebSearchableTextView.m,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- WebSearchableTextView.m 5 Jun 2005 17:54:26 -0000 1.5
+++ WebSearchableTextView.m 15 Jul 2005 20:35:26 -0000 1.6
@@ -87,10 +87,24 @@
unsigned length = [self length];
NSRange searchRange, range;
+ // Our search algorithm, used in WebCore also, is to search in the selection first. If the found text is the
+ // entire selection, then we search again from just past the selection.
+
if (forwards) {
- searchRange.location = selectedRange.length > 0 ? NSMaxRange(selectedRange) : 0;
+ // FIXME: If selectedRange has length of 0, we ignore it, which is appropriate for non-editable text (since
+ // a zero-length selection in non-editable is invisible). We might want to change this someday to only ignore the
+ // selection if its location is NSNotFound when the text is editable (and similarly for the backwards case).
+ searchRange.location = selectedRange.length > 0 ? selectedRange.location : 0;
searchRange.length = length - searchRange.location;
range = [self rangeOfString:string options:options range:searchRange];
+
+ // If found range matches (non-empty) selection, search again from just past selection
+ if (range.location != NSNotFound && NSEqualRanges(range, selectedRange)) {
+ searchRange.location = NSMaxRange(selectedRange);
+ searchRange.length = length - searchRange.location;
+ range = [self rangeOfString:string options:options range:searchRange];
+ }
+
if ((range.length == 0) && wrap) { /* If not found look at the first part of the string */
searchRange.location = 0;
searchRange.length = selectedRange.location;
@@ -98,8 +112,16 @@
}
} else {
searchRange.location = 0;
- searchRange.length = selectedRange.length > 0 ? selectedRange.location : length;
+ searchRange.length = selectedRange.length > 0 ? NSMaxRange(selectedRange) : length;
range = [self rangeOfString:string options:options range:searchRange];
+
+ // If found range matches (non-empty) selection, search again from just before selection
+ if (range.location != NSNotFound && NSEqualRanges(range, selectedRange)) {
+ searchRange.location = 0;
+ searchRange.length = selectedRange.location;
+ range = [self rangeOfString:string options:options range:searchRange];
+ }
+
if ((range.length == 0) && wrap) {
searchRange.location = NSMaxRange(selectedRange);
searchRange.length = length - searchRange.location;
More information about the webkit-changes
mailing list