summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/dom/Text.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/dom/Text.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/dom/Text.cpp')
-rw-r--r--Source/WebCore/dom/Text.cpp34
1 files changed, 6 insertions, 28 deletions
diff --git a/Source/WebCore/dom/Text.cpp b/Source/WebCore/dom/Text.cpp
index 34266f1..5a28e37 100644
--- a/Source/WebCore/dom/Text.cpp
+++ b/Source/WebCore/dom/Text.cpp
@@ -25,8 +25,6 @@
#include "ExceptionCode.h"
#include "RenderCombineText.h"
#include "RenderText.h"
-#include "TextBreakIterator.h"
-#include <wtf/text/CString.h>
#if ENABLE(SVG)
#include "RenderSVGInlineText.h"
@@ -304,37 +302,17 @@ PassRefPtr<Text> Text::virtualCreate(const String& data)
return create(document(), data);
}
-PassRefPtr<Text> Text::createWithLengthLimit(Document* document, const String& data, unsigned& charsLeft, unsigned maxChars)
+PassRefPtr<Text> Text::createWithLengthLimit(Document* document, const String& data, unsigned start, unsigned maxChars)
{
unsigned dataLength = data.length();
- if (charsLeft == dataLength && charsLeft <= maxChars) {
- charsLeft = 0;
+ if (!start && dataLength <= maxChars)
return create(document, data);
- }
- unsigned start = dataLength - charsLeft;
- unsigned end = start + min(charsLeft, maxChars);
-
- // Check we are not on an unbreakable boundary.
- // Some text break iterator implementations work best if the passed buffer is as small as possible,
- // see <https://bugs.webkit.org/show_bug.cgi?id=29092>.
- // We need at least two characters look-ahead to account for UTF-16 surrogates.
- if (end < dataLength) {
- TextBreakIterator* it = characterBreakIterator(data.characters() + start, (end + 2 > dataLength) ? dataLength - start : end - start + 2);
- if (!isTextBreak(it, end - start))
- end = textBreakPreceding(it, end - start) + start;
- }
-
- // If we have maxChars of unbreakable characters the above could lead to
- // an infinite loop.
- // FIXME: It would be better to just have the old value of end before calling
- // textBreakPreceding rather than this, because this exceeds the length limit.
- if (end <= start)
- end = dataLength;
-
- charsLeft = dataLength - end;
- return create(document, data.substring(start, end - start));
+ RefPtr<Text> result = Text::create(document, String());
+ result->parserAppendData(data.characters() + start, dataLength - start, maxChars);
+
+ return result;
}
#ifndef NDEBUG