зеркало из https://github.com/mozilla/pjs.git
Bug 388359: Menu items are highlighted as mouse pointer moves below menu. Fix makes GetEventCoordinatesRelativeTo work across window roots. r+sr=roc.
This commit is contained in:
Родитель
3a62533f47
Коммит
2fd8ec2db1
|
@ -655,20 +655,47 @@ nsLayoutUtils::GetEventCoordinatesForNearestView(nsEvent* aEvent,
|
|||
GUIEvent->refPoint, frameView);
|
||||
}
|
||||
|
||||
static nsPoint GetWidgetOffset(nsIWidget* aWidget, nsIWidget*& aRootWidget) {
|
||||
nsPoint offset(0, 0);
|
||||
nsIWidget* parent = aWidget->GetParent();
|
||||
while (parent) {
|
||||
nsRect bounds;
|
||||
aWidget->GetBounds(bounds);
|
||||
offset += bounds.TopLeft();
|
||||
aWidget = parent;
|
||||
parent = aWidget->GetParent();
|
||||
}
|
||||
aRootWidget = aWidget;
|
||||
return offset;
|
||||
}
|
||||
|
||||
nsPoint
|
||||
nsLayoutUtils::TranslateWidgetToView(nsPresContext* aPresContext,
|
||||
nsIWidget* aWidget, nsIntPoint aPt,
|
||||
nsIView* aView)
|
||||
{
|
||||
nsIView* baseView = nsIView::GetViewFor(aWidget);
|
||||
if (!baseView)
|
||||
return nsPoint(NS_UNCONSTRAINEDSIZE, NS_UNCONSTRAINEDSIZE);
|
||||
nsPoint viewToWidget;
|
||||
nsIWidget* wid = baseView->GetNearestWidget(&viewToWidget);
|
||||
NS_ASSERTION(aWidget == wid, "Clashing widgets");
|
||||
nsPoint refPointAppUnits(aPresContext->DevPixelsToAppUnits(aPt.x),
|
||||
aPresContext->DevPixelsToAppUnits(aPt.y));
|
||||
return refPointAppUnits - viewToWidget - aView->GetOffsetTo(baseView);
|
||||
nsPoint viewOffset;
|
||||
nsIWidget* viewWidget = aView->GetNearestWidget(&viewOffset);
|
||||
|
||||
nsIWidget* fromRoot;
|
||||
nsPoint fromOffset = GetWidgetOffset(aWidget, fromRoot);
|
||||
nsIWidget* toRoot;
|
||||
nsPoint toOffset = GetWidgetOffset(viewWidget, toRoot);
|
||||
|
||||
nsIntPoint widgetPoint;
|
||||
if (fromRoot == toRoot) {
|
||||
widgetPoint = aPt + fromOffset - toOffset;
|
||||
} else {
|
||||
nsIntRect widgetRect(0, 0, 0, 0);
|
||||
nsIntRect screenRect;
|
||||
aWidget->WidgetToScreen(widgetRect, screenRect);
|
||||
viewWidget->ScreenToWidget(screenRect, widgetRect);
|
||||
widgetPoint = aPt + widgetRect.TopLeft();
|
||||
}
|
||||
|
||||
nsPoint widgetAppUnits(aPresContext->DevPixelsToAppUnits(widgetPoint.x),
|
||||
aPresContext->DevPixelsToAppUnits(widgetPoint.y));
|
||||
return widgetAppUnits - viewOffset;
|
||||
}
|
||||
|
||||
// Combine aNewBreakType with aOrigBreakType, but limit the break types
|
||||
|
|
Загрузка…
Ссылка в новой задаче