#ifndef StyleRuleImport_h
#define StyleRuleImport_h
#include "core/css/StyleRule.h"
#include "core/fetch/ResourcePtr.h"
#include "core/fetch/StyleSheetResourceClient.h"
#include "heap/Handle.h"
namespace WebCore {
class CSSStyleSheetResource;
class MediaQuerySet;
class StyleSheetContents;
class StyleRuleImport : public StyleRuleBase {
WTF_MAKE_FAST_ALLOCATED_WILL_BE_REMOVED;
public:
static PassRefPtrWillBeRawPtr<StyleRuleImport> create(const String& href, PassRefPtrWillBeRawPtr<MediaQuerySet>);
~StyleRuleImport();
StyleSheetContents* parentStyleSheet() const { return m_parentStyleSheet; }
void setParentStyleSheet(StyleSheetContents* sheet) { ASSERT(sheet); m_parentStyleSheet = sheet; }
void clearParentStyleSheet() { m_parentStyleSheet = nullptr; }
String href() const { return m_strHref; }
StyleSheetContents* styleSheet() const { return m_styleSheet.get(); }
bool isLoading() const;
MediaQuerySet* mediaQueries() { return m_mediaQueries.get(); }
void requestStyleSheet();
void traceAfterDispatch(Visitor*);
private:
class ImportedStyleSheetClient FINAL : public StyleSheetResourceClient {
public:
ImportedStyleSheetClient(StyleRuleImport* ownerRule) : m_ownerRule(ownerRule) { }
virtual ~ImportedStyleSheetClient() { }
virtual void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource* sheet) OVERRIDE
{
m_ownerRule->setCSSStyleSheet(href, baseURL, charset, sheet);
}
private:
StyleRuleImport* m_ownerRule;
};
void setCSSStyleSheet(const String& href, const KURL& baseURL, const String& charset, const CSSStyleSheetResource*);
friend class ImportedStyleSheetClient;
StyleRuleImport(const String& href, PassRefPtrWillBeRawPtr<MediaQuerySet>);
RawPtrWillBeMember<StyleSheetContents> m_parentStyleSheet;
ImportedStyleSheetClient m_styleSheetClient;
String m_strHref;
RefPtrWillBeMember<MediaQuerySet> m_mediaQueries;
RefPtrWillBeMember<StyleSheetContents> m_styleSheet;
ResourcePtr<CSSStyleSheetResource> m_resource;
bool m_loading;
};
DEFINE_STYLE_RULE_TYPE_CASTS(Import);
}
#endif