mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1425874
- Implement marquee onbounce, onfinish, onstart with WebIDL r=bzbarsky
Differential Revision: https://phabricator.services.mozilla.com/D9970 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
35b0511c9a
commit
1baf74c1d9
@ -177,6 +177,7 @@ enum EventNameType {
|
||||
EventNameType_SVGSVG = 0x0008, // the svg element
|
||||
EventNameType_SMIL = 0x0010, // smil elements
|
||||
EventNameType_HTMLBodyOrFramesetOnly = 0x0020,
|
||||
EventNameType_HTMLMarqueeOnly = 0x0040,
|
||||
|
||||
EventNameType_HTMLXUL = 0x0003,
|
||||
EventNameType_All = 0xFFFF
|
||||
|
@ -152,6 +152,10 @@ EVENT(abort,
|
||||
eImageAbort,
|
||||
EventNameType_All,
|
||||
eBasicEventClass)
|
||||
EVENT(bounce,
|
||||
eMarqueeBounce,
|
||||
EventNameType_HTMLMarqueeOnly,
|
||||
eBasicEventClass)
|
||||
EVENT(canplay,
|
||||
eCanPlay,
|
||||
EventNameType_HTML,
|
||||
@ -242,6 +246,10 @@ EVENT(ended,
|
||||
eEnded,
|
||||
EventNameType_HTML,
|
||||
eBasicEventClass)
|
||||
EVENT(finish,
|
||||
eMarqueeFinish,
|
||||
EventNameType_HTMLMarqueeOnly,
|
||||
eBasicEventClass)
|
||||
EVENT(fullscreenchange,
|
||||
eFullscreenChange,
|
||||
EventNameType_HTML,
|
||||
@ -441,6 +449,10 @@ EVENT(stalled,
|
||||
eStalled,
|
||||
EventNameType_HTML,
|
||||
eBasicEventClass)
|
||||
EVENT(start,
|
||||
eMarqueeStart,
|
||||
EventNameType_HTMLMarqueeOnly,
|
||||
eBasicEventClass)
|
||||
EVENT(submit,
|
||||
eFormSubmit,
|
||||
EventNameType_HTMLXUL,
|
||||
|
@ -210,6 +210,7 @@ skip-if = toolkit == 'android'
|
||||
support-files = file_bug1484371.html
|
||||
[test_dnd_with_modifiers.html]
|
||||
[test_hover_mouseleave.html]
|
||||
[test_marquee_events.html]
|
||||
[test_slotted_mouse_event.html]
|
||||
[test_slotted_text_click.html]
|
||||
[test_unbound_before_in_active_chain.html]
|
||||
|
31
dom/events/test/test_marquee_events.html
Normal file
31
dom/events/test/test_marquee_events.html
Normal file
@ -0,0 +1,31 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for bug 1425874</title>
|
||||
<link rel="stylesheet" href="/tests/SimpleTest/test.css">
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script type="text/javascript" src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<script>
|
||||
var wasEventCalled;
|
||||
function callEventWithAttributeHandler(element, evt) {
|
||||
wasEventCalled = false;
|
||||
let el = document.createElement(element);
|
||||
el.setAttribute(`on${evt}`, "wasEventCalled = true");
|
||||
el.dispatchEvent(new Event(evt));
|
||||
return wasEventCalled;
|
||||
}
|
||||
|
||||
info("Make sure the EventNameType_HTMLMarqueeOnly events only compile for marquee");
|
||||
|
||||
ok(!callEventWithAttributeHandler("div", "bounce"), "no onbounce for div");
|
||||
ok(!callEventWithAttributeHandler("div", "finish"), "no onfinish for div");
|
||||
ok(!callEventWithAttributeHandler("div", "start"), "no onstart for div");
|
||||
|
||||
ok(callEventWithAttributeHandler("marquee", "bounce"), "onbounce for marquee");
|
||||
ok(callEventWithAttributeHandler("marquee", "finish"), "onfinish for marquee");
|
||||
ok(callEventWithAttributeHandler("marquee", "start"), "onstart for marquee");
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
@ -51,6 +51,14 @@ static const nsAttrValue::EnumTable kDirectionTable[] = {
|
||||
// Default direction value is "left".
|
||||
static const nsAttrValue::EnumTable* kDefaultDirection = &kDirectionTable[0];
|
||||
|
||||
bool
|
||||
HTMLMarqueeElement::IsEventAttributeNameInternal(nsAtom *aName)
|
||||
{
|
||||
return nsContentUtils::IsEventAttributeName(aName,
|
||||
EventNameType_HTML |
|
||||
EventNameType_HTMLMarqueeOnly);
|
||||
}
|
||||
|
||||
JSObject*
|
||||
HTMLMarqueeElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
|
||||
{
|
||||
|
@ -31,6 +31,8 @@ public:
|
||||
static const int kDefaultScrollAmount = 6;
|
||||
static const int kDefaultScrollDelayMS = 85;
|
||||
|
||||
bool IsEventAttributeNameInternal(nsAtom *aName) override;
|
||||
|
||||
void SetStartStopCallback(FunctionStringCallback* aCallback);
|
||||
|
||||
void GetBehavior(nsAString& aValue);
|
||||
|
@ -26,9 +26,9 @@ interface HTMLMarqueeElement : HTMLElement {
|
||||
[CEReactions, SetterThrows] attribute unsigned long vspace;
|
||||
[CEReactions, SetterThrows] attribute DOMString width;
|
||||
|
||||
//attribute EventHandler onbounce;
|
||||
//attribute EventHandler onfinish;
|
||||
//attribute EventHandler onstart;
|
||||
attribute EventHandler onbounce;
|
||||
attribute EventHandler onfinish;
|
||||
attribute EventHandler onstart;
|
||||
|
||||
void start();
|
||||
void stop();
|
||||
|
@ -16,35 +16,6 @@
|
||||
<stylesheet src="chrome://xbl-marquee/content/xbl-marquee.css"/>
|
||||
</resources>
|
||||
<implementation>
|
||||
<property name="onstart" exposeToUntrustedContent="true">
|
||||
<getter>
|
||||
return this.getAttribute("onstart");
|
||||
</getter>
|
||||
<setter>
|
||||
this._setEventListener("start", val, true);
|
||||
this.setAttribute("onstart", val);
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
<property name="onfinish" exposeToUntrustedContent="true">
|
||||
<getter>
|
||||
return this.getAttribute("onfinish");
|
||||
</getter>
|
||||
<setter>
|
||||
this._setEventListener("finish", val, true);
|
||||
this.setAttribute("onfinish", val);
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
<property name="onbounce" exposeToUntrustedContent="true">
|
||||
<getter>
|
||||
return this.getAttribute("onbounce");
|
||||
</getter>
|
||||
<setter>
|
||||
this._setEventListener("bounce", val, true);
|
||||
this.setAttribute("onbounce", val);
|
||||
</setter>
|
||||
</property>
|
||||
|
||||
<property name="outerDiv"
|
||||
onget="return document.getAnonymousNodes(this)[0]"
|
||||
@ -89,73 +60,6 @@
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="_setEventListener">
|
||||
<parameter name="aName"/>
|
||||
<parameter name="aValue"/>
|
||||
<parameter name="aIgnoreNextCall"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
// _setEventListener is only used for setting the attribute event
|
||||
// handlers, which we want to ignore if our document is sandboxed
|
||||
// without the allow-scripts keyword.
|
||||
if (document.hasScriptsBlockedBySandbox) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// attribute event handlers should only be added if the
|
||||
// document's CSP allows it.
|
||||
if (!document.inlineScriptAllowedByCSP) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (this._ignoreNextCall) {
|
||||
return this._ignoreNextCall = false;
|
||||
}
|
||||
|
||||
if (aIgnoreNextCall) {
|
||||
this._ignoreNextCall = true;
|
||||
}
|
||||
|
||||
if (typeof this["_on" + aName] == 'function') {
|
||||
this.removeEventListener(aName, this["_on" + aName]);
|
||||
}
|
||||
|
||||
switch (typeof aValue)
|
||||
{
|
||||
case "function":
|
||||
this["_on" + aName] = aValue;
|
||||
this.addEventListener(aName, this["_on" + aName]);
|
||||
break;
|
||||
|
||||
case "string":
|
||||
if (!aIgnoreNextCall) {
|
||||
try {
|
||||
// Function Xrays make this simple and safe. \o/
|
||||
this["_on" + aName] = new window.Function("event", aValue);
|
||||
}
|
||||
catch(e) {
|
||||
return false;
|
||||
}
|
||||
this.addEventListener(aName, this["_on" + aName]);
|
||||
}
|
||||
else {
|
||||
this["_on" + aName] = aValue;
|
||||
}
|
||||
break;
|
||||
|
||||
case "object":
|
||||
this["_on" + aName] = aValue;
|
||||
break;
|
||||
|
||||
default:
|
||||
this._ignoreNextCall = false;
|
||||
throw new Error("Invalid argument for Marquee::on" + aName);
|
||||
}
|
||||
return true;
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<method name="_fireEvent">
|
||||
<parameter name="aName"/>
|
||||
<parameter name="aBubbles"/>
|
||||
@ -364,15 +268,6 @@
|
||||
case "direction":
|
||||
target._currentDirection = target.direction;
|
||||
break;
|
||||
case "onstart":
|
||||
target._setEventListener("start", newValue);
|
||||
break;
|
||||
case "onfinish":
|
||||
target._setEventListener("finish", newValue);
|
||||
break;
|
||||
case "onbounce":
|
||||
target._setEventListener("bounce", newValue);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -406,15 +301,11 @@
|
||||
var myThis = this;
|
||||
var lambda = function myScopeFunction() { if (myThis.init) myThis.init(); }
|
||||
|
||||
this._setEventListener("start", this.getAttribute("onstart"));
|
||||
this._setEventListener("finish", this.getAttribute("onfinish"));
|
||||
this._setEventListener("bounce", this.getAttribute("onbounce"));
|
||||
|
||||
this._mutationObserver = new MutationObserver(this._mutationActor);
|
||||
this._mutationObserver.observe(this, { attributes: true,
|
||||
attributeOldValue: true,
|
||||
attributeFilter: ['loop', '', 'behavior',
|
||||
'direction', 'width', 'height', 'onstart', 'onfinish', 'onbounce'] });
|
||||
'direction', 'width', 'height'] });
|
||||
|
||||
// init needs to be run after the page has loaded in order to calculate
|
||||
// the correct height/width
|
||||
|
@ -618,24 +618,6 @@
|
||||
[HTMLCanvasElement interface: document.createElement("canvas") must inherit property "transferControlToOffscreen()" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute onbounce]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute onfinish]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: attribute onstart]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "onbounce" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "onfinish" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLMarqueeElement interface: document.createElement("marquee") must inherit property "onstart" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLFrameSetElement interface: attribute onrejectionhandled]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -465,6 +465,11 @@ NS_EVENT_MESSAGE(eToggle)
|
||||
// Dialog element events.
|
||||
NS_EVENT_MESSAGE(eClose)
|
||||
|
||||
// Marquee element events.
|
||||
NS_EVENT_MESSAGE(eMarqueeBounce)
|
||||
NS_EVENT_MESSAGE(eMarqueeStart)
|
||||
NS_EVENT_MESSAGE(eMarqueeFinish)
|
||||
|
||||
#ifdef UNDEF_NS_EVENT_MESSAGE_FIRST_LAST
|
||||
#undef UNDEF_NS_EVENT_MESSAGE_FIRST_LAST
|
||||
#undef NS_EVENT_MESSAGE_FIRST_LAST
|
||||
|
Loading…
Reference in New Issue
Block a user