Changeset 21270 in webkit
- Timestamp:
- May 4, 2007 9:08:29 PM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebCore/ChangeLog
r21269 r21270 1 2007-05-04 Steve Falkenburg <sfalken@apple.com> 2 3 Reviewed by Oliver. 4 5 Use TextBreakIterator for sentence breaking instead of TextBoundaries. 6 7 * WebCore.xcodeproj/project.pbxproj: Added TextBreakIeratorInternalICUMac.mm 8 * editing/visible_units.cpp: 9 (WebCore::startSentenceBoundary): Call TextBreakIterator instead of TextBoundaries. 10 (WebCore::endSentenceBoundary): Call TextBreakIterator instead of TextBoundaries. 11 (WebCore::previousSentencePositionBoundary): Call TextBreakIterator instead of TextBoundaries. 12 (WebCore::nextSentencePositionBoundary): Call TextBreakIterator instead of TextBoundaries. 13 * platform/TextBoundaries.h: Removed findSentenceBoundary, findNextSentenceFromIndex. 14 * platform/TextBreakIterator.h: Added sentenceBreakIterator. 15 * platform/TextBreakIteratorICU.cpp: 16 (WebCore::setUpIterator): Add locale parameter (needed to maintain functionality that TextBoundaries code had). 17 (WebCore::characterBreakIterator): Pass en_us for locale (same as old code). 18 (WebCore::wordBreakIterator): Pass en_us for locale (same as old code). 19 (WebCore::lineBreakIterator): Pass en_us for locale (same as old code). 20 (WebCore::sentenceBreakIterator): Added. 21 * platform/TextBreakIteratorInternalICU.h: Added. 22 * platform/gdk/TemporaryLinkStubs.cpp: Removed findNextSentenceFromIndex, findSentenceBoundary. 23 (WebCore::currentTextBreakLocaleID): Added stub. 24 * platform/mac/TextBoundaries.mm: Removed currentTextBreakLocaleID, findSentenceBoundary, findNextSentenceFromIndex. 25 * platform/mac/TextBreakIteratorInternalICUMac.mm: Added. 26 (WebCore::currentTextBreakLocaleID): Moved from TextBoundaries.mm 27 * platform/qt/TextBoundaries.cpp: Removed findNextSentenceFromIndex, findSentenceBoundary. 28 1 29 2007-05-04 Adele Peterson <adele@apple.com> 2 30 -
trunk/WebCore/WebCore.xcodeproj/project.pbxproj
r21197 r21270 2262 2262 AAC8DAB10AA1002000DC0907 /* SVGMetadataElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AAC8DAAF0AA1002000DC0907 /* SVGMetadataElement.cpp */; }; 2263 2263 AAC8DAB20AA1002000DC0907 /* SVGMetadataElement.h in Headers */ = {isa = PBXBuildFile; fileRef = AAC8DAB00AA1002000DC0907 /* SVGMetadataElement.h */; }; 2264 AACF144D0BEC1EF000827982 /* TextBreakIteratorInternalICUMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = AACF144C0BEC1EF000827982 /* TextBreakIteratorInternalICUMac.mm */; }; 2264 2265 AACF7C4E0B42EE6000080BD8 /* SVGParserUtilities.h in Headers */ = {isa = PBXBuildFile; fileRef = AACF7C4C0B42EE6000080BD8 /* SVGParserUtilities.h */; }; 2265 2266 AACF7C4F0B42EE6000080BD8 /* SVGParserUtilities.cpp in Sources */ = {isa = PBXBuildFile; fileRef = AACF7C4D0B42EE6000080BD8 /* SVGParserUtilities.cpp */; }; … … 5342 5343 AAC8DAAF0AA1002000DC0907 /* SVGMetadataElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGMetadataElement.cpp; sourceTree = "<group>"; }; 5343 5344 AAC8DAB00AA1002000DC0907 /* SVGMetadataElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGMetadataElement.h; sourceTree = "<group>"; }; 5345 AACF144C0BEC1EF000827982 /* TextBreakIteratorInternalICUMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; path = TextBreakIteratorInternalICUMac.mm; sourceTree = "<group>"; }; 5344 5346 AACF7C4C0B42EE6000080BD8 /* SVGParserUtilities.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SVGParserUtilities.h; sourceTree = "<group>"; }; 5345 5347 AACF7C4D0B42EE6000080BD8 /* SVGParserUtilities.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = SVGParserUtilities.cpp; sourceTree = "<group>"; }; … … 6890 6892 isa = PBXGroup; 6891 6893 children = ( 6894 AACF144C0BEC1EF000827982 /* TextBreakIteratorInternalICUMac.mm */, 6892 6895 A7CFB3D40B7ED1180070C32D /* DragImageMac.mm */, 6893 6896 A795463D0B5C4C80007B438F /* DragDataMac.mm */, … … 12622 12625 2D9066060BE141D400956998 /* LayoutState.cpp in Sources */, 12623 12626 4A8C96EB0BE69032004EEFF0 /* SelectionControllerMac.mm in Sources */, 12627 AACF144D0BEC1EF000827982 /* TextBreakIteratorInternalICUMac.mm in Sources */, 12624 12628 ); 12625 12629 runOnlyForDeploymentPostprocessing = 0; -
trunk/WebCore/editing/visible_units.cpp
r21221 r21270 33 33 #include "RenderLayer.h" 34 34 #include "TextBoundaries.h" 35 #include "TextBreakIterator.h" 35 36 #include "TextIterator.h" 36 37 #include "htmlediting.h" … … 515 516 static unsigned startSentenceBoundary(const UChar* characters, unsigned length) 516 517 { 517 int start, end; 518 findSentenceBoundary(characters, length, length, &start, &end); 519 return start; 518 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); 519 return textBreakPreceding(iterator, length); 520 520 } 521 521 … … 527 527 static unsigned endSentenceBoundary(const UChar* characters, unsigned length) 528 528 { 529 int start, end;530 findSentenceBoundary(characters, length, 0, &start, &end);531 return end;529 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); 530 int start = textBreakPreceding(iterator, length); 531 return textBreakFollowing(iterator, start); 532 532 } 533 533 … … 539 539 static unsigned previousSentencePositionBoundary(const UChar* characters, unsigned length) 540 540 { 541 return findNextSentenceFromIndex(characters, length, length, false); 541 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); 542 return textBreakPreceding(iterator, length); 542 543 } 543 544 … … 549 550 static unsigned nextSentencePositionBoundary(const UChar* characters, unsigned length) 550 551 { 551 return findNextSentenceFromIndex(characters, length, 0, true); 552 TextBreakIterator* iterator = sentenceBreakIterator(characters, length); 553 return textBreakFollowing(iterator, 0); 552 554 } 553 555 -
trunk/WebCore/platform/TextBoundaries.h
r18712 r21270 34 34 int findNextWordFromIndex(const UChar*, int len, int position, bool forward); 35 35 36 void findSentenceBoundary(const UChar*, int len, int position, int* start, int* end);37 int findNextSentenceFromIndex(const UChar*, int len, int position, bool forward);38 39 36 } 40 37 -
trunk/WebCore/platform/TextBreakIterator.h
r19762 r21270 33 33 TextBreakIterator* wordBreakIterator(const UChar*, int length); 34 34 TextBreakIterator* lineBreakIterator(const UChar*, int length); 35 TextBreakIterator* sentenceBreakIterator(const UChar*, int length); 35 36 36 37 int textBreakFirst(TextBreakIterator*); -
trunk/WebCore/platform/TextBreakIteratorICU.cpp
r19762 r21270 23 23 #include "TextBreakIterator.h" 24 24 25 #include "TextBreakIteratorInternalICU.h" 26 25 27 #include <unicode/ubrk.h> 26 28 … … 28 30 29 31 static TextBreakIterator* setUpIterator(bool& createdIterator, TextBreakIterator*& iterator, 30 UBreakIteratorType type, const UChar* string, int length )32 UBreakIteratorType type, const UChar* string, int length, const char* locale) 31 33 { 32 34 if (!string) … … 39 41 // break iterators, though! 40 42 UErrorCode openStatus = U_ZERO_ERROR; 41 iterator = static_cast<TextBreakIterator*>(ubrk_open(type, "en_us", 0, 0, &openStatus));43 iterator = static_cast<TextBreakIterator*>(ubrk_open(type, locale, 0, 0, &openStatus)); 42 44 createdIterator = true; 43 45 } … … 58 60 static TextBreakIterator* staticCharacterBreakIterator; 59 61 return setUpIterator(createdCharacterBreakIterator, 60 staticCharacterBreakIterator, UBRK_CHARACTER, string, length );62 staticCharacterBreakIterator, UBRK_CHARACTER, string, length, "en_us"); 61 63 } 62 64 … … 66 68 static TextBreakIterator* staticWordBreakIterator; 67 69 return setUpIterator(createdWordBreakIterator, 68 staticWordBreakIterator, UBRK_WORD, string, length );70 staticWordBreakIterator, UBRK_WORD, string, length, "en_us"); 69 71 } 70 72 … … 74 76 static TextBreakIterator* staticLineBreakIterator; 75 77 return setUpIterator(createdLineBreakIterator, 76 staticLineBreakIterator, UBRK_LINE, string, length); 78 staticLineBreakIterator, UBRK_LINE, string, length, "en_us"); 79 } 80 81 TextBreakIterator* sentenceBreakIterator(const UChar* string, int length) 82 { 83 static bool createdSentenceBreakIterator = false; 84 static TextBreakIterator* staticSentenceBreakIterator; 85 return setUpIterator(createdSentenceBreakIterator, 86 staticSentenceBreakIterator, UBRK_SENTENCE, string, length, currentTextBreakLocaleID()); 77 87 } 78 88 -
trunk/WebCore/platform/gdk/TemporaryLinkStubs.cpp
r21089 r21270 99 99 void Widget::invalidateRect(const IntRect&) { notImplementedGdk(); } 100 100 101 int WebCore::findNextSentenceFromIndex(UChar const*, int, int, bool) { notImplementedGdk(); return 0; }102 void WebCore::findSentenceBoundary(UChar const*, int, int, int*, int*) { notImplementedGdk(); }103 101 int WebCore::findNextWordFromIndex(UChar const*, int, int, bool) { notImplementedGdk(); return 0; } 104 102 void WebCore::findWordBoundary(UChar const* str, int len, int position, int* start, int* end) {*start = position; *end = position; } 103 const char* WebCore::currentTextBreakLocaleID() { notImplementedGdk(); return "en_us"; } 105 104 106 105 void ChromeClientGdk::chromeDestroyed() { notImplementedGdk(); } -
trunk/WebCore/platform/mac/TextBoundaries.mm
r15438 r21270 27 27 #import "TextBoundaries.h" 28 28 29 #import <unicode/ubrk.h>30 31 29 namespace WebCore { 32 30 … … 54 52 } 55 53 56 // This code was swiped from the CarbonCore UnicodeUtilities. One change from that is to use the empty57 // string instead of the "old locale model" as the ultimate fallback. This change is per the UnicodeUtilities58 // engineer.59 //60 // NOTE: this abviously could be fairly expensive to do. If it turns out to be a bottleneck, it might61 // help to instead put a call in the iteratory initializer to set the current text break locale. Unfortunately,62 // we can not cache it across calls to our API since the result can change without our knowing (AFAIK63 // there are no notifiers for AppleTextBreakLocale and/or AppleLanguages changes).64 static char* currentTextBreakLocaleID()65 {66 const int localeStringLength = 32;67 static char localeStringBuffer[localeStringLength] = { 0 };68 char* localeString = &localeStringBuffer[0];69 70 // Empty string means "root locale", which what we use if we can't use a pref.71 72 // We get the parts string from AppleTextBreakLocale pref.73 // If that fails then look for the first language in the AppleLanguages pref.74 CFStringRef prefLocaleStr = (CFStringRef)CFPreferencesCopyValue(CFSTR("AppleTextBreakLocale"),75 kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);76 if (!prefLocaleStr) {77 CFArrayRef appleLangArr = (CFArrayRef)CFPreferencesCopyValue(CFSTR("AppleLanguages"),78 kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost);79 if (appleLangArr) {80 // Take the topmost language. Retain so that we can blindly release later.81 prefLocaleStr = (CFStringRef)CFArrayGetValueAtIndex(appleLangArr, 0);82 if (prefLocaleStr)83 CFRetain(prefLocaleStr);84 CFRelease(appleLangArr);85 }86 }87 88 if (prefLocaleStr) {89 // Canonicalize pref string in case it is not in the canonical format. This call is only available on Tiger and newer.90 CFStringRef canonLocaleCFStr = CFLocaleCreateCanonicalLanguageIdentifierFromString(kCFAllocatorDefault, prefLocaleStr);91 if (canonLocaleCFStr) {92 CFStringGetCString(canonLocaleCFStr, localeString, localeStringLength, kCFStringEncodingASCII);93 CFRelease(canonLocaleCFStr);94 }95 CFRelease(prefLocaleStr);96 }97 98 return localeString;99 54 } 100 101 void findSentenceBoundary(const UChar* chars, int len, int position, int* start, int* end)102 {103 int startPos = 0;104 int endPos = 0;105 106 UErrorCode status = U_ZERO_ERROR;107 UBreakIterator* boundary = ubrk_open(UBRK_SENTENCE, currentTextBreakLocaleID(), chars, len, &status);108 if (boundary && U_SUCCESS(status)) {109 startPos = ubrk_preceding(boundary, position);110 if (startPos == UBRK_DONE) {111 startPos = 0;112 }113 endPos = ubrk_following(boundary, startPos);114 if (endPos == UBRK_DONE)115 endPos = len;116 117 ubrk_close(boundary);118 }119 120 *start = startPos;121 *end = endPos;122 }123 124 int findNextSentenceFromIndex(const UChar* chars, int len, int position, bool forward)125 {126 int pos = 0;127 128 UErrorCode status = U_ZERO_ERROR;129 UBreakIterator* boundary = ubrk_open(UBRK_SENTENCE, currentTextBreakLocaleID(), chars, len, &status);130 if (boundary && U_SUCCESS(status)) {131 if (forward) {132 pos = ubrk_following(boundary, position);133 if (pos == UBRK_DONE)134 pos = len;135 } else {136 pos = ubrk_preceding(boundary, position);137 if (pos == UBRK_DONE)138 pos = 0;139 }140 ubrk_close(boundary);141 }142 143 return pos;144 }145 146 } -
trunk/WebCore/platform/qt/TextBoundaries.cpp
r18901 r21270 44 44 { 45 45 46 int findNextSentenceFromIndex(UChar const* buffer, int len, int position, bool forward)47 {48 QString str(reinterpret_cast<QChar const*>(buffer), len);49 notImplemented();50 return 0;51 }52 53 void findSentenceBoundary(UChar const* buffer, int len, int position, int* start, int* end)54 {55 QString str(reinterpret_cast<QChar const*>(buffer), len);56 notImplemented();57 }58 59 46 int findNextWordFromIndex(UChar const* buffer, int len, int position, bool forward) 60 47 {
Note: See TracChangeset
for help on using the changeset viewer.