dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 1 | /* |
dino@apple.com | d2a5e4c | 2014-11-15 23:02:43 +0000 | [diff] [blame] | 2 | * Copyright (C) 2007, 2008, 2012, 2014 Apple Inc. All rights reserved. |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 3 | * |
| 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.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 13 | * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 14 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 15 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
mjs@apple.com | 9204733 | 2014-03-15 04:08:27 +0000 | [diff] [blame] | 16 | * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 17 | * 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.org | f684aec | 2011-10-19 13:31:03 +0000 | [diff] [blame] | 23 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 24 | */ |
| 25 | |
dino@apple.com | d2a5e4c | 2014-11-15 23:02:43 +0000 | [diff] [blame] | 26 | #ifndef CSSKeyframeRule_h |
| 27 | #define CSSKeyframeRule_h |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 28 | |
dino@apple.com | 1c9d2dd | 2015-01-27 19:39:22 +0000 | [diff] [blame] | 29 | #include "CSSParser.h" |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 30 | #include "CSSRule.h" |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 31 | #include "StyleProperties.h" |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 32 | |
| 33 | namespace WebCore { |
| 34 | |
akling@apple.com | 179f7df | 2013-02-25 15:49:25 +0000 | [diff] [blame] | 35 | class CSSStyleDeclaration; |
antti@apple.com | 745b790 | 2012-03-31 18:02:35 +0000 | [diff] [blame] | 36 | class StyleRuleCSSStyleDeclaration; |
dino@apple.com | d2a5e4c | 2014-11-15 23:02:43 +0000 | [diff] [blame] | 37 | class CSSKeyframesRule; |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 38 | |
| 39 | class StyleKeyframe : public RefCounted<StyleKeyframe> { |
zoltan@webkit.org | 2eb7bec | 2012-09-14 09:12:48 +0000 | [diff] [blame] | 40 | WTF_MAKE_FAST_ALLOCATED; |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 41 | public: |
commit-queue@webkit.org | d605b50 | 2015-06-05 04:46:17 +0000 | [diff] [blame] | 42 | static Ref<StyleKeyframe> create(Ref<StyleProperties>&& properties) |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 43 | { |
commit-queue@webkit.org | d605b50 | 2015-06-05 04:46:17 +0000 | [diff] [blame] | 44 | return adoptRef(*new StyleKeyframe(WTF::move(properties))); |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 45 | } |
akling@apple.com | 179f7df | 2013-02-25 15:49:25 +0000 | [diff] [blame] | 46 | ~StyleKeyframe(); |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 47 | |
dino@apple.com | 1c9d2dd | 2015-01-27 19:39:22 +0000 | [diff] [blame] | 48 | String keyText() const; |
| 49 | void setKeyText(const String& text) { m_keys = CSSParser::parseKeyframeSelector(text); } |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 50 | |
dino@apple.com | 1c9d2dd | 2015-01-27 19:39:22 +0000 | [diff] [blame] | 51 | const Vector<double>& keys() const { return m_keys; }; |
| 52 | |
cdumez@apple.com | 2f66120 | 2014-11-04 07:22:18 +0000 | [diff] [blame] | 53 | const StyleProperties& properties() const { return m_properties; } |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 54 | MutableStyleProperties& mutableProperties(); |
dino@apple.com | 1c9d2dd | 2015-01-27 19:39:22 +0000 | [diff] [blame] | 55 | |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 56 | String cssText() const; |
| 57 | |
akling@apple.com | 179f7df | 2013-02-25 15:49:25 +0000 | [diff] [blame] | 58 | private: |
akling@apple.com | 689f761 | 2014-12-14 08:21:05 +0000 | [diff] [blame] | 59 | explicit StyleKeyframe(Ref<StyleProperties>&&); |
dino@apple.com | 1c9d2dd | 2015-01-27 19:39:22 +0000 | [diff] [blame] | 60 | |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 61 | Ref<StyleProperties> m_properties; |
dino@apple.com | 1c9d2dd | 2015-01-27 19:39:22 +0000 | [diff] [blame] | 62 | Vector<double> m_keys; |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 63 | }; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 64 | |
dino@apple.com | d2a5e4c | 2014-11-15 23:02:43 +0000 | [diff] [blame] | 65 | class CSSKeyframeRule final : public CSSRule { |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 66 | public: |
dino@apple.com | d2a5e4c | 2014-11-15 23:02:43 +0000 | [diff] [blame] | 67 | virtual ~CSSKeyframeRule(); |
akling@apple.com | c713db3 | 2012-11-22 03:45:40 +0000 | [diff] [blame] | 68 | |
commit-queue@webkit.org | 2dfe6cb | 2014-01-16 19:42:50 +0000 | [diff] [blame] | 69 | virtual String cssText() const override { return m_keyframe->cssText(); } |
akling@apple.com | 39ce74c | 2014-10-03 04:38:19 +0000 | [diff] [blame] | 70 | virtual void reattach(StyleRuleBase&) override; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 71 | |
antti@apple.com | 6428837 | 2012-03-29 10:17:19 +0000 | [diff] [blame] | 72 | String keyText() const { return m_keyframe->keyText(); } |
dino@apple.com | 1c9d2dd | 2015-01-27 19:39:22 +0000 | [diff] [blame] | 73 | void setKeyText(const String& text) { m_keyframe->setKeyText(text); } |
apavlov@chromium.org | f684aec | 2011-10-19 13:31:03 +0000 | [diff] [blame] | 74 | |
cdumez@apple.com | a3b9381 | 2014-09-24 01:45:40 +0000 | [diff] [blame] | 75 | CSSStyleDeclaration& style(); |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 76 | |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 77 | private: |
dino@apple.com | d2a5e4c | 2014-11-15 23:02:43 +0000 | [diff] [blame] | 78 | CSSKeyframeRule(StyleKeyframe&, CSSKeyframesRule* parent); |
apavlov@chromium.org | f684aec | 2011-10-19 13:31:03 +0000 | [diff] [blame] | 79 | |
dino@apple.com | d2a5e4c | 2014-11-15 23:02:43 +0000 | [diff] [blame] | 80 | virtual CSSRule::Type type() const override { return KEYFRAME_RULE; } |
cdumez@apple.com | 8da96f6 | 2014-10-30 23:08:20 +0000 | [diff] [blame] | 81 | |
akling@apple.com | 39ce74c | 2014-10-03 04:38:19 +0000 | [diff] [blame] | 82 | Ref<StyleKeyframe> m_keyframe; |
antti@apple.com | 745b790 | 2012-03-31 18:02:35 +0000 | [diff] [blame] | 83 | mutable RefPtr<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper; |
| 84 | |
dino@apple.com | d2a5e4c | 2014-11-15 23:02:43 +0000 | [diff] [blame] | 85 | friend class CSSKeyframesRule; |
dino@apple.com | a001d32 | 2008-08-05 23:01:41 +0000 | [diff] [blame] | 86 | }; |
| 87 | |
| 88 | } // namespace WebCore |
| 89 | |
dino@apple.com | d2a5e4c | 2014-11-15 23:02:43 +0000 | [diff] [blame] | 90 | #endif // CSSKeyframeRule_h |