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 | 11 |
11 namespace blink { | 12 namespace blink { |
12 | 13 |
13 StyleRuleKeyframe::StyleRuleKeyframe(PassOwnPtr<Vector<double>> keys, StylePrope
rtySet* properties) | 14 StyleRuleKeyframe::StyleRuleKeyframe(std::unique_ptr<Vector<double>> keys, Style
PropertySet* properties) |
14 : StyleRuleBase(Keyframe) | 15 : StyleRuleBase(Keyframe) |
15 , m_properties(properties) | 16 , m_properties(properties) |
16 , m_keys(*keys) | 17 , m_keys(*keys) |
17 { | 18 { |
18 } | 19 } |
19 | 20 |
20 String StyleRuleKeyframe::keyText() const | 21 String StyleRuleKeyframe::keyText() const |
21 { | 22 { |
22 ASSERT(!m_keys.isEmpty()); | 23 ASSERT(!m_keys.isEmpty()); |
23 | 24 |
24 StringBuilder keyText; | 25 StringBuilder keyText; |
25 for (unsigned i = 0; i < m_keys.size(); ++i) { | 26 for (unsigned i = 0; i < m_keys.size(); ++i) { |
26 if (i) | 27 if (i) |
27 keyText.append(", "); | 28 keyText.append(", "); |
28 keyText.appendNumber(m_keys.at(i) * 100); | 29 keyText.appendNumber(m_keys.at(i) * 100); |
29 keyText.append('%'); | 30 keyText.append('%'); |
30 } | 31 } |
31 | 32 |
32 return keyText.toString(); | 33 return keyText.toString(); |
33 } | 34 } |
34 | 35 |
35 bool StyleRuleKeyframe::setKeyText(const String& keyText) | 36 bool StyleRuleKeyframe::setKeyText(const String& keyText) |
36 { | 37 { |
37 ASSERT(!keyText.isNull()); | 38 ASSERT(!keyText.isNull()); |
38 | 39 |
39 OwnPtr<Vector<double>> keys = CSSParser::parseKeyframeKeyList(keyText); | 40 std::unique_ptr<Vector<double>> keys = CSSParser::parseKeyframeKeyList(keyTe
xt); |
40 if (!keys || keys->isEmpty()) | 41 if (!keys || keys->isEmpty()) |
41 return false; | 42 return false; |
42 | 43 |
43 m_keys = *keys; | 44 m_keys = *keys; |
44 return true; | 45 return true; |
45 } | 46 } |
46 | 47 |
47 const Vector<double>& StyleRuleKeyframe::keys() const | 48 const Vector<double>& StyleRuleKeyframe::keys() const |
48 { | 49 { |
49 return m_keys; | 50 return m_keys; |
(...skipping 19 matching lines...) Expand all Loading... |
69 return result.toString(); | 70 return result.toString(); |
70 } | 71 } |
71 | 72 |
72 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframe) | 73 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframe) |
73 { | 74 { |
74 visitor->trace(m_properties); | 75 visitor->trace(m_properties); |
75 StyleRuleBase::traceAfterDispatch(visitor); | 76 StyleRuleBase::traceAfterDispatch(visitor); |
76 } | 77 } |
77 | 78 |
78 } // namespace blink | 79 } // namespace blink |
OLD | NEW |