Bug 774987 - Remove a leak and unnecessary copy in touch event handling. r=smaug

This commit is contained in:
Wes Johnston 2012-07-19 16:36:45 -07:00
parent b66d71f27e
commit d48f4b5292

View File

@ -5556,11 +5556,13 @@ EvictTouchPoint(nsCOMPtr<nsIDOMTouch>& aTouch)
if (!frame) {
return;
}
nsPoint *pt = new nsPoint(aTouch->mRefPoint.x, aTouch->mRefPoint.y);
widget = frame->GetView()->GetNearestWidget(pt);
nsPoint pt(aTouch->mRefPoint.x, aTouch->mRefPoint.y);
widget = frame->GetView()->GetNearestWidget(&pt);
if (!widget) {
return;
}
nsTouchEvent event(true, NS_TOUCH_END, widget);
event.widget = widget;
event.time = PR_IntervalNow();
@ -6500,9 +6502,8 @@ PresShell::DispatchTouchEvent(nsEvent *aEvent,
nsTouchEvent* touchEvent = static_cast<nsTouchEvent*>(aEvent);
// touch events should fire on all targets
if (aEvent->message != NS_TOUCH_START) {
nsTArray<nsCOMPtr<nsIDOMTouch> > touches = touchEvent->touches;
for (PRUint32 i = 0; i < touches.Length(); ++i) {
nsIDOMTouch *touch = touches[i];
for (PRUint32 i = 0; i < touchEvent->touches.Length(); ++i) {
nsIDOMTouch *touch = touchEvent->touches[i];
if (!touch || !touch->mChanged) {
continue;
}
@ -6550,9 +6551,8 @@ PresShell::DispatchTouchEvent(nsEvent *aEvent,
}
} else {
// touchevents need to have the target attribute set on each touch
nsTArray<nsCOMPtr<nsIDOMTouch> > touches = touchEvent->touches;
for (PRUint32 i = 0; i < touches.Length(); ++i) {
nsIDOMTouch *touch = touches[i];
for (PRUint32 i = 0; i < touchEvent->touches.Length(); ++i) {
nsIDOMTouch *touch = touchEvent->touches[i];
if (touch->mChanged) {
touch->SetTarget(mCurrentEventContent);
}