Bug 289792. Make sure to use the correct (but stupid) reference view when translating event coordinates. Also, bulletproof nsViewManager to not rely on frames undoing event coordinate translations, in case we ever screw that up. r+sr=bzbarsky,a=asa

This commit is contained in:
roc+%cs.cmu.edu 2005-04-14 22:41:52 +00:00
Родитель 4aa8a9115c
Коммит f1d51412bf
3 изменённых файлов: 11 добавлений и 13 удалений

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

@ -6345,7 +6345,9 @@ PresShell::HandleEventInternal(nsEvent* aEvent, nsIView *aView,
"How did GetCurrentEventFrame() succeed?");
nsIView* rootView;
mViewManager->GetRootView(rootView);
nsIView* frameView = mCurrentEventFrame->GetClosestView();
nsIView* frameView;
nsPoint pt;
mCurrentEventFrame->GetOffsetFromView(pt, &frameView);
offset = frameView->GetOffsetTo(rootView) - offsetOfaView;
}

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

@ -6541,10 +6541,11 @@ nsBlockFrame::HandleEvent(nsPresContext* aPresContext,
if (resultFrame)
{
// Translate aEvent->point to resultFrame's closest view (bug 180015).
nsIView* closestView = GetClosestView();
nsIView* resultFrameView = resultFrame->GetClosestView();
if (closestView != resultFrameView && resultFrameView) {
aEvent->point -= resultFrameView->GetOffsetTo(closestView);
nsPoint tmp;
nsIView* resultFrameParentView;
resultFrame->GetOffsetFromView(tmp, &resultFrameParentView);
if (parentWithView != resultFrameParentView && resultFrameParentView) {
aEvent->point += resultFrameParentView->GetOffsetTo(parentWithView);
}
if (NS_POSITION_BEFORE_TABLE == result)

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

@ -2485,6 +2485,8 @@ nsEventStatus nsViewManager::HandleEvent(nsView* aView, nsGUIEvent* aEvent, PRBo
}
}
// Save aEvent->point because child code might change it
nsPoint pt = aEvent->point;
for (i = 0; i < targetViews.Count(); i++) {
DisplayListElement2* element = NS_STATIC_CAST(DisplayListElement2*, targetViews.ElementAt(i));
nsView* v = element->mView;
@ -2494,11 +2496,7 @@ nsEventStatus nsViewManager::HandleEvent(nsView* aView, nsGUIEvent* aEvent, PRBo
nsRect r;
v->GetDimensions(r);
nscoord x = element->mAbsX - r.x;
nscoord y = element->mAbsY - r.y;
aEvent->point.x -= x;
aEvent->point.y -= y;
aEvent->point = pt - (nsPoint(element->mAbsX, element->mAbsY) - r.TopLeft());
nsViewManager* vVM = v->GetViewManager();
if (vVM == this) {
@ -2515,9 +2513,6 @@ nsEventStatus nsViewManager::HandleEvent(nsView* aView, nsGUIEvent* aEvent, PRBo
}
}
aEvent->point.x += x;
aEvent->point.y += y;
if (handled) {
break;
}