Changeset 161844 in webkit
- Timestamp:
- Jan 12, 2014 5:28:53 PM (10 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r161843 r161844 1 2014-01-12 Sam Weinig <sam@webkit.org> 2 3 TextBreakIterator's should support Latin-1 for all iterator types (Part 1) 4 https://bugs.webkit.org/show_bug.cgi?id=126856 5 6 Reviewed by Darin Adler. 7 8 - Do some initial cleanup before adding complete Latin-1 support. 9 10 * platform/text/TextBreakIterator.cpp: 11 Remove non-ICU acquireLineBreakIterator() implementation. 12 13 * platform/text/TextBreakIterator.h: 14 - Changes acquireLineBreakIterator() to take a StringView. 15 16 * platform/text/TextBreakIteratorICU.cpp: 17 - Refactor iterator initialization and setting of text on the iterator. 18 - Add support for using a Latin-1 provider (this is not currently used). 19 20 * platform/text/icu/UTextProviderLatin1.cpp: 21 * platform/text/icu/UTextProviderLatin1.h: 22 - Add back non-context aware Latin-1 provider (from r129662). 23 - Rename context aware provider. 24 25 * platform/text/icu/UTextProviderUTF16.cpp: 26 * platform/text/icu/UTextProviderUTF16.h: 27 - Rename context aware provider. 28 1 29 2014-01-12 Brent Fulgham <bfulgham@apple.com> 2 30 -
trunk/Source/WebCore/platform/text/TextBreakIterator.cpp
r147588 r161844 68 68 } 69 69 70 #if !USE(ICU_UNICODE)71 TextBreakIterator* acquireLineBreakIterator(const LChar* string, int length, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength)72 {73 Vector<UChar> utf16string(length);74 for (int i = 0; i < length; ++i)75 utf16string[i] = string[i];76 return acquireLineBreakIterator(utf16string.data(), length, locale, priorContext, priorContextLength);77 }78 #endif79 80 70 } // namespace WebCore -
trunk/Source/WebCore/platform/text/TextBreakIterator.h
r148791 r161844 24 24 25 25 #include <wtf/text/AtomicString.h> 26 #include <wtf/text/StringView.h> 26 27 #include <wtf/unicode/Unicode.h> 27 28 … … 39 40 40 41 TextBreakIterator* wordBreakIterator(const UChar*, int length); 41 TextBreakIterator* acquireLineBreakIterator(const LChar*, int length, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength); 42 TextBreakIterator* acquireLineBreakIterator(const UChar*, int length, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength); 42 TextBreakIterator* sentenceBreakIterator(const UChar*, int length); 43 44 TextBreakIterator* acquireLineBreakIterator(StringView, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength); 43 45 void releaseLineBreakIterator(TextBreakIterator*); 44 TextBreakIterator* sentenceBreakIterator(const UChar*, int length);45 46 46 47 int textBreakFirst(TextBreakIterator*); … … 131 132 const UChar* priorContext = priorContextLength ? &m_priorContext[priorContextCapacity - priorContextLength] : 0; 132 133 if (!m_iterator) { 133 if (m_string.is8Bit()) 134 m_iterator = acquireLineBreakIterator(m_string.characters8(), m_string.length(), m_locale, priorContext, priorContextLength); 135 else 136 m_iterator = acquireLineBreakIterator(m_string.characters16(), m_string.length(), m_locale, priorContext, priorContextLength); 134 m_iterator = acquireLineBreakIterator(m_string, m_locale, priorContext, priorContextLength); 137 135 m_cachedPriorContext = priorContext; 138 136 m_cachedPriorContextLength = priorContextLength; -
trunk/Source/WebCore/platform/text/TextBreakIteratorICU.cpp
r161817 r161844 27 27 #include "UTextProviderUTF16.h" 28 28 #include <wtf/Atomics.h> 29 #include <wtf/text/StringView.h> 29 30 #include <wtf/text/WTFString.h> 30 31 … … 33 34 namespace WebCore { 34 35 35 static TextBreakIterator* setUpIterator(bool& createdIterator, TextBreakIterator*& iterator, UBreakIteratorType type, const UChar* string, int length) 36 { 37 if (!string) 38 return 0; 39 40 if (!createdIterator) { 36 // Iterator initialization 37 38 static TextBreakIterator* initializeIterator(UBreakIteratorType type, const char* locale = currentTextBreakLocaleID()) 39 { 40 UErrorCode openStatus = U_ZERO_ERROR; 41 TextBreakIterator* iterator = reinterpret_cast<TextBreakIterator*>(ubrk_open(type, locale, 0, 0, &openStatus)); 42 ASSERT_WITH_MESSAGE(U_SUCCESS(openStatus), "ICU could not open a break iterator: %s (%d)", u_errorName(openStatus), openStatus); 43 return iterator; 44 } 45 46 #if !PLATFORM(IOS) 47 static TextBreakIterator* initializeIteratorWithRules(const char* breakRules) 48 { 49 UParseError parseStatus; 50 UErrorCode openStatus = U_ZERO_ERROR; 51 String rules(breakRules); 52 TextBreakIterator* iterator = reinterpret_cast<TextBreakIterator*>(ubrk_openRules(rules.characters(), rules.length(), 0, 0, &parseStatus, &openStatus)); 53 ASSERT_WITH_MESSAGE(U_SUCCESS(openStatus), "ICU could not open a break iterator: %s (%d)", u_errorName(openStatus), openStatus); 54 return iterator; 55 } 56 #endif // !PLATFORM(IOS) 57 58 59 // Iterator text setting 60 61 static TextBreakIterator* setTextForIterator(TextBreakIterator& iterator, StringView string) 62 { 63 if (string.is8Bit()) { 64 UTextWithBuffer textLocal; 65 textLocal.text = UTEXT_INITIALIZER; 66 textLocal.text.extraSize = sizeof(textLocal.buffer); 67 textLocal.text.pExtra = textLocal.buffer; 68 41 69 UErrorCode openStatus = U_ZERO_ERROR; 42 iterator = reinterpret_cast<TextBreakIterator*>(ubrk_open(type, currentTextBreakLocaleID(), 0, 0, &openStatus)); 43 createdIterator = true; 44 ASSERT_WITH_MESSAGE(U_SUCCESS(openStatus), "ICU could not open a break iterator: %s (%d)", u_errorName(openStatus), openStatus); 70 UText* text = openLatin1UTextProvider(&textLocal, string.characters8(), string.length(), &openStatus); 71 if (U_FAILURE(openStatus)) { 72 LOG_ERROR("uTextOpenLatin1 failed with status %d", openStatus); 73 return nullptr; 74 } 75 76 UErrorCode setTextStatus = U_ZERO_ERROR; 77 ubrk_setUText(reinterpret_cast<UBreakIterator*>(&iterator), text, &setTextStatus); 78 if (U_FAILURE(setTextStatus)) { 79 LOG_ERROR("ubrk_setUText failed with status %d", setTextStatus); 80 return nullptr; 81 } 82 83 utext_close(text); 84 } else { 85 UErrorCode setTextStatus = U_ZERO_ERROR; 86 ubrk_setText(reinterpret_cast<UBreakIterator*>(&iterator), string.characters16(), string.length(), &setTextStatus); 87 if (U_FAILURE(setTextStatus)) 88 return nullptr; 45 89 } 46 if (!iterator) 47 return 0; 48 49 UErrorCode setTextStatus = U_ZERO_ERROR; 50 ubrk_setText(reinterpret_cast<UBreakIterator*>(iterator), string, length, &setTextStatus); 51 if (U_FAILURE(setTextStatus)) 52 return 0; 53 54 return iterator; 55 } 56 57 TextBreakIterator* wordBreakIterator(const UChar* string, int length) 58 { 59 static bool createdWordBreakIterator = false; 60 static TextBreakIterator* staticWordBreakIterator; 61 return setUpIterator(createdWordBreakIterator, staticWordBreakIterator, UBRK_WORD, string, length); 62 } 63 64 static UText emptyText = UTEXT_INITIALIZER; 65 66 TextBreakIterator* acquireLineBreakIterator(const LChar* string, int length, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength) 67 { 68 UBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale); 69 if (!iterator) 70 return 0; 71 72 UTextWithBuffer textLocal; 73 textLocal.text = emptyText; 74 textLocal.text.extraSize = sizeof(textLocal.buffer); 75 textLocal.text.pExtra = textLocal.buffer; 76 77 UErrorCode openStatus = U_ZERO_ERROR; 78 UText* text = uTextOpenLatin1(&textLocal, string, length, priorContext, priorContextLength, &openStatus); 79 if (U_FAILURE(openStatus)) { 80 LOG_ERROR("textOpenUTF16 failed with status %d", openStatus); 81 return 0; 90 91 return &iterator; 92 } 93 94 static TextBreakIterator* setContextAwareTextForIterator(TextBreakIterator& iterator, StringView string, const UChar* priorContext, unsigned priorContextLength) 95 { 96 if (string.is8Bit()) { 97 UTextWithBuffer textLocal; 98 textLocal.text = UTEXT_INITIALIZER; 99 textLocal.text.extraSize = sizeof(textLocal.buffer); 100 textLocal.text.pExtra = textLocal.buffer; 101 102 UErrorCode openStatus = U_ZERO_ERROR; 103 UText* text = openLatin1ContextAwareUTextProvider(&textLocal, string.characters8(), string.length(), priorContext, priorContextLength, &openStatus); 104 if (U_FAILURE(openStatus)) { 105 LOG_ERROR("openLatin1ContextAwareUTextProvider failed with status %d", openStatus); 106 return nullptr; 107 } 108 109 UErrorCode setTextStatus = U_ZERO_ERROR; 110 ubrk_setUText(reinterpret_cast<UBreakIterator*>(&iterator), text, &setTextStatus); 111 if (U_FAILURE(setTextStatus)) { 112 LOG_ERROR("ubrk_setUText failed with status %d", setTextStatus); 113 return nullptr; 114 } 115 116 utext_close(text); 117 } else { 118 UText textLocal = UTEXT_INITIALIZER; 119 120 UErrorCode openStatus = U_ZERO_ERROR; 121 UText* text = openUTF16ContextAwareUTextProvider(&textLocal, string.characters16(), string.length(), priorContext, priorContextLength, &openStatus); 122 if (U_FAILURE(openStatus)) { 123 LOG_ERROR("openUTF16ContextAwareUTextProvider failed with status %d", openStatus); 124 return 0; 125 } 126 127 UErrorCode setTextStatus = U_ZERO_ERROR; 128 ubrk_setUText(reinterpret_cast<UBreakIterator*>(&iterator), text, &setTextStatus); 129 if (U_FAILURE(setTextStatus)) { 130 LOG_ERROR("ubrk_setUText failed with status %d", setTextStatus); 131 return nullptr; 132 } 133 134 utext_close(text); 82 135 } 83 136 84 UErrorCode setTextStatus = U_ZERO_ERROR; 85 ubrk_setUText(iterator, text, &setTextStatus); 86 if (U_FAILURE(setTextStatus)) { 87 LOG_ERROR("ubrk_setUText failed with status %d", setTextStatus); 88 return 0; 89 } 90 91 utext_close(text); 92 93 return reinterpret_cast<TextBreakIterator*>(iterator); 94 } 95 96 TextBreakIterator* acquireLineBreakIterator(const UChar* string, int length, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength) 97 { 98 UBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale); 99 if (!iterator) 100 return 0; 101 102 UText textLocal = UTEXT_INITIALIZER; 103 104 UErrorCode openStatus = U_ZERO_ERROR; 105 UText* text = uTextOpenUTF16(&textLocal, string, length, priorContext, priorContextLength, &openStatus); 106 if (U_FAILURE(openStatus)) { 107 LOG_ERROR("textOpenUTF16 failed with status %d", openStatus); 108 return 0; 109 } 110 111 UErrorCode setTextStatus = U_ZERO_ERROR; 112 ubrk_setUText(iterator, text, &setTextStatus); 113 if (U_FAILURE(setTextStatus)) { 114 LOG_ERROR("ubrk_setUText failed with status %d", setTextStatus); 115 return 0; 116 } 117 118 utext_close(text); 119 120 return reinterpret_cast<TextBreakIterator*>(iterator); 121 } 122 123 void releaseLineBreakIterator(TextBreakIterator* iterator) 124 { 125 ASSERT_ARG(iterator, iterator); 126 127 LineBreakIteratorPool::sharedPool().put(reinterpret_cast<UBreakIterator*>(iterator)); 128 } 129 130 static TextBreakIterator* nonSharedCharacterBreakIterator; 131 132 static inline bool compareAndSwapNonSharedCharacterBreakIterator(TextBreakIterator* expected, TextBreakIterator* newValue) 133 { 134 #if ENABLE(COMPARE_AND_SWAP) 135 return weakCompareAndSwap(reinterpret_cast<void**>(&nonSharedCharacterBreakIterator), expected, newValue); 136 #else 137 DEFINE_STATIC_LOCAL(Mutex, nonSharedCharacterBreakIteratorMutex, ()); 138 MutexLocker locker(nonSharedCharacterBreakIteratorMutex); 139 if (nonSharedCharacterBreakIterator != expected) 140 return false; 141 nonSharedCharacterBreakIterator = newValue; 142 return true; 143 #endif 144 } 145 146 NonSharedCharacterBreakIterator::NonSharedCharacterBreakIterator(const UChar* buffer, int length) 147 { 148 m_iterator = nonSharedCharacterBreakIterator; 149 bool createdIterator = m_iterator && compareAndSwapNonSharedCharacterBreakIterator(m_iterator, 0); 150 m_iterator = setUpIterator(createdIterator, m_iterator, UBRK_CHARACTER, buffer, length); 151 } 152 153 NonSharedCharacterBreakIterator::~NonSharedCharacterBreakIterator() 154 { 155 if (!compareAndSwapNonSharedCharacterBreakIterator(0, m_iterator)) 156 ubrk_close(reinterpret_cast<UBreakIterator*>(m_iterator)); 157 } 158 159 TextBreakIterator* sentenceBreakIterator(const UChar* string, int length) 160 { 161 static bool createdSentenceBreakIterator = false; 162 static TextBreakIterator* staticSentenceBreakIterator; 163 return setUpIterator(createdSentenceBreakIterator, staticSentenceBreakIterator, UBRK_SENTENCE, string, length); 164 } 165 166 int textBreakFirst(TextBreakIterator* iterator) 167 { 168 return ubrk_first(reinterpret_cast<UBreakIterator*>(iterator)); 169 } 170 171 int textBreakLast(TextBreakIterator* iterator) 172 { 173 return ubrk_last(reinterpret_cast<UBreakIterator*>(iterator)); 174 } 175 176 int textBreakNext(TextBreakIterator* iterator) 177 { 178 return ubrk_next(reinterpret_cast<UBreakIterator*>(iterator)); 179 } 180 181 int textBreakPrevious(TextBreakIterator* iterator) 182 { 183 return ubrk_previous(reinterpret_cast<UBreakIterator*>(iterator)); 184 } 185 186 int textBreakPreceding(TextBreakIterator* iterator, int pos) 187 { 188 return ubrk_preceding(reinterpret_cast<UBreakIterator*>(iterator), pos); 189 } 190 191 int textBreakFollowing(TextBreakIterator* iterator, int pos) 192 { 193 return ubrk_following(reinterpret_cast<UBreakIterator*>(iterator), pos); 194 } 195 196 int textBreakCurrent(TextBreakIterator* iterator) 197 { 198 return ubrk_current(reinterpret_cast<UBreakIterator*>(iterator)); 199 } 200 201 bool isTextBreak(TextBreakIterator* iterator, int position) 202 { 203 return ubrk_isBoundary(reinterpret_cast<UBreakIterator*>(iterator), position); 204 } 205 206 bool isWordTextBreak(TextBreakIterator* iterator) 207 { 208 int ruleStatus = ubrk_getRuleStatus(reinterpret_cast<UBreakIterator*>(iterator)); 209 return ruleStatus != UBRK_WORD_NONE; 210 } 211 212 #if !PLATFORM(IOS) 213 static TextBreakIterator* setUpIteratorWithRules(bool& createdIterator, TextBreakIterator*& iterator, const char* breakRules, const UChar* string, int length) 214 { 215 if (!string) 216 return 0; 217 218 if (!createdIterator) { 219 UParseError parseStatus; 220 UErrorCode openStatus = U_ZERO_ERROR; 221 String rules(breakRules); 222 iterator = reinterpret_cast<TextBreakIterator*>(ubrk_openRules(rules.characters(), rules.length(), 0, 0, &parseStatus, &openStatus)); 223 createdIterator = true; 224 ASSERT_WITH_MESSAGE(U_SUCCESS(openStatus), "ICU could not open a break iterator: %s (%d)", u_errorName(openStatus), openStatus); 225 } 226 if (!iterator) 227 return 0; 228 229 UErrorCode setTextStatus = U_ZERO_ERROR; 230 ubrk_setText(reinterpret_cast<UBreakIterator*>(iterator), string, length, &setTextStatus); 231 if (U_FAILURE(setTextStatus)) 232 return 0; 233 234 return iterator; 235 } 236 #endif // !PLATFORM(IOS) 237 238 TextBreakIterator* cursorMovementIterator(const UChar* string, int length) 137 return &iterator; 138 } 139 140 141 // Static iterators 142 143 TextBreakIterator* wordBreakIterator(const UChar* buffer, int length) 144 { 145 static TextBreakIterator* staticWordBreakIterator = initializeIterator(UBRK_WORD); 146 if (!staticWordBreakIterator) 147 return nullptr; 148 149 return setTextForIterator(*staticWordBreakIterator, StringView(buffer, length)); 150 } 151 152 TextBreakIterator* sentenceBreakIterator(const UChar* buffer, int length) 153 { 154 static TextBreakIterator* staticSentenceBreakIterator = initializeIterator(UBRK_SENTENCE); 155 if (!staticSentenceBreakIterator) 156 return nullptr; 157 158 return setTextForIterator(*staticSentenceBreakIterator, StringView(buffer, length)); 159 } 160 161 TextBreakIterator* cursorMovementIterator(const UChar* buffer, int length) 239 162 { 240 163 #if !PLATFORM(IOS) … … 321 244 "!!safe_reverse;" 322 245 "!!safe_forward;"; 323 static bool createdCursorMovementIterator = false; 324 static TextBreakIterator* staticCursorMovementIterator; 325 return setUpIteratorWithRules(createdCursorMovementIterator, staticCursorMovementIterator, kRules, string, length); 246 static TextBreakIterator* staticCursorMovementIterator = initializeIteratorWithRules(kRules); 326 247 #else // PLATFORM(IOS) 327 248 // Use the special Thai character break iterator for all locales 328 static bool createdCursorBreakIterator;329 static TextBreakIterator* staticCursorBreakIterator; 330 331 if (!st ring)249 static TextBreakIterator* staticCursorMovementIterator = createSharedIterator(UBRK_CHARACTER, "th"); 250 #endif // !PLATFORM(IOS) 251 252 if (!staticCursorMovementIterator) 332 253 return nullptr; 333 254 334 if (!createdCursorBreakIterator) {335 UErrorCode openStatus = U_ZERO_ERROR; 336 staticCursorBreakIterator = reinterpret_cast<TextBreakIterator*>(ubrk_open(UBRK_CHARACTER, "th", 0, 0, &openStatus)); 337 createdCursorBreakIterator = true; 338 ASSERT_WITH_MESSAGE(U_SUCCESS(openStatus), "ICU could not open a break iterator: %s (%d)", u_errorName(openStatus), openStatus); 339 }340 if (! staticCursorBreakIterator)255 return setTextForIterator(*staticCursorMovementIterator, StringView(buffer, length)); 256 } 257 258 TextBreakIterator* acquireLineBreakIterator(StringView string, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength) 259 { 260 TextBreakIterator* iterator = reinterpret_cast<TextBreakIterator*>(LineBreakIteratorPool::sharedPool().take(locale)); 261 if (!iterator) 341 262 return nullptr; 342 263 343 UErrorCode setTextStatus = U_ZERO_ERROR; 344 ubrk_setText(reinterpret_cast<UBreakIterator*>(staticCursorBreakIterator), string, length, &setTextStatus); 345 if (U_FAILURE(setTextStatus)) 346 return nullptr; 347 348 return staticCursorBreakIterator; 349 #endif // !PLATFORM(IOS) 350 } 351 352 } 264 return setContextAwareTextForIterator(*iterator, string, priorContext, priorContextLength); 265 } 266 267 void releaseLineBreakIterator(TextBreakIterator* iterator) 268 { 269 ASSERT_ARG(iterator, iterator); 270 271 LineBreakIteratorPool::sharedPool().put(reinterpret_cast<UBreakIterator*>(iterator)); 272 } 273 274 static TextBreakIterator* nonSharedCharacterBreakIterator; 275 276 static inline bool compareAndSwapNonSharedCharacterBreakIterator(TextBreakIterator* expected, TextBreakIterator* newValue) 277 { 278 #if ENABLE(COMPARE_AND_SWAP) 279 return weakCompareAndSwap(reinterpret_cast<void**>(&nonSharedCharacterBreakIterator), expected, newValue); 280 #else 281 DEFINE_STATIC_LOCAL(Mutex, nonSharedCharacterBreakIteratorMutex, ()); 282 MutexLocker locker(nonSharedCharacterBreakIteratorMutex); 283 if (nonSharedCharacterBreakIterator != expected) 284 return false; 285 nonSharedCharacterBreakIterator = newValue; 286 return true; 287 #endif 288 } 289 290 NonSharedCharacterBreakIterator::NonSharedCharacterBreakIterator(const UChar* buffer, int length) 291 { 292 m_iterator = nonSharedCharacterBreakIterator; 293 294 bool createdIterator = m_iterator && compareAndSwapNonSharedCharacterBreakIterator(m_iterator, 0); 295 if (!createdIterator) 296 m_iterator = initializeIterator(UBRK_CHARACTER); 297 if (!m_iterator) 298 return; 299 300 m_iterator = setTextForIterator(*m_iterator, StringView(buffer, length)); 301 } 302 303 NonSharedCharacterBreakIterator::~NonSharedCharacterBreakIterator() 304 { 305 if (!compareAndSwapNonSharedCharacterBreakIterator(0, m_iterator)) 306 ubrk_close(reinterpret_cast<UBreakIterator*>(m_iterator)); 307 } 308 309 310 // Iterator implemenation. 311 312 int textBreakFirst(TextBreakIterator* iterator) 313 { 314 return ubrk_first(reinterpret_cast<UBreakIterator*>(iterator)); 315 } 316 317 int textBreakLast(TextBreakIterator* iterator) 318 { 319 return ubrk_last(reinterpret_cast<UBreakIterator*>(iterator)); 320 } 321 322 int textBreakNext(TextBreakIterator* iterator) 323 { 324 return ubrk_next(reinterpret_cast<UBreakIterator*>(iterator)); 325 } 326 327 int textBreakPrevious(TextBreakIterator* iterator) 328 { 329 return ubrk_previous(reinterpret_cast<UBreakIterator*>(iterator)); 330 } 331 332 int textBreakPreceding(TextBreakIterator* iterator, int pos) 333 { 334 return ubrk_preceding(reinterpret_cast<UBreakIterator*>(iterator), pos); 335 } 336 337 int textBreakFollowing(TextBreakIterator* iterator, int pos) 338 { 339 return ubrk_following(reinterpret_cast<UBreakIterator*>(iterator), pos); 340 } 341 342 int textBreakCurrent(TextBreakIterator* iterator) 343 { 344 return ubrk_current(reinterpret_cast<UBreakIterator*>(iterator)); 345 } 346 347 bool isTextBreak(TextBreakIterator* iterator, int position) 348 { 349 return ubrk_isBoundary(reinterpret_cast<UBreakIterator*>(iterator), position); 350 } 351 352 bool isWordTextBreak(TextBreakIterator* iterator) 353 { 354 int ruleStatus = ubrk_getRuleStatus(reinterpret_cast<UBreakIterator*>(iterator)); 355 return ruleStatus != UBRK_WORD_NONE; 356 } 357 358 } -
trunk/Source/WebCore/platform/text/icu/UTextProvider.h
r161817 r161844 47 47 } 48 48 49 inline void uTextInitialize(UText* text, const UTextFuncs* funcs, const void* string, unsigned length, const UChar* priorContext, int priorContextLength)49 inline void initializeContextAwareUTextProvider(UText* text, const UTextFuncs* funcs, const void* string, unsigned length, const UChar* priorContext, int priorContextLength) 50 50 { 51 51 text->pFuncs = funcs; -
trunk/Source/WebCore/platform/text/icu/UTextProviderLatin1.cpp
r161817 r161844 32 32 namespace WebCore { 33 33 34 static inline UTextProviderContext textLatin1GetCurrentContext(const UText* text) 34 // Latin1 provider 35 36 static UText* uTextLatin1Clone(UText*, const UText*, UBool, UErrorCode*); 37 static int64_t uTextLatin1NativeLength(UText*); 38 static UBool uTextLatin1Access(UText*, int64_t, UBool); 39 static int32_t uTextLatin1Extract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode*); 40 static int64_t uTextLatin1MapOffsetToNative(const UText*); 41 static int32_t uTextLatin1MapNativeIndexToUTF16(const UText*, int64_t); 42 static void uTextLatin1Close(UText*); 43 44 static struct UTextFuncs uTextLatin1Funcs = { 45 sizeof(UTextFuncs), 46 0, 47 0, 48 0, 49 uTextLatin1Clone, 50 uTextLatin1NativeLength, 51 uTextLatin1Access, 52 uTextLatin1Extract, 53 nullptr, 54 nullptr, 55 uTextLatin1MapOffsetToNative, 56 uTextLatin1MapNativeIndexToUTF16, 57 uTextLatin1Close, 58 nullptr, 59 nullptr, 60 nullptr 61 }; 62 63 static UText* uTextLatin1Clone(UText* destination, const UText* source, UBool deep, UErrorCode* status) 64 { 65 ASSERT_UNUSED(deep, !deep); 66 67 if (U_FAILURE(*status)) 68 return 0; 69 70 UText* result = utext_setup(destination, sizeof(UChar) * (UTextWithBufferInlineCapacity + 1), status); 71 if (U_FAILURE(*status)) 72 return destination; 73 74 result->providerProperties = source->providerProperties; 75 76 // Point at the same position, but with an empty buffer. 77 result->chunkNativeStart = source->chunkNativeStart; 78 result->chunkNativeLimit = source->chunkNativeStart; 79 result->nativeIndexingLimit = source->chunkNativeStart; 80 result->chunkOffset = 0; 81 result->context = source->context; 82 result->a = source->a; 83 result->pFuncs = &uTextLatin1Funcs; 84 result->chunkContents = (UChar*)result->pExtra; 85 memset(const_cast<UChar*>(result->chunkContents), 0, sizeof(UChar) * (UTextWithBufferInlineCapacity + 1)); 86 87 return result; 88 } 89 90 static int64_t uTextLatin1NativeLength(UText* uText) 91 { 92 return uText->a; 93 } 94 95 static UBool uTextLatin1Access(UText* uText, int64_t index, UBool forward) 96 { 97 int64_t length = uText->a; 98 99 if (forward) { 100 if (index < uText->chunkNativeLimit && index >= uText->chunkNativeStart) { 101 // Already inside the buffer. Set the new offset. 102 uText->chunkOffset = static_cast<int32_t>(index - uText->chunkNativeStart); 103 return TRUE; 104 } 105 if (index >= length && uText->chunkNativeLimit == length) { 106 // Off the end of the buffer, but we can't get it. 107 uText->chunkOffset = uText->chunkLength; 108 return FALSE; 109 } 110 } else { 111 if (index <= uText->chunkNativeLimit && index > uText->chunkNativeStart) { 112 // Already inside the buffer. Set the new offset. 113 uText->chunkOffset = static_cast<int32_t>(index - uText->chunkNativeStart); 114 return TRUE; 115 } 116 if (!index && !uText->chunkNativeStart) { 117 // Already at the beginning; can't go any farther. 118 uText->chunkOffset = 0; 119 return FALSE; 120 } 121 } 122 123 if (forward) { 124 uText->chunkNativeStart = index; 125 uText->chunkNativeLimit = uText->chunkNativeStart + UTextWithBufferInlineCapacity; 126 if (uText->chunkNativeLimit > length) 127 uText->chunkNativeLimit = length; 128 129 uText->chunkOffset = 0; 130 } else { 131 uText->chunkNativeLimit = index; 132 if (uText->chunkNativeLimit > length) 133 uText->chunkNativeLimit = length; 134 135 uText->chunkNativeStart = uText->chunkNativeLimit - UTextWithBufferInlineCapacity; 136 if (uText->chunkNativeStart < 0) 137 uText->chunkNativeStart = 0; 138 139 uText->chunkOffset = uText->chunkLength; 140 } 141 uText->chunkLength = static_cast<int32_t>(uText->chunkNativeLimit - uText->chunkNativeStart); 142 143 StringImpl::copyChars(const_cast<UChar*>(uText->chunkContents), static_cast<const LChar*>(uText->context) + uText->chunkNativeStart, static_cast<unsigned>(uText->chunkLength)); 144 145 uText->nativeIndexingLimit = uText->chunkLength; 146 147 return TRUE; 148 } 149 150 static int32_t uTextLatin1Extract(UText* uText, int64_t start, int64_t limit, UChar* dest, int32_t destCapacity, UErrorCode* status) 151 { 152 int64_t length = uText->a; 153 if (U_FAILURE(*status)) 154 return 0; 155 156 if (destCapacity < 0 || (!dest && destCapacity > 0)) { 157 *status = U_ILLEGAL_ARGUMENT_ERROR; 158 return 0; 159 } 160 161 if (start < 0 || start > limit || (limit - start) > INT32_MAX) { 162 *status = U_INDEX_OUTOFBOUNDS_ERROR; 163 return 0; 164 } 165 166 if (start > length) 167 start = length; 168 if (limit > length) 169 limit = length; 170 171 length = limit - start; 172 173 if (!length) 174 return 0; 175 176 if (destCapacity > 0 && !dest) { 177 int32_t trimmedLength = length; 178 if (trimmedLength > destCapacity) 179 trimmedLength = destCapacity; 180 181 StringImpl::copyChars(dest, static_cast<const LChar*>(uText->context) + start, static_cast<unsigned>(trimmedLength)); 182 } 183 184 if (length < destCapacity) { 185 dest[length] = 0; 186 if (*status == U_STRING_NOT_TERMINATED_WARNING) 187 *status = U_ZERO_ERROR; 188 } else if (length == destCapacity) 189 *status = U_STRING_NOT_TERMINATED_WARNING; 190 else 191 *status = U_BUFFER_OVERFLOW_ERROR; 192 193 return length; 194 } 195 196 static int64_t uTextLatin1MapOffsetToNative(const UText* uText) 197 { 198 return uText->chunkNativeStart + uText->chunkOffset; 199 } 200 201 static int32_t uTextLatin1MapNativeIndexToUTF16(const UText* uText, int64_t nativeIndex) 202 { 203 ASSERT_UNUSED(uText, uText->chunkNativeStart >= nativeIndex); 204 ASSERT_UNUSED(uText, nativeIndex < uText->chunkNativeLimit); 205 return nativeIndex; 206 } 207 208 static void uTextLatin1Close(UText* uText) 209 { 210 uText->context = nullptr; 211 } 212 213 UText* openLatin1UTextProvider(UTextWithBuffer* utWithBuffer, const LChar* string, unsigned length, UErrorCode* status) 214 { 215 if (U_FAILURE(*status)) 216 return nullptr; 217 if (!string || length > static_cast<unsigned>(std::numeric_limits<int32_t>::max())) { 218 *status = U_ILLEGAL_ARGUMENT_ERROR; 219 return nullptr; 220 } 221 UText* text = utext_setup(&utWithBuffer->text, sizeof(utWithBuffer->buffer), status); 222 if (U_FAILURE(*status)) { 223 ASSERT(!text); 224 return nullptr; 225 } 226 227 text->context = string; 228 text->a = length; 229 text->pFuncs = &uTextLatin1Funcs; 230 text->chunkContents = (UChar*)text->pExtra; 231 memset(const_cast<UChar*>(text->chunkContents), 0, sizeof(UChar) * (UTextWithBufferInlineCapacity + 1)); 232 233 return text; 234 } 235 236 237 // Latin1ContextAware provider 238 239 static UText* uTextLatin1ContextAwareClone(UText*, const UText*, UBool, UErrorCode*); 240 static int64_t uTextLatin1ContextAwareNativeLength(UText*); 241 static UBool uTextLatin1ContextAwareAccess(UText*, int64_t, UBool); 242 static int32_t uTextLatin1ContextAwareExtract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode*); 243 static void uTextLatin1ContextAwareClose(UText*); 244 245 static const struct UTextFuncs textLatin1ContextAwareFuncs = { 246 sizeof(UTextFuncs), 247 0, 248 0, 249 0, 250 uTextLatin1ContextAwareClone, 251 uTextLatin1ContextAwareNativeLength, 252 uTextLatin1ContextAwareAccess, 253 uTextLatin1ContextAwareExtract, 254 nullptr, 255 nullptr, 256 nullptr, 257 nullptr, 258 uTextLatin1ContextAwareClose, 259 nullptr, 260 nullptr, 261 nullptr 262 }; 263 264 static inline UTextProviderContext textLatin1ContextAwareGetCurrentContext(const UText* text) 35 265 { 36 266 if (!text->chunkContents) … … 39 269 } 40 270 41 static void textLatin1 MoveInPrimaryContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward)271 static void textLatin1ContextAwareMoveInPrimaryContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward) 42 272 { 43 273 ASSERT(text->chunkContents == text->pExtra); … … 64 294 } 65 295 66 static void textLatin1 SwitchToPrimaryContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward)296 static void textLatin1ContextAwareSwitchToPrimaryContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward) 67 297 { 68 298 ASSERT(!text->chunkContents || text->chunkContents == text->q); 69 299 text->chunkContents = static_cast<const UChar*>(text->pExtra); 70 textLatin1 MoveInPrimaryContext(text, nativeIndex, nativeLength, forward);71 } 72 73 static void textLatin1 MoveInPriorContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward)300 textLatin1ContextAwareMoveInPrimaryContext(text, nativeIndex, nativeLength, forward); 301 } 302 303 static void textLatin1ContextAwareMoveInPriorContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward) 74 304 { 75 305 ASSERT(text->chunkContents == text->q); … … 87 317 } 88 318 89 static void textLatin1 SwitchToPriorContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward)319 static void textLatin1ContextAwareSwitchToPriorContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward) 90 320 { 91 321 ASSERT(!text->chunkContents || text->chunkContents == text->pExtra); 92 322 text->chunkContents = static_cast<const UChar*>(text->q); 93 textLatin1MoveInPriorContext(text, nativeIndex, nativeLength, forward); 94 } 95 96 // -- Begin Latin-1 provider functions -- 97 98 static UText* uTextLatin1Clone(UText*, const UText*, UBool, UErrorCode*); 99 static int64_t uTextLatin1NativeLength(UText*); 100 static UBool uTextLatin1Access(UText*, int64_t, UBool); 101 static int32_t uTextLatin1Extract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode*); 102 static void uTextLatin1Close(UText*); 103 104 static UText* uTextLatin1Clone(UText* destination, const UText* source, UBool deep, UErrorCode* status) 323 textLatin1ContextAwareMoveInPriorContext(text, nativeIndex, nativeLength, forward); 324 } 325 326 static UText* uTextLatin1ContextAwareClone(UText* destination, const UText* source, UBool deep, UErrorCode* status) 105 327 { 106 328 return uTextCloneImpl(destination, source, deep, status); 107 329 } 108 330 109 static int64_t uTextLatin1 NativeLength(UText* text)331 static int64_t uTextLatin1ContextAwareNativeLength(UText* text) 110 332 { 111 333 return text->a + text->b; 112 334 } 113 335 114 static UBool uTextLatin1 Access(UText* text, int64_t nativeIndex, UBool forward)336 static UBool uTextLatin1ContextAwareAccess(UText* text, int64_t nativeIndex, UBool forward) 115 337 { 116 338 if (!text->context) 117 339 return FALSE; 118 int64_t nativeLength = uTextLatin1 NativeLength(text);340 int64_t nativeLength = uTextLatin1ContextAwareNativeLength(text); 119 341 UBool isAccessible; 120 342 if (uTextAccessInChunkOrOutOfRange(text, nativeIndex, nativeLength, forward, isAccessible)) 121 343 return isAccessible; 122 344 nativeIndex = uTextAccessPinIndex(nativeIndex, nativeLength); 123 UTextProviderContext currentContext = textLatin1 GetCurrentContext(text);345 UTextProviderContext currentContext = textLatin1ContextAwareGetCurrentContext(text); 124 346 UTextProviderContext newContext = uTextProviderContext(text, nativeIndex, forward); 125 347 ASSERT(newContext != UTextProviderContext::NoContext); 126 348 if (newContext == currentContext) { 127 349 if (currentContext == UTextProviderContext::PrimaryContext) 128 textLatin1 MoveInPrimaryContext(text, nativeIndex, nativeLength, forward);350 textLatin1ContextAwareMoveInPrimaryContext(text, nativeIndex, nativeLength, forward); 129 351 else 130 textLatin1 MoveInPriorContext(text, nativeIndex, nativeLength, forward);352 textLatin1ContextAwareMoveInPriorContext(text, nativeIndex, nativeLength, forward); 131 353 } else if (newContext == UTextProviderContext::PrimaryContext) 132 textLatin1 SwitchToPrimaryContext(text, nativeIndex, nativeLength, forward);354 textLatin1ContextAwareSwitchToPrimaryContext(text, nativeIndex, nativeLength, forward); 133 355 else { 134 356 ASSERT(newContext == UTextProviderContext::PriorContext); 135 textLatin1 SwitchToPriorContext(text, nativeIndex, nativeLength, forward);357 textLatin1ContextAwareSwitchToPriorContext(text, nativeIndex, nativeLength, forward); 136 358 } 137 359 return TRUE; 138 360 } 139 361 140 static int32_t uTextLatin1 Extract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode* errorCode)362 static int32_t uTextLatin1ContextAwareExtract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode* errorCode) 141 363 { 142 364 // In the present context, this text provider is used only with ICU functions … … 147 369 } 148 370 149 static void uTextLatin1Close(UText* text) 150 { 151 text->context = 0; 152 } 153 154 // -- End Latin-1 provider functions -- 155 156 static const struct UTextFuncs textLatin1Funcs = { 157 sizeof(UTextFuncs), 158 0, 0, 0, 159 uTextLatin1Clone, 160 uTextLatin1NativeLength, 161 uTextLatin1Access, 162 uTextLatin1Extract, 163 0, 0, 0, 0, 164 uTextLatin1Close, 165 0, 0, 0, 166 }; 167 168 UText* uTextOpenLatin1(UTextWithBuffer* utWithBuffer, const LChar* string, unsigned length, const UChar* priorContext, int priorContextLength, UErrorCode* status) 371 static void uTextLatin1ContextAwareClose(UText* text) 372 { 373 text->context = nullptr; 374 } 375 376 UText* openLatin1ContextAwareUTextProvider(UTextWithBuffer* utWithBuffer, const LChar* string, unsigned length, const UChar* priorContext, int priorContextLength, UErrorCode* status) 169 377 { 170 378 if (U_FAILURE(*status)) … … 179 387 return 0; 180 388 } 181 uTextInitialize(text, &textLatin1Funcs, string, length, priorContext, priorContextLength); 389 390 initializeContextAwareUTextProvider(text, &textLatin1ContextAwareFuncs, string, length, priorContext, priorContextLength); 182 391 return text; 183 392 } -
trunk/Source/WebCore/platform/text/icu/UTextProviderLatin1.h
r161817 r161844 39 39 }; 40 40 41 UText* uTextOpenLatin1(UTextWithBuffer* utWithBuffer, const LChar* string, unsigned length, const UChar* priorContext, int priorContextLength, UErrorCode* status); 41 UText* openLatin1UTextProvider(UTextWithBuffer* utWithBuffer, const LChar* string, unsigned length, UErrorCode* status); 42 UText* openLatin1ContextAwareUTextProvider(UTextWithBuffer* utWithBuffer, const LChar* string, unsigned length, const UChar* priorContext, int priorContextLength, UErrorCode* status); 42 43 43 44 } // namespace WebCore -
trunk/Source/WebCore/platform/text/icu/UTextProviderUTF16.cpp
r161817 r161844 31 31 namespace WebCore { 32 32 33 static inline UTextProviderContext textUTF16GetCurrentContext(const UText* text) 33 // UTF16ContextAware provider 34 35 static UText* uTextUTF16ContextAwareClone(UText*, const UText*, UBool, UErrorCode*); 36 static int64_t uTextUTF16ContextAwareNativeLength(UText*); 37 static UBool uTextUTF16ContextAwareAccess(UText*, int64_t, UBool); 38 static int32_t uTextUTF16ContextAwareExtract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode*); 39 static void uTextUTF16ContextAwareClose(UText*); 40 41 static const struct UTextFuncs textUTF16ContextAwareFuncs = { 42 sizeof(UTextFuncs), 43 0, 44 0, 45 0, 46 uTextUTF16ContextAwareClone, 47 uTextUTF16ContextAwareNativeLength, 48 uTextUTF16ContextAwareAccess, 49 uTextUTF16ContextAwareExtract, 50 nullptr, 51 nullptr, 52 nullptr, 53 nullptr, 54 uTextUTF16ContextAwareClose, 55 nullptr, 56 nullptr, 57 nullptr 58 }; 59 60 static inline UTextProviderContext textUTF16ContextAwareGetCurrentContext(const UText* text) 34 61 { 35 62 if (!text->chunkContents) … … 38 65 } 39 66 40 static void textUTF16 MoveInPrimaryContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward)67 static void textUTF16ContextAwareMoveInPrimaryContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward) 41 68 { 42 69 ASSERT(text->chunkContents == text->p); … … 56 83 } 57 84 58 static void textUTF16 SwitchToPrimaryContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward)85 static void textUTF16ContextAwareSwitchToPrimaryContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward) 59 86 { 60 87 ASSERT(!text->chunkContents || text->chunkContents == text->q); 61 88 text->chunkContents = static_cast<const UChar*>(text->p); 62 textUTF16 MoveInPrimaryContext(text, nativeIndex, nativeLength, forward);89 textUTF16ContextAwareMoveInPrimaryContext(text, nativeIndex, nativeLength, forward); 63 90 } 64 91 65 static void textUTF16 MoveInPriorContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward)92 static void textUTF16ContextAwareMoveInPriorContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward) 66 93 { 67 94 ASSERT(text->chunkContents == text->q); … … 79 106 } 80 107 81 static void textUTF16 SwitchToPriorContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward)108 static void textUTF16ContextAwareSwitchToPriorContext(UText* text, int64_t nativeIndex, int64_t nativeLength, UBool forward) 82 109 { 83 110 ASSERT(!text->chunkContents || text->chunkContents == text->p); 84 111 text->chunkContents = static_cast<const UChar*>(text->q); 85 textUTF16 MoveInPriorContext(text, nativeIndex, nativeLength, forward);112 textUTF16ContextAwareMoveInPriorContext(text, nativeIndex, nativeLength, forward); 86 113 } 87 114 88 // -- Begin UTF-16 provider functions -- 89 90 static UText* uTextUTF16Clone(UText*, const UText*, UBool, UErrorCode*); 91 static int64_t uTextUTF16NativeLength(UText*); 92 static UBool uTextUTF16Access(UText*, int64_t, UBool); 93 static int32_t uTextUTF16Extract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode*); 94 static void uTextUTF16Close(UText*); 95 96 static UText* uTextUTF16Clone(UText* destination, const UText* source, UBool deep, UErrorCode* status) 115 static UText* uTextUTF16ContextAwareClone(UText* destination, const UText* source, UBool deep, UErrorCode* status) 97 116 { 98 117 return uTextCloneImpl(destination, source, deep, status); 99 118 } 100 119 101 static inline int64_t uTextUTF16 NativeLength(UText* text)120 static inline int64_t uTextUTF16ContextAwareNativeLength(UText* text) 102 121 { 103 122 return text->a + text->b; 104 123 } 105 124 106 static UBool uTextUTF16 Access(UText* text, int64_t nativeIndex, UBool forward)125 static UBool uTextUTF16ContextAwareAccess(UText* text, int64_t nativeIndex, UBool forward) 107 126 { 108 127 if (!text->context) 109 128 return FALSE; 110 int64_t nativeLength = uTextUTF16 NativeLength(text);129 int64_t nativeLength = uTextUTF16ContextAwareNativeLength(text); 111 130 UBool isAccessible; 112 131 if (uTextAccessInChunkOrOutOfRange(text, nativeIndex, nativeLength, forward, isAccessible)) 113 132 return isAccessible; 114 133 nativeIndex = uTextAccessPinIndex(nativeIndex, nativeLength); 115 UTextProviderContext currentContext = textUTF16 GetCurrentContext(text);134 UTextProviderContext currentContext = textUTF16ContextAwareGetCurrentContext(text); 116 135 UTextProviderContext newContext = uTextProviderContext(text, nativeIndex, forward); 117 136 ASSERT(newContext != UTextProviderContext::NoContext); 118 137 if (newContext == currentContext) { 119 138 if (currentContext == UTextProviderContext::PrimaryContext) 120 textUTF16 MoveInPrimaryContext(text, nativeIndex, nativeLength, forward);139 textUTF16ContextAwareMoveInPrimaryContext(text, nativeIndex, nativeLength, forward); 121 140 else 122 textUTF16 MoveInPriorContext(text, nativeIndex, nativeLength, forward);141 textUTF16ContextAwareMoveInPriorContext(text, nativeIndex, nativeLength, forward); 123 142 } else if (newContext == UTextProviderContext::PrimaryContext) 124 textUTF16 SwitchToPrimaryContext(text, nativeIndex, nativeLength, forward);143 textUTF16ContextAwareSwitchToPrimaryContext(text, nativeIndex, nativeLength, forward); 125 144 else { 126 145 ASSERT(newContext == UTextProviderContext::PriorContext); 127 textUTF16 SwitchToPriorContext(text, nativeIndex, nativeLength, forward);146 textUTF16ContextAwareSwitchToPriorContext(text, nativeIndex, nativeLength, forward); 128 147 } 129 148 return TRUE; 130 149 } 131 150 132 static int32_t uTextUTF16 Extract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode* errorCode)151 static int32_t uTextUTF16ContextAwareExtract(UText*, int64_t, int64_t, UChar*, int32_t, UErrorCode* errorCode) 133 152 { 134 153 // In the present context, this text provider is used only with ICU functions … … 139 158 } 140 159 141 static void uTextUTF16C lose(UText* text)160 static void uTextUTF16ContextAwareClose(UText* text) 142 161 { 143 text->context = 0;162 text->context = nullptr; 144 163 } 145 164 146 // -- End UTF-16 provider functions -- 147 148 static const struct UTextFuncs textUTF16Funcs = { 149 sizeof(UTextFuncs), 150 0, 0, 0, 151 uTextUTF16Clone, 152 uTextUTF16NativeLength, 153 uTextUTF16Access, 154 uTextUTF16Extract, 155 0, 0, 0, 0, 156 uTextUTF16Close, 157 0, 0, 0, 158 }; 159 160 UText* uTextOpenUTF16(UText* text, const UChar* string, unsigned length, const UChar* priorContext, int priorContextLength, UErrorCode* status) 165 UText* openUTF16ContextAwareUTextProvider(UText* text, const UChar* string, unsigned length, const UChar* priorContext, int priorContextLength, UErrorCode* status) 161 166 { 162 167 if (U_FAILURE(*status)) … … 171 176 return 0; 172 177 } 173 uTextInitialize(text, &textUTF16Funcs, string, length, priorContext, priorContextLength); 178 179 initializeContextAwareUTextProvider(text, &textUTF16ContextAwareFuncs, string, length, priorContext, priorContextLength); 174 180 return text; 175 181 } -
trunk/Source/WebCore/platform/text/icu/UTextProviderUTF16.h
r161817 r161844 32 32 namespace WebCore { 33 33 34 UText* uTextOpenUTF16(UText*, const UChar*, unsigned length, const UChar* priorContext, int priorContextLength, UErrorCode*);34 UText* openUTF16ContextAwareUTextProvider(UText*, const UChar*, unsigned length, const UChar* priorContext, int priorContextLength, UErrorCode*); 35 35 36 36 } // namespace WebCore
Note: See TracChangeset
for help on using the changeset viewer.