Bug 664707. Special case converting event coordinates when the frame is the root frame in the widget. r=matspal

This has the side benefit of making events work in transformed select dropdown popups and is the real reason for making the change.
This commit is contained in:
Timothy Nikkel 2012-03-03 15:24:13 -06:00
parent 2fba78bac9
commit ff961d36b5

View File

@ -973,6 +973,21 @@ nsLayoutUtils::GetEventCoordinatesRelativeTo(const nsEvent* aEvent, nsIFrame* aF
#else
if (!GUIEvent->widget)
return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
nsIView* view = aFrame->GetView();
if (view) {
nsIWidget* widget = view->GetWidget();
if (widget && widget == GUIEvent->widget) {
// Special case this cause it happens a lot.
// This also fixes bug 664707, events in the extra-special case of select
// dropdown popups that are transformed.
nsPresContext* presContext = aFrame->PresContext();
nsPoint pt(presContext->DevPixelsToAppUnits(GUIEvent->refPoint.x),
presContext->DevPixelsToAppUnits(GUIEvent->refPoint.y));
return pt - view->ViewToWidgetOffset();
}
}
/* If we walk up the frame tree and discover that any of the frames are
* transformed, we need to do extra work to convert from the global
* space to the local space.
@ -1031,6 +1046,20 @@ nsLayoutUtils::GetEventCoordinatesRelativeTo(const nsEvent* aEvent,
return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
}
nsIView* view = aFrame->GetView();
if (view) {
nsIWidget* fwidget = view->GetWidget();
if (fwidget && fwidget == GUIEvent->widget) {
// Special case this cause it happens a lot.
// This also fixes bug 664707, events in the extra-special case of select
// dropdown popups that are transformed.
nsPresContext* presContext = aFrame->PresContext();
nsPoint pt(presContext->DevPixelsToAppUnits(GUIEvent->refPoint.x),
presContext->DevPixelsToAppUnits(GUIEvent->refPoint.y));
return pt - view->ViewToWidgetOffset();
}
}
/* If we walk up the frame tree and discover that any of the frames are
* transformed, we need to do extra work to convert from the global
* space to the local space.