Reviewed by Ken.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Oct 2004 17:40:13 +0000 (17:40 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 Oct 2004 17:40:13 +0000 (17:40 +0000)
        - fixed <rdar://problem/3800667> REGRESSION (Mail): double-clicking multiple spaces only selects two spaces

        * kwq/KWQTextUtilities.mm: (KWQFindWordBoundary): Moved here from the .cpp file. Changed to use the
        doubleClickAtIndex: method from NSAttributedString rather than using Unicode Utilities.
        * kwq/KWQTextUtilities.cpp: Removed.
        * WebCore.pbproj/project.pbxproj: Removed KWQTextUtilities.cpp.

        - fixed a problem that would show up using HTML editing under garbage collection

        * kwq/KWQEditCommand.mm: (-[KWQEditCommand finalize]): Fixed a [super dealloc] that should have been a
        [super finalize].

        - another small change

        * khtml/editing/visible_units.cpp: (khtml::nextWordBoundary): Tweaked a comment.

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

WebCore/ChangeLog-2005-08-23
WebCore/WebCore.pbproj/project.pbxproj
WebCore/khtml/editing/visible_units.cpp
WebCore/kwq/KWQEditCommand.mm
WebCore/kwq/KWQTextUtilities.cpp [deleted file]
WebCore/kwq/KWQTextUtilities.mm

index d57f2815c319c8e317aad6e33cc04dba74de18e2..6ca5d526a8c54619601ab70d75a658222cca1cbf 100644 (file)
@@ -1,3 +1,23 @@
+2004-10-04  Darin Adler  <darin@apple.com>
+
+        Reviewed by Ken.
+
+        - fixed <rdar://problem/3800667> REGRESSION (Mail): double-clicking multiple spaces only selects two spaces
+
+        * kwq/KWQTextUtilities.mm: (KWQFindWordBoundary): Moved here from the .cpp file. Changed to use the
+        doubleClickAtIndex: method from NSAttributedString rather than using Unicode Utilities.
+        * kwq/KWQTextUtilities.cpp: Removed.
+        * WebCore.pbproj/project.pbxproj: Removed KWQTextUtilities.cpp.
+
+        - fixed a problem that would show up using HTML editing under garbage collection
+
+        * kwq/KWQEditCommand.mm: (-[KWQEditCommand finalize]): Fixed a [super dealloc] that should have been a
+        [super finalize].
+
+        - another small change
+
+        * khtml/editing/visible_units.cpp: (khtml::nextWordBoundary): Tweaked a comment.
+
 2004-10-01  Darin Adler  <darin@apple.com>
 
         Reviewed by Ken (or arguably done by Ken, reviewed by Darin).
index 8f001a2131b0a2dcd8f4b5deadd65cc66d178f56..ebc70039f19ab557ee2822ed9cc58dd7f02752fc 100644 (file)
                                BE91FC8E06133666005E3790,
                                832556E7061DF161007B8054,
                                BC86FB90061F5C23006BB822,
-                               BE8BD8F406359F6000D3F20B,
                                842F72DD06405FDF00CC271B,
                                931D722B065FC40800C966E1,
                                51F6A3D70663BF04004D2919,
                        settings = {
                        };
                };
-               BE8BD8F206359F6000D3F20B = {
-                       fileEncoding = 30;
-                       isa = PBXFileReference;
-                       lastKnownFileType = sourcecode.cpp.cpp;
-                       path = KWQTextUtilities.cpp;
-                       refType = 4;
-                       sourceTree = "<group>";
-               };
                BE8BD8F306359F6000D3F20B = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
                        refType = 4;
                        sourceTree = "<group>";
                };
-               BE8BD8F406359F6000D3F20B = {
-                       fileRef = BE8BD8F206359F6000D3F20B;
-                       isa = PBXBuildFile;
-                       settings = {
-                       };
-               };
                BE8BD8F506359F6000D3F20B = {
                        fileRef = BE8BD8F306359F6000D3F20B;
                        isa = PBXBuildFile;
                                93386B90037045B3008635CE,
                                93386B91037045B3008635CE,
                                F587852F02DE375901EA4122,
-                               BE8BD8F206359F6000D3F20B,
                                BE8BD8F306359F6000D3F20B,
                                BE1A407106CA8A33005B28CF,
                                F587853502DE375901EA4122,
index d87950220dbe2b1edec427eef85fab32ed05007f..811f3800622a52a85f27be2ee989b4ebabbcdef6 100644 (file)
@@ -132,7 +132,7 @@ static VisiblePosition nextWordBoundary(const VisiblePosition &c, unsigned (*sea
     QString string;
     unsigned next = 0;
     while (!it.atEnd() && it.length() > 0) {
-        // Keep asking the iterator for chunks until the findWordBoundary() function
+        // Keep asking the iterator for chunks until the search function
         // returns an end value not equal to the length of the string passed to it.
         string.append(it.characters(), it.length());
         next = searchFunction(string.unicode(), string.length());
index 5a51fae23984d3e0171e297f1d842876bd394343..0cb183422898f4fbbc8a4ce3b204de9c849a5ddb 100644 (file)
@@ -52,7 +52,7 @@ using khtml::EditCommand;
 {
     if (m_impl)
         m_impl->deref();
-    [super dealloc];
+    [super finalize];
 }
 
 + (KWQEditCommand *)commandWithEditCommandImpl:(EditCommand *)impl
diff --git a/WebCore/kwq/KWQTextUtilities.cpp b/WebCore/kwq/KWQTextUtilities.cpp
deleted file mode 100644 (file)
index 254f8a2..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * Copyright (C) 2004 Apple Computer, 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.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``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 COMPUTER, INC. OR
- * 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. 
- */
-
-#import "KWQTextUtilities.h"
-
-#import <qstring.h>
-
-#import <CoreServices/CoreServices.h>
-
-void KWQFindWordBoundary(const QChar *chars, int len, int position, int *start, int *end)
-{
-    TextBreakLocatorRef breakLocator;
-    OSStatus status = UCCreateTextBreakLocator(NULL, 0, kUCTextBreakWordMask, &breakLocator);
-    if (status == noErr) {
-        UniCharArrayOffset startOffset, endOffset;
-        if (position < len) {
-            status = UCFindTextBreak(breakLocator, kUCTextBreakWordMask, kUCTextBreakLeadingEdgeMask, reinterpret_cast<const UniChar *>(chars), len, position, &endOffset);
-        } else {
-            // UCFindTextBreak treats this case as ParamErr
-            endOffset = len;
-        }
-        if (status == noErr) {
-            if (position > 0) {
-                status = UCFindTextBreak(breakLocator, kUCTextBreakWordMask, kUCTextBreakGoBackwardsMask, reinterpret_cast<const UniChar *>(chars), len, position, &startOffset);
-            } else {
-                // UCFindTextBreak treats this case as ParamErr
-                startOffset = 0;
-            }
-        }
-        UCDisposeTextBreakLocator(&breakLocator);
-        if (status == noErr) {
-            *start = startOffset;
-            *end = endOffset;
-            return;
-        }
-    }
-    
-    // If Carbon fails (why would it?), do a simple space/punctuation boundary check.
-    if (chars[position].isSpace()) {
-        int pos = position;
-        while (pos >= 0 && chars[pos].isSpace())
-            pos--;
-        *start = pos+1;
-        pos = position;
-        while (pos < (int)len && chars[pos].isSpace())
-            pos++;
-        *end = pos;
-    } else if (chars[position].isPunct()) {
-        int pos = position;
-        while (pos >= 0 && chars[pos].isPunct())
-            pos--;
-        *start = pos+1;
-        pos = position;
-        while (pos < (int)len && chars[pos].isPunct())
-            pos++;
-        *end = pos;
-    } else {
-        int pos = position;
-        while (pos >= 0 && !chars[pos].isSpace() && !chars[pos].isPunct())
-            pos--;
-        *start = pos+1;
-        pos = position;
-        while (pos < (int)len && !chars[pos].isSpace() && !chars[pos].isPunct())
-            pos++;
-        *end = pos;
-    }
-}
index a73c44fa6a7e9816066199813c60ff827266566a..cedaa5bff2f95752146272f527f391eeadc91a57 100644 (file)
 #import "KWQString.h"
 #import <AppKit/NSAttributedString.h>
 
+void KWQFindWordBoundary(const QChar *chars, int len, int position, int *start, int *end)
+{
+    NSString *string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar *>(reinterpret_cast<const unichar *>(chars))
+        length:len freeWhenDone:NO];
+    NSAttributedString *attr = [[NSAttributedString alloc] initWithString:string];
+    NSRange range = [attr doubleClickAtIndex:(position >= len) ? len - 1 : position];
+    [attr release];
+    [string release];
+    *start = range.location;
+    *end = range.location + range.length;
+}
+
 int KWQFindNextWordFromIndex(const QChar *chars, int len, int position, bool forward)
 {   
     NSString *string = [[NSString alloc] initWithCharactersNoCopy:const_cast<unichar *>(reinterpret_cast<const unichar *>(chars))