Bug 743325 - Back out 554ab0a2f470 (bug 734503) because it broke touch events in XUL Fennec [r=peterv]

This commit is contained in:
Matt Brubeck 2012-04-24 07:51:56 -07:00
parent 8b3515c868
commit 955934c3d9
5 changed files with 21 additions and 61 deletions

View File

@ -8545,8 +8545,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

@ -160,13 +160,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)
@ -174,16 +177,10 @@ 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)
@ -199,7 +196,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;
}
@ -219,12 +216,6 @@ nsDOMTouchList::IdentifiedTouch(PRInt32 aIdentifier, nsIDOMTouch** aRetVal)
return NS_OK;
}
nsIDOMTouch*
nsDOMTouchList::GetItemAt(PRUint32 aIndex)
{
return mPoints.SafeElementAt(aIndex, nsnull);
}
// TouchEvent
nsDOMTouchEvent::nsDOMTouchEvent(nsPresContext* aPresContext,
@ -331,11 +322,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);
@ -365,8 +354,7 @@ nsDOMTouchEvent::GetTargetTouches(nsIDOMTouchList** aTargetTouches)
}
}
}
mTargetTouches = new nsDOMTouchList(static_cast<nsIDOMTouchEvent*>(this),
targetTouches);
mTargetTouches = new nsDOMTouchList(targetTouches);
return CallQueryInterface(mTargetTouches, aTargetTouches);
}
@ -388,8 +376,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

@ -41,8 +41,6 @@
#include "nsIDOMTouchEvent.h"
#include "nsString.h"
#include "nsTArray.h"
#include "nsIDocument.h"
#include "dombindings.h"
class nsDOMTouch : public nsIDOMTouch
{
@ -129,46 +127,27 @@ protected:
float mForce;
};
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

@ -73,8 +73,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

@ -23,7 +23,6 @@ prefableClasses = {
'DOMSettableTokenList': 'nsDOMSettableTokenList',
'ClientRectList': 'nsClientRectList',
'PaintRequestList': 'nsPaintRequestList',
'TouchList': 'nsDOMTouchList',
'FileList': 'nsDOMFileList',
'SVGLengthList': 'mozilla::DOMSVGLengthList',
'SVGNumberList': 'mozilla::DOMSVGNumberList',
@ -36,9 +35,6 @@ irregularFilenames = {
'nsHTMLOptionCollection': 'nsHTMLSelectElement',
'nsClientRectList': 'nsClientRect',
'nsPaintRequestList': 'nsPaintRequest',
'nsIDOMTouch': 'nsIDOMTouchEvent',
'nsIDOMTouchList': 'nsIDOMTouchEvent',
'nsDOMTouchList': 'nsDOMTouchEvent',
'nsDOMFileList': 'nsDOMFile',
}