Bug 780661 - Update mDropdownCanGrow also when the position is currently outside viewport to allow a resize later at a different position. Also, don't call PositionFrameView unless the position really changed to avoid infinite number of calls to AbsolutelyPositionDropDown (via nsResizeDropdownAtFinalPosition event from NotifyGeometryChange). r=roc

This commit is contained in:
Mats Palmgren 2012-08-15 04:28:23 +02:00
parent 60b0bda8c8
commit 5f8f44abac
2 changed files with 10 additions and 2 deletions

View File

@ -720,8 +720,15 @@ nsComboboxControlFrame::AbsolutelyPositionDropDown()
// Align the right edge of the drop-down with the right edge of the control.
dropdownPosition.x = GetRect().width - dropdownSize.width;
}
mDropdownFrame->SetPosition(dropdownPosition + translation);
nsContainerFrame::PositionFrameView(mDropdownFrame);
// Don't position the view unless the position changed since it might cause
// a call to NotifyGeometryChange() and an infinite loop here.
const nsPoint currentPos = mDropdownFrame->GetPosition();
const nsPoint newPos = dropdownPosition + translation;
if (currentPos != newPos) {
mDropdownFrame->SetPosition(newPos);
nsContainerFrame::PositionFrameView(mDropdownFrame);
}
return eDropDownPositionFinal;
}

View File

@ -580,6 +580,7 @@ nsListControlFrame::ReflowAsDropdown(nsPresContext* aPresContext,
if (above <= 0 && below <= 0) {
state.SetComputedHeight(heightOfARow);
mNumDisplayRows = 1;
mDropdownCanGrow = GetNumberOfOptions() > 1;
} else {
nscoord bp = aReflowState.mComputedBorderPadding.TopBottom();
nscoord availableHeight = NS_MAX(above, below) - bp;