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 190912 0e768e11d2c63b82fe07ce15d24d20fb1571d7f7
parent 190911 b6bf2687d93fd3322dd318b158189956fc524b9c
child 190913 ad76a457e5827020390013c1f5b63f5d8e71ccbc
push id3503
push userraliiev@mozilla.com
push dateMon, 28 Apr 2014 18:51:11 +0000
treeherdermozilla-beta@c95ac01e332e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbzbarsky
bugs697451
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 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