| 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 "core/css/serializer/CSSDeserializeStream.h" |
| 10 #include "core/css/serializer/CSSSerializeStream.h" |
| 9 #include "wtf/text/StringBuilder.h" | 11 #include "wtf/text/StringBuilder.h" |
| 10 | 12 |
| 11 namespace blink { | 13 namespace blink { |
| 12 | 14 |
| 13 StyleRuleKeyframe::StyleRuleKeyframe(PassOwnPtr<Vector<double>> keys, PassRefPtr
WillBeRawPtr<StylePropertySet> properties) | 15 StyleRuleKeyframe::StyleRuleKeyframe(PassOwnPtr<Vector<double>> keys, PassRefPtr
WillBeRawPtr<StylePropertySet> properties) |
| 14 : StyleRuleBase(Keyframe) | 16 : StyleRuleBase(Keyframe) |
| 15 , m_properties(properties) | 17 , m_properties(properties) |
| 16 , m_keys(*keys) | 18 , m_keys(*keys) |
| 17 { | 19 { |
| 18 } | 20 } |
| 19 | 21 |
| 20 String StyleRuleKeyframe::keyText() const | 22 String StyleRuleKeyframe::keyText() const |
| 21 { | 23 { |
| 22 ASSERT(!m_keys.isEmpty()); | 24 ASSERT(!m_keys.isEmpty()); |
| 23 | 25 |
| 24 StringBuilder keyText; | 26 StringBuilder keyText; |
| 25 for (unsigned i = 0; i < m_keys.size(); ++i) { | 27 for (unsigned i = 0; i < m_keys.size(); ++i) { |
| 26 if (i) | 28 if (i) |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 result.append(keyText()); | 64 result.append(keyText()); |
| 63 result.appendLiteral(" { "); | 65 result.appendLiteral(" { "); |
| 64 String decls = m_properties->asText(); | 66 String decls = m_properties->asText(); |
| 65 result.append(decls); | 67 result.append(decls); |
| 66 if (!decls.isEmpty()) | 68 if (!decls.isEmpty()) |
| 67 result.append(' '); | 69 result.append(' '); |
| 68 result.append('}'); | 70 result.append('}'); |
| 69 return result.toString(); | 71 return result.toString(); |
| 70 } | 72 } |
| 71 | 73 |
| 74 void StyleRuleKeyframe::serializeAfterDispatch(CSSSerializeStream* stream) const |
| 75 { |
| 76 m_properties->serialize(stream); |
| 77 stream->writeUnsigned(m_keys.size()); |
| 78 for (double key : m_keys) |
| 79 stream->writeDouble(key); |
| 80 } |
| 81 |
| 82 PassRefPtrWillBeRawPtr<StyleRuleKeyframe> StyleRuleKeyframe::deserializeAfterDis
patch(CSSDeserializeStream* stream) |
| 83 { |
| 84 RefPtrWillBeRawPtr<StylePropertySet> properties = ImmutableStylePropertySet:
:deserialize(stream); |
| 85 |
| 86 unsigned size = stream->readUnsigned(); |
| 87 OwnPtr<Vector<double>> keys = adoptPtr(new Vector<double>()); |
| 88 keys->reserveCapacity(size); |
| 89 for (unsigned i = 0; i < size; ++ i) |
| 90 keys->append(stream->readDouble()); |
| 91 |
| 92 return create(keys.release(), properties); |
| 93 } |
| 94 |
| 72 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframe) | 95 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframe) |
| 73 { | 96 { |
| 74 visitor->trace(m_properties); | 97 visitor->trace(m_properties); |
| 75 StyleRuleBase::traceAfterDispatch(visitor); | 98 StyleRuleBase::traceAfterDispatch(visitor); |
| 76 } | 99 } |
| 77 | 100 |
| 78 } // namespace blink | 101 } // namespace blink |
| OLD | NEW |