summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/platform/text/TextBreakIteratorICU.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-24 11:24:40 +0100
committerBen Murdoch <benm@google.com>2011-06-02 09:53:15 +0100
commit81bc750723a18f21cd17d1b173cd2a4dda9cea6e (patch)
tree7a9e5ed86ff429fd347a25153107221543909b19 /Source/WebCore/platform/text/TextBreakIteratorICU.cpp
parent94088a6d336c1dd80a1e734af51e96abcbb689a7 (diff)
downloadexternal_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.zip
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.gz
external_webkit-81bc750723a18f21cd17d1b173cd2a4dda9cea6e.tar.bz2
Merge WebKit at r80534: Intial merge by Git
Change-Id: Ia7a83357124c9e1cdb1debf55d9661ec0bd09a61
Diffstat (limited to 'Source/WebCore/platform/text/TextBreakIteratorICU.cpp')
-rw-r--r--Source/WebCore/platform/text/TextBreakIteratorICU.cpp34
1 files changed, 29 insertions, 5 deletions
diff --git a/Source/WebCore/platform/text/TextBreakIteratorICU.cpp b/Source/WebCore/platform/text/TextBreakIteratorICU.cpp
index f5575ee..3be2d88 100644
--- a/Source/WebCore/platform/text/TextBreakIteratorICU.cpp
+++ b/Source/WebCore/platform/text/TextBreakIteratorICU.cpp
@@ -27,6 +27,8 @@
#include <unicode/ubrk.h>
#include <wtf/Assertions.h>
+using namespace std;
+
namespace WebCore {
static TextBreakIterator* setUpIterator(bool& createdIterator, TextBreakIterator*& iterator,
@@ -68,12 +70,34 @@ TextBreakIterator* wordBreakIterator(const UChar* string, int length)
staticWordBreakIterator, UBRK_WORD, string, length);
}
-TextBreakIterator* lineBreakIterator(const UChar* string, int length)
+static bool createdLineBreakIterator = false;
+static TextBreakIterator* staticLineBreakIterator;
+
+TextBreakIterator* acquireLineBreakIterator(const UChar* string, int length)
+{
+ TextBreakIterator* lineBreakIterator = 0;
+ if (!createdLineBreakIterator || staticLineBreakIterator) {
+ setUpIterator(createdLineBreakIterator, staticLineBreakIterator, UBRK_LINE, string, length);
+ swap(staticLineBreakIterator, lineBreakIterator);
+ }
+
+ if (!lineBreakIterator) {
+ bool createdNewLineBreakIterator = false;
+ setUpIterator(createdNewLineBreakIterator, lineBreakIterator, UBRK_LINE, string, length);
+ }
+
+ return lineBreakIterator;
+}
+
+void releaseLineBreakIterator(TextBreakIterator* iterator)
{
- static bool createdLineBreakIterator = false;
- static TextBreakIterator* staticLineBreakIterator;
- return setUpIterator(createdLineBreakIterator,
- staticLineBreakIterator, UBRK_LINE, string, length);
+ ASSERT(createdLineBreakIterator);
+ ASSERT(iterator);
+
+ if (!staticLineBreakIterator)
+ staticLineBreakIterator = iterator;
+ else
+ ubrk_close(reinterpret_cast<UBreakIterator*>(iterator));
}
TextBreakIterator* sentenceBreakIterator(const UChar* string, int length)