Bug 697451 - Stop overriding line-height (max-ing with 1.0) on inputs other than single-line text inputs. r=bzbarsky
authorL. David Baron <dbaron@dbaron.org>
Fri, 14 Mar 2014 17:00:12 -0700
changeset 173721 0e768e11d2c6
parent 173720 b6bf2687d93f
child 173722 ad76a457e582
push id26415
push userkwierso@gmail.com
push date2014-03-15 05:20 +0000
treeherdermozilla-central@82c90c17fc95 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs697451
milestone30.0a1
Bug 697451 - Stop overriding line-height (max-ing with 1.0) on inputs other than single-line text inputs. r=bzbarsky

This allows *native-themed* button-type inputs to shrink more than
Chromium allows them to, but it might still be Web-compatible.
layout/generic/nsHTMLReflowState.cpp
layout/reftests/forms/button/reftest.list
--- a/layout/generic/nsHTMLReflowState.cpp
+++ b/layout/generic/nsHTMLReflowState.cpp
@@ -23,25 +23,27 @@
 #include "nsTableCellFrame.h"
 #include "nsIPercentHeightObserver.h"
 #include "nsLayoutUtils.h"
 #include "mozilla/Preferences.h"
 #include "nsFontInflationData.h"
 #include "StickyScrollContainer.h"
 #include "nsIFrameInlines.h"
 #include <algorithm>
+#include "mozilla/dom/HTMLInputElement.h"
 
 #ifdef DEBUG
 #undef NOISY_VERTICAL_ALIGN
 #else
 #undef NOISY_VERTICAL_ALIGN
 #endif
 
 using namespace mozilla;
 using namespace mozilla::css;
+using namespace mozilla::dom;
 using namespace mozilla::layout;
 
 enum eNormalLineHeightControl {
   eUninitialized = -1,
   eNoExternalLeading = 0,   // does not include external leading 
   eIncludeExternalLeading,  // use whatever value font vendor provides
   eCompensateLeading        // compensate leading if leading provided by font vendor is not enough
 };
@@ -2480,19 +2482,20 @@ nsHTMLReflowState::CalcLineHeight(nsICon
 {
   NS_PRECONDITION(aStyleContext, "Must have a style context");
 
   nscoord lineHeight =
     ComputeLineHeight(aStyleContext, aBlockHeight, aFontSizeInflation);
 
   NS_ASSERTION(lineHeight >= 0, "ComputeLineHeight screwed up");
 
-  if (aContent && aContent->IsHTML(nsGkAtoms::input)) {
-    // For Web-compatibility, input elements cannot have a line-height
-    // smaller than one.
+  HTMLInputElement* input = HTMLInputElement::FromContentOrNull(aContent);
+  if (input && input->IsSingleLineTextControl()) {
+    // For Web-compatibility, single-line text input elements cannot
+    // have a line-height smaller than one.
     nscoord lineHeightOne =
       aFontSizeInflation * aStyleContext->StyleFont()->mFont.size;
     if (lineHeight < lineHeightOne) {
       lineHeight = lineHeightOne;
     }
   }
 
   return lineHeight;
--- a/layout/reftests/forms/button/reftest.list
+++ b/layout/reftests/forms/button/reftest.list
@@ -10,10 +10,10 @@ fuzzy-if(B2G,125,20) == percent-height-c
 fuzzy-if(B2G,125,80) == percent-height-child-2.html percent-height-child-2-ref.html
 fuzzy-if(B2G,125,20) == percent-width-child-1.html  percent-width-child-1-ref.html
 fuzzy-if(B2G,125,80) == percent-width-child-2.html  percent-width-child-2-ref.html
 
 == vertical-centering.html vertical-centering-ref.html
 
 != line-height-button-0.5.html line-height-button-1.0.html
 != line-height-button-1.5.html line-height-button-1.0.html
-== line-height-input-0.5.html line-height-input-1.0.html
+!= line-height-input-0.5.html line-height-input-1.0.html
 != line-height-input-1.5.html line-height-input-1.0.html