Changeset 89851 in webkit
- Timestamp:
- Jun 27, 2011 2:09:53 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r89844 r89851 1 2011-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 1 22 2011-06-27 Justin Garcia <justin.garcia@apple.com> 2 23 -
trunk/Source/WebCore/GNUmakefile.list.am
r89833 r89851 2785 2785 Source/WebCore/platform/text/Hyphenation.cpp \ 2786 2786 Source/WebCore/platform/text/Hyphenation.h \ 2787 Source/WebCore/platform/text/LineBreakIteratorPoolICU.h \ 2787 2788 Source/WebCore/platform/text/LineEnding.cpp \ 2788 2789 Source/WebCore/platform/text/LineEnding.h \ -
trunk/Source/WebCore/WebCore.gypi
r89837 r89851 930 930 'platform/text/BidiContext.h', 931 931 'platform/text/BidiResolver.h', 932 'platform/text/LineBreakIteratorPoolICU.h', 932 933 'platform/text/LineEnding.h', 933 934 'platform/text/PlatformString.h', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r89766 r89851 31258 31258 </File> 31259 31259 <File 31260 RelativePath="..\platform\text\LineBreakIteratorPoolICU.h" 31261 > 31262 <File 31260 31263 RelativePath="..\platform\text\LineEnding.cpp" 31261 31264 > -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r89833 r89851 3265 3265 A59E3C1E11580F510072928E /* KeyEventCodesIPhone.h in Headers */ = {isa = PBXBuildFile; fileRef = A59E3C1C11580F510072928E /* KeyEventCodesIPhone.h */; }; 3266 3266 A59E3C1F11580F510072928E /* KeyEventIPhone.mm in Sources */ = {isa = PBXBuildFile; fileRef = A59E3C1D11580F510072928E /* KeyEventIPhone.mm */; }; 3267 A5ABB78713B904BC00F197E3 /* LineBreakIteratorPoolICU.h in Headers */ = {isa = PBXBuildFile; fileRef = A5ABB78613B904BC00F197E3 /* LineBreakIteratorPoolICU.h */; }; 3267 3268 A5AFB34F115151A700B045CB /* StepRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5AFB34D115151A700B045CB /* StepRange.cpp */; }; 3268 3269 A5AFB350115151A700B045CB /* StepRange.h in Headers */ = {isa = PBXBuildFile; fileRef = A5AFB34E115151A700B045CB /* StepRange.h */; }; … … 9780 9781 A59E3C1C11580F510072928E /* KeyEventCodesIPhone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyEventCodesIPhone.h; path = iphone/KeyEventCodesIPhone.h; sourceTree = "<group>"; }; 9781 9782 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>"; }; 9782 9784 A5AFB34D115151A700B045CB /* StepRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StepRange.cpp; sourceTree = "<group>"; }; 9783 9785 A5AFB34E115151A700B045CB /* StepRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StepRange.h; sourceTree = "<group>"; }; … … 18103 18105 A8C402921348B2220063F1E5 /* BidiRunList.h */, 18104 18106 375CD231119D43C800A2A859 /* Hyphenation.h */, 18107 A5ABB78613B904BC00F197E3 /* LineBreakIteratorPoolICU.h */, 18105 18108 89B5EA9F11E8003D00F2367E /* LineEnding.cpp */, 18106 18109 89B5EAA011E8003D00F2367E /* LineEnding.h */, … … 23080 23083 0863951613B5FE5700BB344D /* SVGAnimatedPath.h in Headers */, 23081 23084 431A2F9C13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.h in Headers */, 23085 A5ABB78713B904BC00F197E3 /* LineBreakIteratorPoolICU.h in Headers */, 23082 23086 ); 23083 23087 runOnlyForDeploymentPostprocessing = 0; -
trunk/Source/WebCore/platform/text/TextBreakIteratorICU.cpp
r89592 r89851 23 23 #include "TextBreakIterator.h" 24 24 25 #include "LineBreakIteratorPoolICU.h" 25 26 #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>31 27 32 28 using namespace std; … … 72 68 staticWordBreakIterator, UBRK_WORD, string, length); 73 69 } 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 };132 70 133 71 TextBreakIterator* acquireLineBreakIterator(const UChar* string, int length, const AtomicString& locale)
Note: See TracChangeset
for help on using the changeset viewer.