Bug 777706 - Backout new dom bindings for touchlists. r=smaug

This commit is contained in:
Wes Johnston 2012-08-02 10:41:42 -07:00
parent c8ca4ff79c
commit 2088574285
8 changed files with 52 additions and 65 deletions

View File

@ -8439,8 +8439,7 @@ NS_IMETHODIMP
nsDocument::CreateTouchList(nsIVariant* aPoints,
nsIDOMTouchList** aRetVal)
{
nsRefPtr<nsDOMTouchList> retval =
new nsDOMTouchList(static_cast<nsIDocument*>(this));
nsRefPtr<nsDOMTouchList> retval = new nsDOMTouchList();
if (aPoints) {
PRUint16 type;
aPoints->GetDataType(&type);

View File

@ -128,13 +128,16 @@ nsDOMTouch::Equals(nsIDOMTouch* aTouch)
}
// TouchList
nsDOMTouchList::nsDOMTouchList(nsTArray<nsCOMPtr<nsIDOMTouch> > &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<nsIDOMTouchEvent*>(this),
unchangedTouches);
t = new nsDOMTouchList(unchangedTouches);
} else {
t = new nsDOMTouchList(static_cast<nsIDOMTouchEvent*>(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<nsIDOMTouchEvent*>(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<nsIDOMTouchEvent*>(this),
changedTouches);
mChangedTouches = new nsDOMTouchList(changedTouches);
return CallQueryInterface(mChangedTouches, aChangedTouches);
}

View File

@ -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<nsCOMPtr<nsIDOMTouch> > &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<nsCOMPtr<nsIDOMTouch> > &aTouches);
void Append(nsIDOMTouch* aPoint)
{
mPoints.AppendElement(aPoint);
}
nsIDOMTouch* GetItemAt(PRUint32 aIndex)
{
return mPoints.SafeElementAt(aIndex, nsnull);
}
protected:
nsTArray<nsCOMPtr<nsIDOMTouch> > mPoints;
nsCOMPtr<nsISupports> mParent;
};
class nsDOMTouchEvent : public nsDOMUIEvent,

View File

@ -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<nsDOMTouchList*>(aNative);
return list->GetItemAt(aIndex);
}
NS_IMETHODIMP
nsDOMClassInfo::Convert(nsIXPConnectWrappedNative *wrapper, JSContext *cx,
JSObject *obj, PRUint32 type, jsval *vp,

View File

@ -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

View File

@ -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);
};

View File

@ -186,6 +186,7 @@ members = [
'nsIDOMUIEvent.isChar',
'nsIDOMTouch.*',
'nsIDOMTouchList.*',
'nsIDOMTouchEvent.*',
# dom/interfaces/geolocation - None.

View File

@ -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',
}