diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp index 0c36faf6a0d..6a6f64fb77b 100644 --- a/dom/base/nsContentUtils.cpp +++ b/dom/base/nsContentUtils.cpp @@ -639,6 +639,22 @@ nsContentUtils::InitializeModifierStrings() sModifierSeparator = new nsString(modifierSeparator); } +// Because of SVG/SMIL we have several atoms mapped to the same +// id, but we can rely on ID_TO_EVENT to map id to only one atom. +static bool +ShouldAddEventToStringEventTable(const EventNameMapping& aMapping) +{ + switch(aMapping.mId) { +#define ID_TO_EVENT(name_, id_, type_, struct_) \ + case id_: return nsGkAtoms::on##name_ == aMapping.mAtom; +#include "mozilla/EventNameList.h" +#undef ID_TO_EVENT + default: + break; + } + return false; +} + bool nsContentUtils::InitializeEventTable() { NS_ASSERTION(!sAtomEventTable, "EventTable already initialized!"); @@ -651,6 +667,7 @@ nsContentUtils::InitializeEventTable() { #define NON_IDL_EVENT EVENT #include "mozilla/EventNameList.h" #undef WINDOW_ONLY_EVENT +#undef NON_IDL_EVENT #undef EVENT { nullptr } }; @@ -664,8 +681,11 @@ nsContentUtils::InitializeEventTable() { // Subtract one from the length because of the trailing null for (uint32_t i = 0; i < ArrayLength(eventArray) - 1; ++i) { sAtomEventTable->Put(eventArray[i].mAtom, eventArray[i]); - sStringEventTable->Put(Substring(nsDependentAtomString(eventArray[i].mAtom), 2), - eventArray[i]); + if (ShouldAddEventToStringEventTable(eventArray[i])) { + sStringEventTable->Put( + Substring(nsDependentAtomString(eventArray[i].mAtom), 2), + eventArray[i]); + } } return true; diff --git a/dom/smil/test/test_smilTimeEvents.xhtml b/dom/smil/test/test_smilTimeEvents.xhtml index 53b47466e6d..f1e26fe82e3 100644 --- a/dom/smil/test/test_smilTimeEvents.xhtml +++ b/dom/smil/test/test_smilTimeEvents.xhtml @@ -287,6 +287,13 @@ gAnim.addEventListener("beginEvent", handleOnBegin, false); gAnim.addEventListener("repeatEvent", handleOnRepeat, false); gAnim.addEventListener("endEvent", handleOnEnd, false); gCircle.addEventListener("beginEvent", parentHandler, false); + +var expectedEvents = + ["begin", "beginEvent", "repeat", "repeatEvent", "end", "endEvent", "SVGZoom", "zoom"]; + +for (var i = 0; i < expectedEvents.length; ++i) { + is((new Event(expectedEvents[i])).type, expectedEvents[i], "Unexpected event type!"); +} ]]>