summaryrefslogtreecommitdiffstats
path: root/Source/WebCore/dom/Text.cpp
diff options
context:
space:
mode:
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