Commit 24a73d7a authored by paroga@webkit.org's avatar paroga@webkit.org

2010-12-11 Patrick Gansterer <paroga@webkit.org>

        Reviewed by Darin Adler.

        Add an overload to makeString for Vector<char>
        https://bugs.webkit.org/show_bug.cgi?id=50123

        Also cleanup StringTypeAdapter.

        * wtf/text/StringConcatenate.h:
2010-12-11  Patrick Gansterer  <paroga@webkit.org>

        Reviewed by Darin Adler.

        Add an overload to makeString for Vector<char>
        https://bugs.webkit.org/show_bug.cgi?id=50123

        This also contains a segfault fix for ImageBuffer::toDataURL of the Haiku port.

        * platform/graphics/cg/ImageBufferCG.cpp:
        (WebCore::ImageBuffer::toDataURL):
        * platform/graphics/gtk/ImageBufferGtk.cpp:
        (WebCore::ImageBuffer::toDataURL):
        * platform/graphics/haiku/ImageBufferHaiku.cpp:
        (WebCore::ImageBuffer::toDataURL):
        * platform/graphics/skia/ImageBufferSkia.cpp:
        (WebCore::ImageBuffer::toDataURL):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@73853 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1ce7a1f1
2010-12-11 Patrick Gansterer <paroga@webkit.org>
Reviewed by Darin Adler.
Add an overload to makeString for Vector<char>
https://bugs.webkit.org/show_bug.cgi?id=50123
Also cleanup StringTypeAdapter.
* wtf/text/StringConcatenate.h:
2010-12-10 Siddharth Mathur <siddharth.mathur@nokia.com>
Reviewed by Eric Seidel.
......
......@@ -68,7 +68,7 @@ template<>
class StringTypeAdapter<char*> {
public:
StringTypeAdapter<char*>(char* buffer)
: m_buffer((unsigned char*)buffer)
: m_buffer(buffer)
, m_length(strlen(buffer))
{
}
......@@ -77,12 +77,14 @@ public:
void writeTo(UChar* destination)
{
for (unsigned i = 0; i < m_length; ++i)
destination[i] = m_buffer[i];
for (unsigned i = 0; i < m_length; ++i) {
unsigned char c = m_buffer[i];
destination[i] = c;
}
}
private:
const unsigned char* m_buffer;
const char* m_buffer;
unsigned m_length;
};
......@@ -90,7 +92,7 @@ template<>
class StringTypeAdapter<const char*> {
public:
StringTypeAdapter<const char*>(const char* buffer)
: m_buffer((unsigned char*)buffer)
: m_buffer(buffer)
, m_length(strlen(buffer))
{
}
......@@ -99,35 +101,59 @@ public:
void writeTo(UChar* destination)
{
for (unsigned i = 0; i < m_length; ++i)
destination[i] = m_buffer[i];
for (unsigned i = 0; i < m_length; ++i) {
unsigned char c = m_buffer[i];
destination[i] = c;
}
}
private:
const unsigned char* m_buffer;
const char* m_buffer;
unsigned m_length;
};
template<>
class StringTypeAdapter<Vector<char> > {
public:
StringTypeAdapter<Vector<char> >(const Vector<char>& buffer)
: m_buffer(buffer)
{
}
size_t length() { return m_buffer.size(); }
void writeTo(UChar* destination)
{
for (size_t i = 0; i < m_buffer.size(); ++i) {
unsigned char c = m_buffer[i];
destination[i] = c;
}
}
private:
const Vector<char>& m_buffer;
};
template<>
class StringTypeAdapter<String> {
public:
StringTypeAdapter<String>(String& string)
: m_data(string.characters())
, m_length(string.length())
StringTypeAdapter<String>(const String& string)
: m_buffer(string)
{
}
unsigned length() { return m_length; }
unsigned length() { return m_buffer.length(); }
void writeTo(UChar* destination)
{
for (unsigned i = 0; i < m_length; ++i)
destination[i] = m_data[i];
const UChar* data = m_buffer.characters();
unsigned length = m_buffer.length();
for (unsigned i = 0; i < length; ++i)
destination[i] = data[i];
}
private:
const UChar* m_data;
unsigned m_length;
const String& m_buffer;
};
inline void sumWithOverflow(unsigned& total, unsigned addend, bool& overflow)
......
2010-12-11 Patrick Gansterer <paroga@webkit.org>
Reviewed by Darin Adler.
Add an overload to makeString for Vector<char>
https://bugs.webkit.org/show_bug.cgi?id=50123
This also contains a segfault fix for ImageBuffer::toDataURL of the Haiku port.
* platform/graphics/cg/ImageBufferCG.cpp:
(WebCore::ImageBuffer::toDataURL):
* platform/graphics/gtk/ImageBufferGtk.cpp:
(WebCore::ImageBuffer::toDataURL):
* platform/graphics/haiku/ImageBufferHaiku.cpp:
(WebCore::ImageBuffer::toDataURL):
* platform/graphics/skia/ImageBufferSkia.cpp:
(WebCore::ImageBuffer::toDataURL):
2010-12-10 Alexey Proskuryakov <ap@apple.com>
Mac build fix.
......
......@@ -361,9 +361,8 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality) con
Vector<char> out;
base64Encode(reinterpret_cast<const char*>(CFDataGetBytePtr(data.get())), CFDataGetLength(data.get()), out);
out.append('\0');
return makeString("data:", mimeType, ";base64,", out.data());
return makeString("data:", mimeType, ";base64,", out);
}
} // namespace WebCore
......@@ -66,9 +66,8 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality) con
Vector<char> out;
base64Encode(reinterpret_cast<const char*>(buffer.get()), bufferSize, out);
out.append('\0');
return makeString("data:", mimeType, ";base64,", out.data());
return makeString("data:", mimeType, ";base64,", out);
}
}
......@@ -368,7 +368,7 @@ String ImageBuffer::toDataURL(const String& mimeType, const double*) const
base64Encode(reinterpret_cast<const char*>(translatedStream.Buffer()),
translatedStream.BufferLength(), encodedBuffer);
return makeString("data:", mimeType, ";base64,", encodedBuffer.data());
return makeString("data:", mimeType, ";base64,", encodedBuffer);
}
} // namespace WebCore
......
......@@ -339,9 +339,8 @@ String ImageBuffer::toDataURL(const String& mimeType, const double* quality) con
Vector<char> base64Data;
base64Encode(*reinterpret_cast<Vector<char>*>(&encodedImage), base64Data);
base64Data.append('\0');
return makeString("data:", mimeType, ";base64,", base64Data.data());
return makeString("data:", mimeType, ";base64,", base64Data);
}
} // namespace WebCore
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment