This source file includes following definitions.
- addProperties
- timingFunction
- clear
- insert
#include "config.h"
#include "core/rendering/style/KeyframeList.h"
#include "core/animation/Animation.h"
#include "core/css/StylePropertySet.h"
#include "core/rendering/RenderObject.h"
namespace WebCore {
void KeyframeValue::addProperties(const StylePropertySet* propertySet)
{
if (!propertySet)
return;
unsigned propertyCount = propertySet->propertyCount();
for (unsigned i = 0; i < propertyCount; ++i) {
CSSPropertyID property = propertySet->propertyAt(i).id();
if (property != CSSPropertyWebkitAnimationTimingFunction && property != CSSPropertyAnimationTimingFunction)
addProperty(property);
}
}
TimingFunction* KeyframeValue::timingFunction(const RenderStyle& keyframeStyle)
{
const CSSAnimationDataList* animations = keyframeStyle.animations();
ASSERT(animations && !animations->isEmpty());
return animations->animation(0)->timingFunction();
}
KeyframeList::~KeyframeList()
{
clear();
}
void KeyframeList::clear()
{
m_keyframes.clear();
m_properties.clear();
}
void KeyframeList::insert(const KeyframeValue& keyframe)
{
if (keyframe.key() < 0 || keyframe.key() > 1)
return;
bool inserted = false;
bool replaced = false;
for (size_t i = 0; i < m_keyframes.size(); ++i) {
if (m_keyframes[i].key() == keyframe.key()) {
m_keyframes[i] = keyframe;
replaced = true;
break;
}
if (m_keyframes[i].key() > keyframe.key()) {
m_keyframes.insert(i, keyframe);
inserted = true;
break;
}
}
if (!replaced && !inserted)
m_keyframes.append(keyframe);
if (replaced) {
m_properties.clear();
for (Vector<KeyframeValue>::const_iterator it = m_keyframes.begin(); it != m_keyframes.end(); ++it) {
const KeyframeValue& currKeyframe = *it;
for (HashSet<CSSPropertyID>::const_iterator it = currKeyframe.properties().begin(); it != currKeyframe.properties().end(); ++it)
m_properties.add(*it);
}
} else {
for (HashSet<CSSPropertyID>::const_iterator it = keyframe.properties().begin(); it != keyframe.properties().end(); ++it)
m_properties.add(*it);
}
}
}