Reviewed by Adam.
authoraliceli1 <aliceli1@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Jul 2007 18:37:11 +0000 (18:37 +0000)
committeraliceli1 <aliceli1@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 4 Jul 2007 18:37:11 +0000 (18:37 +0000)
        Fixed <rdar://problem/5225119> support smart pasting on Windows

        * WebCore.vcproj/WebCore.vcproj:
        * WebCore.xcodeproj/project.pbxproj:
            Added new files
        * editing/SmartReplace.cpp: Added.
        (WebCore::isCharacterSmartReplaceExempt):
            Added non-CF implementation placeholder
        * editing/SmartReplace.h: Added.
        * editing/SmartReplaceCF.cpp: Added.
        (WebCore::getSmartSet):
        (WebCore::isCharacterSmartReplaceExempt):
            Added new implementation

        * bridge/win/FrameWin.cpp:
        * page/Frame.h:
        * page/mac/FrameMac.mm:
            Removed old declaration and implementation

        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::doApply):
            Changed to call the new function instead of old

        * page/mac/WebCoreFrameBridge.h:
        * page/mac/WebCoreFrameBridge.mm:
            Removed old declaration and implementation
        (-[WebCoreFrameBridge smartInsertForString:replacingRange:beforeString:afterString:]):
            Changed to call the new function instead of old

        * platform/win/PasteboardWin.cpp:
        (WebCore::Pasteboard::Pasteboard):
            Register new clipboard format
        (WebCore::Pasteboard::writeSelection):
            Set data for smartpaste format on clipboard
        (WebCore::Pasteboard::canSmartReplace):
            Added non-stub implementation

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

13 files changed:
WebCore/ChangeLog
WebCore/WebCore.vcproj/WebCore.vcproj
WebCore/WebCore.xcodeproj/project.pbxproj
WebCore/bridge/win/FrameWin.cpp
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/editing/SmartReplace.cpp [new file with mode: 0644]
WebCore/editing/SmartReplace.h [new file with mode: 0644]
WebCore/editing/SmartReplaceCF.cpp [new file with mode: 0644]
WebCore/page/Frame.h
WebCore/page/mac/FrameMac.mm
WebCore/page/mac/WebCoreFrameBridge.h
WebCore/page/mac/WebCoreFrameBridge.mm
WebCore/platform/win/PasteboardWin.cpp

index 8887eace8cd5fd6a29c0564cdc4e20b33908f378..bae6ebf571864ee454f0c723937373b7096e40b5 100644 (file)
@@ -1,3 +1,44 @@
+2007-07-03  Alice Liu  <alice.liu@apple.com>
+
+        Reviewed by Adam.
+
+        Fixed <rdar://problem/5225119> support smart pasting on Windows
+
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+            Added new files
+        * editing/SmartReplace.cpp: Added.
+        (WebCore::isCharacterSmartReplaceExempt):
+            Added non-CF implementation placeholder
+        * editing/SmartReplace.h: Added.
+        * editing/SmartReplaceCF.cpp: Added.
+        (WebCore::getSmartSet):
+        (WebCore::isCharacterSmartReplaceExempt):
+            Added new implementation
+
+        * bridge/win/FrameWin.cpp:
+        * page/Frame.h:
+        * page/mac/FrameMac.mm:
+            Removed old declaration and implementation
+
+        * editing/ReplaceSelectionCommand.cpp:
+        (WebCore::ReplaceSelectionCommand::doApply):
+            Changed to call the new function instead of old
+
+        * page/mac/WebCoreFrameBridge.h:
+        * page/mac/WebCoreFrameBridge.mm:
+            Removed old declaration and implementation
+        (-[WebCoreFrameBridge smartInsertForString:replacingRange:beforeString:afterString:]):
+            Changed to call the new function instead of old
+
+        * platform/win/PasteboardWin.cpp:
+        (WebCore::Pasteboard::Pasteboard):
+            Register new clipboard format
+        (WebCore::Pasteboard::writeSelection):
+            Set data for smartpaste format on clipboard
+        (WebCore::Pasteboard::canSmartReplace):
+            Added non-stub implementation
+
 2007-07-04  Qing Zhao  <qing@staikos.net>
 
         Reviewed by George Staikos.
index 5723aa6b26f28ec5524a94dda5dded67f05b3abc..8d5d323499ef91c4d68084783bbf138cd833bb80 100644 (file)
                                RelativePath="..\editing\SetNodeAttributeCommand.h"
                                >
                        </File>
+                       <File
+                               RelativePath="..\editing\SmartReplace.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\editing\SmartReplace.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\editing\SmartReplaceCF.cpp"
+                               >
+                       </File>
                        <File
                                RelativePath="..\editing\SplitElementCommand.cpp"
                                >
index 5d810b3970f7773be5da1d5a563d453023b7ed39..b5ea342cf01960b46a0a6b202d9279ee0a34a6c3 100644 (file)
                4B3043C90AE0371D00A82647 /* SoundMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4B3043C80AE0371D00A82647 /* SoundMac.mm */; };
                4B3043CC0AE0373B00A82647 /* Editor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B3043CA0AE0373B00A82647 /* Editor.cpp */; };
                4B3043CD0AE0373B00A82647 /* Editor.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B3043CB0AE0373B00A82647 /* Editor.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               4B6FA6F40C39E48C00087011 /* SmartReplace.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B6FA6F20C39E48C00087011 /* SmartReplace.h */; };
+               4B6FA6F50C39E48C00087011 /* SmartReplace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B6FA6F30C39E48C00087011 /* SmartReplace.cpp */; };
+               4B6FA6F70C39E4A100087011 /* SmartReplaceCF.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4B6FA6F60C39E4A100087011 /* SmartReplaceCF.cpp */; };
                4B8AF4AA0B1CE02B00687690 /* ClipboardAccessPolicy.h in Headers */ = {isa = PBXBuildFile; fileRef = 4B8AF4A90B1CE02B00687690 /* ClipboardAccessPolicy.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4BAE95B10B2FA9CE00AED8A0 /* EditorDeleteAction.h in Headers */ = {isa = PBXBuildFile; fileRef = 4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4BBDBF7D0ACC9290005F6E97 /* CommandByName.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4BBDBF7B0ACC9290005F6E97 /* CommandByName.cpp */; };
                4B3043C80AE0371D00A82647 /* SoundMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = SoundMac.mm; sourceTree = "<group>"; };
                4B3043CA0AE0373B00A82647 /* Editor.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = Editor.cpp; sourceTree = "<group>"; };
                4B3043CB0AE0373B00A82647 /* Editor.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = Editor.h; sourceTree = "<group>"; };
+               4B6FA6F20C39E48C00087011 /* SmartReplace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SmartReplace.h; sourceTree = "<group>"; };
+               4B6FA6F30C39E48C00087011 /* SmartReplace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartReplace.cpp; sourceTree = "<group>"; };
+               4B6FA6F60C39E4A100087011 /* SmartReplaceCF.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SmartReplaceCF.cpp; sourceTree = "<group>"; };
                4B8AF4A90B1CE02B00687690 /* ClipboardAccessPolicy.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = ClipboardAccessPolicy.h; sourceTree = "<group>"; };
                4BAE95B00B2FA9CE00AED8A0 /* EditorDeleteAction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EditorDeleteAction.h; sourceTree = "<group>"; };
                4BBDBF7B0ACC9290005F6E97 /* CommandByName.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = CommandByName.cpp; sourceTree = "<group>"; };
                                93309DD1099E64910056E581 /* VisiblePosition.h */,
                                93309DD4099E64910056E581 /* WrapContentsInDummySpanCommand.cpp */,
                                93309DD5099E64910056E581 /* WrapContentsInDummySpanCommand.h */,
+                               4B6FA6F20C39E48C00087011 /* SmartReplace.h */,
+                               4B6FA6F30C39E48C00087011 /* SmartReplace.cpp */,
+                               4B6FA6F60C39E4A100087011 /* SmartReplaceCF.cpp */,
                        );
                        path = editing;
                        sourceTree = "<group>";
                                BC94D14F0C275C68006BC617 /* JSHistory.h in Headers */,
                                BC94D1540C275C8B006BC617 /* History.h in Headers */,
                                BC94D1570C275CAB006BC617 /* GlobalHistory.h in Headers */,
+                               4B6FA6F40C39E48C00087011 /* SmartReplace.h in Headers */,
                                BC5A86850C33676000EEA649 /* DOMSelection.h in Headers */,
                                BC5A86B60C3367E800EEA649 /* JSDOMSelection.h in Headers */,
                                BC073BAA0C399B1F000F5979 /* FloatConversion.h in Headers */,
                                BC94D14E0C275C68006BC617 /* JSHistory.cpp in Sources */,
                                BC94D1530C275C8B006BC617 /* History.cpp in Sources */,
                                BC94D1590C275CB6006BC617 /* GlobalHistoryMac.mm in Sources */,
+                               4B6FA6F50C39E48C00087011 /* SmartReplace.cpp in Sources */,
+                               4B6FA6F70C39E4A100087011 /* SmartReplaceCF.cpp in Sources */,
                                BCEFAF4E0C317E6900FA81F6 /* JSEventCustom.cpp in Sources */,
                                BC5A86840C33676000EEA649 /* DOMSelection.cpp in Sources */,
                                BC5A86B50C3367E800EEA649 /* JSDOMSelection.cpp in Sources */,
index d2f78688eb9742f36a4695939129d8b1ed566479..2f797ddb6c1d4791913059b0c36ad47ed8ff1035 100644 (file)
@@ -179,12 +179,6 @@ HBITMAP imageFromSelection(Frame* frame, bool forceWhiteText)
     return hbmp;
 }
 
-bool Frame::isCharacterSmartReplaceExempt(UChar, bool)
-{
-    // no smart replace
-    return true;
-}
-
 DragImageRef Frame::dragImageForSelection()
 {    
     if (selectionController()->isRange())
index 9f98581f051006b78d1dc0a30709a224ffdf621e..3ca85a89d73a792601bf8d39db609058b111ab82 100644 (file)
@@ -41,6 +41,7 @@
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "SelectionController.h"
+#include "SmartReplace.h"
 #include "TextIterator.h"
 #include "htmlediting.h"
 #include "markup.h"
@@ -675,7 +676,7 @@ void ReplaceSelectionCommand::doApply()
     }
     if (m_smartReplace) {
         bool needsTrailingSpace = !isEndOfParagraph(endOfInsertedContent) &&
-                                  !frame->isCharacterSmartReplaceExempt(endOfInsertedContent.characterAfter(), false);
+                                  !isCharacterSmartReplaceExempt(endOfInsertedContent.characterAfter(), false);
         if (needsTrailingSpace) {
             RenderObject* renderer = m_lastLeafInserted->renderer();
             bool collapseWhiteSpace = !renderer || renderer->style()->collapseWhiteSpace();
@@ -690,7 +691,7 @@ void ReplaceSelectionCommand::doApply()
         }
     
         bool needsLeadingSpace = !isStartOfParagraph(startOfInsertedContent) &&
-                                 !frame->isCharacterSmartReplaceExempt(startOfInsertedContent.previous().characterAfter(), true);
+                                 !isCharacterSmartReplaceExempt(startOfInsertedContent.previous().characterAfter(), true);
         if (needsLeadingSpace) {
             RenderObject* renderer = m_lastLeafInserted->renderer();
             bool collapseWhiteSpace = !renderer || renderer->style()->collapseWhiteSpace();
diff --git a/WebCore/editing/SmartReplace.cpp b/WebCore/editing/SmartReplace.cpp
new file mode 100644 (file)
index 0000000..bf2a476
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SmartReplace.h"
+
+#if !PLATFORM(CF)
+
+namespace WebCore {
+
+bool isCharacterSmartReplaceExempt(UChar32 c, bool isPreviousCharacter)
+{
+    return false;
+}
+
+}
+
+#endif // !PLATFORM(CF)
diff --git a/WebCore/editing/SmartReplace.h b/WebCore/editing/SmartReplace.h
new file mode 100644 (file)
index 0000000..5a37137
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <wtf/unicode/Unicode.h>
+
+namespace WebCore {
+
+bool isCharacterSmartReplaceExempt(UChar32 c, bool isPreviousCharacter);
+
+} // namespace WebCore
diff --git a/WebCore/editing/SmartReplaceCF.cpp b/WebCore/editing/SmartReplaceCF.cpp
new file mode 100644 (file)
index 0000000..f2fd985
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ *
+ * 1.  Redistributions of source code must retain the above copyright
+ *     notice, this list of conditions and the following disclaimer. 
+ * 2.  Redistributions in binary form must reproduce the above copyright
+ *     notice, this list of conditions and the following disclaimer in the
+ *     documentation and/or other materials provided with the distribution. 
+ * 3.  Neither the name of Apple Computer, Inc. ("Apple") nor the names of
+ *     its contributors may be used to endorse or promote products derived
+ *     from this software without specific prior written permission. 
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
+ * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "SmartReplace.h"
+
+#include <CoreFoundation/CFCharacterSet.h>
+
+namespace WebCore {
+
+static CFMutableCharacterSetRef getSmartSet(bool isPreviousCharacter)
+{
+    static CFMutableCharacterSetRef preSmartSet = NULL; 
+    static CFMutableCharacterSetRef postSmartSet = NULL;
+    CFMutableCharacterSetRef smartSet = isPreviousCharacter ? preSmartSet : postSmartSet;
+    if (!smartSet) {
+        smartSet = CFCharacterSetCreateMutable(kCFAllocatorDefault);
+        CFCharacterSetAddCharactersInString(smartSet, isPreviousCharacter ? CFSTR("([\"\'#$/-`{") : CFSTR(")].,;:?\'!\"%*-/}"));
+        CFCharacterSetUnion(smartSet, CFCharacterSetGetPredefined(kCFCharacterSetWhitespaceAndNewline));        
+        // Adding CJK ranges
+        CFCharacterSetAddCharactersInRange(smartSet, CFRangeMake(0x1100, 256)); // Hangul Jamo (0x1100 - 0x11FF)
+        CFCharacterSetAddCharactersInRange(smartSet, CFRangeMake(0x2E80, 352)); // CJK & Kangxi Radicals (0x2E80 - 0x2FDF)
+        CFCharacterSetAddCharactersInRange(smartSet, CFRangeMake(0x2FF0, 464)); // Ideograph Descriptions, CJK Symbols, Hiragana, Katakana, Bopomofo, Hangul Compatibility Jamo, Kanbun, & Bopomofo Ext (0x2FF0 - 0x31BF)
+        CFCharacterSetAddCharactersInRange(smartSet, CFRangeMake(0x3200, 29392)); // Enclosed CJK, CJK Ideographs (Uni Han & Ext A), & Yi (0x3200 - 0xA4CF)
+        CFCharacterSetAddCharactersInRange(smartSet, CFRangeMake(0xAC00, 11183)); // Hangul Syllables (0xAC00 - 0xD7AF)
+        CFCharacterSetAddCharactersInRange(smartSet, CFRangeMake(0xF900, 352)); // CJK Compatibility Ideographs (0xF900 - 0xFA5F)
+        CFCharacterSetAddCharactersInRange(smartSet, CFRangeMake(0xFE30, 32)); // CJK Compatibility From (0xFE30 - 0xFE4F)
+        CFCharacterSetAddCharactersInRange(smartSet, CFRangeMake(0xFF00, 240)); // Half/Full Width Form (0xFF00 - 0xFFEF)
+        CFCharacterSetAddCharactersInRange(smartSet, CFRangeMake(0x20000, 0xA6D7)); // CJK Ideograph Exntension B
+        CFCharacterSetAddCharactersInRange(smartSet, CFRangeMake(0x2F800, 0x021E)); // CJK Compatibility Ideographs (0x2F800 - 0x2FA1D)
+
+        if (isPreviousCharacter)
+            preSmartSet = smartSet;
+        else {
+            CFCharacterSetUnion(smartSet, CFCharacterSetGetPredefined(kCFCharacterSetPunctuation));       
+            postSmartSet = smartSet;
+        }
+    }
+    return smartSet;
+}
+
+bool isCharacterSmartReplaceExempt(UChar32 c, bool isPreviousCharacter)
+{
+    return CFCharacterSetIsLongCharacterMember(getSmartSet(isPreviousCharacter), c);
+}
+
+}
index e2f49d4dd6a3bc0af851b056f2dca04c5027a907..a5e3471f0b5aa8fa54450b31e848c71c2caa36e1 100644 (file)
@@ -335,13 +335,6 @@ private:
     void caretBlinkTimerFired(Timer<Frame>*);
     void setUseSecureKeyboardEntry(bool);
 
-// === to be moved into the Platform directory
-
-public:
-    bool isCharacterSmartReplaceExempt(UChar, bool);
-
-// === to be deleted
-
 public:
     SelectionController* dragCaretController() const;
 
index 7e379cd6502caf6d40866d591ad2bd44c1775ee3..60efd2440d8fcfc74a61180e05abea41384d8a95 100644 (file)
@@ -636,11 +636,6 @@ void Frame::willPopupMenu(NSMenu * menu)
     [d->m_bridge willPopupMenu:menu];
 }
 
-bool Frame::isCharacterSmartReplaceExempt(UChar c, bool isPreviousChar)
-{
-    return [d->m_bridge isCharacterSmartReplaceExempt:c isPreviousCharacter:isPreviousChar];
-}
-
 void Frame::setNeedsReapplyStyles()
 {
     [d->m_bridge setNeedsReapplyStyles];
index 2f0f754865c90ebcb68243e83f38ce2f4a4a20d8..d8e031f38fd5a75c6039a0ed789e95b3f43aefa0 100644 (file)
@@ -233,8 +233,6 @@ typedef enum ObjectElementType {
 - (void)dragSourceMovedTo:(NSPoint)windowLoc;
 - (void)dragSourceEndedAt:(NSPoint)windowLoc operation:(NSDragOperation)operation;
 
-- (BOOL)isCharacterSmartReplaceExempt:(unichar)c isPreviousCharacter:(BOOL)isPreviousCharacter;
-
 - (BOOL)getData:(NSData **)data andResponse:(NSURLResponse **)response forURL:(NSString *)URL;
 - (void)getAllResourceDatas:(NSArray **)datas andResponses:(NSArray **)responses;
 
index b4a0315d58e525c0726d9573fbdf621a31f6ed93..6c520d2e9999fd60258a064da6309019865503fd 100644 (file)
@@ -69,6 +69,7 @@
 #import "ResourceRequest.h"
 #import "PlatformScreen.h"
 #import "SelectionController.h"
+#import "SmartReplace.h"
 #import "SystemTime.h"
 #import "TextEncoding.h"
 #import "TextIterator.h"
@@ -1033,12 +1034,12 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
     bool addLeadingSpace = startPos.leadingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isStartOfParagraph(startVisiblePos);
     if (addLeadingSpace)
         if (UChar previousChar = startVisiblePos.previous().characterAfter())
-            addLeadingSpace = !m_frame->isCharacterSmartReplaceExempt(previousChar, true);
+            addLeadingSpace = !isCharacterSmartReplaceExempt(previousChar, true);
     
     bool addTrailingSpace = endPos.trailingWhitespacePosition(VP_DEFAULT_AFFINITY, true).isNull() && !isEndOfParagraph(endVisiblePos);
     if (addTrailingSpace)
         if (UChar thisChar = endVisiblePos.characterAfter())
-            addTrailingSpace = !m_frame->isCharacterSmartReplaceExempt(thisChar, false);
+            addTrailingSpace = !isCharacterSmartReplaceExempt(thisChar, false);
     
     // inspect source
     bool hasWhitespaceAtStart = false;
@@ -1305,62 +1306,6 @@ static HTMLFormElement *formElementFromDOMElement(DOMElement *element)
     return [DOMRange _wrapRange:makeRange(previous, next).get()];
 }
 
-// FIXME: The following 2 functions are copied from AppKit. It would be best to 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 NSCharacterSet *_getPreSmartSet(void)
-{
-    static RetainPtr<NSMutableCharacterSet> _preSmartSet = nil;
-    if (!_preSmartSet) {
-        _preSmartSet = [[NSMutableCharacterSet characterSetWithCharactersInString:_preSmartString] retain];
-        [_preSmartSet.get() formUnionWithCharacterSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
-        // Adding CJK ranges
-        [_preSmartSet.get() addCharactersInRange:NSMakeRange(0x1100, 256)]; // Hangul Jamo (0x1100 - 0x11FF)
-        [_preSmartSet.get() addCharactersInRange:NSMakeRange(0x2E80, 352)]; // CJK & Kangxi Radicals (0x2E80 - 0x2FDF)
-        [_preSmartSet.get() addCharactersInRange:NSMakeRange(0x2FF0, 464)]; // Ideograph Descriptions, CJK Symbols, Hiragana, Katakana, Bopomofo, Hangul Compatibility Jamo, Kanbun, & Bopomofo Ext (0x2FF0 - 0x31BF)
-        [_preSmartSet.get() addCharactersInRange:NSMakeRange(0x3200, 29392)]; // Enclosed CJK, CJK Ideographs (Uni Han & Ext A), & Yi (0x3200 - 0xA4CF)
-        [_preSmartSet.get() addCharactersInRange:NSMakeRange(0xAC00, 11183)]; // Hangul Syllables (0xAC00 - 0xD7AF)
-        [_preSmartSet.get() addCharactersInRange:NSMakeRange(0xF900, 352)]; // CJK Compatibility Ideographs (0xF900 - 0xFA5F)
-        [_preSmartSet.get() addCharactersInRange:NSMakeRange(0xFE30, 32)]; // CJK Compatibility From (0xFE30 - 0xFE4F)
-        [_preSmartSet.get() addCharactersInRange:NSMakeRange(0xFF00, 240)]; // Half/Full Width Form (0xFF00 - 0xFFEF)
-        [_preSmartSet.get() addCharactersInRange:NSMakeRange(0x20000, 0xA6D7)]; // CJK Ideograph Exntension B
-        [_preSmartSet.get() addCharactersInRange:NSMakeRange(0x2F800, 0x021E)]; // CJK Compatibility Ideographs (0x2F800 - 0x2FA1D)
-    }
-    return _preSmartSet.get();
-}
-
-static NSCharacterSet *_getPostSmartSet(void)
-{
-    static RetainPtr<NSMutableCharacterSet> _postSmartSet = nil;
-    if (!_postSmartSet) {
-        _postSmartSet = [[NSMutableCharacterSet characterSetWithCharactersInString:_postSmartString] retain];
-        [_postSmartSet.get() formUnionWithCharacterSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
-        [_postSmartSet.get() addCharactersInRange:NSMakeRange(0x1100, 256)]; // Hangul Jamo (0x1100 - 0x11FF)
-        [_postSmartSet.get() addCharactersInRange:NSMakeRange(0x2E80, 352)]; // CJK & Kangxi Radicals (0x2E80 - 0x2FDF)
-        [_postSmartSet.get() addCharactersInRange:NSMakeRange(0x2FF0, 464)]; // Ideograph Descriptions, CJK Symbols, Hiragana, Katakana, Bopomofo, Hangul Compatibility Jamo, Kanbun, & Bopomofo Ext (0x2FF0 - 0x31BF)
-        [_postSmartSet.get() addCharactersInRange:NSMakeRange(0x3200, 29392)]; // Enclosed CJK, CJK Ideographs (Uni Han & Ext A), & Yi (0x3200 - 0xA4CF)
-        [_postSmartSet.get() addCharactersInRange:NSMakeRange(0xAC00, 11183)]; // Hangul Syllables (0xAC00 - 0xD7AF)
-        [_postSmartSet.get() addCharactersInRange:NSMakeRange(0xF900, 352)]; // CJK Compatibility Ideographs (0xF900 - 0xFA5F)
-        [_postSmartSet.get() addCharactersInRange:NSMakeRange(0xFE30, 32)]; // CJK Compatibility From (0xFE30 - 0xFE4F)
-        [_postSmartSet.get() addCharactersInRange:NSMakeRange(0xFF00, 240)]; // Half/Full Width Form (0xFF00 - 0xFFEF)
-        [_postSmartSet.get() addCharactersInRange:NSMakeRange(0x20000, 0xA6D7)]; // CJK Ideograph Exntension B
-        [_postSmartSet.get() addCharactersInRange:NSMakeRange(0x2F800, 0x021E)]; // CJK Compatibility Ideographs (0x2F800 - 0x2FA1D)        
-        [_postSmartSet.get() formUnionWithCharacterSet:[NSCharacterSet punctuationCharacterSet]];
-    }
-    return _postSmartSet.get();
-}
-
-- (BOOL)isCharacterSmartReplaceExempt:(unichar)c isPreviousCharacter:(BOOL)isPreviousCharacter
-{
-    return [isPreviousCharacter ? _getPreSmartSet() : _getPostSmartSet() characterIsMember:c];
-}
-
 - (BOOL)getData:(NSData **)data andResponse:(NSURLResponse **)response forURL:(NSString *)URL
 {
     Document* doc = m_frame->document();
index e11ab45ddcb0c0c7526214d75143a450c3d548ac..2eeb1bf49320bafeee5943b06adf12e26bc01c79 100644 (file)
@@ -47,6 +47,7 @@ namespace WebCore {
 
 static UINT HTMLClipboardFormat = 0;
 static UINT BookmarkClipboardFormat = 0;
+static UINT WebSmartPasteFormat = 0;
 
 static LRESULT CALLBACK PasteboardOwnerWndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 {
@@ -97,6 +98,7 @@ Pasteboard::Pasteboard()
 
     HTMLClipboardFormat = ::RegisterClipboardFormat(L"HTML Format");
     BookmarkClipboardFormat = ::RegisterClipboardFormat(L"UniformResourceLocatorW");
+    WebSmartPasteFormat = ::RegisterClipboardFormat(L"WebKit Smart Paste Format");
 }
 
 void Pasteboard::clear()
@@ -130,6 +132,15 @@ void Pasteboard::writeSelection(Range* selectedRange, bool canSmartCopyOrDelete,
             ::GlobalFree(cbData);
         ::CloseClipboard();
     }
+
+    // enable smart-replacing later on by putting dummy data on the pasteboard
+    if (canSmartCopyOrDelete) {
+        if (::OpenClipboard(m_owner)) {
+            ::SetClipboardData(WebSmartPasteFormat, NULL);
+            ::CloseClipboard();
+        }
+        
+    }
 }
 
 void Pasteboard::writeURL(const KURL& url, const String& titleStr, Frame* frame)
@@ -220,8 +231,7 @@ void Pasteboard::writeImage(Node* node, const KURL&, const String&)
 
 bool Pasteboard::canSmartReplace()
 { 
-    // WebSmartPastePboardType is unavailable
-    return false; 
+    return ::IsClipboardFormatAvailable(WebSmartPasteFormat);
 }
 
 String Pasteboard::plainText(Frame* frame)