mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Bug 667919 - Add support for window.ondevicemotion and window.ondeviceorientation. r=smaug
This commit is contained in:
parent
0ae15196ba
commit
6143433d38
@ -564,6 +564,9 @@ nsContentUtils::InitializeEventTable() {
|
||||
{ nsGkAtoms::onMozTouchMove, NS_MOZTOUCH_MOVE, EventNameType_None, NS_MOZTOUCH_EVENT },
|
||||
{ nsGkAtoms::onMozTouchUp, NS_MOZTOUCH_UP, EventNameType_None, NS_MOZTOUCH_EVENT },
|
||||
|
||||
{ nsGkAtoms::ondevicemotion, NS_DEVICE_MOTION, EventNameType_None, NS_EVENT },
|
||||
{ nsGkAtoms::ondeviceorientation, NS_DEVICE_ORIENTATION, EventNameType_None, NS_EVENT },
|
||||
|
||||
{ nsGkAtoms::ontransitionend, NS_TRANSITION_END, EventNameType_None, NS_TRANSITION_EVENT },
|
||||
{ nsGkAtoms::onanimationstart, NS_ANIMATION_START, EventNameType_None, NS_ANIMATION_EVENT },
|
||||
{ nsGkAtoms::onanimationend, NS_ANIMATION_END, EventNameType_None, NS_ANIMATION_EVENT },
|
||||
|
@ -108,7 +108,9 @@ static const char* const sEventNames[] = {
|
||||
"transitionend",
|
||||
"animationstart",
|
||||
"animationend",
|
||||
"animationiteration"
|
||||
"animationiteration",
|
||||
"devicemotion",
|
||||
"deviceorientation"
|
||||
};
|
||||
|
||||
static char *sPopupAllowedEvents;
|
||||
@ -1361,6 +1363,10 @@ const char* nsDOMEvent::GetEventName(PRUint32 aEventType)
|
||||
return sEventNames[eDOMEvents_animationend];
|
||||
case NS_ANIMATION_ITERATION:
|
||||
return sEventNames[eDOMEvents_animationiteration];
|
||||
case NS_DEVICE_MOTION:
|
||||
return sEventNames[eDOMEvents_devicemotion];
|
||||
case NS_DEVICE_ORIENTATION:
|
||||
return sEventNames[eDOMEvents_deviceorientation];
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -192,7 +192,9 @@ public:
|
||||
eDOMEvents_transitionend,
|
||||
eDOMEvents_animationstart,
|
||||
eDOMEvents_animationend,
|
||||
eDOMEvents_animationiteration
|
||||
eDOMEvents_animationiteration,
|
||||
eDOMEvents_devicemotion,
|
||||
eDOMEvents_deviceorientation
|
||||
};
|
||||
|
||||
nsDOMEvent(nsPresContext* aPresContext, nsEvent* aEvent);
|
||||
|
@ -104,7 +104,9 @@ _TEST_FILES = \
|
||||
test_bug656379-1.html \
|
||||
test_bug656379-2.html \
|
||||
test_bug656954.html \
|
||||
test_bug662678.html \
|
||||
test_bug662678.html \
|
||||
test_bug667919-1.html \
|
||||
test_bug667919-2.html \
|
||||
$(NULL)
|
||||
|
||||
#bug 585630
|
||||
|
42
content/events/test/test_bug667919-1.html
Normal file
42
content/events/test/test_bug667919-1.html
Normal file
@ -0,0 +1,42 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=615597
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 615597</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=615597">Mozilla Bug 615597</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 615597 **/
|
||||
|
||||
window.ondeviceorientation = function(event) {
|
||||
is(event.alpha, 1.5);
|
||||
is(event.beta, 2.25);
|
||||
is(event.gamma, 3.667);
|
||||
is(event.absolute, true);
|
||||
SimpleTest.finish();
|
||||
};
|
||||
|
||||
var event = DeviceOrientationEvent;
|
||||
ok(!!event, "Should have seen DeviceOrientationEvent!");
|
||||
|
||||
event = document.createEvent("DeviceOrientationEvent");
|
||||
event.initDeviceOrientationEvent('deviceorientation', true, true, 1.5, 2.25, 3.667, true);
|
||||
window.dispatchEvent(event);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
42
content/events/test/test_bug667919-2.html
Normal file
42
content/events/test/test_bug667919-2.html
Normal file
@ -0,0 +1,42 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=615597
|
||||
-->
|
||||
<head>
|
||||
<title>Test for Bug 615597</title>
|
||||
<script type="application/javascript" src="/MochiKit/packed.js"></script>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=615597">Mozilla Bug 615597</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/** Test for Bug 615597 **/
|
||||
|
||||
window.ondeviceorientation = function(event) {
|
||||
is(event.alpha, 1.5);
|
||||
is(event.beta, 2.25);
|
||||
is(event.gamma, 3.667);
|
||||
is(event.absolute, true);
|
||||
SimpleTest.finish();
|
||||
};
|
||||
|
||||
var event = DeviceOrientationEvent;
|
||||
ok(!!event, "Should have seen DeviceOrientationEvent!");
|
||||
|
||||
event = document.createEvent("DeviceOrientationEvent");
|
||||
event.initDeviceOrientationEvent('deviceorientation', true, true, 1.5, 2.25, 3.667, true);
|
||||
window.dispatchEvent(event);
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
@ -1707,6 +1707,9 @@ jsid nsDOMClassInfo::sOntouchcancel_id = JSID_VOID;
|
||||
jsid nsDOMClassInfo::sOnbeforeprint_id = JSID_VOID;
|
||||
jsid nsDOMClassInfo::sOnafterprint_id = JSID_VOID;
|
||||
|
||||
jsid nsDOMClassInfo::sOndevicemotion_id = JSID_VOID;
|
||||
jsid nsDOMClassInfo::sOndeviceorientation_id = JSID_VOID;
|
||||
|
||||
static const JSClass *sObjectClass = nsnull;
|
||||
|
||||
/**
|
||||
@ -2043,6 +2046,9 @@ nsDOMClassInfo::DefineStaticJSVals(JSContext *cx)
|
||||
SET_JSID_TO_STRING(sOntouchcancel_id, cx, "ontouchcancel");
|
||||
SET_JSID_TO_STRING(sOnbeforeprint_id, cx, "onbeforeprint");
|
||||
SET_JSID_TO_STRING(sOnafterprint_id, cx, "onafterprint");
|
||||
|
||||
SET_JSID_TO_STRING(sOndevicemotion_id, cx, "ondevicemotion");
|
||||
SET_JSID_TO_STRING(sOndeviceorientation_id, cx, "ondeviceorientation");
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
@ -7653,7 +7659,9 @@ nsEventReceiverSH::ReallyIsEventName(jsid id, jschar aFirstChar)
|
||||
id == sOndragover_id ||
|
||||
id == sOndragstart_id ||
|
||||
id == sOndrop_id ||
|
||||
id == sOndurationchange_id);
|
||||
id == sOndurationchange_id ||
|
||||
id == sOndeviceorientation_id ||
|
||||
id == sOndevicemotion_id );
|
||||
case 'e' :
|
||||
return (id == sOnerror_id ||
|
||||
id == sOnemptied_id ||
|
||||
|
@ -367,6 +367,9 @@ public:
|
||||
static jsid sOnbeforeprint_id;
|
||||
static jsid sOnafterprint_id;
|
||||
|
||||
static jsid sOndevicemotion_id;
|
||||
static jsid sOndeviceorientation_id;
|
||||
|
||||
protected:
|
||||
static JSPropertyOp sXPCNativeWrapperGetPropertyOp;
|
||||
static JSPropertyOp sXrayWrapperPropertyHolderGetPropertyOp;
|
||||
|
@ -533,6 +533,11 @@ class nsHashKey;
|
||||
#define NS_OPEN (NS_OPENCLOSE_EVENT_START)
|
||||
#define NS_CLOSE (NS_OPENCLOSE_EVENT_START+1)
|
||||
|
||||
// Device motion and orientation
|
||||
#define NS_DEVICE_ORIENTATION_START 4900
|
||||
#define NS_DEVICE_ORIENTATION (NS_DEVICE_ORIENTATION_START)
|
||||
#define NS_DEVICE_MOTION (NS_DEVICE_ORIENTATION_START+1)
|
||||
|
||||
/**
|
||||
* Return status for event processors, nsEventStatus, is defined in
|
||||
* nsEvent.h.
|
||||
|
Loading…
Reference in New Issue
Block a user