Changeset 209907 in webkit


Ignore:
Timestamp:
Dec 15, 2016 9:19:32 PM (7 years ago)
Author:
mmaxfield@apple.com
Message:

Stop reinterpret_casting UBreakIterators to the undefined type TextBreakIterator
https://bugs.webkit.org/show_bug.cgi?id=165931

Source/WebCore:

Reviewed by Alex Christensen.

No new tests because there is no behavior change.

  • dom/CharacterData.cpp:

(WebCore::CharacterData::parserAppendData):

  • editing/TextCheckingHelper.cpp:

(WebCore::findMisspellings):

  • editing/VisibleUnits.cpp:

(WebCore::wordBreakIteratorForMinOffsetBoundary):
(WebCore::wordBreakIteratorForMaxOffsetBoundary):
(WebCore::isLogicalStartOfWord):
(WebCore::islogicalEndOfWord):
(WebCore::visualWordPosition):
(WebCore::startSentenceBoundary):
(WebCore::endSentenceBoundary):
(WebCore::previousSentencePositionBoundary):
(WebCore::nextSentencePositionBoundary):

  • html/HTMLInputElement.cpp:
  • html/HTMLTextAreaElement.cpp:
  • html/InputType.cpp:
  • html/TextFieldInputType.cpp:
  • html/TextInputType.cpp:
  • platform/graphics/StringTruncator.cpp:

(WebCore::textBreakAtOrPreceding):
(WebCore::boundedTextBreakFollowing):
(WebCore::rightClipToWordBuffer):

  • platform/graphics/mac/ComplexTextController.cpp:

(WebCore::ComplexTextController::offsetForPosition):

  • platform/text/TextBoundaries.cpp:

(WebCore::findNextWordFromIndex):
(WebCore::findWordBoundary):
(WebCore::findEndWordBoundary):

  • platform/text/mac/TextBoundaries.mm:

(WebCore::findNextWordFromIndex):

  • rendering/BreakLines.h:

(WebCore::nextBreakablePositionNonLoosely):
(WebCore::nextBreakablePositionLoosely):

  • rendering/RenderBlock.cpp:
  • rendering/RenderText.cpp:

(WebCore::makeCapitalized):
(WebCore::RenderText::previousOffset):
(WebCore::RenderText::previousOffsetForBackwardDeletion):
(WebCore::RenderText::nextOffset):

  • rendering/SimpleLineLayoutTextFragmentIterator.h:
  • rendering/line/LineBreaker.h:

Source/WebKit/ios:

Reviewed by Alex Christensen.

  • Misc/WebUIKitSupport.mm:

Source/WTF:

We have a class declaration for TextBreakIterator but no definition for it. When we
create an ICU UBreakIterator, we immediately reinterpret_cast it to this undefined
type, and pass it around our code inside WebCore. Then, whenever we want to actually
use this iterator, we reinterpret_cast it back to UBreakIterator. This is likely due
to some ports historically implementing breaking interators on top of other libraries
other than ICU; however, now, all ports use ICU. Because this internal type is not
helpful and just adds confusion, we should just call our breaking iterators what
they are: UBreakIterators.

This patch is a mechanical replacement of TextBreakIterator to UBreakIterator and
removes the functions we were calling which pass through directly to ubrk_*().

Reviewed by Alex Christensen.

  • wtf/text/LineBreakIteratorPoolICU.h:

(WTF::LineBreakIteratorPool::take):
(WTF::LineBreakIteratorPool::put):

  • wtf/text/StringView.cpp:

(WTF::StringView::GraphemeClusters::Iterator::Impl::computeIndexEnd):

  • wtf/text/TextBreakIterator.cpp:

(WTF::initializeIterator):
(WTF::initializeIteratorWithRules):
(WTF::setTextForIterator):
(WTF::setContextAwareTextForIterator):
(WTF::wordBreakIterator):
(WTF::sentenceBreakIterator):
(WTF::cursorMovementIterator):
(WTF::acquireLineBreakIterator):
(WTF::releaseLineBreakIterator):
(WTF::openLineBreakIterator):
(WTF::closeLineBreakIterator):
(WTF::getNonSharedCharacterBreakIterator):
(WTF::cacheNonSharedCharacterBreakIterator):
(WTF::isWordTextBreak):
(WTF::numGraphemeClusters):
(WTF::numCharactersInGraphemeClusters):
(WTF::textBreakFirst): Deleted.
(WTF::textBreakLast): Deleted.
(WTF::textBreakNext): Deleted.
(WTF::textBreakPrevious): Deleted.
(WTF::textBreakPreceding): Deleted.
(WTF::textBreakFollowing): Deleted.
(WTF::textBreakCurrent): Deleted.
(WTF::isTextBreak): Deleted.

  • wtf/text/TextBreakIterator.h:

(WTF::LazyLineBreakIterator::lastCharacter):
(WTF::LazyLineBreakIterator::secondToLastCharacter):
(WTF::LazyLineBreakIterator::setPriorContext):
(WTF::LazyLineBreakIterator::updatePriorContext):
(WTF::LazyLineBreakIterator::resetPriorContext):
(WTF::LazyLineBreakIterator::priorContextLength):
(WTF::LazyLineBreakIterator::get):
(WTF::NonSharedCharacterBreakIterator::operator UBreakIterator*):
(WTF::NonSharedCharacterBreakIterator::operator TextBreakIterator*): Deleted.

Location:
trunk/Source
Files:
29 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WTF/ChangeLog

    r209896 r209907  
     12016-12-15  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Stop reinterpret_casting UBreakIterators to the undefined type TextBreakIterator
     4        https://bugs.webkit.org/show_bug.cgi?id=165931
     5
     6        We have a class declaration for TextBreakIterator but no definition for it. When we
     7        create an ICU UBreakIterator, we immediately reinterpret_cast it to this undefined
     8        type, and pass it around our code inside WebCore. Then, whenever we want to actually
     9        use this iterator, we reinterpret_cast it back to UBreakIterator. This is likely due
     10        to some ports historically implementing breaking interators on top of other libraries
     11        other than ICU; however, now, all ports use ICU. Because this internal type is not
     12        helpful and just adds confusion, we should just call our breaking iterators what
     13        they are: UBreakIterators.
     14
     15        This patch is a mechanical replacement of TextBreakIterator to UBreakIterator and
     16        removes the functions we were calling which pass through directly to ubrk_*().
     17
     18        Reviewed by Alex Christensen.
     19
     20        * wtf/text/LineBreakIteratorPoolICU.h:
     21        (WTF::LineBreakIteratorPool::take):
     22        (WTF::LineBreakIteratorPool::put):
     23        * wtf/text/StringView.cpp:
     24        (WTF::StringView::GraphemeClusters::Iterator::Impl::computeIndexEnd):
     25        * wtf/text/TextBreakIterator.cpp:
     26        (WTF::initializeIterator):
     27        (WTF::initializeIteratorWithRules):
     28        (WTF::setTextForIterator):
     29        (WTF::setContextAwareTextForIterator):
     30        (WTF::wordBreakIterator):
     31        (WTF::sentenceBreakIterator):
     32        (WTF::cursorMovementIterator):
     33        (WTF::acquireLineBreakIterator):
     34        (WTF::releaseLineBreakIterator):
     35        (WTF::openLineBreakIterator):
     36        (WTF::closeLineBreakIterator):
     37        (WTF::getNonSharedCharacterBreakIterator):
     38        (WTF::cacheNonSharedCharacterBreakIterator):
     39        (WTF::isWordTextBreak):
     40        (WTF::numGraphemeClusters):
     41        (WTF::numCharactersInGraphemeClusters):
     42        (WTF::textBreakFirst): Deleted.
     43        (WTF::textBreakLast): Deleted.
     44        (WTF::textBreakNext): Deleted.
     45        (WTF::textBreakPrevious): Deleted.
     46        (WTF::textBreakPreceding): Deleted.
     47        (WTF::textBreakFollowing): Deleted.
     48        (WTF::textBreakCurrent): Deleted.
     49        (WTF::isTextBreak): Deleted.
     50        * wtf/text/TextBreakIterator.h:
     51        (WTF::LazyLineBreakIterator::lastCharacter):
     52        (WTF::LazyLineBreakIterator::secondToLastCharacter):
     53        (WTF::LazyLineBreakIterator::setPriorContext):
     54        (WTF::LazyLineBreakIterator::updatePriorContext):
     55        (WTF::LazyLineBreakIterator::resetPriorContext):
     56        (WTF::LazyLineBreakIterator::priorContextLength):
     57        (WTF::LazyLineBreakIterator::get):
     58        (WTF::NonSharedCharacterBreakIterator::operator UBreakIterator*):
     59        (WTF::NonSharedCharacterBreakIterator::operator TextBreakIterator*): Deleted.
     60
    1612016-12-15  Myles C. Maxfield  <mmaxfield@apple.com>
    262
  • trunk/Source/WTF/wtf/Platform.h

    r209764 r209907  
    12091209
    12101210#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101201 && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101200
    1211 #define HAVE_TOUCH_BAR 1
     1211#define HAVE_TOUCH_BAR 0
    12121212#define HAVE_ADVANCED_SPELL_CHECKING 1
    12131213
  • trunk/Source/WTF/wtf/text/LineBreakIteratorPoolICU.h

    r208963 r209907  
    6161    }
    6262
    63     TextBreakIterator* take(const AtomicString& locale, LineBreakIteratorMode mode, bool isCJK)
     63    UBreakIterator* take(const AtomicString& locale, LineBreakIteratorMode mode, bool isCJK)
    6464    {
    6565        auto localeWithOptionalBreakKeyword = makeLocaleWithBreakKeyword(locale, mode);
    6666
    67         TextBreakIterator* iterator = nullptr;
     67        UBreakIterator* iterator = nullptr;
    6868        for (size_t i = 0; i < m_pool.size(); ++i) {
    6969            if (m_pool[i].first == localeWithOptionalBreakKeyword) {
     
    8585    }
    8686
    87     void put(TextBreakIterator* iterator)
     87    void put(UBreakIterator* iterator)
    8888    {
    8989        ASSERT(m_vendedIterators.contains(iterator));
     
    9898    static constexpr size_t capacity = 4;
    9999
    100     Vector<std::pair<AtomicString, TextBreakIterator*>, capacity> m_pool;
    101     HashMap<TextBreakIterator*, AtomicString> m_vendedIterators;
     100    Vector<std::pair<AtomicString, UBreakIterator*>, capacity> m_pool;
     101    HashMap<UBreakIterator*, AtomicString> m_vendedIterators;
    102102
    103103    friend WTF::ThreadSpecific<LineBreakIteratorPool>::operator LineBreakIteratorPool*();
  • trunk/Source/WTF/wtf/text/StringView.cpp

    r208985 r209907  
    2929
    3030#include <mutex>
     31#include <unicode/ubrk.h>
    3132#include <wtf/HashMap.h>
    3233#include <wtf/Lock.h>
     
    132133        if (m_index == m_stringView.length())
    133134            return m_index;
    134         return textBreakFollowing(m_iterator.value(), m_index);
     135        return ubrk_following(m_iterator.value(), m_index);
    135136    }
    136137
  • trunk/Source/WTF/wtf/text/TextBreakIterator.cpp

    r208965 r209907  
    3939// Iterator initialization
    4040
    41 static TextBreakIterator* initializeIterator(UBreakIteratorType type, const char* locale = currentTextBreakLocaleID())
     41static UBreakIterator* initializeIterator(UBreakIteratorType type, const char* locale = currentTextBreakLocaleID())
    4242{
    4343    UErrorCode openStatus = U_ZERO_ERROR;
    44     TextBreakIterator* iterator = reinterpret_cast<TextBreakIterator*>(ubrk_open(type, locale, 0, 0, &openStatus));
     44    UBreakIterator* iterator = ubrk_open(type, locale, 0, 0, &openStatus);
    4545    ASSERT_WITH_MESSAGE(U_SUCCESS(openStatus), "ICU could not open a break iterator: %s (%d)", u_errorName(openStatus), openStatus);
    4646    return iterator;
     
    4949#if !PLATFORM(IOS)
    5050
    51 static TextBreakIterator* initializeIteratorWithRules(const char* breakRules)
     51static UBreakIterator* initializeIteratorWithRules(const char* breakRules)
    5252{
    5353    UParseError parseStatus;
     
    5555    unsigned length = strlen(breakRules);
    5656    auto upconvertedCharacters = StringView(reinterpret_cast<const LChar*>(breakRules), length).upconvertedCharacters();
    57     TextBreakIterator* iterator = reinterpret_cast<TextBreakIterator*>(ubrk_openRules(upconvertedCharacters, length, 0, 0, &parseStatus, &openStatus));
     57    UBreakIterator* iterator = ubrk_openRules(upconvertedCharacters, length, 0, 0, &parseStatus, &openStatus);
    5858    ASSERT_WITH_MESSAGE(U_SUCCESS(openStatus), "ICU could not open a break iterator: %s (%d)", u_errorName(openStatus), openStatus);
    5959    return iterator;
     
    6565// Iterator text setting
    6666
    67 static TextBreakIterator* setTextForIterator(TextBreakIterator& iterator, StringView string)
     67static UBreakIterator* setTextForIterator(UBreakIterator& iterator, StringView string)
    6868{
    6969    if (string.is8Bit()) {
     
    8181
    8282        UErrorCode setTextStatus = U_ZERO_ERROR;
    83         ubrk_setUText(reinterpret_cast<UBreakIterator*>(&iterator), text, &setTextStatus);
     83        ubrk_setUText(&iterator, text, &setTextStatus);
    8484        if (U_FAILURE(setTextStatus)) {
    8585            LOG_ERROR("ubrk_setUText failed with status %d", setTextStatus);
     
    9090    } else {
    9191        UErrorCode setTextStatus = U_ZERO_ERROR;
    92         ubrk_setText(reinterpret_cast<UBreakIterator*>(&iterator), string.characters16(), string.length(), &setTextStatus);
     92        ubrk_setText(&iterator, string.characters16(), string.length(), &setTextStatus);
    9393        if (U_FAILURE(setTextStatus))
    9494            return nullptr;
     
    9898}
    9999
    100 static TextBreakIterator* setContextAwareTextForIterator(TextBreakIterator& iterator, StringView string, const UChar* priorContext, unsigned priorContextLength)
     100static UBreakIterator* setContextAwareTextForIterator(UBreakIterator& iterator, StringView string, const UChar* priorContext, unsigned priorContextLength)
    101101{
    102102    if (string.is8Bit()) {
     
    114114
    115115        UErrorCode setTextStatus = U_ZERO_ERROR;
    116         ubrk_setUText(reinterpret_cast<UBreakIterator*>(&iterator), text, &setTextStatus);
     116        ubrk_setUText(&iterator, text, &setTextStatus);
    117117        if (U_FAILURE(setTextStatus)) {
    118118            LOG_ERROR("ubrk_setUText failed with status %d", setTextStatus);
     
    132132
    133133        UErrorCode setTextStatus = U_ZERO_ERROR;
    134         ubrk_setUText(reinterpret_cast<UBreakIterator*>(&iterator), text, &setTextStatus);
     134        ubrk_setUText(&iterator, text, &setTextStatus);
    135135        if (U_FAILURE(setTextStatus)) {
    136136            LOG_ERROR("ubrk_setUText failed with status %d", setTextStatus);
     
    147147// Static iterators
    148148
    149 TextBreakIterator* wordBreakIterator(StringView string)
    150 {
    151     static TextBreakIterator* staticWordBreakIterator = initializeIterator(UBRK_WORD);
     149UBreakIterator* wordBreakIterator(StringView string)
     150{
     151    static UBreakIterator* staticWordBreakIterator = initializeIterator(UBRK_WORD);
    152152    if (!staticWordBreakIterator)
    153153        return nullptr;
     
    156156}
    157157
    158 TextBreakIterator* sentenceBreakIterator(StringView string)
    159 {
    160     static TextBreakIterator* staticSentenceBreakIterator = initializeIterator(UBRK_SENTENCE);
     158UBreakIterator* sentenceBreakIterator(StringView string)
     159{
     160    static UBreakIterator* staticSentenceBreakIterator = initializeIterator(UBRK_SENTENCE);
    161161    if (!staticSentenceBreakIterator)
    162162        return nullptr;
     
    165165}
    166166
    167 TextBreakIterator* cursorMovementIterator(StringView string)
     167UBreakIterator* cursorMovementIterator(StringView string)
    168168{
    169169#if !PLATFORM(IOS)
     
    292292        "!!safe_forward;";
    293293#endif
    294     static TextBreakIterator* staticCursorMovementIterator = initializeIteratorWithRules(kRules);
     294    static UBreakIterator* staticCursorMovementIterator = initializeIteratorWithRules(kRules);
    295295#else // PLATFORM(IOS)
    296296    // Use the special Thai character break iterator for all locales
    297     static TextBreakIterator* staticCursorMovementIterator = initializeIterator(UBRK_CHARACTER, "th");
     297    static UBreakIterator* staticCursorMovementIterator = initializeIterator(UBRK_CHARACTER, "th");
    298298#endif // !PLATFORM(IOS)
    299299
     
    304304}
    305305
    306 TextBreakIterator* acquireLineBreakIterator(StringView string, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength, LineBreakIteratorMode mode, bool isCJK)
    307 {
    308     TextBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale, mode, isCJK);
     306UBreakIterator* acquireLineBreakIterator(StringView string, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength, LineBreakIteratorMode mode, bool isCJK)
     307{
     308    UBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale, mode, isCJK);
    309309    if (!iterator)
    310310        return nullptr;
     
    313313}
    314314
    315 void releaseLineBreakIterator(TextBreakIterator* iterator)
     315void releaseLineBreakIterator(UBreakIterator* iterator)
    316316{
    317317    ASSERT_ARG(iterator, iterator);
     
    781781}
    782782
    783 TextBreakIterator* openLineBreakIterator(const AtomicString& locale, LineBreakIteratorMode mode, bool isCJK)
     783UBreakIterator* openLineBreakIterator(const AtomicString& locale, LineBreakIteratorMode mode, bool isCJK)
    784784{
    785785    UBreakIterator* ubrkIter;
     
    805805    }
    806806
    807     return reinterpret_cast<TextBreakIterator*>(ubrkIter);
    808 }
    809 
    810 void closeLineBreakIterator(TextBreakIterator*& iterator)
    811 {
    812     UBreakIterator* ubrkIter = reinterpret_cast<UBreakIterator*>(iterator);
     807    return ubrkIter;
     808}
     809
     810void closeLineBreakIterator(UBreakIterator*& iterator)
     811{
     812    UBreakIterator* ubrkIter = iterator;
    813813    ASSERT(ubrkIter);
    814814    ubrk_close(ubrkIter);
     
    816816}
    817817
    818 static std::atomic<TextBreakIterator*> nonSharedCharacterBreakIterator = ATOMIC_VAR_INIT(nullptr);
    819 
    820 static inline TextBreakIterator* getNonSharedCharacterBreakIterator()
     818static std::atomic<UBreakIterator*> nonSharedCharacterBreakIterator = ATOMIC_VAR_INIT(nullptr);
     819
     820static inline UBreakIterator* getNonSharedCharacterBreakIterator()
    821821{
    822822    if (auto *res = nonSharedCharacterBreakIterator.exchange(nullptr, std::memory_order_acquire))
     
    825825}
    826826
    827 static inline void cacheNonSharedCharacterBreakIterator(TextBreakIterator* cacheMe)
     827static inline void cacheNonSharedCharacterBreakIterator(UBreakIterator* cacheMe)
    828828{
    829829    if (auto *old = nonSharedCharacterBreakIterator.exchange(cacheMe, std::memory_order_release))
    830         ubrk_close(reinterpret_cast<UBreakIterator*>(old));
     830        ubrk_close(old);
    831831}
    832832
     
    849849}
    850850
    851 
    852851// Iterator implemenation.
    853852
    854 int textBreakFirst(TextBreakIterator* iterator)
    855 {
    856     return ubrk_first(reinterpret_cast<UBreakIterator*>(iterator));
    857 }
    858 
    859 int textBreakLast(TextBreakIterator* iterator)
    860 {
    861     return ubrk_last(reinterpret_cast<UBreakIterator*>(iterator));
    862 }
    863 
    864 int textBreakNext(TextBreakIterator* iterator)
    865 {
    866     return ubrk_next(reinterpret_cast<UBreakIterator*>(iterator));
    867 }
    868 
    869 int textBreakPrevious(TextBreakIterator* iterator)
    870 {
    871     return ubrk_previous(reinterpret_cast<UBreakIterator*>(iterator));
    872 }
    873 
    874 int textBreakPreceding(TextBreakIterator* iterator, int pos)
    875 {
    876     return ubrk_preceding(reinterpret_cast<UBreakIterator*>(iterator), pos);
    877 }
    878 
    879 int textBreakFollowing(TextBreakIterator* iterator, int pos)
    880 {
    881     return ubrk_following(reinterpret_cast<UBreakIterator*>(iterator), pos);
    882 }
    883 
    884 int textBreakCurrent(TextBreakIterator* iterator)
    885 {
    886     return ubrk_current(reinterpret_cast<UBreakIterator*>(iterator));
    887 }
    888 
    889 bool isTextBreak(TextBreakIterator* iterator, int position)
    890 {
    891     return ubrk_isBoundary(reinterpret_cast<UBreakIterator*>(iterator), position);
    892 }
    893 
    894 bool isWordTextBreak(TextBreakIterator* iterator)
    895 {
    896     int ruleStatus = ubrk_getRuleStatus(reinterpret_cast<UBreakIterator*>(iterator));
     853bool isWordTextBreak(UBreakIterator* iterator)
     854{
     855    int ruleStatus = ubrk_getRuleStatus(iterator);
    897856    return ruleStatus != UBRK_WORD_NONE;
    898857}
     
    921880
    922881    unsigned numGraphemeClusters = 0;
    923     while (textBreakNext(iterator) != TextBreakDone)
     882    while (ubrk_next(iterator) != UBRK_DONE)
    924883        ++numGraphemeClusters;
    925884    return numGraphemeClusters;
     
    949908
    950909    for (unsigned i = 0; i < numGraphemeClusters; ++i) {
    951         if (textBreakNext(iterator) == TextBreakDone)
     910        if (ubrk_next(iterator) == UBRK_DONE)
    952911            return stringLength;
    953912    }
    954     return textBreakCurrent(iterator);
     913    return ubrk_current(iterator);
    955914}
    956915
  • trunk/Source/WTF/wtf/text/TextBreakIterator.h

    r208963 r209907  
    2626namespace WTF {
    2727
    28 class TextBreakIterator;
    29 
    3028// Note: The returned iterator is good only until you get another iterator, with the exception of acquireLineBreakIterator.
    3129
     
    3634// from character break iterator is Thai prepend characters, see bug 24342.
    3735// Use this for insertion point and selection manipulations.
    38 WTF_EXPORT_PRIVATE TextBreakIterator* cursorMovementIterator(StringView);
     36WTF_EXPORT_PRIVATE UBreakIterator* cursorMovementIterator(StringView);
    3937
    40 WTF_EXPORT_PRIVATE TextBreakIterator* wordBreakIterator(StringView);
    41 WTF_EXPORT_PRIVATE TextBreakIterator* sentenceBreakIterator(StringView);
     38WTF_EXPORT_PRIVATE UBreakIterator* wordBreakIterator(StringView);
     39WTF_EXPORT_PRIVATE UBreakIterator* sentenceBreakIterator(StringView);
    4240
    43 WTF_EXPORT_PRIVATE TextBreakIterator* acquireLineBreakIterator(StringView, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength, LineBreakIteratorMode, bool isCJK);
    44 WTF_EXPORT_PRIVATE void releaseLineBreakIterator(TextBreakIterator*);
    45 TextBreakIterator* openLineBreakIterator(const AtomicString& locale, LineBreakIteratorMode, bool isCJK);
    46 void closeLineBreakIterator(TextBreakIterator*&);
     41WTF_EXPORT_PRIVATE UBreakIterator* acquireLineBreakIterator(StringView, const AtomicString& locale, const UChar* priorContext, unsigned priorContextLength, LineBreakIteratorMode, bool isCJK);
     42WTF_EXPORT_PRIVATE void releaseLineBreakIterator(UBreakIterator*);
     43UBreakIterator* openLineBreakIterator(const AtomicString& locale, LineBreakIteratorMode, bool isCJK);
     44void closeLineBreakIterator(UBreakIterator*&);
    4745
    48 WTF_EXPORT_PRIVATE int textBreakFirst(TextBreakIterator*);
    49 WTF_EXPORT_PRIVATE int textBreakLast(TextBreakIterator*);
    50 WTF_EXPORT_PRIVATE int textBreakNext(TextBreakIterator*);
    51 WTF_EXPORT_PRIVATE int textBreakPrevious(TextBreakIterator*);
    52 WTF_EXPORT_PRIVATE int textBreakCurrent(TextBreakIterator*);
    53 WTF_EXPORT_PRIVATE int textBreakPreceding(TextBreakIterator*, int);
    54 WTF_EXPORT_PRIVATE int textBreakFollowing(TextBreakIterator*, int);
    55 WTF_EXPORT_PRIVATE bool isTextBreak(TextBreakIterator*, int);
    56 WTF_EXPORT_PRIVATE bool isWordTextBreak(TextBreakIterator*);
    57 
    58 constexpr int TextBreakDone = -1;
     46WTF_EXPORT_PRIVATE bool isWordTextBreak(UBreakIterator*);
    5947
    6048WTF_EXPORT_PRIVATE bool isCJKLocale(const AtomicString&);
     
    8775    UChar lastCharacter() const
    8876    {
    89         COMPILE_ASSERT(WTF_ARRAY_LENGTH(m_priorContext) == 2, TextBreakIterator_unexpected_prior_context_length);
     77        static_assert(WTF_ARRAY_LENGTH(m_priorContext) == 2, "UBreakIterator unexpected prior context length");
    9078        return m_priorContext[1];
    9179    }
     
    9381    UChar secondToLastCharacter() const
    9482    {
    95         COMPILE_ASSERT(WTF_ARRAY_LENGTH(m_priorContext) == 2, TextBreakIterator_unexpected_prior_context_length);
     83        static_assert(WTF_ARRAY_LENGTH(m_priorContext) == 2, "UBreakIterator unexpected prior context length");
    9684        return m_priorContext[0];
    9785    }
     
    9987    void setPriorContext(UChar last, UChar secondToLast)
    10088    {
    101         COMPILE_ASSERT(WTF_ARRAY_LENGTH(m_priorContext) == 2, TextBreakIterator_unexpected_prior_context_length);
     89        static_assert(WTF_ARRAY_LENGTH(m_priorContext) == 2, "UBreakIterator unexpected prior context length");
    10290        m_priorContext[0] = secondToLast;
    10391        m_priorContext[1] = last;
     
    10694    void updatePriorContext(UChar last)
    10795    {
    108         COMPILE_ASSERT(WTF_ARRAY_LENGTH(m_priorContext) == 2, TextBreakIterator_unexpected_prior_context_length);
     96        static_assert(WTF_ARRAY_LENGTH(m_priorContext) == 2, "UBreakIterator unexpected prior context length");
    10997        m_priorContext[0] = m_priorContext[1];
    11098        m_priorContext[1] = last;
     
    113101    void resetPriorContext()
    114102    {
    115         COMPILE_ASSERT(WTF_ARRAY_LENGTH(m_priorContext) == 2, TextBreakIterator_unexpected_prior_context_length);
     103        static_assert(WTF_ARRAY_LENGTH(m_priorContext) == 2, "UBreakIterator unexpected prior context length");
    116104        m_priorContext[0] = 0;
    117105        m_priorContext[1] = 0;
     
    121109    {
    122110        unsigned priorContextLength = 0;
    123         COMPILE_ASSERT(WTF_ARRAY_LENGTH(m_priorContext) == 2, TextBreakIterator_unexpected_prior_context_length);
     111        static_assert(WTF_ARRAY_LENGTH(m_priorContext) == 2, "UBreakIterator unexpected prior context length");
    124112        if (m_priorContext[1]) {
    125113            ++priorContextLength;
     
    133121    // initialized to use the previously stored string as the primary breaking context and using
    134122    // previously stored prior context if non-empty.
    135     TextBreakIterator* get(unsigned priorContextLength)
     123    UBreakIterator* get(unsigned priorContextLength)
    136124    {
    137125        ASSERT(priorContextLength <= priorContextCapacity);
     
    165153    StringView m_stringView;
    166154    AtomicString m_locale;
    167     TextBreakIterator* m_iterator { nullptr };
     155    UBreakIterator* m_iterator { nullptr };
    168156    const UChar* m_cachedPriorContext { nullptr };
    169157    LineBreakIteratorMode m_mode { LineBreakIteratorMode::Default };
     
    186174    NonSharedCharacterBreakIterator(NonSharedCharacterBreakIterator&&);
    187175
    188     operator TextBreakIterator*() const { return m_iterator; }
     176    operator UBreakIterator*() const { return m_iterator; }
    189177
    190178private:
    191     TextBreakIterator* m_iterator;
     179    UBreakIterator* m_iterator;
    192180};
    193181
     
    206194using WTF::LineBreakIteratorMode;
    207195using WTF::NonSharedCharacterBreakIterator;
    208 using WTF::TextBreakDone;
    209 using WTF::TextBreakIterator;
     196using WTF::isWordTextBreak;
  • trunk/Source/WebCore/ChangeLog

    r209906 r209907  
     12016-12-15  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Stop reinterpret_casting UBreakIterators to the undefined type TextBreakIterator
     4        https://bugs.webkit.org/show_bug.cgi?id=165931
     5
     6        Reviewed by Alex Christensen.
     7
     8        No new tests because there is no behavior change.
     9
     10        * dom/CharacterData.cpp:
     11        (WebCore::CharacterData::parserAppendData):
     12        * editing/TextCheckingHelper.cpp:
     13        (WebCore::findMisspellings):
     14        * editing/VisibleUnits.cpp:
     15        (WebCore::wordBreakIteratorForMinOffsetBoundary):
     16        (WebCore::wordBreakIteratorForMaxOffsetBoundary):
     17        (WebCore::isLogicalStartOfWord):
     18        (WebCore::islogicalEndOfWord):
     19        (WebCore::visualWordPosition):
     20        (WebCore::startSentenceBoundary):
     21        (WebCore::endSentenceBoundary):
     22        (WebCore::previousSentencePositionBoundary):
     23        (WebCore::nextSentencePositionBoundary):
     24        * html/HTMLInputElement.cpp:
     25        * html/HTMLTextAreaElement.cpp:
     26        * html/InputType.cpp:
     27        * html/TextFieldInputType.cpp:
     28        * html/TextInputType.cpp:
     29        * platform/graphics/StringTruncator.cpp:
     30        (WebCore::textBreakAtOrPreceding):
     31        (WebCore::boundedTextBreakFollowing):
     32        (WebCore::rightClipToWordBuffer):
     33        * platform/graphics/mac/ComplexTextController.cpp:
     34        (WebCore::ComplexTextController::offsetForPosition):
     35        * platform/text/TextBoundaries.cpp:
     36        (WebCore::findNextWordFromIndex):
     37        (WebCore::findWordBoundary):
     38        (WebCore::findEndWordBoundary):
     39        * platform/text/mac/TextBoundaries.mm:
     40        (WebCore::findNextWordFromIndex):
     41        * rendering/BreakLines.h:
     42        (WebCore::nextBreakablePositionNonLoosely):
     43        (WebCore::nextBreakablePositionLoosely):
     44        * rendering/RenderBlock.cpp:
     45        * rendering/RenderText.cpp:
     46        (WebCore::makeCapitalized):
     47        (WebCore::RenderText::previousOffset):
     48        (WebCore::RenderText::previousOffsetForBackwardDeletion):
     49        (WebCore::RenderText::nextOffset):
     50        * rendering/SimpleLineLayoutTextFragmentIterator.h:
     51        * rendering/line/LineBreaker.h:
     52
    1532016-12-15  Darin Adler  <darin@apple.com>
    254
  • trunk/Source/WebCore/dom/CharacterData.cpp

    r208603 r209907  
    3434#include "RenderText.h"
    3535#include "StyleInheritedData.h"
     36#include <unicode/ubrk.h>
    3637#include <wtf/Ref.h>
    37 #include <wtf/text/TextBreakIterator.h>
    3838
    3939namespace WebCore {
     
    8787    if (characterLengthLimit < characterLength) {
    8888        NonSharedCharacterBreakIterator it(StringView(string).substring(offset, (characterLengthLimit + 2 > characterLength) ? characterLength : characterLengthLimit + 2));
    89         if (!isTextBreak(it, characterLengthLimit))
    90             characterLengthLimit = textBreakPreceding(it, characterLengthLimit);
     89        if (!ubrk_isBoundary(it, characterLengthLimit))
     90            characterLengthLimit = ubrk_preceding(it, characterLengthLimit);
    9191    }
    9292
  • trunk/Source/WebCore/editing/TextCheckingHelper.cpp

    r208479 r209907  
    3434#include "FrameSelection.h"
    3535#include "Settings.h"
    36 #include <wtf/text/TextBreakIterator.h>
    3736#include "TextCheckerClient.h"
    3837#include "TextIterator.h"
    3938#include "VisiblePosition.h"
    4039#include "VisibleUnits.h"
     40#include <unicode/ubrk.h>
    4141#include <wtf/text/StringView.h>
     42#include <wtf/text/TextBreakIterator.h>
    4243
    4344namespace WebCore {
     
    7778static void findMisspellings(TextCheckerClient& client, StringView text, Vector<TextCheckingResult>& results)
    7879{
    79     TextBreakIterator* iterator = wordBreakIterator(text);
     80    UBreakIterator* iterator = wordBreakIterator(text);
    8081    if (!iterator)
    8182        return;
    82     for (int wordStart = textBreakCurrent(iterator); wordStart >= 0; ) {
    83         int wordEnd = textBreakNext(iterator);
     83    for (int wordStart = ubrk_current(iterator); wordStart >= 0; ) {
     84        int wordEnd = ubrk_next(iterator);
    8485        if (wordEnd < 0)
    8586            break;
  • trunk/Source/WebCore/editing/VisibleUnits.cpp

    r208479 r209907  
    3838#include "Text.h"
    3939#include "TextBoundaries.h"
    40 #include <wtf/text/TextBreakIterator.h>
    4140#include "TextIterator.h"
    4241#include "VisibleSelection.h"
     42#include <unicode/ubrk.h>
     43#include <wtf/text/TextBreakIterator.h>
    4344#include "htmlediting.h"
    4445
     
    286287}
    287288
    288 static TextBreakIterator* wordBreakIteratorForMinOffsetBoundary(const VisiblePosition& visiblePosition, const InlineTextBox* textBox,
     289static UBreakIterator* wordBreakIteratorForMinOffsetBoundary(const VisiblePosition& visiblePosition, const InlineTextBox* textBox,
    289290    int& previousBoxLength, bool& previousBoxInDifferentBlock, Vector<UChar, 1024>& string, CachedLogicallyOrderedLeafBoxes& leafBoxes)
    290291{
     
    306307}
    307308
    308 static TextBreakIterator* wordBreakIteratorForMaxOffsetBoundary(const VisiblePosition& visiblePosition, const InlineTextBox* textBox,
     309static UBreakIterator* wordBreakIteratorForMaxOffsetBoundary(const VisiblePosition& visiblePosition, const InlineTextBox* textBox,
    309310    bool& nextBoxInDifferentBlock, Vector<UChar, 1024>& string, CachedLogicallyOrderedLeafBoxes& leafBoxes)
    310311{
     
    324325}
    325326
    326 static bool isLogicalStartOfWord(TextBreakIterator* iter, int position, bool hardLineBreak)
    327 {
    328     bool boundary = hardLineBreak ? true : isTextBreak(iter, position);
     327static bool isLogicalStartOfWord(UBreakIterator* iter, int position, bool hardLineBreak)
     328{
     329    bool boundary = hardLineBreak ? true : ubrk_isBoundary(iter, position);
    329330    if (!boundary)
    330331        return false;
    331332
    332     textBreakFollowing(iter, position);
     333    ubrk_following(iter, position);
    333334    // isWordTextBreak returns true after moving across a word and false after moving across a punctuation/space.
    334335    return isWordTextBreak(iter);
    335336}
    336337
    337 static bool islogicalEndOfWord(TextBreakIterator* iter, int position, bool hardLineBreak)
    338 {
    339     bool boundary = isTextBreak(iter, position);
     338static bool islogicalEndOfWord(UBreakIterator* iter, int position, bool hardLineBreak)
     339{
     340    bool boundary = ubrk_isBoundary(iter, position);
    340341    return (hardLineBreak || boundary) && isWordTextBreak(iter);
    341342}
     
    352353    InlineBox* previouslyVisitedBox = nullptr;
    353354    VisiblePosition current = visiblePosition;
    354     TextBreakIterator* iter = nullptr;
     355    UBreakIterator* iter = nullptr;
    355356
    356357    CachedLogicallyOrderedLeafBoxes leafBoxes;
     
    391392            break;
    392393
    393         textBreakFirst(iter);
     394        ubrk_first(iter);
    394395        int offsetInIterator = offsetInBox - textBox.start() + previousBoxLength;
    395396
     
    11101111{
    11111112    // FIXME: The following function can return -1; we don't handle that.
    1112     return textBreakPreceding(sentenceBreakIterator(text), text.length());
     1113    return ubrk_preceding(sentenceBreakIterator(text), text.length());
    11131114}
    11141115
     
    11201121unsigned endSentenceBoundary(StringView text, unsigned, BoundarySearchContextAvailability, bool&)
    11211122{
    1122     return textBreakNext(sentenceBreakIterator(text));
     1123    return ubrk_next(sentenceBreakIterator(text));
    11231124}
    11241125
     
    11331134    // FIXME: This is identical to startSentenceBoundary. I'm pretty sure that's not right.
    11341135    // FIXME: The following function can return -1; we don't handle that.
    1135     return textBreakPreceding(sentenceBreakIterator(text), text.length());
     1136    return ubrk_preceding(sentenceBreakIterator(text), text.length());
    11361137}
    11371138
     
    11451146    // FIXME: This is identical to endSentenceBoundary.
    11461147    // That isn't right. This function needs to move to the equivalent position in the following sentence.
    1147     return textBreakFollowing(sentenceBreakIterator(text), 0);
     1148    return ubrk_following(sentenceBreakIterator(text), 0);
    11481149}
    11491150
  • trunk/Source/WebCore/html/HTMLInputElement.cpp

    r209756 r209907  
    6363#include <wtf/MathExtras.h>
    6464#include <wtf/Ref.h>
    65 #include <wtf/text/TextBreakIterator.h>
    6665
    6766#if ENABLE(TOUCH_EVENTS)
  • trunk/Source/WebCore/html/HTMLTextAreaElement.cpp

    r209756 r209907  
    4545#include "ShadowRoot.h"
    4646#include "Text.h"
    47 #include <wtf/text/TextBreakIterator.h>
    4847#include "TextControlInnerElements.h"
    4948#include "TextIterator.h"
  • trunk/Source/WebCore/html/InputType.cpp

    r208985 r209907  
    7070#include "SubmitInputType.h"
    7171#include "TelephoneInputType.h"
    72 #include <wtf/text/TextBreakIterator.h>
    7372#include "TextInputType.h"
    7473#include "TimeInputType.h"
     
    7978#include <wtf/HashMap.h>
    8079#include <wtf/text/StringHash.h>
     80#include <wtf/text/TextBreakIterator.h>
    8181
    8282namespace WebCore {
  • trunk/Source/WebCore/html/TextFieldInputType.cpp

    r208963 r209907  
    5353#include "RenderTheme.h"
    5454#include "ShadowRoot.h"
    55 #include <wtf/text/TextBreakIterator.h>
    5655#include "TextControlInnerElements.h"
    5756#include "TextEvent.h"
  • trunk/Source/WebCore/html/TextInputType.cpp

    r203038 r209907  
    3434#include "HTMLInputElement.h"
    3535#include "InputTypeNames.h"
    36 #include <wtf/text/TextBreakIterator.h>
    3736
    3837namespace WebCore {
  • trunk/Source/WebCore/platform/graphics/StringTruncator.cpp

    r203038 r209907  
    3333#include <wtf/text/TextBreakIterator.h>
    3434#include "TextRun.h"
     35#include <unicode/ubrk.h>
    3536#include <wtf/Assertions.h>
    3637#include <wtf/Vector.h>
     
    4445typedef unsigned TruncationFunction(const String&, unsigned length, unsigned keepCount, UChar* buffer, bool shouldInsertEllipsis);
    4546
    46 static inline int textBreakAtOrPreceding(TextBreakIterator* it, int offset)
    47 {
    48     if (isTextBreak(it, offset))
     47static inline int textBreakAtOrPreceding(UBreakIterator* it, int offset)
     48{
     49    if (ubrk_isBoundary(it, offset))
    4950        return offset;
    5051
    51     int result = textBreakPreceding(it, offset);
    52     return result == TextBreakDone ? 0 : result;
    53 }
    54 
    55 static inline int boundedTextBreakFollowing(TextBreakIterator* it, int offset, int length)
    56 {
    57     int result = textBreakFollowing(it, offset);
    58     return result == TextBreakDone ? length : result;
     52    int result = ubrk_preceding(it, offset);
     53    return result == UBRK_DONE ? 0 : result;
     54}
     55
     56static inline int boundedTextBreakFollowing(UBreakIterator* it, int offset, int length)
     57{
     58    int result = ubrk_following(it, offset);
     59    return result == UBRK_DONE ? length : result;
    5960}
    6061
     
    147148    ASSERT(keepCount < STRING_BUFFER_SIZE);
    148149
    149     TextBreakIterator* it = wordBreakIterator(StringView(string).substring(0, length));
     150    UBreakIterator* it = wordBreakIterator(StringView(string).substring(0, length));
    150151    unsigned keepLength = textBreakAtOrPreceding(it, keepCount);
    151152    StringView(string).substring(0, keepLength).getCharactersWithUpconvert(buffer);
  • trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp

    r209875 r209907  
    3131#include "RenderBlock.h"
    3232#include "RenderText.h"
    33 #include <wtf/text/TextBreakIterator.h>
    3433#include "TextRun.h"
     34#include <unicode/ubrk.h>
    3535#include <wtf/Optional.h>
    3636#include <wtf/StdLibExtras.h>
     37#include <wtf/text/TextBreakIterator.h>
    3738#include <wtf/unicode/CharacterNames.h>
    3839
     
    177178                CFIndex hitIndex = hitGlyphStart + (hitGlyphEnd - hitGlyphStart) * (m_run.ltr() ? x / adjustedAdvance : 1 - x / adjustedAdvance);
    178179                int stringLength = complexTextRun.stringLength();
    179                 TextBreakIterator* cursorPositionIterator = cursorMovementIterator(StringView(complexTextRun.characters(), stringLength));
     180                UBreakIterator* cursorPositionIterator = cursorMovementIterator(StringView(complexTextRun.characters(), stringLength));
    180181                int clusterStart;
    181                 if (isTextBreak(cursorPositionIterator, hitIndex))
     182                if (ubrk_isBoundary(cursorPositionIterator, hitIndex))
    182183                    clusterStart = hitIndex;
    183184                else {
    184                     clusterStart = textBreakPreceding(cursorPositionIterator, hitIndex);
    185                     if (clusterStart == TextBreakDone)
     185                    clusterStart = ubrk_preceding(cursorPositionIterator, hitIndex);
     186                    if (clusterStart == UBRK_DONE)
    186187                        clusterStart = 0;
    187188                }
     
    190191                    return complexTextRun.stringLocation() + clusterStart;
    191192
    192                 int clusterEnd = textBreakFollowing(cursorPositionIterator, hitIndex);
    193                 if (clusterEnd == TextBreakDone)
     193                int clusterEnd = ubrk_following(cursorPositionIterator, hitIndex);
     194                if (clusterEnd == UBRK_DONE)
    194195                    clusterEnd = stringLength;
    195196
  • trunk/Source/WebCore/platform/text/TextBoundaries.cpp

    r203038 r209907  
    2828#include "TextBoundaries.h"
    2929
     30#include <unicode/ubrk.h>
    3031#include <wtf/text/StringImpl.h>
    3132#include <wtf/text/TextBreakIterator.h>
     
    6364int findNextWordFromIndex(StringView text, int position, bool forward)
    6465{
    65     TextBreakIterator* it = wordBreakIterator(text);
     66    UBreakIterator* it = wordBreakIterator(text);
    6667
    6768    if (forward) {
    68         position = textBreakFollowing(it, position);
    69         while (position != TextBreakDone) {
     69        position = ubrk_following(it, position);
     70        while (position != UBRK_DONE) {
    7071            // We stop searching when the character preceeding the break is alphanumeric.
    7172            if (static_cast<unsigned>(position) < text.length() && u_isalnum(text[position - 1]))
    7273                return position;
    7374
    74             position = textBreakFollowing(it, position);
     75            position = ubrk_following(it, position);
    7576        }
    7677
    7778        return text.length();
    7879    } else {
    79         position = textBreakPreceding(it, position);
    80         while (position != TextBreakDone) {
     80        position = ubrk_preceding(it, position);
     81        while (position != UBRK_DONE) {
    8182            // We stop searching when the character following the break is alphanumeric.
    8283            if (position && u_isalnum(text[position]))
    8384                return position;
    8485
    85             position = textBreakPreceding(it, position);
     86            position = ubrk_preceding(it, position);
    8687        }
    8788
     
    9293void findWordBoundary(StringView text, int position, int* start, int* end)
    9394{
    94     TextBreakIterator* it = wordBreakIterator(text);
    95     *end = textBreakFollowing(it, position);
     95    UBreakIterator* it = wordBreakIterator(text);
     96    *end = ubrk_following(it, position);
    9697    if (*end < 0)
    97         *end = textBreakLast(it);
    98     *start = textBreakPrevious(it);
     98        *end = ubrk_last(it);
     99    *start = ubrk_previous(it);
    99100}
    100101
    101102void findEndWordBoundary(StringView text, int position, int* end)
    102103{
    103     TextBreakIterator* it = wordBreakIterator(text);
    104     *end = textBreakFollowing(it, position);
     104    UBreakIterator* it = wordBreakIterator(text);
     105    *end = ubrk_following(it, position);
    105106    if (*end < 0)
    106         *end = textBreakLast(it);
     107        *end = ubrk_last(it);
    107108}
    108109
  • trunk/Source/WebCore/platform/text/enchant/TextCheckerEnchant.cpp

    r203038 r209907  
    2525#include <Language.h>
    2626#include <glib.h>
     27#include <unicode/ubrk.h>
    2728#include <wtf/text/TextBreakIterator.h>
    2829
     
    9293        return;
    9394
    94     TextBreakIterator* iter = wordBreakIterator(string);
     95    UBreakIterator* iter = wordBreakIterator(string);
    9596    if (!iter)
    9697        return;
    9798
    9899    CString utf8String = string.utf8();
    99     int start = textBreakFirst(iter);
    100     for (int end = textBreakNext(iter); end != TextBreakDone; end = textBreakNext(iter)) {
     100    int start = ubrk_first(iter);
     101    for (int end = ubrk_next(iter); end != UBRK_DONE; end = ubrk_next(iter)) {
    101102        if (isWordTextBreak(iter)) {
    102103            checkSpellingOfWord(utf8String, start, end, misspellingLocation, misspellingLength);
  • trunk/Source/WebCore/platform/text/mac/TextBoundaries.mm

    r204027 r209907  
    268268    // tuned to improve the iPhone-specific behavior for the keyboard and text editing.
    269269    int pos = position;
    270     TextBreakIterator* boundary = wordBreakIterator(text);
     270    UBreakIterator* boundary = wordBreakIterator(text);
    271271    if (boundary) {
    272272        if (forward) {
    273273            do {
    274                 pos = textBreakFollowing(boundary, pos);
     274                pos = ubrk_following(boundary, pos);
    275275                if (pos == UBRK_DONE)
    276276                    pos = text.length();
     
    279279        else {
    280280            do {
    281                 pos = textBreakPreceding(boundary, pos);
     281                pos = ubrk_preceding(boundary, pos);
    282282                if (pos == UBRK_DONE)
    283283                    pos = 0;
  • trunk/Source/WebCore/rendering/BreakLines.h

    r208985 r209907  
    103103                // Don't break if positioned at start of primary context and there is no prior context.
    104104                if (i || priorContextLength) {
    105                     TextBreakIterator* breakIterator = lazyBreakIterator.get(priorContextLength);
     105                    UBreakIterator* breakIterator = lazyBreakIterator.get(priorContextLength);
    106106                    if (breakIterator) {
    107                         int candidate = textBreakFollowing(breakIterator, i - 1 + priorContextLength);
    108                         if (candidate == TextBreakDone)
     107                        int candidate = ubrk_following(breakIterator, i - 1 + priorContextLength);
     108                        if (candidate == UBRK_DONE)
    109109                            nextBreak = std::nullopt;
    110110                        else {
     
    148148            // Don't break if positioned at start of primary context and there is no prior context.
    149149            if (i || priorContextLength) {
    150                 TextBreakIterator* breakIterator = lazyBreakIterator.get(priorContextLength);
     150                UBreakIterator* breakIterator = lazyBreakIterator.get(priorContextLength);
    151151                if (breakIterator) {
    152152                    ASSERT(i + priorContextLength >= 1);
    153                     int candidate = textBreakFollowing(breakIterator, i + priorContextLength - 1);
    154                     if (candidate == TextBreakDone)
     153                    int candidate = ubrk_following(breakIterator, i + priorContextLength - 1);
     154                    if (candidate == UBRK_DONE)
    155155                        nextBreak = std::nullopt;
    156156                    else {
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r209903 r209907  
    6969#include "ShadowRoot.h"
    7070#include "ShapeOutsideInfo.h"
    71 #include <wtf/text/TextBreakIterator.h>
    7271#include "TransformState.h"
    7372
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r209591 r209907  
    154154    }
    155155
    156     TextBreakIterator* boundary = wordBreakIterator(StringView(stringWithPrevious.characters(), length + 1));
     156    UBreakIterator* boundary = wordBreakIterator(StringView(stringWithPrevious.characters(), length + 1));
    157157    if (!boundary)
    158158        return;
     
    162162
    163163    int32_t endOfWord;
    164     int32_t startOfWord = textBreakFirst(boundary);
    165     for (endOfWord = textBreakNext(boundary); endOfWord != TextBreakDone; startOfWord = endOfWord, endOfWord = textBreakNext(boundary)) {
     164    int32_t startOfWord = ubrk_first(boundary);
     165    for (endOfWord = ubrk_next(boundary); endOfWord != UBRK_DONE; startOfWord = endOfWord, endOfWord = ubrk_next(boundary)) {
    166166        if (startOfWord) // Ignore first char of previous string
    167167            result.append(stringImpl[startOfWord - 1] == noBreakSpace ? noBreakSpace : u_totitle(stringWithPrevious[startOfWord]));
     
    14701470
    14711471    StringImpl* textImpl = m_text.impl();
    1472     TextBreakIterator* iterator = cursorMovementIterator(StringView(textImpl->characters16(), textImpl->length()));
     1472    UBreakIterator* iterator = cursorMovementIterator(StringView(textImpl->characters16(), textImpl->length()));
    14731473    if (!iterator)
    14741474        return current - 1;
    14751475
    1476     long result = textBreakPreceding(iterator, current);
    1477     if (result == TextBreakDone)
     1476    long result = ubrk_preceding(iterator, current);
     1477    if (result == UBRK_DONE)
    14781478        result = current - 1;
    14791479
     
    15241524    StringImpl& text = *m_text.impl();
    15251525
    1526     // FIXME: Unclear why this has so much handrolled code rather than using TextBreakIterator.
     1526    // FIXME: Unclear why this has so much handrolled code rather than using UBreakIterator.
    15271527    // Also unclear why this is so different from advanceByCombiningCharacterSequence.
    15281528
     
    16501650
    16511651    StringImpl* textImpl = m_text.impl();
    1652     TextBreakIterator* iterator = cursorMovementIterator(StringView(textImpl->characters16(), textImpl->length()));
     1652    UBreakIterator* iterator = cursorMovementIterator(StringView(textImpl->characters16(), textImpl->length()));
    16531653    if (!iterator)
    16541654        return current + 1;
    16551655
    1656     long result = textBreakFollowing(iterator, current);
    1657     if (result == TextBreakDone)
     1656    long result = ubrk_following(iterator, current);
     1657    if (result == UBRK_DONE)
    16581658        result = current + 1;
    16591659
  • trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.h

    r204531 r209907  
    2929#include "RenderLineBreak.h"
    3030#include "SimpleLineLayoutFlowContents.h"
    31 #include <wtf/text/TextBreakIterator.h>
    3231
    3332namespace WebCore {
  • trunk/Source/WebCore/rendering/line/LineBreaker.h

    r208668 r209907  
    2929#include "LineInlineHeaders.h"
    3030#include <wtf/Vector.h>
    31 #include <wtf/text/TextBreakIterator.h>
    3231
    3332namespace WebCore {
  • trunk/Source/WebKit/ios/ChangeLog

    r208289 r209907  
     12016-12-15  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Stop reinterpret_casting UBreakIterators to the undefined type TextBreakIterator
     4        https://bugs.webkit.org/show_bug.cgi?id=165931
     5
     6        Reviewed by Alex Christensen.
     7
     8        * Misc/WebUIKitSupport.mm:
     9
    1102016-11-01  Alex Christensen  <achristensen@webkit.org>
    211
  • trunk/Source/WebKit/ios/Misc/WebUIKitSupport.mm

    r204531 r209907  
    4141#import <WebCore/WebCoreThreadSystemInterface.h>
    4242#import <wtf/spi/darwin/dyldSPI.h>
    43 #import <wtf/text/TextBreakIterator.h>
    4443
    4544#import <runtime/InitializeThreading.h>
  • trunk/Source/WebKit2/UIProcess/efl/TextCheckerEfl.cpp

    r209235 r209907  
    136136{
    137137    // FIXME: avoid creating textIterator object here, it could be passed as a parameter.
    138     //        isTextBreak() leaves the iterator pointing to the first boundary position at
     138    //        ubrk_isBoundary() leaves the iterator pointing to the first boundary position at
    139139    //        or after "offset" (ubrk_isBoundary side effect).
    140140    //        For many word separators, the method doesn't properly determine the boundaries
     
    145145
    146146    unsigned wordOffset = currentOffset;
    147     while (wordOffset < text.length() && isTextBreak(textIterator, wordOffset))
     147    while (wordOffset < text.length() && ubrk_isBoundary(textIterator, wordOffset))
    148148        ++wordOffset;
    149149
     
    176176        unsigned offset = nextWordOffset(text, 0);
    177177        unsigned lengthStrip = text.length();
    178         while (lengthStrip > 0 && isTextBreak(textIterator, lengthStrip - 1))
     178        while (lengthStrip > 0 && ubrk_isBoundary(textIterator, lengthStrip - 1))
    179179            --lengthStrip;
    180180
  • trunk/Source/WebKit2/UIProcess/gtk/TextCheckerGtk.cpp

    r206261 r209907  
    3333#include <WebCore/NotImplemented.h>
    3434#include <WebCore/TextCheckerEnchant.h>
     35#include <unicode/ubrk.h>
    3536#include <wtf/NeverDestroyed.h>
    3637#include <wtf/text/TextBreakIterator.h>
     
    227228{
    228229    // FIXME: avoid creating textIterator object here, it could be passed as a parameter.
    229     //        isTextBreak() leaves the iterator pointing to the first boundary position at
     230    //        ubrk_isBoundary() leaves the iterator pointing to the first boundary position at
    230231    //        or after "offset" (ubrk_isBoundary side effect).
    231232    //        For many word separators, the method doesn't properly determine the boundaries
    232233    //        without resetting the iterator.
    233     TextBreakIterator* textIterator = wordBreakIterator(text);
     234    UBreakIterator* textIterator = wordBreakIterator(text);
    234235    if (!textIterator)
    235236        return currentOffset;
    236237
    237238    unsigned wordOffset = currentOffset;
    238     while (wordOffset < text.length() && isTextBreak(textIterator, wordOffset))
     239    while (wordOffset < text.length() && ubrk_isBoundary(textIterator, wordOffset))
    239240        ++wordOffset;
    240241
     
    259260        return Vector<TextCheckingResult>();
    260261
    261     TextBreakIterator* textIterator = wordBreakIterator(text);
     262    UBreakIterator* textIterator = wordBreakIterator(text);
    262263    if (!textIterator)
    263264        return Vector<TextCheckingResult>();
     
    267268    unsigned offset = nextWordOffset(text, 0);
    268269    unsigned lengthStrip = text.length();
    269     while (lengthStrip > 0 && isTextBreak(textIterator, lengthStrip - 1))
     270    while (lengthStrip > 0 && ubrk_isBoundary(textIterator, lengthStrip - 1))
    270271        --lengthStrip;
    271272
Note: See TracChangeset for help on using the changeset viewer.