diff options
Diffstat (limited to 'Source/WebCore/platform/text/gtk/TextBreakIteratorGtk.cpp')
-rw-r--r-- | Source/WebCore/platform/text/gtk/TextBreakIteratorGtk.cpp | 31 |
1 files changed, 27 insertions, 4 deletions
diff --git a/Source/WebCore/platform/text/gtk/TextBreakIteratorGtk.cpp b/Source/WebCore/platform/text/gtk/TextBreakIteratorGtk.cpp index 990e331..8f289f3 100644 --- a/Source/WebCore/platform/text/gtk/TextBreakIteratorGtk.cpp +++ b/Source/WebCore/platform/text/gtk/TextBreakIteratorGtk.cpp @@ -239,11 +239,34 @@ TextBreakIterator* wordBreakIterator(const UChar* string, int length) return setUpIterator(createdWordBreakIterator, 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) { - static bool createdLineBreakIterator = false; - static TextBreakIterator* staticLineBreakIterator; - return setUpIterator(createdLineBreakIterator, staticLineBreakIterator, UBRK_LINE, string, 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) +{ + ASSERT(createdLineBreakIterator); + ASSERT(iterator); + + if (!staticLineBreakIterator) + staticLineBreakIterator = iterator; + else + delete iterator; } TextBreakIterator* sentenceBreakIterator(const UChar* string, int length) |