summaryrefslogtreecommitdiffstats
path: root/WebCore/xml/XSLTProcessorLibxslt.cpp
diff options
context:
space:
mode:
authorBen Murdoch <benm@google.com>2011-05-05 14:36:32 +0100
committerBen Murdoch <benm@google.com>2011-05-10 15:38:30 +0100
commitf05b935882198ccf7d81675736e3aeb089c5113a (patch)
tree4ea0ca838d9ef1b15cf17ddb3928efb427c7e5a1 /WebCore/xml/XSLTProcessorLibxslt.cpp
parent60fbdcc62bced8db2cb1fd233cc4d1e4ea17db1b (diff)
downloadexternal_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.zip
external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.gz
external_webkit-f05b935882198ccf7d81675736e3aeb089c5113a.tar.bz2
Merge WebKit at r74534: Initial merge by git.
Change-Id: I6ccd1154fa1b19c2ec2a66878eb675738735f1eb
Diffstat (limited to 'WebCore/xml/XSLTProcessorLibxslt.cpp')
-rw-r--r--WebCore/xml/XSLTProcessorLibxslt.cpp25
1 files changed, 20 insertions, 5 deletions
diff --git a/WebCore/xml/XSLTProcessorLibxslt.cpp b/WebCore/xml/XSLTProcessorLibxslt.cpp
index af2987f..852dcd6 100644
--- a/WebCore/xml/XSLTProcessorLibxslt.cpp
+++ b/WebCore/xml/XSLTProcessorLibxslt.cpp
@@ -39,14 +39,14 @@
#include "XSLStyleSheet.h"
#include "XSLTExtensions.h"
#include "XSLTUnicodeSort.h"
-#include "loader.h"
#include "markup.h"
#include <libxslt/imports.h>
#include <libxslt/variables.h>
#include <libxslt/xsltutils.h>
#include <wtf/Assertions.h>
-#include <wtf/text/CString.h>
#include <wtf/Vector.h>
+#include <wtf/text/StringBuffer.h>
+#include <wtf/unicode/UTF8.h>
#if PLATFORM(MAC)
#include "SoftLinking.h"
@@ -161,9 +161,24 @@ static inline void setXSLTLoadCallBack(xsltDocLoaderFunc func, XSLTProcessor* pr
static int writeToVector(void* context, const char* buffer, int len)
{
Vector<UChar>& resultOutput = *static_cast<Vector<UChar>*>(context);
- String decodedChunk = String::fromUTF8(buffer, len);
- resultOutput.append(decodedChunk.characters(), decodedChunk.length());
- return len;
+
+ if (!len)
+ return 0;
+
+ StringBuffer stringBuffer(len);
+ UChar* bufferUChar = stringBuffer.characters();
+ UChar* bufferUCharEnd = bufferUChar + len;
+
+ const char* stringCurrent = buffer;
+ WTF::Unicode::ConversionResult result = WTF::Unicode::convertUTF8ToUTF16(&stringCurrent, buffer + len, &bufferUChar, bufferUCharEnd);
+ if (result != WTF::Unicode::conversionOK && result != WTF::Unicode::sourceExhausted) {
+ ASSERT_NOT_REACHED();
+ return -1;
+ }
+
+ int utf16Length = bufferUChar - stringBuffer.characters();
+ resultOutput.append(stringBuffer.characters(), utf16Length);
+ return stringCurrent - buffer;
}
static bool saveResultToString(xmlDocPtr resultDoc, xsltStylesheetPtr sheet, String& resultString)