Title: [139635] branches/chromium/1364
Revision
139635
Author
simon...@chromium.org
Date
2013-01-14 11:45:56 -0800 (Mon, 14 Jan 2013)

Log Message

Merge 139509
> Restore old semantics to webkitRequestAnimationFrame callbacks
> https://bugs.webkit.org/show_bug.cgi?id=106697
> 
> Reviewed by James Robinson.
> 
> Source/WebCore:
> 
> Sites that use GWT <= 2.4 are buggy and rely on Date.now()-like callback values.
> We'll restore that behavior to the prefixed version of webkitRequestAnimationFrame.
> requestAnimationFrame will continue to follow the spec.
> 
> Test: fast/animation/request-animation-frame-prefix.html
> 
> * dom/RequestAnimationFrameCallback.h:
> (RequestAnimationFrameCallback):
> * dom/ScriptedAnimationController.cpp:
> (WebCore::ScriptedAnimationController::serviceScriptedAnimations):
> * page/DOMWindow.cpp:
> (WebCore::DOMWindow::requestAnimationFrame):
> (WebCore):
> (WebCore::DOMWindow::webkitRequestAnimationFrame):
> * page/DOMWindow.h:
> (DOMWindow):
> * page/DOMWindow.idl:
> 
> LayoutTests:
> 
> * fast/animation/request-animation-frame-prefix-expected.txt: Added.
> * fast/animation/request-animation-frame-prefix.html: Added.
> * fast/animation/script-tests/request-animation-frame-prefix.js: Added.
> (busyWait):
> (window.webkitRequestAnimationFrame):
> 

TBR=simon...@chromium.org
Review URL: https://codereview.chromium.org/11876026

Modified Paths

Added Paths

Diff

Copied: branches/chromium/1364/LayoutTests/fast/animation/request-animation-frame-prefix-expected.txt (from rev 139509, trunk/LayoutTests/fast/animation/request-animation-frame-prefix-expected.txt) (0 => 139635)


--- branches/chromium/1364/LayoutTests/fast/animation/request-animation-frame-prefix-expected.txt	                        (rev 0)
+++ branches/chromium/1364/LayoutTests/fast/animation/request-animation-frame-prefix-expected.txt	2013-01-14 19:45:56 UTC (rev 139635)
@@ -0,0 +1,9 @@
+Tests the timestamps provided to prefixed webkitRequestAnimationFrame callbacks
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS legacyFirstTimestamp is >= firstTimestamp
+PASS legacySecondTimestamp is >= secondTimestamp
+PASS deltaError < 0.001 is true
+

Copied: branches/chromium/1364/LayoutTests/fast/animation/request-animation-frame-prefix.html (from rev 139509, trunk/LayoutTests/fast/animation/request-animation-frame-prefix.html) (0 => 139635)


--- branches/chromium/1364/LayoutTests/fast/animation/request-animation-frame-prefix.html	                        (rev 0)
+++ branches/chromium/1364/LayoutTests/fast/animation/request-animation-frame-prefix.html	2013-01-14 19:45:56 UTC (rev 139635)
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<span id="e"></span>
+<span id="f"></span>
+<script src=""
+</body>
+</html>

Copied: branches/chromium/1364/LayoutTests/fast/animation/script-tests/request-animation-frame-prefix.js (from rev 139509, trunk/LayoutTests/fast/animation/script-tests/request-animation-frame-prefix.js) (0 => 139635)


--- branches/chromium/1364/LayoutTests/fast/animation/script-tests/request-animation-frame-prefix.js	                        (rev 0)
+++ branches/chromium/1364/LayoutTests/fast/animation/script-tests/request-animation-frame-prefix.js	2013-01-14 19:45:56 UTC (rev 139635)
@@ -0,0 +1,46 @@
+description("Tests the timestamps provided to prefixed webkitRequestAnimationFrame callbacks");
+
+var firstTimestamp = undefined;
+var secondTimestamp = undefined;
+var legacyFirstTimestamp = undefined;
+var legacySecondTimestamp = undefined;
+var deltaError = undefined;
+
+function busyWait(millis) {
+    var start = Date.now();
+    while (Date.now()-start < millis) {}
+}
+
+window.requestAnimationFrame(function(timestamp) {
+    firstTimestamp = timestamp;
+});
+
+window.webkitRequestAnimationFrame(function(timestamp) {
+    legacyFirstTimestamp = timestamp;
+
+    window.requestAnimationFrame(function(timestamp) {
+        secondTimestamp = timestamp;
+    });
+
+    window.webkitRequestAnimationFrame(function(timestamp) {
+        legacySecondTimestamp = timestamp;
+
+        shouldBeGreaterThanOrEqual("legacyFirstTimestamp", "firstTimestamp");
+        shouldBeGreaterThanOrEqual("legacySecondTimestamp", "secondTimestamp");
+        deltaError = Math.abs((legacySecondTimestamp - legacyFirstTimestamp) - (secondTimestamp - firstTimestamp));
+        shouldBeTrue("deltaError < 0.001");
+        testRunner.notifyDone();
+    });
+
+    busyWait(10);
+    if (window.testRunner)
+        testRunner.display();
+});
+
+if (window.testRunner)
+    window.setTimeout(function() {
+        testRunner.display();
+    });
+
+if (window.testRunner)
+    testRunner.waitUntilDone();

Modified: branches/chromium/1364/Source/WebCore/dom/RequestAnimationFrameCallback.h (139634 => 139635)


--- branches/chromium/1364/Source/WebCore/dom/RequestAnimationFrameCallback.h	2013-01-14 19:43:42 UTC (rev 139634)
+++ branches/chromium/1364/Source/WebCore/dom/RequestAnimationFrameCallback.h	2013-01-14 19:45:56 UTC (rev 139635)
@@ -42,6 +42,7 @@
 
     int m_id;
     bool m_firedOrCancelled;
+    bool m_useLegacyTimeBase;
 };
 
 }

Modified: branches/chromium/1364/Source/WebCore/dom/ScriptedAnimationController.cpp (139634 => 139635)


--- branches/chromium/1364/Source/WebCore/dom/ScriptedAnimationController.cpp	2013-01-14 19:43:42 UTC (rev 139634)
+++ branches/chromium/1364/Source/WebCore/dom/ScriptedAnimationController.cpp	2013-01-14 19:45:56 UTC (rev 139635)
@@ -114,6 +114,7 @@
         return;
 
     double highResNowMs = 1000.0 * m_document->loader()->timing()->monotonicTimeToZeroBasedDocumentTime(monotonicTimeNow);
+    double legacyHighResNowMs = 1000.0 * m_document->loader()->timing()->monotonicTimeToPseudoWallTime(monotonicTimeNow);
 
     // First, generate a list of callbacks to consider.  Callbacks registered from this point
     // on are considered only for the "next" frame, not this one.
@@ -128,7 +129,10 @@
         if (!callback->m_firedOrCancelled) {
             callback->m_firedOrCancelled = true;
             InspectorInstrumentationCookie cookie = InspectorInstrumentation::willFireAnimationFrame(m_document, callback->m_id);
-            callback->handleEvent(highResNowMs);
+            if (callback->m_useLegacyTimeBase)
+                callback->handleEvent(legacyHighResNowMs);
+            else
+                callback->handleEvent(highResNowMs);
             InspectorInstrumentation::didFireAnimationFrame(cookie);
         }
     }

Modified: branches/chromium/1364/Source/WebCore/page/DOMWindow.cpp (139634 => 139635)


--- branches/chromium/1364/Source/WebCore/page/DOMWindow.cpp	2013-01-14 19:43:42 UTC (rev 139634)
+++ branches/chromium/1364/Source/WebCore/page/DOMWindow.cpp	2013-01-14 19:45:56 UTC (rev 139635)
@@ -1549,11 +1549,20 @@
 #if ENABLE(REQUEST_ANIMATION_FRAME)
 int DOMWindow::requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback)
 {
+    callback->m_useLegacyTimeBase = false;
     if (Document* d = document())
         return d->requestAnimationFrame(callback);
     return 0;
 }
 
+int DOMWindow::webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback> callback)
+{
+    callback->m_useLegacyTimeBase = true;
+    if (Document* d = document())
+        return d->requestAnimationFrame(callback);
+    return 0;
+}
+
 void DOMWindow::cancelAnimationFrame(int id)
 {
     if (Document* d = document())

Modified: branches/chromium/1364/Source/WebCore/page/DOMWindow.h (139634 => 139635)


--- branches/chromium/1364/Source/WebCore/page/DOMWindow.h	2013-01-14 19:43:42 UTC (rev 139634)
+++ branches/chromium/1364/Source/WebCore/page/DOMWindow.h	2013-01-14 19:45:56 UTC (rev 139635)
@@ -264,6 +264,7 @@
         // WebKit animation extensions
 #if ENABLE(REQUEST_ANIMATION_FRAME)
         int requestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
+        int webkitRequestAnimationFrame(PassRefPtr<RequestAnimationFrameCallback>);
         void cancelAnimationFrame(int id);
 #endif
 

Modified: branches/chromium/1364/Source/WebCore/page/DOMWindow.idl (139634 => 139635)


--- branches/chromium/1364/Source/WebCore/page/DOMWindow.idl	2013-01-14 19:43:42 UTC (rev 139634)
+++ branches/chromium/1364/Source/WebCore/page/DOMWindow.idl	2013-01-14 19:45:56 UTC (rev 139635)
@@ -216,7 +216,7 @@
 #if defined(ENABLE_REQUEST_ANIMATION_FRAME) && ENABLE_REQUEST_ANIMATION_FRAME
     [V8MeasureAs=UnprefixedRequestAnimationFrame] long requestAnimationFrame(in [Callback] RequestAnimationFrameCallback callback);
     void cancelAnimationFrame(in long id);
-    [ImplementedAs=requestAnimationFrame, V8MeasureAs=PrefixedRequestAnimationFrame] long webkitRequestAnimationFrame(in [Callback] RequestAnimationFrameCallback callback);
+    [V8MeasureAs=PrefixedRequestAnimationFrame] long webkitRequestAnimationFrame(in [Callback] RequestAnimationFrameCallback callback);
     [ImplementedAs=cancelAnimationFrame] void webkitCancelAnimationFrame(in long id);
     [ImplementedAs=cancelAnimationFrame] void webkitCancelRequestAnimationFrame(in long id); // This is a deprecated alias for webkitCancelAnimationFrame(). Remove this when removing vendor prefix.
 #endif
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to