Fixed: <rdar://problem/3838413> REGRESSION (Mail): "Smart" word paste adds spaces...
authorcblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Nov 2004 00:36:12 +0000 (00:36 +0000)
committercblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 6 Nov 2004 00:36:12 +0000 (00:36 +0000)
        Reviewed by rjw.

        * WebCoreSupport.subproj/WebBridge.m:
        (_getPreSmartSet): copied from AppKit
        (_getPostSmartSet): ditto
        (-[WebBridge isCharacterSmartReplaceExempt:isPreviousCharacter:]): new

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

WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebBridge.m

index bc6b2e573e8bfaa0c88cdddd708b10f1fcbc1aa5..ca4f668e1ea6a85a67d6690b8aed737990a972c9 100644 (file)
@@ -1,3 +1,14 @@
+2004-11-05  Chris Blumenberg  <cblu@apple.com>
+
+       Fixed: <rdar://problem/3838413> REGRESSION (Mail): "Smart" word paste adds spaces before/after special characters
+
+        Reviewed by rjw.
+
+        * WebCoreSupport.subproj/WebBridge.m:
+        (_getPreSmartSet): copied from AppKit
+        (_getPostSmartSet): ditto
+        (-[WebBridge isCharacterSmartReplaceExempt:isPreviousCharacter:]): new
+
 2004-11-05  Richard Williamson   <rjw@apple.com>
 
         Fixed <rdar://problem/3810702> _checkNavigationPolicyForRequest:dataSource:formState:andCall:withSelector: ASSERTS when reentered from Xcode's man page viewer
index e74264fe55df1bed28fa6d691110daed684621ca..f51fac4b7cf87bd2e24e59ee5b5a170bf4810072 100644 (file)
@@ -1437,4 +1437,58 @@ static id <WebFormDelegate> formDelegate(WebBridge *self)
     return nil;
 }
 
+// FIXME: The following 2 functions are copied from AppKit. It would be best share code.
+
+// MF:!!! For now we will use static character sets for the computation, but we should eventually probably make these keys in the language dictionaries.
+// MF:!!! The following characters (listed with their nextstep encoding values) were in the preSmartTable in the old text objet, but aren't yet in the new text object: NS_FIGSPACE (0x80), exclamdown (0xa1), sterling (0xa3), yen (0xa5), florin (0xa6) section (0xa7), currency (0xa8), quotesingle (0xa9), quotedblleft (0xaa), guillemotleft (0xab), guilsinglleft (0xac), endash (0xb1), quotesinglbase (0xb8), quotedblbase (0xb9), questiondown (0xbf), emdash (0xd0), plusminus (0xd1).
+// MF:!!! The following characters (listed with their nextstep encoding values) were in the postSmartTable in the old text objet, but aren't yet in the new text object: NS_FIGSPACE (0x80), cent (0xa2), guilsinglright (0xad), registered (0xb0), dagger (0xa2), daggerdbl (0xa3), endash (0xb1), quotedblright (0xba), guillemotright (0xbb), perthousand (0xbd), onesuperior (0xc0), twosuperior (0xc9), threesuperior (0xcc), emdash (0xd0), ordfeminine (0xe3), ordmasculine (0xeb).
+// MF:!!! Another difference in both of these sets from the old text object is we include all the whitespace in whitespaceAndNewlineCharacterSet.
+#define _preSmartString @"([\"\'#$/-`{"
+#define _postSmartString @")].,;:?\'!\"%*-/}"
+static NSMutableCharacterSet *_preSmartSet = nil;
+static NSMutableCharacterSet *_postSmartSet = nil;
+
+static NSCharacterSet *_getPreSmartSet() {
+    if (!_preSmartSet) {
+        _preSmartSet = [[NSMutableCharacterSet characterSetWithCharactersInString:_preSmartString] retain];
+        [_preSmartSet formUnionWithCharacterSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+        // Adding CJK ranges
+        [_preSmartSet addCharactersInRange:NSMakeRange(0x1100, 256)]; // Hangul Jamo (0x1100 - 0x11FF)
+        [_preSmartSet addCharactersInRange:NSMakeRange(0x2E80, 352)]; // CJK & Kangxi Radicals (0x2E80 - 0x2FDF)
+        [_preSmartSet addCharactersInRange:NSMakeRange(0x2FF0, 464)]; // Ideograph Descriptions, CJK Symbols, Hiragana, Katakana, Bopomofo, Hangul Compatibility Jamo, Kanbun, & Bopomofo Ext (0x2FF0 - 0x31BF)
+        [_preSmartSet addCharactersInRange:NSMakeRange(0x3200, 29392)]; // Enclosed CJK, CJK Ideographs (Uni Han & Ext A), & Yi (0x3200 - 0xA4CF)
+        [_preSmartSet addCharactersInRange:NSMakeRange(0xAC00, 11183)]; // Hangul Syllables (0xAC00 - 0xD7AF)
+        [_preSmartSet addCharactersInRange:NSMakeRange(0xF900, 352)]; // CJK Compatibility Ideographs (0xF900 - 0xFA5F)
+        [_preSmartSet addCharactersInRange:NSMakeRange(0xFE30, 32)]; // CJK Compatibility From (0xFE30 - 0xFE4F)
+        [_preSmartSet addCharactersInRange:NSMakeRange(0xFF00, 240)]; // Half/Full Width Form (0xFF00 - 0xFFEF)
+        [_preSmartSet addCharactersInRange:NSMakeRange(0x20000, 0xA6D7)]; // CJK Ideograph Exntension B
+        [_preSmartSet addCharactersInRange:NSMakeRange(0x2F800, 0x021E)]; // CJK Compatibility Ideographs (0x2F800 - 0x2FA1D)
+    }
+    return _preSmartSet;
+}
+
+static NSCharacterSet *_getPostSmartSet() {
+    if (!_postSmartSet) {
+        _postSmartSet = [[NSMutableCharacterSet characterSetWithCharactersInString:_postSmartString] retain];
+        [_postSmartSet formUnionWithCharacterSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
+        [_postSmartSet addCharactersInRange:NSMakeRange(0x1100, 256)]; // Hangul Jamo (0x1100 - 0x11FF)
+        [_postSmartSet addCharactersInRange:NSMakeRange(0x2E80, 352)]; // CJK & Kangxi Radicals (0x2E80 - 0x2FDF)
+        [_postSmartSet addCharactersInRange:NSMakeRange(0x2FF0, 464)]; // Ideograph Descriptions, CJK Symbols, Hiragana, Katakana, Bopomofo, Hangul Compatibility Jamo, Kanbun, & Bopomofo Ext (0x2FF0 - 0x31BF)
+        [_postSmartSet addCharactersInRange:NSMakeRange(0x3200, 29392)]; // Enclosed CJK, CJK Ideographs (Uni Han & Ext A), & Yi (0x3200 - 0xA4CF)
+        [_postSmartSet addCharactersInRange:NSMakeRange(0xAC00, 11183)]; // Hangul Syllables (0xAC00 - 0xD7AF)
+        [_postSmartSet addCharactersInRange:NSMakeRange(0xF900, 352)]; // CJK Compatibility Ideographs (0xF900 - 0xFA5F)
+        [_postSmartSet addCharactersInRange:NSMakeRange(0xFE30, 32)]; // CJK Compatibility From (0xFE30 - 0xFE4F)
+        [_postSmartSet addCharactersInRange:NSMakeRange(0xFF00, 240)]; // Half/Full Width Form (0xFF00 - 0xFFEF)
+        [_postSmartSet addCharactersInRange:NSMakeRange(0x20000, 0xA6D7)]; // CJK Ideograph Exntension B
+        [_postSmartSet addCharactersInRange:NSMakeRange(0x2F800, 0x021E)]; // CJK Compatibility Ideographs (0x2F800 - 0x2FA1D)        
+        [_postSmartSet formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];
+    }
+    return _postSmartSet;
+}
+
+- (BOOL)isCharacterSmartReplaceExempt:(unichar)c isPreviousCharacter:(BOOL)isPreviousCharacter
+{
+    return [isPreviousCharacter ? _getPreSmartSet() : _getPostSmartSet() characterIsMember:c];
+}
+
 @end