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
3 // found in the LICENSE file.
6 #include "core/css/StyleRuleKeyframe.h"
8 #include "core/css/StylePropertySet.h"
9 #include "core/css/parser/CSSParser.h"
10 #include "wtf/text/StringBuilder.h"
14 StyleRuleKeyframe::StyleRuleKeyframe(PassOwnPtr
<Vector
<double>> keys
, PassRefPtrWillBeRawPtr
<StylePropertySet
> properties
)
15 : StyleRuleBase(Keyframe
)
16 , m_properties(properties
)
21 String
StyleRuleKeyframe::keyText() const
23 ASSERT(!m_keys
.isEmpty());
25 StringBuilder keyText
;
26 for (unsigned i
= 0; i
< m_keys
.size(); ++i
) {
29 keyText
.appendNumber(m_keys
.at(i
) * 100);
33 return keyText
.toString();
36 bool StyleRuleKeyframe::setKeyText(const String
& keyText
)
38 ASSERT(!keyText
.isNull());
40 OwnPtr
<Vector
<double>> keys
= CSSParser::parseKeyframeKeyList(keyText
);
41 if (!keys
|| keys
->isEmpty())
48 const Vector
<double>& StyleRuleKeyframe::keys() const
53 MutableStylePropertySet
& StyleRuleKeyframe::mutableProperties()
55 if (!m_properties
->isMutable())
56 m_properties
= m_properties
->mutableCopy();
57 return *toMutableStylePropertySet(m_properties
.get());
60 String
StyleRuleKeyframe::cssText() const
63 result
.append(keyText());
64 result
.appendLiteral(" { ");
65 String decls
= m_properties
->asText();
70 return result
.toString();
73 DEFINE_TRACE_AFTER_DISPATCH(StyleRuleKeyframe
)
75 visitor
->trace(m_properties
);
76 StyleRuleBase::traceAfterDispatch(visitor
);