Changeset 133644 in webkit


Ignore:
Timestamp:
Nov 6, 2012 11:10:09 AM (11 years ago)
Author:
commit-queue@webkit.org
Message:

Unreviewed, rolling out r133529 and r133562.
http://trac.webkit.org/changeset/133529
http://trac.webkit.org/changeset/133562
https://bugs.webkit.org/show_bug.cgi?id=101371

Caused 15% memory regression on Chromium page cyclers
(Requested by jsbell|gardener on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2012-11-06

Source/WebCore:

  • platform/text/LineBreakIteratorPoolICU.h:

(WebCore::LineBreakIteratorPool::take):
(WebCore::LineBreakIteratorPool::put):
(LineBreakIteratorPool):

  • platform/text/TextBreakIterator.cpp:

(WebCore::acquireLineBreakIterator):

  • platform/text/TextBreakIterator.h:

(WebCore):
(WebCore::LazyLineBreakIterator::LazyLineBreakIterator):
(WebCore::LazyLineBreakIterator::get):
(WebCore::LazyLineBreakIterator::reset):
(LazyLineBreakIterator):

  • platform/text/TextBreakIteratorICU.cpp:

(WebCore::acquireLineBreakIterator):
(WebCore::releaseLineBreakIterator):

  • platform/text/gtk/TextBreakIteratorGtk.cpp:

(WebCore::setUpIterator):
(WebCore::acquireLineBreakIterator):

  • platform/text/wince/TextBreakIteratorWinCE.cpp:

(WebCore::acquireLineBreakIterator):

  • rendering/RenderBlockLineLayout.cpp:

(WebCore::RenderBlock::LineBreaker::nextLineBreak):

  • rendering/RenderText.cpp:

(WebCore::RenderText::computePreferredLogicalWidths):

  • rendering/RenderText.h:

(WebCore):

  • rendering/break_lines.cpp:

(WebCore):
(WebCore::isBreakableSpace):
(WebCore::needsLineBreakIterator):
(WebCore::nextBreakablePosition):
(WebCore::nextBreakablePositionIgnoringNBSP):

  • rendering/break_lines.h:

(WebCore):
(WebCore::isBreakable):

LayoutTests:

  • css3/line-break/line-break-auto-centered-expected.html: Removed.
  • css3/line-break/line-break-auto-centered.html: Removed.
  • css3/line-break/line-break-auto-half-kana-expected.html: Removed.
  • css3/line-break/line-break-auto-half-kana.html: Removed.
  • css3/line-break/line-break-auto-hyphens-expected.html: Removed.
  • css3/line-break/line-break-auto-hyphens.html: Removed.
  • css3/line-break/line-break-auto-inseparables-expected.html: Removed.
  • css3/line-break/line-break-auto-inseparables.html: Removed.
  • css3/line-break/line-break-auto-iteration-marks-expected.html: Removed.
  • css3/line-break/line-break-auto-iteration-marks.html: Removed.
  • css3/line-break/line-break-auto-postfixes-expected.html: Removed.
  • css3/line-break/line-break-auto-postfixes.html: Removed.
  • css3/line-break/line-break-auto-prefixes-expected.html: Removed.
  • css3/line-break/line-break-auto-prefixes.html: Removed.
  • css3/line-break/line-break-auto-sound-marks-expected.html: Removed.
  • css3/line-break/line-break-auto-sound-marks.html: Removed.
  • css3/line-break/line-break-loose-centered-expected.html: Removed.
  • css3/line-break/line-break-loose-centered.html: Removed.
  • css3/line-break/line-break-loose-half-kana-expected.html: Removed.
  • css3/line-break/line-break-loose-half-kana.html: Removed.
  • css3/line-break/line-break-loose-hyphens-expected.html: Removed.
  • css3/line-break/line-break-loose-hyphens.html: Removed.
  • css3/line-break/line-break-loose-inseparables-expected.html: Removed.
  • css3/line-break/line-break-loose-inseparables.html: Removed.
  • css3/line-break/line-break-loose-iteration-marks-expected.html: Removed.
  • css3/line-break/line-break-loose-iteration-marks.html: Removed.
  • css3/line-break/line-break-loose-postfixes-expected.html: Removed.
  • css3/line-break/line-break-loose-postfixes.html: Removed.
  • css3/line-break/line-break-loose-prefixes-expected.html: Removed.
  • css3/line-break/line-break-loose-prefixes.html: Removed.
  • css3/line-break/line-break-loose-sound-marks-expected.html: Removed.
  • css3/line-break/line-break-loose-sound-marks.html: Removed.
  • css3/line-break/line-break-normal-centered-expected.html: Removed.
  • css3/line-break/line-break-normal-centered.html: Removed.
  • css3/line-break/line-break-normal-half-kana-expected.html: Removed.
  • css3/line-break/line-break-normal-half-kana.html: Removed.
  • css3/line-break/line-break-normal-hyphens-expected.html: Removed.
  • css3/line-break/line-break-normal-hyphens.html: Removed.
  • css3/line-break/line-break-normal-inseparables-expected.html: Removed.
  • css3/line-break/line-break-normal-inseparables.html: Removed.
  • css3/line-break/line-break-normal-iteration-marks-expected.html: Removed.
  • css3/line-break/line-break-normal-iteration-marks.html: Removed.
  • css3/line-break/line-break-normal-postfixes-expected.html: Removed.
  • css3/line-break/line-break-normal-postfixes.html: Removed.
  • css3/line-break/line-break-normal-prefixes-expected.html: Removed.
  • css3/line-break/line-break-normal-prefixes.html: Removed.
  • css3/line-break/line-break-normal-sound-marks-expected.html: Removed.
  • css3/line-break/line-break-normal-sound-marks.html: Removed.
  • css3/line-break/line-break-strict-centered-expected.html: Removed.
  • css3/line-break/line-break-strict-centered.html: Removed.
  • css3/line-break/line-break-strict-half-kana-expected.html: Removed.
  • css3/line-break/line-break-strict-half-kana.html: Removed.
  • css3/line-break/line-break-strict-hyphens-expected.html: Removed.
  • css3/line-break/line-break-strict-hyphens.html: Removed.
  • css3/line-break/line-break-strict-inseparables-expected.html: Removed.
  • css3/line-break/line-break-strict-inseparables.html: Removed.
  • css3/line-break/line-break-strict-iteration-marks-expected.html: Removed.
  • css3/line-break/line-break-strict-iteration-marks.html: Removed.
  • css3/line-break/line-break-strict-postfixes-expected.html: Removed.
  • css3/line-break/line-break-strict-postfixes.html: Removed.
  • css3/line-break/line-break-strict-prefixes-expected.html: Removed.
  • css3/line-break/line-break-strict-prefixes.html: Removed.
  • css3/line-break/line-break-strict-sound-marks-expected.html: Removed.
  • css3/line-break/line-break-strict-sound-marks.html: Removed.
  • platform/chromium-android/css3/line-break/line-break-auto-half-kana-expected.html: Removed.
  • platform/chromium-android/css3/line-break/line-break-auto-sound-marks-expected.html: Removed.
  • platform/chromium/css3/line-break/line-break-auto-half-kana-expected.html: Removed.
  • platform/chromium/css3/line-break/line-break-auto-sound-marks-expected.html: Removed.
Location:
trunk
Files:
68 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r133641 r133644  
     12012-11-06  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r133529 and r133562.
     4        http://trac.webkit.org/changeset/133529
     5        http://trac.webkit.org/changeset/133562
     6        https://bugs.webkit.org/show_bug.cgi?id=101371
     7
     8        Caused 15% memory regression on Chromium page cyclers
     9        (Requested by jsbell|gardener on #webkit).
     10
     11        * css3/line-break/line-break-auto-centered-expected.html: Removed.
     12        * css3/line-break/line-break-auto-centered.html: Removed.
     13        * css3/line-break/line-break-auto-half-kana-expected.html: Removed.
     14        * css3/line-break/line-break-auto-half-kana.html: Removed.
     15        * css3/line-break/line-break-auto-hyphens-expected.html: Removed.
     16        * css3/line-break/line-break-auto-hyphens.html: Removed.
     17        * css3/line-break/line-break-auto-inseparables-expected.html: Removed.
     18        * css3/line-break/line-break-auto-inseparables.html: Removed.
     19        * css3/line-break/line-break-auto-iteration-marks-expected.html: Removed.
     20        * css3/line-break/line-break-auto-iteration-marks.html: Removed.
     21        * css3/line-break/line-break-auto-postfixes-expected.html: Removed.
     22        * css3/line-break/line-break-auto-postfixes.html: Removed.
     23        * css3/line-break/line-break-auto-prefixes-expected.html: Removed.
     24        * css3/line-break/line-break-auto-prefixes.html: Removed.
     25        * css3/line-break/line-break-auto-sound-marks-expected.html: Removed.
     26        * css3/line-break/line-break-auto-sound-marks.html: Removed.
     27        * css3/line-break/line-break-loose-centered-expected.html: Removed.
     28        * css3/line-break/line-break-loose-centered.html: Removed.
     29        * css3/line-break/line-break-loose-half-kana-expected.html: Removed.
     30        * css3/line-break/line-break-loose-half-kana.html: Removed.
     31        * css3/line-break/line-break-loose-hyphens-expected.html: Removed.
     32        * css3/line-break/line-break-loose-hyphens.html: Removed.
     33        * css3/line-break/line-break-loose-inseparables-expected.html: Removed.
     34        * css3/line-break/line-break-loose-inseparables.html: Removed.
     35        * css3/line-break/line-break-loose-iteration-marks-expected.html: Removed.
     36        * css3/line-break/line-break-loose-iteration-marks.html: Removed.
     37        * css3/line-break/line-break-loose-postfixes-expected.html: Removed.
     38        * css3/line-break/line-break-loose-postfixes.html: Removed.
     39        * css3/line-break/line-break-loose-prefixes-expected.html: Removed.
     40        * css3/line-break/line-break-loose-prefixes.html: Removed.
     41        * css3/line-break/line-break-loose-sound-marks-expected.html: Removed.
     42        * css3/line-break/line-break-loose-sound-marks.html: Removed.
     43        * css3/line-break/line-break-normal-centered-expected.html: Removed.
     44        * css3/line-break/line-break-normal-centered.html: Removed.
     45        * css3/line-break/line-break-normal-half-kana-expected.html: Removed.
     46        * css3/line-break/line-break-normal-half-kana.html: Removed.
     47        * css3/line-break/line-break-normal-hyphens-expected.html: Removed.
     48        * css3/line-break/line-break-normal-hyphens.html: Removed.
     49        * css3/line-break/line-break-normal-inseparables-expected.html: Removed.
     50        * css3/line-break/line-break-normal-inseparables.html: Removed.
     51        * css3/line-break/line-break-normal-iteration-marks-expected.html: Removed.
     52        * css3/line-break/line-break-normal-iteration-marks.html: Removed.
     53        * css3/line-break/line-break-normal-postfixes-expected.html: Removed.
     54        * css3/line-break/line-break-normal-postfixes.html: Removed.
     55        * css3/line-break/line-break-normal-prefixes-expected.html: Removed.
     56        * css3/line-break/line-break-normal-prefixes.html: Removed.
     57        * css3/line-break/line-break-normal-sound-marks-expected.html: Removed.
     58        * css3/line-break/line-break-normal-sound-marks.html: Removed.
     59        * css3/line-break/line-break-strict-centered-expected.html: Removed.
     60        * css3/line-break/line-break-strict-centered.html: Removed.
     61        * css3/line-break/line-break-strict-half-kana-expected.html: Removed.
     62        * css3/line-break/line-break-strict-half-kana.html: Removed.
     63        * css3/line-break/line-break-strict-hyphens-expected.html: Removed.
     64        * css3/line-break/line-break-strict-hyphens.html: Removed.
     65        * css3/line-break/line-break-strict-inseparables-expected.html: Removed.
     66        * css3/line-break/line-break-strict-inseparables.html: Removed.
     67        * css3/line-break/line-break-strict-iteration-marks-expected.html: Removed.
     68        * css3/line-break/line-break-strict-iteration-marks.html: Removed.
     69        * css3/line-break/line-break-strict-postfixes-expected.html: Removed.
     70        * css3/line-break/line-break-strict-postfixes.html: Removed.
     71        * css3/line-break/line-break-strict-prefixes-expected.html: Removed.
     72        * css3/line-break/line-break-strict-prefixes.html: Removed.
     73        * css3/line-break/line-break-strict-sound-marks-expected.html: Removed.
     74        * css3/line-break/line-break-strict-sound-marks.html: Removed.
     75        * platform/chromium-android/css3/line-break/line-break-auto-half-kana-expected.html: Removed.
     76        * platform/chromium-android/css3/line-break/line-break-auto-sound-marks-expected.html: Removed.
     77        * platform/chromium/css3/line-break/line-break-auto-half-kana-expected.html: Removed.
     78        * platform/chromium/css3/line-break/line-break-auto-sound-marks-expected.html: Removed.
     79
    1802012-11-06  Dirk Pranke  <dpranke@chromium.org>
    281
  • trunk/Source/WebCore/ChangeLog

    r133642 r133644  
     12012-11-06  Sheriff Bot  <webkit.review.bot@gmail.com>
     2
     3        Unreviewed, rolling out r133529 and r133562.
     4        http://trac.webkit.org/changeset/133529
     5        http://trac.webkit.org/changeset/133562
     6        https://bugs.webkit.org/show_bug.cgi?id=101371
     7
     8        Caused 15% memory regression on Chromium page cyclers
     9        (Requested by jsbell|gardener on #webkit).
     10
     11        * platform/text/LineBreakIteratorPoolICU.h:
     12        (WebCore::LineBreakIteratorPool::take):
     13        (WebCore::LineBreakIteratorPool::put):
     14        (LineBreakIteratorPool):
     15        * platform/text/TextBreakIterator.cpp:
     16        (WebCore::acquireLineBreakIterator):
     17        * platform/text/TextBreakIterator.h:
     18        (WebCore):
     19        (WebCore::LazyLineBreakIterator::LazyLineBreakIterator):
     20        (WebCore::LazyLineBreakIterator::get):
     21        (WebCore::LazyLineBreakIterator::reset):
     22        (LazyLineBreakIterator):
     23        * platform/text/TextBreakIteratorICU.cpp:
     24        (WebCore::acquireLineBreakIterator):
     25        (WebCore::releaseLineBreakIterator):
     26        * platform/text/gtk/TextBreakIteratorGtk.cpp:
     27        (WebCore::setUpIterator):
     28        (WebCore::acquireLineBreakIterator):
     29        * platform/text/wince/TextBreakIteratorWinCE.cpp:
     30        (WebCore::acquireLineBreakIterator):
     31        * rendering/RenderBlockLineLayout.cpp:
     32        (WebCore::RenderBlock::LineBreaker::nextLineBreak):
     33        * rendering/RenderText.cpp:
     34        (WebCore::RenderText::computePreferredLogicalWidths):
     35        * rendering/RenderText.h:
     36        (WebCore):
     37        * rendering/break_lines.cpp:
     38        (WebCore):
     39        (WebCore::isBreakableSpace):
     40        (WebCore::needsLineBreakIterator):
     41        (WebCore::nextBreakablePosition):
     42        (WebCore::nextBreakablePositionIgnoringNBSP):
     43        * rendering/break_lines.h:
     44        (WebCore):
     45        (WebCore::isBreakable):
     46
    1472012-11-06  Peter Beverloo  <peter@chromium.org>
    248
  • trunk/Source/WebCore/platform/text/LineBreakIteratorPoolICU.h

    r133529 r133644  
    2727#define LineBreakIteratorPoolICU_h
    2828
    29 #include "TextBreakIterator.h"
    3029#include "TextBreakIteratorInternalICU.h"
     30#include <unicode/ubrk.h>
    3131#include <wtf/Assertions.h>
    3232#include <wtf/HashMap.h>
     
    3535#include <wtf/text/AtomicString.h>
    3636#include <wtf/text/CString.h>
    37 #include <wtf/text/StringBuilder.h>
    3837
    3938namespace WebCore {
     
    5049    static PassOwnPtr<LineBreakIteratorPool> create() { return adoptPtr(new LineBreakIteratorPool); }
    5150
    52     static String makeLocaleWithBreakKeyword(const AtomicString& locale, LineBreakIteratorMode mode)
     51    UBreakIterator* take(const AtomicString& locale)
    5352    {
    54         StringBuilder localeWithKeyword;
    55         localeWithKeyword.append(locale);
    56         localeWithKeyword.appendLiteral("@break=");
    57         switch (mode) {
    58         case LineBreakIteratorModeUAX14:
    59             break;
    60         case LineBreakIteratorModeUAX14Loose:
    61             localeWithKeyword.appendLiteral("loose");
    62             break;
    63         case LineBreakIteratorModeUAX14Normal:
    64             localeWithKeyword.appendLiteral("normal");
    65             break;
    66         case LineBreakIteratorModeUAX14Strict:
    67             localeWithKeyword.appendLiteral("strict");
    68             break;
    69         }
    70         return localeWithKeyword.toString();
    71     }
    72 
    73     TextBreakIterator* take(const AtomicString& locale, LineBreakIteratorMode mode, bool isCJK)
    74     {
    75         AtomicString localeWithOptionalBreakKeyword;
    76         if (mode == LineBreakIteratorModeUAX14)
    77             localeWithOptionalBreakKeyword = locale;
    78         else
    79             localeWithOptionalBreakKeyword = makeLocaleWithBreakKeyword(locale, mode);
    80 
    81         TextBreakIterator* iterator = 0;
     53        UBreakIterator* iterator = 0;
    8254        for (size_t i = 0; i < m_pool.size(); ++i) {
    83             if (m_pool[i].first == localeWithOptionalBreakKeyword) {
     55            if (m_pool[i].first == locale) {
    8456                iterator = m_pool[i].second;
    8557                m_pool.remove(i);
     
    8961
    9062        if (!iterator) {
    91             iterator = openLineBreakIterator(localeWithOptionalBreakKeyword, mode, isCJK);
    92             if (!iterator)
     63            UErrorCode openStatus = U_ZERO_ERROR;
     64            bool localeIsEmpty = locale.isEmpty();
     65            iterator = ubrk_open(UBRK_LINE, localeIsEmpty ? currentTextBreakLocaleID() : locale.string().utf8().data(), 0, 0, &openStatus);
     66            // locale comes from a web page and it can be invalid, leading ICU
     67            // to fail, in which case we fall back to the default locale.
     68            if (!localeIsEmpty && U_FAILURE(openStatus)) {
     69                openStatus = U_ZERO_ERROR;
     70                iterator = ubrk_open(UBRK_LINE, currentTextBreakLocaleID(), 0, 0, &openStatus);
     71            }
     72               
     73            if (U_FAILURE(openStatus)) {
     74                LOG_ERROR("ubrk_open failed with status %d", openStatus);
    9375                return 0;
     76            }
    9477        }
    9578
    9679        ASSERT(!m_vendedIterators.contains(iterator));
    97         m_vendedIterators.set(iterator, localeWithOptionalBreakKeyword);
     80        m_vendedIterators.set(iterator, locale);
    9881        return iterator;
    9982    }
    10083
    101     void put(TextBreakIterator* iterator)
     84    void put(UBreakIterator* iterator)
    10285    {
    10386        ASSERT_ARG(iterator, m_vendedIterators.contains(iterator));
    10487
    10588        if (m_pool.size() == capacity) {
    106             closeLineBreakIterator(m_pool[0].second);
     89            ubrk_close(m_pool[0].second);
    10790            m_pool.remove(0);
    10891        }
     
    11699    static const size_t capacity = 4;
    117100
    118     typedef pair<AtomicString, TextBreakIterator*> Entry;
     101    typedef pair<AtomicString, UBreakIterator*> Entry;
    119102    typedef Vector<Entry, capacity> Pool;
    120103    Pool m_pool;
    121     HashMap<TextBreakIterator*, AtomicString> m_vendedIterators;
     104    HashMap<UBreakIterator*, AtomicString> m_vendedIterators;
    122105
    123106    friend WTF::ThreadSpecific<LineBreakIteratorPool>::operator LineBreakIteratorPool*();
  • trunk/Source/WebCore/platform/text/TextBreakIterator.cpp

    r133562 r133644  
    5151
    5252#if !USE(ICU_UNICODE)
    53 TextBreakIterator* acquireLineBreakIterator(const LChar* string, int length, const AtomicString& locale, LineBreakIteratorMode mode, bool isCJK)
     53TextBreakIterator* acquireLineBreakIterator(const LChar* string, int length, const AtomicString& locale)
    5454{
    5555    Vector<UChar> utf16string(length);
    5656    for (int i = 0; i < length; ++i)
    5757        utf16string[i] = string[i];
    58     return acquireLineBreakIterator(utf16string.data(), length, locale, mode, isCJK);
     58    return acquireLineBreakIterator(utf16string.data(), length, locale);
    5959}
    6060#endif
  • trunk/Source/WebCore/platform/text/TextBreakIterator.h

    r133529 r133644  
    3232    // Note: The returned iterator is good only until you get another iterator, with the exception of acquireLineBreakIterator.
    3333
    34     enum LineBreakIteratorMode {
    35         LineBreakIteratorModeUAX14,
    36         LineBreakIteratorModeUAX14Loose,
    37         LineBreakIteratorModeUAX14Normal,
    38         LineBreakIteratorModeUAX14Strict,
    39     };
    40 
    4134    // This is similar to character break iterator in most cases, but is subject to
    4235    // platform UI conventions. One notable example where this can be different
     
    4639
    4740    TextBreakIterator* wordBreakIterator(const UChar*, int length);
    48     TextBreakIterator* acquireLineBreakIterator(const LChar*, int length, const AtomicString& locale, LineBreakIteratorMode, bool isCJK);
    49     TextBreakIterator* acquireLineBreakIterator(const UChar*, int length, const AtomicString& locale, LineBreakIteratorMode, bool isCJK);
     41    TextBreakIterator* acquireLineBreakIterator(const LChar*, int length, const AtomicString& locale);
     42    TextBreakIterator* acquireLineBreakIterator(const UChar*, int length, const AtomicString& locale);
    5043    void releaseLineBreakIterator(TextBreakIterator*);
    51     TextBreakIterator* openLineBreakIterator(const AtomicString& locale, LineBreakIteratorMode, bool isCJK);
    52     void closeLineBreakIterator(TextBreakIterator*&);
    5344    TextBreakIterator* sentenceBreakIterator(const UChar*, int length);
    5445
     
    6556    const int TextBreakDone = -1;
    6657
    67     bool isCJKLocale(const AtomicString&);
    68 
    6958class LazyLineBreakIterator {
    7059public:
    7160    LazyLineBreakIterator()
    72         : m_mode(LineBreakIteratorModeUAX14)
    73         , m_isCJK(false)
    74         , m_iterator(0)
     61        : m_iterator(0)
    7562    {
    7663    }
    7764
    78     LazyLineBreakIterator(String string, const AtomicString& locale = AtomicString(), LineBreakIteratorMode mode = LineBreakIteratorModeUAX14)
     65    LazyLineBreakIterator(String string, const AtomicString& locale = AtomicString())
    7966        : m_string(string)
    8067        , m_locale(locale)
    81         , m_mode(mode)
    8268        , m_iterator(0)
    8369    {
    84         m_isCJK = isCJKLocale(locale);
    8570    }
    8671
     
    9277
    9378    String string() const { return m_string; }
    94     bool isLooseCJKMode() const { return m_isCJK && m_mode == LineBreakIteratorModeUAX14Loose; }
    9579
    9680    TextBreakIterator* get()
     
    9882        if (!m_iterator) {
    9983            if (m_string.is8Bit())
    100                 m_iterator = acquireLineBreakIterator(m_string.characters8(), m_string.length(), m_locale, m_mode, m_isCJK);
     84                m_iterator = acquireLineBreakIterator(m_string.characters8(), m_string.length(), m_locale);
    10185            else
    102                 m_iterator = acquireLineBreakIterator(m_string.characters16(), m_string.length(), m_locale, m_mode, m_isCJK);
     86                m_iterator = acquireLineBreakIterator(m_string.characters16(), m_string.length(), m_locale);
    10387        }
    10488        return m_iterator;
    10589    }
    10690
    107     void reset(String string, const AtomicString& locale, LineBreakIteratorMode mode)
     91    void reset(String string, const AtomicString& locale)
    10892    {
    10993        if (m_iterator)
     
    11296        m_string = string;
    11397        m_locale = locale;
    114         m_mode = mode;
    115         m_isCJK = isCJKLocale(locale);
    11698        m_iterator = 0;
    11799    }
     
    120102    String m_string;
    121103    AtomicString m_locale;
    122     LineBreakIteratorMode m_mode;
    123     bool m_isCJK;
    124104    TextBreakIterator* m_iterator;
    125105};
  • trunk/Source/WebCore/platform/text/TextBreakIteratorICU.cpp

    r133529 r133644  
    2424
    2525#include "LineBreakIteratorPoolICU.h"
    26 #include <unicode/ubrk.h>
    27 #include <unicode/uloc.h>
    2826#include <wtf/Atomics.h>
    2927#include <wtf/text/WTFString.h>
     
    263261}
    264262
    265 TextBreakIterator* acquireLineBreakIterator(const LChar* string, int length, const AtomicString& locale, LineBreakIteratorMode mode, bool isCJK)
    266 {
    267     TextBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale, mode, isCJK);
     263TextBreakIterator* acquireLineBreakIterator(const LChar* string, int length, const AtomicString& locale)
     264{
     265    UBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale);
    268266    if (!iterator)
    269267        return 0;
     
    281279    }
    282280
    283     UBreakIterator* ubrkIter = reinterpret_cast<UBreakIterator*>(iterator);
    284281    UErrorCode setTextStatus = U_ZERO_ERROR;
    285     ubrk_setUText(ubrkIter, uTextLatin1, &setTextStatus);
     282    ubrk_setUText(iterator, uTextLatin1, &setTextStatus);
    286283    if (U_FAILURE(setTextStatus)) {
    287284        LOG_ERROR("ubrk_setUText failed with status %d", setTextStatus);
     
    291288    utext_close(uTextLatin1);
    292289
    293     return iterator;
    294 }
    295 
    296 TextBreakIterator* acquireLineBreakIterator(const UChar* string, int length, const AtomicString& locale, LineBreakIteratorMode mode, bool isCJK)
    297 {
    298     TextBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale, mode, isCJK);
     290    return reinterpret_cast<TextBreakIterator*>(iterator);
     291}
     292
     293TextBreakIterator* acquireLineBreakIterator(const UChar* string, int length, const AtomicString& locale)
     294{
     295    UBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale);
    299296    if (!iterator)
    300297        return 0;
    301298
    302     UBreakIterator* ubrkIter = reinterpret_cast<UBreakIterator*>(iterator);
    303299    UErrorCode setTextStatus = U_ZERO_ERROR;
    304     ubrk_setText(ubrkIter, string, length, &setTextStatus);
     300    ubrk_setText(iterator, string, length, &setTextStatus);
    305301    if (U_FAILURE(setTextStatus)) {
    306302        LOG_ERROR("ubrk_setText failed with status %d", setTextStatus);
     
    308304    }
    309305
    310     return iterator;
     306    return reinterpret_cast<TextBreakIterator*>(iterator);
    311307}
    312308
     
    315311    ASSERT_ARG(iterator, iterator);
    316312
    317     LineBreakIteratorPool::sharedPool().put(iterator);
    318 }
    319 
    320 // Recognize BCP47 compliant primary language values of 'zh', 'ja', 'ko'
    321 // (in any combination of case), optionally followed by subtags. Don't
    322 // recognize 3-letter variants 'chi'/'zho', 'jpn', or 'kor' since BCP47
    323 // requires use of shortest language tag.
    324 template<typename T>
    325 static bool isCJKLocale(const T* s, size_t length)
    326 {
    327     if (!s || length < 2)
    328         return false;
    329     T c1 = s[0];
    330     T c2 = s[1];
    331     T c3 = length == 2 ? 0 : s[2];
    332     if (!c3 || c3 == '-' || c3 == '_' || c3 == '@') {
    333         if (c1 == 'z' || c1 == 'Z')
    334             return c2 == 'h' || c2 == 'H';
    335         if (c1 == 'j' || c1 == 'J')
    336             return c2 == 'a' || c2 == 'A';
    337         if (c1 == 'k' || c1 == 'K')
    338             return c2 == 'o' || c2 == 'O';
    339     }
    340     return false;
    341 }
    342 
    343 bool isCJKLocale(const AtomicString& locale)
    344 {
    345     if (locale.isEmpty())
    346         return false;
    347     size_t length = locale.length();
    348     if (locale.is8Bit())
    349         return isCJKLocale<LChar>(locale.characters8(), length);
    350     return isCJKLocale<UChar>(locale.characters16(), length);
    351 }
    352 
    353 static void mapLineIteratorModeToRules(LineBreakIteratorMode, bool isCJK, String& rules);
    354 
    355 TextBreakIterator* openLineBreakIterator(const AtomicString& locale, LineBreakIteratorMode mode, bool isCJK)
    356 {
    357     UBreakIterator* ubrkIter;
    358     UErrorCode openStatus = U_ZERO_ERROR;
    359     bool isLocaleEmpty = locale.isEmpty();
    360     if ((mode == LineBreakIteratorModeUAX14) && !isCJK)
    361         ubrkIter = ubrk_open(UBRK_LINE, isLocaleEmpty ? currentTextBreakLocaleID() : locale.string().utf8().data(), 0, 0, &openStatus);
    362     else {
    363         UParseError parseStatus;
    364         String rules;
    365         mapLineIteratorModeToRules(mode, isCJK, rules);
    366         ubrkIter = ubrk_openRules(rules.characters(), rules.length(), 0, 0, &parseStatus, &openStatus);
    367     }
    368     // Locale comes from a web page and it can be invalid, leading ICU
    369     // to fail, in which case we fall back to the default locale (with default rules).
    370     if (!isLocaleEmpty && U_FAILURE(openStatus)) {
    371         openStatus = U_ZERO_ERROR;
    372         ubrkIter = ubrk_open(UBRK_LINE, currentTextBreakLocaleID(), 0, 0, &openStatus);
    373     }
    374 
    375     if (U_FAILURE(openStatus)) {
    376         LOG_ERROR("ubrk_open failed with status %d", openStatus);
    377         ASSERT(!ubrkIter);
    378     }
    379     return reinterpret_cast<TextBreakIterator*>(ubrkIter);
    380 }
    381 
    382 void closeLineBreakIterator(TextBreakIterator*& iterator)
    383 {
    384     UBreakIterator* ubrkIter = reinterpret_cast<UBreakIterator*>(iterator);
    385     ASSERT(ubrkIter);
    386     ubrk_close(ubrkIter);
    387     iterator = 0;
     313    LineBreakIteratorPool::sharedPool().put(reinterpret_cast<UBreakIterator*>(iterator));
    388314}
    389315
     
    585511}
    586512
    587 static const char* uax14Prologue =
    588     "!!chain;"
    589     "!!LBCMNoChain;"
    590     "!!lookAheadHardBreak;";
    591 
    592 static const char* uax14AssignmentsBefore =
    593     // explicitly enumerate $CJ since ICU versions prior to 49 don't support :LineBreak=Conditional_Japanese_Starter:
    594     "$CJ = ["
    595 #if (U_ICU_VERSION_MAJOR_NUM >= 4) && (U_ICU_VERSION_MINOR_NUM >= 9)
    596     ":LineBreak=Conditional_Japanese_Starter:"
    597 #else
    598     "\\u3041\\u3043\\u3045\\u3047\\u3049\\u3063\\u3083\\u3085\\u3087\\u308E\\u3095\\u3096\\u30A1\\u30A3\\u30A5\\u30A7"
    599     "\\u30A9\\u30C3\\u30E3\\u30E5\\u30E7\\u30EE\\u30F5\\u30F6\\u30FC"
    600     "\\u31F0\\u31F1\\u31F2\\u31F3\\u31F4\\u31F5\\u31F6\\u31F7\\u31F8\\u31F9\\u31FA\\u31FB\\u31FC\\u31FD\\u31FE\\u31FF"
    601     "\\uFF67\\uFF68\\uFF69\\uFF6A\\uFF6B\\uFF6C\\uFF6D\\uFF6E\\uFF6F\\uFF70"
    602 #endif
    603     "];";
    604 
    605 static const char* uax14AssignmentsCustomLooseCJK =
    606     "$BA_SUB = [\\u2010\\u2013];"
    607     "$EX_SUB = [\\u0021\\u003F\\uFF01\\uFF1F];"
    608     "$ID_SUB = '';"
    609     "$IN_SUB = [\\u2025\\u2026];"
    610     "$IS_SUB = [\\u003A\\u003B];"
    611     "$NS_SUB = [\\u203C\\u2047\\u2048\\u2049\\u3005\\u301C\\u303B\\u309D\\u309E\\u30A0\\u30FB\\u30FD\\u30FE\\uFF1A\\uFF1B\\uFF65];"
    612     "$PO_SUB = [\\u0025\\u00A2\\u00B0\\u2030\\u2032\\u2033\\u2103\\uFF05\\uFFE0];"
    613     "$PR_SUB = [\\u0024\\u00A3\\u00A5\\u20AC\\u2116\\uFF04\\uFFE1\\uFFE5];"
    614     "$ID_ADD = [$CJ $BA_SUB $EX_SUB $IN_SUB $IS_SUB $NS_SUB $PO_SUB $PR_SUB];"
    615     "$NS_ADD = '';";
    616 
    617 static const char* uax14AssignmentsCustomLooseNonCJK =
    618     "$BA_SUB = '';"
    619     "$EX_SUB = '';"
    620     "$ID_SUB = '';"
    621     "$IN_SUB = [\\u2025\\u2026];"
    622     "$IS_SUB = '';"
    623     "$NS_SUB = [\\u3005\\u303B\\u309D\\u309E\\u30FD\\u30FE];"
    624     "$PO_SUB = '';"
    625     "$PR_SUB = '';"
    626     "$ID_ADD = [$CJ $IN_SUB $NS_SUB];"
    627     "$NS_ADD = '';";
    628 
    629 static const char* uax14AssignmentsCustomNormalCJK =
    630     "$BA_SUB = [\\u2010\\u2013];"
    631     "$EX_SUB = '';"
    632     "$IN_SUB = '';"
    633     "$ID_SUB = '';"
    634     "$IS_SUB = '';"
    635     "$NS_SUB = [\\u301C\\u30A0];"
    636     "$PO_SUB = '';"
    637     "$PR_SUB = '';"
    638     "$ID_ADD = [$CJ $BA_SUB $NS_SUB];"
    639     "$NS_ADD = '';";
    640 
    641 static const char* uax14AssignmentsCustomNormalNonCJK =
    642     "$BA_SUB = '';"
    643     "$EX_SUB = '';"
    644     "$ID_SUB = '';"
    645     "$IN_SUB = '';"
    646     "$IS_SUB = '';"
    647     "$NS_SUB = '';"
    648     "$PO_SUB = '';"
    649     "$PR_SUB = '';"
    650     "$ID_ADD = [$CJ];"
    651     "$NS_ADD = '';";
    652 
    653 static const char* uax14AssignmentsCustomStrictCJK =
    654     "$BA_SUB = '';"
    655     "$EX_SUB = '';"
    656     "$ID_SUB = '';"
    657     "$IN_SUB = '';"
    658     "$IS_SUB = '';"
    659     "$NS_SUB = '';"
    660     "$PO_SUB = '';"
    661     "$PR_SUB = '';"
    662     "$ID_ADD = '';"
    663     "$NS_ADD = [$CJ];";
    664 
    665 #define uax14AssignmentsCustomStrictNonCJK      uax14AssignmentsCustomStrictCJK
    666 #define uax14AssignmentsCustomDefaultCJK        uax14AssignmentsCustomNormalCJK
    667 #define uax14AssignmentsCustomDefaultNonCJK     uax14AssignmentsCustomStrictNonCJK
    668 
    669 static const char* uax14AssignmentsAfter =
    670     "$AI = [:LineBreak = Ambiguous:];"
    671     "$AL = [:LineBreak = Alphabetic:];"
    672     "$BA = [[:LineBreak = Break_After:] - $BA_SUB];"
    673     "$BB = [:LineBreak = Break_Before:];"
    674     "$BK = [:LineBreak = Mandatory_Break:];"
    675     "$B2 = [:LineBreak = Break_Both:];"
    676     "$CB = [:LineBreak = Contingent_Break:];"
    677     "$CL = [:LineBreak = Close_Punctuation:];"
    678     "$CM = [:LineBreak = Combining_Mark:];"
    679     "$CP = [:LineBreak = Close_Parenthesis:];"
    680     "$CR = [:LineBreak = Carriage_Return:];"
    681     "$EX = [[:LineBreak = Exclamation:] - $EX_SUB];"
    682     "$GL = [:LineBreak = Glue:];"
    683 #if (U_ICU_VERSION_MAJOR_NUM >= 4) && (U_ICU_VERSION_MINOR_NUM >= 9)
    684     "$HL = [:LineBreak = Hebrew_Letter:];"
    685 #else
    686     "$HL = [[:Hebrew:] & [:Letter:]];"
    687 #endif
    688     "$HY = [:LineBreak = Hyphen:];"
    689     "$H2 = [:LineBreak = H2:];"
    690     "$H3 = [:LineBreak = H3:];"
    691     "$ID = [[[[:LineBreak = Ideographic:] - $CJ] $ID_ADD] - $ID_SUB];"
    692     "$IN = [[:LineBreak = Inseparable:] - $IN_SUB];"
    693     "$IS = [[:LineBreak = Infix_Numeric:] - $IS_SUB];"
    694     "$JL = [:LineBreak = JL:];"
    695     "$JV = [:LineBreak = JV:];"
    696     "$JT = [:LineBreak = JT:];"
    697     "$LF = [:LineBreak = Line_Feed:];"
    698     "$NL = [:LineBreak = Next_Line:];"
    699     "$NS = [[[[:LineBreak = Nonstarter:] - $CJ] $NS_ADD] - $NS_SUB];"
    700     "$NU = [:LineBreak = Numeric:];"
    701     "$OP = [:LineBreak = Open_Punctuation:];"
    702     "$PO = [[:LineBreak = Postfix_Numeric:] - $PO_SUB];"
    703     "$PR = [[:LineBreak = Prefix_Numeric:] - $PR_SUB];"
    704     "$QU = [:LineBreak = Quotation:];"
    705     "$SA = [:LineBreak = Complex_Context:];"
    706     "$SG = [:LineBreak = Surrogate:];"
    707     "$SP = [:LineBreak = Space:];"
    708     "$SY = [:LineBreak = Break_Symbols:];"
    709     "$WJ = [:LineBreak = Word_Joiner:];"
    710     "$XX = [:LineBreak = Unknown:];"
    711     "$ZW = [:LineBreak = ZWSpace:];"
    712     "$dictionary = [:LineBreak = Complex_Context:];"
    713     "$ALPlus = [$AL $AI $SA $SG $XX];"
    714     "$ALcm = $ALPlus $CM*;"
    715     "$BAcm = $BA $CM*;"
    716     "$BBcm = $BB $CM*;"
    717     "$B2cm = $B2 $CM*;"
    718     "$CLcm = $CL $CM*;"
    719     "$CPcm = $CP $CM*;"
    720     "$EXcm = $EX $CM*;"
    721     "$GLcm = $GL $CM*;"
    722     "$HLcm = $HL $CM*;"
    723     "$HYcm = $HY $CM*;"
    724     "$H2cm = $H2 $CM*;"
    725     "$H3cm = $H3 $CM*;"
    726     "$IDcm = $ID $CM*;"
    727     "$INcm = $IN $CM*;"
    728     "$IScm = $IS $CM*;"
    729     "$JLcm = $JL $CM*;"
    730     "$JVcm = $JV $CM*;"
    731     "$JTcm = $JT $CM*;"
    732     "$NScm = $NS $CM*;"
    733     "$NUcm = $NU $CM*;"
    734     "$OPcm = $OP $CM*;"
    735     "$POcm = $PO $CM*;"
    736     "$PRcm = $PR $CM*;"
    737     "$QUcm = $QU $CM*;"
    738     "$SYcm = $SY $CM*;"
    739     "$WJcm = $WJ $CM*;";
    740 
    741 static const char* uax14Forward =
    742     "!!forward;"
    743     "$CAN_CM = [^$SP $BK $CR $LF $NL $ZW $CM];"
    744     "$CANT_CM = [$SP $BK $CR $LF $NL $ZW $CM];"
    745     "$AL_FOLLOW_NOCM = [$BK $CR $LF $NL $ZW $SP];"
    746     "$AL_FOLLOW_CM = [$CL $CP $EX $HL $IS $SY $WJ $GL $OP $QU $BA $HY $NS $IN $NU $ALPlus];"
    747     "$AL_FOLLOW = [$AL_FOLLOW_NOCM $AL_FOLLOW_CM];"
    748     "$LB4Breaks = [$BK $CR $LF $NL];"
    749     "$LB4NonBreaks = [^$BK $CR $LF $NL];"
    750     "$LB8Breaks = [$LB4Breaks $ZW];"
    751     "$LB8NonBreaks = [[$LB4NonBreaks] - [$ZW]];"
    752     "$LB18NonBreaks = [$LB8NonBreaks - [$SP]];"
    753     "$LB18Breaks = [$LB8Breaks $SP];"
    754     "$LB20NonBreaks = [$LB18NonBreaks - $CB];"
    755     "$ALPlus $CM+;"
    756     "$BA $CM+;"
    757     "$BB $CM+;"
    758     "$B2 $CM+;"
    759     "$CL $CM+;"
    760     "$CP $CM+;"
    761     "$EX $CM+;"
    762     "$GL $CM+;"
    763     "$HL $CM+;"
    764     "$HY $CM+;"
    765     "$H2 $CM+;"
    766     "$H3 $CM+;"
    767     "$ID $CM+;"
    768     "$IN $CM+;"
    769     "$IS $CM+;"
    770     "$JL $CM+;"
    771     "$JV $CM+;"
    772     "$JT $CM+;"
    773     "$NS $CM+;"
    774     "$NU $CM+;"
    775     "$OP $CM+;"
    776     "$PO $CM+;"
    777     "$PR $CM+;"
    778     "$QU $CM+;"
    779     "$SY $CM+;"
    780     "$WJ $CM+;"
    781     "$CR $LF {100};"
    782     "$LB4NonBreaks? $LB4Breaks {100};"
    783     "$CAN_CM $CM* $LB4Breaks {100};"
    784     "$CM+ $LB4Breaks {100};"
    785     "$LB4NonBreaks [$SP $ZW];"
    786     "$CAN_CM $CM* [$SP $ZW];"
    787     "$CM+ [$SP $ZW];"
    788     "$CAN_CM $CM+;"
    789     "$CM+;"
    790     "$CAN_CM $CM* $WJcm;"
    791     "$LB8NonBreaks $WJcm;"
    792     "$CM+ $WJcm;"
    793     "$WJcm $CANT_CM;"
    794     "$WJcm $CAN_CM $CM*;"
    795     "$GLcm $CAN_CM $CM*;"
    796     "$GLcm $CANT_CM;"
    797     "[[$LB8NonBreaks] - [$SP $BA $HY]] $CM* $GLcm;"
    798     "$CM+ GLcm;"
    799     "$LB8NonBreaks $CL;"
    800     "$CAN_CM $CM* $CL;"
    801     "$CM+ $CL;"
    802     "$LB8NonBreaks $CP;"
    803     "$CAN_CM $CM* $CP;"
    804     "$CM+ $CP;"
    805     "$LB8NonBreaks $EX;"
    806     "$CAN_CM $CM* $EX;"
    807     "$CM+ $EX;"
    808     "$LB8NonBreaks $IS;"
    809     "$CAN_CM $CM* $IS;"
    810     "$CM+ $IS;"
    811     "$LB8NonBreaks $SY;"
    812     "$CAN_CM $CM* $SY;"
    813     "$CM+ $SY;"
    814     "$OPcm $SP* $CAN_CM $CM*;"
    815     "$OPcm $SP* $CANT_CM;"
    816     "$OPcm $SP+ $CM+ $AL_FOLLOW?;"
    817     "$QUcm $SP* $OPcm;"
    818     "($CLcm | $CPcm) $SP* $NScm;"
    819     "$B2cm $SP* $B2cm;"
    820     "$LB18NonBreaks $CM* $QUcm;"
    821     "$CM+ $QUcm;"
    822     "$QUcm .?;"
    823     "$QUcm $LB18NonBreaks $CM*;"
    824     "$LB20NonBreaks $CM* ($BAcm | $HYcm | $NScm); "
    825     "$BBcm [^$CB];"
    826     "$BBcm $LB20NonBreaks $CM*;"
    827     "$HLcm ($HYcm | $BAcm) [^$CB]?;"
    828     "($ALcm | $HLcm) $INcm;"
    829     "$CM+ $INcm;"
    830     "$IDcm $INcm;"
    831     "$INcm $INcm;"
    832     "$NUcm $INcm;"
    833     "$IDcm $POcm;"
    834     "$ALcm $NUcm;"
    835     "$HLcm $NUcm;"
    836     "$CM+ $NUcm;"
    837     "$NUcm $ALcm;"
    838     "$NUcm $HLcm;"
    839     "$PRcm $IDcm;"
    840     "$PRcm ($ALcm | $HLcm);"
    841     "$POcm ($ALcm | $HLcm);"
    842     "($PRcm | $POcm)? ($OPcm | $HYcm)? $NUcm ($NUcm | $SYcm | $IScm)* ($CLcm | $CPcm)? ($PRcm | $POcm)?;"
    843     "$JLcm ($JLcm | $JVcm | $H2cm | $H3cm);"
    844     "($JVcm | $H2cm) ($JVcm | $JTcm);"
    845     "($JTcm | $H3cm) $JTcm;"
    846     "($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $INcm;"
    847     "($JLcm | $JVcm | $JTcm | $H2cm | $H3cm) $POcm;"
    848     "$PRcm ($JLcm | $JVcm | $JTcm | $H2cm | $H3cm);"
    849     "($ALcm | $HLcm) ($ALcm | $HLcm);"
    850     "$CM+ ($ALcm | $HLcm);"
    851     "$IScm ($ALcm | $HLcm);"
    852     "($ALcm | $HLcm | $NUcm) $OPcm;"
    853     "$CM+ $OPcm;"
    854     "$CPcm ($ALcm | $HLcm | $NUcm);";
    855 
    856 static const char* uax14Reverse =
    857     "!!reverse;"
    858     "$CM+ $ALPlus;"
    859     "$CM+ $BA;"
    860     "$CM+ $BB;"
    861     "$CM+ $B2;"
    862     "$CM+ $CL;"
    863     "$CM+ $CP;"
    864     "$CM+ $EX;"
    865     "$CM+ $GL;"
    866     "$CM+ $HL;"
    867     "$CM+ $HY;"
    868     "$CM+ $H2;"
    869     "$CM+ $H3;"
    870     "$CM+ $ID;"
    871     "$CM+ $IN;"
    872     "$CM+ $IS;"
    873     "$CM+ $JL;"
    874     "$CM+ $JV;"
    875     "$CM+ $JT;"
    876     "$CM+ $NS;"
    877     "$CM+ $NU;"
    878     "$CM+ $OP;"
    879     "$CM+ $PO;"
    880     "$CM+ $PR;"
    881     "$CM+ $QU;"
    882     "$CM+ $SY;"
    883     "$CM+ $WJ;"
    884     "$CM+;"
    885     "$AL_FOLLOW $CM+ / ([$BK $CR $LF $NL $ZW {eof}] | $SP+ $CM+ $SP | $SP+ $CM* ([^$OP $CM $SP] | [$AL {eof}]));"
    886     "[$PR] / $CM+ [$BK $CR $LF $NL $ZW $SP {eof}];"
    887     "$LB4Breaks [$LB4NonBreaks-$CM];"
    888     "$LB4Breaks $CM+ $CAN_CM;"
    889     "$LF $CR;"
    890     "[$SP $ZW] [$LB4NonBreaks-$CM];"
    891     "[$SP $ZW] $CM+ $CAN_CM;"
    892     "$CM+ $CAN_CM;"
    893     "$CM* $WJ $CM* $CAN_CM;"
    894     "$CM* $WJ [$LB8NonBreaks-$CM];"
    895     "$CANT_CM $CM* $WJ;"
    896     "$CM* $CAN_CM $CM* $WJ;"
    897     "$CM* $GL $CM* [$LB8NonBreaks-[$CM $SP $BA $HY]];"
    898     "$CANT_CM $CM* $GL;"
    899     "$CM* $CAN_CM $CM* $GL;"
    900     "$CL $CM+ $CAN_CM;"
    901     "$CP $CM+ $CAN_CM;"
    902     "$EX $CM+ $CAN_CM;"
    903     "$IS $CM+ $CAN_CM;"
    904     "$SY $CM+ $CAN_CM;"
    905     "$CL [$LB8NonBreaks-$CM];"
    906     "$CP [$LB8NonBreaks-$CM];"
    907     "$EX [$LB8NonBreaks-$CM];"
    908     "$IS [$LB8NonBreaks-$CM];"
    909     "$SY [$LB8NonBreaks-$CM];"
    910     "[$CL $CP $EX $IS $SY] $CM+ $SP+ $CM* $OP; "
    911     "$CM* $CAN_CM $SP* $CM* $OP;"
    912     "$CANT_CM $SP* $CM* $OP;"
    913     "$AL_FOLLOW? $CM+ $SP $SP* $CM* $OP;"
    914     "$AL_FOLLOW_NOCM $CM+ $SP+ $CM* $OP;"
    915     "$CM* $AL_FOLLOW_CM $CM+ $SP+ $CM* $OP;"
    916     "$SY $CM $SP+ $OP;"
    917     "$CM* $OP $SP* $CM* $QU;"
    918     "$CM* $NS $SP* $CM* ($CL | $CP);"
    919     "$CM* $B2 $SP* $CM* $B2;"
    920     "$CM* $QU $CM* $CAN_CM;"
    921     "$CM* $QU $LB18NonBreaks;"
    922     "$CM* $CAN_CM $CM* $QU;"
    923     "$CANT_CM $CM* $QU;"
    924     "$CM* ($BA | $HY | $NS) $CM* [$LB20NonBreaks-$CM];"
    925     "$CM* [$LB20NonBreaks-$CM] $CM* $BB;"
    926     "[^$CB] $CM* $BB;"
    927     "[^$CB] $CM* ($HY | $BA) $CM* $HL;"
    928     "$CM* $IN $CM* ($ALPlus | $HL);"
    929     "$CM* $IN $CM* $ID;"
    930     "$CM* $IN $CM* $IN;"
    931     "$CM* $IN $CM* $NU;"
    932     "$CM* $PO $CM* $ID;"
    933     "$CM* $NU $CM* ($ALPlus | $HL);"
    934     "$CM* ($ALPlus | $HL) $CM* $NU;"
    935     "$CM* $ID $CM* $PR;"
    936     "$CM* ($ALPlus | $HL) $CM* $PR;"
    937     "$CM* ($ALPlus | $HL) $CM* $PO;"
    938     "($CM* ($PR | $PO))? ($CM* ($CL | $CP))? ($CM* ($NU | $IS | $SY))* $CM* $NU ($CM* ($OP | $HY))? ($CM* ($PR | $PO))?;"
    939     "$CM* ($H3 | $H2 | $JV | $JL) $CM* $JL;"
    940     "$CM* ($JT | $JV) $CM* ($H2 | $JV);"
    941     "$CM* $JT $CM* ($H3 | $JT);"
    942     "$CM* $IN $CM* ($H3 | $H2 | $JT | $JV | $JL);"
    943     "$CM* $PO $CM* ($H3 | $H2 | $JT | $JV | $JL);"
    944     "$CM* ($H3 | $H2 | $JT | $JV | $JL) $CM* $PR;"
    945     "$CM* ($ALPlus | $HL) $CM* ($ALPlus | $HL);"
    946     "$CM* ($ALPlus | $HL) $CM* $IS;"
    947     "$CM* $OP $CM* ($ALPlus | $HL | $NU);"
    948     "$CM* ($ALPlus | $HL | $NU) $CM* $CP;";
    949 
    950 static const char* uax14SafeForward =
    951     "!!safe_forward;"
    952     "[$CM $OP $QU $CL $CP $B2 $PR $HY $BA $SP $dictionary]+ [^$CM $OP $QU $CL $CP $B2 $PR $HY $BA $dictionary];"
    953     "$dictionary $dictionary;";
    954 
    955 static const char* uax14SafeReverse =
    956     "!!safe_reverse;"
    957     "$CM+ [^$CM $BK $CR $LF $NL $ZW $SP];"
    958     "$CM+ $SP / .;"
    959     "$SP+ $CM* $OP;"
    960     "$SP+ $CM* $QU;"
    961     "$SP+ $CM* ($CL | $CP);"
    962     "$SP+ $CM* $B2;"
    963     "$CM* ($HY | $BA) $CM* $HL;"
    964     "($CM* ($IS | $SY))+ $CM* $NU;"
    965     "($CL | $CP) $CM* ($NU | $IS | $SY);"
    966     "$dictionary $dictionary;";
    967 
    968 static void mapLineIteratorModeToRules(LineBreakIteratorMode mode, bool isCJK, String& rules)
    969 {
    970     StringBuilder rulesBuilder;
    971     rulesBuilder.append(uax14Prologue);
    972     rulesBuilder.append(uax14AssignmentsBefore);
    973     switch (mode) {
    974     case LineBreakIteratorModeUAX14:
    975         rulesBuilder.append(isCJK ? uax14AssignmentsCustomDefaultCJK : uax14AssignmentsCustomDefaultNonCJK);
    976         break;
    977     case LineBreakIteratorModeUAX14Loose:
    978         rulesBuilder.append(isCJK ? uax14AssignmentsCustomLooseCJK : uax14AssignmentsCustomLooseNonCJK);
    979         break;
    980     case LineBreakIteratorModeUAX14Normal:
    981         rulesBuilder.append(isCJK ? uax14AssignmentsCustomNormalCJK : uax14AssignmentsCustomNormalNonCJK);
    982         break;
    983     case LineBreakIteratorModeUAX14Strict:
    984         rulesBuilder.append(isCJK ? uax14AssignmentsCustomStrictCJK : uax14AssignmentsCustomStrictNonCJK);
    985         break;
    986     }
    987     rulesBuilder.append(uax14AssignmentsAfter);
    988     rulesBuilder.append(uax14Forward);
    989     rulesBuilder.append(uax14Reverse);
    990     rulesBuilder.append(uax14SafeForward);
    991     rulesBuilder.append(uax14SafeReverse);
    992     rules = rulesBuilder.toString();
    993 }
    994 
    995 }
     513}
  • trunk/Source/WebCore/platform/text/gtk/TextBreakIteratorGtk.cpp

    r133562 r133644  
    195195
    196196static TextBreakIterator* setUpIterator(bool& createdIterator, TextBreakIterator*& iterator,
    197     UBreakIteratorType type, const UChar* string, int length, LineBreakIteratorMode, bool)
     197    UBreakIteratorType type, const UChar* string, int length)
    198198{
    199199    if (!string)
     
    255255static TextBreakIterator* staticLineBreakIterator;
    256256
    257 TextBreakIterator* acquireLineBreakIterator(const UChar* string, int length, const AtomicString&, LineBreakIteratorMode mode, bool isCJK)
     257TextBreakIterator* acquireLineBreakIterator(const UChar* string, int length, const AtomicString&)
    258258{
    259259    TextBreakIterator* lineBreakIterator = 0;
    260260    if (!createdLineBreakIterator || staticLineBreakIterator) {
    261         setUpIterator(createdLineBreakIterator, staticLineBreakIterator, UBRK_LINE, string, length, mode, isCJK);
     261        setUpIterator(createdLineBreakIterator, staticLineBreakIterator, UBRK_LINE, string, length);
    262262        swap(staticLineBreakIterator, lineBreakIterator);
    263263    }
     
    265265    if (!lineBreakIterator) {
    266266        bool createdNewLineBreakIterator = false;
    267         setUpIterator(createdNewLineBreakIterator, lineBreakIterator, UBRK_LINE, string, length, mode, isCJK);
     267        setUpIterator(createdNewLineBreakIterator, lineBreakIterator, UBRK_LINE, string, length);
    268268    }
    269269
  • trunk/Source/WebCore/platform/text/wince/TextBreakIteratorWinCE.cpp

    r133562 r133644  
    257257static TextBreakIterator* staticLineBreakIterator;
    258258
    259 TextBreakIterator* acquireLineBreakIterator(const UChar* string, int length, const AtomicString&, LineBreakIteratorMode, bool)
     259TextBreakIterator* acquireLineBreakIterator(const UChar* string, int length, const AtomicString&)
    260260{
    261261    TextBreakIterator* lineBreakIterator = 0;
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r133529 r133644  
    25502550            bool breakAll = currentStyle->wordBreak() == BreakAllWordBreak && autoWrap;
    25512551            float hyphenWidth = 0;
    2552             bool isLooseCJKMode = false;
    25532552
    25542553            if (t->isWordBreak()) {
     
    25632562                renderTextInfo.m_font = &f;
    25642563                renderTextInfo.m_layout = f.createLayout(t, width.currentWidth(), collapseWhiteSpace);
    2565                 renderTextInfo.m_lineBreakIterator.reset(t->text(), style->locale(), mapLineBreakToIteratorMode(blockStyle->lineBreak()));
    2566                 isLooseCJKMode = renderTextInfo.m_lineBreakIterator.isLooseCJKMode();
     2564                renderTextInfo.m_lineBreakIterator.reset(t->text(), style->locale());
    25672565            } else if (renderTextInfo.m_layout && renderTextInfo.m_font != &f) {
    25682566                renderTextInfo.m_font = &f;
     
    26012599                }
    26022600
    2603                 bool betweenWords = c == '\n' || (currWS != PRE && !atStart && isBreakable(renderTextInfo.m_lineBreakIterator, current.m_pos, current.m_nextBreakablePosition, breakNBSP, isLooseCJKMode)
     2601                bool betweenWords = c == '\n' || (currWS != PRE && !atStart && isBreakable(renderTextInfo.m_lineBreakIterator, current.m_pos, current.m_nextBreakablePosition, breakNBSP)
    26042602                    && (style->hyphens() != HyphensNone || (current.previousInSameNode() != softHyphen)));
    26052603
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r133529 r133644  
    936936}
    937937
    938 LineBreakIteratorMode mapLineBreakToIteratorMode(LineBreak lineBreak)
    939 {
    940     switch (lineBreak) {
    941     case LineBreakAuto:
    942     case LineBreakAfterWhiteSpace:
    943         return LineBreakIteratorModeUAX14;
    944     case LineBreakLoose:
    945         return LineBreakIteratorModeUAX14Loose;
    946     case LineBreakNormal:
    947         return LineBreakIteratorModeUAX14Normal;
    948     case LineBreakStrict:
    949         return LineBreakIteratorModeUAX14Strict;
    950     }
    951     return LineBreakIteratorModeUAX14;
    952 }
    953 
    954938void RenderText::computePreferredLogicalWidths(float leadWidth, HashSet<const SimpleFontData*>& fallbackFonts, GlyphOverflow& glyphOverflow)
    955939{
     
    976960    float wordSpacing = styleToUse->wordSpacing();
    977961    int len = textLength();
    978     LazyLineBreakIterator breakIterator(m_text, styleToUse->locale(), mapLineBreakToIteratorMode(styleToUse->lineBreak()));
     962    LazyLineBreakIterator breakIterator(m_text, styleToUse->locale());
    979963    bool needsWordSpacing = false;
    980964    bool ignoringSpaces = false;
     
    1011995    bool breakNBSP = styleToUse->autoWrap() && styleToUse->nbspMode() == SPACE;
    1012996    bool breakAll = (styleToUse->wordBreak() == BreakAllWordBreak || styleToUse->wordBreak() == BreakWordBreak) && styleToUse->autoWrap();
    1013     bool isLooseCJKMode = breakIterator.isLooseCJKMode();
    1014997
    1015998    for (int i = 0; i < len; i++) {
     
    10591042        }
    10601043
    1061         bool hasBreak = breakAll || isBreakable(breakIterator, i, nextBreakable, breakNBSP, isLooseCJKMode);
     1044        bool hasBreak = breakAll || isBreakable(breakIterator, i, nextBreakable, breakNBSP);
    10621045        bool betweenWords = true;
    10631046        int j = i;
     
    10671050                break;
    10681051            c = characterAt(j);
    1069             if (isBreakable(breakIterator, j, nextBreakable, breakNBSP, isLooseCJKMode) && characterAt(j - 1) != softHyphen)
     1052            if (isBreakable(breakIterator, j, nextBreakable, breakNBSP) && characterAt(j - 1) != softHyphen)
    10701053                break;
    10711054            if (breakAll) {
  • trunk/Source/WebCore/rendering/RenderText.h

    r133529 r133644  
    234234void applyTextTransform(const RenderStyle*, String&, UChar);
    235235
    236 LineBreakIteratorMode mapLineBreakToIteratorMode(LineBreak);
    237 
    238236} // namespace WebCore
    239237
  • trunk/Source/WebCore/rendering/break_lines.cpp

    r133529 r133644  
    3939namespace WebCore {
    4040
    41 // Parameterization for non-breaking space (U+00A0) behavior.
    42 enum NBSPBehavior {
    43     IgnoreNBSP,
    44     TreatNBSPAsBreak,
    45 };
    46 
    47 // Parameterization for loose mode behavior. In loose mode, we can't use the ASCII
    48 // table below since loose mode allows "$100" to break after '$' in content marked as CJK.
    49 enum LooseBehavior {
    50     NonLooseMode,
    51     LooseMode,
    52 };
    53 
    54 template<NBSPBehavior nbspBehavior>
     41template<bool treatNoBreakSpaceAsBreak>
    5542static inline bool isBreakableSpace(UChar ch)
    5643{
     
    6148        return true;
    6249    case noBreakSpace:
    63         return (nbspBehavior == TreatNBSPAsBreak);
     50        return treatNoBreakSpaceAsBreak;
    6451    default:
    6552        return false;
     
    153140}
    154141
    155 template<NBSPBehavior nbspBehavior>
     142template<bool treatNoBreakSpaceAsBreak>
    156143inline bool needsLineBreakIterator(UChar ch)
    157144{
    158     if (nbspBehavior == TreatNBSPAsBreak)
     145    if (treatNoBreakSpaceAsBreak)
    159146        return ch > asciiLineBreakTableLastChar;
    160147    return ch > asciiLineBreakTableLastChar && ch != noBreakSpace;
    161148}
    162149
    163 template<typename CharacterType, NBSPBehavior nbspBehavior, LooseBehavior looseBehavior>
     150template<typename CharacterType, bool treatNoBreakSpaceAsBreak>
    164151static inline int nextBreakablePosition(LazyLineBreakIterator& lazyBreakIterator, const CharacterType* str, unsigned length, int pos)
    165152{
     
    172159        CharacterType ch = str[i];
    173160
    174         // Don't use ASCII shortcut (shouldBreakAfter) if loose mode.
    175         if (isBreakableSpace<nbspBehavior>(ch) || ((looseBehavior != LooseMode) && shouldBreakAfter(lastLastCh, lastCh, ch)))
     161        if (isBreakableSpace<treatNoBreakSpaceAsBreak>(ch) || shouldBreakAfter(lastLastCh, lastCh, ch))
    176162            return i;
    177163
    178         // Always use line break iterator if loose mode.
    179         if ((looseBehavior == LooseMode) || needsLineBreakIterator<nbspBehavior>(ch) || needsLineBreakIterator<nbspBehavior>(lastCh)) {
     164        if (needsLineBreakIterator<treatNoBreakSpaceAsBreak>(ch) || needsLineBreakIterator<treatNoBreakSpaceAsBreak>(lastCh)) {
    180165            if (nextBreak < i && i) {
    181166                TextBreakIterator* breakIterator = lazyBreakIterator.get();
     
    183168                    nextBreak = textBreakFollowing(breakIterator, i - 1);
    184169            }
    185             if (i == nextBreak && !isBreakableSpace<nbspBehavior>(lastCh))
     170            if (i == nextBreak && !isBreakableSpace<treatNoBreakSpaceAsBreak>(lastCh))
    186171                return i;
    187172        }
     
    198183    String string = lazyBreakIterator.string();
    199184    if (string.is8Bit())
    200         return nextBreakablePosition<LChar, IgnoreNBSP, NonLooseMode>(lazyBreakIterator, string.characters8(), string.length(), pos);
    201     return nextBreakablePosition<UChar, IgnoreNBSP, NonLooseMode>(lazyBreakIterator, string.characters16(), string.length(), pos);
    202 }
    203 
    204 int nextBreakablePositionIgnoringNBSPLoose(LazyLineBreakIterator& lazyBreakIterator, int pos)
    205 {
    206     String string = lazyBreakIterator.string();
    207     if (string.is8Bit())
    208         return nextBreakablePosition<LChar, IgnoreNBSP, LooseMode>(lazyBreakIterator, string.characters8(), string.length(), pos);
    209     return nextBreakablePosition<UChar, IgnoreNBSP, LooseMode>(lazyBreakIterator, string.characters16(), string.length(), pos);
     185        return nextBreakablePosition<LChar, false>(lazyBreakIterator, string.characters8(), string.length(), pos);
     186    return nextBreakablePosition<UChar, false>(lazyBreakIterator, string.characters16(), string.length(), pos);
    210187}
    211188
     
    214191    String string = lazyBreakIterator.string();
    215192    if (string.is8Bit())
    216         return nextBreakablePosition<LChar, TreatNBSPAsBreak, NonLooseMode>(lazyBreakIterator, string.characters8(), string.length(), pos);
    217     return nextBreakablePosition<UChar, TreatNBSPAsBreak, NonLooseMode>(lazyBreakIterator, string.characters16(), string.length(), pos);
    218 }
    219 
    220 int nextBreakablePositionLoose(LazyLineBreakIterator& lazyBreakIterator, int pos)
    221 {
    222     String string = lazyBreakIterator.string();
    223     if (string.is8Bit())
    224         return nextBreakablePosition<LChar, TreatNBSPAsBreak, LooseMode>(lazyBreakIterator, string.characters8(), string.length(), pos);
    225     return nextBreakablePosition<UChar, TreatNBSPAsBreak, LooseMode>(lazyBreakIterator, string.characters16(), string.length(), pos);
     193        return nextBreakablePosition<LChar, true>(lazyBreakIterator, string.characters8(), string.length(), pos);
     194    return nextBreakablePosition<UChar, true>(lazyBreakIterator, string.characters16(), string.length(), pos);
    226195}
    227196
  • trunk/Source/WebCore/rendering/break_lines.h

    r133529 r133644  
    2929
    3030int nextBreakablePositionIgnoringNBSP(LazyLineBreakIterator&, int pos);
    31 int nextBreakablePositionIgnoringNBSPLoose(LazyLineBreakIterator&, int pos);
    3231int nextBreakablePosition(LazyLineBreakIterator&, int pos);
    33 int nextBreakablePositionLoose(LazyLineBreakIterator&, int pos);
    3432
    35 inline bool isBreakable(LazyLineBreakIterator& lazyBreakIterator, int pos, int& nextBreakable, bool breakNBSP, bool isLooseMode)
     33inline bool isBreakable(LazyLineBreakIterator& lazyBreakIterator, int pos, int& nextBreakable, bool breakNBSP)
    3634{
    3735    if (pos > nextBreakable) {
    38         if (isLooseMode) {
    39             if (breakNBSP)
    40                 nextBreakable = nextBreakablePositionLoose(lazyBreakIterator, pos);
    41             else
    42                 nextBreakable = nextBreakablePositionIgnoringNBSPLoose(lazyBreakIterator, pos);
    43         } else {
    44             if (breakNBSP)
    45                 nextBreakable = nextBreakablePosition(lazyBreakIterator, pos);
    46             else
    47                 nextBreakable = nextBreakablePositionIgnoringNBSP(lazyBreakIterator, pos);
    48         }
     36        if (breakNBSP)
     37            nextBreakable = nextBreakablePosition(lazyBreakIterator, pos);
     38        else
     39            nextBreakable = nextBreakablePositionIgnoringNBSP(lazyBreakIterator, pos);
    4940    }
    5041    return pos == nextBreakable;
Note: See TracChangeset for help on using the changeset viewer.