diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h index c7cf6c62b278..008825a2cc95 100644 --- a/dom/base/nsGkAtomList.h +++ b/dom/base/nsGkAtomList.h @@ -931,10 +931,6 @@ GK_ATOM(onupgradeneeded, "onupgradeneeded") GK_ATOM(onussdreceived, "onussdreceived") GK_ATOM(onversionchange, "onversionchange") GK_ATOM(onvoicechange, "onvoicechange") -GK_ATOM(onwebkitAnimationEnd, "onwebkitAnimationEnd") -GK_ATOM(onwebkitAnimationIteration, "onwebkitAnimationIteration") -GK_ATOM(onwebkitAnimationStart, "onwebkitAnimationStart") -GK_ATOM(onwebkitTransitionEnd, "onwebkitTransitionEnd") GK_ATOM(onwheel, "onwheel") GK_ATOM(open, "open") GK_ATOM(optgroup, "optgroup") diff --git a/dom/events/Event.h b/dom/events/Event.h index 85fb0642d092..2dd50c50961d 100644 --- a/dom/events/Event.h +++ b/dom/events/Event.h @@ -30,7 +30,6 @@ namespace mozilla { namespace dom { class EventTarget; -class EventMessageAutoOverride; class WantsPopupControlCheck; #define GENERATED_EVENT(EventClass_) class EventClass_; #include "mozilla/dom/GeneratedEventList.h" @@ -240,7 +239,6 @@ protected: void SetEventType(const nsAString& aEventTypeArg); already_AddRefed GetTargetFromFrame(); - friend class EventMessageAutoOverride; friend class WantsPopupControlCheck; void SetWantsPopupControlCheck(bool aCheck) { @@ -270,48 +268,6 @@ protected: bool mWantsPopupControlCheck; }; -/** - * RAII helper-class to override an event's message (i.e. its DOM-exposed - * type), for as long as the object is alive. Restores the original - * EventMessage when destructed. - * - * Notable requirements: - * - The original & overriding messages must be known (not eUnidentifiedEvent). - * - The original & overriding messages must be different. - * - The passed-in nsIDOMEvent must outlive this RAII helper. - */ -class MOZ_RAII EventMessageAutoOverride -{ -public: - explicit EventMessageAutoOverride(nsIDOMEvent* aEvent, - EventMessage aOverridingMessage) - : mEvent(aEvent->InternalDOMEvent()), - mOrigMessage(mEvent->mEvent->mMessage) - { - MOZ_ASSERT(aOverridingMessage != mOrigMessage, - "Don't use this class if you're not actually overriding"); - MOZ_ASSERT(aOverridingMessage != eUnidentifiedEvent, - "Only use this class with a valid overriding EventMessage"); - MOZ_ASSERT(mOrigMessage != eUnidentifiedEvent && - mEvent->mEvent->typeString.IsEmpty(), - "Only use this class on events whose overridden type is " - "known (so we can restore it properly)"); - - mEvent->mEvent->mMessage = aOverridingMessage; - } - - ~EventMessageAutoOverride() - { - mEvent->mEvent->mMessage = mOrigMessage; - } - -protected: - // Non-owning ref, which should be safe since we're a stack-allocated object - // with limited lifetime. Whoever creates us should keep mEvent alive. - Event* const MOZ_NON_OWNING_REF mEvent; - const EventMessage mOrigMessage; -}; - class MOZ_STACK_CLASS WantsPopupControlCheck { public: diff --git a/dom/events/EventListenerManager.cpp b/dom/events/EventListenerManager.cpp index ecc3d95eb8dc..3ddb7dd9e486 100644 --- a/dom/events/EventListenerManager.cpp +++ b/dom/events/EventListenerManager.cpp @@ -19,9 +19,7 @@ #include "mozilla/HalSensor.h" #include "mozilla/InternalMutationEvent.h" #include "mozilla/JSEventHandler.h" -#include "mozilla/Maybe.h" #include "mozilla/MemoryReporting.h" -#include "mozilla/Preferences.h" #include "mozilla/dom/BindingUtils.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/Event.h" @@ -97,46 +95,6 @@ MutationBitForEventType(EventMessage aEventType) uint32_t EventListenerManager::sMainThreadCreatedCount = 0; -static bool -IsWebkitPrefixSupportEnabled() -{ - static bool sIsWebkitPrefixSupportEnabled; - static bool sIsPrefCached = false; - - if (!sIsPrefCached) { - sIsPrefCached = true; - Preferences::AddBoolVarCache(&sIsWebkitPrefixSupportEnabled, - "layout.css.prefixes.webkit"); - } - - return sIsWebkitPrefixSupportEnabled; -} - -// If the given EventMessage has a legacy version that we support, then this -// function returns that legacy version. Otherwise, this function simply -// returns the passed-in EventMessage. -EventMessage -GetLegacyEventMessage(EventMessage aEventMessage) -{ - if (IsWebkitPrefixSupportEnabled()) { - // webkit-prefixed legacy events: - if (aEventMessage == eTransitionEnd) { - return eWebkitTransitionEnd; - } - if (aEventMessage == eAnimationStart) { - return eWebkitAnimationStart; - } - if (aEventMessage == eAnimationEnd) { - return eWebkitAnimationEnd; - } - if (aEventMessage == eAnimationIteration) { - return eWebkitAnimationIteration; - } - } - - return aEventMessage; -} - EventListenerManagerBase::EventListenerManagerBase() : mNoListenerForEvent(eVoidEvent) , mMayHavePaintEventListener(false) @@ -645,15 +603,9 @@ EventListenerManager::RemoveEventListenerInternal( } bool -EventListenerManager::ListenerCanHandle(const Listener* aListener, - const WidgetEvent* aEvent, - EventMessage aEventMessage) const - +EventListenerManager::ListenerCanHandle(Listener* aListener, + WidgetEvent* aEvent) { - MOZ_ASSERT(aEventMessage == aEvent->mMessage || - aEventMessage == GetLegacyEventMessage(aEvent->mMessage), - "aEvent and aEventMessage should agree, modulo legacyness"); - // This is slightly different from EVENT_TYPE_EQUALS in that it returns // true even when aEvent->mMessage == eUnidentifiedEvent and // aListener=>mEventMessage != eUnidentifiedEvent as long as the atoms are @@ -668,7 +620,7 @@ EventListenerManager::ListenerCanHandle(const Listener* aListener, return aListener->mTypeString.Equals(aEvent->typeString); } MOZ_ASSERT(mIsMainThreadELM); - return aListener->mEventMessage == aEventMessage; + return aListener->mEventMessage == aEvent->mMessage; } void @@ -1152,107 +1104,77 @@ EventListenerManager::HandleEventInternal(nsPresContext* aPresContext, aEvent->mFlags.mDefaultPrevented = true; } + nsAutoTObserverArray::EndLimitedIterator iter(mListeners); Maybe popupStatePusher; if (mIsMainThreadELM) { popupStatePusher.emplace(Event::GetEventPopupControlState(aEvent, *aDOMEvent)); } bool hasListener = false; - bool usingLegacyMessage = false; - EventMessage eventMessage = aEvent->mMessage; - - while (true) { - nsAutoTObserverArray::EndLimitedIterator iter(mListeners); - Maybe legacyAutoOverride; - while (iter.HasMore()) { - if (aEvent->mFlags.mImmediatePropagationStopped) { - break; - } - Listener* listener = &iter.GetNext(); - // Check that the phase is same in event and event listener. - // Handle only trusted events, except when listener permits untrusted events. - if (ListenerCanHandle(listener, aEvent, eventMessage)) { - hasListener = true; - if (listener->IsListening(aEvent) && - (aEvent->mFlags.mIsTrusted || - listener->mFlags.mAllowUntrustedEvents)) { - if (!*aDOMEvent) { - // This is tiny bit slow, but happens only once per event. - nsCOMPtr et = - do_QueryInterface(aEvent->originalTarget); - RefPtr event = EventDispatcher::CreateEvent(et, aPresContext, + while (iter.HasMore()) { + if (aEvent->mFlags.mImmediatePropagationStopped) { + break; + } + Listener* listener = &iter.GetNext(); + // Check that the phase is same in event and event listener. + // Handle only trusted events, except when listener permits untrusted events. + if (ListenerCanHandle(listener, aEvent)) { + hasListener = true; + if (listener->IsListening(aEvent) && + (aEvent->mFlags.mIsTrusted || + listener->mFlags.mAllowUntrustedEvents)) { + if (!*aDOMEvent) { + // This is tiny bit slow, but happens only once per event. + nsCOMPtr et = + do_QueryInterface(aEvent->originalTarget); + RefPtr event = EventDispatcher::CreateEvent(et, aPresContext, aEvent, EmptyString()); - event.forget(aDOMEvent); - } - if (*aDOMEvent) { + event.forget(aDOMEvent); + } + if (*aDOMEvent) { + if (!aEvent->currentTarget) { + aEvent->currentTarget = aCurrentTarget->GetTargetForDOMEvent(); if (!aEvent->currentTarget) { - aEvent->currentTarget = aCurrentTarget->GetTargetForDOMEvent(); - if (!aEvent->currentTarget) { - break; + break; + } + } + + // Maybe add a marker to the docshell's timeline, but only + // bother with all the logic if some docshell is recording. + nsDocShell* docShell; + RefPtr timelines = TimelineConsumers::Get(); + bool needsEndEventMarker = false; + + if (mIsMainThreadELM && + listener->mListenerType != Listener::eNativeListener) { + nsCOMPtr docShellComPtr = GetDocShellForTarget(); + if (docShellComPtr) { + docShell = static_cast(docShellComPtr.get()); + if (timelines && timelines->HasConsumer(docShell)) { + needsEndEventMarker = true; + nsAutoString typeStr; + (*aDOMEvent)->GetType(typeStr); + uint16_t phase; + (*aDOMEvent)->GetEventPhase(&phase); + timelines->AddMarkerForDocShell(docShell, Move( + MakeUnique( + typeStr, phase, MarkerTracingType::START))); } } - if (usingLegacyMessage && !legacyAutoOverride) { - // Override the aDOMEvent's event-message (its .type) until we - // finish traversing listeners (when legacyAutoOverride destructs) - legacyAutoOverride.emplace(*aDOMEvent, eventMessage); - } + } - // Maybe add a marker to the docshell's timeline, but only - // bother with all the logic if some docshell is recording. - nsDocShell* docShell; - RefPtr timelines = TimelineConsumers::Get(); - bool needsEndEventMarker = false; + if (NS_FAILED(HandleEventSubType(listener, *aDOMEvent, aCurrentTarget))) { + aEvent->mFlags.mExceptionHasBeenRisen = true; + } - if (mIsMainThreadELM && - listener->mListenerType != Listener::eNativeListener) { - nsCOMPtr docShellComPtr = GetDocShellForTarget(); - if (docShellComPtr) { - docShell = static_cast(docShellComPtr.get()); - if (timelines && timelines->HasConsumer(docShell)) { - needsEndEventMarker = true; - nsAutoString typeStr; - (*aDOMEvent)->GetType(typeStr); - uint16_t phase; - (*aDOMEvent)->GetEventPhase(&phase); - timelines->AddMarkerForDocShell(docShell, Move( - MakeUnique( - typeStr, phase, MarkerTracingType::START))); - } - } - } - - if (NS_FAILED(HandleEventSubType(listener, *aDOMEvent, aCurrentTarget))) { - aEvent->mFlags.mExceptionHasBeenRisen = true; - } - - if (needsEndEventMarker) { - timelines->AddMarkerForDocShell( - docShell, "DOMEvent", MarkerTracingType::END); - } + if (needsEndEventMarker) { + timelines->AddMarkerForDocShell( + docShell, "DOMEvent", MarkerTracingType::END); } } } } - - // If we didn't find any matching listeners, and our event has a legacy - // version, we'll now switch to looking for that legacy version and we'll - // recheck our listeners. - if (hasListener || usingLegacyMessage) { - // (No need to recheck listeners, because we already found a match, or we - // already rechecked them.) - break; - } - EventMessage legacyEventMessage = GetLegacyEventMessage(eventMessage); - if (legacyEventMessage == eventMessage) { - break; // There's no legacy version of our event; no need to recheck. - } - MOZ_ASSERT(GetLegacyEventMessage(legacyEventMessage) == legacyEventMessage, - "Legacy event messages should not themselves have legacy versions"); - - // Recheck our listeners, using the legacy event message we just looked up: - eventMessage = legacyEventMessage; - usingLegacyMessage = true; } aEvent->currentTarget = nullptr; diff --git a/dom/events/EventListenerManager.h b/dom/events/EventListenerManager.h index fbe5a737e5ed..85660e77b37a 100644 --- a/dom/events/EventListenerManager.h +++ b/dom/events/EventListenerManager.h @@ -571,9 +571,7 @@ protected: nsPIDOMWindowInner* GetInnerWindowForTarget(); already_AddRefed GetTargetAsInnerWindow() const; - bool ListenerCanHandle(const Listener* aListener, - const WidgetEvent* aEvent, - EventMessage aEventMessage) const; + bool ListenerCanHandle(Listener* aListener, WidgetEvent* aEvent); // BE AWARE, a lot of instances of EventListenerManager will be created. // Therefor, we need to keep this class compact. When you add integer diff --git a/dom/events/EventNameList.h b/dom/events/EventNameList.h index b3846b3ee3d5..1fb978f32ef6 100644 --- a/dom/events/EventNameList.h +++ b/dom/events/EventNameList.h @@ -924,7 +924,6 @@ NON_IDL_EVENT(MozEdgeUICompleted, EventNameType_None, eSimpleGestureEventClass) -// CSS Transition & Animation events: NON_IDL_EVENT(transitionend, eTransitionEnd, EventNameType_None, @@ -942,24 +941,6 @@ NON_IDL_EVENT(animationiteration, EventNameType_None, eAnimationEventClass) -// Webkit-prefixed versions of Transition & Animation events, for web compat: -NON_IDL_EVENT(webkitTransitionEnd, - eWebkitTransitionEnd, - EventNameType_None, - eTransitionEventClass) -NON_IDL_EVENT(webkitAnimationEnd, - eWebkitAnimationEnd, - EventNameType_None, - eAnimationEventClass) -NON_IDL_EVENT(webkitAnimationIteration, - eWebkitAnimationIteration, - EventNameType_None, - eAnimationEventClass) -NON_IDL_EVENT(webkitAnimationStart, - eWebkitAnimationStart, - EventNameType_None, - eAnimationEventClass) - NON_IDL_EVENT(audioprocess, eAudioProcess, EventNameType_None, diff --git a/dom/events/test/mochitest.ini b/dom/events/test/mochitest.ini index 91e6582dc273..732087811a38 100644 --- a/dom/events/test/mochitest.ini +++ b/dom/events/test/mochitest.ini @@ -168,7 +168,6 @@ skip-if = toolkit == 'android' #CRASH_DUMP, RANDOM [test_eventTimeStamp.html] [test_focus_disabled.html] skip-if = buildapp == 'mulet' -[test_legacy_event.html] [test_messageEvent.html] [test_moz_mouse_pixel_scroll_event.html] skip-if = buildapp == 'b2g' # bug 1126090, no wheel events on b2g diff --git a/dom/events/test/test_legacy_event.html b/dom/events/test/test_legacy_event.html deleted file mode 100644 index c877975e0807..000000000000 --- a/dom/events/test/test_legacy_event.html +++ /dev/null @@ -1,256 +0,0 @@ - - - - - - Test for Bug 1236979 (events that have legacy alternative versions) - - - - - -Mozilla Bug 1236979 -

- -
-
-
- - diff --git a/widget/EventMessageList.h b/widget/EventMessageList.h index 4adadf6437d6..38d4deb9a6ff 100644 --- a/widget/EventMessageList.h +++ b/widget/EventMessageList.h @@ -312,18 +312,12 @@ NS_EVENT_MESSAGE(eGestureNotify) NS_EVENT_MESSAGE(eScrolledAreaChanged) -// CSS Transition & Animation events: NS_EVENT_MESSAGE(eTransitionEnd) + NS_EVENT_MESSAGE(eAnimationStart) NS_EVENT_MESSAGE(eAnimationEnd) NS_EVENT_MESSAGE(eAnimationIteration) -// Webkit-prefixed versions of Transition & Animation events, for web compat: -NS_EVENT_MESSAGE(eWebkitTransitionEnd) -NS_EVENT_MESSAGE(eWebkitAnimationStart) -NS_EVENT_MESSAGE(eWebkitAnimationEnd) -NS_EVENT_MESSAGE(eWebkitAnimationIteration) - NS_EVENT_MESSAGE(eSMILBeginEvent) NS_EVENT_MESSAGE(eSMILEndEvent) NS_EVENT_MESSAGE(eSMILRepeatEvent)