Bug 668437. Part 5. Make the view bounds of a popup coincide with the client area of the widget. r=enndeakin,roc

This commit is contained in:
Timothy Nikkel 2011-12-01 13:56:42 -06:00
parent d6466c2a0e
commit 8ce4c15a30
2 changed files with 10 additions and 22 deletions

View File

@ -487,21 +487,6 @@ nsMenuPopupFrame::LayoutPopup(nsBoxLayoutState& aState, nsIFrame* aParentMenu, b
nsRect rect = GetRect();
rect.x = rect.y = 0;
// Increase the popup's view size to account for any titlebar or borders.
// XXXndeakin this should really be accounted for earlier in
// SetPopupPosition so that this extra size is accounted for when flipping
// or resizing the popup due to it being too large, but that can be a
// followup bug.
if (mPopupType == ePopupTypePanel && view) {
nsIWidget* widget = view->GetWidget();
if (widget) {
nsIntSize popupSize = nsIntSize(pc->AppUnitsToDevPixels(rect.width),
pc->AppUnitsToDevPixels(rect.height));
popupSize = widget->ClientToWindowSize(popupSize);
rect.width = pc->DevPixelsToAppUnits(popupSize.width);
rect.height = pc->DevPixelsToAppUnits(popupSize.height);
}
}
viewManager->ResizeView(view, rect);
viewManager->SetViewVisibility(view, nsViewVisibility_kShow);
@ -1319,8 +1304,6 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove)
nsIView* view = GetView();
NS_ASSERTION(view, "popup with no view");
presContext->GetPresShell()->GetViewManager()->
MoveViewTo(view, viewPoint.x, viewPoint.y);
// Offset the position by the width and height of the borders and titlebar.
// Even though GetClientOffset should return (0, 0) when there is no
@ -1333,6 +1316,9 @@ nsMenuPopupFrame::SetPopupPosition(nsIFrame* aAnchorFrame, bool aIsMove)
viewPoint.y += presContext->DevPixelsToAppUnits(mLastClientOffset.y);
}
presContext->GetPresShell()->GetViewManager()->
MoveViewTo(view, viewPoint.x, viewPoint.y);
// Now that we've positioned the view, sync up the frame's origin.
nsBoxFrame::SetPosition(viewPoint - GetParent()->GetOffsetTo(rootFrame));

View File

@ -438,7 +438,7 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly,
}
nsIntRect curBounds;
mWindow->GetBounds(curBounds);
mWindow->GetClientBounds(curBounds);
nsWindowType type;
mWindow->GetWindowType(type);
@ -462,14 +462,16 @@ void nsView::DoResetWidgetBounds(bool aMoveOnly,
// Child views are never attached to top level widgets, this is safe.
if (changedPos) {
if (changedSize && !aMoveOnly) {
mWindow->Resize(newBounds.x, newBounds.y, newBounds.width, newBounds.height,
aInvalidateChangedSize);
mWindow->ResizeClient(newBounds.x, newBounds.y,
newBounds.width, newBounds.height,
aInvalidateChangedSize);
} else {
mWindow->Move(newBounds.x, newBounds.y);
mWindow->MoveClient(newBounds.x, newBounds.y);
}
} else {
if (changedSize && !aMoveOnly) {
mWindow->Resize(newBounds.width, newBounds.height, aInvalidateChangedSize);
mWindow->ResizeClient(newBounds.width, newBounds.height,
aInvalidateChangedSize);
} // else do nothing!
}
}