diff options
Diffstat (limited to 'Source/WebCore/rendering/style/KeyframeList.cpp')
-rw-r--r-- | Source/WebCore/rendering/style/KeyframeList.cpp | 58 |
1 files changed, 30 insertions, 28 deletions
diff --git a/Source/WebCore/rendering/style/KeyframeList.cpp b/Source/WebCore/rendering/style/KeyframeList.cpp index a127b468b..97298ab44 100644 --- a/Source/WebCore/rendering/style/KeyframeList.cpp +++ b/Source/WebCore/rendering/style/KeyframeList.cpp @@ -21,13 +21,29 @@ #include "config.h" #include "KeyframeList.h" + +#include "Animation.h" #include "RenderObject.h" namespace WebCore { +TimingFunction* KeyframeValue::timingFunction(const AtomicString& name) const +{ + auto* keyframeStyle = style(); + if (!keyframeStyle || !keyframeStyle->animations()) + return nullptr; + + for (size_t i = 0; i < keyframeStyle->animations()->size(); ++i) { + const Animation& animation = keyframeStyle->animations()->animation(i); + if (name == animation.name()) + return animation.timingFunction(); + } + + return nullptr; +} + KeyframeList::~KeyframeList() { - clear(); } void KeyframeList::clear() @@ -41,57 +57,43 @@ bool KeyframeList::operator==(const KeyframeList& o) const if (m_keyframes.size() != o.m_keyframes.size()) return false; - Vector<KeyframeValue>::const_iterator it2 = o.m_keyframes.begin(); - for (Vector<KeyframeValue>::const_iterator it1 = m_keyframes.begin(); it1 != m_keyframes.end(); ++it1) { + auto it2 = o.m_keyframes.begin(); + for (auto it1 = m_keyframes.begin(); it1 != m_keyframes.end(); ++it1, ++it2) { if (it1->key() != it2->key()) return false; - const RenderStyle& style1 = *it1->style(); - const RenderStyle& style2 = *it2->style(); - if (style1 != style2) + if (*it1->style() != *it2->style()) return false; - ++it2; } return true; } -void KeyframeList::insert(const KeyframeValue& keyframe) +void KeyframeList::insert(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) { + size_t i = 0; + for (; i < m_keyframes.size(); ++i) { if (m_keyframes[i].key() == keyframe.key()) { - m_keyframes[i] = keyframe; - replaced = true; + ASSERT_NOT_REACHED(); break; } if (m_keyframes[i].key() > keyframe.key()) { // insert before - m_keyframes.insert(i, keyframe); + m_keyframes.insert(i, WTFMove(keyframe)); inserted = true; break; } } - if (!replaced && !inserted) - m_keyframes.append(keyframe); - - if (replaced) { - // We have to rebuild the properties list from scratch. - 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); - } + if (!inserted) + m_keyframes.append(WTFMove(keyframe)); + + for (auto& property : m_keyframes[i].properties()) + m_properties.add(property); } } // namespace WebCore |