Bug 680747 - Set a min and pref width to nsProgressFrame. r=dbaron
authorMounir Lamouri <mounir.lamouri@gmail.com>
Mon, 22 Aug 2011 20:38:06 +0200
changeset 76710 f2d73e22ea287d8c146afc1dde8f27aae711443c
parent 76709 e10579e136f1859c067da16eeb0b46f23bb775e6
child 76711 742b8b74473e1210497adb80c034607dbc35b7f7
push id340
push userclegnitto@mozilla.com
push dateTue, 08 Nov 2011 22:56:33 +0000
treeherdermozilla-beta@f745dc151615 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdbaron
bugs680747
milestone9.0a1
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 680747 - Set a min and pref width to nsProgressFrame. r=dbaron
layout/forms/nsProgressFrame.cpp
layout/forms/nsProgressFrame.h
layout/reftests/forms/progress/reftest.list
--- a/layout/forms/nsProgressFrame.cpp
+++ b/layout/forms/nsProgressFrame.cpp
@@ -274,16 +274,38 @@ nsProgressFrame::ComputeAutoSize(nsRende
     autoSize.height *= 10; // 10em
   } else {
     autoSize.width *= 10; // 10em
   }
 
   return autoSize;
 }
 
+nscoord
+nsProgressFrame::GetMinWidth(nsRenderingContext *aRenderingContext)
+{
+  nsRefPtr<nsFontMetrics> fontMet;
+  NS_ENSURE_SUCCESS(
+      nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fontMet)), 0);
+
+  nscoord minWidth = fontMet->Font().size; // 1em
+
+  if (GetStyleDisplay()->mOrient == NS_STYLE_ORIENT_HORIZONTAL) {
+    minWidth *= 10; // 10em
+  }
+
+  return minWidth;
+}
+
+nscoord
+nsProgressFrame::GetPrefWidth(nsRenderingContext *aRenderingContext)
+{
+  return GetMinWidth(aRenderingContext);
+}
+
 bool
 nsProgressFrame::ShouldUseNativeStyle() const
 {
   // Use the native style if these conditions are satisfied:
   // - both frames use the native appearance;
   // - neither frame has author specified rules setting the border or the
   //   background.
   return GetStyleDisplay()->mAppearance == NS_THEME_PROGRESSBAR &&
--- a/layout/forms/nsProgressFrame.h
+++ b/layout/forms/nsProgressFrame.h
@@ -79,16 +79,19 @@ public:
                               nsIAtom* aAttribute,
                               PRInt32  aModType);
 
   virtual nsSize ComputeAutoSize(nsRenderingContext *aRenderingContext,
                                  nsSize aCBSize, nscoord aAvailableWidth,
                                  nsSize aMargin, nsSize aBorder,
                                  nsSize aPadding, PRBool aShrinkWrap);
 
+  virtual nscoord GetMinWidth(nsRenderingContext *aRenderingContext);
+  virtual nscoord GetPrefWidth(nsRenderingContext *aRenderingContext);
+
   virtual PRBool IsFrameOfType(PRUint32 aFlags) const
   {
     return nsHTMLContainerFrame::IsFrameOfType(aFlags &
       ~(nsIFrame::eReplaced | nsIFrame::eReplacedContainsBlock));
   }
 
   /**
    * Returns whether the frame and its child should use the native style.
--- a/layout/reftests/forms/progress/reftest.list
+++ b/layout/reftests/forms/progress/reftest.list
@@ -17,8 +17,9 @@
 
 # The following test is disabled but kept in the repository because the
 # transformations will not behave exactly the same for <progress> and two divs.
 # However, it would be possible to manually check those.
 # == transformations.html transformations-ref.html
 
 # Tests for bugs:
 == block-invalidate.html block-invalidate-ref.html
+== in-cells.html in-cells-ref.html