OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "config.h" | 5 #include "config.h" |
6 #include "core/css/StyleRuleKeyframe.h" | 6 #include "core/css/StyleRuleKeyframe.h" |
7 | 7 |
8 #include "core/css/StylePropertySet.h" | 8 #include "core/css/StylePropertySet.h" |
9 #include "core/css/parser/CSSParser.h" | 9 #include "core/css/parser/CSSParser.h" |
10 #include "core/css/parser/CSSParserValues.h" | |
11 #include "wtf/text/StringBuilder.h" | 10 #include "wtf/text/StringBuilder.h" |
12 | 11 |
13 namespace blink { | 12 namespace blink { |
14 | 13 |
15 StyleRuleKeyframe::StyleRuleKeyframe(PassOwnPtr<Vector<double>> keys, PassRefPtr
WillBeRawPtr<StylePropertySet> properties) | 14 StyleRuleKeyframe::StyleRuleKeyframe(PassOwnPtr<Vector<double>> keys, PassRefPtr
WillBeRawPtr<StylePropertySet> properties) |
16 : StyleRuleBase(Keyframe) | 15 : StyleRuleBase(Keyframe) |
17 , m_properties(properties) | 16 , m_properties(properties) |
18 , m_keys(*keys) | 17 , m_keys(*keys) |
19 { | 18 { |
20 } | 19 } |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 result.append(keyText()); | 63 result.append(keyText()); |
65 result.appendLiteral(" { "); | 64 result.appendLiteral(" { "); |
66 String decls = m_properties->asText(); | 65 String decls = m_properties->asText(); |
67 result.append(decls); | 66 result.append(decls); |
68 if (!decls.isEmpty()) | 67 if (!decls.isEmpty()) |
69 result.append(' '); | 68 result.append(' '); |
70 result.append('}'); | 69 result.append('}'); |
71 return result.toString(); | 70 return result.toString(); |
72 } | 71 } |
73 | 72 |
74 PassOwnPtr<Vector<double>> StyleRuleKeyframe::createKeyList(CSSParserValueList*
keys) | |
75 { | |
76 size_t numKeys = keys ? keys->size() : 0; | |
77 OwnPtr<Vector<double>> keyVector = adoptPtr(new Vector<double>(numKeys)); | |
78 for (size_t i = 0; i < numKeys; ++i) { | |
79 ASSERT(keys->valueAt(i)->unit == CSSPrimitiveValue::CSS_NUMBER); | |
80 double key = keys->valueAt(i)->fValue; | |
81 if (key < 0 || key > 100) { | |
82 // As per http://www.w3.org/TR/css3-animations/#keyframes, | |
83 // "If a keyframe selector specifies negative percentage values | |
84 // or values higher than 100%, then the keyframe will be ignored." | |
85 keyVector->clear(); | |
86 break; | |
87 } | |
88 keyVector->at(i) = key / 100; | |
89 } | |
90 return keyVector.release(); | |
91 } | |
92 | |
93 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframe) | 73 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframe) |
94 { | 74 { |
95 visitor->trace(m_properties); | 75 visitor->trace(m_properties); |
96 StyleRuleBase::traceAfterDispatch(visitor); | 76 StyleRuleBase::traceAfterDispatch(visitor); |
97 } | 77 } |
98 | 78 |
99 } // namespace blink | 79 } // namespace blink |
OLD | NEW |