@@ -0,0 +1,2696 @@
+/*%0A * Copyright 2011 Google Inc.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22); you may not%0A * use this file except in compliance with the License. You may obtain a copy of%0A * the License at%0A *%0A * http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS, WITHOUT%0A * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the%0A * License for the specific language governing permissions and limitations under%0A * the License.%0A */%0Apackage com.google.gwt.animation.client;%0A%0Aimport com.google.gwt.dom.client.Element;%0A%0A/**%0A * Implementation using %3Ccode%3EwebkitRequestAnimationFrame%3C/code%3E and%0A * %3Ccode%3EwebkitCancelRequestAnimationFrame%3C/code%3E.%0A *%0A * @see %3Ca%0A *      href=%22http://www.chromium.org/developers/web-platform-status#TOC-requestAnimationFrame%22%3E%0A *      Chromium Web Platform Status%3C/a%3E%0A * @see %3Ca href=%22http://webstuff.nfshost.com/anim-timing/Overview.html%22%3E webkit%0A *      draft spec%3C/a%3E%0A */%0Aclass AnimationSchedulerImplWebkit extends AnimationSchedulerImpl %7B%0A%09/**%0A%09 * Webkit implementation of %7B@link AnimationScheduler.AnimationHandle%7D.%0A%09 * Webkit provides the request ID as a double.%0A%09 */%0A%09private class AnimationHandleImpl extends AnimationHandle %7B%0A%09%09private final double requestId;%0A%0A%09%09public AnimationHandleImpl(double requestId) %7B%0A%09%09%09this.requestId = requestId;%0A%09%09%7D%0A%0A%09%09@Override%0A%09%09public void cancel() %7B%0A%09%09%09cancelAnimationFrameImpl(requestId);%0A%09%09%7D%0A%09%7D%0A%0A%09@Override%0A%09public AnimationHandle requestAnimationFrame(AnimationCallback callback, Element element) %7B%0A%09%09double requestId = requestAnimationFrameImpl(callback, element);%0A%09%09return new AnimationHandleImpl(requestId);%0A%09%7D%0A%0A%09@Override%0A%09protected native boolean isNativelySupported() /*-%7B%0A%09%09return !!($wnd.webkitRequestAnimationFrame && $wnd.webkitCancelRequestAnimationFrame);%0A%09%7D-*/;%0A%0A%09private native void cancelAnimationFrameImpl(double requestId) /*-%7B%0A%09%09$wnd.webkitCancelRequestAnimationFrame(requestId);%0A%09%7D-*/;%0A%0A%09private native double requestAnimationFrameImpl(AnimationCallback callback, Element element) /*-%7B%0A%09%09var thiss = this;%0A%09%09var _callback = callback;%0A%09%09var wrapper = $entry(function(time) %7B%0A%09%09%09if (time %3C 1e12) %7B%0A%09%09%09%09// .. high resolution timer%0A%09%09%09%09time = @com.google.gwt.core.client.Duration::currentTimeMillis()();%0A%09%09%09%7D else %7B%0A%09%09%09%09// Chrome 10 does not pass the 'time' argument, so we fake it.%0A%09%09%09%09time = time%0A%09%09%09%09%09%09%7C%7C @com.google.gwt.core.client.Duration::currentTimeMillis()();%0A%09%09%09%7D%0A%09%09%09_callback.@com.google.gwt.animation.client.AnimationScheduler.AnimationCallback::execute(D)(time);%0A%09%09%7D);%0A%09%09return $wnd.webkitRequestAnimationFrame(wrapper, element);%0A%09%7D-*/;%0A%7D%0A

normalize time for requestanimationframe function in chrome issue YPUB-4858