Make nsMenuFrame::SizeToPopup consider its own border/padding properly, by increasing the popup's content's width by the larger of its own border/padding or the popup's scrollbar, rather than only the latter. (Bug 623922) r=enndeakin

This commit is contained in:
L. David Baron 2011-06-29 14:39:21 -07:00
Родитель 8b15f3793c
Коммит 0661b939b7
1 изменённых файлов: 15 добавлений и 2 удалений

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

@ -1384,14 +1384,27 @@ nsMenuFrame::SizeToPopup(nsBoxLayoutState& aState, nsSize& aSize)
if (!mPopupFrame)
return PR_FALSE;
tmpSize = mPopupFrame->GetPrefSize(aState);
aSize.width = tmpSize.width;
// Produce a size such that:
// (1) the menu and its popup can be the same width
// (2) there's enough room in the menu for the content and its
// border-padding
// (3) there's enough room in the popup for the content and its
// scrollbar
nsMargin borderPadding;
GetBorderAndPadding(borderPadding);
// if there is a scroll frame, add the desired width of the scrollbar as well
nsIScrollableFrame* scrollFrame = do_QueryFrame(mPopupFrame->GetFirstChild(nsnull));
nscoord scrollbarWidth = 0;
if (scrollFrame) {
aSize.width += scrollFrame->GetDesiredScrollbarSizes(&aState).LeftRight();
scrollbarWidth =
scrollFrame->GetDesiredScrollbarSizes(&aState).LeftRight();
}
aSize.width =
tmpSize.width + NS_MAX(borderPadding.LeftRight(), scrollbarWidth);
return PR_TRUE;
}
}