mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-11 16:32:59 +00:00
Fix sizing regression for selects with optgroups. b=188426 r+sr=bzbarsky
This commit is contained in:
parent
0cf9f72e1b
commit
849440045e
@ -778,6 +778,31 @@ static void printSize(char * aDesc, nscoord aSize)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static nscoord
|
||||||
|
GetMaxOptionHeight(nsIPresContext *aPresContext, nsIFrame *aContainer)
|
||||||
|
{
|
||||||
|
nscoord result = 0;
|
||||||
|
nsIFrame *option;
|
||||||
|
for (aContainer->FirstChild(aPresContext, nsnull, &option);
|
||||||
|
option; option->GetNextSibling(&option)) {
|
||||||
|
nscoord optionHeight;
|
||||||
|
nsCOMPtr<nsIContent> content;
|
||||||
|
option->GetContent(getter_AddRefs(content));
|
||||||
|
if (nsCOMPtr<nsIDOMHTMLOptGroupElement>(do_QueryInterface(content))) {
|
||||||
|
// an optgroup
|
||||||
|
optionHeight = GetMaxOptionHeight(aPresContext, option);
|
||||||
|
} else {
|
||||||
|
// an option
|
||||||
|
nsSize size;
|
||||||
|
option->GetSize(size);
|
||||||
|
optionHeight = size.height;
|
||||||
|
}
|
||||||
|
if (result < optionHeight)
|
||||||
|
result = optionHeight;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
// Main Reflow for ListBox/Dropdown
|
// Main Reflow for ListBox/Dropdown
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
@ -1047,16 +1072,9 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||||||
// list by using the tallest of the grandchildren, since there may be
|
// list by using the tallest of the grandchildren, since there may be
|
||||||
// option groups in addition to option elements, either of which may
|
// option groups in addition to option elements, either of which may
|
||||||
// be visible or invisible.
|
// be visible or invisible.
|
||||||
PRInt32 heightOfARow = 0;
|
nsIFrame *optionsContainer;
|
||||||
nsIFrame *optionsContainer, *option;
|
|
||||||
GetOptionsContainer(aPresContext, &optionsContainer);
|
GetOptionsContainer(aPresContext, &optionsContainer);
|
||||||
for (optionsContainer->FirstChild(aPresContext, nsnull, &option);
|
PRInt32 heightOfARow = GetMaxOptionHeight(aPresContext, optionsContainer);
|
||||||
option; option->GetNextSibling(&option)) {
|
|
||||||
nsSize size;
|
|
||||||
option->GetSize(size);
|
|
||||||
if (heightOfARow < size.height)
|
|
||||||
heightOfARow = size.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check to see if we have zero items
|
// Check to see if we have zero items
|
||||||
PRInt32 length = 0;
|
PRInt32 length = 0;
|
||||||
|
@ -778,6 +778,31 @@ static void printSize(char * aDesc, nscoord aSize)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
static nscoord
|
||||||
|
GetMaxOptionHeight(nsIPresContext *aPresContext, nsIFrame *aContainer)
|
||||||
|
{
|
||||||
|
nscoord result = 0;
|
||||||
|
nsIFrame *option;
|
||||||
|
for (aContainer->FirstChild(aPresContext, nsnull, &option);
|
||||||
|
option; option->GetNextSibling(&option)) {
|
||||||
|
nscoord optionHeight;
|
||||||
|
nsCOMPtr<nsIContent> content;
|
||||||
|
option->GetContent(getter_AddRefs(content));
|
||||||
|
if (nsCOMPtr<nsIDOMHTMLOptGroupElement>(do_QueryInterface(content))) {
|
||||||
|
// an optgroup
|
||||||
|
optionHeight = GetMaxOptionHeight(aPresContext, option);
|
||||||
|
} else {
|
||||||
|
// an option
|
||||||
|
nsSize size;
|
||||||
|
option->GetSize(size);
|
||||||
|
optionHeight = size.height;
|
||||||
|
}
|
||||||
|
if (result < optionHeight)
|
||||||
|
result = optionHeight;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
// Main Reflow for ListBox/Dropdown
|
// Main Reflow for ListBox/Dropdown
|
||||||
//-----------------------------------------------------------------
|
//-----------------------------------------------------------------
|
||||||
@ -1047,16 +1072,9 @@ nsListControlFrame::Reflow(nsIPresContext* aPresContext,
|
|||||||
// list by using the tallest of the grandchildren, since there may be
|
// list by using the tallest of the grandchildren, since there may be
|
||||||
// option groups in addition to option elements, either of which may
|
// option groups in addition to option elements, either of which may
|
||||||
// be visible or invisible.
|
// be visible or invisible.
|
||||||
PRInt32 heightOfARow = 0;
|
nsIFrame *optionsContainer;
|
||||||
nsIFrame *optionsContainer, *option;
|
|
||||||
GetOptionsContainer(aPresContext, &optionsContainer);
|
GetOptionsContainer(aPresContext, &optionsContainer);
|
||||||
for (optionsContainer->FirstChild(aPresContext, nsnull, &option);
|
PRInt32 heightOfARow = GetMaxOptionHeight(aPresContext, optionsContainer);
|
||||||
option; option->GetNextSibling(&option)) {
|
|
||||||
nsSize size;
|
|
||||||
option->GetSize(size);
|
|
||||||
if (heightOfARow < size.height)
|
|
||||||
heightOfARow = size.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check to see if we have zero items
|
// Check to see if we have zero items
|
||||||
PRInt32 length = 0;
|
PRInt32 length = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user