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 "core/css/StyleRuleKeyframe.h" | 5 #include "core/css/StyleRuleKeyframe.h" |
6 | 6 |
7 #include "core/css/StylePropertySet.h" | 7 #include "core/css/StylePropertySet.h" |
8 #include "core/css/parser/CSSParser.h" | 8 #include "core/css/parser/CSSParser.h" |
9 #include "wtf/text/StringBuilder.h" | 9 #include "wtf/text/StringBuilder.h" |
10 | 10 |
11 namespace blink { | 11 namespace blink { |
12 | 12 |
13 StyleRuleKeyframe::StyleRuleKeyframe(PassOwnPtr<Vector<double>> keys, StylePrope
rtySet* properties) | 13 StyleRuleKeyframe::StyleRuleKeyframe(PassOwnPtr<Vector<double>> keys, StylePrope
rtySet* properties) |
14 : StyleRuleBase(Keyframe) | 14 : StyleRuleBase(Keyframe) |
15 , m_properties(properties) | 15 , m_properties(properties) |
16 , m_keys(*keys) | 16 , m_keys(*keys) |
17 { | 17 { |
18 } | 18 } |
19 | 19 |
20 String StyleRuleKeyframe::keyText() const | 20 String StyleRuleKeyframe::keyText() const |
21 { | 21 { |
22 ASSERT(!m_keys.isEmpty()); | 22 ASSERT(!m_keys.isEmpty()); |
23 | 23 |
24 StringBuilder keyText; | 24 StringBuilder keyText; |
25 for (unsigned i = 0; i < m_keys.size(); ++i) { | 25 for (unsigned i = 0; i < m_keys.size(); ++i) { |
26 if (i) | 26 if (i) |
27 keyText.append(", "); | 27 keyText.appendLiteral(", "); |
28 keyText.appendNumber(m_keys.at(i) * 100); | 28 keyText.appendNumber(m_keys.at(i) * 100); |
29 keyText.append('%'); | 29 keyText.append('%'); |
30 } | 30 } |
31 | 31 |
32 return keyText.toString(); | 32 return keyText.toString(); |
33 } | 33 } |
34 | 34 |
35 bool StyleRuleKeyframe::setKeyText(const String& keyText) | 35 bool StyleRuleKeyframe::setKeyText(const String& keyText) |
36 { | 36 { |
37 ASSERT(!keyText.isNull()); | 37 ASSERT(!keyText.isNull()); |
(...skipping 15 matching lines...) Expand all Loading... |
53 { | 53 { |
54 if (!m_properties->isMutable()) | 54 if (!m_properties->isMutable()) |
55 m_properties = m_properties->mutableCopy(); | 55 m_properties = m_properties->mutableCopy(); |
56 return *toMutableStylePropertySet(m_properties.get()); | 56 return *toMutableStylePropertySet(m_properties.get()); |
57 } | 57 } |
58 | 58 |
59 String StyleRuleKeyframe::cssText() const | 59 String StyleRuleKeyframe::cssText() const |
60 { | 60 { |
61 StringBuilder result; | 61 StringBuilder result; |
62 result.append(keyText()); | 62 result.append(keyText()); |
63 result.append(" { "); | 63 result.appendLiteral(" { "); |
64 String decls = m_properties->asText(); | 64 String decls = m_properties->asText(); |
65 result.append(decls); | 65 result.append(decls); |
66 if (!decls.isEmpty()) | 66 if (!decls.isEmpty()) |
67 result.append(' '); | 67 result.append(' '); |
68 result.append('}'); | 68 result.append('}'); |
69 return result.toString(); | 69 return result.toString(); |
70 } | 70 } |
71 | 71 |
72 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframe) | 72 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframe) |
73 { | 73 { |
74 visitor->trace(m_properties); | 74 visitor->trace(m_properties); |
75 StyleRuleBase::traceAfterDispatch(visitor); | 75 StyleRuleBase::traceAfterDispatch(visitor); |
76 } | 76 } |
77 | 77 |
78 } // namespace blink | 78 } // namespace blink |
OLD | NEW |