示例#1
0
RenderStyle* AnimationController::updateAnimations(RenderObject* renderer, RenderStyle* newStyle)
{    
    // don't do anything if we're in the cache
    if (!renderer->document() || renderer->document()->inPageCache())
        return newStyle;
    
    RenderStyle* oldStyle = renderer->style();
    
    if ((!oldStyle || (!oldStyle->animations() && !oldStyle->transitions())) && 
                        (!newStyle->animations() && !newStyle->transitions()))
        return newStyle;
    
    RenderStyle* blendedStyle = newStyle;
    
    // Fetch our current set of implicit animations from a hashtable.  We then compare them
    // against the animations in the style and make sure we're in sync.  If destination values
    // have changed, we reset the animation.  We then do a blend to get new values and we return
    // a new style.
    ASSERT(renderer->element()); // FIXME: We do not animate generated content yet.
    
    CompositeAnimation* rendererAnimations = m_data->accessCompositeAnimation(renderer);
    blendedStyle = rendererAnimations->animate(renderer, oldStyle, newStyle);
    
    m_data->updateAnimationTimer();
    
    if (blendedStyle != newStyle) {
        // If the animations/transitions change opacity or transform, we neeed to update
        // the style to impose the stacking rules. Note that this is also
        // done in CSSStyleSelector::adjustRenderStyle().
        if (blendedStyle->hasAutoZIndex() && (blendedStyle->opacity() < 1.0f || blendedStyle->hasTransform()))
            blendedStyle->setZIndex(0);
    }
    return blendedStyle;
}