Title: [153396] trunk
Revision
153396
Author
[email protected]
Date
2013-07-26 17:57:31 -0700 (Fri, 26 Jul 2013)

Log Message

Allow new transitions to run even when controller is suspended
https://bugs.webkit.org/show_bug.cgi?id=119171
<rdar://problem/14511404>

Reviewed by Simon Fraser.

Source/WebCore:

Expose a new property on AnimationController that allows newly created
animations to run even if the controller says it is suspended. See WebKit
ChangeLog for more details.

Test: transitions/created-while-suspended.html

* WebCore.exp.in: Export the new methods so WebView can use them.
* page/animation/AnimationController.cpp:
(WebCore::AnimationControllerPrivate::AnimationControllerPrivate): Initialize new flag to false.
(WebCore::AnimationControllerPrivate::startAnimationsIfNotSuspended): Check new flag is not true.
(WebCore::AnimationControllerPrivate::setAllowsNewAnimationsWhileSuspended): Expose setter.
(WebCore::AnimationController::allowsNewAnimationsWhileSuspended): "Public" getter.
(WebCore::AnimationController::setAllowsNewAnimationsWhileSuspended): "Public" setter.
* page/animation/AnimationController.h:
* page/animation/AnimationControllerPrivate.h:
(WebCore::AnimationControllerPrivate::allowsNewAnimationsWhileSuspended):
* page/animation/CompositeAnimation.cpp:
(WebCore::CompositeAnimation::CompositeAnimation): Only suspend if new flag is false. Everything else
relies on the m_suspended flag, so the real code change is this one line.

Source/WebKit/mac:

Expose a new SPI on WebView that triggers the (buggy) old behaviour
for animations, such that any newly created animations will start even
when the document is supposedly suspended. It turns out that client content was
unknowingly relying on this behaviour - e.g. suspending a view, loading a
bunch of new content, bringing the view on screen and then unsuspending. In this
situation, we were not running CSS transitions, because the page was suspended.
However, JS was still triggering them, and content was expecting a transitionEnd event.

* WebView/WebView.mm:
(-[WebView allowsNewCSSAnimationsWhileSuspended]): Calls into AnimationController.
(-[WebView setAllowsNewCSSAnimationsWhileSuspended:]): Ditto.
* WebView/WebViewPrivate.h: New methods listed above.

LayoutTests:

This is actually a test to make sure this fix didn't break anything. There is no
way to trigger the new behaviour from the test system (or from Safari).

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (153395 => 153396)


--- trunk/LayoutTests/ChangeLog	2013-07-27 00:24:08 UTC (rev 153395)
+++ trunk/LayoutTests/ChangeLog	2013-07-27 00:57:31 UTC (rev 153396)
@@ -1,3 +1,14 @@
+2013-07-26  Dean Jackson  <[email protected]>
+
+        Allow new transitions to run even when controller is suspended
+        https://bugs.webkit.org/show_bug.cgi?id=119171
+        <rdar://problem/14511404>
+
+        Reviewed by Simon Fraser.
+
+        This is actually a test to make sure this fix didn't break anything. There is no
+        way to trigger the new behaviour from the test system (or from Safari).
+
 2013-07-26  Bem Jones-Bey  <[email protected]>
 
         [CSS Shapes] New positioning model: support for polygon shape-outside

Added: trunk/LayoutTests/transitions/created-while-suspended-expected.txt (0 => 153396)


--- trunk/LayoutTests/transitions/created-while-suspended-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/transitions/created-while-suspended-expected.txt	2013-07-27 00:57:31 UTC (rev 153396)
@@ -0,0 +1,12 @@
+This test creates a box, adds a transition, then sets the left property. It will only have reproducible output when run in the test system
+
+*** Starting test.
+Transitions should not be suspended: PASS
+*** Suspending Animations/Transitions
+Transitions should be suspended: PASS
+*** Creating the box.
+*** Adding transition property and setting left to 100px. We should NOT see transition events.
+*** Resuming Animations/Transitions
+Transitions should not be suspended: PASS
+*** Test finished
+
Property changes on: trunk/LayoutTests/transitions/created-while-suspended-expected.txt
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Added: trunk/LayoutTests/transitions/created-while-suspended.html (0 => 153396)


--- trunk/LayoutTests/transitions/created-while-suspended.html	                        (rev 0)
+++ trunk/LayoutTests/transitions/created-while-suspended.html	2013-07-27 00:57:31 UTC (rev 153396)
@@ -0,0 +1,92 @@
+<title>Test that newly created transitions do not run while we are suspended</title>
+<style>
+#box {
+    position: relative;
+    left: 0px;
+    height: 50px;
+    width: 50px;
+    background-color: blue;
+}
+</style>
+<script>
+var box;
+
+function suspend()
+{
+    if (window.internals)
+        internals.suspendAnimations(document);
+}
+
+function resume()
+{
+    if (window.internals)
+        internals.resumeAnimations(document);
+}
+
+function transitionEnded(event)
+{
+    log("#### Transition ended on element with id: " + event.target.id);
+}
+
+function suspendAndCreate()
+{
+    log("*** Suspending Animations/Transitions");
+    suspend();
+    setTimeout(function() {
+        if (window.internals)
+            log("Transitions should be suspended: " + (window.internals.animationsAreSuspended(document) ? "PASS" : "FAIL"));
+
+        log("*** Creating the box.")
+        box = document.createElement("div");
+        box.id = "box";
+        document.addEventListener("webkitTransitionEnd", transitionEnded, false);
+        document.body.insertBefore(box, document.querySelector("#results"));
+        setTimeout(function() {
+            log("*** Adding transition property and setting left to 100px. We should NOT see transition events.")
+            box.style.webkitTransitionDuration = "100ms";
+            box.style.left = "100px";
+            setTimeout(endTest, 200);
+        }, 100);
+    }, 100);
+}
+
+function endTest()
+{
+    log("*** Resuming Animations/Transitions");
+    resume();
+    if (window.internals)
+        log("Transitions should not be suspended: " + (window.internals.animationsAreSuspended(document) ? "FAIL" : "PASS"));
+
+    resume(); // Just in case.
+    log("*** Test finished");
+    if (window.testRunner)
+        setTimeout(function () { testRunner.notifyDone();}, 8000);
+}
+
+function startTest()
+{
+    log("*** Starting test.")
+
+    if (window.internals)
+        log("Transitions should not be suspended: " + (window.internals.animationsAreSuspended(document) ? "FAIL" : "PASS"));
+
+    suspendAndCreate();
+}
+
+function log(message)
+{
+    var results = document.getElementById("results");
+    results.innerHTML = results.innerHTML + message + "<br>";
+}
+
+if (window.testRunner) {
+    testRunner.waitUntilDone();
+    testRunner.dumpAsText();
+}
+
+window.addEventListener("load", startTest, false);
+
+</script>
+<p>This test creates a box, adds a transition, then sets the left property. It will only have reproducible output when run in the test system</p>
+<div id="results">
+</div>
Property changes on: trunk/LayoutTests/transitions/created-while-suspended.html
___________________________________________________________________

Added: svn:mime-type

Added: svn:keywords

Added: svn:eol-style

Modified: trunk/Source/WebCore/ChangeLog (153395 => 153396)


--- trunk/Source/WebCore/ChangeLog	2013-07-27 00:24:08 UTC (rev 153395)
+++ trunk/Source/WebCore/ChangeLog	2013-07-27 00:57:31 UTC (rev 153396)
@@ -1,3 +1,31 @@
+2013-07-26  Dean Jackson  <[email protected]>
+
+        Allow new transitions to run even when controller is suspended
+        https://bugs.webkit.org/show_bug.cgi?id=119171
+        <rdar://problem/14511404>
+
+        Reviewed by Simon Fraser.
+
+        Expose a new property on AnimationController that allows newly created
+        animations to run even if the controller says it is suspended. See WebKit
+        ChangeLog for more details.
+
+        Test: transitions/created-while-suspended.html
+
+        * WebCore.exp.in: Export the new methods so WebView can use them.
+        * page/animation/AnimationController.cpp:
+        (WebCore::AnimationControllerPrivate::AnimationControllerPrivate): Initialize new flag to false.
+        (WebCore::AnimationControllerPrivate::startAnimationsIfNotSuspended): Check new flag is not true.
+        (WebCore::AnimationControllerPrivate::setAllowsNewAnimationsWhileSuspended): Expose setter.
+        (WebCore::AnimationController::allowsNewAnimationsWhileSuspended): "Public" getter.
+        (WebCore::AnimationController::setAllowsNewAnimationsWhileSuspended): "Public" setter.
+        * page/animation/AnimationController.h:
+        * page/animation/AnimationControllerPrivate.h:
+        (WebCore::AnimationControllerPrivate::allowsNewAnimationsWhileSuspended):
+        * page/animation/CompositeAnimation.cpp:
+        (WebCore::CompositeAnimation::CompositeAnimation): Only suspend if new flag is false. Everything else
+        relies on the m_suspended flag, so the real code change is this one line.
+
 2013-07-26  Brent Fulgham  <[email protected]>
 
         [Windows] Unreviewed build fix.

Modified: trunk/Source/WebCore/WebCore.exp.in (153395 => 153396)


--- trunk/Source/WebCore/WebCore.exp.in	2013-07-27 00:24:08 UTC (rev 153395)
+++ trunk/Source/WebCore/WebCore.exp.in	2013-07-27 00:57:31 UTC (rev 153396)
@@ -622,6 +622,8 @@
 __ZN7WebCore19AnimationController17suspendAnimationsEv
 __ZN7WebCore19AnimationController20pauseAnimationAtTimeEPNS_12RenderObjectERKN3WTF12AtomicStringEd
 __ZN7WebCore19AnimationController21pauseTransitionAtTimeEPNS_12RenderObjectERKN3WTF6StringEd
+__ZN7WebCore19AnimationController36setAllowsNewAnimationsWhileSuspendedEb
+__ZNK7WebCore19AnimationController33allowsNewAnimationsWhileSuspendedEv
 __ZN7WebCore19BackForwardListImpl10removeItemEPNS_11HistoryItemE
 __ZN7WebCore19BackForwardListImpl10setEnabledEb
 __ZN7WebCore19BackForwardListImpl11currentItemEv

Modified: trunk/Source/WebCore/page/animation/AnimationController.cpp (153395 => 153396)


--- trunk/Source/WebCore/page/animation/AnimationController.cpp	2013-07-27 00:24:08 UTC (rev 153395)
+++ trunk/Source/WebCore/page/animation/AnimationController.cpp	2013-07-27 00:57:31 UTC (rev 153396)
@@ -59,6 +59,7 @@
     , m_animationsWaitingForStartTimeResponse()
     , m_waitingForAsyncStartNotification(false)
     , m_isSuspended(false)
+    , m_allowsNewAnimationsWhileSuspended(false)
 {
 }
 
@@ -322,10 +323,15 @@
 
 void AnimationControllerPrivate::startAnimationsIfNotSuspended(Document* document)
 {
-    if (!isSuspended())
+    if (!isSuspended() || allowsNewAnimationsWhileSuspended())
         resumeAnimationsForDocument(document);
 }
 
+void AnimationControllerPrivate::setAllowsNewAnimationsWhileSuspended(bool allowed)
+{
+    m_allowsNewAnimationsWhileSuspended = allowed;
+}
+
 bool AnimationControllerPrivate::pauseAnimationAtTime(RenderObject* renderer, const AtomicString& name, double t)
 {
     if (!renderer)
@@ -603,6 +609,16 @@
     m_data->resumeAnimations();
 }
 
+bool AnimationController::allowsNewAnimationsWhileSuspended() const
+{
+    return m_data->allowsNewAnimationsWhileSuspended();
+}
+
+void AnimationController::setAllowsNewAnimationsWhileSuspended(bool allowed)
+{
+    m_data->setAllowsNewAnimationsWhileSuspended(allowed);
+}
+
 #if ENABLE(REQUEST_ANIMATION_FRAME)
 void AnimationController::serviceAnimations()
 {

Modified: trunk/Source/WebCore/page/animation/AnimationController.h (153395 => 153396)


--- trunk/Source/WebCore/page/animation/AnimationController.h	2013-07-27 00:24:08 UTC (rev 153395)
+++ trunk/Source/WebCore/page/animation/AnimationController.h	2013-07-27 00:57:31 UTC (rev 153396)
@@ -76,6 +76,9 @@
 
     void beginAnimationUpdate();
     void endAnimationUpdate();
+
+    bool allowsNewAnimationsWhileSuspended() const;
+    void setAllowsNewAnimationsWhileSuspended(bool);
     
     static bool supportsAcceleratedAnimationOfProperty(CSSPropertyID);
 

Modified: trunk/Source/WebCore/page/animation/AnimationControllerPrivate.h (153395 => 153396)


--- trunk/Source/WebCore/page/animation/AnimationControllerPrivate.h	2013-07-27 00:24:08 UTC (rev 153395)
+++ trunk/Source/WebCore/page/animation/AnimationControllerPrivate.h	2013-07-27 00:57:31 UTC (rev 153396)
@@ -109,7 +109,10 @@
     void animationWillBeRemoved(AnimationBase*);
 
     void updateAnimationTimerForRenderer(RenderObject*);
-    
+
+    bool allowsNewAnimationsWhileSuspended() const { return m_allowsNewAnimationsWhileSuspended; }
+    void setAllowsNewAnimationsWhileSuspended(bool);
+
 private:
     void animationTimerFired(Timer<AnimationControllerPrivate>*);
 
@@ -142,6 +145,11 @@
     WaitingAnimationsSet m_animationsWaitingForStartTimeResponse;
     bool m_waitingForAsyncStartNotification;
     bool m_isSuspended;
+
+    // Used to flag whether we should revert to previous buggy
+    // behavior of allowing new transitions and animations to
+    // run even when this object is suspended.
+    bool m_allowsNewAnimationsWhileSuspended;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/page/animation/CompositeAnimation.cpp (153395 => 153396)


--- trunk/Source/WebCore/page/animation/CompositeAnimation.cpp	2013-07-27 00:24:08 UTC (rev 153395)
+++ trunk/Source/WebCore/page/animation/CompositeAnimation.cpp	2013-07-27 00:57:31 UTC (rev 153396)
@@ -44,7 +44,7 @@
 CompositeAnimation::CompositeAnimation(AnimationControllerPrivate* animationController)
     : m_animationController(animationController)
 {
-    m_suspended = animationController->isSuspended();
+    m_suspended = animationController->isSuspended() && !animationController->allowsNewAnimationsWhileSuspended();
 }
 
 CompositeAnimation::~CompositeAnimation()

Modified: trunk/Source/WebKit/mac/ChangeLog (153395 => 153396)


--- trunk/Source/WebKit/mac/ChangeLog	2013-07-27 00:24:08 UTC (rev 153395)
+++ trunk/Source/WebKit/mac/ChangeLog	2013-07-27 00:57:31 UTC (rev 153396)
@@ -1,3 +1,24 @@
+2013-07-26  Dean Jackson  <[email protected]>
+
+        Allow new transitions to run even when controller is suspended
+        https://bugs.webkit.org/show_bug.cgi?id=119171
+        <rdar://problem/14511404>
+
+        Reviewed by Simon Fraser.
+
+        Expose a new SPI on WebView that triggers the (buggy) old behaviour
+        for animations, such that any newly created animations will start even
+        when the document is supposedly suspended. It turns out that client content was
+        unknowingly relying on this behaviour - e.g. suspending a view, loading a
+        bunch of new content, bringing the view on screen and then unsuspending. In this
+        situation, we were not running CSS transitions, because the page was suspended.
+        However, JS was still triggering them, and content was expecting a transitionEnd event.
+
+        * WebView/WebView.mm:
+        (-[WebView allowsNewCSSAnimationsWhileSuspended]): Calls into AnimationController.
+        (-[WebView setAllowsNewCSSAnimationsWhileSuspended:]): Ditto.
+        * WebView/WebViewPrivate.h: New methods listed above.
+
 2013-07-26  Anders Carlsson  <[email protected]>
 
         Add another method that we need to set aside subviews for

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (153395 => 153396)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2013-07-27 00:24:08 UTC (rev 153395)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2013-07-27 00:57:31 UTC (rev 153396)
@@ -2790,6 +2790,22 @@
     pageGroup->removeAllUserContent();
 }
 
+- (BOOL)allowsNewCSSAnimationsWhileSuspended
+{
+    Frame* frame = core([self mainFrame]);
+    if (frame)
+        return frame->animation()->allowsNewAnimationsWhileSuspended();
+
+    return false;
+}
+
+- (void)setAllowsNewCSSAnimationsWhileSuspended:(BOOL)allowed
+{
+    Frame* frame = core([self mainFrame]);
+    if (frame)
+        frame->animation()->setAllowsNewAnimationsWhileSuspended(allowed);
+}
+
 - (BOOL)cssAnimationsSuspended
 {
     // should ask the page!

Modified: trunk/Source/WebKit/mac/WebView/WebViewPrivate.h (153395 => 153396)


--- trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2013-07-27 00:24:08 UTC (rev 153395)
+++ trunk/Source/WebKit/mac/WebView/WebViewPrivate.h	2013-07-27 00:57:31 UTC (rev 153396)
@@ -564,6 +564,14 @@
 */
 - (void)setCSSAnimationsSuspended:(BOOL)suspended;
 
+/*
+    SPI to revert back to buggy behavior that would allow new transitions
+    and animations to run even when the view is suspended (e.g. loading a
+    new document).
+*/
+- (BOOL)allowsNewCSSAnimationsWhileSuspended;
+- (void)setAllowsNewCSSAnimationsWhileSuspended:(BOOL)allowed;
+
 + (void)_setDomainRelaxationForbidden:(BOOL)forbidden forURLScheme:(NSString *)scheme;
 + (void)_registerURLSchemeAsSecure:(NSString *)scheme;
 + (void)_registerURLSchemeAsAllowingLocalStorageAccessInPrivateBrowsing:(NSString *)scheme;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to