Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1629)

Side by Side Diff: Source/core/css/CSSKeyframeRule.h

Issue 19037003: Re-use CSSParser logic to parse keyframe keys (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebased Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/core/css/CSSGrammar.y.in ('k') | Source/core/css/CSSKeyframeRule.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008, 2012 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008, 2012 Apple Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 12 matching lines...) Expand all
23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #ifndef CSSKeyframeRule_h 26 #ifndef CSSKeyframeRule_h
27 #define CSSKeyframeRule_h 27 #define CSSKeyframeRule_h
28 28
29 #include "core/css/CSSRule.h" 29 #include "core/css/CSSRule.h"
30 30
31 namespace WebCore { 31 namespace WebCore {
32 32
33 class CSSKeyframesRule;
34 class CSSParserValueList;
33 class CSSStyleDeclaration; 35 class CSSStyleDeclaration;
34 class MutableStylePropertySet; 36 class MutableStylePropertySet;
35 class StylePropertySet; 37 class StylePropertySet;
36 class StyleRuleCSSStyleDeclaration; 38 class StyleRuleCSSStyleDeclaration;
37 class CSSKeyframesRule;
38 39
39 class StyleKeyframe FINAL : public RefCounted<StyleKeyframe> { 40 class StyleKeyframe FINAL : public RefCounted<StyleKeyframe> {
40 WTF_MAKE_FAST_ALLOCATED; 41 WTF_MAKE_FAST_ALLOCATED;
41 public: 42 public:
42 static PassRefPtr<StyleKeyframe> create() 43 static PassRefPtr<StyleKeyframe> create()
43 { 44 {
44 return adoptRef(new StyleKeyframe()); 45 return adoptRef(new StyleKeyframe());
45 } 46 }
46 ~StyleKeyframe(); 47 ~StyleKeyframe();
47 48
48 String keyText() const { return m_key; } 49 // Exposed to JavaScript.
49 // FIXME: Should we trim whitespace? 50 String keyText() const;
50 // FIXME: Should we leave keyText unchanged when attempting to set to an 51 void setKeyText(const String&);
51 // invalid string?
52 void setKeyText(const String& s) { m_key = s; }
53 52
54 void getKeys(Vector<double>& keys) const { parseKeyString(m_key, keys); } 53 // Used by StyleResolver.
54 const Vector<double>& keys() const;
55 // Used by CSSParser when constructing a new StyleKeyframe.
56 void setKeys(PassOwnPtr<Vector<double> >);
55 57
56 const StylePropertySet* properties() const { return m_properties.get(); } 58 const StylePropertySet* properties() const { return m_properties.get(); }
57 MutableStylePropertySet* mutableProperties(); 59 MutableStylePropertySet* mutableProperties();
58 void setProperties(PassRefPtr<StylePropertySet>); 60 void setProperties(PassRefPtr<StylePropertySet>);
59 61
60 String cssText() const; 62 String cssText() const;
61 63
64 static PassOwnPtr<Vector<double> > createKeyList(CSSParserValueList*);
65
62 private: 66 private:
63 StyleKeyframe(); 67 StyleKeyframe();
64 68
65 static void parseKeyString(const String&, Vector<double>& keys);
66
67 RefPtr<StylePropertySet> m_properties; 69 RefPtr<StylePropertySet> m_properties;
68 // FIXME: This should be a parsed vector of floats. 70 // These are both calculated lazily. Either one can be set, which invalidate s the other.
69 // comma separated list of keys 71 mutable String m_keyText;
70 String m_key; 72 mutable OwnPtr<Vector<double> > m_keys;
71 }; 73 };
72 74
73 class CSSKeyframeRule FINAL : public CSSRule { 75 class CSSKeyframeRule FINAL : public CSSRule {
74 public: 76 public:
75 virtual ~CSSKeyframeRule(); 77 virtual ~CSSKeyframeRule();
76 78
77 virtual CSSRule::Type type() const OVERRIDE { return KEYFRAME_RULE; } 79 virtual CSSRule::Type type() const OVERRIDE { return KEYFRAME_RULE; }
78 virtual String cssText() const OVERRIDE { return m_keyframe->cssText(); } 80 virtual String cssText() const OVERRIDE { return m_keyframe->cssText(); }
79 virtual void reattach(StyleRuleBase*) OVERRIDE; 81 virtual void reattach(StyleRuleBase*) OVERRIDE;
80 82
81 String keyText() const { return m_keyframe->keyText(); } 83 String keyText() const { return m_keyframe->keyText(); }
82 void setKeyText(const String& s) { m_keyframe->setKeyText(s); } 84 void setKeyText(const String& s) { m_keyframe->setKeyText(s); }
83 85
84 CSSStyleDeclaration* style() const; 86 CSSStyleDeclaration* style() const;
85 87
86 private: 88 private:
87 CSSKeyframeRule(StyleKeyframe*, CSSKeyframesRule* parent); 89 CSSKeyframeRule(StyleKeyframe*, CSSKeyframesRule* parent);
88 90
89 RefPtr<StyleKeyframe> m_keyframe; 91 RefPtr<StyleKeyframe> m_keyframe;
90 mutable RefPtr<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper; 92 mutable RefPtr<StyleRuleCSSStyleDeclaration> m_propertiesCSSOMWrapper;
91 93
92 friend class CSSKeyframesRule; 94 friend class CSSKeyframesRule;
93 }; 95 };
94 96
95 } // namespace WebCore 97 } // namespace WebCore
96 98
97 #endif // CSSKeyframeRule_h 99 #endif // CSSKeyframeRule_h
OLDNEW
« no previous file with comments | « Source/core/css/CSSGrammar.y.in ('k') | Source/core/css/CSSKeyframeRule.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698