Bug 1353596 part 3 - Remove aDevPixPerCSSPixel param from LookAndFeel::GetFont. r?jfkthame
This parameter was introduced in
bug 674373 for HiDPI mode on OS X.
Nowadays, all impls except Gonk and GTK simply just multiple this
parameter with the size. Gonk has mostly gone, and GTK impl is fixed
by the previous patch. So this parameter is no longer useful.
MozReview-Commit-ID: BJ3Mv7cF6XL
--- a/gfx/thebes/gfxMacPlatformFontList.h
+++ b/gfx/thebes/gfxMacPlatformFontList.h
@@ -104,18 +104,17 @@ public:
nsTArray<gfxFontFamily*>* aOutput,
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,
nsAString& aSystemFontName,
- gfxFontStyle &aFontStyle,
- float aDevPixPerCSSPixel);
+ 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
@@ -1262,18 +1262,17 @@ gfxMacPlatformFontList::FindAndAddFamili
return gfxPlatformFontList::FindAndAddFamilies(aFamily, aOutput, aStyle,
aDevToCssSize);
}
void
gfxMacPlatformFontList::LookupSystemFont(LookAndFeel::FontID aSystemFontID,
nsAString& aSystemFontName,
- gfxFontStyle &aFontStyle,
- float aDevPixPerCSSPixel)
+ 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:
@@ -1326,18 +1325,17 @@ gfxMacPlatformFontList::LookupSystemFont
aFontStyle.style =
(traits & NSFontItalicTrait) ? NS_FONT_STYLE_ITALIC : NS_FONT_STYLE_NORMAL;
aFontStyle.weight =
(traits & NSFontBoldTrait) ? NS_FONT_WEIGHT_BOLD : NS_FONT_WEIGHT_NORMAL;
aFontStyle.stretch =
(traits & NSFontExpandedTrait) ?
NS_FONT_STRETCH_EXPANDED : (traits & NSFontCondensedTrait) ?
NS_FONT_STRETCH_CONDENSED : NS_FONT_STRETCH_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,
--- a/gfx/thebes/gfxPlatformMac.cpp
+++ b/gfx/thebes/gfxPlatformMac.cpp
@@ -341,22 +341,20 @@ gfxPlatformMac::GetCommonFallbackFonts(u
// 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,
nsAString& 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
--- a/gfx/thebes/gfxPlatformMac.h
+++ b/gfx/thebes/gfxPlatformMac.h
@@ -52,18 +52,17 @@ public:
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,
nsAString& aSystemFontName,
- gfxFontStyle &aFontStyle,
- float aDevPixPerCSSPixel);
+ gfxFontStyle &aFontStyle);
virtual bool CanRenderContentToDataSurface() const override {
return true;
}
virtual bool SupportsApzWheelInput() const override {
return true;
}
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -3601,32 +3601,27 @@ nsRuleNode::SetFont(nsPresContext* aPres
// Fall back to defaultVariableFont.
nsFont systemFont = *defaultVariableFont;
const nsCSSValue* systemFontValue = aRuleData->ValueForSystemFont();
if (eCSSUnit_Enumerated == systemFontValue->GetUnit()) {
gfxFontStyle fontStyle;
LookAndFeel::FontID fontID =
(LookAndFeel::FontID)systemFontValue->GetIntValue();
- float devPerCSS =
- (float)nsPresContext::AppUnitsPerCSSPixel() /
- aPresContext->DeviceContext()->AppUnitsPerDevPixelAtUnitFullZoom();
nsAutoString systemFontName;
- if (LookAndFeel::GetFont(fontID, systemFontName, fontStyle, devPerCSS)) {
+ if (LookAndFeel::GetFont(fontID, systemFontName, fontStyle)) {
systemFontName.Trim("\"'");
systemFont.fontlist = FontFamilyList(systemFontName, eUnquotedName);
systemFont.fontlist.SetDefaultFontType(eFamily_none);
systemFont.style = fontStyle.style;
systemFont.systemFont = fontStyle.systemFont;
systemFont.weight = fontStyle.weight;
systemFont.stretch = fontStyle.stretch;
- systemFont.size =
- NSFloatPixelsToAppUnits(fontStyle.size,
- aPresContext->DeviceContext()->
- AppUnitsPerDevPixelAtUnitFullZoom());
+ systemFont.size = nsPresContext::
+ CSSPixelsToAppUnits(static_cast<float>(fontStyle.size));
//systemFont.langGroup = fontStyle.langGroup;
systemFont.sizeAdjust = fontStyle.sizeAdjust;
}
}
// font-family: font family list, enum, inherit
const nsCSSValue* familyValue = aRuleData->ValueForFontFamily();
NS_ASSERTION(eCSSUnit_Enumerated != familyValue->GetUnit(),
--- a/widget/LookAndFeel.h
+++ b/widget/LookAndFeel.h
@@ -556,20 +556,18 @@ public:
/**
* 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.
*
* @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
@@ -452,24 +452,23 @@ nsLookAndFeel::GetFloatImpl(FloatID aID,
break;
}
return rv;
}
/*virtual*/
bool
nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
- gfxFontStyle& aFontStyle,
- float aDevPixPerCSSPixel)
+ gfxFontStyle& aFontStyle)
{
aFontName.AssignLiteral("\"Droid Sans\"");
aFontStyle.style = NS_FONT_STYLE_NORMAL;
aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
aFontStyle.stretch = NS_FONT_STRETCH_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()
{
--- a/widget/android/nsLookAndFeel.h
+++ b/widget/android/nsLookAndFeel.h
@@ -12,18 +12,17 @@ class nsLookAndFeel: public nsXPLookAndF
{
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
virtual nsresult NativeGetColor(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& aName, gfxFontStyle& aStyle,
- float aDevPixPerCSSPixel);
+ virtual bool GetFontImpl(FontID aID, nsString& aName, gfxFontStyle& aStyle);
virtual bool GetEchoPasswordImpl();
virtual uint32_t GetPasswordMaskDelayImpl();
virtual char16_t GetPasswordCharacterImpl();
protected:
static bool mInitializedSystemColors;
static mozilla::AndroidSystemColors mSystemColors;
static bool mInitializedShowPassword;
--- a/widget/cocoa/nsLookAndFeel.h
+++ b/widget/cocoa/nsLookAndFeel.h
@@ -11,18 +11,17 @@ class nsLookAndFeel: public nsXPLookAndF
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
virtual nsresult NativeGetColor(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);
+ gfxFontStyle& aFontStyle);
virtual char16_t GetPasswordCharacterImpl()
{
// 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
@@ -507,35 +507,33 @@ bool nsLookAndFeel::SystemWantsOverlaySc
bool nsLookAndFeel::AllowOverlayScrollbarsOverlap()
{
return (UseOverlayScrollbars());
}
bool
nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName,
- gfxFontStyle &aFontStyle,
- float aDevPixPerCSSPixel)
+ gfxFontStyle &aFontStyle)
{
NS_OBJC_BEGIN_TRY_ABORT_BLOCK_RETURN;
// hack for now
if (aID == eFont_Window || aID == eFont_Document) {
aFontStyle.style = NS_FONT_STYLE_NORMAL;
aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
- aFontStyle.size = 14 * aDevPixPerCSSPixel;
+ aFontStyle.size = 14;
aFontStyle.systemFont = true;
aFontName.AssignLiteral("sans-serif");
return true;
}
- gfxPlatformMac::LookupSystemFont(aID, aFontName, aFontStyle,
- aDevPixPerCSSPixel);
+ gfxPlatformMac::LookupSystemFont(aID, aFontName, aFontStyle);
return true;
NS_OBJC_END_TRY_ABORT_BLOCK_RETURN(false);
}
nsTArray<LookAndFeelInt>
nsLookAndFeel::GetIntCacheImpl()
--- a/widget/gonk/nsLookAndFeel.cpp
+++ b/widget/gonk/nsLookAndFeel.cpp
@@ -426,18 +426,17 @@ nsLookAndFeel::GetFloatImpl(FloatID aID,
res = NS_ERROR_FAILURE;
}
return res;
}
/*virtual*/
bool
nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
- gfxFontStyle& aFontStyle,
- float aDevPixPerCSSPixel)
+ gfxFontStyle& aFontStyle)
{
aFontName.AssignLiteral("\"Fira Sans\"");
aFontStyle.style = NS_FONT_STYLE_NORMAL;
aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
aFontStyle.size = 9.0 * 96.0f / 72.0f;
aFontStyle.systemFont = true;
return true;
--- a/widget/gonk/nsLookAndFeel.h
+++ b/widget/gonk/nsLookAndFeel.h
@@ -20,18 +20,17 @@
#include "nsXPLookAndFeel.h"
class nsLookAndFeel : public nsXPLookAndFeel
{
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
- virtual bool GetFontImpl(FontID aID, nsString& aName, gfxFontStyle& aStyle,
- float aDevPixPerCSSPixel);
+ virtual bool GetFontImpl(FontID aID, nsString& aName, gfxFontStyle& aStyle);
virtual nsresult GetIntImpl(IntID aID, int32_t &aResult);
virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
virtual bool GetEchoPasswordImpl();
virtual uint32_t GetPasswordMaskDelayImpl();
virtual char16_t GetPasswordCharacterImpl();
protected:
virtual nsresult NativeGetColor(ColorID aID, nscolor &aColor);
--- a/widget/gtk/nsLookAndFeel.cpp
+++ b/widget/gtk/nsLookAndFeel.cpp
@@ -993,18 +993,17 @@ GetSystemFontInfo(LookAndFeel::FontID aI
gtk_widget_ensure_style(accel_label);
GetSystemFontInfo(accel_label, aFontName, aFontStyle);
g_object_unref(menu);
}
}
bool
nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
- gfxFontStyle& aFontStyle,
- float aDevPixPerCSSPixel)
+ gfxFontStyle& aFontStyle)
{
nsString *cachedFontName = nullptr;
gfxFontStyle *cachedFontStyle = nullptr;
bool *isCached = nullptr;
switch (aID) {
case eFont_Menu: // css2
case eFont_PullDownMenu: // css3
@@ -1050,17 +1049,16 @@ nsLookAndFeel::GetFontImpl(FontID aID, n
if (!*isCached) {
GetSystemFontInfo(aID, cachedFontName, cachedFontStyle);
*isCached = true;
}
aFontName = *cachedFontName;
aFontStyle = *cachedFontStyle;
- aFontStyle.size *= aDevPixPerCSSPixel;
return true;
}
void
nsLookAndFeel::EnsureInit()
{
GdkColor colorValue;
GdkColor *colorValuePtr;
--- a/widget/gtk/nsLookAndFeel.h
+++ b/widget/gtk/nsLookAndFeel.h
@@ -18,18 +18,17 @@ class nsLookAndFeel: public nsXPLookAndF
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
virtual nsresult NativeGetColor(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);
+ gfxFontStyle& aFontStyle);
virtual void RefreshImpl();
virtual char16_t GetPasswordCharacterImpl();
virtual bool GetEchoPasswordImpl();
protected:
#if (MOZ_WIDGET_GTK == 2)
struct _GtkStyle *mStyle;
--- a/widget/nsXPLookAndFeel.cpp
+++ b/widget/nsXPLookAndFeel.cpp
@@ -935,21 +935,19 @@ LookAndFeel::GetInt(IntID aID, int32_t*
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)
+LookAndFeel::GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle)
{
- return nsLookAndFeel::GetInstance()->GetFontImpl(aID, aName, aStyle,
- aDevPixPerCSSPixel);
+ return nsLookAndFeel::GetInstance()->GetFontImpl(aID, aName, aStyle);
}
// static
char16_t
LookAndFeel::GetPasswordCharacter()
{
return nsLookAndFeel::GetInstance()->GetPasswordCharacterImpl();
}
--- a/widget/nsXPLookAndFeel.h
+++ b/widget/nsXPLookAndFeel.h
@@ -56,18 +56,17 @@ public:
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;
+ gfxFontStyle& aStyle) = 0;
virtual void RefreshImpl();
virtual char16_t GetPasswordCharacterImpl()
{
return char16_t('*');
}
--- a/widget/uikit/nsLookAndFeel.h
+++ b/widget/uikit/nsLookAndFeel.h
@@ -13,18 +13,17 @@ class nsLookAndFeel: public nsXPLookAndF
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
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);
+ gfxFontStyle& aFontStyle);
virtual char16_t GetPasswordCharacterImpl()
{
// unicode value for the bullet character, used for password textfields.
return 0x2022;
}
static bool UseOverlayScrollbars()
{
--- a/widget/uikit/nsLookAndFeel.mm
+++ b/widget/uikit/nsLookAndFeel.mm
@@ -376,25 +376,24 @@ nsLookAndFeel::GetFloatImpl(FloatID aID,
res = NS_ERROR_FAILURE;
}
return res;
}
bool
nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName,
- gfxFontStyle &aFontStyle,
- float aDevPixPerCSSPixel)
+ gfxFontStyle &aFontStyle)
{
// hack for now
if (aID == eFont_Window || aID == eFont_Document) {
aFontStyle.style = NS_FONT_STYLE_NORMAL;
aFontStyle.weight = NS_FONT_WEIGHT_NORMAL;
aFontStyle.stretch = NS_FONT_STRETCH_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
@@ -645,24 +645,21 @@ GetSysFontInfo(HDC aHDC, LookAndFeel::Fo
aFontName = name;
}
return true;
}
bool
nsLookAndFeel::GetFontImpl(FontID anID, nsString &aFontName,
- gfxFontStyle &aFontStyle,
- float aDevPixPerCSSPixel)
+ gfxFontStyle &aFontStyle)
{
HDC tdc = GetDC(nullptr);
bool status = GetSysFontInfo(tdc, anID, aFontName, aFontStyle);
ReleaseDC(nullptr, tdc);
- // 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
--- a/widget/windows/nsLookAndFeel.h
+++ b/widget/windows/nsLookAndFeel.h
@@ -35,18 +35,17 @@ class nsLookAndFeel: public nsXPLookAndF
public:
nsLookAndFeel();
virtual ~nsLookAndFeel();
virtual nsresult NativeGetColor(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);
+ gfxFontStyle& aFontStyle);
virtual char16_t GetPasswordCharacterImpl();
virtual nsTArray<LookAndFeelInt> GetIntCacheImpl();
virtual void SetIntCacheImpl(const nsTArray<LookAndFeelInt>& aLookAndFeelIntCache);
private:
int32_t mUseAccessibilityTheme;
};