OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2007, 2012 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2012 Apple Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above copyright | 8 * 1. Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * 2. Redistributions in binary form must reproduce the above copyright | 10 * 2. Redistributions in binary form must reproduce the above copyright |
(...skipping 25 matching lines...) Expand all Loading... |
36 #include "EventNames.h" | 36 #include "EventNames.h" |
37 #include "RenderBoxModelObject.h" | 37 #include "RenderBoxModelObject.h" |
38 #include "RenderStyle.h" | 38 #include "RenderStyle.h" |
39 #include "StyleResolver.h" | 39 #include "StyleResolver.h" |
40 #include <wtf/UnusedParam.h> | 40 #include <wtf/UnusedParam.h> |
41 | 41 |
42 using namespace std; | 42 using namespace std; |
43 | 43 |
44 namespace WebCore { | 44 namespace WebCore { |
45 | 45 |
46 KeyframeAnimation::KeyframeAnimation(const Animation* animation, RenderObject* r
enderer, int index, CompositeAnimation* compAnim, RenderStyle* unanimatedStyle) | 46 KeyframeAnimation::KeyframeAnimation(const PrimitiveAnimation* animation, Render
Object* renderer, int index, CompositeAnimation* compAnim, RenderStyle* unanimat
edStyle) |
47 : AnimationBase(animation, renderer, compAnim) | 47 : AnimationBase(animation, renderer, compAnim) |
48 , m_keyframes(renderer, animation->name()) | 48 , m_keyframes(renderer, animation->name()) |
49 , m_index(index) | 49 , m_index(index) |
50 , m_startEventDispatched(false) | 50 , m_startEventDispatched(false) |
51 , m_unanimatedStyle(unanimatedStyle) | 51 , m_unanimatedStyle(unanimatedStyle) |
52 { | 52 { |
53 // Get the keyframe RenderStyles | 53 // Get the keyframe RenderStyles |
54 if (m_object && m_object->node() && m_object->node()->isElementNode()) | 54 if (m_object && m_object->node() && m_object->node()->isElementNode()) |
55 m_object->document()->styleResolver()->keyframeStylesForAnimation(toElem
ent(m_object->node()), unanimatedStyle, m_keyframes); | 55 m_object->document()->styleResolver()->keyframeStylesForAnimation(toElem
ent(m_object->node()), unanimatedStyle, m_keyframes); |
56 | 56 |
57 // Update the m_transformFunctionListValid flag based on whether the functio
n lists in the keyframes match. | 57 // Update the m_transformFunctionListValid flag based on whether the functio
n lists in the keyframes match. |
58 validateTransformFunctionList(); | 58 validateTransformFunctionList(); |
59 checkForMatchingFilterFunctionLists(); | 59 checkForMatchingFilterFunctionLists(); |
60 } | 60 } |
61 | 61 |
62 KeyframeAnimation::~KeyframeAnimation() | 62 KeyframeAnimation::~KeyframeAnimation() |
63 { | 63 { |
64 // Make sure to tell the renderer that we are ending. This will make sure an
y accelerated animations are removed. | 64 // Make sure to tell the renderer that we are ending. This will make sure an
y accelerated animations are removed. |
65 if (!postActive()) | 65 if (!postActive()) |
66 endAnimation(); | 66 endAnimation(); |
67 } | 67 } |
68 | 68 |
69 static const Animation* getAnimationFromStyleByName(const RenderStyle* style, co
nst AtomicString& name) | 69 static const PrimitiveAnimation* getAnimationFromStyleByName(const RenderStyle*
style, const AtomicString& name) |
70 { | 70 { |
71 if (!style->animations()) | 71 if (!style->animations()) |
72 return 0; | 72 return 0; |
73 | 73 |
74 for (size_t i = 0; i < style->animations()->size(); i++) { | 74 for (size_t i = 0; i < style->animations()->size(); i++) { |
75 if (name == style->animations()->animation(i)->name()) | 75 if (name == style->animations()->animation(i)->name()) |
76 return style->animations()->animation(i); | 76 return style->animations()->animation(i); |
77 } | 77 } |
78 | 78 |
79 return 0; | 79 return 0; |
80 } | 80 } |
81 | 81 |
82 void KeyframeAnimation::fetchIntervalEndpointsForProperty(CSSPropertyID property
, const RenderStyle*& fromStyle, const RenderStyle*& toStyle, double& prog) cons
t | 82 void KeyframeAnimation::fetchIntervalEndpointsForProperty(CSSPropertyID property
, const RenderStyle*& fromStyle, const RenderStyle*& toStyle, double& prog) cons
t |
83 { | 83 { |
84 // Find the first key | 84 // Find the first key |
85 double elapsedTime = getElapsedTime(); | 85 double elapsedTime = getElapsedTime(); |
86 if (m_animation->duration() && m_animation->iterationCount() != Animation::I
terationCountInfinite) | 86 if (m_animation->duration() && m_animation->iterationCount() != PrimitiveAni
mation::IterationCountInfinite) |
87 elapsedTime = min(elapsedTime, m_animation->duration() * m_animation->it
erationCount()); | 87 elapsedTime = min(elapsedTime, m_animation->duration() * m_animation->it
erationCount()); |
88 | 88 |
89 const double fractionalTime = this->fractionalTime(1, elapsedTime, 0); | 89 const double fractionalTime = this->fractionalTime(1, elapsedTime, 0); |
90 | 90 |
91 size_t numKeyframes = m_keyframes.size(); | 91 size_t numKeyframes = m_keyframes.size(); |
92 if (!numKeyframes) | 92 if (!numKeyframes) |
93 return; | 93 return; |
94 | 94 |
95 ASSERT(!m_keyframes[0].key()); | 95 ASSERT(!m_keyframes[0].key()); |
96 ASSERT(m_keyframes[m_keyframes.size() - 1].key() == 1); | 96 ASSERT(m_keyframes[m_keyframes.size() - 1].key() == 1); |
(...skipping 28 matching lines...) Expand all Loading... |
125 const KeyframeValue& prevKeyframe = m_keyframes[prevIndex]; | 125 const KeyframeValue& prevKeyframe = m_keyframes[prevIndex]; |
126 const KeyframeValue& nextKeyframe = m_keyframes[nextIndex]; | 126 const KeyframeValue& nextKeyframe = m_keyframes[nextIndex]; |
127 | 127 |
128 fromStyle = prevKeyframe.style(); | 128 fromStyle = prevKeyframe.style(); |
129 toStyle = nextKeyframe.style(); | 129 toStyle = nextKeyframe.style(); |
130 | 130 |
131 offset = prevKeyframe.key(); | 131 offset = prevKeyframe.key(); |
132 scale = 1.0 / (nextKeyframe.key() - prevKeyframe.key()); | 132 scale = 1.0 / (nextKeyframe.key() - prevKeyframe.key()); |
133 | 133 |
134 const TimingFunction* timingFunction = 0; | 134 const TimingFunction* timingFunction = 0; |
135 if (const Animation* matchedAnimation = getAnimationFromStyleByName(fromStyl
e, name())) | 135 if (const PrimitiveAnimation* matchedAnimation = getAnimationFromStyleByName
(fromStyle, name())) |
136 timingFunction = matchedAnimation->timingFunction().get(); | 136 timingFunction = matchedAnimation->timingFunction().get(); |
137 | 137 |
138 prog = progress(scale, offset, timingFunction); | 138 prog = progress(scale, offset, timingFunction); |
139 } | 139 } |
140 | 140 |
141 void KeyframeAnimation::animate(CompositeAnimation*, RenderObject*, const Render
Style*, RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle) | 141 void KeyframeAnimation::animate(CompositeAnimation*, RenderObject*, const Render
Style*, RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle) |
142 { | 142 { |
143 // Fire the start timeout if needed | 143 // Fire the start timeout if needed |
144 fireAnimationEventsIfNeeded(); | 144 fireAnimationEventsIfNeeded(); |
145 | 145 |
(...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 | 440 |
441 if (acceleratedPropertiesOnly) { | 441 if (acceleratedPropertiesOnly) { |
442 bool isLooping; | 442 bool isLooping; |
443 getTimeToNextEvent(t, isLooping); | 443 getTimeToNextEvent(t, isLooping); |
444 } | 444 } |
445 | 445 |
446 return t; | 446 return t; |
447 } | 447 } |
448 | 448 |
449 } // namespace WebCore | 449 } // namespace WebCore |
OLD | NEW |