http://gwt-code-reviews.appspot.com/1446812/diff/3002/user/src/com/google/gwt/animation/client/AnimationSchedulerImplMozilla.java
File
user/src/com/google/gwt/animation/client/AnimationSchedulerImplMozilla.java
(right):

http://gwt-code-reviews.appspot.com/1446812/diff/3002/user/src/com/google/gwt/animation/client/AnimationSchedulerImplMozilla.java#newcode75
user/src/com/google/gwt/animation/client/AnimationSchedulerImplMozilla.java:75:
handle.canceled = false;
On 2011/05/27 13:07:01, jlabanca wrote:
On 2011/05/27 12:11:44, tbroyer wrote:
> Hox about constructing an AnimationHandleImpl object in
requestAnimationFrame
> and passing it as an argument here, given that it's always
constructed? (or
> construct it here in the JSNI if you prefer)

If we pass AnimationHandleImpl as an argument, then we need another
JSNI block
to create the JavaScriptObject that it contains.  Or, we need a setter
to set
the JavaScriptObject.  Personally, I like the way its implemented now
where
requestAnimationFrameImpl() returns a JSO handle, and the Java code
wraps it in
a logical handle.

I was actually suggesting using something like:
class AnimationHandleImpl implements AnimationHandle {
  private boolean canceled;

  @Override
  public void cancel() { this.canceled = true; }
}

and then in the 'wrapper' function:
  if ([email protected]::canceled) { ...

http://gwt-code-reviews.appspot.com/1446812/diff/3002/user/src/com/google/gwt/animation/client/testing/StubAnimationSchedulerImpl.java
File
user/src/com/google/gwt/animation/client/testing/StubAnimationSchedulerImpl.java
(right):

http://gwt-code-reviews.appspot.com/1446812/diff/3002/user/src/com/google/gwt/animation/client/testing/StubAnimationSchedulerImpl.java#newcode29
user/src/com/google/gwt/animation/client/testing/StubAnimationSchedulerImpl.java:29:
public class StubAnimationSchedulerImpl extends AnimationSchedulerImpl {
On 2011/05/27 13:07:01, jlabanca wrote:
On 2011/05/27 12:11:44, tbroyer wrote:
> Should IMO extend AnimationScheduler to bypass the
AnimationSchedulerImpl
clinit
> and be usable in a "plain JVM" without requiring
GWTMockUtilities.disarm().
>
> AnimationSchedulerImpl could then be tweaked a bit to allow the
GWT.create()
to
> return something that doesn't extend AnimationSchedulerImpl (I'd
then also
> change it to GWT.create(AnimationScheduler.class) rather than
> AnimationSchedulerImpl.class), so that StubAnimationSchedulerImpl
could still
be
> used with deferred-binding as in the unit tests here.
>
> But even better would be, IMO, to allow somehow "injecting" the
> AnimationScheduler actual implementation into the Animation class,
so that
> AnimationTest could run in a plain-JVM instead of being a
GWTTestCase. It
could
> be as simple as adding a protected getAnimationScheduler to the
Animation
class
> that defaults to returning AnimationScheduler.get(), and overriding
it in the
> TestAnimation to return the StubAnimationScheduler.

Done.

I couldn't find a clean way to implement the static initializer in
AnimationSchedulerImpl if GWT.create() returns an AnimationScheduler,
because we
need to check if the impl class natively supports
requestAnimationFrame.
However, an instanceof check works, and its only called once.

I for one find the instanceof check clean, if you ask me; and I believe
it'll be optimized out.

http://gwt-code-reviews.appspot.com/1446812/diff/3002/user/test/com/google/gwt/animation/AnimationTest.gwt.xml
File user/test/com/google/gwt/animation/AnimationTest.gwt.xml (right):

http://gwt-code-reviews.appspot.com/1446812/diff/3002/user/test/com/google/gwt/animation/AnimationTest.gwt.xml#newcode25
user/test/com/google/gwt/animation/AnimationTest.gwt.xml:25:
<replace-with
class="com.google.gwt.animation.client.testing.StubAnimationSchedulerImpl">
On 2011/05/27 13:07:01, jlabanca wrote:
On 2011/05/27 12:11:44, tbroyer wrote:
> Would probably be better to somehow "inject" a
StubAnimationScheduler into
> Animation, rather than "hack" AnimationScheduler.

Agreed if we had an injection framework like gin built in to GWT.
Deferred
bindings are the closest thing we have for now.

How about my proposal for "protected AnimationScheduler
getAnimationScheduler() { return AnimationScheduler.get(); }" in
Animation?
(which you'd override in TestAnimation in the AnimationTest)

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

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

Reply via email to