Fix for bug 734503 (Add new DOM binding for TouchList). r=jst.

--HG--
extra : rebase_source : 701eb8d9a60ffa981ebcd24f426109bd70cc5cbf
This commit is contained in:
Peter Van der Beken 2011-08-22 11:14:13 +02:00
Родитель 969e7029c9
Коммит 3b247fb028
5 изменённых файлов: 61 добавлений и 21 удалений

Просмотреть файл

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

Просмотреть файл

@ -160,16 +160,13 @@ 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)
@ -177,10 +174,16 @@ 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)
@ -196,7 +199,7 @@ nsDOMTouchList::GetLength(PRUint32* aLength)
NS_IMETHODIMP
nsDOMTouchList::Item(PRUint32 aIndex, nsIDOMTouch** aRetVal)
{
NS_IF_ADDREF(*aRetVal = mPoints.SafeElementAt(aIndex, nsnull));
NS_IF_ADDREF(*aRetVal = nsDOMTouchList::GetItemAt(aIndex));
return NS_OK;
}
@ -216,6 +219,12 @@ nsDOMTouchList::IdentifiedTouch(PRInt32 aIdentifier, nsIDOMTouch** aRetVal)
return NS_OK;
}
nsIDOMTouch*
nsDOMTouchList::GetItemAt(PRUint32 aIndex)
{
return mPoints.SafeElementAt(aIndex, nsnull);
}
// TouchEvent
nsDOMTouchEvent::nsDOMTouchEvent(nsPresContext* aPresContext,
@ -322,9 +331,11 @@ nsDOMTouchEvent::GetTouches(nsIDOMTouchList** aTouches)
unchangedTouches.AppendElement(touches[i]);
}
}
t = new nsDOMTouchList(unchangedTouches);
t = new nsDOMTouchList(static_cast<nsIDOMTouchEvent*>(this),
unchangedTouches);
} else {
t = new nsDOMTouchList(touchEvent->touches);
t = new nsDOMTouchList(static_cast<nsIDOMTouchEvent*>(this),
touchEvent->touches);
}
mTouches = t;
return CallQueryInterface(mTouches, aTouches);
@ -354,7 +365,8 @@ nsDOMTouchEvent::GetTargetTouches(nsIDOMTouchList** aTargetTouches)
}
}
}
mTargetTouches = new nsDOMTouchList(targetTouches);
mTargetTouches = new nsDOMTouchList(static_cast<nsIDOMTouchEvent*>(this),
targetTouches);
return CallQueryInterface(mTargetTouches, aTargetTouches);
}
@ -376,7 +388,8 @@ nsDOMTouchEvent::GetChangedTouches(nsIDOMTouchList** aChangedTouches)
changedTouches.AppendElement(touches[i]);
}
}
mChangedTouches = new nsDOMTouchList(changedTouches);
mChangedTouches = new nsDOMTouchList(static_cast<nsIDOMTouchEvent*>(this),
changedTouches);
return CallQueryInterface(mChangedTouches, aChangedTouches);
}

Просмотреть файл

@ -41,6 +41,8 @@
#include "nsIDOMTouchEvent.h"
#include "nsString.h"
#include "nsTArray.h"
#include "nsIDocument.h"
#include "dombindings.h"
class nsDOMTouch : public nsIDOMTouch
{
@ -127,27 +129,46 @@ protected:
float mForce;
};
class nsDOMTouchList : public nsIDOMTouchList
class nsDOMTouchList MOZ_FINAL : public nsIDOMTouchList,
public nsWrapperCache
{
public:
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_CLASS(nsDOMTouchList)
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMTouchList)
NS_DECL_NSIDOMTOUCHLIST
nsDOMTouchList() { }
nsDOMTouchList(nsTArray<nsCOMPtr<nsIDOMTouch> > &aTouches);
nsDOMTouchList(nsISupports *aParent) : mParent(aParent)
{
SetIsProxy();
}
nsDOMTouchList(nsISupports *aParent,
nsTArray<nsCOMPtr<nsIDOMTouch> > &aTouches)
: mPoints(aTouches),
mParent(aParent)
{
SetIsProxy();
}
virtual JSObject* WrapObject(JSContext *cx, XPCWrappedNativeScope *scope,
bool *triedToWrap)
{
return mozilla::dom::binding::TouchList::create(cx, scope, this,
triedToWrap);
}
nsISupports *GetParentObject()
{
return mParent;
}
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,

Просмотреть файл

@ -73,7 +73,8 @@ interface nsIDOMTouch : nsISupports {
[scriptable, uuid(60706eb7-d50d-4379-b01c-e78e6af84213)]
interface nsIDOMTouchList : nsISupports {
readonly attribute unsigned long length;
nsIDOMTouch item(in unsigned long index);
[getter,forward(getItemAt)] nsIDOMTouch item(in unsigned long index);
[noscript,notxpcom,nostdcall] nsIDOMTouch getItemAt(in unsigned long index);
nsIDOMTouch identifiedTouch(in long identifier);
};

Просмотреть файл

@ -8,12 +8,16 @@ prefableClasses = {
'DOMSettableTokenList': 'nsDOMSettableTokenList',
'ClientRectList': 'nsClientRectList',
'PaintRequestList': 'nsPaintRequestList',
'TouchList': 'nsDOMTouchList',
}
irregularFilenames = {
'nsHTMLOptionCollection': 'nsHTMLSelectElement',
'nsClientRectList': 'nsClientRect',
'nsPaintRequestList': 'nsPaintRequest',
'nsIDOMTouch': 'nsIDOMTouchEvent',
'nsIDOMTouchList': 'nsIDOMTouchEvent',
'nsDOMTouchList': 'nsDOMTouchEvent',
}
customInheritance = {