Title: [118052] trunk/Source/WebCore
Revision
118052
Author
[email protected]
Date
2012-05-22 14:17:44 -0700 (Tue, 22 May 2012)

Log Message

Use the same animation begin time while updating compositing layers
https://bugs.webkit.org/show_bug.cgi?id=87080

Reviewed by Dean Jackson.

Tidied up some beginAnimationUpdate/endAnimationUpdate logic,
but further cleaning is required. We currently bracket some calls
to recaclcStyle() with begin/endAnimationUpdate, but not all.
We don't bracket layout, or compositing updates. This patch
adds bracketing around compositing updates, in order to be
able to add some assertions in a later patch that rely on
RenderLayer::currentTransform() giving consistent results,
since currentTransform() depends on the animation begin time.

Made AnimationController::beginAnimationUpdate() and
AnimationController::endAnimationUpdate() nestable by adding
a counter.

Added a stack-based class, AnimationUpdateBlock, which
calls begin/endAnimationUpdate.

Replaced calls to begin/endAnimationUpdate in Document::updateStyleIfNeeded()
and Document::styleResolverChanged() with AnimationUpdateBlock. Filed a bug
to cover other calls to recalcStyle which might need this (87159).

Removed a call to beginAnimationUpdate() in Document::implicitOpen(),
which was added in r42415. I believe that r57390 makes this unnecessary,
and was not able to reproduce the original bug after removing it. It
was the only unpaired beginAnimationUpdate call.

Made AnimationControllerPrivate::getAnimatedStyleForRenderer() not
use a new beginTime each time it was called, so its beginTime now
depends on some earlier beginAnimationUpdate.

Fixed CSSComputedStyleDeclaration::getPropertyCSSValue() to use
an AnimationUpdateBlock so that calls to computed style do
use the current time to compute an animating value (as before).

Not testable.

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
* dom/Document.cpp:
(WebCore::Document::updateStyleIfNeeded):
(WebCore::Document::implicitOpen):
(WebCore::Document::styleResolverChanged):
* page/animation/AnimationController.cpp:
(WebCore::AnimationControllerPrivate::getAnimatedStyleForRenderer):
(WebCore::AnimationController::AnimationController):
(WebCore::AnimationController::beginAnimationUpdate):
(WebCore::AnimationController::endAnimationUpdate):
* page/animation/AnimationController.h:
(AnimationController):
(WebCore):
(AnimationUpdateBlock):
(WebCore::AnimationUpdateBlock::AnimationUpdateBlock):
(WebCore::AnimationUpdateBlock::~AnimationUpdateBlock):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::updateCompositingLayers):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (118051 => 118052)


--- trunk/Source/WebCore/ChangeLog	2012-05-22 21:02:52 UTC (rev 118051)
+++ trunk/Source/WebCore/ChangeLog	2012-05-22 21:17:44 UTC (rev 118052)
@@ -1,3 +1,65 @@
+2012-05-22  Simon Fraser  <[email protected]>
+
+        Use the same animation begin time while updating compositing layers
+        https://bugs.webkit.org/show_bug.cgi?id=87080
+
+        Reviewed by Dean Jackson.
+        
+        Tidied up some beginAnimationUpdate/endAnimationUpdate logic,
+        but further cleaning is required. We currently bracket some calls
+        to recaclcStyle() with begin/endAnimationUpdate, but not all.
+        We don't bracket layout, or compositing updates. This patch
+        adds bracketing around compositing updates, in order to be
+        able to add some assertions in a later patch that rely on
+        RenderLayer::currentTransform() giving consistent results,
+        since currentTransform() depends on the animation begin time.
+        
+        Made AnimationController::beginAnimationUpdate() and
+        AnimationController::endAnimationUpdate() nestable by adding
+        a counter.
+        
+        Added a stack-based class, AnimationUpdateBlock, which
+        calls begin/endAnimationUpdate.
+        
+        Replaced calls to begin/endAnimationUpdate in Document::updateStyleIfNeeded()
+        and Document::styleResolverChanged() with AnimationUpdateBlock. Filed a bug
+        to cover other calls to recalcStyle which might need this (87159).
+        
+        Removed a call to beginAnimationUpdate() in Document::implicitOpen(),
+        which was added in r42415. I believe that r57390 makes this unnecessary,
+        and was not able to reproduce the original bug after removing it. It
+        was the only unpaired beginAnimationUpdate call.
+        
+        Made AnimationControllerPrivate::getAnimatedStyleForRenderer() not 
+        use a new beginTime each time it was called, so its beginTime now
+        depends on some earlier beginAnimationUpdate.
+        
+        Fixed CSSComputedStyleDeclaration::getPropertyCSSValue() to use
+        an AnimationUpdateBlock so that calls to computed style do
+        use the current time to compute an animating value (as before).
+
+        Not testable.
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+        * dom/Document.cpp:
+        (WebCore::Document::updateStyleIfNeeded):
+        (WebCore::Document::implicitOpen):
+        (WebCore::Document::styleResolverChanged):
+        * page/animation/AnimationController.cpp:
+        (WebCore::AnimationControllerPrivate::getAnimatedStyleForRenderer):
+        (WebCore::AnimationController::AnimationController):
+        (WebCore::AnimationController::beginAnimationUpdate):
+        (WebCore::AnimationController::endAnimationUpdate):
+        * page/animation/AnimationController.h:
+        (AnimationController):
+        (WebCore):
+        (AnimationUpdateBlock):
+        (WebCore::AnimationUpdateBlock::AnimationUpdateBlock):
+        (WebCore::AnimationUpdateBlock::~AnimationUpdateBlock):
+        * rendering/RenderLayerCompositor.cpp:
+        (WebCore::RenderLayerCompositor::updateCompositingLayers):
+
 2012-05-22  Tony Chang  <[email protected]>
 
         REGRESSION(r117613): Dromaeo/jslib-style-prototype regressed by 20%

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (118051 => 118052)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-05-22 21:02:52 UTC (rev 118051)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2012-05-22 21:17:44 UTC (rev 118052)
@@ -1322,6 +1322,7 @@
 
     RefPtr<RenderStyle> style;
     if (renderer && renderer->isComposited() && AnimationController::supportsAcceleratedAnimationOfProperty(propertyID)) {
+        AnimationUpdateBlock animationUpdateBlock(renderer->animation());
         style = renderer->animation()->getAnimatedStyleForRenderer(renderer);
         if (m_pseudoElementSpecifier) {
             // FIXME: This cached pseudo style will only exist if the animation has been run at least once.

Modified: trunk/Source/WebCore/dom/Document.cpp (118051 => 118052)


--- trunk/Source/WebCore/dom/Document.cpp	2012-05-22 21:02:52 UTC (rev 118051)
+++ trunk/Source/WebCore/dom/Document.cpp	2012-05-22 21:17:44 UTC (rev 118052)
@@ -1808,14 +1808,8 @@
     if ((!m_pendingStyleRecalcShouldForce && !childNeedsStyleRecalc()) || inPageCache())
         return;
 
-    if (m_frame)
-        m_frame->animation()->beginAnimationUpdate();
-        
+    AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation() : 0);
     recalcStyle(NoChange);
-
-    // Tell the animation controller that updateStyleIfNeeded is finished and it can do any post-processing
-    if (m_frame)
-        m_frame->animation()->endAnimationUpdate();
 }
 
 void Document::updateStyleForAllDocuments()
@@ -2297,11 +2291,6 @@
     m_parser = createParser();
     setParsing(true);
     setReadyState(Loading);
-
-    // If we reload, the animation controller sticks around and has
-    // a stale animation time. We need to update it here.
-    if (m_frame && m_frame->animation())
-        m_frame->animation()->beginAnimationUpdate();
 }
 
 HTMLElement* Document::body() const
@@ -3289,11 +3278,10 @@
 
     // This recalcStyle initiates a new recalc cycle. We need to bracket it to
     // make sure animations get the correct update time
-    if (m_frame)
-        m_frame->animation()->beginAnimationUpdate();
-    recalcStyle(Force);
-    if (m_frame)
-        m_frame->animation()->endAnimationUpdate();
+    {
+        AnimationUpdateBlock animationUpdateBlock(m_frame ? m_frame->animation() : 0);
+        recalcStyle(Force);
+    }
 
 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
     if (!ownerElement())

Modified: trunk/Source/WebCore/page/animation/AnimationController.cpp (118051 => 118052)


--- trunk/Source/WebCore/page/animation/AnimationController.cpp	2012-05-22 21:02:52 UTC (rev 118051)
+++ trunk/Source/WebCore/page/animation/AnimationController.cpp	2012-05-22 21:17:44 UTC (rev 118052)
@@ -383,9 +383,6 @@
     if (!rendererAnimations)
         return renderer->style();
     
-    // Make sure animationUpdateTime is updated, so that it is current even if no
-    // styleChange has happened (e.g. accelerated animations).
-    setBeginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet);
     RefPtr<RenderStyle> animatingStyle = rendererAnimations->getAnimatedStyle();
     if (!animatingStyle)
         animatingStyle = renderer->style();
@@ -497,6 +494,7 @@
 
 AnimationController::AnimationController(Frame* frame)
     : m_data(adoptPtr(new AnimationControllerPrivate(frame)))
+    , m_beginAnimationUpdateCount(0)
 {
 }
 
@@ -622,12 +620,17 @@
 
 void AnimationController::beginAnimationUpdate()
 {
-    m_data->setBeginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet);
+    if (!m_beginAnimationUpdateCount)
+        m_data->setBeginAnimationUpdateTime(cBeginAnimationUpdateTimeNotSet);
+    ++m_beginAnimationUpdateCount;
 }
 
 void AnimationController::endAnimationUpdate()
 {
-    m_data->endAnimationUpdate();
+    ASSERT(m_beginAnimationUpdateCount > 0);
+    --m_beginAnimationUpdateCount;
+    if (!m_beginAnimationUpdateCount)
+        m_data->endAnimationUpdate();
 }
 
 bool AnimationController::supportsAcceleratedAnimationOfProperty(CSSPropertyID property)

Modified: trunk/Source/WebCore/page/animation/AnimationController.h (118051 => 118052)


--- trunk/Source/WebCore/page/animation/AnimationController.h	2012-05-22 21:02:52 UTC (rev 118051)
+++ trunk/Source/WebCore/page/animation/AnimationController.h	2012-05-22 21:17:44 UTC (rev 118052)
@@ -82,8 +82,27 @@
 
 private:
     OwnPtr<AnimationControllerPrivate> m_data;
+    int m_beginAnimationUpdateCount;
 };
 
+class AnimationUpdateBlock {
+public:
+    AnimationUpdateBlock(AnimationController* animationController)
+        : m_animationController(animationController)
+    {
+        if (m_animationController)
+            m_animationController->beginAnimationUpdate();
+    }
+    
+    ~AnimationUpdateBlock()
+    {
+        if (m_animationController)
+            m_animationController->endAnimationUpdate();
+    }
+    
+    AnimationController* m_animationController;
+};
+
 } // namespace WebCore
 
 #endif // AnimationController_h

Modified: trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp (118051 => 118052)


--- trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2012-05-22 21:02:52 UTC (rev 118051)
+++ trunk/Source/WebCore/rendering/RenderLayerCompositor.cpp	2012-05-22 21:17:44 UTC (rev 118052)
@@ -350,6 +350,8 @@
     if (!m_reevaluateCompositingAfterLayout && !m_compositing)
         return;
 
+    AnimationUpdateBlock animationUpdateBlock(m_renderView->frameView()->frame()->animation());
+
     bool checkForHierarchyUpdate = m_reevaluateCompositingAfterLayout;
     bool needGeometryUpdate = false;
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to