#ifndef StyleRuleImport_h
#define StyleRuleImport_h
#include "CachedResourceHandle.h"
#include "CachedStyleSheetClient.h"
#include "StyleRule.h"
#include <wtf/TypeCasts.h>
namespace WebCore {
class CachedCSSStyleSheet;
class MediaQuerySet;
class StyleSheetContents;
class StyleRuleImport : public StyleRuleBase {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<StyleRuleImport> create(const String& href, PassRefPtr<MediaQuerySet>);
~StyleRuleImport();
StyleSheetContents* parentStyleSheet() const { return m_parentStyleSheet; }
void setParentStyleSheet(StyleSheetContents* sheet) { ASSERT(sheet); m_parentStyleSheet = sheet; }
void clearParentStyleSheet() { m_parentStyleSheet = 0; }
String href() const { return m_strHref; }
StyleSheetContents* styleSheet() const { return m_styleSheet.get(); }
bool isLoading() const;
MediaQuerySet* mediaQueries() const { return m_mediaQueries.get(); }
void requestStyleSheet();
private:
class ImportedStyleSheetClient : public CachedStyleSheetClient {
public:
ImportedStyleSheetClient(StyleRuleImport* ownerRule) : m_ownerRule(ownerRule) { }
virtual ~ImportedStyleSheetClient() { }
virtual void setCSSStyleSheet(const String& href, const URL& baseURL, const String& charset, const CachedCSSStyleSheet* sheet)
{
m_ownerRule->setCSSStyleSheet(href, baseURL, charset, sheet);
}
private:
StyleRuleImport* m_ownerRule;
};
void setCSSStyleSheet(const String& href, const URL& baseURL, const String& charset, const CachedCSSStyleSheet*);
friend class ImportedStyleSheetClient;
StyleRuleImport(const String& href, PassRefPtr<MediaQuerySet>);
StyleSheetContents* m_parentStyleSheet;
ImportedStyleSheetClient m_styleSheetClient;
String m_strHref;
RefPtr<MediaQuerySet> m_mediaQueries;
RefPtr<StyleSheetContents> m_styleSheet;
CachedResourceHandle<CachedCSSStyleSheet> m_cachedSheet;
bool m_loading;
};
}
SPECIALIZE_TYPE_TRAITS_BEGIN(WebCore::StyleRuleImport)
static bool isType(const WebCore::StyleRuleBase& rule) { return rule.isImportRule(); }
SPECIALIZE_TYPE_TRAITS_END()
#endif