CachedSVGDocument.cpp [plain text]
#include "config.h"
#if ENABLE(SVG)
#include "CachedSVGDocument.h"
#include "CachedResourceClient.h"
#include "CachedResourceHandle.h"
#include "SharedBuffer.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
CachedSVGDocument::CachedSVGDocument(const ResourceRequest& request)
: CachedResource(request, SVGDocumentResource)
, m_decoder(TextResourceDecoder::create("application/xml"))
{
setAccept("image/svg+xml");
}
CachedSVGDocument::~CachedSVGDocument()
{
}
void CachedSVGDocument::setEncoding(const String& chs)
{
m_decoder->setEncoding(chs, TextResourceDecoder::EncodingFromHTTPHeader);
}
String CachedSVGDocument::encoding() const
{
return m_decoder->encoding().name();
}
void CachedSVGDocument::data(PassRefPtr<SharedBuffer> data, bool allDataReceived)
{
if (!allDataReceived)
return;
if (data) {
StringBuilder decodedText;
decodedText.append(m_decoder->decode(data->data(), data->size()));
decodedText.append(m_decoder->flush());
m_document = SVGDocument::create(0, response().url());
m_document->setContent(decodedText.toString());
}
setLoading(false);
checkNotify();
}
}
#endif