diff --git a/content/base/src/nsDocument.cpp b/content/base/src/nsDocument.cpp index 62c6ebc5e4b..bb85ecae2fe 100644 --- a/content/base/src/nsDocument.cpp +++ b/content/base/src/nsDocument.cpp @@ -8439,8 +8439,7 @@ NS_IMETHODIMP nsDocument::CreateTouchList(nsIVariant* aPoints, nsIDOMTouchList** aRetVal) { - nsRefPtr retval = - new nsDOMTouchList(static_cast(this)); + nsRefPtr retval = new nsDOMTouchList(); if (aPoints) { PRUint16 type; aPoints->GetDataType(&type); diff --git a/content/events/src/nsDOMTouchEvent.cpp b/content/events/src/nsDOMTouchEvent.cpp index ecbc97fda2e..5a398164600 100644 --- a/content/events/src/nsDOMTouchEvent.cpp +++ b/content/events/src/nsDOMTouchEvent.cpp @@ -128,13 +128,16 @@ nsDOMTouch::Equals(nsIDOMTouch* aTouch) } // TouchList +nsDOMTouchList::nsDOMTouchList(nsTArray > &aTouches) +{ + mPoints.AppendElements(aTouches); +} DOMCI_DATA(TouchList, nsDOMTouchList) NS_IMPL_CYCLE_COLLECTION_CLASS(nsDOMTouchList) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMTouchList) - NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_INTERFACE_MAP_ENTRY(nsISupports) NS_INTERFACE_MAP_ENTRY(nsIDOMTouchList) NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(TouchList) @@ -142,16 +145,9 @@ NS_INTERFACE_MAP_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDOMTouchList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSTARRAY_OF_NSCOMPTR(mPoints) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mParent) - NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END -NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(nsDOMTouchList) - NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER -NS_IMPL_CYCLE_COLLECTION_TRACE_END NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDOMTouchList) NS_IMPL_CYCLE_COLLECTION_UNLINK_NSTARRAY(mPoints) - NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mParent) - NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMTouchList) @@ -167,7 +163,7 @@ nsDOMTouchList::GetLength(PRUint32* aLength) NS_IMETHODIMP nsDOMTouchList::Item(PRUint32 aIndex, nsIDOMTouch** aRetVal) { - NS_IF_ADDREF(*aRetVal = nsDOMTouchList::GetItemAt(aIndex)); + NS_IF_ADDREF(*aRetVal = mPoints.SafeElementAt(aIndex, nsnull)); return NS_OK; } @@ -187,12 +183,6 @@ nsDOMTouchList::IdentifiedTouch(PRInt32 aIdentifier, nsIDOMTouch** aRetVal) return NS_OK; } -nsIDOMTouch* -nsDOMTouchList::GetItemAt(PRUint32 aIndex) -{ - return mPoints.SafeElementAt(aIndex, nullptr); -} - // TouchEvent nsDOMTouchEvent::nsDOMTouchEvent(nsPresContext* aPresContext, @@ -297,11 +287,9 @@ nsDOMTouchEvent::GetTouches(nsIDOMTouchList** aTouches) unchangedTouches.AppendElement(touches[i]); } } - t = new nsDOMTouchList(static_cast(this), - unchangedTouches); + t = new nsDOMTouchList(unchangedTouches); } else { - t = new nsDOMTouchList(static_cast(this), - touchEvent->touches); + t = new nsDOMTouchList(touchEvent->touches); } mTouches = t; return CallQueryInterface(mTouches, aTouches); @@ -331,8 +319,7 @@ nsDOMTouchEvent::GetTargetTouches(nsIDOMTouchList** aTargetTouches) } } } - mTargetTouches = new nsDOMTouchList(static_cast(this), - targetTouches); + mTargetTouches = new nsDOMTouchList(targetTouches); return CallQueryInterface(mTargetTouches, aTargetTouches); } @@ -354,8 +341,7 @@ nsDOMTouchEvent::GetChangedTouches(nsIDOMTouchList** aChangedTouches) changedTouches.AppendElement(touches[i]); } } - mChangedTouches = new nsDOMTouchList(static_cast(this), - changedTouches); + mChangedTouches = new nsDOMTouchList(changedTouches); return CallQueryInterface(mChangedTouches, aChangedTouches); } diff --git a/content/events/src/nsDOMTouchEvent.h b/content/events/src/nsDOMTouchEvent.h index 37dd0b43398..addbdbb51ae 100644 --- a/content/events/src/nsDOMTouchEvent.h +++ b/content/events/src/nsDOMTouchEvent.h @@ -9,8 +9,6 @@ #include "nsIDOMTouchEvent.h" #include "nsString.h" #include "nsTArray.h" -#include "nsIDocument.h" -#include "dombindings.h" #include "mozilla/Attributes.h" class nsDOMTouch MOZ_FINAL : public nsIDOMTouch @@ -99,46 +97,28 @@ protected: bool mPointsInitialized; }; -class nsDOMTouchList MOZ_FINAL : public nsIDOMTouchList, - public nsWrapperCache +class nsDOMTouchList : public nsIDOMTouchList { public: NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMTouchList) + NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMTouchList) NS_DECL_NSIDOMTOUCHLIST - nsDOMTouchList(nsISupports *aParent) : mParent(aParent) - { - SetIsDOMBinding(); - } - nsDOMTouchList(nsISupports *aParent, - nsTArray > &aTouches) - : mPoints(aTouches), - mParent(aParent) - { - SetIsDOMBinding(); - } - - virtual JSObject* WrapObject(JSContext *cx, JSObject *scope, - bool *triedToWrap) - { - return mozilla::dom::binding::TouchList::create(cx, scope, this, - triedToWrap); - } - - nsISupports *GetParentObject() - { - return mParent; - } + nsDOMTouchList() { } + nsDOMTouchList(nsTArray > &aTouches); void Append(nsIDOMTouch* aPoint) { mPoints.AppendElement(aPoint); } + nsIDOMTouch* GetItemAt(PRUint32 aIndex) + { + return mPoints.SafeElementAt(aIndex, nsnull); + } + protected: nsTArray > mPoints; - nsCOMPtr mParent; }; class nsDOMTouchEvent : public nsDOMUIEvent, diff --git a/dom/base/nsDOMClassInfo.cpp b/dom/base/nsDOMClassInfo.cpp index c2a632f069f..01db7b3b28c 100644 --- a/dom/base/nsDOMClassInfo.cpp +++ b/dom/base/nsDOMClassInfo.cpp @@ -1633,8 +1633,8 @@ static nsDOMClassInfoData sClassInfoData[] = { NS_DEFINE_CLASSINFO_DATA(Touch, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) - NS_DEFINE_CLASSINFO_DATA(TouchList, nsDOMGenericSH, - DOM_DEFAULT_SCRIPTABLE_FLAGS) + NS_DEFINE_CLASSINFO_DATA(TouchList, nsDOMTouchListSH, + ARRAY_SCRIPTABLE_FLAGS) NS_DEFINE_CLASSINFO_DATA(TouchEvent, nsDOMGenericSH, DOM_DEFAULT_SCRIPTABLE_FLAGS) @@ -4887,6 +4887,14 @@ nsDOMClassInfo::NewResolve(nsIXPConnectWrappedNative *wrapper, JSContext *cx, return NS_OK; } +nsISupports* +nsDOMTouchListSH::GetItemAt(nsISupports *aNative, PRUint32 aIndex, + nsWrapperCache **aCache, nsresult *aResult) +{ + nsDOMTouchList* list = static_cast(aNative); + return list->GetItemAt(aIndex); +} + NS_IMETHODIMP nsDOMClassInfo::Convert(nsIXPConnectWrappedNative *wrapper, JSContext *cx, JSObject *obj, PRUint32 type, jsval *vp, diff --git a/dom/base/nsDOMClassInfo.h b/dom/base/nsDOMClassInfo.h index 5a92a6f12c5..97438006837 100644 --- a/dom/base/nsDOMClassInfo.h +++ b/dom/base/nsDOMClassInfo.h @@ -1216,6 +1216,27 @@ public: } }; +class nsDOMTouchListSH : public nsArraySH +{ + protected: + nsDOMTouchListSH(nsDOMClassInfoData* aData) : nsArraySH(aData) + { + } + + virtual ~nsDOMTouchListSH() + { + } + + virtual nsISupports* GetItemAt(nsISupports *aNative, PRUint32 aIndex, + nsWrapperCache **aCache, nsresult *aResult); + + public: + static nsIClassInfo* doCreate(nsDOMClassInfoData* aData) + { + return new nsDOMTouchListSH(aData); + } +}; + #ifdef MOZ_XUL // TreeColumns helper diff --git a/dom/interfaces/events/nsIDOMTouchEvent.idl b/dom/interfaces/events/nsIDOMTouchEvent.idl index 6ad6b967853..db4bb5257f5 100644 --- a/dom/interfaces/events/nsIDOMTouchEvent.idl +++ b/dom/interfaces/events/nsIDOMTouchEvent.idl @@ -41,8 +41,7 @@ interface nsIDOMTouch : nsISupports { [scriptable, uuid(60706eb7-d50d-4379-b01c-e78e6af84213)] interface nsIDOMTouchList : nsISupports { readonly attribute unsigned long length; - [getter,forward(getItemAt)] nsIDOMTouch item(in unsigned long index); - [noscript,notxpcom,nostdcall] nsIDOMTouch getItemAt(in unsigned long index); + nsIDOMTouch item(in unsigned long index); nsIDOMTouch identifiedTouch(in long identifier); }; diff --git a/js/xpconnect/src/dom_quickstubs.qsconf b/js/xpconnect/src/dom_quickstubs.qsconf index 815227bc6f8..bbbe23998e5 100644 --- a/js/xpconnect/src/dom_quickstubs.qsconf +++ b/js/xpconnect/src/dom_quickstubs.qsconf @@ -186,6 +186,7 @@ members = [ 'nsIDOMUIEvent.isChar', 'nsIDOMTouch.*', + 'nsIDOMTouchList.*', 'nsIDOMTouchEvent.*', # dom/interfaces/geolocation - None. diff --git a/js/xpconnect/src/dombindings.conf b/js/xpconnect/src/dombindings.conf index 0e3f30c1ed4..4286da92afb 100644 --- a/js/xpconnect/src/dombindings.conf +++ b/js/xpconnect/src/dombindings.conf @@ -40,10 +40,6 @@ list_classes = [ 'name': 'PaintRequestList', 'nativeClass': 'nsPaintRequestList' }, - { - 'name': 'TouchList', - 'nativeClass': 'nsDOMTouchList' - }, { 'name': 'FileList', 'nativeClass': 'nsDOMFileList' @@ -78,9 +74,6 @@ irregularFilenames = { 'mozilla::dom::PropertyNodeList': 'HTMLPropertiesCollection', 'nsClientRectList': 'nsClientRect', 'nsPaintRequestList': 'nsPaintRequest', - 'nsIDOMTouch': 'nsIDOMTouchEvent', - 'nsIDOMTouchList': 'nsIDOMTouchEvent', - 'nsDOMTouchList': 'nsDOMTouchEvent', 'nsDOMFileList': 'nsDOMFile', }