Changeset 89851 in webkit


Ignore:
Timestamp:
Jun 27, 2011 2:09:53 PM (13 years ago)
Author:
Joseph Pecoraro
Message:

2011-06-27 Joseph Pecoraro <Joseph Pecoraro>

Reviewed by Darin Adler.

Extract LineBreakIteratorPool class into its own file
https://bugs.webkit.org/show_bug.cgi?id=63471

  • GNUmakefile.list.am:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj: Add the new file to builds that used TextBreakIteratorPoolICU.h.
  • platform/text/LineBreakIteratorPoolICU.h: Added. (WebCore::LineBreakIteratorPool::sharedPool): (WebCore::LineBreakIteratorPool::LineBreakIteratorPool): Expose the constructor so it can be used by others.
  • platform/text/TextBreakIteratorICU.cpp: Remove the old LineBreakIteratorPool implementation.
Location:
trunk/Source/WebCore
Files:
1 added
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r89844 r89851  
     12011-06-27  Joseph Pecoraro  <joepeck@webkit.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Extract LineBreakIteratorPool class into its own file
     6        https://bugs.webkit.org/show_bug.cgi?id=63471
     7
     8        * GNUmakefile.list.am:
     9        * WebCore.gypi:
     10        * WebCore.vcproj/WebCore.vcproj:
     11        * WebCore.xcodeproj/project.pbxproj:
     12        Add the new file to builds that used TextBreakIteratorPoolICU.h.
     13
     14        * platform/text/LineBreakIteratorPoolICU.h: Added.
     15        (WebCore::LineBreakIteratorPool::sharedPool):
     16        (WebCore::LineBreakIteratorPool::LineBreakIteratorPool):
     17        Expose the constructor so it can be used by others.
     18
     19        * platform/text/TextBreakIteratorICU.cpp:
     20        Remove the old LineBreakIteratorPool implementation.
     21
    1222011-06-27  Justin Garcia  <justin.garcia@apple.com>
    223
  • trunk/Source/WebCore/GNUmakefile.list.am

    r89833 r89851  
    27852785        Source/WebCore/platform/text/Hyphenation.cpp \
    27862786        Source/WebCore/platform/text/Hyphenation.h \
     2787        Source/WebCore/platform/text/LineBreakIteratorPoolICU.h \
    27872788        Source/WebCore/platform/text/LineEnding.cpp \
    27882789        Source/WebCore/platform/text/LineEnding.h \
  • trunk/Source/WebCore/WebCore.gypi

    r89837 r89851  
    930930            'platform/text/BidiContext.h',
    931931            'platform/text/BidiResolver.h',
     932            'platform/text/LineBreakIteratorPoolICU.h',
    932933            'platform/text/LineEnding.h',
    933934            'platform/text/PlatformString.h',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r89766 r89851  
    3125831258                                </File>
    3125931259                                <File
     31260                                        RelativePath="..\platform\text\LineBreakIteratorPoolICU.h"
     31261                                        >
     31262                                <File
    3126031263                                        RelativePath="..\platform\text\LineEnding.cpp"
    3126131264                                        >
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r89833 r89851  
    32653265                A59E3C1E11580F510072928E /* KeyEventCodesIPhone.h in Headers */ = {isa = PBXBuildFile; fileRef = A59E3C1C11580F510072928E /* KeyEventCodesIPhone.h */; };
    32663266                A59E3C1F11580F510072928E /* KeyEventIPhone.mm in Sources */ = {isa = PBXBuildFile; fileRef = A59E3C1D11580F510072928E /* KeyEventIPhone.mm */; };
     3267                A5ABB78713B904BC00F197E3 /* LineBreakIteratorPoolICU.h in Headers */ = {isa = PBXBuildFile; fileRef = A5ABB78613B904BC00F197E3 /* LineBreakIteratorPoolICU.h */; };
    32673268                A5AFB34F115151A700B045CB /* StepRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5AFB34D115151A700B045CB /* StepRange.cpp */; };
    32683269                A5AFB350115151A700B045CB /* StepRange.h in Headers */ = {isa = PBXBuildFile; fileRef = A5AFB34E115151A700B045CB /* StepRange.h */; };
     
    97809781                A59E3C1C11580F510072928E /* KeyEventCodesIPhone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyEventCodesIPhone.h; path = iphone/KeyEventCodesIPhone.h; sourceTree = "<group>"; };
    97819782                A59E3C1D11580F510072928E /* KeyEventIPhone.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = KeyEventIPhone.mm; path = iphone/KeyEventIPhone.mm; sourceTree = "<group>"; };
     9783                A5ABB78613B904BC00F197E3 /* LineBreakIteratorPoolICU.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineBreakIteratorPoolICU.h; sourceTree = "<group>"; };
    97829784                A5AFB34D115151A700B045CB /* StepRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StepRange.cpp; sourceTree = "<group>"; };
    97839785                A5AFB34E115151A700B045CB /* StepRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StepRange.h; sourceTree = "<group>"; };
     
    1810318105                                A8C402921348B2220063F1E5 /* BidiRunList.h */,
    1810418106                                375CD231119D43C800A2A859 /* Hyphenation.h */,
     18107                                A5ABB78613B904BC00F197E3 /* LineBreakIteratorPoolICU.h */,
    1810518108                                89B5EA9F11E8003D00F2367E /* LineEnding.cpp */,
    1810618109                                89B5EAA011E8003D00F2367E /* LineEnding.h */,
     
    2308023083                                0863951613B5FE5700BB344D /* SVGAnimatedPath.h in Headers */,
    2308123084                                431A2F9C13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.h in Headers */,
     23085                                A5ABB78713B904BC00F197E3 /* LineBreakIteratorPoolICU.h in Headers */,
    2308223086                        );
    2308323087                        runOnlyForDeploymentPostprocessing = 0;
  • trunk/Source/WebCore/platform/text/TextBreakIteratorICU.cpp

    r89592 r89851  
    2323#include "TextBreakIterator.h"
    2424
     25#include "LineBreakIteratorPoolICU.h"
    2526#include "PlatformString.h"
    26 #include "TextBreakIteratorInternalICU.h"
    27 #include <unicode/ubrk.h>
    28 #include <wtf/Assertions.h>
    29 #include <wtf/HashMap.h>
    30 #include <wtf/text/CString.h>
    3127
    3228using namespace std;
     
    7268        staticWordBreakIterator, UBRK_WORD, string, length);
    7369}
    74 
    75 class LineBreakIteratorPool {
    76 WTF_MAKE_NONCOPYABLE(LineBreakIteratorPool);
    77 public:
    78     static LineBreakIteratorPool& sharedPool()
    79     {
    80         ASSERT(isMainThread());
    81         DEFINE_STATIC_LOCAL(LineBreakIteratorPool, pool, ());
    82         return pool;
    83     }
    84 
    85     UBreakIterator* take(const AtomicString& locale)
    86     {
    87         UBreakIterator* iterator = 0;
    88         for (size_t i = 0; i < m_pool.size(); ++i) {
    89             if (m_pool[i].first == locale) {
    90                 iterator = m_pool[i].second;
    91                 m_pool.remove(i);
    92                 break;
    93             }
    94         }
    95 
    96         if (!iterator) {
    97             UErrorCode openStatus = U_ZERO_ERROR;
    98             iterator = ubrk_open(UBRK_LINE, locale.isEmpty() ? currentTextBreakLocaleID() : locale.string().utf8().data(), 0, 0, &openStatus);
    99             if (U_FAILURE(openStatus)) {
    100                 LOG_ERROR("ubrk_open failed with status %d", openStatus);
    101                 return 0;
    102             }
    103         }
    104 
    105         ASSERT(!m_vendedIterators.contains(iterator));
    106         m_vendedIterators.set(iterator, locale);
    107         return iterator;
    108     }
    109 
    110     void put(UBreakIterator* iterator)
    111     {
    112         ASSERT_ARG(iterator, m_vendedIterators.contains(iterator));
    113 
    114         if (m_pool.size() == capacity) {
    115             ubrk_close(m_pool[0].second);
    116             m_pool.remove(0);
    117         }
    118 
    119         m_pool.append(Entry(m_vendedIterators.take(iterator), iterator));
    120     }
    121 
    122 private:
    123     LineBreakIteratorPool() { }
    124 
    125     static const size_t capacity = 4;
    126 
    127     typedef pair<AtomicString, UBreakIterator*> Entry;
    128     typedef Vector<Entry, capacity> Pool;
    129     Pool m_pool;
    130     HashMap<UBreakIterator*, AtomicString> m_vendedIterators;
    131 };
    13270
    13371TextBreakIterator* acquireLineBreakIterator(const UChar* string, int length, const AtomicString& locale)
Note: See TracChangeset for help on using the changeset viewer.