| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2007, 2008, 2009 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 , m_animationsWaitingForStyle() | 55 , m_animationsWaitingForStyle() |
| 56 , m_animationsWaitingForStartTimeResponse() | 56 , m_animationsWaitingForStartTimeResponse() |
| 57 , m_animationsWaitingForAsyncStartNotification() | 57 , m_animationsWaitingForAsyncStartNotification() |
| 58 { | 58 { |
| 59 } | 59 } |
| 60 | 60 |
| 61 AnimationControllerPrivate::~AnimationControllerPrivate() | 61 AnimationControllerPrivate::~AnimationControllerPrivate() |
| 62 { | 62 { |
| 63 } | 63 } |
| 64 | 64 |
| 65 PassRefPtr<CompositeAnimation> AnimationControllerPrivate::accessCompositeAnimat
ion(RenderObject* renderer) | 65 PassRefPtr<CompositeAnimation> AnimationControllerPrivate::accessCompositeAnimat
ion(RenderObject& renderer) |
| 66 { | 66 { |
| 67 RefPtr<CompositeAnimation> animation = m_compositeAnimations.get(renderer); | 67 RefPtr<CompositeAnimation> animation = m_compositeAnimations.get(&renderer); |
| 68 if (!animation) { | 68 if (!animation) { |
| 69 animation = CompositeAnimation::create(this); | 69 animation = CompositeAnimation::create(this); |
| 70 m_compositeAnimations.set(renderer, animation); | 70 m_compositeAnimations.set(&renderer, animation); |
| 71 } | 71 } |
| 72 return animation; | 72 return animation; |
| 73 } | 73 } |
| 74 | 74 |
| 75 bool AnimationControllerPrivate::clear(RenderObject* renderer) | 75 bool AnimationControllerPrivate::clear(RenderObject* renderer) |
| 76 { | 76 { |
| 77 // Return false if we didn't do anything. | 77 // Return false if we didn't do anything. |
| 78 PassRefPtr<CompositeAnimation> animation = m_compositeAnimations.take(render
er); | 78 PassRefPtr<CompositeAnimation> animation = m_compositeAnimations.take(render
er); |
| 79 if (!animation) | 79 if (!animation) |
| 80 return false; | 80 return false; |
| (...skipping 30 matching lines...) Expand all Loading... |
| 111 } | 111 } |
| 112 } | 112 } |
| 113 | 113 |
| 114 if (updateStyleNeeded) | 114 if (updateStyleNeeded) |
| 115 m_frame->document()->updateStyleIfNeeded(); | 115 m_frame->document()->updateStyleIfNeeded(); |
| 116 | 116 |
| 117 timeToNextService = minTimeToNextService; | 117 timeToNextService = minTimeToNextService; |
| 118 timeToNextEvent = minTimeToNextEvent; | 118 timeToNextEvent = minTimeToNextEvent; |
| 119 } | 119 } |
| 120 | 120 |
| 121 void AnimationControllerPrivate::scheduleServiceForRenderer(RenderObject* render
er) | 121 void AnimationControllerPrivate::scheduleServiceForRenderer(RenderObject& render
er) |
| 122 { | 122 { |
| 123 double timeToNextService = -1; | 123 double timeToNextService = -1; |
| 124 double timeToNextEvent = -1; | 124 double timeToNextEvent = -1; |
| 125 | 125 |
| 126 RefPtr<CompositeAnimation> compAnim = m_compositeAnimations.get(renderer); | 126 RefPtr<CompositeAnimation> compAnim = m_compositeAnimations.get(&renderer); |
| 127 if (compAnim->hasAnimations()) { | 127 if (compAnim->hasAnimations()) { |
| 128 timeToNextService = compAnim->timeToNextService(); | 128 timeToNextService = compAnim->timeToNextService(); |
| 129 timeToNextEvent = compAnim->timeToNextEvent(); | 129 timeToNextEvent = compAnim->timeToNextEvent(); |
| 130 } | 130 } |
| 131 | 131 |
| 132 if (timeToNextService >= 0) | 132 if (timeToNextService >= 0) |
| 133 scheduleService(timeToNextService, timeToNextEvent); | 133 scheduleService(timeToNextService, timeToNextEvent); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void AnimationControllerPrivate::scheduleService() | 136 void AnimationControllerPrivate::scheduleService() |
| (...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 436 { | 436 { |
| 437 if (!m_data->hasAnimations()) | 437 if (!m_data->hasAnimations()) |
| 438 return; | 438 return; |
| 439 | 439 |
| 440 if (m_data->clear(renderer)) { | 440 if (m_data->clear(renderer)) { |
| 441 if (Node* node = renderer->node()) | 441 if (Node* node = renderer->node()) |
| 442 node->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer)
; | 442 node->setNeedsStyleRecalc(LocalStyleChange, StyleChangeFromRenderer)
; |
| 443 } | 443 } |
| 444 } | 444 } |
| 445 | 445 |
| 446 PassRefPtr<RenderStyle> AnimationController::updateAnimations(RenderObject* rend
erer, RenderStyle* newStyle) | 446 PassRefPtr<RenderStyle> AnimationController::updateAnimations(RenderObject& rend
erer, RenderStyle& newStyle) |
| 447 { | 447 { |
| 448 RenderStyle* oldStyle = renderer->style(); | 448 RenderStyle* oldStyle = renderer.style(); |
| 449 | 449 |
| 450 if ((!oldStyle || (!oldStyle->animations() && !oldStyle->transitions())) &&
(!newStyle->animations() && !newStyle->transitions())) | 450 if ((!oldStyle || (!oldStyle->animations() && !oldStyle->transitions())) &&
(!newStyle.animations() && !newStyle.transitions())) |
| 451 return newStyle; | 451 return PassRefPtr<RenderStyle>(newStyle); |
| 452 | 452 |
| 453 // Don't run transitions when printing. | 453 // Don't run transitions when printing. |
| 454 if (renderer->view()->document().printing()) | 454 if (renderer.view()->document().printing()) |
| 455 return newStyle; | 455 return PassRefPtr<RenderStyle>(newStyle); |
| 456 | 456 |
| 457 // Fetch our current set of implicit animations from a hashtable. We then c
ompare them | 457 // Fetch our current set of implicit animations from a hashtable. We then c
ompare them |
| 458 // against the animations in the style and make sure we're in sync. If dest
ination values | 458 // against the animations in the style and make sure we're in sync. If dest
ination values |
| 459 // have changed, we reset the animation. We then do a blend to get new valu
es and we return | 459 // have changed, we reset the animation. We then do a blend to get new valu
es and we return |
| 460 // a new style. | 460 // a new style. |
| 461 | 461 |
| 462 // We don't support anonymous pseudo elements like :first-line or :first-let
ter. | 462 // We don't support anonymous pseudo elements like :first-line or :first-let
ter. |
| 463 ASSERT(renderer->node()); | 463 ASSERT(renderer.node()); |
| 464 | 464 |
| 465 RefPtr<CompositeAnimation> rendererAnimations = m_data->accessCompositeAnima
tion(renderer); | 465 RefPtr<CompositeAnimation> rendererAnimations = m_data->accessCompositeAnima
tion(renderer); |
| 466 RefPtr<RenderStyle> blendedStyle = rendererAnimations->animate(renderer, old
Style, newStyle); | 466 RefPtr<RenderStyle> blendedStyle = rendererAnimations->animate(renderer, old
Style, newStyle); |
| 467 | 467 |
| 468 if (renderer->parent() || newStyle->animations() || (oldStyle && oldStyle->a
nimations())) { | 468 if (renderer.parent() || newStyle.animations() || (oldStyle && oldStyle->ani
mations())) { |
| 469 m_data->scheduleServiceForRenderer(renderer); | 469 m_data->scheduleServiceForRenderer(renderer); |
| 470 } | 470 } |
| 471 | 471 |
| 472 if (blendedStyle != newStyle) { | 472 if (blendedStyle != &newStyle) { |
| 473 // If the animations/transitions change opacity or transform, we need to
update | 473 // If the animations/transitions change opacity or transform, we need to
update |
| 474 // the style to impose the stacking rules. Note that this is also | 474 // the style to impose the stacking rules. Note that this is also |
| 475 // done in StyleResolver::adjustRenderStyle(). | 475 // done in StyleResolver::adjustRenderStyle(). |
| 476 if (blendedStyle->hasAutoZIndex() && (blendedStyle->opacity() < 1.0f ||
blendedStyle->hasTransform())) | 476 if (blendedStyle->hasAutoZIndex() && (blendedStyle->opacity() < 1.0f ||
blendedStyle->hasTransform())) |
| 477 blendedStyle->setZIndex(0); | 477 blendedStyle->setZIndex(0); |
| 478 } | 478 } |
| 479 return blendedStyle.release(); | 479 return blendedStyle.release(); |
| 480 } | 480 } |
| 481 | 481 |
| 482 PassRefPtr<RenderStyle> AnimationController::getAnimatedStyleForRenderer(RenderO
bject* renderer) | 482 PassRefPtr<RenderStyle> AnimationController::getAnimatedStyleForRenderer(RenderO
bject* renderer) |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 533 if (!m_beginAnimationUpdateCount) | 533 if (!m_beginAnimationUpdateCount) |
| 534 m_data->endAnimationUpdate(); | 534 m_data->endAnimationUpdate(); |
| 535 } | 535 } |
| 536 | 536 |
| 537 bool AnimationController::supportsAcceleratedAnimationOfProperty(CSSPropertyID p
roperty) | 537 bool AnimationController::supportsAcceleratedAnimationOfProperty(CSSPropertyID p
roperty) |
| 538 { | 538 { |
| 539 return CSSPropertyAnimation::animationOfPropertyIsAccelerated(property); | 539 return CSSPropertyAnimation::animationOfPropertyIsAccelerated(property); |
| 540 } | 540 } |
| 541 | 541 |
| 542 } // namespace WebCore | 542 } // namespace WebCore |
| OLD | NEW |