[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:24:28 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit a2747859b46f04694daad751c06a217b769023b0
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Feb 12 22:18:38 2003 +0000

            Reviewed by Trey.
    
            - fixed 3162786 -- hang with large amounts of text in textarea
    
            * kwq/KWQTextArea.mm: (-[KWQTextArea getCursorPositionAsIndex:inParagraph:]):
            Rewrite to not use RangeOfParagraph to avoid n^2 algorithm. Also made small
            changes to similar functions so they look similar, and got rid of an int/unsigned
            mismatch in a case where the value is guaranteed to be positive.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3641 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index b13612f..a52cb17 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,14 @@
+2003-02-12  Darin Adler  <darin at apple.com>
+
+        Reviewed by Trey.
+
+        - fixed 3162786 -- hang with large amounts of text in textarea
+
+        * kwq/KWQTextArea.mm: (-[KWQTextArea getCursorPositionAsIndex:inParagraph:]):
+        Rewrite to not use RangeOfParagraph to avoid n^2 algorithm. Also made small
+        changes to similar functions so they look similar, and got rid of an int/unsigned
+        mismatch in a case where the value is guaranteed to be positive.
+
 2003-02-11  Darin Adler  <darin at apple.com>
 
         Reviewed by Dave.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index b13612f..a52cb17 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,14 @@
+2003-02-12  Darin Adler  <darin at apple.com>
+
+        Reviewed by Trey.
+
+        - fixed 3162786 -- hang with large amounts of text in textarea
+
+        * kwq/KWQTextArea.mm: (-[KWQTextArea getCursorPositionAsIndex:inParagraph:]):
+        Rewrite to not use RangeOfParagraph to avoid n^2 algorithm. Also made small
+        changes to similar functions so they look similar, and got rid of an int/unsigned
+        mismatch in a case where the value is guaranteed to be positive.
+
 2003-02-11  Darin Adler  <darin at apple.com>
 
         Reviewed by Dave.
diff --git a/WebCore/kwq/KWQTextArea.mm b/WebCore/kwq/KWQTextArea.mm
index 53a3a53..da171e6 100644
--- a/WebCore/kwq/KWQTextArea.mm
+++ b/WebCore/kwq/KWQTextArea.mm
@@ -255,18 +255,16 @@ const float LargeNumberForText = 1.0e7;
     NSString *text = [textView string];
     int paragraphSoFar = 0;
     NSRange searchRange = NSMakeRange(0, [text length]);
-    NSRange newlineRange;
-    int advance;
 
     while (true) {
-	newlineRange = [text rangeOfString:@"\n" options:NSLiteralSearch range:searchRange];
+	NSRange newlineRange = [text rangeOfString:@"\n" options:NSLiteralSearch range:searchRange];
 	if (newlineRange.location == NSNotFound) {
 	    break;
 	}
 
 	paragraphSoFar++;
 
-        advance = newlineRange.location + 1 - searchRange.location;
+        unsigned advance = newlineRange.location + 1 - searchRange.location;
         
 	searchRange.length -= advance;
 	searchRange.location += advance;
@@ -279,9 +277,8 @@ static NSRange RangeOfParagraph(NSString *text, int paragraph)
 {
     int paragraphSoFar = 0;
     NSRange searchRange = NSMakeRange(0, [text length]);
-    NSRange newlineRange;
-    int advance;
 
+    NSRange newlineRange;
     while (true) {
 	newlineRange = [text rangeOfString:@"\n" options:NSLiteralSearch range:searchRange];
 	if (newlineRange.location == NSNotFound) {
@@ -294,8 +291,8 @@ static NSRange RangeOfParagraph(NSString *text, int paragraph)
 
 	paragraphSoFar++;
 
-        advance = newlineRange.location + 1 - searchRange.location;
-	if ((int)searchRange.length <= advance) {
+        unsigned advance = newlineRange.location + 1 - searchRange.location;
+	if (searchRange.length <= advance) {
 	    searchRange.location = NSNotFound;
 	    searchRange.length = 0;
 	    break;
@@ -367,32 +364,31 @@ static NSRange RangeOfParagraph(NSString *text, int paragraph)
     NSString *text = [textView string];
     NSRange selectedRange = [textView selectedRange];
     
-    *index = 0;
-    *paragraph = 0;
-
     if (selectedRange.location == NSNotFound) {
+        *paragraph = 0;
+        *index = 0;
         return;
     }
     
-    int num = [self paragraphs];
-    if (num == 0) {
-        return;
-    }
-    
-    int i;
-    NSRange range;
-    
-    for (i = 0; i < num; i++) {
-        range = RangeOfParagraph(text, i);
-        if (range.location + range.length > selectedRange.location) {
-            *paragraph = i;
-            *index = selectedRange.location - range.location;
-            return;
-        }
+    int paragraphSoFar = 0;
+    NSRange searchRange = NSMakeRange(0, [text length]);
+
+    while (true) {
+	NSRange newlineRange = [text rangeOfString:@"\n" options:NSLiteralSearch range:searchRange];
+	if (newlineRange.location == NSNotFound || selectedRange.location <= newlineRange.location) {
+	    break;
+	}
+        
+	paragraphSoFar++;
+
+        unsigned advance = newlineRange.location + 1 - searchRange.location;
+
+	searchRange.length -= advance;
+	searchRange.location += advance;
     }
 
-    // Express the end of text as past the last paragraph.
-    *paragraph = num;
+    *paragraph = paragraphSoFar;
+    *index = selectedRange.location - searchRange.location;
 }
 
 - (void)setCursorPositionToIndex:(int)index inParagraph:(int)paragraph

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list