Reviewers: rdayal,

Description:
Preparing for an upcoming API change to requestAnimationFrame where
browsers will pass a sub-millisecond timer instead of a Date.now()
timestamp.  This can cause havoc with animations and has already popped
up in the Chrome dev channel (but was reverted). We now ignore the
native callback argument and just grab the current time from javascript.

http://gwt-code-reviews.appspot.com/1702803/


Please review this at http://gwt-code-reviews.appspot.com/1715803/

Affected files:
M user/src/com/google/gwt/animation/client/AnimationSchedulerImplMozilla.java M user/src/com/google/gwt/animation/client/AnimationSchedulerImplWebkit.java


Index: user/src/com/google/gwt/animation/client/AnimationSchedulerImplMozilla.java
===================================================================
--- user/src/com/google/gwt/animation/client/AnimationSchedulerImplMozilla.java (revision 10982) +++ user/src/com/google/gwt/animation/client/AnimationSchedulerImplMozilla.java (working copy)
@@ -64,9 +64,12 @@
    */
   private native void requestAnimationFrameImpl(AnimationCallback callback,
       AnimationHandleImpl handle) /*-{
-    var wrapper = $entry(function(time) {
+    var wrapper = $entry(function() {
if (!hand...@com.google.gwt.animation.client.AnimationSchedulerImplMozilla.AnimationHandleImpl::canceled) { - callba...@com.google.gwt.animation.client.AnimationScheduler.AnimationCallback::execute(D)(time); + // Older versions of firefox pass the current timestamp, but newer versions pass a
+        // high resolution timer. We normalize on the current timestamp.
+ var now = @com.google.gwt.core.client.Duration::currentTimeMillis()(); + callba...@com.google.gwt.animation.client.AnimationScheduler.AnimationCallback::execute(D)(now);
       }
     });
     $wnd.mozRequestAnimationFrame(wrapper);
Index: user/src/com/google/gwt/animation/client/AnimationSchedulerImplWebkit.java
===================================================================
--- user/src/com/google/gwt/animation/client/AnimationSchedulerImplWebkit.java (revision 10982) +++ user/src/com/google/gwt/animation/client/AnimationSchedulerImplWebkit.java (working copy)
@@ -63,10 +63,11 @@

private native double requestAnimationFrameImpl(AnimationCallback callback, Element element) /*-{
     var _callback = callback;
-    var wrapper = $entry(function(time) {
-      // Chrome 10 does not pass the 'time' argument, so we fake it.
- time = time || @com.google.gwt.core.client.Duration::currentTimeMillis()(); - _callba...@com.google.gwt.animation.client.AnimationScheduler.AnimationCallback::execute(D)(time);
+    var wrapper = $entry(function() {
+ // Older versions of Chrome pass the current timestamp, but newer versions pass a
+      // high resolution timer. We normalize on the current timestamp.
+ var now = @com.google.gwt.core.client.Duration::currentTimeMillis()(); + _callba...@com.google.gwt.animation.client.AnimationScheduler.AnimationCallback::execute(D)(now);
     });
     return $wnd.webkitRequestAnimationFrame(wrapper, element);
   }-*/;


--
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to