mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 847596 - Paris binding for DeviceMotionEvent, r=peterv
--HG-- extra : rebase_source : 7cbf9ac11b81506a2ffe0a5c3a34ecb78fe54f5b
This commit is contained in:
parent
e90a629735
commit
53d9f3b057
@ -5,6 +5,9 @@
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsDOMDeviceMotionEvent.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAcceleration)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAccelerationIncludingGravity)
|
||||
@ -46,12 +49,31 @@ nsDOMDeviceMotionEvent::InitDeviceMotionEvent(const nsAString & aEventTypeArg,
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
nsDOMDeviceMotionEvent::InitDeviceMotionEvent(const nsAString& aType,
|
||||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
nsIDOMDeviceAcceleration* aAcceleration,
|
||||
nsIDOMDeviceAcceleration* aAccelerationIncludingGravity,
|
||||
nsIDOMDeviceRotationRate* aRotationRate,
|
||||
double aInterval,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
aRv = InitDeviceMotionEvent(aType,
|
||||
aCanBubble,
|
||||
aCancelable,
|
||||
aAcceleration,
|
||||
aAccelerationIncludingGravity,
|
||||
aRotationRate,
|
||||
aInterval);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMDeviceMotionEvent::GetAcceleration(nsIDOMDeviceAcceleration **aAcceleration)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAcceleration);
|
||||
|
||||
NS_IF_ADDREF(*aAcceleration = mAcceleration);
|
||||
NS_IF_ADDREF(*aAcceleration = GetAcceleration());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -60,7 +82,8 @@ nsDOMDeviceMotionEvent::GetAccelerationIncludingGravity(nsIDOMDeviceAcceleration
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aAccelerationIncludingGravity);
|
||||
|
||||
NS_IF_ADDREF(*aAccelerationIncludingGravity = mAccelerationIncludingGravity);
|
||||
NS_IF_ADDREF(*aAccelerationIncludingGravity =
|
||||
GetAccelerationIncludingGravity());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -69,7 +92,7 @@ nsDOMDeviceMotionEvent::GetRotationRate(nsIDOMDeviceRotationRate **aRotationRate
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aRotationRate);
|
||||
|
||||
NS_IF_ADDREF(*aRotationRate = mRotationRate);
|
||||
NS_IF_ADDREF(*aRotationRate = GetRotationRate());
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -78,7 +101,7 @@ nsDOMDeviceMotionEvent::GetInterval(double *aInterval)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aInterval);
|
||||
|
||||
*aInterval = mInterval;
|
||||
*aInterval = Interval();
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@
|
||||
#include "nsIDOMDeviceMotionEvent.h"
|
||||
#include "nsDOMEvent.h"
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/dom/DeviceMotionEventBinding.h"
|
||||
|
||||
class nsDOMDeviceRotationRate MOZ_FINAL : public nsIDOMDeviceRotationRate
|
||||
{
|
||||
@ -47,7 +48,9 @@ public:
|
||||
nsDOMDeviceMotionEvent(mozilla::dom::EventTarget* aOwner,
|
||||
nsPresContext* aPresContext, nsEvent* aEvent)
|
||||
: nsDOMEvent(aOwner, aPresContext, aEvent)
|
||||
{}
|
||||
{
|
||||
SetIsDOMBinding();
|
||||
}
|
||||
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
@ -59,6 +62,40 @@ public:
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(nsDOMDeviceMotionEvent, nsDOMEvent)
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx, JSObject* aScope)
|
||||
{
|
||||
return mozilla::dom::DeviceMotionEventBinding::Wrap(aCx, aScope, this);
|
||||
}
|
||||
|
||||
nsIDOMDeviceAcceleration* GetAcceleration()
|
||||
{
|
||||
return mAcceleration;
|
||||
}
|
||||
|
||||
nsIDOMDeviceAcceleration* GetAccelerationIncludingGravity()
|
||||
{
|
||||
return mAccelerationIncludingGravity;
|
||||
}
|
||||
|
||||
nsIDOMDeviceRotationRate* GetRotationRate()
|
||||
{
|
||||
return mRotationRate;
|
||||
}
|
||||
|
||||
double Interval() const
|
||||
{
|
||||
return mInterval;
|
||||
}
|
||||
|
||||
void InitDeviceMotionEvent(const nsAString& aType,
|
||||
bool aCanBubble,
|
||||
bool aCancelable,
|
||||
nsIDOMDeviceAcceleration* aAcceleration,
|
||||
nsIDOMDeviceAcceleration* aAccelerationIncludingGravity,
|
||||
nsIDOMDeviceRotationRate* aRotationRate,
|
||||
double aInterval,
|
||||
mozilla::ErrorResult& aRv);
|
||||
|
||||
nsCOMPtr<nsIDOMDeviceAcceleration> mAcceleration;
|
||||
nsCOMPtr<nsIDOMDeviceAcceleration> mAccelerationIncludingGravity;
|
||||
nsCOMPtr<nsIDOMDeviceRotationRate> mRotationRate;
|
||||
|
@ -24,16 +24,39 @@ var checkMotion = function(event) {
|
||||
window.removeEventListener("devicemotion", checkMotion, true);
|
||||
|
||||
is(event.acceleration.x, 1.5);
|
||||
is(event.acceleration.y, 1.5);
|
||||
is(event.acceleration.z, 1.5);
|
||||
is(event.acceleration.y, 2.5);
|
||||
is(event.acceleration.z, 3.5);
|
||||
|
||||
is(event.accelerationIncludingGravity.x, 1.5);
|
||||
is(event.accelerationIncludingGravity.y, 1.5);
|
||||
is(event.accelerationIncludingGravity.z, 1.5);
|
||||
is(event.accelerationIncludingGravity.x, 4.5);
|
||||
is(event.accelerationIncludingGravity.y, 5.5);
|
||||
is(event.accelerationIncludingGravity.z, 6.5);
|
||||
|
||||
is(event.rotationRate.alpha, 7.5);
|
||||
is(event.rotationRate.beta, 8.5);
|
||||
is(event.rotationRate.gamma, 9.5);
|
||||
|
||||
var e = document.createEvent("DeviceMotionEvent");
|
||||
e.initDeviceMotionEvent('devicemotion', true, true,
|
||||
null, null, null, 0);
|
||||
is(e.acceleration, null);
|
||||
is(e.accelerationIncludingGravity, null);
|
||||
is(e.rotationRate, null);
|
||||
|
||||
e.initDeviceMotionEvent('devicemotion', true, true,
|
||||
{}, {}, {}, 0);
|
||||
|
||||
ok(isNaN(e.acceleration.x));
|
||||
ok(isNaN(e.acceleration.y));
|
||||
ok(isNaN(e.acceleration.z));
|
||||
|
||||
ok(isNaN(e.accelerationIncludingGravity.x));
|
||||
ok(isNaN(e.accelerationIncludingGravity.y));
|
||||
ok(isNaN(e.accelerationIncludingGravity.z));
|
||||
|
||||
ok(isNaN(e.rotationRate.alpha));
|
||||
ok(isNaN(e.rotationRate.beta));
|
||||
ok(isNaN(e.rotationRate.gamma));
|
||||
|
||||
is(event.rotationRate.alpha, 1.5);
|
||||
is(event.rotationRate.beta, 1.5);
|
||||
is(event.rotationRate.gamma, 1.5);
|
||||
SimpleTest.finish();
|
||||
};
|
||||
|
||||
@ -44,9 +67,9 @@ ok(!!event, "Should have seen DeviceMotionEvent!");
|
||||
|
||||
event = document.createEvent("DeviceMotionEvent");
|
||||
event.initDeviceMotionEvent('devicemotion', true, true,
|
||||
{x:1.5,y:1.5,z:1.5},
|
||||
{x:1.5,y:1.5,z:1.5},
|
||||
{alpha:1.5,beta:1.5,gamma:1.5},
|
||||
{x:1.5,y:2.5,z:3.5},
|
||||
{x:4.5,y:5.5,z:6.5},
|
||||
{alpha:7.5,beta:8.5,gamma:9.5},
|
||||
0);
|
||||
window.dispatchEvent(event);
|
||||
|
||||
|
@ -229,6 +229,10 @@ DOMInterfaces = {
|
||||
'headerFile': 'mozilla/dom/DesktopNotification.h',
|
||||
},
|
||||
|
||||
'DeviceMotionEvent': {
|
||||
'nativeType': 'nsDOMDeviceMotionEvent',
|
||||
},
|
||||
|
||||
'Document': [
|
||||
{
|
||||
'nativeType': 'nsIDocument',
|
||||
@ -1472,6 +1476,8 @@ addExternalIface('CanvasGradient', headerFile='nsIDOMCanvasRenderingContext2D.h'
|
||||
addExternalIface('CanvasPattern', headerFile='nsIDOMCanvasRenderingContext2D.h')
|
||||
addExternalIface('Counter')
|
||||
addExternalIface('CSSRule')
|
||||
addExternalIface('DeviceAcceleration', headerFile='nsIDOMDeviceMotionEvent.h', notflattened=True)
|
||||
addExternalIface('DeviceRotationRate', headerFile='nsIDOMDeviceMotionEvent.h', notflattened=True)
|
||||
addExternalIface('DOMError')
|
||||
addExternalIface('CSSRuleList')
|
||||
addExternalIface('DOMStringList')
|
||||
|
26
dom/webidl/DeviceMotionEvent.webidl
Normal file
26
dom/webidl/DeviceMotionEvent.webidl
Normal file
@ -0,0 +1,26 @@
|
||||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
interface DeviceAcceleration;
|
||||
interface DeviceRotationRate;
|
||||
|
||||
interface DeviceMotionEvent : Event
|
||||
{
|
||||
[Throws]
|
||||
void initDeviceMotionEvent(DOMString type,
|
||||
boolean canBubble,
|
||||
boolean cancelable,
|
||||
DeviceAcceleration? acceleration,
|
||||
DeviceAcceleration? accelerationIncludingGravity,
|
||||
DeviceRotationRate? rotationRate,
|
||||
double interval);
|
||||
|
||||
readonly attribute DeviceAcceleration? acceleration;
|
||||
readonly attribute DeviceAcceleration? accelerationIncludingGravity;
|
||||
readonly attribute DeviceRotationRate? rotationRate;
|
||||
readonly attribute double interval;
|
||||
};
|
||||
|
@ -46,6 +46,7 @@ webidl_files = \
|
||||
CSSValueList.webidl \
|
||||
DelayNode.webidl \
|
||||
DesktopNotification.webidl \
|
||||
DeviceMotionEvent.webidl \
|
||||
Document.webidl \
|
||||
DocumentFragment.webidl \
|
||||
DocumentType.webidl \
|
||||
|
Loading…
Reference in New Issue
Block a user