Bug 603141 (2/2) - <select multiple> should show 4 rows by default. r=bz a=blocking-b8
authorMounir Lamouri <mounir.lamouri@gmail.com>
Tue, 09 Nov 2010 15:24:01 +0100
changeset 57156 5c43321021b16b7bca886c0785427ce9f9242a44
parent 57155 73fce728315708a9e90d3cfe78b47468f0fd0e1c
child 57157 68fe2106f2801a37b667b6c029f1f6d4d44e34b7
push id16816
push usermlamouri@mozilla.com
push dateTue, 09 Nov 2010 14:25:41 +0000
treeherdermozilla-central@5c43321021b1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, blocking-b8
bugs603141
milestone2.0b8pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 603141 (2/2) - <select multiple> should show 4 rows by default. r=bz a=blocking-b8
layout/forms/nsListControlFrame.cpp
--- a/layout/forms/nsListControlFrame.cpp
+++ b/layout/forms/nsListControlFrame.cpp
@@ -464,35 +464,16 @@ GetNumberOfOptionsRecursive(nsIContent* 
     }
     else if (::IsOptGroup(child)) {
       optionCount += ::GetNumberOfOptionsRecursive(child);
     }
   }
   return optionCount;
 }
 
-static nscoord
-GetOptGroupLabelsHeight(nsIContent*    aContent,
-                        nscoord        aRowHeight)
-{
-  nscoord height = 0;
-  const PRUint32 childCount = aContent ? aContent->GetChildCount() : 0;
-  for (PRUint32 index = 0; index < childCount; ++index) {
-    nsIContent* child = aContent->GetChildAt(index);
-    if (::IsOptGroup(child)) {
-      PRUint32 numOptions = ::GetNumberOfOptionsRecursive(child);
-      nscoord optionsHeight = aRowHeight * numOptions;
-      nsIFrame* frame = child->GetPrimaryFrame();
-      nscoord totalHeight = frame ? frame->GetSize().height : 0;
-      height += NS_MAX(0, totalHeight - optionsHeight);
-    }
-  }
-  return height;
-}
-
 //-----------------------------------------------------------------
 // Main Reflow for ListBox/Dropdown
 //-----------------------------------------------------------------
 
 nscoord
 nsListControlFrame::CalcHeightOfARow()
 {
   // Calculate the height of a single row in the listbox or dropdown list by
@@ -1909,50 +1890,25 @@ nsListControlFrame::CalcFallbackRowHeigh
 }
 
 nscoord
 nsListControlFrame::CalcIntrinsicHeight(nscoord aHeightOfARow,
                                         PRInt32 aNumberOfOptions)
 {
   NS_PRECONDITION(!IsInDropDownMode(),
                   "Shouldn't be in dropdown mode when we call this");
-  
+
   mNumDisplayRows = 1;
   GetSizeAttribute(&mNumDisplayRows);
 
-  // Extra height to tack on to aHeightOfARow * mNumDisplayRows
-  nscoord extraHeight = 0;
-  
   if (mNumDisplayRows < 1) {
-    // When SIZE=0 or unspecified we constrain the height to
-    // [2..kMaxDropDownRows] rows.  We add in the height of optgroup labels
-    // (within the constraint above), bug 300474.
-    nscoord labelHeight = ::GetOptGroupLabelsHeight(mContent, aHeightOfARow);
-
-    if (GetMultiple()) {
-      if (aNumberOfOptions < 2) {
-        // Add in 1 aHeightOfARow also when aNumberOfOptions == 0
-        mNumDisplayRows = 1;
-        extraHeight = NS_MAX(aHeightOfARow, labelHeight);
-      }
-      else if (aNumberOfOptions * aHeightOfARow + labelHeight >
-               kMaxDropDownRows * aHeightOfARow) {
-        mNumDisplayRows = kMaxDropDownRows;
-      } else {
-        mNumDisplayRows = aNumberOfOptions;
-        extraHeight = labelHeight;
-      }
-    }
-    else {
-      NS_NOTREACHED("Shouldn't hit this case -- we should a be a combobox if "
-                    "we have no size set and no multiple set!");
-    }
+    mNumDisplayRows = 4;
   }
 
-  return mNumDisplayRows * aHeightOfARow + extraHeight;
+  return mNumDisplayRows * aHeightOfARow;
 }
 
 //----------------------------------------------------------------------
 // nsIDOMMouseListener
 //----------------------------------------------------------------------
 nsresult
 nsListControlFrame::MouseUp(nsIDOMEvent* aMouseEvent)
 {