Bug 970257 - Make <input type=number> handle auto width properly. r=dholbert
authorJonathan Watt <jwatt@jwatt.org>
Wed, 12 Feb 2014 02:54:14 +0000
changeset 169356 7ac30a8de3d6cc4f3250114475956c6332064423
parent 169355 f55c1d834649aa4061e1d622e862f14f4e14a583
child 169357 1a0927d0558bdacda2274212065683ea2d8e1d0c
push id26245
push userryanvm@gmail.com
push dateTue, 18 Feb 2014 20:18:17 +0000
treeherdermozilla-central@9019cc90719c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs970257
milestone30.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 970257 - Make <input type=number> handle auto width properly. r=dholbert
layout/forms/nsNumberControlFrame.cpp
layout/forms/nsNumberControlFrame.h
layout/reftests/forms/input/number/number-auto-width-1-ref.html
layout/reftests/forms/input/number/number-auto-width-1.html
layout/reftests/forms/input/number/reftest.list
--- a/layout/forms/nsNumberControlFrame.cpp
+++ b/layout/forms/nsNumberControlFrame.cpp
@@ -55,16 +55,52 @@ nsNumberControlFrame::DestroyFrom(nsIFra
   NS_ASSERTION(!GetPrevContinuation() && !GetNextContinuation(),
                "nsNumberControlFrame should not have continuations; if it does we "
                "need to call RegUnregAccessKey only for the first");
   nsFormControlFrame::RegUnRegAccessKey(static_cast<nsIFrame*>(this), false);
   nsContentUtils::DestroyAnonymousContent(&mOuterWrapper);
   nsContainerFrame::DestroyFrom(aDestructRoot);
 }
 
+nscoord
+nsNumberControlFrame::GetMinWidth(nsRenderingContext* aRenderingContext)
+{
+  nscoord result;
+  DISPLAY_MIN_WIDTH(this, result);
+
+  nsIFrame* kid = mFrames.FirstChild();
+  if (kid) { // display:none?
+    result = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
+                                                  kid,
+                                                  nsLayoutUtils::MIN_WIDTH);
+  } else {
+    result = 0;
+  }
+
+  return result;
+}
+
+nscoord
+nsNumberControlFrame::GetPrefWidth(nsRenderingContext* aRenderingContext)
+{
+  nscoord result;
+  DISPLAY_PREF_WIDTH(this, result);
+
+  nsIFrame* kid = mFrames.FirstChild();
+  if (kid) { // display:none?
+    result = nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
+                                                  kid,
+                                                  nsLayoutUtils::PREF_WIDTH);
+  } else {
+    result = 0;
+  }
+
+  return result;
+}
+
 nsresult
 nsNumberControlFrame::Reflow(nsPresContext* aPresContext,
                              nsHTMLReflowMetrics& aDesiredSize,
                              const nsHTMLReflowState& aReflowState,
                              nsReflowStatus& aStatus)
 {
   DO_GLOBAL_REFLOW_COUNT("nsNumberControlFrame");
   DISPLAY_REFLOW(aPresContext, this, aReflowState, aDesiredSize, aStatus);
--- a/layout/forms/nsNumberControlFrame.h
+++ b/layout/forms/nsNumberControlFrame.h
@@ -45,16 +45,20 @@ public:
   virtual void DestroyFrom(nsIFrame* aDestructRoot) MOZ_OVERRIDE;
   virtual void ContentStatesChanged(nsEventStates aStates);
   virtual bool IsLeaf() const MOZ_OVERRIDE { return true; }
 
 #ifdef ACCESSIBILITY
   virtual mozilla::a11y::AccType AccessibleType() MOZ_OVERRIDE;
 #endif
 
+  virtual nscoord GetMinWidth(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE;
+
+  virtual nscoord GetPrefWidth(nsRenderingContext* aRenderingContext) MOZ_OVERRIDE;
+
   virtual nsresult Reflow(nsPresContext*           aPresContext,
                           nsHTMLReflowMetrics&     aDesiredSize,
                           const nsHTMLReflowState& aReflowState,
                           nsReflowStatus&          aStatus) MOZ_OVERRIDE;
 
   virtual nsresult AttributeChanged(int32_t  aNameSpaceID,
                                     nsIAtom* aAttribute,
                                     int32_t  aModType) MOZ_OVERRIDE;
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/input/number/number-auto-width-1-ref.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <input type="text" style="-moz-appearance:none; width:auto;">
+    <!-- div to cover spin box area -->
+    <div style="display:block; position:absolute; background-color:black; width:2000px; height:100px; top:0px; left:100px;">
+  </body>
+</html>
new file mode 100644
--- /dev/null
+++ b/layout/reftests/forms/input/number/number-auto-width-1.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+  <body>
+    <input type="number" style="-moz-appearance:none; width:auto;">
+    <!-- div to cover spin box area -->
+    <div style="display:block; position:absolute; background-color:black; width:2000px; height:100px; top:0px; left:100px;">
+  </body>
+</html>
--- a/layout/reftests/forms/input/number/reftest.list
+++ b/layout/reftests/forms/input/number/reftest.list
@@ -15,16 +15,19 @@ fuzzy-if(/^Windows\x20NT\x205\.1/.test(h
 == from-number-to-other-type-unthemed-1.html from-number-to-other-type-unthemed-1-ref.html
 
 # dynamic value changes:
 == show-value.html show-value-ref.html
 
 # disabled
 == number-disabled.html number-disabled-ref.html
 
+# auto width:
+== number-auto-width-1.html number-auto-width-1-ref.html
+
 # min-height/max-height tests:
 skip-if(B2G) == number-min-height-1.html number-min-height-1-ref.html
 skip-if(B2G) == number-min-height-2.html number-min-height-2-ref.html
 skip-if(B2G) == number-max-height-1.html number-max-height-1-ref.html
 skip-if(B2G) == number-max-height-2.html number-max-height-2-ref.html
 
 # focus
 # autofocus is disabled on B2G