mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-24 05:11:16 +00:00
Bug 1234656 - Add TouchEvent ctor, r=mbrubeck
--HG-- extra : rebase_source : 8aa6e435587a2d8129955251abf5cba02fe7ac1d
This commit is contained in:
parent
d66b5a124f
commit
480b819b0d
@ -7,7 +7,6 @@
|
||||
#include "mozilla/dom/Touch.h"
|
||||
|
||||
#include "mozilla/dom/EventTarget.h"
|
||||
#include "mozilla/dom/TouchBinding.h"
|
||||
#include "mozilla/dom/TouchEvent.h"
|
||||
#include "nsGlobalWindow.h"
|
||||
#include "nsContentUtils.h"
|
||||
@ -16,6 +15,29 @@
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
// static
|
||||
already_AddRefed<Touch>
|
||||
Touch::Constructor(const GlobalObject& aGlobal,
|
||||
const TouchInit& aParam,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
// Annoyingly many parameters, make sure the ordering is the same as in the
|
||||
// Touch constructor.
|
||||
RefPtr<Touch> touch = new Touch(aParam.mTarget,
|
||||
aParam.mIdentifier,
|
||||
aParam.mPageX,
|
||||
aParam.mPageY,
|
||||
aParam.mScreenX,
|
||||
aParam.mScreenY,
|
||||
aParam.mClientX,
|
||||
aParam.mClientY,
|
||||
aParam.mRadiusX,
|
||||
aParam.mRadiusY,
|
||||
aParam.mRotationAngle,
|
||||
aParam.mForce);
|
||||
return touch.forget();
|
||||
}
|
||||
|
||||
Touch::Touch(EventTarget* aTarget,
|
||||
int32_t aIdentifier,
|
||||
int32_t aPageX,
|
||||
|
@ -10,6 +10,7 @@
|
||||
#include "mozilla/Attributes.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/dom/TouchBinding.h"
|
||||
#include "nsWrapperCache.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "Units.h"
|
||||
@ -28,6 +29,10 @@ class Touch final : public nsISupports
|
||||
public:
|
||||
static bool PrefEnabled(JSContext* aCx, JSObject* aGlobal);
|
||||
|
||||
static already_AddRefed<Touch> Constructor(const GlobalObject& aGlobal,
|
||||
const TouchInit& aParam,
|
||||
ErrorResult& aRv);
|
||||
|
||||
Touch(EventTarget* aTarget,
|
||||
int32_t aIdentifier,
|
||||
int32_t aPageX,
|
||||
|
@ -207,6 +207,39 @@ TouchEvent::PrefEnabled(JSContext* aCx, JSObject* aGlobal)
|
||||
return prefValue;
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<Event>
|
||||
TouchEvent::Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const TouchEventInit& aParam,
|
||||
ErrorResult& aRv)
|
||||
{
|
||||
nsCOMPtr<EventTarget> t = do_QueryInterface(aGlobal.GetAsSupports());
|
||||
RefPtr<TouchEvent> e = new TouchEvent(t, nullptr, nullptr);
|
||||
bool trusted = e->Init(t);
|
||||
RefPtr<TouchList> touches = e->CopyTouches(aParam.mTouches);
|
||||
RefPtr<TouchList> targetTouches = e->CopyTouches(aParam.mTargetTouches);
|
||||
RefPtr<TouchList> changedTouches = e->CopyTouches(aParam.mChangedTouches);
|
||||
e->InitTouchEvent(aType, aParam.mBubbles, aParam.mCancelable, aParam.mView,
|
||||
aParam.mDetail, aParam.mCtrlKey, aParam.mAltKey,
|
||||
aParam.mShiftKey, aParam.mMetaKey, touches, targetTouches,
|
||||
changedTouches);
|
||||
e->SetTrusted(trusted);
|
||||
return e.forget();
|
||||
}
|
||||
|
||||
|
||||
already_AddRefed<TouchList>
|
||||
TouchEvent::CopyTouches(const Sequence<OwningNonNull<Touch>>& aTouches)
|
||||
{
|
||||
RefPtr<TouchList> list = new TouchList(GetParentObject());
|
||||
size_t len = aTouches.Length();
|
||||
for (size_t i = 0; i < len; ++i) {
|
||||
list->Append(aTouches[i]);
|
||||
}
|
||||
return list.forget();
|
||||
}
|
||||
|
||||
bool
|
||||
TouchEvent::AltKey()
|
||||
{
|
||||
|
@ -95,6 +95,9 @@ public:
|
||||
return TouchEventBinding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
already_AddRefed<TouchList>
|
||||
CopyTouches(const Sequence<OwningNonNull<Touch>>& aTouches);
|
||||
|
||||
TouchList* Touches();
|
||||
TouchList* TargetTouches();
|
||||
TouchList* ChangedTouches();
|
||||
@ -120,6 +123,11 @@ public:
|
||||
static bool PrefEnabled(JSContext* aCx = nullptr,
|
||||
JSObject* aGlobal = nullptr);
|
||||
|
||||
static already_AddRefed<Event> Constructor(const GlobalObject& aGlobal,
|
||||
const nsAString& aType,
|
||||
const TouchEventInit& aParam,
|
||||
ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
~TouchEvent() {}
|
||||
|
||||
|
@ -10,7 +10,23 @@
|
||||
* liability, trademark and document use rules apply.
|
||||
*/
|
||||
|
||||
[Func="mozilla::dom::Touch::PrefEnabled"]
|
||||
dictionary TouchInit {
|
||||
required long identifier;
|
||||
required EventTarget target;
|
||||
long clientX = 0;
|
||||
long clientY = 0;
|
||||
long screenX = 0;
|
||||
long screenY = 0;
|
||||
long pageX = 0;
|
||||
long pageY = 0;
|
||||
float radiusX = 0;
|
||||
float radiusY = 0;
|
||||
float rotationAngle = 0;
|
||||
float force = 0;
|
||||
};
|
||||
|
||||
[Constructor(TouchInit touchInitDict),
|
||||
Func="mozilla::dom::Touch::PrefEnabled"]
|
||||
interface Touch {
|
||||
readonly attribute long identifier;
|
||||
readonly attribute EventTarget? target;
|
||||
|
@ -4,7 +4,14 @@
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
[Func="mozilla::dom::TouchEvent::PrefEnabled"]
|
||||
dictionary TouchEventInit : EventModifierInit {
|
||||
sequence<Touch> touches = [];
|
||||
sequence<Touch> targetTouches = [];
|
||||
sequence<Touch> changedTouches = [];
|
||||
};
|
||||
|
||||
[Constructor(DOMString type, optional TouchEventInit eventInitDict),
|
||||
Func="mozilla::dom::TouchEvent::PrefEnabled"]
|
||||
interface TouchEvent : UIEvent {
|
||||
readonly attribute TouchList touches;
|
||||
readonly attribute TouchList targetTouches;
|
||||
|
Loading…
Reference in New Issue
Block a user