#ifndef CSSKeyframeRule_h
#define CSSKeyframeRule_h
#include "CSSParser.h"
#include "CSSRule.h"
#include "StyleProperties.h"
namespace WebCore {
class CSSStyleDeclaration;
class StyleRuleCSSStyleDeclaration;
class CSSKeyframesRule;
class StyleKeyframe : public RefCounted<StyleKeyframe> {
WTF_MAKE_FAST_ALLOCATED;
public:
static Ref<StyleKeyframe> create(Ref<StyleProperties>&& properties)
{
return adoptRef(*new StyleKeyframe(WTF::move(properties)));
}
~StyleKeyframe();
String keyText() const;
void setKeyText(const String& text) { m_keys = CSSParser::parseKeyframeSelector(text); }
const Vector<double>& keys() const { return m_keys; };
const StyleProperties& properties() const { return m_properties; }
MutableStyleProperties& mutableProperties();
String cssText() const;
private:
explicit StyleKeyframe(Ref<StyleProperties>&&);
Ref<StyleProperties> m_properties;
Vector<double> m_keys;
};
class CSSKeyframeRule final : public CSSRule {
public:
virtual ~CSSKeyframeRule();
virtual String cssText() const override { return m_keyframe->cssText(); }
virtual void reattach(StyleRuleBase&) override;
String keyText() const { return m_keyframe->keyText(); }
void setKeyText(const String& text) { m_keyframe->setKeyText(text); }
CSSStyleDeclaration& style();
private:
CSSKeyframeRule(StyleKeyframe&, CSSKeyframesRule* parent);
virtual CSSRule::Type type() const override { return KEYFRAME_RULE; }
Ref<StyleKeyframe> m_keyframe;
mutable RefPtr<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper;
friend class CSSKeyframesRule;
};
}
#endif // CSSKeyframeRule_h