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 #include <memory> | 10 #include <memory> |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 StyleRuleKeyframe::StyleRuleKeyframe(std::unique_ptr<Vector<double>> keys, | 14 StyleRuleKeyframe::StyleRuleKeyframe(std::unique_ptr<Vector<double>> keys, |
15 StylePropertySet* properties) | 15 StylePropertySet* properties) |
16 : StyleRuleBase(Keyframe), m_properties(properties), m_keys(*keys) {} | 16 : StyleRuleBase(Keyframe), m_properties(properties), m_keys(*keys) {} |
17 | 17 |
18 String StyleRuleKeyframe::keyText() const { | 18 String StyleRuleKeyframe::keyText() const { |
19 ASSERT(!m_keys.isEmpty()); | 19 DCHECK(!m_keys.isEmpty()); |
20 | 20 |
21 StringBuilder keyText; | 21 StringBuilder keyText; |
22 for (unsigned i = 0; i < m_keys.size(); ++i) { | 22 for (unsigned i = 0; i < m_keys.size(); ++i) { |
23 if (i) | 23 if (i) |
24 keyText.append(", "); | 24 keyText.append(", "); |
25 keyText.appendNumber(m_keys.at(i) * 100); | 25 keyText.appendNumber(m_keys.at(i) * 100); |
26 keyText.append('%'); | 26 keyText.append('%'); |
27 } | 27 } |
28 | 28 |
29 return keyText.toString(); | 29 return keyText.toString(); |
30 } | 30 } |
31 | 31 |
32 bool StyleRuleKeyframe::setKeyText(const String& keyText) { | 32 bool StyleRuleKeyframe::setKeyText(const String& keyText) { |
33 ASSERT(!keyText.isNull()); | 33 DCHECK(!keyText.isNull()); |
34 | 34 |
35 std::unique_ptr<Vector<double>> keys = | 35 std::unique_ptr<Vector<double>> keys = |
36 CSSParser::parseKeyframeKeyList(keyText); | 36 CSSParser::parseKeyframeKeyList(keyText); |
37 if (!keys || keys->isEmpty()) | 37 if (!keys || keys->isEmpty()) |
38 return false; | 38 return false; |
39 | 39 |
40 m_keys = *keys; | 40 m_keys = *keys; |
41 return true; | 41 return true; |
42 } | 42 } |
43 | 43 |
(...skipping 18 matching lines...) Expand all Loading... |
62 result.append('}'); | 62 result.append('}'); |
63 return result.toString(); | 63 return result.toString(); |
64 } | 64 } |
65 | 65 |
66 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframe) { | 66 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframe) { |
67 visitor->trace(m_properties); | 67 visitor->trace(m_properties); |
68 StyleRuleBase::traceAfterDispatch(visitor); | 68 StyleRuleBase::traceAfterDispatch(visitor); |
69 } | 69 } |
70 | 70 |
71 } // namespace blink | 71 } // namespace blink |
OLD | NEW |