Bug 518378: buttons and list boxes in content document are unreasonably large, r=dbaron

This commit is contained in:
Mark Finkle 2009-09-26 20:21:32 -04:00
Родитель 923bf76ebe
Коммит e76ee379f1
7 изменённых файлов: 33 добавлений и 17 удалений

Просмотреть файл

@ -221,7 +221,7 @@ nsSystemFontsGTK2::GetSystemFontInfo(GtkWidget *aWidget, nsString *aFontName,
if (!MOZ_pango_font_description_get_size_is_absolute(desc)) {
// |size| is in pango-points, so convert to pixels.
size *= float(gfxPlatform::GetDPI()) / POINTS_PER_INCH_FLOAT;
size *= float(gfxPlatformGtk::GetPlatformDPI()) / POINTS_PER_INCH_FLOAT;
}
// |size| is now pixels

Просмотреть файл

@ -79,7 +79,7 @@ nsSystemFontsQt::GetSystemFontInfo(const char *aClassName, nsString *aFontName,
aFontStyle->weight = qFont.weight();
// FIXME: Set aFontStyle->stretch correctly!
aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
aFontStyle->size = qFont.pointSizeF() * float(gfxPlatform::GetDPI()) / 72.0f;
aFontStyle->size = qFont.pointSizeF() * float(gfxQtPlatform::GetPlatformDPI()) / 72.0f;
return NS_OK;
}

Просмотреть файл

@ -129,9 +129,18 @@ public:
GdkDrawable *drawable);
GdkDrawable *GetGdkDrawable(gfxASurface *target);
static PRInt32 GetPlatformDPI() {
if (sPlatformDPI < 0) {
gfxPlatformGtk::GetPlatform()->InitDisplayCaps();
}
NS_ASSERTION(sPlatformDPI > 0, "Something is wrong");
return sPlatformDPI;
}
protected:
void InitDisplayCaps();
static PRInt32 sPlatformDPI;
static gfxFontconfigUtils *sFontconfigUtils;
private:

Просмотреть файл

@ -85,9 +85,11 @@ public:
FT_Library GetFTLibrary();
protected:
void InitDisplayCaps();
static PRInt32 GetPlatformDPI() {
return 96;
}
protected:
static gfxFontconfigUtils *sFontconfigUtils;
private:

Просмотреть файл

@ -787,7 +787,7 @@ gfx_pango_fc_font_describe(PangoFont *font)
gfxFcFont *gfxFont = gfxPangoFcFont::GfxFont(self);
if (gfxFont) {
double pixelsize = gfxFont->GetStyle()->size;
double dpi = gfxPlatform::GetDPI();
double dpi = gfxPlatformGtk::GetPlatformDPI();
gint size = moz_pango_units_from_double(pixelsize * dpi / 72.0);
pango_font_description_set_size(result, size);
}
@ -1784,8 +1784,8 @@ gfx_pango_font_map_get_resolution(PangoFcFontMap *fcfontmap,
PangoContext *context)
{
// This merely enables the FC_SIZE field of the pattern to be accurate.
// We use gfxPlatform::GetDPI() much of the time...
return gfxPlatform::GetDPI();
// We use gfxPlatformGtk::GetPlatformDPI() much of the time...
return gfxPlatformGtk::GetPlatformDPI();
}
#ifdef MOZ_WIDGET_GTK2

Просмотреть файл

@ -98,6 +98,7 @@
#include "nsNetUtil.h"
#endif
PRInt32 gfxPlatformGtk::sPlatformDPI = -1;
gfxFontconfigUtils *gfxPlatformGtk::sFontconfigUtils = nsnull;
#ifndef MOZ_PANGO
@ -530,6 +531,15 @@ gfxPlatformGtk::CreateFontGroup(const nsAString &aFamilies,
void
gfxPlatformGtk::InitDisplayCaps()
{
GdkScreen *screen = gdk_screen_get_default();
gtk_settings_get_for_screen(screen); // Make sure init is run so we have a resolution
gfxPlatformGtk::sPlatformDPI = PRInt32(round(gdk_screen_get_resolution(screen)));
if (gfxPlatformGtk::sPlatformDPI <= 0) {
// Fall back to something sane
gfxPlatformGtk::sPlatformDPI = 96;
}
#if defined(MOZ_PLATFORM_HILDON)
// Check the cached value
if (gfxPlatform::sDPI == -1) {
@ -539,13 +549,13 @@ gfxPlatformGtk::InitDisplayCaps()
PR_TRUE, getter_AddRefs(file));
if (NS_SUCCEEDED(rv)) {
nsCOMPtr<nsIInputStream> fileStream;
NS_NewLocalFileInputStream(getter_AddRefs(fileStream), file);
NS_NewLocalFileInputStream(getter_AddRefs(fileStream), file);
nsCOMPtr<nsILineInputStream> lineStream = do_QueryInterface(fileStream);
// Extract the product code from the component_version file
nsCAutoString buffer;
PRBool isMore = PR_TRUE;
if (NS_SUCCEEDED(lineStream->ReadLine(buffer, &isMore))) {
if (lineStream && NS_SUCCEEDED(lineStream->ReadLine(buffer, &isMore))) {
if (StringEndsWith(buffer, NS_LITERAL_CSTRING("RX-51"))) {
gfxPlatform::sDPI = 265; // It's an N900
}
@ -558,14 +568,12 @@ gfxPlatformGtk::InitDisplayCaps()
}
}
#else
GdkScreen *screen = gdk_screen_get_default();
gtk_settings_get_for_screen(screen); // Make sure init is run so we have a resolution
gfxPlatform::sDPI = PRInt32(round(gdk_screen_get_resolution(screen)));
gfxPlatform::sDPI = gfxPlatformGtk::sPlatformDPI;
#endif
if (gfxPlatform::sDPI <= 0.0) {
if (gfxPlatform::sDPI <= 0) {
// Fall back to something sane
gfxPlatform::sDPI = 96.0;
gfxPlatform::sDPI = 96;
} else {
// Minimum DPI is 96
gfxPlatform::sDPI = PR_MAX(sDPI, 96);

Просмотреть файл

@ -363,9 +363,6 @@ gfxQtPlatform::GetFTLibrary()
return gPlatformFTLibrary;
}
void gfxQtPlatform::InitDisplayCaps()
{ }
FontFamily *
gfxQtPlatform::FindFontFamily(const nsAString& aName)
{