Bug 868751: Remove support for obsolete document.createEvent("AnimationEvent"), document.createEvent("TransitionEvent"), AnimationEvent.initAnimationEvent, and TransitionEvent.initTransitionEvent. r=smaug
authorL. David Baron <dbaron@dbaron.org>
Wed, 08 May 2013 13:45:35 -0700
changeset 131298 a20ea0d494a049d68544cdc43973b5a515f55b59
parent 131297 d986ae112cb6dbcf69a5727547d3ea0d618c9bfc
child 131299 c51eab92e5cb0da35865403dc248c02f8a35472f
push id24654
push userryanvm@gmail.com
push dateThu, 09 May 2013 04:17:56 +0000
treeherdermozilla-central@ea059733677c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs868751
milestone23.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 868751: Remove support for obsolete document.createEvent("AnimationEvent"), document.createEvent("TransitionEvent"), AnimationEvent.initAnimationEvent, and TransitionEvent.initTransitionEvent. r=smaug
content/events/src/nsDOMAnimationEvent.cpp
content/events/src/nsDOMAnimationEvent.h
content/events/src/nsDOMTransitionEvent.cpp
content/events/src/nsDOMTransitionEvent.h
content/events/src/nsEventDispatcher.cpp
dom/interfaces/events/nsIDOMAnimationEvent.idl
dom/interfaces/events/nsIDOMTransitionEvent.idl
dom/webidl/AnimationEvent.webidl
dom/webidl/TransitionEvent.webidl
layout/style/test/test_transitions_events.html
--- a/content/events/src/nsDOMAnimationEvent.cpp
+++ b/content/events/src/nsDOMAnimationEvent.cpp
@@ -51,19 +51,23 @@ already_AddRefed<nsDOMAnimationEvent>
 nsDOMAnimationEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
                                  const nsAString& aType,
                                  const mozilla::dom::AnimationEventInit& aParam,
                                  mozilla::ErrorResult& aRv)
 {
   nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
   nsRefPtr<nsDOMAnimationEvent> e = new nsDOMAnimationEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
-  aRv = e->InitAnimationEvent(aType, aParam.mBubbles, aParam.mCancelable,
-                              aParam.mAnimationName, aParam.mElapsedTime,
-                              aParam.mPseudoElement);
+
+  aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
+
+  e->AnimationEvent()->animationName = aParam.mAnimationName;
+  e->AnimationEvent()->elapsedTime = aParam.mElapsedTime;
+  e->AnimationEvent()->pseudoElement = aParam.mPseudoElement;
+
   e->SetTrusted(trusted);
   return e.forget();
 }
 
 NS_IMETHODIMP
 nsDOMAnimationEvent::GetAnimationName(nsAString & aAnimationName)
 {
   aAnimationName = AnimationEvent()->animationName;
@@ -79,33 +83,16 @@ nsDOMAnimationEvent::GetElapsedTime(floa
 
 NS_IMETHODIMP
 nsDOMAnimationEvent::GetPseudoElement(nsAString& aPseudoElement)
 {
   aPseudoElement = AnimationEvent()->pseudoElement;
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsDOMAnimationEvent::InitAnimationEvent(const nsAString & typeArg,
-                                        bool canBubbleArg,
-                                        bool cancelableArg,
-                                        const nsAString & animationNameArg,
-                                        float elapsedTimeArg,
-                                        const nsAString & pseudoElementArg)
-{
-  nsresult rv = nsDOMEvent::InitEvent(typeArg, canBubbleArg, cancelableArg);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  AnimationEvent()->animationName = animationNameArg;
-  AnimationEvent()->elapsedTime = elapsedTimeArg;
-  AnimationEvent()->pseudoElement = pseudoElementArg;
-  return NS_OK;
-}
-
 nsresult
 NS_NewDOMAnimationEvent(nsIDOMEvent **aInstancePtrResult,
                         mozilla::dom::EventTarget* aOwner,
                         nsPresContext *aPresContext,
                         nsAnimationEvent *aEvent)
 {
   nsDOMAnimationEvent* it =
     new nsDOMAnimationEvent(aOwner, aPresContext, aEvent);
--- a/content/events/src/nsDOMAnimationEvent.h
+++ b/content/events/src/nsDOMAnimationEvent.h
@@ -41,28 +41,16 @@ public:
   // GetAnimationName(nsAString& aAnimationName);
   // GetPseudoElement(nsAString& aPseudoElement);
 
   float ElapsedTime()
   {
     return AnimationEvent()->elapsedTime;
   }
 
-  void InitAnimationEvent(const nsAString& aType,
-                          bool aCanBubble,
-                          bool aCancelable,
-                          const nsAString& aAnimationName,
-                          float aElapsedTime,
-                          const mozilla::dom::Optional<nsAString>& aPseudoElement,
-                          mozilla::ErrorResult& aRv)
-  {
-    aRv = InitAnimationEvent(aType, aCanBubble, aCancelable, aAnimationName,
-                             aElapsedTime, aPseudoElement.WasPassed() ?
-                               aPseudoElement.Value() : EmptyString());
-  }
 private:
   nsAnimationEvent* AnimationEvent() {
     NS_ABORT_IF_FALSE(mEvent->eventStructType == NS_ANIMATION_EVENT,
                       "unexpected struct type");
     return static_cast<nsAnimationEvent*>(mEvent);
   }
 };
 
--- a/content/events/src/nsDOMTransitionEvent.cpp
+++ b/content/events/src/nsDOMTransitionEvent.cpp
@@ -51,19 +51,23 @@ already_AddRefed<nsDOMTransitionEvent>
 nsDOMTransitionEvent::Constructor(const mozilla::dom::GlobalObject& aGlobal,
                                   const nsAString& aType,
                                   const mozilla::dom::TransitionEventInit& aParam,
                                   mozilla::ErrorResult& aRv)
 {
   nsCOMPtr<mozilla::dom::EventTarget> t = do_QueryInterface(aGlobal.Get());
   nsRefPtr<nsDOMTransitionEvent> e = new nsDOMTransitionEvent(t, nullptr, nullptr);
   bool trusted = e->Init(t);
-  aRv = e->InitTransitionEvent(aType, aParam.mBubbles, aParam.mCancelable,
-                               aParam.mPropertyName, aParam.mElapsedTime,
-                               aParam.mPseudoElement);
+
+  aRv = e->InitEvent(aType, aParam.mBubbles, aParam.mCancelable);
+
+  e->TransitionEvent()->propertyName = aParam.mPropertyName;
+  e->TransitionEvent()->elapsedTime = aParam.mElapsedTime;
+  e->TransitionEvent()->pseudoElement = aParam.mPseudoElement;
+
   e->SetTrusted(trusted);
   return e.forget();
 }
 
 NS_IMETHODIMP
 nsDOMTransitionEvent::GetPropertyName(nsAString & aPropertyName)
 {
   aPropertyName = TransitionEvent()->propertyName;
@@ -79,33 +83,16 @@ nsDOMTransitionEvent::GetElapsedTime(flo
 
 NS_IMETHODIMP
 nsDOMTransitionEvent::GetPseudoElement(nsAString& aPseudoElement)
 {
   aPseudoElement = TransitionEvent()->pseudoElement;
   return NS_OK;
 }
 
-NS_IMETHODIMP
-nsDOMTransitionEvent::InitTransitionEvent(const nsAString & typeArg,
-                                          bool canBubbleArg,
-                                          bool cancelableArg,
-                                          const nsAString & propertyNameArg,
-                                          float elapsedTimeArg,
-                                          const nsAString& aPseudoElement)
-{
-  nsresult rv = nsDOMEvent::InitEvent(typeArg, canBubbleArg, cancelableArg);
-  NS_ENSURE_SUCCESS(rv, rv);
-
-  TransitionEvent()->propertyName = propertyNameArg;
-  TransitionEvent()->elapsedTime = elapsedTimeArg;
-  TransitionEvent()->pseudoElement = aPseudoElement;
-  return NS_OK;
-}
-
 nsresult
 NS_NewDOMTransitionEvent(nsIDOMEvent **aInstancePtrResult,
                          mozilla::dom::EventTarget* aOwner,
                          nsPresContext *aPresContext,
                          nsTransitionEvent *aEvent)
 {
   nsDOMTransitionEvent *it =
     new nsDOMTransitionEvent(aOwner, aPresContext, aEvent);
--- a/content/events/src/nsDOMTransitionEvent.h
+++ b/content/events/src/nsDOMTransitionEvent.h
@@ -41,28 +41,16 @@ public:
   // GetPropertyName(nsAString& aPropertyName)
   // GetPseudoElement(nsAString& aPreudoElement)
 
   float ElapsedTime()
   {
     return TransitionEvent()->elapsedTime;
   }
 
-  void InitTransitionEvent(const nsAString& aType,
-                           bool aCanBubble,
-                           bool aCancelable,
-                           const nsAString& aPropertyName,
-                           float aElapsedTime,
-                           const mozilla::dom::Optional<nsAString>& aPseudoElement,
-                           mozilla::ErrorResult& aRv)
-  {
-    aRv = InitTransitionEvent(aType, aCanBubble, aCancelable, aPropertyName,
-                              aElapsedTime, aPseudoElement.WasPassed() ?
-                                aPseudoElement.Value() : EmptyString());
-  }
 private:
   nsTransitionEvent* TransitionEvent() {
     NS_ABORT_IF_FALSE(mEvent->eventStructType == NS_TRANSITION_EVENT,
                       "unexpected struct type");
     return static_cast<nsTransitionEvent*>(mEvent);
   }
 };
 
--- a/content/events/src/nsEventDispatcher.cpp
+++ b/content/events/src/nsEventDispatcher.cpp
@@ -834,22 +834,16 @@ nsEventDispatcher::CreateEvent(mozilla::
   if (aEventType.LowerCaseEqualsLiteral("beforeunloadevent"))
     return NS_NewDOMBeforeUnloadEvent(aDOMEvent, aOwner, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("pagetransition"))
     return NS_NewDOMPageTransitionEvent(aDOMEvent, aOwner, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("domtransaction"))
     return NS_NewDOMDOMTransactionEvent(aDOMEvent, aOwner, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("scrollareaevent"))
     return NS_NewDOMScrollAreaEvent(aDOMEvent, aOwner, aPresContext, nullptr);
-  // FIXME: Should get spec to say what the right string is here!  This
-  // is probably wrong!
-  if (aEventType.LowerCaseEqualsLiteral("transitionevent"))
-    return NS_NewDOMTransitionEvent(aDOMEvent, aOwner, aPresContext, nullptr);
-  if (aEventType.LowerCaseEqualsLiteral("animationevent"))
-    return NS_NewDOMAnimationEvent(aDOMEvent, aOwner, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("popstateevent"))
     return NS_NewDOMPopStateEvent(aDOMEvent, aOwner, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("mozaudioavailableevent"))
     return NS_NewDOMAudioAvailableEvent(aDOMEvent, aOwner, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("closeevent"))
     return NS_NewDOMCloseEvent(aDOMEvent, aOwner, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("touchevent") &&
       nsDOMTouchEvent::PrefEnabled())
@@ -860,11 +854,13 @@ nsEventDispatcher::CreateEvent(mozilla::
     return NS_NewDOMCustomEvent(aDOMEvent, aOwner, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("mozsmsevent"))
     return NS_NewDOMMozSmsEvent(aDOMEvent, aOwner, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("mozmmsevent"))
     return NS_NewDOMMozMmsEvent(aDOMEvent, aOwner, aPresContext, nullptr);
   if (aEventType.LowerCaseEqualsLiteral("storageevent")) {
     return NS_NewDOMStorageEvent(aDOMEvent, aOwner, aPresContext, nullptr);
   }
+  // NEW EVENT TYPES SHOULD NOT BE ADDED HERE; THEY SHOULD USE ONLY EVENT
+  // CONSTRUCTORS
 
   return NS_ERROR_DOM_NOT_SUPPORTED_ERR;
 }
--- a/dom/interfaces/events/nsIDOMAnimationEvent.idl
+++ b/dom/interfaces/events/nsIDOMAnimationEvent.idl
@@ -6,20 +6,14 @@
 #include "nsIDOMEvent.idl"
 
 /**
  * Animation events are defined in:
  * http://www.w3.org/TR/css3-animations/#animation-events-
  * http://dev.w3.org/csswg/css3-animations/#animation-events-
  */
 
-[scriptable, builtinclass, uuid(12626092-ee93-44d1-8ecd-160298f98b0f)]
+[scriptable, builtinclass, uuid(b1bea1bc-689b-4e07-8cbc-ef342725f9a6)]
 interface nsIDOMAnimationEvent : nsIDOMEvent {
   readonly attribute DOMString          animationName;
   readonly attribute float              elapsedTime;
   readonly attribute DOMString          pseudoElement;
-  void               initAnimationEvent(in DOMString typeArg,
-                                        in boolean canBubbleArg,
-                                        in boolean cancelableArg,
-                                        in DOMString propertyNameArg,
-                                        in float elapsedTimeArg,
-                                        [optional] in DOMString pseudoElementArg);
 };
--- a/dom/interfaces/events/nsIDOMTransitionEvent.idl
+++ b/dom/interfaces/events/nsIDOMTransitionEvent.idl
@@ -6,20 +6,14 @@
 #include "nsIDOMEvent.idl"
 
 /**
  * Transition events are defined in:
  * http://www.w3.org/TR/css3-transitions/#transition-events-
  * http://dev.w3.org/csswg/css3-transitions/#transition-events-
  */
 
-[scriptable, builtinclass, uuid(eca50ac5-087a-4e50-bdf6-b341f0f9f8ab)]
+[scriptable, builtinclass, uuid(a37171e0-9f43-41ea-a25c-0b78a3329683)]
 interface nsIDOMTransitionEvent : nsIDOMEvent {
   readonly attribute DOMString           propertyName;
   readonly attribute float               elapsedTime;
   readonly attribute DOMString           pseudoElement;
-  void               initTransitionEvent(in DOMString typeArg, 
-                                         in boolean canBubbleArg, 
-                                         in boolean cancelableArg, 
-                                         in DOMString propertyNameArg,
-                                         in float elapsedTimeArg,
-                                         [optional] in DOMString pseudoElement);
 };
--- a/dom/webidl/AnimationEvent.webidl
+++ b/dom/webidl/AnimationEvent.webidl
@@ -18,20 +18,8 @@ interface AnimationEvent : Event {
   readonly attribute DOMString pseudoElement;
 };
 
 dictionary AnimationEventInit : EventInit {
   DOMString animationName = "";
   float elapsedTime = 0;
   DOMString pseudoElement = "";
 };
-
-// initAnimationEvent is a legacy method, and removed from the latest version
-// of the specification.
-partial interface AnimationEvent {
-  [Throws]
-  void initAnimationEvent(DOMString type,
-                          boolean canBubble,
-                          boolean cancelable,
-                          DOMString animationName,
-                          float elapsedTime,
-                          optional DOMString pseudoElement);
-};
--- a/dom/webidl/TransitionEvent.webidl
+++ b/dom/webidl/TransitionEvent.webidl
@@ -18,20 +18,8 @@ interface TransitionEvent : Event {
   readonly attribute DOMString pseudoElement;
 };
 
 dictionary TransitionEventInit : EventInit {
   DOMString propertyName = "";
   float elapsedTime = 0;
   DOMString pseudoElement = "";
 };
-
-// initTransitionEvent is a legacy method, and removed from the latest version
-// of the specification.
-partial interface TransitionEvent {
-  [Throws]
-  void initTransitionEvent(DOMString aType,
-                           boolean aCanBubble,
-                           boolean aCancelable,
-                           DOMString aPropertyName,
-                           float aElapsedTime,
-                           optional DOMString pseudoElement);
-};
--- a/layout/style/test/test_transitions_events.html
+++ b/layout/style/test/test_transitions_events.html
@@ -105,17 +105,17 @@ document.documentElement.addEventListene
       got_four_root = true;
       finished_test();
     } else if (event.target == document.body) {
       // A synthesized event.
       ok(!got_body, "transitionend on body on root");
       is(event.propertyName, "some-unknown-prop",
          "propertyName for transitionend on body");
       // Reported time should (really?) be shortened by reversing.
-      is(event.elapsedTime, -4.75,
+      is(event.elapsedTime, 0.5,
          "elapsedTime for transitionend on body");
       got_body = true;
       finished_test();
     } else if (event.target == $("seven")) {
       if (!got_before) {
         got_before = true;
         is(event.pseudoElement, "::before");
       } else {
@@ -296,32 +296,29 @@ function poll_start_reversal() {
     setTimeout(poll_start_reversal, 20);
   }
 }
 setTimeout(poll_start_reversal, 200);
 
 // And make our own event to dispatch to the body.
 started_test();
 
-var e = new TransitionEvent("foo",
+var e = new TransitionEvent("transitionend",
                             {
                               bubbles: true,
                               cancelable: true,
-                              propertyName: "name",
+                              propertyName: "some-unknown-prop",
                               elapsedTime: 0.5,
                               pseudoElement: "pseudo"
                             });
 is(e.bubbles, true);
 is(e.cancelable, true);
-is(e.propertyName, "name");
+is(e.propertyName, "some-unknown-prop");
 is(e.elapsedTime, "0.5");
 is(e.pseudoElement, "pseudo");
 is(e.isTrusted, false)
 
-var ev = document.createEvent("TransitionEvent"); // FIXME: un-specified
-ev.initTransitionEvent("transitionend", true, true,
-                       "some-unknown-prop", -4.75);
-document.body.dispatchEvent(ev);
+document.body.dispatchEvent(e);
 
 </script>
 </pre>
 </body>
 </html>