[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:52:20 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 6d44d405f849be4dfd9b6fbffaca395484ccd215
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Aug 19 20:07:52 2003 +0000

            Reviewed by John.
    
            - fixed 3380411 -- Unicode supplementary characters cut in half in text control with maxlength set
    
            * kwq/KWQTextField.mm:
            (-[KWQTextField setMaximumLength:]): Enforce maximum length based on number of composed character
            sequences rather than on number of UTF-16 values. This helps with both surrogate pairs (the supplementary
            characters mentioned in the bug report) and composed character sequences.
            (-[KWQTextField setStringValue:]): Ditto.
            (-[KWQTextFieldFormatter isPartialStringValid:newEditingString:errorDescription:]): Ditto.
            (-[NSString _KWQ_numComposedCharacterSequences]): Added. Computes the length of a string in terms of
            number of composed character sequences.
            (-[NSString _KWQ_truncateToNumComposedCharacterSequences:]): Added. Truncates a string in terms of
            number of composed character sequences.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4843 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index d58e9a2..1926f1f 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,5 +1,22 @@
 2003-08-18  Darin Adler  <darin at apple.com>
 
+        Reviewed by John.
+
+        - fixed 3380411 -- Unicode supplementary characters cut in half in text control with maxlength set
+
+        * kwq/KWQTextField.mm:
+        (-[KWQTextField setMaximumLength:]): Enforce maximum length based on number of composed character
+        sequences rather than on number of UTF-16 values. This helps with both surrogate pairs (the supplementary
+        characters mentioned in the bug report) and composed character sequences.
+        (-[KWQTextField setStringValue:]): Ditto.
+        (-[KWQTextFieldFormatter isPartialStringValid:newEditingString:errorDescription:]): Ditto.
+        (-[NSString _KWQ_numComposedCharacterSequences]): Added. Computes the length of a string in terms of
+        number of composed character sequences.
+        (-[NSString _KWQ_truncateToNumComposedCharacterSequences:]): Added. Truncates a string in terms of
+        number of composed character sequences.
+
+2003-08-18  Darin Adler  <darin at apple.com>
+
         Reviewed by Maciej.
 
         - fixed 3299893 -- oncontextmenu support
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index d58e9a2..1926f1f 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,22 @@
 2003-08-18  Darin Adler  <darin at apple.com>
 
+        Reviewed by John.
+
+        - fixed 3380411 -- Unicode supplementary characters cut in half in text control with maxlength set
+
+        * kwq/KWQTextField.mm:
+        (-[KWQTextField setMaximumLength:]): Enforce maximum length based on number of composed character
+        sequences rather than on number of UTF-16 values. This helps with both surrogate pairs (the supplementary
+        characters mentioned in the bug report) and composed character sequences.
+        (-[KWQTextField setStringValue:]): Ditto.
+        (-[KWQTextFieldFormatter isPartialStringValid:newEditingString:errorDescription:]): Ditto.
+        (-[NSString _KWQ_numComposedCharacterSequences]): Added. Computes the length of a string in terms of
+        number of composed character sequences.
+        (-[NSString _KWQ_truncateToNumComposedCharacterSequences:]): Added. Truncates a string in terms of
+        number of composed character sequences.
+
+2003-08-18  Darin Adler  <darin at apple.com>
+
         Reviewed by Maciej.
 
         - fixed 3299893 -- oncontextmenu support
diff --git a/WebCore/kwq/KWQTextField.mm b/WebCore/kwq/KWQTextField.mm
index e745448..b07b656 100644
--- a/WebCore/kwq/KWQTextField.mm
+++ b/WebCore/kwq/KWQTextField.mm
@@ -32,6 +32,11 @@
 #import "KWQView.h"
 #import "WebCoreBridge.h"
 
+ at interface NSString (KWQTextField)
+- (int)_KWQ_numComposedCharacterSequences;
+- (NSString *)_KWQ_truncateToNumComposedCharacterSequences:(int)num;
+ at end
+
 @interface KWQTextField (KWQInternal)
 - (void)setHasFocus:(BOOL)hasFocus;
 @end
@@ -208,8 +213,8 @@
 - (void)setMaximumLength:(int)len
 {
     NSString *oldValue = [self stringValue];
-    if ((int)[oldValue length] > len) {
-        [self setStringValue:[oldValue substringToIndex:len]];
+    if ([oldValue _KWQ_numComposedCharacterSequences] > len) {
+        [self setStringValue:[oldValue _KWQ_truncateToNumComposedCharacterSequences:len]];
     }
     [formatter setMaximumLength:len];
 }
@@ -339,9 +344,7 @@
     }
 
     int maxLength = [formatter maximumLength];
-    if ((int)[string length] > maxLength) {
-        string = [string substringToIndex:maxLength];
-    }
+    string = [string _KWQ_truncateToNumComposedCharacterSequences:maxLength];
     [secureField setStringValue:string];
     [super setStringValue:string];
     widget->textChanged();
@@ -616,7 +619,7 @@
 
 - (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
 {
-    if ((int)[partialString length] > maxLength) {
+    if ([partialString _KWQ_numComposedCharacterSequences] > maxLength) {
         *newString = nil;
         return NO;
     }
@@ -766,3 +769,35 @@
 }
 
 @end
+
+ at implementation NSString (KWQTextField)
+
+- (int)_KWQ_numComposedCharacterSequences
+{
+    unsigned i = 0;
+    unsigned l = [self length];
+    int num = 0;
+    while (i < l) {
+        i = NSMaxRange([self rangeOfComposedCharacterSequenceAtIndex:i]);
+        ++num;
+    }
+    return num;
+}
+
+- (NSString *)_KWQ_truncateToNumComposedCharacterSequences:(int)num
+{
+    unsigned i = 0;
+    unsigned l = [self length];
+    if (l == 0) {
+        return self;
+    }
+    for (int j = 0; j < num; j++) {
+        i = NSMaxRange([self rangeOfComposedCharacterSequenceAtIndex:i]);
+        if (i >= l) {
+            return self;
+        }
+    }
+    return [self substringToIndex:i];
+}
+
+ at end

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list