Commit 500f02ec authored by commit-queue@webkit.org's avatar commit-queue@webkit.org
Browse files

2011-02-15 Gavin Peters <gavinp@chromium.org>

        Reviewed by Antti Koivisto.

        SharedBuffer::buffer() does not do what you think.
        https://bugs.webkit.org/show_bug.cgi?id=54420

        No new tests.

        * inspector/InspectorResourceAgent.cpp:
        (WebCore::InspectorResourceAgent::resourceContentBase64):
        * platform/SharedBuffer.h:
        * platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
        (WebCore::JPEGImageReader::decode):
        (WebCore::JPEGImageDecoder::decode):
        * platform/image-decoders/webp/WEBPImageDecoder.cpp:
        (WebCore::WEBPImageDecoder::decode):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@78548 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent e5cbb2e8
2011-02-15 Gavin Peters <gavinp@chromium.org>
Reviewed by Antti Koivisto.
SharedBuffer::buffer() does not do what you think.
https://bugs.webkit.org/show_bug.cgi?id=54420
No new tests.
* inspector/InspectorResourceAgent.cpp:
(WebCore::InspectorResourceAgent::resourceContentBase64):
* platform/SharedBuffer.h:
* platform/image-decoders/jpeg/JPEGImageDecoder.cpp:
(WebCore::JPEGImageReader::decode):
(WebCore::JPEGImageDecoder::decode):
* platform/image-decoders/webp/WEBPImageDecoder.cpp:
(WebCore::WEBPImageDecoder::decode):
2011-02-15 Dirk Schulze <krit@webkit.org>
 
Reviewed by Nikolas Zimmermann.
......@@ -107,7 +107,7 @@ bool InspectorResourceAgent::resourceContentBase64(Frame* frame, const KURL& url
return false;
}
*result = base64Encode(data->buffer());
*result = base64Encode(data->data(), data->size());
return true;
}
......
......@@ -81,10 +81,6 @@ public:
unsigned size() const;
// Calling this function will force internal segmented buffers
// to be merged into a flat buffer. Use getSomeData() whenever possible
// for better performance.
const Vector<char>& buffer() const;
bool isEmpty() const { return !size(); }
......@@ -119,6 +115,13 @@ private:
SharedBuffer(const char*, int);
SharedBuffer(const unsigned char*, int);
// Calling this function will force internal segmented buffers
// to be merged into a flat buffer. Use getSomeData() whenever possible
// for better performance.
// As well, be aware that this method does *not* return any purgeable
// memory, which can be a source of bugs.
const Vector<char>& buffer() const;
void clearPlatformData();
void maybeTransferPlatformData();
bool hasPlatformData() const;
......
......@@ -179,7 +179,7 @@ public:
m_bytesToSkip = std::max(numBytes - bytesToSkip, static_cast<long>(0));
}
bool decode(const Vector<char>& data, bool onlySize)
bool decode(const SharedBuffer& data, bool onlySize)
{
m_decodingSizeOnly = onlySize;
......@@ -532,7 +532,7 @@ void JPEGImageDecoder::decode(bool onlySize)
// If we couldn't decode the image but we've received all the data, decoding
// has failed.
if (!m_reader->decode(m_data->buffer(), onlySize) && isAllDataReceived())
if (!m_reader->decode(*m_data, onlySize) && isAllDataReceived())
setFailed();
// If we're done decoding the image, we don't need the JPEGImageReader
// anymore. (If we failed, |m_reader| has already been cleared.)
......
......@@ -79,9 +79,9 @@ bool WEBPImageDecoder::decode(bool onlySize)
if (failed())
return false;
const size_t dataSize = m_data->buffer().size();
const size_t dataSize = m_data->size();
const uint8_t* dataBytes =
reinterpret_cast<const uint8_t*>(m_data->buffer().data());
reinterpret_cast<const uint8_t*>(m_data->data());
int width, height;
if (dataSize < sizeOfHeader)
return true;
......
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