Bug 751286 - eventPhase NONE constant, r=sicking
authorOlli Pettay <Olli.Pettay@helsinki.fi>
Thu, 03 May 2012 13:59:51 +0300
changeset 92895 b4d2343fff9d5bfef28dcb2a00c6358cc65a4d30
parent 92894 807403a04a6a054b23edeef64d076bf496e18b12
child 92896 55888632fa91a28d1694739877c3891b29497b4f
push id22596
push useropettay@mozilla.com
push dateThu, 03 May 2012 11:00:45 +0000
treeherdermozilla-central@b4d2343fff9d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssicking
bugs751286
milestone15.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 751286 - eventPhase NONE constant, r=sicking
content/events/src/nsDOMEvent.cpp
content/events/test/test_eventctors.html
content/smil/test/test_smilTimeEvents.xhtml
dom/interfaces/events/nsIDOMEvent.idl
--- a/content/events/src/nsDOMEvent.cpp
+++ b/content/events/src/nsDOMEvent.cpp
@@ -422,26 +422,27 @@ nsDOMEvent::InitFromCtor(const nsAString
   return InitEvent(aType, d.bubbles, d.cancelable);
 }
 
 NS_IMETHODIMP
 nsDOMEvent::GetEventPhase(PRUint16* aEventPhase)
 {
   // Note, remember to check that this works also
   // if or when Bug 235441 is fixed.
-  if (mEvent->currentTarget == mEvent->target ||
+  if ((mEvent->currentTarget &&
+       mEvent->currentTarget == mEvent->target) ||
       ((mEvent->flags & NS_EVENT_FLAG_CAPTURE) &&
        (mEvent->flags & NS_EVENT_FLAG_BUBBLE))) {
     *aEventPhase = nsIDOMEvent::AT_TARGET;
   } else if (mEvent->flags & NS_EVENT_FLAG_CAPTURE) {
     *aEventPhase = nsIDOMEvent::CAPTURING_PHASE;
   } else if (mEvent->flags & NS_EVENT_FLAG_BUBBLE) {
     *aEventPhase = nsIDOMEvent::BUBBLING_PHASE;
   } else {
-    *aEventPhase = 0;
+    *aEventPhase = nsIDOMEvent::NONE;
   }
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsDOMEvent::GetBubbles(bool* aBubbles)
 {
   *aBubbles = !(mEvent->flags & NS_EVENT_FLAG_CANT_BUBBLE);
--- a/content/events/test/test_eventctors.html
+++ b/content/events/test/test_eventctors.html
@@ -59,17 +59,19 @@ ok(ex, "2nd parameter should be an objec
 ex = false;
 
 
 e = new Event("hello");
 ok(e.type, "hello", "Wrong event type!");
 ok(!e.isTrusted, "Event shouldn't be trusted!");
 ok(!e.bubbles, "Event shouldn't bubble!");
 ok(!e.cancelable, "Event shouldn't be cancelable!");
+is(e.eventPhase, Event.NONE, "Wrong event phase");
 document.dispatchEvent(e);
+is(e.eventPhase, Event.NONE, "Wrong event phase");
 is(receivedEvent, e, "Wrong event!");
 
 e = new Event("hello", { bubbles: true, cancelable: true });
 ok(e.type, "hello", "Wrong event type!");
 ok(!e.isTrusted, "Event shouldn't be trusted!");
 ok(e.bubbles, "Event should bubble!");
 ok(e.cancelable, "Event should be cancelable!");
 document.dispatchEvent(e);
--- a/content/smil/test/test_smilTimeEvents.xhtml
+++ b/content/smil/test/test_smilTimeEvents.xhtml
@@ -152,17 +152,17 @@ function testCreateEvent()
     ok(false, "Failed to create TimeEvent via script: " + e);
     return;
   }
   evt.initTimeEvent("repeatEvent", null, 3);
   is(evt.type, "repeatEvent", "Unexpected type for user-generated event");
   is(evt.detail, 3, "Unexpected detail for user-generated event");
   is(evt.target, null, "Unexpected event target");
   is(evt.currentTarget, null, "Unexpected event current target");
-  is(evt.eventPhase, evt.AT_TARGET);
+  is(evt.eventPhase, evt.NONE);
   is(evt.bubbles, false, "Event should not bubble");
   is(evt.cancelable, false, "Event should not be cancelable");
   is(evt.view, null, "Event view should be null");
 
   // Prior to dispatch we should be able to change the event type
   evt.initTimeEvent("beginEvent", document.defaultView, 0);
   is(evt.type, "beginEvent", "Failed to update event type before dispatch");
   is(evt.detail, 0, "Failed to update event detail before dispatch");
--- a/dom/interfaces/events/nsIDOMEvent.idl
+++ b/dom/interfaces/events/nsIDOMEvent.idl
@@ -41,24 +41,29 @@
 
 interface nsIDOMEventTarget;
 
 /**
  * The nsIDOMEvent interface is the primary datatype for all events in
  * the Document Object Model.
  *
  * For more information on this interface please see 
- * http://www.w3.org/TR/DOM-Level-2-Events/
+ * http://dev.w3.org/2006/webapi/DOM-Level-3-Events/html/DOM3-Events.html and
+ * http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html
  */
 
 [scriptable, uuid(e85cff74-951f-45c1-be0c-89442ea2f500)]
 interface nsIDOMEvent : nsISupports
 {
   // PhaseType
   /**
+   * The event isn't being dispatched.
+   */
+  const unsigned short      NONE                           = 0;
+  /**
    * The current event phase is the capturing phase.
    */
   const unsigned short      CAPTURING_PHASE                = 1;
 
   /**
    * The event is currently being evaluated at the target EventTarget.
    */
   const unsigned short      AT_TARGET                      = 2;