From 5f8f44abac86e6a8b327c54755a5fd1efc0c02bb Mon Sep 17 00:00:00 2001 From: Mats Palmgren Date: Wed, 15 Aug 2012 04:28:23 +0200 Subject: [PATCH] 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 --- layout/forms/nsComboboxControlFrame.cpp | 11 +++++++++-- layout/forms/nsListControlFrame.cpp | 1 + 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/layout/forms/nsComboboxControlFrame.cpp b/layout/forms/nsComboboxControlFrame.cpp index eb58f254dd59..68895d9f597b 100644 --- a/layout/forms/nsComboboxControlFrame.cpp +++ b/layout/forms/nsComboboxControlFrame.cpp @@ -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; } diff --git a/layout/forms/nsListControlFrame.cpp b/layout/forms/nsListControlFrame.cpp index c11ef3bf9928..5fcabb8cd484 100644 --- a/layout/forms/nsListControlFrame.cpp +++ b/layout/forms/nsListControlFrame.cpp @@ -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;