blob: ad8be3df6bfdc72cfcfc7c13935c68cb405d4ae7 [file] [log] [blame]
dino@apple.coma001d322008-08-05 23:01:41 +00001/*
dino@apple.comd2a5e4c2014-11-15 23:02:43 +00002 * Copyright (C) 2007, 2008, 2012, 2014 Apple Inc. All rights reserved.
dino@apple.coma001d322008-08-05 23:01:41 +00003 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions
6 * are met:
7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution.
12 *
mjs@apple.com92047332014-03-15 04:08:27 +000013 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
dino@apple.coma001d322008-08-05 23:01:41 +000014 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
mjs@apple.com92047332014-03-15 04:08:27 +000016 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
dino@apple.coma001d322008-08-05 23:01:41 +000017 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
18 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
19 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
20 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
21 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
apavlov@chromium.orgf684aec2011-10-19 13:31:03 +000023 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dino@apple.coma001d322008-08-05 23:01:41 +000024 */
25
dino@apple.comd2a5e4c2014-11-15 23:02:43 +000026#ifndef CSSKeyframeRule_h
27#define CSSKeyframeRule_h
dino@apple.coma001d322008-08-05 23:01:41 +000028
dino@apple.com1c9d2dd2015-01-27 19:39:22 +000029#include "CSSParser.h"
dino@apple.coma001d322008-08-05 23:01:41 +000030#include "CSSRule.h"
antti@apple.come5428c52013-11-28 20:53:22 +000031#include "StyleProperties.h"
dino@apple.coma001d322008-08-05 23:01:41 +000032
33namespace WebCore {
34
akling@apple.com179f7df2013-02-25 15:49:25 +000035class CSSStyleDeclaration;
antti@apple.com745b7902012-03-31 18:02:35 +000036class StyleRuleCSSStyleDeclaration;
dino@apple.comd2a5e4c2014-11-15 23:02:43 +000037class CSSKeyframesRule;
antti@apple.com64288372012-03-29 10:17:19 +000038
39class StyleKeyframe : public RefCounted<StyleKeyframe> {
zoltan@webkit.org2eb7bec2012-09-14 09:12:48 +000040 WTF_MAKE_FAST_ALLOCATED;
antti@apple.com64288372012-03-29 10:17:19 +000041public:
commit-queue@webkit.orgd605b502015-06-05 04:46:17 +000042 static Ref<StyleKeyframe> create(Ref<StyleProperties>&& properties)
antti@apple.com64288372012-03-29 10:17:19 +000043 {
commit-queue@webkit.orgd605b502015-06-05 04:46:17 +000044 return adoptRef(*new StyleKeyframe(WTF::move(properties)));
antti@apple.com64288372012-03-29 10:17:19 +000045 }
akling@apple.com179f7df2013-02-25 15:49:25 +000046 ~StyleKeyframe();
antti@apple.com64288372012-03-29 10:17:19 +000047
dino@apple.com1c9d2dd2015-01-27 19:39:22 +000048 String keyText() const;
49 void setKeyText(const String& text) { m_keys = CSSParser::parseKeyframeSelector(text); }
antti@apple.com64288372012-03-29 10:17:19 +000050
dino@apple.com1c9d2dd2015-01-27 19:39:22 +000051 const Vector<double>& keys() const { return m_keys; };
52
cdumez@apple.com2f661202014-11-04 07:22:18 +000053 const StyleProperties& properties() const { return m_properties; }
antti@apple.come5428c52013-11-28 20:53:22 +000054 MutableStyleProperties& mutableProperties();
dino@apple.com1c9d2dd2015-01-27 19:39:22 +000055
antti@apple.com64288372012-03-29 10:17:19 +000056 String cssText() const;
57
akling@apple.com179f7df2013-02-25 15:49:25 +000058private:
akling@apple.com689f7612014-12-14 08:21:05 +000059 explicit StyleKeyframe(Ref<StyleProperties>&&);
dino@apple.com1c9d2dd2015-01-27 19:39:22 +000060
antti@apple.come5428c52013-11-28 20:53:22 +000061 Ref<StyleProperties> m_properties;
dino@apple.com1c9d2dd2015-01-27 19:39:22 +000062 Vector<double> m_keys;
antti@apple.com64288372012-03-29 10:17:19 +000063};
dino@apple.coma001d322008-08-05 23:01:41 +000064
dino@apple.comd2a5e4c2014-11-15 23:02:43 +000065class CSSKeyframeRule final : public CSSRule {
dino@apple.coma001d322008-08-05 23:01:41 +000066public:
dino@apple.comd2a5e4c2014-11-15 23:02:43 +000067 virtual ~CSSKeyframeRule();
akling@apple.comc713db32012-11-22 03:45:40 +000068
commit-queue@webkit.org2dfe6cb2014-01-16 19:42:50 +000069 virtual String cssText() const override { return m_keyframe->cssText(); }
akling@apple.com39ce74c2014-10-03 04:38:19 +000070 virtual void reattach(StyleRuleBase&) override;
dino@apple.coma001d322008-08-05 23:01:41 +000071
antti@apple.com64288372012-03-29 10:17:19 +000072 String keyText() const { return m_keyframe->keyText(); }
dino@apple.com1c9d2dd2015-01-27 19:39:22 +000073 void setKeyText(const String& text) { m_keyframe->setKeyText(text); }
apavlov@chromium.orgf684aec2011-10-19 13:31:03 +000074
cdumez@apple.coma3b93812014-09-24 01:45:40 +000075 CSSStyleDeclaration& style();
dino@apple.coma001d322008-08-05 23:01:41 +000076
dino@apple.coma001d322008-08-05 23:01:41 +000077private:
dino@apple.comd2a5e4c2014-11-15 23:02:43 +000078 CSSKeyframeRule(StyleKeyframe&, CSSKeyframesRule* parent);
apavlov@chromium.orgf684aec2011-10-19 13:31:03 +000079
dino@apple.comd2a5e4c2014-11-15 23:02:43 +000080 virtual CSSRule::Type type() const override { return KEYFRAME_RULE; }
cdumez@apple.com8da96f62014-10-30 23:08:20 +000081
akling@apple.com39ce74c2014-10-03 04:38:19 +000082 Ref<StyleKeyframe> m_keyframe;
antti@apple.com745b7902012-03-31 18:02:35 +000083 mutable RefPtr<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper;
84
dino@apple.comd2a5e4c2014-11-15 23:02:43 +000085 friend class CSSKeyframesRule;
dino@apple.coma001d322008-08-05 23:01:41 +000086};
87
88} // namespace WebCore
89
dino@apple.comd2a5e4c2014-11-15 23:02:43 +000090#endif // CSSKeyframeRule_h