This source file includes following definitions.
- m_decoder
- didAddClient
- setEncoding
- encoding
- checkNotify
#include "config.h"
#include "core/fetch/XSLStyleSheetResource.h"
#include "RuntimeEnabledFeatures.h"
#include "core/fetch/ResourceClientWalker.h"
#include "core/fetch/StyleSheetResourceClient.h"
#include "core/html/parser/TextResourceDecoder.h"
#include "platform/SharedBuffer.h"
#include "wtf/Vector.h"
namespace WebCore {
XSLStyleSheetResource::XSLStyleSheetResource(const ResourceRequest& resourceRequest)
: StyleSheetResource(resourceRequest, XSLStyleSheet)
, m_decoder(TextResourceDecoder::create("text/xsl"))
{
ASSERT(RuntimeEnabledFeatures::xsltEnabled());
DEFINE_STATIC_LOCAL(const AtomicString, acceptXSLT, ("text/xml, application/xml, application/xhtml+xml, text/xsl, application/rss+xml, application/atom+xml", AtomicString::ConstructFromLiteral));
setAccept(acceptXSLT);
}
void XSLStyleSheetResource::didAddClient(ResourceClient* c)
{
ASSERT(c->resourceClientType() == StyleSheetResourceClient::expectedType());
Resource::didAddClient(c);
if (!isLoading())
static_cast<StyleSheetResourceClient*>(c)->setXSLStyleSheet(m_resourceRequest.url(), m_response.url(), m_sheet);
}
void XSLStyleSheetResource::setEncoding(const String& chs)
{
m_decoder->setEncoding(chs, TextResourceDecoder::EncodingFromHTTPHeader);
}
String XSLStyleSheetResource::encoding() const
{
return m_decoder->encoding().name();
}
void XSLStyleSheetResource::checkNotify()
{
if (m_data.get()) {
m_sheet = m_decoder->decode(m_data->data(), encodedSize());
m_sheet = m_sheet + m_decoder->flush();
}
ResourceClientWalker<StyleSheetResourceClient> w(m_clients);
while (StyleSheetResourceClient* c = w.next())
c->setXSLStyleSheet(m_resourceRequest.url(), m_response.url(), m_sheet);
}
}