Bug 1526294 - Should not need a pres context to get a system font. r=jfkthame
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 08 Feb 2019 14:22:11 +0100
changeset 517401 56f4c25656d9b5ff4b6fefe187e42cad4125fc0b
parent 517400 5b7bdfe0b357db0759c2067de17ef50a1fa05099
child 517402 4f0ef112751747a8fb695e7558bb0b3692a12452
push id10862
push userffxbld-merge
push dateMon, 11 Mar 2019 13:01:11 +0000
treeherdermozilla-beta@a2e7f5c935da [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjfkthame
bugs1526294
milestone67.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 1526294 - Should not need a pres context to get a system font. r=jfkthame The only caller wants CSS pixels, no need to go back and forth. This is the last dependency on the pres context, I think, from the style system font code. Differential Revision: https://phabricator.services.mozilla.com/D19147
gfx/thebes/gfxMacPlatformFontList.h
gfx/thebes/gfxMacPlatformFontList.mm
gfx/thebes/gfxPlatformMac.cpp
gfx/thebes/gfxPlatformMac.h
layout/base/nsLayoutUtils.cpp
layout/base/nsLayoutUtils.h
layout/style/GeckoBindings.cpp
widget/LookAndFeel.h
widget/android/nsLookAndFeel.cpp
widget/android/nsLookAndFeel.h
widget/cocoa/nsLookAndFeel.h
widget/cocoa/nsLookAndFeel.mm
widget/gtk/nsLookAndFeel.cpp
widget/gtk/nsLookAndFeel.h
widget/headless/HeadlessLookAndFeel.h
widget/headless/HeadlessLookAndFeelGTK.cpp
widget/nsXPLookAndFeel.cpp
widget/nsXPLookAndFeel.h
widget/uikit/nsLookAndFeel.h
widget/uikit/nsLookAndFeel.mm
widget/windows/nsLookAndFeel.cpp
widget/windows/nsLookAndFeel.h
--- a/gfx/thebes/gfxMacPlatformFontList.h
+++ b/gfx/thebes/gfxMacPlatformFontList.h
@@ -161,18 +161,17 @@ class gfxMacPlatformFontList : public gf
                           nsTArray<FamilyAndGeneric>* aOutput,
                           FindFamiliesFlags aFlags,
                           gfxFontStyle* aStyle = nullptr,
                           gfxFloat aDevToCssSize = 1.0) override;
 
   // lookup the system font for a particular system font type and set
   // the name and style characteristics
   void LookupSystemFont(mozilla::LookAndFeel::FontID aSystemFontID,
-                        nsACString& aSystemFontName, gfxFontStyle& aFontStyle,
-                        float aDevPixPerCSSPixel);
+                        nsACString& aSystemFontName, gfxFontStyle& aFontStyle);
 
   // Values for the entryType field in FontFamilyListEntry records passed
   // from chrome to content process.
   enum FontFamilyEntryType {
     kStandardFontFamily = 0,          // a standard installed font family
     kHiddenSystemFontFamily = 1,      // hidden system family, not exposed to UI
     kTextSizeSystemFontFamily = 2,    // name of 'system' font at text sizes
     kDisplaySizeSystemFontFamily = 3  // 'system' font at display sizes
--- a/gfx/thebes/gfxMacPlatformFontList.mm
+++ b/gfx/thebes/gfxMacPlatformFontList.mm
@@ -1461,18 +1461,18 @@ bool gfxMacPlatformFontList::FindAndAddF
     aOutput->AppendElement(FindSystemFontFamily(mSystemTextFontFamilyName));
     return true;
   }
 
   return gfxPlatformFontList::FindAndAddFamilies(aFamily, aOutput, aFlags, aStyle, aDevToCssSize);
 }
 
 void gfxMacPlatformFontList::LookupSystemFont(LookAndFeel::FontID aSystemFontID,
-                                              nsACString& aSystemFontName, gfxFontStyle& aFontStyle,
-                                              float aDevPixPerCSSPixel) {
+                                              nsACString& aSystemFontName,
+                                              gfxFontStyle& aFontStyle) {
   // code moved here from widget/cocoa/nsLookAndFeel.mm
   NSFont* font = nullptr;
   char* systemFontName = nullptr;
   switch (aSystemFontID) {
     case LookAndFeel::eFont_MessageBox:
     case LookAndFeel::eFont_StatusBar:
     case LookAndFeel::eFont_List:
     case LookAndFeel::eFont_Field:
@@ -1523,18 +1523,17 @@ void gfxMacPlatformFontList::LookupSyste
   NSFontSymbolicTraits traits = [[font fontDescriptor] symbolicTraits];
   aFontStyle.style =
       (traits & NSFontItalicTrait) ? FontSlantStyle::Italic() : FontSlantStyle::Normal();
   aFontStyle.weight = (traits & NSFontBoldTrait) ? FontWeight::Bold() : FontWeight::Normal();
   aFontStyle.stretch =
       (traits & NSFontExpandedTrait)
           ? FontStretch::Expanded()
           : (traits & NSFontCondensedTrait) ? FontStretch::Condensed() : FontStretch::Normal();
-  // convert size from css pixels to device pixels
-  aFontStyle.size = [font pointSize] * aDevPixPerCSSPixel;
+  aFontStyle.size = [font pointSize];
   aFontStyle.systemFont = true;
 }
 
 // used to load system-wide font info on off-main thread
 class MacFontInfo : public FontInfoData {
  public:
   MacFontInfo(bool aLoadOtherNames, bool aLoadFaceNames, bool aLoadCmaps)
       : FontInfoData(aLoadOtherNames, aLoadFaceNames, aLoadCmaps) {}
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -316,20 +316,19 @@ void gfxPlatformMac::GetCommonFallbackFo
   }
 
   // Arial Unicode MS has lots of glyphs for obscure, use it as a last resort
   aFontList.AppendElement(kFontArialUnicodeMS);
 }
 
 /*static*/ void gfxPlatformMac::LookupSystemFont(
     mozilla::LookAndFeel::FontID aSystemFontID, nsACString& aSystemFontName,
-    gfxFontStyle& aFontStyle, float aDevPixPerCSSPixel) {
+    gfxFontStyle& aFontStyle) {
   gfxMacPlatformFontList* pfl = gfxMacPlatformFontList::PlatformFontList();
-  return pfl->LookupSystemFont(aSystemFontID, aSystemFontName, aFontStyle,
-                               aDevPixPerCSSPixel);
+  return pfl->LookupSystemFont(aSystemFontID, aSystemFontName, aFontStyle);
 }
 
 uint32_t gfxPlatformMac::ReadAntiAliasingThreshold() {
   uint32_t threshold = 0;  // default == no threshold
 
   // first read prefs flag to determine whether to use the setting or not
   bool useAntiAliasingThreshold =
       Preferences::GetBool("gfx.use_text_smoothing_setting", false);
--- a/gfx/thebes/gfxPlatformMac.h
+++ b/gfx/thebes/gfxPlatformMac.h
@@ -48,18 +48,17 @@ class gfxPlatformMac : public gfxPlatfor
   virtual void GetCommonFallbackFonts(
       uint32_t aCh, uint32_t aNextCh, Script aRunScript,
       nsTArray<const char*>& aFontList) override;
 
   // lookup the system font for a particular system font type and set
   // the name and style characteristics
   static void LookupSystemFont(mozilla::LookAndFeel::FontID aSystemFontID,
                                nsACString& aSystemFontName,
-                               gfxFontStyle& aFontStyle,
-                               float aDevPixPerCSSPixel);
+                               gfxFontStyle& aFontStyle);
 
   virtual bool SupportsApzWheelInput() const override { return true; }
 
   bool RespectsFontStyleSmoothing() const override {
     // gfxMacFont respects the font smoothing hint.
     return true;
   }
 
--- a/layout/base/nsLayoutUtils.cpp
+++ b/layout/base/nsLayoutUtils.cpp
@@ -9683,34 +9683,29 @@ already_AddRefed<nsFontMetrics> nsLayout
       fontSize = aMinFontSize;
     }
   }
   aFont->mFont.size = fontSize;
 }
 
 /* static */ void nsLayoutUtils::ComputeSystemFont(
     nsFont* aSystemFont, LookAndFeel::FontID aFontID,
-    const nsPresContext* aPresContext, const nsFont* aDefaultVariableFont) {
+    const nsFont* aDefaultVariableFont) {
   gfxFontStyle fontStyle;
-  float devPerCSS =
-      (float)AppUnitsPerCSSPixel() /
-      aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
   nsAutoString systemFontName;
-  if (LookAndFeel::GetFont(aFontID, systemFontName, fontStyle, devPerCSS)) {
+  if (LookAndFeel::GetFont(aFontID, systemFontName, fontStyle)) {
     systemFontName.Trim("\"'");
     aSystemFont->fontlist =
         FontFamilyList(NS_ConvertUTF16toUTF8(systemFontName), eUnquotedName);
     aSystemFont->fontlist.SetDefaultFontType(eFamily_none);
     aSystemFont->style = fontStyle.style;
     aSystemFont->systemFont = fontStyle.systemFont;
     aSystemFont->weight = fontStyle.weight;
     aSystemFont->stretch = fontStyle.stretch;
-    aSystemFont->size = NSFloatPixelsToAppUnits(
-        fontStyle.size,
-        aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom());
+    aSystemFont->size = CSSPixel::ToAppUnits(fontStyle.size);
     // aSystemFont->langGroup = fontStyle.langGroup;
     aSystemFont->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.
--- a/layout/base/nsLayoutUtils.h
+++ b/layout/base/nsLayoutUtils.h
@@ -2967,17 +2967,16 @@ class nsLayoutUtils {
    * from preferences, as well as -moz-min-font-size-ratio.
    */
   static void ApplyMinFontSize(nsStyleFont* aFont,
                                const nsPresContext* aPresContext,
                                nscoord aMinFontSize);
 
   static void ComputeSystemFont(nsFont* aSystemFont,
                                 mozilla::LookAndFeel::FontID aFontID,
-                                const nsPresContext* aPresContext,
                                 const nsFont* aDefaultVariableFont);
 
   static void ComputeFontFeatures(const nsCSSValuePairList* aFeaturesList,
                                   nsTArray<gfxFontFeature>& aFeatureSettings);
 
   static void ComputeFontVariations(
       const nsCSSValuePairList* aVariationsList,
       nsTArray<gfxFontVariation>& aVariationSettings);
--- a/layout/style/GeckoBindings.cpp
+++ b/layout/style/GeckoBindings.cpp
@@ -1024,18 +1024,17 @@ void Gecko_nsFont_InitSystem(nsFont* aDe
   nsFont* system = new (aDest) nsFont(*defaultVariableFont);
 
   MOZ_RELEASE_ASSERT(system);
 
   *aDest = *defaultVariableFont;
   LookAndFeel::FontID fontID = static_cast<LookAndFeel::FontID>(aFontId);
 
   AutoWriteLock guard(*sServoFFILock);
-  nsLayoutUtils::ComputeSystemFont(aDest, fontID, aPresContext,
-                                   defaultVariableFont);
+  nsLayoutUtils::ComputeSystemFont(aDest, fontID, defaultVariableFont);
 }
 
 void Gecko_nsFont_Destroy(nsFont* aDest) { aDest->~nsFont(); }
 
 gfxFontFeatureValueSet* Gecko_ConstructFontFeatureValueSet() {
   return new gfxFontFeatureValueSet();
 }
 
--- a/widget/LookAndFeel.h
+++ b/widget/LookAndFeel.h
@@ -645,23 +645,23 @@ class LookAndFeel {
     return result;
   }
 
   /**
    * Retrieve the name and style of a system-theme font.  Returns true
    * if the system theme specifies this font, false if a default should
    * be used.  In the latter case neither aName nor aStyle is modified.
    *
+   * Size of the font should be in CSS pixels, not device pixels.
+   *
    * @param aID    Which system-theme font is wanted.
    * @param aName  The name of the font to use.
    * @param aStyle Styling to apply to the font.
-   * @param aDevPixPerCSSPixel  Ratio of device pixels to CSS pixels
    */
-  static bool GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle,
-                      float aDevPixPerCSSPixel);
+  static bool GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle);
 
   /**
    * GetPasswordCharacter() returns a unicode character which should be used
    * for a masked character in password editor.  E.g., '*'.
    */
   static char16_t GetPasswordCharacter();
 
   /**
--- a/widget/android/nsLookAndFeel.cpp
+++ b/widget/android/nsLookAndFeel.cpp
@@ -427,23 +427,22 @@ nsresult nsLookAndFeel::GetFloatImpl(Flo
       rv = NS_ERROR_FAILURE;
       break;
   }
   return rv;
 }
 
 /*virtual*/
 bool nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
-                                gfxFontStyle& aFontStyle,
-                                float aDevPixPerCSSPixel) {
+                                gfxFontStyle& aFontStyle) {
   aFontName.AssignLiteral("\"Roboto\"");
   aFontStyle.style = FontSlantStyle::Normal();
   aFontStyle.weight = FontWeight::Normal();
   aFontStyle.stretch = FontStretch::Normal();
-  aFontStyle.size = 9.0 * 96.0f / 72.0f * aDevPixPerCSSPixel;
+  aFontStyle.size = 9.0 * 96.0f / 72.0f;
   aFontStyle.systemFont = true;
   return true;
 }
 
 /*virtual*/
 bool nsLookAndFeel::GetEchoPasswordImpl() {
   EnsureInitShowPassword();
   return mShowPassword;
--- a/widget/android/nsLookAndFeel.h
+++ b/widget/android/nsLookAndFeel.h
@@ -13,18 +13,18 @@ class nsLookAndFeel final : public nsXPL
   nsLookAndFeel();
   virtual ~nsLookAndFeel();
 
   void NativeInit() final;
   virtual void RefreshImpl() override;
   virtual nsresult NativeGetColor(ColorID aID, nscolor& aResult) override;
   virtual nsresult GetIntImpl(IntID aID, int32_t& aResult) override;
   virtual nsresult GetFloatImpl(FloatID aID, float& aResult) override;
-  virtual bool GetFontImpl(FontID aID, nsString& aName, gfxFontStyle& aStyle,
-                           float aDevPixPerCSSPixel) override;
+  virtual bool GetFontImpl(FontID aID, nsString& aName,
+                           gfxFontStyle& aStyle) override;
   virtual bool GetEchoPasswordImpl() override;
   virtual uint32_t GetPasswordMaskDelayImpl() override;
   virtual char16_t GetPasswordCharacterImpl() override;
   virtual nsTArray<LookAndFeelInt> GetIntCacheImpl() override;
   virtual void SetIntCacheImpl(
       const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) override;
 
  protected:
--- a/widget/cocoa/nsLookAndFeel.h
+++ b/widget/cocoa/nsLookAndFeel.h
@@ -13,18 +13,17 @@ class nsLookAndFeel final : public nsXPL
   virtual ~nsLookAndFeel();
 
   void NativeInit() final;
   virtual void RefreshImpl() override;
   virtual nsresult NativeGetColor(ColorID aID, nscolor& aResult) override;
   virtual nsresult GetIntImpl(IntID aID, int32_t& aResult) override;
   virtual nsresult GetFloatImpl(FloatID aID, float& aResult) override;
   virtual bool GetFontImpl(FontID aID, nsString& aFontName,
-                           gfxFontStyle& aFontStyle,
-                           float aDevPixPerCSSPixel) override;
+                           gfxFontStyle& aFontStyle) override;
 
   virtual char16_t GetPasswordCharacterImpl() override {
     // unicode value for the bullet character, used for password textfields.
     return 0x2022;
   }
 
   static bool UseOverlayScrollbars();
 
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -623,34 +623,33 @@ bool nsLookAndFeel::SystemWantsDarkTheme
   // This returns true if the macOS system appearance is set to dark mode on
   // 10.14+, false otherwise.
   if (nsCocoaFeatures::OnMojaveOrLater()) {
     return !![[NSUserDefaults standardUserDefaults] stringForKey:@"AppleInterfaceStyle"];
   }
   return false;
 }
 
-bool nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName, gfxFontStyle& aFontStyle,
-                                float aDevPixPerCSSPixel) {
+bool nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName, gfxFontStyle& aFontStyle) {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
 
   // hack for now
   if (aID == eFont_Window || aID == eFont_Document) {
     aFontStyle.style = mozilla::FontSlantStyle::Normal();
     aFontStyle.weight = mozilla::FontWeight::Normal();
     aFontStyle.stretch = mozilla::FontStretch::Normal();
-    aFontStyle.size = 14 * aDevPixPerCSSPixel;
+    aFontStyle.size = 14;
     aFontStyle.systemFont = true;
 
     aFontName.AssignLiteral("sans-serif");
     return true;
   }
 
   nsAutoCString name;
-  gfxPlatformMac::LookupSystemFont(aID, name, aFontStyle, aDevPixPerCSSPixel);
+  gfxPlatformMac::LookupSystemFont(aID, name, aFontStyle);
   aFontName.Append(NS_ConvertUTF8toUTF16(name));
 
   return true;
 
   NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
 }
 
 nsTArray<LookAndFeelInt> nsLookAndFeel::GetIntCacheImpl() {
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -762,28 +762,25 @@ static void GetSystemFontInfo(GtkStyleCo
   float size = float(pango_font_description_get_size(desc)) / PANGO_SCALE;
 
   // |size| is now either pixels or pango-points (not Mozilla-points!)
 
   if (!pango_font_description_get_size_is_absolute(desc)) {
     // |size| is in pango-points, so convert to pixels.
     size *= float(gfxPlatformGtk::GetFontScaleDPI()) / POINTS_PER_INCH_FLOAT;
   }
+
   // |size| is now pixels but not scaled for the hidpi displays,
-  // this needs to be done in GetFontImpl where the aDevPixPerCSSPixel
-  // parameter is provided.
-
   aFontStyle->size = size;
 
   pango_font_description_free(desc);
 }
 
 bool nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
-                                gfxFontStyle& aFontStyle,
-                                float aDevPixPerCSSPixel) {
+                                gfxFontStyle& aFontStyle) {
   switch (aID) {
     case eFont_Menu:          // css2
     case eFont_PullDownMenu:  // css3
       aFontName = mMenuFontName;
       aFontStyle = mMenuFontStyle;
       break;
 
     case eFont_Field:  // css3
@@ -810,27 +807,27 @@ bool nsLookAndFeel::GetFontImpl(FontID a
     case eFont_Dialog:        // css3
     case eFont_Tooltips:      // moz
     case eFont_Widget:        // moz
     default:
       aFontName = mDefaultFontName;
       aFontStyle = mDefaultFontStyle;
       break;
   }
+
   // Scale the font for the current monitor
   double scaleFactor = nsIWidget::DefaultScaleOverride();
   if (scaleFactor > 0) {
     aFontStyle.size *=
-        mozilla::widget::ScreenHelperGTK::GetGTKMonitorScaleFactor();
+        widget::ScreenHelperGTK::GetGTKMonitorScaleFactor() / scaleFactor;
   } else {
-    // Remove effect of font scale because it has been already applied in
-    // GetSystemFontInfo
-    aFontStyle.size *=
-        aDevPixPerCSSPixel / gfxPlatformGtk::GetFontScaleFactor();
+    // Convert gdk pixels to CSS pixels.
+    aFontStyle.size /= gfxPlatformGtk::GetFontScaleFactor();
   }
+
   return true;
 }
 
 void nsLookAndFeel::EnsureInit() {
   GdkColor colorValue;
   GdkColor* colorValuePtr;
 
   if (mInitialized) return;
--- a/widget/gtk/nsLookAndFeel.h
+++ b/widget/gtk/nsLookAndFeel.h
@@ -21,18 +21,17 @@ class nsLookAndFeel final : public nsXPL
   virtual ~nsLookAndFeel();
 
   void NativeInit() final;
   virtual void RefreshImpl() override;
   virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult) override;
   virtual nsresult GetIntImpl(IntID aID, int32_t &aResult) override;
   virtual nsresult GetFloatImpl(FloatID aID, float &aResult) override;
   virtual bool GetFontImpl(FontID aID, nsString &aFontName,
-                           gfxFontStyle &aFontStyle,
-                           float aDevPixPerCSSPixel) override;
+                           gfxFontStyle &aFontStyle) override;
 
   virtual char16_t GetPasswordCharacterImpl() override;
   virtual bool GetEchoPasswordImpl() override;
 
   bool IsCSDAvailable() const { return mCSDAvailable; }
 
  protected:
   // Cached fonts
--- a/widget/headless/HeadlessLookAndFeel.h
+++ b/widget/headless/HeadlessLookAndFeel.h
@@ -23,18 +23,17 @@ class HeadlessLookAndFeel : public nsXPL
   HeadlessLookAndFeel();
   virtual ~HeadlessLookAndFeel();
 
   virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult) override;
   void NativeInit() final{};
   virtual nsresult GetIntImpl(IntID aID, int32_t &aResult) override;
   virtual nsresult GetFloatImpl(FloatID aID, float &aResult) override;
   virtual bool GetFontImpl(FontID aID, nsString &aFontName,
-                           gfxFontStyle &aFontStyle,
-                           float aDevPixPerCSSPixel) override;
+                           gfxFontStyle &aFontStyle) override;
 
   virtual void RefreshImpl() override;
   virtual char16_t GetPasswordCharacterImpl() override;
   virtual bool GetEchoPasswordImpl() override;
 };
 
 #else
 
--- a/widget/headless/HeadlessLookAndFeelGTK.cpp
+++ b/widget/headless/HeadlessLookAndFeelGTK.cpp
@@ -322,23 +322,22 @@ nsresult HeadlessLookAndFeel::GetFloatIm
       res = NS_ERROR_FAILURE;
       break;
   }
 
   return res;
 }
 
 bool HeadlessLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
-                                      gfxFontStyle& aFontStyle,
-                                      float aDevPixPerCSSPixel) {
+                                      gfxFontStyle& aFontStyle) {
   // Default to san-serif for everything.
   aFontStyle.style = FontSlantStyle::Normal();
   aFontStyle.weight = FontWeight::Normal();
   aFontStyle.stretch = FontStretch::Normal();
-  aFontStyle.size = 14 * aDevPixPerCSSPixel;
+  aFontStyle.size = 14;
   aFontStyle.systemFont = true;
 
   aFontName.AssignLiteral("sans-serif");
   return true;
 }
 
 char16_t HeadlessLookAndFeel::GetPasswordCharacterImpl() {
   return UNICODE_BULLET;
--- a/widget/nsXPLookAndFeel.cpp
+++ b/widget/nsXPLookAndFeel.cpp
@@ -980,20 +980,18 @@ nsresult LookAndFeel::GetInt(IntID aID, 
 }
 
 // static
 nsresult LookAndFeel::GetFloat(FloatID aID, float* aResult) {
   return nsLookAndFeel::GetInstance()->GetFloatImpl(aID, *aResult);
 }
 
 // static
-bool LookAndFeel::GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle,
-                          float aDevPixPerCSSPixel) {
-  return nsLookAndFeel::GetInstance()->GetFontImpl(aID, aName, aStyle,
-                                                   aDevPixPerCSSPixel);
+bool LookAndFeel::GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle) {
+  return nsLookAndFeel::GetInstance()->GetFontImpl(aID, aName, aStyle);
 }
 
 // static
 char16_t LookAndFeel::GetPasswordCharacter() {
   return nsLookAndFeel::GetInstance()->GetPasswordCharacterImpl();
 }
 
 // static
--- a/widget/nsXPLookAndFeel.h
+++ b/widget/nsXPLookAndFeel.h
@@ -55,18 +55,18 @@ class nsXPLookAndFeel : public mozilla::
   //
   nsresult GetColorImpl(ColorID aID, bool aUseStandinsForNativeColors,
                         nscolor& aResult);
   virtual nsresult GetIntImpl(IntID aID, int32_t& aResult);
   virtual nsresult GetFloatImpl(FloatID aID, float& aResult);
 
   // This one is different: there are no override prefs (fixme?), so
   // there is no XP implementation, only per-system impls.
-  virtual bool GetFontImpl(FontID aID, nsString& aName, gfxFontStyle& aStyle,
-                           float aDevPixPerCSSPixel) = 0;
+  virtual bool GetFontImpl(FontID aID, nsString& aName,
+                           gfxFontStyle& aStyle) = 0;
 
   virtual void RefreshImpl();
 
   virtual char16_t GetPasswordCharacterImpl() { return char16_t('*'); }
 
   virtual bool GetEchoPasswordImpl() { return false; }
 
   virtual uint32_t GetPasswordMaskDelayImpl() { return 600; }
--- a/widget/uikit/nsLookAndFeel.h
+++ b/widget/uikit/nsLookAndFeel.h
@@ -13,18 +13,18 @@ class nsLookAndFeel final : public nsXPL
   nsLookAndFeel();
   virtual ~nsLookAndFeel();
 
   void NativeInit() final;
   virtual void RefreshImpl();
   virtual nsresult NativeGetColor(const ColorID aID, nscolor &aResult);
   virtual nsresult GetIntImpl(IntID aID, int32_t &aResult);
   virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
-  virtual bool GetFontImpl(FontID aID, nsString &aFontName,
-                           gfxFontStyle &aFontStyle, float aDevPixPerCSSPixel);
+  bool GetFontImpl(FontID aID, nsString &aFontName,
+                   gfxFontStyle &aFontStyle) override;
   virtual char16_t GetPasswordCharacterImpl() {
     // unicode value for the bullet character, used for password textfields.
     return 0x2022;
   }
 
   static bool UseOverlayScrollbars() { return true; }
 
  private:
--- a/widget/uikit/nsLookAndFeel.mm
+++ b/widget/uikit/nsLookAndFeel.mm
@@ -367,24 +367,23 @@ nsLookAndFeel::GetFloatImpl(FloatID aID,
     default:
       aResult = -1.0;
       res = NS_ERROR_FAILURE;
   }
 
   return res;
 }
 
-bool nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName, gfxFontStyle &aFontStyle,
-                                float aDevPixPerCSSPixel) {
+bool nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName, gfxFontStyle &aFontStyle) {
   // hack for now
   if (aID == eFont_Window || aID == eFont_Document) {
     aFontStyle.style = FontSlantStyle::Normal();
     aFontStyle.weight = FontWeight::Normal();
     aFontStyle.stretch = FontStretch::Normal();
-    aFontStyle.size = 14 * aDevPixPerCSSPixel;
+    aFontStyle.size = 14;
     aFontStyle.systemFont = true;
 
     aFontName.AssignLiteral("sans-serif");
     return true;
   }
 
   // TODO: implement more here?
   return false;
--- a/widget/windows/nsLookAndFeel.cpp
+++ b/widget/windows/nsLookAndFeel.cpp
@@ -737,18 +737,17 @@ static bool GetSysFontInfo(HDC aHDC, Loo
     memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE * sizeof(char16_t));
     aFontName = name;
   }
 
   return true;
 }
 
 bool nsLookAndFeel::GetFontImpl(FontID anID, nsString &aFontName,
-                                gfxFontStyle &aFontStyle,
-                                float aDevPixPerCSSPixel) {
+                                gfxFontStyle &aFontStyle) {
   CachedSystemFont &cacheSlot = mSystemFontCache[anID];
 
   bool status;
   if (cacheSlot.mCacheValid) {
     status = cacheSlot.mHaveFont;
     if (status) {
       aFontName = cacheSlot.mFontName;
       aFontStyle = cacheSlot.mFontStyle;
@@ -760,19 +759,16 @@ bool nsLookAndFeel::GetFontImpl(FontID a
 
     cacheSlot.mCacheValid = true;
     cacheSlot.mHaveFont = status;
     if (status) {
       cacheSlot.mFontName = aFontName;
       cacheSlot.mFontStyle = aFontStyle;
     }
   }
-  // now convert the logical font size from GetSysFontInfo into device pixels
-  // for layout
-  aFontStyle.size *= aDevPixPerCSSPixel;
   return status;
 }
 
 /* virtual */
 char16_t nsLookAndFeel::GetPasswordCharacterImpl() {
 #define UNICODE_BLACK_CIRCLE_CHAR 0x25cf
   return UNICODE_BLACK_CIRCLE_CHAR;
 }
--- a/widget/windows/nsLookAndFeel.h
+++ b/widget/windows/nsLookAndFeel.h
@@ -49,18 +49,18 @@ class nsLookAndFeel final : public nsXPL
   nsLookAndFeel();
   virtual ~nsLookAndFeel();
 
   void NativeInit() final;
   void RefreshImpl() override;
   nsresult NativeGetColor(ColorID aID, nscolor& aResult) override;
   nsresult GetIntImpl(IntID aID, int32_t& aResult) override;
   nsresult GetFloatImpl(FloatID aID, float& aResult) override;
-  bool GetFontImpl(FontID aID, nsString& aFontName, gfxFontStyle& aFontStyle,
-                   float aDevPixPerCSSPixel) override;
+  bool GetFontImpl(FontID aID, nsString& aFontName,
+                   gfxFontStyle& aFontStyle) override;
   char16_t GetPasswordCharacterImpl() override;
 
   nsTArray<LookAndFeelInt> GetIntCacheImpl() override;
   void SetIntCacheImpl(
       const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache) override;
 
  private:
   /**