diff options
Diffstat (limited to 'Source/WebCore/page/animation/ImplicitAnimation.cpp')
| -rw-r--r-- | Source/WebCore/page/animation/ImplicitAnimation.cpp | 136 |
1 files changed, 51 insertions, 85 deletions
diff --git a/Source/WebCore/page/animation/ImplicitAnimation.cpp b/Source/WebCore/page/animation/ImplicitAnimation.cpp index 4eae7b4ac..af1d78819 100644 --- a/Source/WebCore/page/animation/ImplicitAnimation.cpp +++ b/Source/WebCore/page/animation/ImplicitAnimation.cpp @@ -10,7 +10,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. Neither the name of Apple Inc. ("Apple") nor the names of + * 3. Neither the name of Apple Computer, Inc. ("Apple") nor the names of * its contributors may be used to endorse or promote products derived * from this software without specific prior written permission. * @@ -32,18 +32,19 @@ #include "CSSPropertyAnimation.h" #include "CompositeAnimation.h" #include "EventNames.h" -#include "GeometryUtilities.h" #include "ImplicitAnimation.h" #include "KeyframeAnimation.h" -#include "RenderBox.h" +#include "RenderBoxModelObject.h" namespace WebCore { -ImplicitAnimation::ImplicitAnimation(Animation& transition, CSSPropertyID animatingProperty, RenderElement* renderer, CompositeAnimation* compAnim, RenderStyle* fromStyle) +ImplicitAnimation::ImplicitAnimation(const Animation& transition, CSSPropertyID animatingProperty, RenderElement* renderer, CompositeAnimation* compAnim, RenderStyle* fromStyle) : AnimationBase(transition, renderer, compAnim) - , m_fromStyle(fromStyle) , m_transitionProperty(transition.property()) , m_animatingProperty(animatingProperty) + , m_overridden(false) + , m_active(true) + , m_fromStyle(fromStyle) { ASSERT(animatingProperty != CSSPropertyInvalid); } @@ -60,14 +61,12 @@ bool ImplicitAnimation::shouldSendEventForListener(Document::ListenerType inList return m_object->document().hasListenerType(inListenerType); } -bool ImplicitAnimation::animate(CompositeAnimation*, RenderElement*, const RenderStyle*, RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle) +void ImplicitAnimation::animate(CompositeAnimation*, RenderElement*, const RenderStyle*, RenderStyle* targetStyle, RefPtr<RenderStyle>& animatedStyle) { // If we get this far and the animation is done, it means we are cleaning up a just finished animation. // So just return. Everything is already all cleaned up. if (postActive()) - return false; - - AnimationState oldState = state(); + return; // Reset to start the transition if we are new if (isNew()) @@ -78,21 +77,20 @@ bool ImplicitAnimation::animate(CompositeAnimation*, RenderElement*, const Rende if (!animatedStyle) animatedStyle = RenderStyle::clone(targetStyle); - bool needsAnim = CSSPropertyAnimation::blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress()); +#if USE(ACCELERATED_COMPOSITING) + bool needsAnim = CSSPropertyAnimation::blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress(1, 0, 0)); // FIXME: we also need to detect cases where we have to software animate for other reasons, // such as a child using inheriting the transform. https://bugs.webkit.org/show_bug.cgi?id=23902 - if (!needsAnim) { + if (!needsAnim) // If we are running an accelerated animation, set a flag in the style which causes the style // to compare as different to any other style. This ensures that changes to the property // that is animating are correctly detected during the animation (e.g. when a transition // gets interrupted). - // FIXME: still need this hack? animatedStyle->setIsRunningAcceleratedAnimation(); - } +#endif // Fire the start timeout if needed fireAnimationEventsIfNeeded(); - return state() != oldState; } void ImplicitAnimation::getAnimatedStyle(RefPtr<RenderStyle>& animatedStyle) @@ -100,46 +98,17 @@ void ImplicitAnimation::getAnimatedStyle(RefPtr<RenderStyle>& animatedStyle) if (!animatedStyle) animatedStyle = RenderStyle::clone(m_toStyle.get()); - CSSPropertyAnimation::blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress()); -} - -bool ImplicitAnimation::computeExtentOfTransformAnimation(LayoutRect& bounds) const -{ - ASSERT(hasStyle()); - - if (!is<RenderBox>(m_object)) - return true; // Non-boxes don't get transformed; - - ASSERT(m_animatingProperty == CSSPropertyTransform); - - RenderBox& box = downcast<RenderBox>(*m_object); - FloatRect rendererBox = snapRectToDevicePixels(box.borderBoxRect(), box.document().deviceScaleFactor()); - - LayoutRect startBounds = bounds; - LayoutRect endBounds = bounds; - - if (transformFunctionListsMatch()) { - if (!computeTransformedExtentViaTransformList(rendererBox, *m_fromStyle, startBounds)) - return false; - - if (!computeTransformedExtentViaTransformList(rendererBox, *m_toStyle, endBounds)) - return false; - } else { - if (!computeTransformedExtentViaMatrix(rendererBox, *m_fromStyle, startBounds)) - return false; - - if (!computeTransformedExtentViaMatrix(rendererBox, *m_toStyle, endBounds)) - return false; - } - - bounds = unionRect(startBounds, endBounds); - return true; + CSSPropertyAnimation::blendProperties(this, m_animatingProperty, animatedStyle.get(), m_fromStyle.get(), m_toStyle.get(), progress(1, 0, 0)); } bool ImplicitAnimation::startAnimation(double timeOffset) { +#if USE(ACCELERATED_COMPOSITING) if (m_object && m_object->isComposited()) - return downcast<RenderBoxModelObject>(*m_object).startTransition(timeOffset, m_animatingProperty, m_fromStyle.get(), m_toStyle.get()); + return toRenderBoxModelObject(m_object)->startTransition(timeOffset, m_animatingProperty, m_fromStyle.get(), m_toStyle.get()); +#else + UNUSED_PARAM(timeOffset); +#endif return false; } @@ -148,8 +117,12 @@ void ImplicitAnimation::pauseAnimation(double timeOffset) if (!m_object) return; +#if USE(ACCELERATED_COMPOSITING) if (m_object->isComposited()) - downcast<RenderBoxModelObject>(*m_object).transitionPaused(timeOffset, m_animatingProperty); + toRenderBoxModelObject(m_object)->transitionPaused(timeOffset, m_animatingProperty); +#else + UNUSED_PARAM(timeOffset); +#endif // Restore the original (unanimated) style if (!paused()) setNeedsStyleRecalc(m_object->element()); @@ -157,8 +130,10 @@ void ImplicitAnimation::pauseAnimation(double timeOffset) void ImplicitAnimation::endAnimation() { +#if USE(ACCELERATED_COMPOSITING) if (m_object && m_object->isComposited()) - downcast<RenderBoxModelObject>(*m_object).transitionFinished(m_animatingProperty); + toRenderBoxModelObject(m_object)->transitionFinished(m_animatingProperty); +#endif } void ImplicitAnimation::onAnimationEnd(double elapsedTime) @@ -168,7 +143,7 @@ void ImplicitAnimation::onAnimationEnd(double elapsedTime) // running. But now that the transition has completed, we need to update this style with its new // destination. If we didn't, the next time through we would think a transition had started // (comparing the old unanimated style with the new final style of the transition). - RefPtr<KeyframeAnimation> keyframeAnim = m_compositeAnimation->getAnimationForProperty(m_animatingProperty); + RefPtr<KeyframeAnimation> keyframeAnim = m_compAnim->getAnimationForProperty(m_animatingProperty); if (keyframeAnim) keyframeAnim->setUnanimatedStyle(m_toStyle); @@ -192,7 +167,7 @@ bool ImplicitAnimation::sendTransitionEvent(const AtomicString& eventType, doubl return false; // Schedule event handling - m_compositeAnimation->animationController().addEventToDispatch(element, eventType, propertyName, elapsedTime); + m_compAnim->animationController()->addEventToDispatch(element, eventType, propertyName, elapsedTime); // Restore the original (unanimated) style if (eventType == eventNames().transitionendEvent && element->renderer()) @@ -214,13 +189,12 @@ void ImplicitAnimation::reset(RenderStyle* to) // Restart the transition if (m_fromStyle && m_toStyle) - updateStateMachine(AnimationStateInput::RestartAnimation, -1); + updateStateMachine(AnimationStateInputRestartAnimation, -1); // set the transform animation list validateTransformFunctionList(); +#if ENABLE(CSS_FILTERS) checkForMatchingFilterFunctionLists(); -#if ENABLE(FILTERS_LEVEL_2) - checkForMatchingBackdropFilterFunctionLists(); #endif } @@ -230,7 +204,7 @@ void ImplicitAnimation::setOverridden(bool b) return; m_overridden = b; - updateStateMachine(m_overridden ? AnimationStateInput::PauseOverride : AnimationStateInput::ResumeOverride, -1); + updateStateMachine(m_overridden ? AnimationStateInputPauseOverride : AnimationStateInputResumeOverride, -1); } bool ImplicitAnimation::affectsProperty(CSSPropertyID property) const @@ -255,12 +229,12 @@ void ImplicitAnimation::blendPropertyValueInStyle(CSSPropertyID prop, RenderStyl if (!m_toStyle) return; - CSSPropertyAnimation::blendProperties(this, prop, currentStyle, m_fromStyle.get(), m_toStyle.get(), progress()); + CSSPropertyAnimation::blendProperties(this, prop, currentStyle, m_fromStyle.get(), m_toStyle.get(), progress(1, 0, 0)); } void ImplicitAnimation::validateTransformFunctionList() { - m_transformFunctionListsMatch = false; + m_transformFunctionListValid = false; if (!m_fromStyle || !m_toStyle) return; @@ -274,53 +248,44 @@ void ImplicitAnimation::validateTransformFunctionList() if (val->operations().isEmpty()) return; - // An empty transform list matches anything. + // An emtpy transform list matches anything. if (val != toVal && !toVal->operations().isEmpty() && !val->operationsMatch(*toVal)) return; // Transform lists match. - m_transformFunctionListsMatch = true; -} - -static bool filterOperationsMatch(const FilterOperations* fromOperations, const FilterOperations& toOperations) -{ - if (fromOperations->operations().isEmpty()) - fromOperations = &toOperations; - - if (fromOperations->operations().isEmpty()) - return false; - - if (fromOperations != &toOperations && !toOperations.operations().isEmpty() && !fromOperations->operationsMatch(toOperations)) - return false; - - return true; + m_transformFunctionListValid = true; } +#if ENABLE(CSS_FILTERS) void ImplicitAnimation::checkForMatchingFilterFunctionLists() { m_filterFunctionListsMatch = false; - + if (!m_fromStyle || !m_toStyle) return; + + const FilterOperations* val = &m_fromStyle->filter(); + const FilterOperations* toVal = &m_toStyle->filter(); - m_filterFunctionListsMatch = filterOperationsMatch(&m_fromStyle->filter(), m_toStyle->filter()); -} - -#if ENABLE(FILTERS_LEVEL_2) -void ImplicitAnimation::checkForMatchingBackdropFilterFunctionLists() -{ - m_backdropFilterFunctionListsMatch = false; + if (val->operations().isEmpty()) + val = toVal; - if (!m_fromStyle || !m_toStyle) + if (val->operations().isEmpty()) + return; + + // An emtpy filter list matches anything. + if (val != toVal && !toVal->operations().isEmpty() && !val->operationsMatch(*toVal)) return; - m_backdropFilterFunctionListsMatch = filterOperationsMatch(&m_fromStyle->backdropFilter(), m_toStyle->backdropFilter()); + // Filter lists match. + m_filterFunctionListsMatch = true; } #endif double ImplicitAnimation::timeToNextService() { double t = AnimationBase::timeToNextService(); +#if USE(ACCELERATED_COMPOSITING) if (t != 0 || preActive()) return t; @@ -330,6 +295,7 @@ double ImplicitAnimation::timeToNextService() bool isLooping; getTimeToNextEvent(t, isLooping); } +#endif return t; } |
