CachedCSSStyleSheet.h [plain text]
#ifndef CachedCSSStyleSheet_h
#define CachedCSSStyleSheet_h
#include "CachedResource.h"
#include <wtf/Vector.h>
namespace WebCore {
class CachedResourceClient;
class StyleSheetContents;
class TextResourceDecoder;
struct CSSParserContext;
class CachedCSSStyleSheet final : public CachedResource {
public:
CachedCSSStyleSheet(const ResourceRequest&, const String& charset, SessionID);
virtual ~CachedCSSStyleSheet();
enum class MIMETypeCheck { Strict, Lax };
const String sheetText(MIMETypeCheck = MIMETypeCheck::Strict, bool* hasValidMIMEType = nullptr) const;
PassRefPtr<StyleSheetContents> restoreParsedStyleSheet(const CSSParserContext&, CachePolicy);
void saveParsedStyleSheet(Ref<StyleSheetContents>&&);
private:
bool canUseSheet(MIMETypeCheck, bool* hasValidMIMEType) const;
virtual bool mayTryReplaceEncodedData() const override { return true; }
virtual void didAddClient(CachedResourceClient*) override;
virtual void setEncoding(const String&) override;
virtual String encoding() const override;
virtual void finishLoading(SharedBuffer*) override;
virtual void destroyDecodedData() override;
protected:
virtual void checkNotify() override;
RefPtr<TextResourceDecoder> m_decoder;
String m_decodedSheetText;
RefPtr<StyleSheetContents> m_parsedStyleSheetCache;
};
}
SPECIALIZE_TYPE_TRAITS_CACHED_RESOURCE(CachedCSSStyleSheet, CachedResource::CSSStyleSheet)
#endif // CachedCSSStyleSheet_h