Bug 1353596 part 1 - Move the Windows-specific size fix for button/field/list into LookAndFeel. r?bz draft
authorXidorn Quan <me@upsuper.org>
Wed, 05 Apr 2017 16:15:07 +1000
changeset 558250 58928d457006ebedcfcdd382c53256b4632e2b47
parent 555959 b961004631f1130670c95d0899e4ed82778d9f0d
child 558251 5ec28dee1411d617399e0c50c17bc24a981f10a3
push id52850
push userxquan@mozilla.com
push dateFri, 07 Apr 2017 11:54:10 +0000
reviewersbz
bugs1353596
milestone55.0a1
Bug 1353596 part 1 - Move the Windows-specific size fix for button/field/list into LookAndFeel. r?bz Although there is still no way to set those size from system, but it keeps the font-size (10pt) for current default settings, which matches Edge and Chrome on Windows. This brings Windows to have the same behavior as other platforms, and also brings us to have the same behavior with Chrome on Windows that the font size of them are consistent regardless of settings. MozReview-Commit-ID: KdtcaMNKY35
layout/style/nsRuleNode.cpp
widget/windows/nsLookAndFeel.cpp
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -3619,42 +3619,16 @@ nsRuleNode::SetFont(nsPresContext* aPres
       systemFont.weight = fontStyle.weight;
       systemFont.stretch = fontStyle.stretch;
       systemFont.size =
         NSFloatPixelsToAppUnits(fontStyle.size,
                                 aPresContext->DeviceContext()->
                                   AppUnitsPerDevPixelAtUnitFullZoom());
       //systemFont.langGroup = fontStyle.langGroup;
       systemFont.sizeAdjust = fontStyle.sizeAdjust;
-
-#ifdef XP_WIN
-      // XXXldb This platform-specific stuff should be in the
-      // LookAndFeel implementation, not here.
-      // XXXzw Should we even still *have* this code?  It looks to be making
-      // old, probably obsolete assumptions.
-
-      if (fontID == LookAndFeel::eFont_Field ||
-          fontID == LookAndFeel::eFont_Button ||
-          fontID == LookAndFeel::eFont_List) {
-        // As far as I can tell the system default fonts and sizes
-        // on MS-Windows for Buttons, Listboxes/Comboxes and Text Fields are
-        // all pre-determined and cannot be changed by either the control panel
-        // or programmatically.
-        // Fields (text fields)
-        // Button and Selects (listboxes/comboboxes)
-        //    We use whatever font is defined by the system. Which it appears
-        //    (and the assumption is) it is always a proportional font. Then we
-        //    always use 2 points smaller than what the browser has defined as
-        //    the default proportional font.
-        // Assumption: system defined font is proportional
-        systemFont.size =
-          std::max(defaultVariableFont->size -
-                 nsPresContext::CSSPointsToAppUnits(2), 0);
-      }
-#endif
     }
   }
 
   // font-family: font family list, enum, inherit
   const nsCSSValue* familyValue = aRuleData->ValueForFontFamily();
   NS_ASSERTION(eCSSUnit_Enumerated != familyValue->GetUnit(),
                "system fonts should not be in mFamily anymore");
   if (eCSSUnit_FontFamilyList == familyValue->GetUnit()) {
--- a/widget/windows/nsLookAndFeel.cpp
+++ b/widget/windows/nsLookAndFeel.cpp
@@ -617,16 +617,31 @@ GetSysFontInfo(HDC aHDC, LookAndFeel::Fo
 
   // we have problem on Simplified Chinese system because the system
   // report the default font size is 8 points. but if we use 8, the text
   // display very ugly. force it to be at 9 points (12 pixels) on that
   // system (cp936), but leave other sizes alone.
   if (pixelHeight < 12 && ::GetACP() == 936)
     pixelHeight = 12;
 
+  if (anID == LookAndFeel::eFont_Field ||
+      anID == LookAndFeel::eFont_Button ||
+      anID == LookAndFeel::eFont_List) {
+    // As far as I can tell the system default fonts and sizes
+    // on MS-Windows for Buttons, Listboxes/Comboxes and Text Fields are
+    // all pre-determined and cannot be changed by either the control panel
+    // or programmatically.
+    // Fields (text fields)
+    // Button and Selects (listboxes/comboboxes)
+    // We use whatever font is defined by the system, but explicitly use
+    // 10 points (13.33px) for consistency with our existing default behavior
+    // as well as other browsers on Windows.
+    pixelHeight = 96.0f / 72.0f * 10;
+  }
+
   aFontStyle.size = pixelHeight;
 
   // FIXME: What about oblique?
   aFontStyle.style =
     (ptrLogFont->lfItalic) ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL;
 
   // FIXME: Other weights?
   aFontStyle.weight =