CachedCSSStyleSheet.h [plain text]
#pragma once
#include "CachedResource.h"
namespace WebCore {
class FrameLoader;
class StyleSheetContents;
class TextResourceDecoder;
struct CSSParserContext;
class CachedCSSStyleSheet final : public CachedResource {
public:
CachedCSSStyleSheet(CachedResourceRequest&&, const PAL::SessionID&, const CookieJar*);
virtual ~CachedCSSStyleSheet();
enum class MIMETypeCheckHint { Strict, Lax };
const String sheetText(MIMETypeCheckHint = MIMETypeCheckHint::Strict, bool* hasValidMIMEType = nullptr) const;
RefPtr<StyleSheetContents> restoreParsedStyleSheet(const CSSParserContext&, CachePolicy, FrameLoader&);
void saveParsedStyleSheet(Ref<StyleSheetContents>&&);
bool mimeTypeAllowedByNosniff() const;
private:
String responseMIMEType() const;
bool canUseSheet(MIMETypeCheckHint, bool* hasValidMIMEType) const;
bool mayTryReplaceEncodedData() const final { return true; }
void didAddClient(CachedResourceClient&) final;
void setEncoding(const String&) final;
String encoding() const final;
const TextResourceDecoder* textResourceDecoder() const final { return m_decoder.get(); }
void finishLoading(SharedBuffer*, const NetworkLoadMetrics&) final;
void destroyDecodedData() final;
void setBodyDataFrom(const CachedResource&) final;
void checkNotify(const NetworkLoadMetrics&) final;
RefPtr<TextResourceDecoder> m_decoder;
String m_decodedSheetText;
RefPtr<StyleSheetContents> m_parsedStyleSheetCache;
};
}
SPECIALIZE_TYPE_TRAITS_CACHED_RESOURCE(CachedCSSStyleSheet, CachedResource::Type::CSSStyleSheet)