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