Revision: 10028
Author:   gwt.mirror...@gmail.com
Date:     Tue Apr 19 08:29:47 2011
Log:      Cherry picking r9887

http://code.google.com/p/google-web-toolkit/source/detail?r=10028

Added:
/releases/2.3/user/src/com/google/gwt/event/dom/client/CanPlayThroughEvent.java /releases/2.3/user/src/com/google/gwt/event/dom/client/CanPlayThroughHandler.java
 /releases/2.3/user/src/com/google/gwt/event/dom/client/EndedEvent.java
 /releases/2.3/user/src/com/google/gwt/event/dom/client/EndedHandler.java
/releases/2.3/user/src/com/google/gwt/event/dom/client/HasAllMediaHandlers.java /releases/2.3/user/src/com/google/gwt/event/dom/client/HasCanPlayThroughHandlers.java /releases/2.3/user/src/com/google/gwt/event/dom/client/HasEndedHandlers.java /releases/2.3/user/src/com/google/gwt/event/dom/client/HasProgressHandlers.java
 /releases/2.3/user/src/com/google/gwt/event/dom/client/ProgressEvent.java
 /releases/2.3/user/src/com/google/gwt/event/dom/client/ProgressHandler.java
 /releases/2.3/user/test/com/google/gwt/user/client/MediaEventsSinkTest.java
Modified:
 /releases/2.3/dev/core/src/com/google/gwt/dev/js/ast/JsRootScope.java
 /releases/2.3/user/src/com/google/gwt/user/client/DOM.java
 /releases/2.3/user/src/com/google/gwt/user/client/Event.java
 /releases/2.3/user/src/com/google/gwt/user/client/impl/DOMImpl.java
 /releases/2.3/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java
 /releases/2.3/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java
 /releases/2.3/user/src/com/google/gwt/user/client/ui/UIObject.java
 /releases/2.3/user/src/com/google/gwt/user/client/ui/Widget.java

=======================================
--- /dev/null
+++ /releases/2.3/user/src/com/google/gwt/event/dom/client/CanPlayThroughEvent.java Tue Apr 19 08:29:47 2011
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.event.dom.client;
+
+/**
+ * Represents a native media can play through event.
+ *
+ * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+ * and is subject to change.
+ * </span>
+ * </p>
+ */
+public class CanPlayThroughEvent extends DomEvent<CanPlayThroughHandler> {
+
+  /**
+   * Event type for media can play through events. Represents the meta-data
+   * associated with this event.
+   */
+  private static final Type<CanPlayThroughHandler> TYPE = new Type<
+      CanPlayThroughHandler>("canplaythrough", new CanPlayThroughEvent());
+
+  /**
+   * Gets the event type associated with media can play through events.
+   *
+   * @return the handler type
+   */
+  public static Type<CanPlayThroughHandler> getType() {
+    return TYPE;
+  }
+
+  /**
+   * Protected constructor, use {@link
+   * DomEvent#fireNativeEvent(com.google.gwt.dom.client.NativeEvent,
+ * com.google.gwt.event.shared.HasHandlers)} to fire media can play through
+   * events.
+   */
+  protected CanPlayThroughEvent() {
+  }
+
+  @Override
+  public final Type<CanPlayThroughHandler> getAssociatedType() {
+    return TYPE;
+  }
+
+
+  @Override
+  protected void dispatch(CanPlayThroughHandler handler) {
+    handler.onCanPlayThrough(this);
+  }
+}
=======================================
--- /dev/null
+++ /releases/2.3/user/src/com/google/gwt/event/dom/client/CanPlayThroughHandler.java Tue Apr 19 08:29:47 2011
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.event.dom.client;
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * Handler interface for {@link CanPlayThroughEvent} events.
+ *
+ * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+ * and is subject to change.
+ * </span>
+ * </p>
+ */
+public interface CanPlayThroughHandler extends EventHandler {
+
+  /**
+   * Called when CanPlayThroughEvent is fired.
+   *
+   * @param event the {@link CanPlayThroughEvent} that was fired
+   */
+  void onCanPlayThrough(CanPlayThroughEvent event);
+}
=======================================
--- /dev/null
+++ /releases/2.3/user/src/com/google/gwt/event/dom/client/EndedEvent.java Tue Apr 19 08:29:47 2011
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.event.dom.client;
+
+/**
+ * Represents a native media ended event.
+ *
+ * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+ * and is subject to change.
+ * </span>
+ * </p>
+ */
+public class EndedEvent extends DomEvent<EndedHandler> {
+
+  /**
+ * Event type for media ended events. Represents the meta-data associated with
+   * this event.
+   */
+  private static final Type<EndedHandler> TYPE = new Type<
+      EndedHandler>("ended", new EndedEvent());
+
+  /**
+   * Gets the event type associated with media ended events.
+   *
+   * @return the handler type
+   */
+  public static Type<EndedHandler> getType() {
+    return TYPE;
+  }
+
+  /**
+   * Protected constructor, use {@link
+   * DomEvent#fireNativeEvent(com.google.gwt.dom.client.NativeEvent,
+   * com.google.gwt.event.shared.HasHandlers)} to fire media ended events.
+   */
+  protected EndedEvent() {
+  }
+
+  @Override
+  public final Type<EndedHandler> getAssociatedType() {
+    return TYPE;
+  }
+
+
+  @Override
+  protected void dispatch(EndedHandler handler) {
+    handler.onEnded(this);
+  }
+}
=======================================
--- /dev/null
+++ /releases/2.3/user/src/com/google/gwt/event/dom/client/EndedHandler.java Tue Apr 19 08:29:47 2011
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.event.dom.client;
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * Handler interface for {@link EndedEvent} events.
+ *
+ * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+ * and is subject to change.
+ * </span>
+ * </p>
+ */
+public interface EndedHandler extends EventHandler {
+
+  /**
+   * Called when EndedEvent is fired.
+   *
+   * @param event the {@link EndedEvent} that was fired
+   */
+  void onEnded(EndedEvent event);
+}
=======================================
--- /dev/null
+++ /releases/2.3/user/src/com/google/gwt/event/dom/client/HasAllMediaHandlers.java Tue Apr 19 08:29:47 2011
@@ -0,0 +1,31 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.event.dom.client;
+
+/**
+ * This is a convenience interface that includes all media handlers defined by
+ * the core GWT system.
+ *
+ * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+ * and is subject to change.
+ * </span>
+ * </p>
+ */
+public interface HasAllMediaHandlers extends HasEndedHandlers,
+    HasProgressHandlers, HasCanPlayThroughHandlers {
+}
=======================================
--- /dev/null
+++ /releases/2.3/user/src/com/google/gwt/event/dom/client/HasCanPlayThroughHandlers.java Tue Apr 19 08:29:47 2011
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.event.dom.client;
+
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.HasHandlers;
+
+/**
+ * A widget that implements this interface provides registration for
+ * {@link CanPlayThroughHandler} instances.
+ *
+ * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+ * and is subject to change.
+ * </span>
+ * </p>
+ */
+public interface HasCanPlayThroughHandlers extends HasHandlers {
+  /**
+   * Adds a {@link CanPlayThroughEvent} handler.
+   *
+   * @param handler the media CanPlayThrough handler
+   * @return {@link HandlerRegistration} used to remove this handler
+   */
+ HandlerRegistration addCanPlayThroughHandler(CanPlayThroughHandler handler);
+}
=======================================
--- /dev/null
+++ /releases/2.3/user/src/com/google/gwt/event/dom/client/HasEndedHandlers.java Tue Apr 19 08:29:47 2011
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.event.dom.client;
+
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.HasHandlers;
+
+/**
+ * A widget that implements this interface provides registration for
+ * {@link EndedHandler} instances.
+ *
+ * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+ * and is subject to change.
+ * </span>
+ * </p>
+ */
+public interface HasEndedHandlers extends HasHandlers {
+  /**
+   * Adds a {@link EndedEvent} handler.
+   *
+   * @param handler the media ended handler
+   * @return {@link HandlerRegistration} used to remove this handler
+   */
+  HandlerRegistration addEndedHandler(EndedHandler handler);
+}
=======================================
--- /dev/null
+++ /releases/2.3/user/src/com/google/gwt/event/dom/client/HasProgressHandlers.java Tue Apr 19 08:29:47 2011
@@ -0,0 +1,39 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.event.dom.client;
+
+import com.google.gwt.event.shared.HandlerRegistration;
+import com.google.gwt.event.shared.HasHandlers;
+
+/**
+ * A widget that implements this interface provides registration for
+ * {@link ProgressHandler} instances.
+ *
+ * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+ * and is subject to change.
+ * </span>
+ * </p>
+ */
+public interface HasProgressHandlers extends HasHandlers {
+  /**
+   * Adds a {@link ProgressEvent} handler.
+   *
+   * @param handler the media progress handler
+   * @return {@link HandlerRegistration} used to remove this handler
+   */
+  HandlerRegistration addProgressHandler(ProgressHandler handler);
+}
=======================================
--- /dev/null
+++ /releases/2.3/user/src/com/google/gwt/event/dom/client/ProgressEvent.java Tue Apr 19 08:29:47 2011
@@ -0,0 +1,63 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.event.dom.client;
+
+/**
+ * Represents a native media progress event.
+ *
+ * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+ * and is subject to change.
+ * </span>
+ * </p>
+ */
+public class ProgressEvent extends DomEvent<ProgressHandler> {
+
+  /**
+ * Event type for media progress events. Represents the meta-data associated
+   * with this event.
+   */
+  private static final Type<ProgressHandler> TYPE = new Type<
+  ProgressHandler>("progress", new ProgressEvent());
+
+  /**
+   * Gets the event type associated with media progress events.
+   *
+   * @return the handler type
+   */
+  public static Type<ProgressHandler> getType() {
+    return TYPE;
+  }
+
+  /**
+   * Protected constructor, use {@link
+   * DomEvent#fireNativeEvent(com.google.gwt.dom.client.NativeEvent,
+ * com.google.gwt.event.shared.HasHandlers)} to fire media progress events.
+   */
+  protected ProgressEvent() {
+  }
+
+  @Override
+  public final Type<ProgressHandler> getAssociatedType() {
+    return TYPE;
+  }
+
+
+  @Override
+  protected void dispatch(ProgressHandler handler) {
+    handler.onProgress(this);
+  }
+}
=======================================
--- /dev/null
+++ /releases/2.3/user/src/com/google/gwt/event/dom/client/ProgressHandler.java Tue Apr 19 08:29:47 2011
@@ -0,0 +1,37 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+package com.google.gwt.event.dom.client;
+
+import com.google.gwt.event.shared.EventHandler;
+
+/**
+ * Handler interface for {@link ProgressEvent} events.
+ *
+ * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+ * and is subject to change.
+ * </span>
+ * </p>
+ */
+public interface ProgressHandler extends EventHandler {
+
+  /**
+   * Called when ProgressEvent is fired.
+   *
+   * @param event the {@link ProgressEvent} that was fired
+   */
+  void onProgress(ProgressEvent event);
+}
=======================================
--- /dev/null
+++ /releases/2.3/user/test/com/google/gwt/user/client/MediaEventsSinkTest.java Tue Apr 19 08:29:47 2011
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2011 Google Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not + * use this file except in compliance with the License. You may obtain a copy of
+ * the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+ * License for the specific language governing permissions and limitations under
+ * the License.
+ */
+
+package com.google.gwt.user.client;
+
+import com.google.gwt.event.dom.client.CanPlayThroughEvent;
+import com.google.gwt.event.dom.client.CanPlayThroughHandler;
+import com.google.gwt.event.dom.client.EndedEvent;
+import com.google.gwt.event.dom.client.EndedHandler;
+import com.google.gwt.event.dom.client.HasAllMediaHandlers;
+import com.google.gwt.event.dom.client.ProgressEvent;
+import com.google.gwt.event.dom.client.ProgressHandler;
+import com.google.gwt.junit.client.GWTTestCase;
+import com.google.gwt.media.client.Audio;
+import com.google.gwt.media.client.Video;
+import com.google.gwt.user.client.ui.RootPanel;
+import com.google.gwt.user.client.ui.Widget;
+
+/**
+ * Test Case for sinking of media events.
+ */
+public class MediaEventsSinkTest extends GWTTestCase {
+
+  @Override
+  public String getModuleName() {
+    return "com.google.gwt.user.User";
+  }
+
+  public void testAudioMediaEventsSinkByAddingHandler() {
+    if (!Audio.isSupported()) {
+      return;
+    }
+    verifyProgressEventSinkOnAddHandler(Audio.createIfSupported());
+    verifyEndedEventSinkOnAddHandler(Audio.createIfSupported());
+    verifyCanPlayThroughEventSinkOnAddHandler(Audio.createIfSupported());
+  }
+
+  public void testVideoMediaEventsSinkByAddingHandler() {
+    if (!Audio.isSupported()) {
+      return;
+    }
+    verifyProgressEventSinkOnAddHandler(Video.createIfSupported());
+    verifyEndedEventSinkOnAddHandler(Video.createIfSupported());
+    verifyCanPlayThroughEventSinkOnAddHandler(Video.createIfSupported());
+  }
+
+  public void testMediaEventBitFieldsNotTriviallyZero() {
+    assertNotSame(0, Event.ONCANPLAYTHROUGH);
+    assertNotSame(0, Event.ONPROGRESS);
+    assertNotSame(0, Event.ONENDED);
+  }
+
+  @Override
+  protected void gwtTearDown() throws Exception {
+    // clean up after ourselves
+    RootPanel.get().clear();
+    super.gwtTearDown();
+  }
+
+ private <W extends Widget & HasAllMediaHandlers> void assertNotSunkAfterAttach(
+      W w, String eventName, boolean isSunk) {
+    assertFalse("Event should not be sunk on " + w.getClass().getName()
+        + " until a " + eventName + " handler has been added", isSunk);
+  }
+
+ private <W extends Widget & HasAllMediaHandlers> void assertSunkAfterAddHandler(
+      W w, String eventName, boolean isSunk) {
+    assertTrue("Event should have been sunk on " + w.getClass().getName()
+        + " once the widget has been attached and a " + eventName
+        + " handler has been added", isSunk);
+  }
+
+  private boolean isCanPlayThroughEventSunk(Element e) {
+    return (DOM.getEventsSunk(e) & Event.ONCANPLAYTHROUGH) != 0;
+  }
+
+  private boolean isEndedEventSunk(Element e) {
+    return (DOM.getEventsSunk(e) & Event.ONENDED) != 0;
+  }
+
+  private boolean isProgressEventSunk(Element e) {
+    return (DOM.getEventsSunk(e) & Event.ONPROGRESS) != 0;
+  }
+
+ private <W extends Widget & HasAllMediaHandlers> void verifyCanPlayThroughEventSinkOnAddHandler(
+      W w) {
+    verifyCanPlayThroughEventSinkOnAddHandler(w, w.getElement());
+  }
+
+ private <W extends Widget & HasAllMediaHandlers> void verifyCanPlayThroughEventSinkOnAddHandler(
+      W w, Element e) {
+    RootPanel.get().add(w);
+
+    assertNotSunkAfterAttach(w, CanPlayThroughEvent.getType().getName(),
+        isCanPlayThroughEventSunk(e));
+
+    w.addCanPlayThroughHandler(new CanPlayThroughHandler() {
+      public void onCanPlayThrough(CanPlayThroughEvent event) {
+      }
+    });
+
+    assertSunkAfterAddHandler(w, CanPlayThroughEvent.getType().getName(),
+        isCanPlayThroughEventSunk(e));
+  }
+
+ private <W extends Widget & HasAllMediaHandlers> void verifyEndedEventSinkOnAddHandler(
+      W w) {
+    verifyEndedEventSinkOnAddHandler(w, w.getElement());
+  }
+
+ private <W extends Widget & HasAllMediaHandlers> void verifyEndedEventSinkOnAddHandler(
+      W w, Element e) {
+    RootPanel.get().add(w);
+
+    assertNotSunkAfterAttach(w, EndedEvent.getType().getName(),
+        isEndedEventSunk(e));
+
+    w.addEndedHandler(new EndedHandler() {
+      public void onEnded(EndedEvent event) {
+      }
+    });
+
+    assertSunkAfterAddHandler(w, EndedEvent.getType().getName(),
+        isEndedEventSunk(e));
+  }
+
+ private <W extends Widget & HasAllMediaHandlers> void verifyProgressEventSinkOnAddHandler(
+      W w) {
+    verifyProgressEventSinkOnAddHandler(w, w.getElement());
+  }
+
+ private <W extends Widget & HasAllMediaHandlers> void verifyProgressEventSinkOnAddHandler(
+      W w, Element e) {
+    RootPanel.get().add(w);
+
+    assertNotSunkAfterAttach(w, ProgressEvent.getType().getName(),
+        isProgressEventSunk(e));
+
+    w.addProgressHandler(new ProgressHandler() {
+      public void onProgress(ProgressEvent event) {
+      }
+    });
+
+    assertSunkAfterAddHandler(w, ProgressEvent.getType().getName(),
+        isProgressEventSunk(e));
+  }
+}
=======================================
--- /releases/2.3/dev/core/src/com/google/gwt/dev/js/ast/JsRootScope.java Mon Feb 7 13:29:15 2011 +++ /releases/2.3/dev/core/src/com/google/gwt/dev/js/ast/JsRootScope.java Tue Apr 19 08:29:47 2011
@@ -237,6 +237,11 @@
       "ongesturechange",
       "ongestureend",

+      // Media events
+      "oncanplaythrough",
+      "onended",
+      "onprogress",
+
       // extra window methods
       "uneval",

=======================================
--- /releases/2.3/user/src/com/google/gwt/user/client/DOM.java Tue Nov 23 11:35:12 2010 +++ /releases/2.3/user/src/com/google/gwt/user/client/DOM.java Tue Apr 19 08:29:47 2011
@@ -1210,6 +1210,17 @@
     elem.getStyle().setProperty(attr, value);
   }

+  /**
+   * Sinks a named event. Events will be fired to the nearest
+   * {@link EventListener} specified on any of the element's parents.
+   *
+   * @param elem the element whose events are to be retrieved
+   * @param eventTypeName name of the event to sink on this element
+   */
+  public static void sinkBitlessEvent(Element elem, String eventTypeName) {
+    impl.sinkBitlessEvent(elem, eventTypeName);
+  }
+
   /**
* Sets the current set of events sunk by a given element. These events will
    * be fired to the nearest {@link EventListener} specified on any of the
=======================================
--- /releases/2.3/user/src/com/google/gwt/user/client/Event.java Thu Dec 16 11:33:51 2010 +++ /releases/2.3/user/src/com/google/gwt/user/client/Event.java Tue Apr 19 08:29:47 2011
@@ -398,6 +398,50 @@
    */
public static final int GESTUREEVENTS = ONGESTURESTART | ONGESTURECHANGE | ONGESTUREEND;

+  /**
+ * Fired when media is fully buffered and can be played through to the end.
+   *
+   * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+   * and is subject to change.
+   * </span>
+   * </p>
+   */
+  public static final int ONCANPLAYTHROUGH = 0x20000000;
+
+  /**
+   * Fired when media stops playing.
+   *
+   * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+   * and is subject to change.
+   * </span>
+   * </p>
+   */
+  public static final int ONENDED = 0x8000000;
+
+  /**
+   * Fired when progress is made downloading media.
+   *
+   * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+   * and is subject to change.
+   * </span>
+   * </p>
+   */
+  public static final int ONPROGRESS = 0x10000000;
+
+  /**
+   * A bit-mask covering all media events.
+   *
+   * <p>
+ * <span style="color:red">Experimental API: This API is still under development
+   * and is subject to change.
+   * </span>
+   * </p>
+   */
+ public static final int MEDIAEVENTS = ONCANPLAYTHROUGH | ONENDED | ONPROGRESS;
+
   /**
* Value returned by accessors when the actual integer value is undefined. In * Development Mode, most accessors assert that the requested attribute is
=======================================
--- /releases/2.3/user/src/com/google/gwt/user/client/impl/DOMImpl.java Thu Dec 16 11:33:51 2010 +++ /releases/2.3/user/src/com/google/gwt/user/client/impl/DOMImpl.java Tue Apr 19 08:29:47 2011
@@ -92,6 +92,9 @@
     case "gesturestart": return 0x1000000;
     case "gesturechange": return 0x2000000;
     case "gestureend": return 0x4000000;
+    case "ended": return 0x8000000;
+    case "progress": return 0x10000000;
+    case "canplaythrough": return 0x20000000;
     default: return -1;
     }
   }-*/;
@@ -131,6 +134,8 @@
     elem.__listener = listener;
   }-*/;

+ public abstract void sinkBitlessEvent(Element elem, String eventTypeName);
+
   public abstract void sinkEvents(Element elem, int eventBits);

   /**
=======================================
--- /releases/2.3/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java Wed Mar 23 05:27:01 2011 +++ /releases/2.3/user/src/com/google/gwt/user/client/impl/DOMImplStandard.java Tue Apr 19 08:29:47 2011
@@ -137,6 +137,12 @@
     setCaptureImpl(elem);
   }

+  @Override
+  public void sinkBitlessEvent(Element elem, String eventTypeName) {
+    maybeInitializeEventSystem();
+    sinkBitlessEventImpl(elem, eventTypeName);
+  }
+
   @Override
   public void sinkEvents(Element elem, int bits) {
     maybeInitializeEventSystem();
@@ -210,6 +216,17 @@
$wnd.addEventListener('gestureend', @com.google.gwt.user.client.impl.DOMImplStandard::dispatchCapturedMouseEvent, true);
   }-*/;

+ protected native void sinkBitlessEventImpl(Element elem, String eventTypeName) /*-{
+    if (eventTypeName == "dragenter")
+ elem.ondragenter = @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent;
+    if (eventTypeName == "dragexit")
+ elem.ondragexit = @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent;
+    if (eventTypeName == "dragover")
+ elem.ondragover = @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent;
+    if (eventTypeName == "drop")
+ elem.ondrop = @com.google.gwt.user.client.impl.DOMImplStandard::dispatchEvent;
+  }-*/;
+
   protected native void sinkEventsImpl(Element elem, int bits) /*-{
     var chMask = (elem.__eventBits || 0) ^ bits;
     elem.__eventBits = bits;
=======================================
--- /releases/2.3/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java Tue Mar 22 11:44:40 2011 +++ /releases/2.3/user/src/com/google/gwt/user/client/impl/DOMImplTrident.java Tue Apr 19 08:29:47 2011
@@ -222,6 +222,11 @@
     maybeInitializeEventSystem();
     setCaptureImpl(elem);
   }
+
+  @Override
+  public void sinkBitlessEvent(Element elem, String eventTypeName) {
+    // not supported
+  }

   @Override
   public void sinkEvents(Element elem, int bits) {
=======================================
--- /releases/2.3/user/src/com/google/gwt/user/client/ui/UIObject.java Tue Jul 20 08:04:29 2010 +++ /releases/2.3/user/src/com/google/gwt/user/client/ui/UIObject.java Tue Apr 19 08:29:47 2011
@@ -753,6 +753,18 @@
     DOM.setStyleAttribute(getElement(), "width", width);
   }

+  /**
+ * Sinks a named event. Note that only {@link Widget widgets} may actually + * receive events, but can receive events from all objects contained within
+   * them.
+   *
+   * @param eventTypeName name of the event to sink on this element
+   * @see com.google.gwt.user.client.Event
+   */
+  public void sinkBitlessEvent(String eventTypeName) {
+    DOM.sinkBitlessEvent(getElement(), eventTypeName);
+  }
+
   /**
    * Adds a set of events to be sunk by this object. Note that only
* {@link Widget widgets} may actually receive events, but can receive events
=======================================
--- /releases/2.3/user/src/com/google/gwt/user/client/ui/Widget.java Fri Dec 3 10:28:00 2010 +++ /releases/2.3/user/src/com/google/gwt/user/client/ui/Widget.java Tue Apr 19 08:29:47 2011
@@ -62,6 +62,28 @@
   public HandlerRegistration addAttachHandler(Handler handler) {
     return addHandler(handler, AttachEvent.getType());
   }
+
+  /**
+   * For <a href=
+ * "http://code.google.com/p/google-web-toolkit/wiki/UnderstandingMemoryLeaks"; + * >browsers which do not leak</a>, adds a native event handler to the widget.
+   * Note that, unlike the
+ * {@link #addDomHandler(EventHandler, com.google.gwt.event.dom.client.DomEvent.Type)} + * implementation, there is no need to attach the widget to the DOM in order
+   * to cause the event handlers to be attached.
+   *
+   * @param <H> the type of handler to add
+   * @param type the event key
+   * @param handler the handler
+   * @return {@link HandlerRegistration} used to remove the handler
+   */
+ public final <H extends EventHandler> HandlerRegistration addBitlessDomHandler(
+      final H handler, DomEvent.Type<H> type) {
+    assert handler != null : "handler must not be null";
+    assert type != null : "type must not be null";
+    sinkBitlessEvent(type.getName());
+    return ensureHandlers().addHandler(type, handler);
+  }

   /**
    * Adds a native event handler to the widget and sinks the corresponding

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

Reply via email to