Bug 911987 part 4 - Add onwebkitanimation** and onwebkittransitionend event handlers. r?smaug
Add the onwebkit prefixed event handler attributes of CSS-Animation
and CSS-Transition.
We need to support both content attributes and IDL attributes like
onanimation** attributes.
We should support attribute of lower-case and mixed-case. But currently
Gecko defined as mixed-case only. [1][2]
[1] https://dxr.mozilla.org/mozilla-central/rev/6608e5864780589b25d5421c3d3673ab30c4c318/dom/base/nsContentUtils.cpp#747
[2] https://dxr.mozilla.org/mozilla-central/rev/6608e5864780589b25d5421c3d3673ab30c4c318/dom/events/EventNameList.h#977
So we can't find the related Atom when we set content attributes as lower-case. [3]
[3] https://dxr.mozilla.org/mozilla-central/rev/6608e5864780589b25d5421c3d3673ab30c4c318/dom/base/nsGlobalWindow.h#818
In this patch, I add two Atoms in order to support mixed and lower case.
MozReview-Commit-ID: 8nOfVGQ8h7R
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -947,16 +947,20 @@ GK_ATOM(onupgradeneeded, "onupgradeneede
GK_ATOM(onussdreceived, "onussdreceived")
GK_ATOM(onversionchange, "onversionchange")
GK_ATOM(onvoicechange, "onvoicechange")
GK_ATOM(onvoiceschanged, "onvoiceschanged")
GK_ATOM(onwebkitAnimationEnd, "onwebkitAnimationEnd")
GK_ATOM(onwebkitAnimationIteration, "onwebkitAnimationIteration")
GK_ATOM(onwebkitAnimationStart, "onwebkitAnimationStart")
GK_ATOM(onwebkitTransitionEnd, "onwebkitTransitionEnd")
+GK_ATOM(onwebkitanimationend, "onwebkitanimationend")
+GK_ATOM(onwebkitanimationiteration, "onwebkitanimationiteration")
+GK_ATOM(onwebkitanimationstart, "onwebkitanimationstart")
+GK_ATOM(onwebkittransitionend, "onwebkittransitionend")
GK_ATOM(onwebsocket, "onwebsocket")
GK_ATOM(onwheel, "onwheel")
GK_ATOM(open, "open")
GK_ATOM(optgroup, "optgroup")
GK_ATOM(optimum, "optimum")
GK_ATOM(option, "option")
GK_ATOM(_or, "or")
GK_ATOM(order, "order")
--- a/dom/events/EventNameList.h
+++ b/dom/events/EventNameList.h
@@ -969,32 +969,50 @@ EVENT(animationend,
EventNameType_All,
eAnimationEventClass)
EVENT(animationiteration,
eAnimationIteration,
EventNameType_All,
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)
+EVENT(webkitAnimationEnd,
+ eWebkitAnimationEnd,
+ EventNameType_All,
+ eAnimationEventClass)
+EVENT(webkitAnimationIteration,
+ eWebkitAnimationIteration,
+ EventNameType_All,
+ eAnimationEventClass)
+EVENT(webkitAnimationStart,
+ eWebkitAnimationStart,
+ EventNameType_All,
+ eAnimationEventClass)
+EVENT(webkitTransitionEnd,
+ eWebkitTransitionEnd,
+ EventNameType_All,
+ eTransitionEventClass)
+#ifndef MESSAGE_TO_EVENT
+EVENT(webkitanimationend,
+ eWebkitAnimationEnd,
+ EventNameType_All,
+ eAnimationEventClass)
+EVENT(webkitanimationiteration,
+ eWebkitAnimationIteration,
+ EventNameType_All,
+ eAnimationEventClass)
+EVENT(webkitanimationstart,
+ eWebkitAnimationStart,
+ EventNameType_All,
+ eAnimationEventClass)
+EVENT(webkittransitionend,
+ eWebkitTransitionEnd,
+ EventNameType_All,
+ eTransitionEventClass)
+#endif
NON_IDL_EVENT(audioprocess,
eAudioProcess,
EventNameType_None,
eBasicEventClass)
NON_IDL_EVENT(complete,
eAudioComplete,
--- a/dom/webidl/EventHandler.webidl
+++ b/dom/webidl/EventHandler.webidl
@@ -126,16 +126,23 @@ interface GlobalEventHandlers {
[Pref="pointer-lock-api.prefixed.enabled"]
attribute EventHandler onmozpointerlockerror;
// CSS-Animation and CSS-Transition handlers.
attribute EventHandler onanimationend;
attribute EventHandler onanimationiteration;
attribute EventHandler onanimationstart;
attribute EventHandler ontransitionend;
+
+ // CSS-Animation and CSS-Transition legacy handlers.
+ // This handler isn't standard.
+ attribute EventHandler onwebkitanimationend;
+ attribute EventHandler onwebkitanimationiteration;
+ attribute EventHandler onwebkitanimationstart;
+ attribute EventHandler onwebkittransitionend;
};
[NoInterfaceObject]
interface WindowEventHandlers {
attribute EventHandler onafterprint;
attribute EventHandler onbeforeprint;
attribute OnBeforeUnloadEventHandler onbeforeunload;
attribute EventHandler onhashchange;
--- a/layout/style/test/test_animations_event_handler_attribute.html
+++ b/layout/style/test/test_animations_event_handler_attribute.html
@@ -49,23 +49,22 @@ function handleEvent(event) {
if (event.target.receivedEventType) {
ok(false, `Received ${event.type} event, but this element have previous `
`received event '${event.target.receivedEventType}'.`);
return;
}
event.target.receivedEventType = event.type;
}
-function checkReceivedEvents(eventType, elements, evalFunc) {
- if (!evalFunc) { evalFunc = is; }
+function checkReceivedEvents(eventType, elements) {
elements.forEach(element => {
- evalFunc(element.receivedEventType, eventType,
- `Expected to receive '${eventType}', got
- '${element.receivedEventType}', for event handler registered
- using ${element.handlerType}`);
+ is(element.receivedEventType, eventType,
+ `Expected to receive '${eventType}', got
+ '${element.receivedEventType}', for event handler registered
+ using ${element.handlerType}`);
element.receivedEventType = undefined;
});
}
// Take over the refresh driver right from the start.
advance_clock(0);
// 1. Test CSS Animation event handlers.
@@ -111,39 +110,39 @@ var targets = createAndRegisterTargets([
'onwebkitanimationiteration',
'onwebkitanimationend' ]);
targets.forEach(div => {
div.setAttribute('style', 'animation: anim 100ms 2');
getComputedStyle(div).animationName; // flush
});
advance_clock(0);
-checkReceivedEvents("webkitAnimationStart", targets, todo_is);
+checkReceivedEvents("webkitAnimationStart", targets);
advance_clock(100);
-checkReceivedEvents("webkitAnimationIteration", targets, todo_is);
+checkReceivedEvents("webkitAnimationIteration", targets);
advance_clock(200);
-checkReceivedEvents("webkitAnimationEnd", targets, todo_is);
+checkReceivedEvents("webkitAnimationEnd", targets);
targets.forEach(div => { div.remove(); });
// 4. Test prefixed CSS Transition event handlers.
advance_clock(0);
var targets = createAndRegisterTargets([ 'onwebkittransitionend' ]);
targets.forEach(div => {
div.style.transition = 'margin-left 100ms';
getComputedStyle(div).marginLeft; // flush
div.style.marginLeft = "200px";
getComputedStyle(div).marginLeft; // flush
});
advance_clock(100);
-checkReceivedEvents("webkitTransitionEnd", targets, todo_is);
+checkReceivedEvents("webkitTransitionEnd", targets);
targets.forEach(div => { div.remove(); });
SpecialPowers.DOMWindowUtils.restoreNormalRefresh();
</script>
</body>
</html>