CachedXSLStyleSheet.cpp [plain text]
#include "config.h"
#include "CachedXSLStyleSheet.h"
#include "Cache.h"
#include "CachedResourceClient.h"
#include "CachedResourceClientWalker.h"
#include "Decoder.h"
#include "loader.h"
#include <wtf/Vector.h>
namespace WebCore {
#ifdef KHTML_XSLT
CachedXSLStyleSheet::CachedXSLStyleSheet(DocLoader* dl, const String &url, CachePolicy cachePolicy)
: CachedResource(url, XSLStyleSheet, cachePolicy)
{
setAccept("text/xml, application/xml, application/xhtml+xml, text/xsl, application/rss+xml, application/atom+xml");
cache()->loader()->load(dl, this, false);
m_loading = true;
m_decoder = new Decoder;
}
void CachedXSLStyleSheet::ref(CachedResourceClient *c)
{
CachedResource::ref(c);
if (!m_loading)
c->setStyleSheet(m_url, m_sheet);
}
void CachedXSLStyleSheet::setCharset( const DeprecatedString &chs )
{
if (!chs.isEmpty())
m_decoder->setEncodingName(chs.latin1(), Decoder::EncodingFromHTTPHeader);
}
void CachedXSLStyleSheet::data(Vector<char>& data, bool allDataReceived)
{
if (!allDataReceived)
return;
setEncodedSize(data.size());
m_sheet = String(m_decoder->decode(data.data(), encodedSize()));
m_loading = false;
checkNotify();
}
void CachedXSLStyleSheet::checkNotify()
{
if (m_loading)
return;
CachedResourceClientWalker w(m_clients);
while (CachedResourceClient *c = w.next())
c->setStyleSheet(m_url, m_sheet);
}
void CachedXSLStyleSheet::error()
{
m_loading = false;
checkNotify();
}
#endif
}