Title: [89851] trunk/Source/WebCore
Revision
89851
Author
[email protected]
Date
2011-06-27 14:09:53 -0700 (Mon, 27 Jun 2011)

Log Message

2011-06-27  Joseph Pecoraro  <[email protected]>

        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.

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (89850 => 89851)


--- trunk/Source/WebCore/ChangeLog	2011-06-27 20:57:31 UTC (rev 89850)
+++ trunk/Source/WebCore/ChangeLog	2011-06-27 21:09:53 UTC (rev 89851)
@@ -1,3 +1,24 @@
+2011-06-27  Joseph Pecoraro  <[email protected]>
+
+        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.
+
 2011-06-27  Justin Garcia  <[email protected]>
 
         Reviewed by Ryosuke Niwa.

Modified: trunk/Source/WebCore/GNUmakefile.list.am (89850 => 89851)


--- trunk/Source/WebCore/GNUmakefile.list.am	2011-06-27 20:57:31 UTC (rev 89850)
+++ trunk/Source/WebCore/GNUmakefile.list.am	2011-06-27 21:09:53 UTC (rev 89851)
@@ -2784,6 +2784,7 @@
 	Source/WebCore/platform/text/BidiRunList.h \
 	Source/WebCore/platform/text/Hyphenation.cpp \
 	Source/WebCore/platform/text/Hyphenation.h \
+	Source/WebCore/platform/text/LineBreakIteratorPoolICU.h \
 	Source/WebCore/platform/text/LineEnding.cpp \
 	Source/WebCore/platform/text/LineEnding.h \
 	Source/WebCore/platform/text/LocalizedDate.h \

Modified: trunk/Source/WebCore/WebCore.gypi (89850 => 89851)


--- trunk/Source/WebCore/WebCore.gypi	2011-06-27 20:57:31 UTC (rev 89850)
+++ trunk/Source/WebCore/WebCore.gypi	2011-06-27 21:09:53 UTC (rev 89851)
@@ -929,6 +929,7 @@
             'platform/text/BidiRunList.h',
             'platform/text/BidiContext.h',
             'platform/text/BidiResolver.h',
+            'platform/text/LineBreakIteratorPoolICU.h',
             'platform/text/LineEnding.h',
             'platform/text/PlatformString.h',
             'platform/text/QuotedPrintable.h',

Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (89850 => 89851)


--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-06-27 20:57:31 UTC (rev 89850)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj	2011-06-27 21:09:53 UTC (rev 89851)
@@ -31257,6 +31257,9 @@
 					>
 				</File>
 				<File
+					RelativePath="..\platform\text\LineBreakIteratorPoolICU.h"
+					>
+				<File
 					RelativePath="..\platform\text\LineEnding.cpp"
 					>
 				</File>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (89850 => 89851)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-06-27 20:57:31 UTC (rev 89850)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2011-06-27 21:09:53 UTC (rev 89851)
@@ -3264,6 +3264,7 @@
 		A5732B0F136A1715005C8D7C /* LocalizedDateNone.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5732B0E136A1715005C8D7C /* LocalizedDateNone.cpp */; };
 		A59E3C1E11580F510072928E /* KeyEventCodesIPhone.h in Headers */ = {isa = PBXBuildFile; fileRef = A59E3C1C11580F510072928E /* KeyEventCodesIPhone.h */; };
 		A59E3C1F11580F510072928E /* KeyEventIPhone.mm in Sources */ = {isa = PBXBuildFile; fileRef = A59E3C1D11580F510072928E /* KeyEventIPhone.mm */; };
+		A5ABB78713B904BC00F197E3 /* LineBreakIteratorPoolICU.h in Headers */ = {isa = PBXBuildFile; fileRef = A5ABB78613B904BC00F197E3 /* LineBreakIteratorPoolICU.h */; };
 		A5AFB34F115151A700B045CB /* StepRange.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A5AFB34D115151A700B045CB /* StepRange.cpp */; };
 		A5AFB350115151A700B045CB /* StepRange.h in Headers */ = {isa = PBXBuildFile; fileRef = A5AFB34E115151A700B045CB /* StepRange.h */; };
 		A6148A6212E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = A6148A6112E41D3A0044A784 /* DOMHTMLKeygenElementInternal.h */; };
@@ -9779,6 +9780,7 @@
 		A5732B0E136A1715005C8D7C /* LocalizedDateNone.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = LocalizedDateNone.cpp; sourceTree = "<group>"; };
 		A59E3C1C11580F510072928E /* KeyEventCodesIPhone.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyEventCodesIPhone.h; path = iphone/KeyEventCodesIPhone.h; sourceTree = "<group>"; };
 		A59E3C1D11580F510072928E /* KeyEventIPhone.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = KeyEventIPhone.mm; path = iphone/KeyEventIPhone.mm; sourceTree = "<group>"; };
+		A5ABB78613B904BC00F197E3 /* LineBreakIteratorPoolICU.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LineBreakIteratorPoolICU.h; sourceTree = "<group>"; };
 		A5AFB34D115151A700B045CB /* StepRange.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StepRange.cpp; sourceTree = "<group>"; };
 		A5AFB34E115151A700B045CB /* StepRange.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StepRange.h; sourceTree = "<group>"; };
 		A5C974CF11485FF10066F2AB /* KeyEventCocoa.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = KeyEventCocoa.h; path = cocoa/KeyEventCocoa.h; sourceTree = "<group>"; };
@@ -18102,6 +18104,7 @@
 				B2C3D9F40D006C1D00EF6F26 /* BidiResolver.h */,
 				A8C402921348B2220063F1E5 /* BidiRunList.h */,
 				375CD231119D43C800A2A859 /* Hyphenation.h */,
+				A5ABB78613B904BC00F197E3 /* LineBreakIteratorPoolICU.h */,
 				89B5EA9F11E8003D00F2367E /* LineEnding.cpp */,
 				89B5EAA011E8003D00F2367E /* LineEnding.h */,
 				A5732B0C136A16C4005C8D7C /* LocalizedDate.h */,
@@ -23079,6 +23082,7 @@
 				087558C613B4A57D00F49307 /* SurrogatePairAwareTextIterator.h in Headers */,
 				0863951613B5FE5700BB344D /* SVGAnimatedPath.h in Headers */,
 				431A2F9C13B6F2B0007791E4 /* SVGAnimatedNumberOptionalNumber.h in Headers */,
+				A5ABB78713B904BC00F197E3 /* LineBreakIteratorPoolICU.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

Added: trunk/Source/WebCore/platform/text/LineBreakIteratorPoolICU.h (0 => 89851)


--- trunk/Source/WebCore/platform/text/LineBreakIteratorPoolICU.h	                        (rev 0)
+++ trunk/Source/WebCore/platform/text/LineBreakIteratorPoolICU.h	2011-06-27 21:09:53 UTC (rev 89851)
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2011 Apple Inc. All Rights Reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef LineBreakIteratorPoolICU_h
+#define LineBreakIteratorPoolICU_h
+
+#include "TextBreakIteratorInternalICU.h"
+#include <unicode/ubrk.h>
+#include <wtf/Assertions.h>
+#include <wtf/HashMap.h>
+#include <wtf/text/CString.h>
+
+namespace WebCore {
+
+class LineBreakIteratorPool {
+    WTF_MAKE_NONCOPYABLE(LineBreakIteratorPool);
+public:
+    static LineBreakIteratorPool& sharedPool()
+    {
+        ASSERT(isMainThread());
+        DEFINE_STATIC_LOCAL(LineBreakIteratorPool, pool, ());
+        return pool;
+    }
+
+    LineBreakIteratorPool() { }
+
+    UBreakIterator* take(const AtomicString& locale)
+    {
+        UBreakIterator* iterator = 0;
+        for (size_t i = 0; i < m_pool.size(); ++i) {
+            if (m_pool[i].first == locale) {
+                iterator = m_pool[i].second;
+                m_pool.remove(i);
+                break;
+            }
+        }
+
+        if (!iterator) {
+            UErrorCode openStatus = U_ZERO_ERROR;
+            iterator = ubrk_open(UBRK_LINE, locale.isEmpty() ? currentTextBreakLocaleID() : locale.string().utf8().data(), 0, 0, &openStatus);
+            if (U_FAILURE(openStatus)) {
+                LOG_ERROR("ubrk_open failed with status %d", openStatus);
+                return 0;
+            }
+        }
+
+        ASSERT(!m_vendedIterators.contains(iterator));
+        m_vendedIterators.set(iterator, locale);
+        return iterator;
+    }
+
+    void put(UBreakIterator* iterator)
+    {
+        ASSERT_ARG(iterator, m_vendedIterators.contains(iterator));
+
+        if (m_pool.size() == capacity) {
+            ubrk_close(m_pool[0].second);
+            m_pool.remove(0);
+        }
+
+        m_pool.append(Entry(m_vendedIterators.take(iterator), iterator));
+    }
+
+private:
+    static const size_t capacity = 4;
+
+    typedef pair<AtomicString, UBreakIterator*> Entry;
+    typedef Vector<Entry, capacity> Pool;
+    Pool m_pool;
+    HashMap<UBreakIterator*, AtomicString> m_vendedIterators;
+};
+
+}
+
+#endif

Modified: trunk/Source/WebCore/platform/text/TextBreakIteratorICU.cpp (89850 => 89851)


--- trunk/Source/WebCore/platform/text/TextBreakIteratorICU.cpp	2011-06-27 20:57:31 UTC (rev 89850)
+++ trunk/Source/WebCore/platform/text/TextBreakIteratorICU.cpp	2011-06-27 21:09:53 UTC (rev 89851)
@@ -22,12 +22,8 @@
 #include "config.h"
 #include "TextBreakIterator.h"
 
+#include "LineBreakIteratorPoolICU.h"
 #include "PlatformString.h"
-#include "TextBreakIteratorInternalICU.h"
-#include <unicode/ubrk.h>
-#include <wtf/Assertions.h>
-#include <wtf/HashMap.h>
-#include <wtf/text/CString.h>
 
 using namespace std;
 
@@ -72,64 +68,6 @@
         staticWordBreakIterator, UBRK_WORD, string, length);
 }
 
-class LineBreakIteratorPool {
-WTF_MAKE_NONCOPYABLE(LineBreakIteratorPool);
-public:
-    static LineBreakIteratorPool& sharedPool()
-    {
-        ASSERT(isMainThread());
-        DEFINE_STATIC_LOCAL(LineBreakIteratorPool, pool, ());
-        return pool;
-    }
-
-    UBreakIterator* take(const AtomicString& locale)
-    {
-        UBreakIterator* iterator = 0;
-        for (size_t i = 0; i < m_pool.size(); ++i) {
-            if (m_pool[i].first == locale) {
-                iterator = m_pool[i].second;
-                m_pool.remove(i);
-                break;
-            }
-        }
-
-        if (!iterator) {
-            UErrorCode openStatus = U_ZERO_ERROR;
-            iterator = ubrk_open(UBRK_LINE, locale.isEmpty() ? currentTextBreakLocaleID() : locale.string().utf8().data(), 0, 0, &openStatus);
-            if (U_FAILURE(openStatus)) {
-                LOG_ERROR("ubrk_open failed with status %d", openStatus);
-                return 0;
-            }
-        }
-
-        ASSERT(!m_vendedIterators.contains(iterator));
-        m_vendedIterators.set(iterator, locale);
-        return iterator;
-    }
-
-    void put(UBreakIterator* iterator)
-    {
-        ASSERT_ARG(iterator, m_vendedIterators.contains(iterator));
-
-        if (m_pool.size() == capacity) {
-            ubrk_close(m_pool[0].second);
-            m_pool.remove(0);
-        }
-
-        m_pool.append(Entry(m_vendedIterators.take(iterator), iterator));
-    }
-
-private:
-    LineBreakIteratorPool() { }
-
-    static const size_t capacity = 4;
-
-    typedef pair<AtomicString, UBreakIterator*> Entry;
-    typedef Vector<Entry, capacity> Pool;
-    Pool m_pool;
-    HashMap<UBreakIterator*, AtomicString> m_vendedIterators;
-};
-
 TextBreakIterator* acquireLineBreakIterator(const UChar* string, int length, const AtomicString& locale)
 {
     UBreakIterator* iterator = LineBreakIteratorPool::sharedPool().take(locale);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to