Bug 96971: Move GetSystemFont from nsDeviceContext to mozilla::LookAndFeel. r=roc
authorZack Weinberg <zackw@panix.com>
Mon, 20 Feb 2012 15:19:48 -0800
changeset 90146 027f56e65a84cba315935f13c9a71edf6214edc0
parent 90145 621528be5df8c9862d390918d3fb2b214c373d32
child 90147 4038ffaa5d820b7ee60db411517f6d3179e17f4f
child 90150 5dab4b89eabc665297df1e51d7f38f5ca01da589
push id783
push userlsblakk@mozilla.com
push dateTue, 24 Apr 2012 17:33:42 +0000
treeherdermozilla-beta@11faed19f136 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersroc
bugs96971
milestone13.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 96971: Move GetSystemFont from nsDeviceContext to mozilla::LookAndFeel. r=roc
gfx/src/Makefile.in
gfx/src/nsDeviceContext.cpp
gfx/src/nsDeviceContext.h
gfx/src/nsSystemFontsAndroid.cpp
gfx/src/nsSystemFontsAndroid.h
gfx/src/nsSystemFontsGTK2.cpp
gfx/src/nsSystemFontsGTK2.h
gfx/src/nsSystemFontsMac.h
gfx/src/nsSystemFontsMac.mm
gfx/src/nsSystemFontsOS2.cpp
gfx/src/nsSystemFontsOS2.h
gfx/src/nsSystemFontsQt.cpp
gfx/src/nsSystemFontsQt.h
gfx/src/nsSystemFontsWin.cpp
gfx/src/nsSystemFontsWin.h
gfx/src/nsThebesGfxFactory.cpp
layout/base/nsStyleConsts.h
layout/style/nsRuleNode.cpp
widget/LookAndFeel.h
widget/android/nsLookAndFeel.cpp
widget/android/nsLookAndFeel.h
widget/cocoa/nsLookAndFeel.h
widget/cocoa/nsLookAndFeel.mm
widget/gonk/nsLookAndFeel.cpp
widget/gonk/nsLookAndFeel.h
widget/gtk2/nsLookAndFeel.cpp
widget/gtk2/nsLookAndFeel.h
widget/gtk2/nsNativeThemeGTK.cpp
widget/os2/nsLookAndFeel.cpp
widget/os2/nsLookAndFeel.h
widget/qt/nsLookAndFeel.cpp
widget/qt/nsLookAndFeel.h
widget/windows/nsLookAndFeel.cpp
widget/windows/nsLookAndFeel.h
widget/xpwidgets/nsXPLookAndFeel.cpp
widget/xpwidgets/nsXPLookAndFeel.h
--- a/gfx/src/Makefile.in
+++ b/gfx/src/Makefile.in
@@ -49,17 +49,17 @@ EXPORT_LIBRARY = 1
 GRE_MODULE     = 1
 LIBXUL_LIBRARY = 1
 IS_COMPONENT   = 1
 
 XPIDLSRCS = \
 	nsIFontEnumerator.idl \
 	nsIScriptableRegion.idl \
 	$(NULL)
-        
+
 EXPORTS	= \
 	gfxCore.h \
 	gfxCrashReporterUtils.h \
 	nsColor.h \
 	nsColorNames.h \
 	nsColorNameList.h \
 	nsCoord.h \
 	nsFont.h \
@@ -98,44 +98,16 @@ CPPSRCS = \
         nsFontMetrics.cpp \
         nsThebesFontEnumerator.cpp \
        $(NULL)
 
 ifdef MOZ_X11
 CPPSRCS += X11Util.cpp
 endif
 
-ifeq ($(MOZ_WIDGET_TOOLKIT),android)
-CPPSRCS += nsSystemFontsAndroid.cpp
-endif
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),gonk)
-CPPSRCS += nsSystemFontsAndroid.cpp
-endif
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
-CMMSRCS = nsSystemFontsMac.mm
-endif
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
-CPPSRCS += nsSystemFontsGTK2.cpp
-endif
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),os2)
-CPPSRCS += nsSystemFontsOS2.cpp
-endif
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),qt)
-CPPSRCS += nsSystemFontsQt.cpp
-endif
-
-ifeq ($(MOZ_WIDGET_TOOLKIT),windows)
-CPPSRCS += nsSystemFontsWin.cpp
-endif
-
 include $(topsrcdir)/config/rules.mk
 
 CXXFLAGS += $(TK_CFLAGS) $(MOZ_CAIRO_CFLAGS)
 
 ifeq ($(MOZ_WIDGET_TOOLKIT),gtk2)
 DEFINES += -DMOZ_ENABLE_GTK2
 CXXFLAGS += $(MOZ_GTK2_CFLAGS) $(MOZ_PANGO_CFLAGS)
 endif
--- a/gfx/src/nsDeviceContext.cpp
+++ b/gfx/src/nsDeviceContext.cpp
@@ -49,49 +49,28 @@
 #include "mozilla/Preferences.h"
 #include "nsIServiceManager.h"
 #include "nsILanguageAtomService.h"
 #include "nsIObserver.h"
 #include "nsIObserverService.h"
 
 #include "gfxImageSurface.h"
 
+#if !XP_MACOSX
+#include "gfxPDFSurface.h"
+#endif
+
 #ifdef MOZ_ENABLE_GTK2
-#include "nsSystemFontsGTK2.h"
-#include "gfxPDFSurface.h"
 #include "gfxPSSurface.h"
-static nsSystemFontsGTK2 *gSystemFonts = nsnull;
 #elif XP_WIN
-#include "nsSystemFontsWin.h"
 #include "gfxWindowsSurface.h"
-#include "gfxPDFSurface.h"
-static nsSystemFontsWin *gSystemFonts = nsnull;
 #elif defined(XP_OS2)
-#include "nsSystemFontsOS2.h"
 #include "gfxOS2Surface.h"
-#include "gfxPDFSurface.h"
-static nsSystemFontsOS2 *gSystemFonts = nsnull;
 #elif XP_MACOSX
-#include "nsSystemFontsMac.h"
 #include "gfxQuartzSurface.h"
-static nsSystemFontsMac *gSystemFonts = nsnull;
-#elif defined(MOZ_WIDGET_QT)
-#include "nsSystemFontsQt.h"
-#include "gfxPDFSurface.h"
-static nsSystemFontsQt *gSystemFonts = nsnull;
-#elif defined(MOZ_WIDGET_ANDROID)
-#include "nsSystemFontsAndroid.h"
-#include "gfxPDFSurface.h"
-static nsSystemFontsAndroid *gSystemFonts = nsnull;
-#elif defined(MOZ_WIDGET_GONK)
-#include "nsSystemFontsAndroid.h"
-#include "gfxPDFSurface.h"
-static nsSystemFontsAndroid *gSystemFonts = nsnull;
-#else
-#error Need to declare gSystemFonts!
 #endif
 
 using namespace mozilla;
 using mozilla::services::GetObserverService;
 
 class nsFontCache MOZ_FINAL : public nsIObserver
 {
 public:
@@ -447,65 +426,16 @@ nsDeviceContext::CreateRenderingContext(
     pContext->Init(this, mPrintingSurface);
     pContext->Scale(mPrintingScale, mPrintingScale);
     aContext = pContext;
     NS_ADDREF(aContext);
 
     return NS_OK;
 }
 
-/* static */ void
-nsDeviceContext::ClearCachedSystemFonts()
-{
-    if (gSystemFonts) {
-        delete gSystemFonts;
-        gSystemFonts = nsnull;
-    }
-}
-
-nsresult
-nsDeviceContext::GetSystemFont(nsSystemFontID aID, nsFont *aFont) const
-{
-    if (!gSystemFonts) {
-#ifdef MOZ_ENABLE_GTK2
-        gSystemFonts = new nsSystemFontsGTK2();
-#elif XP_WIN
-        gSystemFonts = new nsSystemFontsWin();
-#elif XP_OS2
-        gSystemFonts = new nsSystemFontsOS2();
-#elif XP_MACOSX
-        gSystemFonts = new nsSystemFontsMac();
-#elif defined(MOZ_WIDGET_QT)
-        gSystemFonts = new nsSystemFontsQt();
-#elif defined(ANDROID)
-        gSystemFonts = new nsSystemFontsAndroid();
-#else
-#error Need to know how to create gSystemFonts, fix me!
-#endif
-    }
-
-    nsString fontName;
-    gfxFontStyle fontStyle;
-    nsresult rv = gSystemFonts->GetSystemFont(aID, &fontName, &fontStyle);
-    NS_ENSURE_SUCCESS(rv, rv);
-
-    aFont->name = fontName;
-    aFont->style = fontStyle.style;
-    aFont->systemFont = fontStyle.systemFont;
-    aFont->variant = NS_FONT_VARIANT_NORMAL;
-    aFont->weight = fontStyle.weight;
-    aFont->stretch = fontStyle.stretch;
-    aFont->decorations = NS_FONT_DECORATION_NONE;
-    aFont->size = NSFloatPixelsToAppUnits(fontStyle.size, UnscaledAppUnitsPerDevPixel());
-    //aFont->langGroup = fontStyle.langGroup;
-    aFont->sizeAdjust = fontStyle.sizeAdjust;
-
-    return rv;
-}
-
 nsresult
 nsDeviceContext::GetDepth(PRUint32& aDepth)
 {
     if (mDepth == 0) {
         nsCOMPtr<nsIScreen> primaryScreen;
         mScreenManager->GetPrimaryScreen(getter_AddRefs(primaryScreen));
         primaryScreen->GetColorDepth(reinterpret_cast<PRInt32 *>(&mDepth));
     }
--- a/gfx/src/nsDeviceContext.h
+++ b/gfx/src/nsDeviceContext.h
@@ -46,39 +46,16 @@
 #include "nsIWidget.h"
 #include "nsCoord.h"
 #include "gfxContext.h"
 
 class nsIAtom;
 class nsFontCache;
 class gfxUserFontSet;
 
-typedef enum {
-    eSystemFont_Caption,         // css2
-    eSystemFont_Icon,
-    eSystemFont_Menu,
-    eSystemFont_MessageBox,
-    eSystemFont_SmallCaption,
-    eSystemFont_StatusBar,
-
-    eSystemFont_Window,          // css3
-    eSystemFont_Document,
-    eSystemFont_Workspace,
-    eSystemFont_Desktop,
-    eSystemFont_Info,
-    eSystemFont_Dialog,
-    eSystemFont_Button,
-    eSystemFont_PullDownMenu,
-    eSystemFont_List,
-    eSystemFont_Field,
-
-    eSystemFont_Tooltips,        // moz
-    eSystemFont_Widget
-} nsSystemFontID;
-
 class nsDeviceContext
 {
 public:
     nsDeviceContext();
     ~nsDeviceContext();
 
     NS_INLINE_DECL_REFCOUNTING(nsDeviceContext)
 
@@ -146,32 +123,16 @@ public:
     /**
      * Get the unscaled ratio of app units to dev pixels; useful if something
      * needs to be converted from to unscaled pixels
      */
     PRInt32 UnscaledAppUnitsPerDevPixel() const
     { return mAppUnitsPerDevNotScaledPixel; }
 
     /**
-     * Fill in an nsFont based on the ID of a system font.  This function
-     * may or may not fill in the size, so the size should be set to a
-     * reasonable default before calling.
-     *
-     * @param aID    The system font ID.
-     * @param aInfo  The font structure to be filled in.
-     * @return error status
-     */
-    nsresult GetSystemFont(nsSystemFontID aID, nsFont *aFont) const;
-
-    /**
-     * Clear cached system fonts (refresh from theme when requested).
-     */
-    static void ClearCachedSystemFonts();
-
-    /**
      * Get the nsFontMetrics that describe the properties of
      * an nsFont.
      * @param aFont font description to obtain metrics for
      * @param aLanguage the language of the document
      * @param aMetrics out parameter for font metrics
      * @param aUserFontSet user font set
      * @return error status
      */
deleted file mode 100644
--- a/gfx/src/nsSystemFontsAndroid.cpp
+++ /dev/null
@@ -1,111 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Android port
- *
- * The Initial Developer of the Original Code is mozilla.org.
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Vladimir Vukicevic <vladimir@pobox.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsSystemFontsAndroid.h"
-#include "gfxPlatform.h"
-
-#define DEFAULT_FONT  "Droid Sans"
-
-nsSystemFontsAndroid::nsSystemFontsAndroid()
-  : mDefaultFontName(NS_LITERAL_STRING(DEFAULT_FONT))
-  , mButtonFontName(NS_LITERAL_STRING(DEFAULT_FONT))
-  , mFieldFontName(NS_LITERAL_STRING(DEFAULT_FONT))
-  , mMenuFontName(NS_LITERAL_STRING(DEFAULT_FONT))
-{
-}
-
-nsSystemFontsAndroid::~nsSystemFontsAndroid()
-{
-}
-
-nsresult
-nsSystemFontsAndroid::GetSystemFontInfo(const char *aClassName, nsString *aFontName,
-                                        gfxFontStyle *aFontStyle) const
-{
-    aFontStyle->style = FONT_STYLE_NORMAL;
-    aFontStyle->systemFont = true;
-    *aFontName = NS_LITERAL_STRING("Droid Sans");
-    aFontStyle->weight = 400;
-    aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
-    aFontStyle->size = 9.0 * 96.0f / 72.0f;
-    return NS_OK;
-}
-
-
-nsresult
-nsSystemFontsAndroid::GetSystemFont(nsSystemFontID anID, nsString *aFontName,
-                                    gfxFontStyle *aFontStyle) const
-{
-    switch (anID) {
-    case eSystemFont_Menu:         // css2
-    case eSystemFont_PullDownMenu: // css3
-        *aFontName = mMenuFontName;
-        *aFontStyle = mMenuFontStyle;
-        break;
-
-    case eSystemFont_Field:        // css3
-    case eSystemFont_List:         // css3
-        *aFontName = mFieldFontName;
-        *aFontStyle = mFieldFontStyle;
-        break;
-
-    case eSystemFont_Button:       // css3
-        *aFontName = mButtonFontName;
-        *aFontStyle = mButtonFontStyle;
-        break;
-
-    case eSystemFont_Caption:      // css2
-    case eSystemFont_Icon:         // css2
-    case eSystemFont_MessageBox:   // css2
-    case eSystemFont_SmallCaption: // css2
-    case eSystemFont_StatusBar:    // css2
-    case eSystemFont_Window:       // css3
-    case eSystemFont_Document:     // css3
-    case eSystemFont_Workspace:    // css3
-    case eSystemFont_Desktop:      // css3
-    case eSystemFont_Info:         // css3
-    case eSystemFont_Dialog:       // css3
-    case eSystemFont_Tooltips:     // moz
-    case eSystemFont_Widget:       // moz
-        *aFontName = mDefaultFontName;
-        *aFontStyle = mDefaultFontStyle;
-        break;
-    }
-
-    return NS_OK;
-}
-
deleted file mode 100644
--- a/gfx/src/nsSystemFontsAndroid.h
+++ /dev/null
@@ -1,79 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Android port
- *
- * The Initial Developer of the Original Code is mozilla.org.
- * Portions created by the Initial Developer are Copyright (C) 2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Vladimir Vukicevic <vladimir@pobox.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _NS_SYSTEMFONTSANDROID_H_
-#define _NS_SYSTEMFONTSANDROID_H_
-
-#include "gfxFont.h"
-#include "nsDeviceContext.h"
-
-class nsSystemFontsAndroid
-{
-public:
-    nsSystemFontsAndroid();
-    ~nsSystemFontsAndroid();
-
-    nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName,
-                           gfxFontStyle *aFontStyle) const;
-
-private:
-
-    nsresult GetSystemFontInfo(const char *aClassName, nsString *aFontName,
-                               gfxFontStyle *aFontStyle) const;
-
-    /*
-     * The following system font constants exist:
-     *
-     * css2: http://www.w3.org/TR/REC-CSS2/fonts.html#x27
-     * eSystemFont_Caption, eSystemFont_Icon, eSystemFont_Menu,
-     * eSystemFont_MessageBox, eSystemFont_SmallCaption,
-     * eSystemFont_StatusBar,
-     * // css3
-     * eSystemFont_Window, eSystemFont_Document,
-     * eSystemFont_Workspace, eSystemFont_Desktop,
-     * eSystemFont_Info, eSystemFont_Dialog,
-     * eSystemFont_Button, eSystemFont_PullDownMenu,
-     * eSystemFont_List, eSystemFont_Field,
-     * // moz
-     * eSystemFont_Tooltips, eSystemFont_Widget
-     */
-    nsString mDefaultFontName, mButtonFontName, mFieldFontName, mMenuFontName;
-    gfxFontStyle mDefaultFontStyle, mButtonFontStyle, mFieldFontStyle, mMenuFontStyle;
-};
-
-#endif /* _NS_SYSTEMFONTSANDROID_H_ */
-
deleted file mode 100644
--- a/gfx/src/nsSystemFontsGTK2.cpp
+++ /dev/null
@@ -1,287 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is thebes gfx
- *
- * The Initial Developer of the Original Code is mozilla.org.
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Vladimir Vukicevic <vladimir@pobox.com>
- *   Stuart Parmenter <pavlov@pavlov.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-// for strtod()
-#include <stdlib.h>
-
-#include "nsSystemFontsGTK2.h"
-#include "prlink.h"
-
-#include <gtk/gtk.h>
-#include <gdk/gdk.h>
-
-#ifdef MOZ_PANGO
-#include <pango/pango.h>
-#include <pango/pango-fontmap.h>
-#endif
-
-#include <fontconfig/fontconfig.h>
-#include "gfxPlatformGtk.h"
-
-// Glue to avoid build/runtime dependencies on Pango > 1.6
-#if defined(MOZ_PANGO) && !defined(THEBES_USE_PANGO_CAIRO)
-static gboolean
-(* PTR_pango_font_description_get_size_is_absolute)(PangoFontDescription*)
-    = nsnull;
-
-static void InitPangoLib()
-{
-    static bool initialized = false;
-    if (initialized)
-        return;
-    initialized = true;
-
-    PRLibrary *pangoLib = nsnull;
-    PTR_pango_font_description_get_size_is_absolute =
-        (gboolean (*)(PangoFontDescription*))
-        PR_FindFunctionSymbolAndLibrary("pango_font_description_get_size_is_absolute",
-                                        &pangoLib);
-    if (pangoLib)
-        PR_UnloadLibrary(pangoLib);
-}
-
-static void
-ShutdownPangoLib()
-{
-}
-
-static gboolean
-MOZ_pango_font_description_get_size_is_absolute(PangoFontDescription *desc)
-{
-    if (PTR_pango_font_description_get_size_is_absolute) {
-        return PTR_pango_font_description_get_size_is_absolute(desc);
-    }
-
-    // In old versions of pango, this was always false.
-    return false;
-}
-#else
-static inline void InitPangoLib()
-{
-}
-
-static inline void ShutdownPangoLib()
-{
-}
-
-#ifdef MOZ_PANGO
-static inline gboolean
-MOZ_pango_font_description_get_size_is_absolute(PangoFontDescription *desc)
-{
-    pango_font_description_get_size_is_absolute(desc);
-}
-#endif
-#endif
-
-nsSystemFontsGTK2::nsSystemFontsGTK2()
-  : mDefaultFontName(NS_LITERAL_STRING("sans-serif"))
-  , mButtonFontName(NS_LITERAL_STRING("sans-serif"))
-  , mFieldFontName(NS_LITERAL_STRING("sans-serif"))
-  , mMenuFontName(NS_LITERAL_STRING("sans-serif"))
-{
-    InitPangoLib();
-
-    /*
-     * Much of the widget creation code here is similar to the code in
-     * nsLookAndFeel::InitColors().
-     */
-
-    // mDefaultFont
-    GtkWidget *label = gtk_label_new("M");
-    GtkWidget *parent = gtk_fixed_new();
-    GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
-
-    gtk_container_add(GTK_CONTAINER(parent), label);
-    gtk_container_add(GTK_CONTAINER(window), parent);
-
-    gtk_widget_ensure_style(label);
-
-    GetSystemFontInfo(label, &mDefaultFontName, &mDefaultFontStyle);
-
-    gtk_widget_destroy(window);  // no unref, windows are different
-
-    // mFieldFont
-    GtkWidget *entry = gtk_entry_new();
-    parent = gtk_fixed_new();
-    window = gtk_window_new(GTK_WINDOW_POPUP);
-
-    gtk_container_add(GTK_CONTAINER(parent), entry);
-    gtk_container_add(GTK_CONTAINER(window), parent);
-    gtk_widget_ensure_style(entry);
-
-    GetSystemFontInfo(entry, &mFieldFontName, &mFieldFontStyle);
-
-    gtk_widget_destroy(window);  // no unref, windows are different
-
-    // mMenuFont
-    GtkWidget *accel_label = gtk_accel_label_new("M");
-    GtkWidget *menuitem = gtk_menu_item_new();
-    GtkWidget *menu = gtk_menu_new();
-    g_object_ref_sink(GTK_OBJECT(menu));
-
-    gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
-    gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(menu), menuitem);
-
-    gtk_widget_ensure_style(accel_label);
-
-    GetSystemFontInfo(accel_label, &mMenuFontName, &mMenuFontStyle);
-
-    g_object_unref(menu);
-
-    // mButtonFont
-    parent = gtk_fixed_new();
-    GtkWidget *button = gtk_button_new();
-    label = gtk_label_new("M");
-    window = gtk_window_new(GTK_WINDOW_POPUP);
-          
-    gtk_container_add(GTK_CONTAINER(button), label);
-    gtk_container_add(GTK_CONTAINER(parent), button);
-    gtk_container_add(GTK_CONTAINER(window), parent);
-
-    gtk_widget_ensure_style(label);
-
-    GetSystemFontInfo(label, &mButtonFontName, &mButtonFontStyle);
-
-    gtk_widget_destroy(window);  // no unref, windows are different
-}
-
-nsSystemFontsGTK2::~nsSystemFontsGTK2()
-{
-    ShutdownPangoLib();
-}
-
-nsresult
-nsSystemFontsGTK2::GetSystemFontInfo(GtkWidget *aWidget, nsString *aFontName,
-                                     gfxFontStyle *aFontStyle) const
-{
-#ifdef MOZ_PANGO
-    GtkSettings *settings = gtk_widget_get_settings(aWidget);
-
-    aFontStyle->style       = FONT_STYLE_NORMAL;
-
-    gchar *fontname;
-    g_object_get(settings, "gtk-font-name", &fontname, NULL);
-
-    PangoFontDescription *desc;
-    desc = pango_font_description_from_string(fontname);
-
-    aFontStyle->systemFont = true;
-
-    g_free(fontname);
-
-    NS_NAMED_LITERAL_STRING(quote, "\"");
-    NS_ConvertUTF8toUTF16 family(pango_font_description_get_family(desc));
-    *aFontName = quote + family + quote;
-
-    aFontStyle->weight = pango_font_description_get_weight(desc);
-
-    // FIXME: Set aFontStyle->stretch correctly!
-    aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
-
-    float size = float(pango_font_description_get_size(desc)) / PANGO_SCALE;
-
-    // |size| is now either pixels or pango-points (not Mozilla-points!)
-
-    if (!MOZ_pango_font_description_get_size_is_absolute(desc)) {
-        // |size| is in pango-points, so convert to pixels.
-        size *= float(gfxPlatformGtk::GetDPI()) / POINTS_PER_INCH_FLOAT;
-    }
-
-    // |size| is now pixels
-
-    aFontStyle->size = size;
-  
-    pango_font_description_free(desc);
-
-#else
-    /* FIXME: DFB FT2 Hardcoding the system font info for now.. */
-    aFontStyle->style       = FONT_STYLE_NORMAL;
-    aFontStyle->systemFont = true;
-
-    NS_NAMED_LITERAL_STRING(fontname, "\"Sans\"");
-    *aFontName = fontname;
-    aFontStyle->weight = 400;
-    aFontStyle->size = 40/3;
-
-#endif
-
-    return NS_OK;
-}
-
-nsresult
-nsSystemFontsGTK2::GetSystemFont(nsSystemFontID anID, nsString *aFontName,
-                                 gfxFontStyle *aFontStyle) const
-{
-    switch (anID) {
-    case eSystemFont_Menu:         // css2
-    case eSystemFont_PullDownMenu: // css3
-        *aFontName = mMenuFontName;
-        *aFontStyle = mMenuFontStyle;
-        break;
-
-    case eSystemFont_Field:        // css3
-    case eSystemFont_List:         // css3
-        *aFontName = mFieldFontName;
-        *aFontStyle = mFieldFontStyle;
-        break;
-
-    case eSystemFont_Button:       // css3
-        *aFontName = mButtonFontName;
-        *aFontStyle = mButtonFontStyle;
-        break;
-
-    case eSystemFont_Caption:      // css2
-    case eSystemFont_Icon:         // css2
-    case eSystemFont_MessageBox:   // css2
-    case eSystemFont_SmallCaption: // css2
-    case eSystemFont_StatusBar:    // css2
-    case eSystemFont_Window:       // css3
-    case eSystemFont_Document:     // css3
-    case eSystemFont_Workspace:    // css3
-    case eSystemFont_Desktop:      // css3
-    case eSystemFont_Info:         // css3
-    case eSystemFont_Dialog:       // css3
-    case eSystemFont_Tooltips:     // moz
-    case eSystemFont_Widget:       // moz
-        *aFontName = mDefaultFontName;
-        *aFontStyle = mDefaultFontStyle;
-        break;
-    }
-
-    return NS_OK;
-}
deleted file mode 100644
--- a/gfx/src/nsSystemFontsGTK2.h
+++ /dev/null
@@ -1,81 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is thebes gfx
- *
- * The Initial Developer of the Original Code is mozilla.org.
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Vladimir Vukicevic <vladimir@pobox.com>
- *   Stuart Parmenter <pavlov@pavlov.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _NS_SYSTEMFONTSGTK2_H_
-#define _NS_SYSTEMFONTSGTK2_H_
-
-#include "gfxFont.h"
-#include "nsDeviceContext.h"
-
-typedef struct _GtkWidget GtkWidget;
-
-class nsSystemFontsGTK2
-{
-public:
-    nsSystemFontsGTK2();
-    ~nsSystemFontsGTK2();
-
-    nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName,
-                           gfxFontStyle *aFontStyle) const;
-
-private:
-
-    nsresult GetSystemFontInfo(GtkWidget *aWidget, nsString *aFontName,
-                               gfxFontStyle *aFontStyle) const;
-
-    /*
-     * The following system font constants exist:
-     *
-     * css2: http://www.w3.org/TR/REC-CSS2/fonts.html#x27
-     * eSystemFont_Caption, eSystemFont_Icon, eSystemFont_Menu,
-     * eSystemFont_MessageBox, eSystemFont_SmallCaption,
-     * eSystemFont_StatusBar,
-     * // css3
-     * eSystemFont_Window, eSystemFont_Document,
-     * eSystemFont_Workspace, eSystemFont_Desktop,
-     * eSystemFont_Info, eSystemFont_Dialog,
-     * eSystemFont_Button, eSystemFont_PullDownMenu,
-     * eSystemFont_List, eSystemFont_Field,
-     * // moz
-     * eSystemFont_Tooltips, eSystemFont_Widget
-     */
-    nsString mDefaultFontName, mButtonFontName, mFieldFontName, mMenuFontName;
-    gfxFontStyle mDefaultFontStyle, mButtonFontStyle, mFieldFontStyle, mMenuFontStyle;
-};
-
-#endif /* _NS_SYSTEMFONTSGTK2_H_ */
deleted file mode 100644
--- a/gfx/src/nsSystemFontsMac.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Corporation code.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2006
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Vladimir Vukicevic <vladimir@pobox.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _NS_SYSTEMFONTSMAC_H_
-#define _NS_SYSTEMFONTSMAC_H_
-
-#include "gfxFont.h"
-#include "nsDeviceContext.h"
-
-class nsSystemFontsMac
-{
-public:
-    nsSystemFontsMac();
-    nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName,
-                           gfxFontStyle *aFontStyle) const;
-};
-
-#endif /* _NS_SYSTEMFONTSMAC_H_ */
deleted file mode 100644
--- a/gfx/src/nsSystemFontsMac.mm
+++ /dev/null
@@ -1,167 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*-
- * ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is Mozilla Corporation code.
- *
- * The Initial Developer of the Original Code is Mozilla Foundation.
- * Portions created by the Initial Developer are Copyright (C) 2006-2009
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Vladimir Vukicevic <vladimir@pobox.com>
- *   Jonathan Kew <jfkthame@gmail.com>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsSystemFontsMac.h"
-#include <Cocoa/Cocoa.h>
-
-nsSystemFontsMac::nsSystemFontsMac()
-{
-}
-
-// copied from gfxQuartzFontCache.mm, maybe should go in a Cocoa utils file somewhere
-static void GetStringForNSString(const NSString *aSrc, nsAString& aDest)
-{
-    aDest.SetLength([aSrc length]);
-    [aSrc getCharacters:aDest.BeginWriting()];
-}
-
-nsresult
-nsSystemFontsMac::GetSystemFont(nsSystemFontID aID, nsString *aFontName,
-                                gfxFontStyle *aFontStyle) const
-{
-    // hack for now
-    if (aID == eSystemFont_Window ||
-        aID == eSystemFont_Document)
-    {
-        aFontStyle->style       = FONT_STYLE_NORMAL;
-        aFontStyle->weight      = FONT_WEIGHT_NORMAL;
-        aFontStyle->stretch     = NS_FONT_STRETCH_NORMAL;
-
-        aFontName->AssignLiteral("sans-serif");
-        aFontStyle->size = 14;
-        aFontStyle->systemFont = true;
-
-        return NS_OK;
-    }
-
-/* possibilities, see NSFont Class Reference:
-    [NSFont boldSystemFontOfSize:     0.0]
-    [NSFont controlContentFontOfSize: 0.0]
-    [NSFont labelFontOfSize:          0.0]
-    [NSFont menuBarFontOfSize:        0.0]
-    [NSFont menuFontOfSize:           0.0]
-    [NSFont messageFontOfSize:        0.0]
-    [NSFont paletteFontOfSize:        0.0]
-    [NSFont systemFontOfSize:         0.0]
-    [NSFont titleBarFontOfSize:       0.0]
-    [NSFont toolTipsFontOfSize:       0.0]
-    [NSFont userFixedPitchFontOfSize: 0.0]
-    [NSFont userFontOfSize:           0.0]
-    [NSFont systemFontOfSize:         [NSFont smallSystemFontSize]]
-    [NSFont boldSystemFontOfSize:     [NSFont smallSystemFontSize]]
-*/
-
-    NSFont *font = nsnull;
-    switch (aID) {
-        // css2
-        case eSystemFont_Caption:
-            font = [NSFont systemFontOfSize:0.0];
-            break;
-        case eSystemFont_Icon: // used in urlbar; tried labelFont, but too small
-            font = [NSFont controlContentFontOfSize:0.0];
-            break;
-        case eSystemFont_Menu:
-            font = [NSFont systemFontOfSize:0.0];
-            break;
-        case eSystemFont_MessageBox:
-            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
-            break;
-        case eSystemFont_SmallCaption:
-            font = [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]];
-            break;
-        case eSystemFont_StatusBar:
-            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
-            break;
-        // css3
-        //case eSystemFont_Window:     = 'sans-serif'
-        //case eSystemFont_Document:   = 'sans-serif'
-        case eSystemFont_Workspace:
-            font = [NSFont controlContentFontOfSize:0.0];
-            break;
-        case eSystemFont_Desktop:
-            font = [NSFont controlContentFontOfSize:0.0];
-            break;
-        case eSystemFont_Info:
-            font = [NSFont controlContentFontOfSize:0.0];
-            break;
-        case eSystemFont_Dialog:
-            font = [NSFont systemFontOfSize:0.0];
-            break;
-        case eSystemFont_Button:
-            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
-            break;
-        case eSystemFont_PullDownMenu:
-            font = [NSFont menuBarFontOfSize:0.0];
-            break;
-        case eSystemFont_List:
-            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
-            break;
-        case eSystemFont_Field:
-            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
-            break;
-        // moz
-        case eSystemFont_Tooltips:
-            font = [NSFont toolTipsFontOfSize:0.0];
-            break;
-        case eSystemFont_Widget:
-            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
-            break;
-        default:
-            // should never hit this
-            return NS_ERROR_FAILURE;
-    }
-
-    NS_ASSERTION(font != nsnull, "failed to find a system font!");
-
-    GetStringForNSString([font familyName], *aFontName);
-    aFontStyle->size = [font pointSize];
-
-    NSFontSymbolicTraits traits = [[font fontDescriptor] symbolicTraits];
-    if (traits & NSFontBoldTrait)
-        aFontStyle->weight = FONT_WEIGHT_BOLD;
-    if (traits & NSFontItalicTrait)
-        aFontStyle->style = FONT_STYLE_ITALIC;
-    aFontStyle->stretch =
-        (traits & NSFontExpandedTrait) ?
-            NS_FONT_STRETCH_EXPANDED : (traits & NSFontCondensedTrait) ?
-                NS_FONT_STRETCH_CONDENSED : NS_FONT_STRETCH_NORMAL;
-
-    aFontStyle->systemFont = true;
-
-    return NS_OK;
-}
deleted file mode 100644
--- a/gfx/src/nsSystemFontsOS2.cpp
+++ /dev/null
@@ -1,275 +0,0 @@
-/* vim: set sw=4 sts=4 et cin: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OS/2 system font code in Thebes.
- *
- * The Initial Developer of the Original Code is
- * Peter Weilbacher <mozilla@Weilbacher.org>.
- * Portions created by the Initial Developer are Copyright (C) 2006
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  Developers of code taken from nsDeviceContextOS2:
- *    John Fairhurst, <john_fairhurst@iname.com>
- *    Henry Sobotka <sobotka@axess.com>
- *    IBM Corp.
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsSystemFontsOS2.h"
-
-#define INCL_WINWINDOWMGR
-#define INCL_WINSHELLDATA
-#define INCL_DOSNLS
-#define INCL_DOSERRORS
-#include <os2.h>
-
-#include <stdlib.h>
-
-/************************
- *   Helper functions   *
- ************************/
-static BOOL bIsDBCS;
-static BOOL bIsDBCSSet = FALSE;
-
-/* Helper function to determine if we are running on DBCS */
-BOOL IsDBCS()
-{
-    if (!bIsDBCSSet) {
-        // the following lines of code determine whether the system is a DBCS country
-        APIRET rc;
-        COUNTRYCODE ctrycodeInfo = {0};
-        CHAR        achDBCSInfo[12] = {0};                  // DBCS environmental vector
-        ctrycodeInfo.country  = 0;                          // current country
-        ctrycodeInfo.codepage = 0;                          // current codepage
-
-        rc = DosQueryDBCSEnv(sizeof(achDBCSInfo), &ctrycodeInfo, achDBCSInfo);
-        if (rc == NO_ERROR) {
-            // Non-DBCS countries will have four bytes in the first four bytes of the
-            // DBCS environmental vector
-            if (achDBCSInfo[0] != 0 || achDBCSInfo[1] != 0 ||
-                achDBCSInfo[2] != 0 || achDBCSInfo[3] != 0)
-            {
-                bIsDBCS = TRUE;
-            } else {
-                bIsDBCS = FALSE;
-            }
-        } else {
-            bIsDBCS = FALSE;
-        } /* endif */
-        bIsDBCSSet = TRUE;
-    } /* endif */
-    return bIsDBCS;
-}
-
-/* Helper function to query font from INI file */
-void QueryFontFromINI(char* fontType, char* fontName, ULONG ulLength)
-{
-    ULONG ulMaxNameL = ulLength;
-
-    /* We had to switch to using PrfQueryProfileData because */
-    /* some users have binary font data in their INI files */
-    BOOL rc = PrfQueryProfileData(HINI_USER, (PCSZ)"PM_SystemFonts", (PCSZ)fontType,
-                                  fontName, &ulMaxNameL);
-    /* If there was no entry in the INI, default to something */
-    if (rc == FALSE) {
-        /* Different values for DBCS vs. SBCS */
-        /* WarpSans is only available on Warp 4, we exclude Warp 3 now */
-        if (!IsDBCS()) {
-            strcpy(fontName, "9.WarpSans");
-        } else {
-            strcpy(fontName, "9.WarpSans Combined");
-        }
-    } else {
-        /* null terminate fontname */
-        fontName[ulMaxNameL] = '\0';
-    }
-}
-
-/************************/
-
-nsSystemFontsOS2::nsSystemFontsOS2()
-{
-#ifdef DEBUG_thebes
-    printf("nsSystemFontsOS2::nsSystemFontsOS2()\n");
-#endif
-}
-
-/*
- * Query the font used for various CSS properties (aID) from the system.
- * For OS/2, only very few fonts are defined in the system, so most of the IDs
- * resolve to the same system font.
- * The font queried will give back a string like
- *    9.WarpSans Bold
- *    12.Times New Roman Bold Italic
- *    10.Times New Roman.Strikeout.Underline
- *    20.Bitstream Vera Sans Mono Obli
- * (always restricted to 32 chars, at least before the second dot)
- * We use the value before the dot as the font size (in pt, and convert it to
- * px using the screen resolution) and then try to use the rest of the string
- * to determine the font style from it.
- */
-nsresult nsSystemFontsOS2::GetSystemFont(nsSystemFontID aID, nsString* aFontName,
-                                         gfxFontStyle *aFontStyle) const
-{
-#ifdef DEBUG_thebes
-    printf("nsSystemFontsOS2::GetSystemFont: ");
-#endif
-    char szFontNameSize[MAXNAMEL];
-
-    switch (aID)
-    {
-    case eSystemFont_Icon:
-        QueryFontFromINI("IconText", szFontNameSize, MAXNAMEL);
-#ifdef DEBUG_thebes
-        printf("IconText ");
-#endif
-        break;
-
-    case eSystemFont_Menu:
-        QueryFontFromINI("Menus", szFontNameSize, MAXNAMEL);
-#ifdef DEBUG_thebes
-        printf("Menus ");
-#endif
-        break;
-
-    case eSystemFont_Caption:
-    case eSystemFont_MessageBox:
-    case eSystemFont_SmallCaption:
-    case eSystemFont_StatusBar:
-    case eSystemFont_Tooltips:
-    case eSystemFont_Widget:
-
-    case eSystemFont_Window:      // css3
-    case eSystemFont_Document:
-    case eSystemFont_Workspace:
-    case eSystemFont_Desktop:
-    case eSystemFont_Info:
-    case eSystemFont_Dialog:
-    case eSystemFont_Button:
-    case eSystemFont_PullDownMenu:
-    case eSystemFont_List:
-    case eSystemFont_Field:
-        QueryFontFromINI("WindowText", szFontNameSize, MAXNAMEL);
-#ifdef DEBUG_thebes
-        printf("WindowText ");
-#endif
-        break;
-
-    default:
-        NS_WARNING("None of the listed font types, using WarpSans");
-        if (!IsDBCS()) {
-            strcpy(szFontNameSize, "9.WarpSans");
-        } else {
-            strcpy(szFontNameSize, "9.WarpSans Combined");
-        }
-    } // switch
-#ifdef DEBUG_thebes
-    printf(" (%s)\n", szFontNameSize);
-#endif
-
-    char *szFacename = strchr(szFontNameSize, '.');
-    if (!szFacename || (*(szFacename++) == '\0'))
-        return NS_ERROR_FAILURE;
-
-    // local DPI for size will be taken into account below
-    aFontStyle->size = atof(szFontNameSize);
-
-    // determine DPI resolution of screen device to compare compute
-    // font size in pixels
-    HPS ps = WinGetScreenPS(HWND_DESKTOP);
-    HDC dc = GpiQueryDevice(ps);
-    // effective vertical resolution in DPI
-    LONG vertScreenRes = 120; // assume 120 dpi as default
-    DevQueryCaps(dc, CAPS_VERTICAL_FONT_RES, 1, &vertScreenRes);
-    WinReleasePS(ps);
-
-    // now scale to make pixels from points (1 pt = 1/72in)
-    aFontStyle->size *= vertScreenRes / 72.0;
-
-    NS_ConvertUTF8toUTF16 fontFace(szFacename);
-    int pos = 0;
-
-    // this is a system font in any case
-    aFontStyle->systemFont = true;
-
-    // bold fonts should have " Bold" in their names, at least we hope that they
-    // do, otherwise it's bad luck
-    NS_NAMED_LITERAL_CSTRING(spcBold, " Bold");
-    if ((pos = fontFace.Find(spcBold.get(), false, 0, -1)) > -1) {
-        aFontStyle->weight = FONT_WEIGHT_BOLD;
-        // strip the attribute, now that we have set it in the gfxFontStyle
-        fontFace.Cut(pos, spcBold.Length());
-    } else {
-        aFontStyle->weight = FONT_WEIGHT_NORMAL;
-    }
-
-    // FIXME: Set aFontStyle->stretch correctly!
-    aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
-
-    // similar hopes for italic and oblique fonts...
-    NS_NAMED_LITERAL_CSTRING(spcItalic, " Italic");
-    NS_NAMED_LITERAL_CSTRING(spcOblique, " Oblique");
-    NS_NAMED_LITERAL_CSTRING(spcObli, " Obli");
-    if ((pos = fontFace.Find(spcItalic.get(), false, 0, -1)) > -1) {
-        aFontStyle->style = FONT_STYLE_ITALIC;
-        fontFace.Cut(pos, spcItalic.Length());
-    } else if ((pos = fontFace.Find(spcOblique.get(), false, 0, -1)) > -1) {
-        // oblique fonts are rare on OS/2 and not specially supported by
-        // the GPI system, but at least we are trying...
-        aFontStyle->style = FONT_STYLE_OBLIQUE;
-        fontFace.Cut(pos, spcOblique.Length());
-    } else if ((pos = fontFace.Find(spcObli.get(), false, 0, -1)) > -1) {
-        // especially oblique often gets cut by the 32 char limit to "Obli",
-        // so search for that, too (anything shorter would be ambiguous)
-        aFontStyle->style = FONT_STYLE_OBLIQUE;
-        // In this case, assume that this is the last property in the line
-        // and cut off everything else, too
-        // This is needed in case it was really Obliq or Obliqu...
-        fontFace.Cut(pos, fontFace.Length());
-    } else {
-        aFontStyle->style = FONT_STYLE_NORMAL;
-    }
-
-    // just throw away any modifiers that are separated by dots (which are either
-    // .Strikeout, .Underline, or .Outline, none of which have a corresponding
-    // gfxFont property)
-    if ((pos = fontFace.Find(".", false, 0, -1)) > -1) {
-        fontFace.Cut(pos, fontFace.Length());
-    }
-
-#ifdef DEBUG_thebes
-    printf("  after=%s\n", NS_LossyConvertUTF16toASCII(fontFace).get());
-    printf("  style: %s %s %s\n",
-           (aFontStyle->weight == FONT_WEIGHT_BOLD) ? "BOLD" : "",
-           (aFontStyle->style == FONT_STYLE_ITALIC) ? "ITALIC" : "",
-           (aFontStyle->style == FONT_STYLE_OBLIQUE) ? "OBLIQUE" : "");
-#endif
-    NS_NAMED_LITERAL_STRING(quote, "\""); // seems like we need quotes around the font name
-    *aFontName = quote + fontFace + quote;
-
-    return NS_OK;
-}
deleted file mode 100644
--- a/gfx/src/nsSystemFontsOS2.h
+++ /dev/null
@@ -1,55 +0,0 @@
-/* vim: set sw=4 sts=4 et cin: */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is OS/2 system font code in Thebes.
- *
- * The Initial Developer of the Original Code is
- * Peter Weilbacher <mozilla@Weilbacher.org>.
- * Portions created by the Initial Developer are Copyright (C) 2006
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *  John Fairhurst, <john_fairhurst@iname.com> } original developers of
- *  Henry Sobotka <sobotka@axess.com>          } code taken from 
- *  IBM Corp.                                  } nsDeviceContextOS2
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _NS_SYSTEMFONTSOS2_H_
-#define _NS_SYSTEMFONTSOS2_H_
-
-#include "gfxFont.h"
-#include "nsDeviceContext.h"
-
-class nsSystemFontsOS2
-{
-public:
-    nsSystemFontsOS2();
-    nsresult GetSystemFont(nsSystemFontID aID, nsString* aFontName,
-                           gfxFontStyle *aFontStyle) const;
-};
-
-#endif /* _NS_SYSTEMFONTSOS2_H_ */
deleted file mode 100644
--- a/gfx/src/nsSystemFontsQt.cpp
+++ /dev/null
@@ -1,134 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is thebes gfx
- *
- * The Initial Developer of the Original Code is mozilla.org.
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Vladimir Vukicevic <vladimir@pobox.com>
- *   Stuart Parmenter <pavlov@pavlov.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-// Qt headers must be included before anything that might pull in our
-// malloc wrappers.
-#include <QApplication>
-#include <QFont>
-
-#include "nsSystemFontsQt.h"
-#include "gfxQtPlatform.h"
-
-nsSystemFontsQt::nsSystemFontsQt()
-  : mDefaultFontName(NS_LITERAL_STRING("sans-serif"))
-  , mButtonFontName(NS_LITERAL_STRING("sans-serif"))
-  , mFieldFontName(NS_LITERAL_STRING("sans-serif"))
-  , mMenuFontName(NS_LITERAL_STRING("sans-serif"))
-{
-   // What about using QFontInfo? is it faster or what?
-   GetSystemFontInfo("Qlabel", &mDefaultFontName, &mDefaultFontStyle);
-
-   GetSystemFontInfo("QlineEdit", &mFieldFontName, &mFieldFontStyle);
-
-   GetSystemFontInfo("QAction", &mMenuFontName, &mMenuFontStyle);
-
-   GetSystemFontInfo("QPushButton", &mButtonFontName, &mButtonFontStyle);
-}
-
-nsSystemFontsQt::~nsSystemFontsQt()
-{
-    // No implementation needed
-}
-
-nsresult
-nsSystemFontsQt::GetSystemFontInfo(const char *aClassName, nsString *aFontName,
-                                   gfxFontStyle *aFontStyle) const
-{
-    QFont qFont = QApplication::font(aClassName);
-
-    aFontStyle->style = FONT_STYLE_NORMAL;
-    aFontStyle->systemFont = true;
-    NS_NAMED_LITERAL_STRING(quote, "\"");
-    nsString family((PRUnichar*)qFont.family().data());
-    *aFontName = quote + family + quote;
-    aFontStyle->weight = qFont.weight();
-    // FIXME: Set aFontStyle->stretch correctly!
-    aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
-    // use pixel size directly if it is set, otherwise compute from point size
-    if (qFont.pixelSize() != -1) {
-        aFontStyle->size = qFont.pixelSize();
-    } else {
-        aFontStyle->size = qFont.pointSizeF() * 96.0f / 72.0f;
-    }
-    return NS_OK;
-}
-
-
-nsresult
-nsSystemFontsQt::GetSystemFont(nsSystemFontID anID, nsString *aFontName,
-                                 gfxFontStyle *aFontStyle) const
-{
-    switch (anID) {
-    case eSystemFont_Menu:         // css2
-    case eSystemFont_PullDownMenu: // css3
-        *aFontName = mMenuFontName;
-        *aFontStyle = mMenuFontStyle;
-        break;
-
-    case eSystemFont_Field:        // css3
-    case eSystemFont_List:         // css3
-        *aFontName = mFieldFontName;
-        *aFontStyle = mFieldFontStyle;
-        break;
-
-    case eSystemFont_Button:       // css3
-        *aFontName = mButtonFontName;
-        *aFontStyle = mButtonFontStyle;
-        break;
-
-    case eSystemFont_Caption:      // css2
-    case eSystemFont_Icon:         // css2
-    case eSystemFont_MessageBox:   // css2
-    case eSystemFont_SmallCaption: // css2
-    case eSystemFont_StatusBar:    // css2
-    case eSystemFont_Window:       // css3
-    case eSystemFont_Document:     // css3
-    case eSystemFont_Workspace:    // css3
-    case eSystemFont_Desktop:      // css3
-    case eSystemFont_Info:         // css3
-    case eSystemFont_Dialog:       // css3
-    case eSystemFont_Tooltips:     // moz
-    case eSystemFont_Widget:       // moz
-        *aFontName = mDefaultFontName;
-        *aFontStyle = mDefaultFontStyle;
-        break;
-    }
-
-    return NS_OK;
-}
-
deleted file mode 100644
--- a/gfx/src/nsSystemFontsQt.h
+++ /dev/null
@@ -1,80 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is thebes gfx
- *
- * The Initial Developer of the Original Code is mozilla.org.
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Vladimir Vukicevic <vladimir@pobox.com>
- *   Stuart Parmenter <pavlov@pavlov.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _NS_SYSTEMFONTSQT_H_
-#define _NS_SYSTEMFONTSQT_H_
-
-#include "gfxFont.h"
-#include "nsDeviceContext.h"
-
-class nsSystemFontsQt
-{
-public:
-    nsSystemFontsQt();
-    ~nsSystemFontsQt();
-
-    nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName,
-                           gfxFontStyle *aFontStyle) const;
-
-private:
-
-    nsresult GetSystemFontInfo(const char *aClassName, nsString *aFontName,
-                               gfxFontStyle *aFontStyle) const;
-
-    /*
-     * The following system font constants exist:
-     *
-     * css2: http://www.w3.org/TR/REC-CSS2/fonts.html#x27
-     * eSystemFont_Caption, eSystemFont_Icon, eSystemFont_Menu,
-     * eSystemFont_MessageBox, eSystemFont_SmallCaption,
-     * eSystemFont_StatusBar,
-     * // css3
-     * eSystemFont_Window, eSystemFont_Document,
-     * eSystemFont_Workspace, eSystemFont_Desktop,
-     * eSystemFont_Info, eSystemFont_Dialog,
-     * eSystemFont_Button, eSystemFont_PullDownMenu,
-     * eSystemFont_List, eSystemFont_Field,
-     * // moz
-     * eSystemFont_Tooltips, eSystemFont_Widget
-     */
-    nsString mDefaultFontName, mButtonFontName, mFieldFontName, mMenuFontName;
-    gfxFontStyle mDefaultFontStyle, mButtonFontStyle, mFieldFontStyle, mMenuFontStyle;
-};
-
-#endif /* _NS_SYSTEMFONTSQT_H_ */
-
deleted file mode 100644
--- a/gfx/src/nsSystemFontsWin.cpp
+++ /dev/null
@@ -1,246 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is thebes gfx
- *
- * The Initial Developer of the Original Code is mozilla.org.
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Vladimir Vukicevic <vladimir@pobox.com>
- *   Stuart Parmenter <pavlov@pavlov.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#include "nsSystemFontsWin.h"
-#include "gfxWindowsSurface.h"
-
-nsresult nsSystemFontsWin::CopyLogFontToNSFont(HDC* aHDC, const LOGFONTW* ptrLogFont,
-                                               nsString *aFontName,
-                                               gfxFontStyle *aFontStyle) const
-{
-  PRUnichar name[LF_FACESIZE];
-  name[0] = 0;
-  memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*sizeof(PRUnichar));
-  *aFontName = name;
-
-  // Do Style
-  aFontStyle->style = FONT_STYLE_NORMAL;
-  if (ptrLogFont->lfItalic)
-  {
-    aFontStyle->style = FONT_STYLE_ITALIC;
-  }
-  // XXX What about oblique?
-
-  // Do Weight
-  aFontStyle->weight = (ptrLogFont->lfWeight == FW_BOLD ? 
-            FONT_WEIGHT_BOLD : FONT_WEIGHT_NORMAL);
-
-  // FIXME: Set aFontStyle->stretch correctly!
-  aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
-
-  // XXX mPixelScale is currently hardcoded to 1 in thebes gfx...
-  float mPixelScale = 1.0f;
-  // Do Point Size
-  //
-  // The lfHeight is in pixel and it needs to be adjusted for the
-  // device it will be "displayed" on
-  // Screens and Printers will differe in DPI
-  //
-  // So this accounts for the difference in the DeviceContexts
-  // The mPixelScale will be a "1" for the screen and could be
-  // any value when going to a printer, for example mPixleScale is
-  // 6.25 when going to a 600dpi printer.
-  // round, but take into account whether it is negative
-  float pixelHeight = -ptrLogFont->lfHeight;
-  if (pixelHeight < 0) {
-    HFONT hFont = ::CreateFontIndirectW(ptrLogFont);
-    if (!hFont)
-      return NS_ERROR_OUT_OF_MEMORY;
-    HGDIOBJ hObject = ::SelectObject(*aHDC, hFont);
-    TEXTMETRIC tm;
-    ::GetTextMetrics(*aHDC, &tm);
-    ::SelectObject(*aHDC, hObject);
-    ::DeleteObject(hFont);
-    pixelHeight = tm.tmAscent;
-  }
-
-  pixelHeight *= mPixelScale;
-
-  // 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) && 
-      (936 == ::GetACP())) 
-    pixelHeight = 12;
-
-  aFontStyle->size = pixelHeight;
-  return NS_OK;
-}
-
-nsresult nsSystemFontsWin::GetSysFontInfo(HDC aHDC, nsSystemFontID anID,
-                                          nsString *aFontName,
-                                          gfxFontStyle *aFontStyle) const
-{
-  HGDIOBJ hGDI;
-
-  LOGFONTW logFont;
-  LOGFONTW* ptrLogFont = NULL;
-
-  NONCLIENTMETRICSW ncm;
-
-  BOOL status;
-  if (anID == eSystemFont_Icon) 
-  {
-    status = ::SystemParametersInfoW(SPI_GETICONTITLELOGFONT,
-                                     sizeof(logFont),
-                                     (PVOID)&logFont,
-                                     0);
-  }
-  else
-  {
-    ncm.cbSize = sizeof(NONCLIENTMETRICSW);
-    status = ::SystemParametersInfoW(SPI_GETNONCLIENTMETRICS, 
-                                     sizeof(ncm),  
-                                     (PVOID)&ncm, 
-                                     0);
-  }
-
-  if (!status)
-  {
-    return NS_ERROR_FAILURE;
-  }
-
-  switch (anID)
-  {
-    // Caption in CSS is NOT the same as Caption on Windows
-    //case eSystemFont_Caption: 
-    //  ptrLogFont = &ncm.lfCaptionFont;
-    //  break;
-
-    case eSystemFont_Icon: 
-      ptrLogFont = &logFont;
-      break;
-
-    case eSystemFont_Menu: 
-      ptrLogFont = &ncm.lfMenuFont;
-      break;
-
-    case eSystemFont_MessageBox: 
-      ptrLogFont = &ncm.lfMessageFont;
-      break;
-
-    case eSystemFont_SmallCaption: 
-      ptrLogFont = &ncm.lfSmCaptionFont;
-      break;
-
-    case eSystemFont_StatusBar: 
-    case eSystemFont_Tooltips: 
-      ptrLogFont = &ncm.lfStatusFont;
-      break;
-
-    case eSystemFont_Widget:
-
-    case eSystemFont_Window:      // css3
-    case eSystemFont_Document:
-    case eSystemFont_Workspace:
-    case eSystemFont_Desktop:
-    case eSystemFont_Info:
-    case eSystemFont_Dialog:
-    case eSystemFont_Button:
-    case eSystemFont_PullDownMenu:
-    case eSystemFont_List:
-    case eSystemFont_Field:
-    case eSystemFont_Caption: 
-      hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
-      if (hGDI != NULL)
-      {
-        if (::GetObjectW(hGDI, sizeof(logFont), &logFont) > 0)
-        { 
-          ptrLogFont = &logFont;
-        }
-      }
-      break;
-  } // switch 
-
-  if (nsnull == ptrLogFont)
-  {
-    return NS_ERROR_FAILURE;
-  }
-
-  aFontStyle->systemFont = true;
-
-  return CopyLogFontToNSFont(&aHDC, ptrLogFont, aFontName, aFontStyle);
-}
-
-nsresult nsSystemFontsWin::GetSystemFont(nsSystemFontID anID,
-                                         nsString *aFontName,
-                                         gfxFontStyle *aFontStyle) const
-{
-  nsresult status = NS_OK;
-
-  switch (anID) {
-    case eSystemFont_Caption: 
-    case eSystemFont_Icon: 
-    case eSystemFont_Menu: 
-    case eSystemFont_MessageBox: 
-    case eSystemFont_SmallCaption: 
-    case eSystemFont_StatusBar: 
-    case eSystemFont_Tooltips: 
-    case eSystemFont_Widget:
-
-    case eSystemFont_Window:      // css3
-    case eSystemFont_Document:
-    case eSystemFont_Workspace:
-    case eSystemFont_Desktop:
-    case eSystemFont_Info:
-    case eSystemFont_Dialog:
-    case eSystemFont_Button:
-    case eSystemFont_PullDownMenu:
-    case eSystemFont_List:
-    case eSystemFont_Field:
-    {
-      HWND hwnd = nsnull;
-      HDC tdc = GetDC(hwnd);
-
-      status = GetSysFontInfo(tdc, anID, aFontName, aFontStyle);
-
-      ReleaseDC(hwnd, tdc);
-
-      break;
-    }
-  }
-
-  return status;
-}
-
-nsSystemFontsWin::nsSystemFontsWin()
-{
-
-}
-
deleted file mode 100644
--- a/gfx/src/nsSystemFontsWin.h
+++ /dev/null
@@ -1,61 +0,0 @@
-/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
-/* ***** BEGIN LICENSE BLOCK *****
- * Version: MPL 1.1/GPL 2.0/LGPL 2.1
- *
- * The contents of this file are subject to the Mozilla Public License Version
- * 1.1 (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- * http://www.mozilla.org/MPL/
- *
- * Software distributed under the License is distributed on an "AS IS" basis,
- * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
- * for the specific language governing rights and limitations under the
- * License.
- *
- * The Original Code is thebes gfx
- *
- * The Initial Developer of the Original Code is mozilla.org.
- * Portions created by the Initial Developer are Copyright (C) 2005
- * the Initial Developer. All Rights Reserved.
- *
- * Contributor(s):
- *   Vladimir Vukicevic <vladimir@pobox.com>
- *   Stuart Parmenter <pavlov@pavlov.net>
- *
- * Alternatively, the contents of this file may be used under the terms of
- * either the GNU General Public License Version 2 or later (the "GPL"), or
- * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
- * in which case the provisions of the GPL or the LGPL are applicable instead
- * of those above. If you wish to allow use of your version of this file only
- * under the terms of either the GPL or the LGPL, and not to allow others to
- * use your version of this file under the terms of the MPL, indicate your
- * decision by deleting the provisions above and replace them with the notice
- * and other provisions required by the GPL or the LGPL. If you do not delete
- * the provisions above, a recipient may use your version of this file under
- * the terms of any one of the MPL, the GPL or the LGPL.
- *
- * ***** END LICENSE BLOCK ***** */
-
-#ifndef _NS_SYSTEMFONTSWIN_H_
-#define _NS_SYSTEMFONTSWIN_H_
-
-#include "gfxFont.h"
-#include "nsDeviceContext.h"
-#include <windows.h> // need HDC and LOGFONTW
-
-class nsSystemFontsWin
-{
-public:
-    nsSystemFontsWin();
-
-    nsresult GetSystemFont(nsSystemFontID anID, nsString *aFontName,
-                           gfxFontStyle *aFontStyle) const;
-private:
-    nsresult CopyLogFontToNSFont(HDC* aHDC, const LOGFONTW* ptrLogFont,
-                                 nsString *aFontName, gfxFontStyle *aFontStyle) const;
-    nsresult GetSysFontInfo(HDC aHDC, nsSystemFontID anID,
-                            nsString *aFontName,
-                            gfxFontStyle *aFontStyle) const;
-};
-
-#endif /* _NS_SYSTEMFONTSWIN_H_ */
--- a/gfx/src/nsThebesGfxFactory.cpp
+++ b/gfx/src/nsThebesGfxFactory.cpp
@@ -38,17 +38,16 @@
 
 #include "mozilla/ModuleUtils.h"
 #include "nsCOMPtr.h"
 #include "nsGfxCIID.h"
 
 #include "nsThebesFontEnumerator.h"
 #include "nsScriptableRegion.h"
 
-#include "nsDeviceContext.h"
 #include "gfxPlatform.h"
 
 // This class doesn't do anything; its only purpose is to give
 // gfxPlatform::Init a way to force this component to be registered,
 // so that gfxPlatform::Shutdown will be called at an appropriate
 // time.  (Component teardown is the only shutdown hook that runs
 // late enough; see bug 651498.)
 
@@ -95,17 +94,16 @@ static const mozilla::Module::ContractID
     { "@mozilla.org/gfx/region;1", &kNS_SCRIPTABLE_REGION_CID },
     { "@mozilla.org/gfx/init;1", &kNS_GFX_INITIALIZATION_CID },
     { NULL }
 };
 
 static void
 nsThebesGfxModuleDtor()
 {
-    nsDeviceContext::ClearCachedSystemFonts();
     gfxPlatform::Shutdown();
 }
 
 static const mozilla::Module kThebesModule = {
     mozilla::Module::kVersion,
     kThebesCIDs,
     kThebesContracts,
     NULL,
--- a/layout/base/nsStyleConsts.h
+++ b/layout/base/nsStyleConsts.h
@@ -470,32 +470,32 @@ static inline mozilla::css::Side operato
 #define NS_STYLE_FONT_STRETCH_SEMI_CONDENSED    NS_FONT_STRETCH_SEMI_CONDENSED
 #define NS_STYLE_FONT_STRETCH_NORMAL            NS_FONT_STRETCH_NORMAL
 #define NS_STYLE_FONT_STRETCH_SEMI_EXPANDED     NS_FONT_STRETCH_SEMI_EXPANDED
 #define NS_STYLE_FONT_STRETCH_EXPANDED          NS_FONT_STRETCH_EXPANDED
 #define NS_STYLE_FONT_STRETCH_EXTRA_EXPANDED    NS_FONT_STRETCH_EXTRA_EXPANDED
 #define NS_STYLE_FONT_STRETCH_ULTRA_EXPANDED    NS_FONT_STRETCH_ULTRA_EXPANDED
 
 // See nsStyleFont - system fonts
-#define NS_STYLE_FONT_CAPTION                   1		// css2
+#define NS_STYLE_FONT_CAPTION                   1   // css2
 #define NS_STYLE_FONT_ICON                      2
 #define NS_STYLE_FONT_MENU                      3
 #define NS_STYLE_FONT_MESSAGE_BOX               4
 #define NS_STYLE_FONT_SMALL_CAPTION             5
 #define NS_STYLE_FONT_STATUS_BAR                6
-#define NS_STYLE_FONT_WINDOW										7		// css3
-#define NS_STYLE_FONT_DOCUMENT									8
-#define NS_STYLE_FONT_WORKSPACE									9
-#define NS_STYLE_FONT_DESKTOP										10
-#define NS_STYLE_FONT_INFO											11
-#define NS_STYLE_FONT_DIALOG										12
-#define NS_STYLE_FONT_BUTTON										13
-#define NS_STYLE_FONT_PULL_DOWN_MENU						14
-#define NS_STYLE_FONT_LIST											15
-#define NS_STYLE_FONT_FIELD											16
+#define NS_STYLE_FONT_WINDOW                    7   // css3
+#define NS_STYLE_FONT_DOCUMENT                  8
+#define NS_STYLE_FONT_WORKSPACE                 9
+#define NS_STYLE_FONT_DESKTOP                   10
+#define NS_STYLE_FONT_INFO                      11
+#define NS_STYLE_FONT_DIALOG                    12
+#define NS_STYLE_FONT_BUTTON                    13
+#define NS_STYLE_FONT_PULL_DOWN_MENU            14
+#define NS_STYLE_FONT_LIST                      15
+#define NS_STYLE_FONT_FIELD                     16
 
 // defaults per MathML spec
 #define NS_MATHML_DEFAULT_SCRIPT_SIZE_MULTIPLIER 0.71f
 #define NS_MATHML_DEFAULT_SCRIPT_MIN_SIZE_PT 8
 
 // See nsStylePosition::mWidth, mMinWidth, mMaxWidth
 #define NS_STYLE_WIDTH_MAX_CONTENT              0
 #define NS_STYLE_WIDTH_MIN_CONTENT              1
--- a/layout/style/nsRuleNode.cpp
+++ b/layout/style/nsRuleNode.cpp
@@ -2676,80 +2676,83 @@ nsRuleNode::SetFont(nsPresContext* aPres
     aFont->mLanguage = do_GetAtom(lang);
   }
 
   const nsFont* defaultVariableFont =
     aPresContext->GetDefaultFont(kPresContext_DefaultVariableFont_ID,
                                  aFont->mLanguage);
 
   // -moz-system-font: enum (never inherit!)
-  nsFont systemFont;
+  PR_STATIC_ASSERT(
+    NS_STYLE_FONT_CAPTION        == LookAndFeel::eFont_Caption &&
+    NS_STYLE_FONT_ICON           == LookAndFeel::eFont_Icon &&
+    NS_STYLE_FONT_MENU           == LookAndFeel::eFont_Menu &&
+    NS_STYLE_FONT_MESSAGE_BOX    == LookAndFeel::eFont_MessageBox &&
+    NS_STYLE_FONT_SMALL_CAPTION  == LookAndFeel::eFont_SmallCaption &&
+    NS_STYLE_FONT_STATUS_BAR     == LookAndFeel::eFont_StatusBar &&
+    NS_STYLE_FONT_WINDOW         == LookAndFeel::eFont_Window &&
+    NS_STYLE_FONT_DOCUMENT       == LookAndFeel::eFont_Document &&
+    NS_STYLE_FONT_WORKSPACE      == LookAndFeel::eFont_Workspace &&
+    NS_STYLE_FONT_DESKTOP        == LookAndFeel::eFont_Desktop &&
+    NS_STYLE_FONT_INFO           == LookAndFeel::eFont_Info &&
+    NS_STYLE_FONT_DIALOG         == LookAndFeel::eFont_Dialog &&
+    NS_STYLE_FONT_BUTTON         == LookAndFeel::eFont_Button &&
+    NS_STYLE_FONT_PULL_DOWN_MENU == LookAndFeel::eFont_PullDownMenu &&
+    NS_STYLE_FONT_LIST           == LookAndFeel::eFont_List &&
+    NS_STYLE_FONT_FIELD          == LookAndFeel::eFont_Field);
+
+  // Fall back to defaultVariableFont.
+  nsFont systemFont = *defaultVariableFont;
   const nsCSSValue* systemFontValue = aRuleData->ValueForSystemFont();
   if (eCSSUnit_Enumerated == systemFontValue->GetUnit()) {
-    nsSystemFontID sysID;
-    switch (systemFontValue->GetIntValue()) {
-      case NS_STYLE_FONT_CAPTION:       sysID = eSystemFont_Caption;      break;    // css2
-      case NS_STYLE_FONT_ICON:          sysID = eSystemFont_Icon;         break;
-      case NS_STYLE_FONT_MENU:          sysID = eSystemFont_Menu;         break;
-      case NS_STYLE_FONT_MESSAGE_BOX:   sysID = eSystemFont_MessageBox;   break;
-      case NS_STYLE_FONT_SMALL_CAPTION: sysID = eSystemFont_SmallCaption; break;
-      case NS_STYLE_FONT_STATUS_BAR:    sysID = eSystemFont_StatusBar;    break;
-      case NS_STYLE_FONT_WINDOW:        sysID = eSystemFont_Window;       break;    // css3
-      case NS_STYLE_FONT_DOCUMENT:      sysID = eSystemFont_Document;     break;
-      case NS_STYLE_FONT_WORKSPACE:     sysID = eSystemFont_Workspace;    break;
-      case NS_STYLE_FONT_DESKTOP:       sysID = eSystemFont_Desktop;      break;
-      case NS_STYLE_FONT_INFO:          sysID = eSystemFont_Info;         break;
-      case NS_STYLE_FONT_DIALOG:        sysID = eSystemFont_Dialog;       break;
-      case NS_STYLE_FONT_BUTTON:        sysID = eSystemFont_Button;       break;
-      case NS_STYLE_FONT_PULL_DOWN_MENU:sysID = eSystemFont_PullDownMenu; break;
-      case NS_STYLE_FONT_LIST:          sysID = eSystemFont_List;         break;
-      case NS_STYLE_FONT_FIELD:         sysID = eSystemFont_Field;        break;
-    }
-
-    // GetSystemFont sets the font face but not necessarily the size
-    // XXX Or at least it used to -- no longer true for thebes.  Maybe
-    // it should be again, though.
-    systemFont.size = defaultVariableFont->size;
-
-    if (NS_FAILED(aPresContext->DeviceContext()->GetSystemFont(sysID,
-                                                               &systemFont))) {
-        systemFont.name = defaultVariableFont->name;
-    }
-
-    // XXXldb All of this platform-specific stuff should be in the
-    // nsDeviceContext implementations, not here.
+    gfxFontStyle fontStyle;
+    LookAndFeel::FontID fontID =
+      (LookAndFeel::FontID)systemFontValue->GetIntValue();
+    if (LookAndFeel::GetFont(fontID, systemFont.name, fontStyle)) {
+      systemFont.style = fontStyle.style;
+      systemFont.systemFont = fontStyle.systemFont;
+      systemFont.variant = NS_FONT_VARIANT_NORMAL;
+      systemFont.weight = fontStyle.weight;
+      systemFont.stretch = fontStyle.stretch;
+      systemFont.decorations = NS_FONT_DECORATION_NONE;
+      systemFont.size = NSFloatPixelsToAppUnits(fontStyle.size,
+                                                aPresContext->DeviceContext()->
+                                                UnscaledAppUnitsPerDevPixel());
+      //systemFont.langGroup = fontStyle.langGroup;
+      systemFont.sizeAdjust = fontStyle.sizeAdjust;
 
 #ifdef XP_WIN
-    //
-    // As far as I can tell the system default fonts and sizes for
-    // on MS-Windows for Buttons, Listboxes/Comboxes and Text Fields are
-    // all pre-determined and cannot be changed by either the control panel
-    // or programmtically.
-    //
-    switch (sysID) {
-      // 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.
-      case eSystemFont_Field:
-      case eSystemFont_Button:
-      case eSystemFont_List:
+      // 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.
+
+      // 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 programmtically.
+      switch (fontID) {
+        // 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.
+      case LookAndFeel::eFont_Field:
+      case LookAndFeel::eFont_Button:
+      case LookAndFeel::eFont_List:
         // Assumption: system defined font is proportional
         systemFont.size =
-          NS_MAX(defaultVariableFont->size - nsPresContext::CSSPointsToAppUnits(2), 0);
+          NS_MAX(defaultVariableFont->size -
+                 nsPresContext::CSSPointsToAppUnits(2), 0);
         break;
-    }
+      }
 #endif
-  } else {
-    // In case somebody explicitly used -moz-use-system-font.
-    systemFont = *defaultVariableFont;
-  }
-
+    }
+  }
 
   // font-family: string list, enum, inherit
   const nsCSSValue* familyValue = aRuleData->ValueForFontFamily();
   NS_ASSERTION(eCSSUnit_Enumerated != familyValue->GetUnit(),
                "system fonts should not be in mFamily anymore");
   if (eCSSUnit_Families == familyValue->GetUnit()) {
     // set the correct font if we are using DocumentFonts OR we are overriding for XUL
     // MJA: bug 31816
--- a/widget/LookAndFeel.h
+++ b/widget/LookAndFeel.h
@@ -40,18 +40,17 @@
 
 #ifndef MOZILLA_INTERNAL_API
 #error "This header is only usable from within libxul (MOZILLA_INTERNAL_API)."
 #endif
 
 #include "nsDebug.h"
 #include "nsColor.h"
 
-// for |#ifdef NS_DEBUG|
-struct nsSize;
+struct gfxFontStyle;
 
 namespace mozilla {
 
 class LookAndFeel
 {
 public:
   // When modifying this list, also modify nsXPLookAndFeel::sColorPrefs
   // in widget/xpwidgts/nsXPLookAndFeel.cpp.
@@ -429,16 +428,41 @@ public:
     eFloatID_IMEUnderlineRelativeSize,
     eFloatID_SpellCheckerUnderlineRelativeSize,
 
     // The width/height ratio of the cursor. If used, the CaretWidth int metric
     // should be added to the calculated caret width.
     eFloatID_CaretAspectRatio
   };
 
+  // These constants must be kept in 1:1 correspondence with the
+  // NS_STYLE_FONT_* system font constants.
+  enum FontID {
+    eFont_Caption = 1,     // css2
+    eFont_Icon,
+    eFont_Menu,
+    eFont_MessageBox,
+    eFont_SmallCaption,
+    eFont_StatusBar,
+
+    eFont_Window,          // css3
+    eFont_Document,
+    eFont_Workspace,
+    eFont_Desktop,
+    eFont_Info,
+    eFont_Dialog,
+    eFont_Button,
+    eFont_PullDownMenu,
+    eFont_List,
+    eFont_Field,
+
+    eFont_Tooltips,        // moz
+    eFont_Widget
+  };
+
   /**
    * GetColor() return a native color value (might be overwritten by prefs) for
    * aID.  Some platforms don't return an error even if the index doesn't
    * match any system colors.  And also some platforms may initialize the
    * return value even when it returns an error.  Therefore, if you want to
    * use a color for the default value, you should use the other GetColor()
    * which returns nscolor directly.
    *
@@ -485,16 +509,27 @@ public:
     float result;
     if (NS_FAILED(GetFloat(aID, &result))) {
       return aDefault;
     }
     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.
+   *
+   * @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.
+   */
+  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 PRUnichar GetPasswordCharacter();
 
   /**
    * If the latest character in password field shouldn't be hidden by the
    * result of GetPasswordCharacter(), GetEchoPassword() returns TRUE.
--- a/widget/android/nsLookAndFeel.cpp
+++ b/widget/android/nsLookAndFeel.cpp
@@ -36,16 +36,17 @@
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "mozilla/dom/ContentChild.h"
 #include "nsStyleConsts.h"
 #include "nsXULAppAPI.h"
 #include "nsLookAndFeel.h"
+#include "gfxFont.h"
 
 using namespace mozilla;
 using mozilla::dom::ContentChild;
 
 bool nsLookAndFeel::mInitializedSystemColors = false;
 AndroidSystemColors nsLookAndFeel::mSystemColors;
 
 bool nsLookAndFeel::mInitializedShowPassword = false;
@@ -468,16 +469,30 @@ nsLookAndFeel::GetFloatImpl(FloatID aID,
             rv = NS_ERROR_FAILURE;
             break;
     }
     return rv;
 }
 
 /*virtual*/
 bool
+nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
+                           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;
+    aFontStyle.systemFont = true;
+    return true;
+}
+
+/*virtual*/
+bool
 nsLookAndFeel::GetEchoPasswordImpl()
 {
     if (!mInitializedShowPassword) {
         if (XRE_GetProcessType() == GeckoProcessType_Default) {
             if (AndroidBridge::Bridge())
                 mShowPassword = AndroidBridge::Bridge()->GetShowPasswordSetting();
             else
                 NS_ASSERTION(AndroidBridge::Bridge() != nsnull, "AndroidBridge is not available!");
--- a/widget/android/nsLookAndFeel.h
+++ b/widget/android/nsLookAndFeel.h
@@ -46,16 +46,17 @@ class nsLookAndFeel: public nsXPLookAndF
 {
 public:
     nsLookAndFeel();
     virtual ~nsLookAndFeel();
 
     virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult);
     virtual nsresult GetIntImpl(IntID aID, PRInt32 &aResult);
     virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
+    virtual bool GetFontImpl(FontID aID, nsString& aName, gfxFontStyle& aStyle);
     virtual bool GetEchoPasswordImpl();
 
 protected:
     static bool mInitializedSystemColors;
     static mozilla::AndroidSystemColors mSystemColors;
     static bool mInitializedShowPassword;
     static bool mShowPassword;
 
--- a/widget/cocoa/nsLookAndFeel.h
+++ b/widget/cocoa/nsLookAndFeel.h
@@ -42,16 +42,18 @@
 class nsLookAndFeel: public nsXPLookAndFeel {
 public:
   nsLookAndFeel();
   virtual ~nsLookAndFeel();
 
   virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult);
   virtual nsresult GetIntImpl(IntID aID, PRInt32 &aResult);
   virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
+  virtual bool GetFontImpl(FontID aID, nsString& aFontName,
+                           gfxFontStyle& aFontStyle);
   virtual PRUnichar GetPasswordCharacterImpl()
   {
     // unicode value for the bullet character, used for password textfields.
     return 0x2022;
   }
 
 protected:
 
--- a/widget/cocoa/nsLookAndFeel.mm
+++ b/widget/cocoa/nsLookAndFeel.mm
@@ -36,16 +36,17 @@
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsLookAndFeel.h"
 #include "nsObjCExceptions.h"
 #include "nsIServiceManager.h"
 #include "nsNativeThemeColors.h"
 #include "nsStyleConsts.h"
+#include "gfxFont.h"
 
 #import <Cocoa/Cocoa.h>
 
 nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
 {
 }
 
 nsLookAndFeel::~nsLookAndFeel()
@@ -463,8 +464,127 @@ nsLookAndFeel::GetFloatImpl(FloatID aID,
       break;
     default:
       aResult = -1.0;
       res = NS_ERROR_FAILURE;
   }
 
   return res;
 }
+
+// copied from gfxQuartzFontCache.mm, maybe should go in a Cocoa utils
+// file somewhere
+static void GetStringForNSString(const NSString *aSrc, nsAString& aDest)
+{
+    aDest.SetLength([aSrc length]);
+    [aSrc getCharacters:aDest.BeginWriting()];
+}
+
+bool
+nsLookAndFeel::GetFontImpl(FontID aID, nsString &aFontName,
+                           gfxFontStyle &aFontStyle)
+{
+    // hack for now
+    if (aID == eFont_Window || aID == eFont_Document) {
+        aFontStyle.style      = FONT_STYLE_NORMAL;
+        aFontStyle.weight     = FONT_WEIGHT_NORMAL;
+        aFontStyle.stretch    = NS_FONT_STRETCH_NORMAL;
+        aFontStyle.size       = 14;
+        aFontStyle.systemFont = true;
+
+        aFontName.AssignLiteral("sans-serif");
+        return true;
+    }
+
+/* possibilities, see NSFont Class Reference:
+    [NSFont boldSystemFontOfSize:     0.0]
+    [NSFont controlContentFontOfSize: 0.0]
+    [NSFont labelFontOfSize:          0.0]
+    [NSFont menuBarFontOfSize:        0.0]
+    [NSFont menuFontOfSize:           0.0]
+    [NSFont messageFontOfSize:        0.0]
+    [NSFont paletteFontOfSize:        0.0]
+    [NSFont systemFontOfSize:         0.0]
+    [NSFont titleBarFontOfSize:       0.0]
+    [NSFont toolTipsFontOfSize:       0.0]
+    [NSFont userFixedPitchFontOfSize: 0.0]
+    [NSFont userFontOfSize:           0.0]
+    [NSFont systemFontOfSize:         [NSFont smallSystemFontSize]]
+    [NSFont boldSystemFontOfSize:     [NSFont smallSystemFontSize]]
+*/
+
+    NSFont *font = nsnull;
+    switch (aID) {
+        // css2
+        case eFont_Caption:
+            font = [NSFont systemFontOfSize:0.0];
+            break;
+        case eFont_Icon: // used in urlbar; tried labelFont, but too small
+            font = [NSFont controlContentFontOfSize:0.0];
+            break;
+        case eFont_Menu:
+            font = [NSFont systemFontOfSize:0.0];
+            break;
+        case eFont_MessageBox:
+            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
+            break;
+        case eFont_SmallCaption:
+            font = [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]];
+            break;
+        case eFont_StatusBar:
+            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
+            break;
+        // css3
+        //case eFont_Window:     = 'sans-serif'
+        //case eFont_Document:   = 'sans-serif'
+        case eFont_Workspace:
+            font = [NSFont controlContentFontOfSize:0.0];
+            break;
+        case eFont_Desktop:
+            font = [NSFont controlContentFontOfSize:0.0];
+            break;
+        case eFont_Info:
+            font = [NSFont controlContentFontOfSize:0.0];
+            break;
+        case eFont_Dialog:
+            font = [NSFont systemFontOfSize:0.0];
+            break;
+        case eFont_Button:
+            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
+            break;
+        case eFont_PullDownMenu:
+            font = [NSFont menuBarFontOfSize:0.0];
+            break;
+        case eFont_List:
+            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
+            break;
+        case eFont_Field:
+            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
+            break;
+        // moz
+        case eFont_Tooltips:
+            font = [NSFont toolTipsFontOfSize:0.0];
+            break;
+        case eFont_Widget:
+            font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
+            break;
+    }
+
+    if (!font) {
+        NS_WARNING("failed to find a system font!");
+        return false;
+    }
+
+    NSFontSymbolicTraits traits = [[font fontDescriptor] symbolicTraits];
+    aFontStyle.style =
+        (traits & NSFontItalicTrait) ?  FONT_STYLE_ITALIC : FONT_STYLE_NORMAL;
+    aFontStyle.weight =
+        (traits & NSFontBoldTrait) ? FONT_WEIGHT_BOLD : FONT_WEIGHT_NORMAL;
+    aFontStyle.stretch =
+        (traits & NSFontExpandedTrait) ?
+            NS_FONT_STRETCH_EXPANDED : (traits & NSFontCondensedTrait) ?
+                NS_FONT_STRETCH_CONDENSED : NS_FONT_STRETCH_NORMAL;
+    aFontStyle.size = [font pointSize];
+    aFontStyle.systemFont = true;
+
+    GetStringForNSString([font familyName], aFontName);
+    return true;
+}
--- a/widget/gonk/nsLookAndFeel.cpp
+++ b/widget/gonk/nsLookAndFeel.cpp
@@ -32,16 +32,17 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsLookAndFeel.h"
+#include "gfxFont.h"
 
 nsLookAndFeel::nsLookAndFeel()
     : nsXPLookAndFeel()
 {
 }
 
 nsLookAndFeel::~nsLookAndFeel()
 {
@@ -311,9 +312,21 @@ nsLookAndFeel::NativeGetColor(ColorID aI
         aColor = 0;
         rv = NS_ERROR_FAILURE;
         break;
     }
 
     return rv;
 }
 
-
+/*virtual*/
+bool
+nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
+                           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;
+    aFontStyle.systemFont = true;
+    return true;
+}
--- a/widget/gonk/nsLookAndFeel.h
+++ b/widget/gonk/nsLookAndFeel.h
@@ -42,13 +42,15 @@
 #include "nsXPLookAndFeel.h"
 
 class nsLookAndFeel : public nsXPLookAndFeel
 {
 public:
     nsLookAndFeel();
     virtual ~nsLookAndFeel();
 
+    virtual bool GetFontImpl(FontID aID, nsString& aName, gfxFontStyle& aStyle);
+
 protected:
     virtual nsresult NativeGetColor(ColorID aID, nscolor &aColor);
 };
 
 #endif
--- a/widget/gtk2/nsLookAndFeel.cpp
+++ b/widget/gtk2/nsLookAndFeel.cpp
@@ -33,28 +33,43 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
+// for strtod()
+#include <stdlib.h>
+
 #include "nsLookAndFeel.h"
+
 #include <gtk/gtk.h>
+#include <gdk/gdk.h>
+
+#ifdef MOZ_PANGO
+#include <pango/pango.h>
+#include <pango/pango-fontmap.h>
+#endif
+
+#include <fontconfig/fontconfig.h>
+#include "gfxPlatformGtk.h"
 
 #include "gtkdrawing.h"
 #include "nsStyleConsts.h"
 
 #ifdef MOZ_PLATFORM_MAEMO
 #include "nsIServiceManager.h"
 #include "nsIPropertyBag2.h"
 #include "nsLiteralString.h"
 #endif
 
+using mozilla::LookAndFeel;
+
 #define GDK_COLOR_TO_NS_RGB(c) \
     ((nscolor) NS_RGB(c.red>>8, c.green>>8, c.blue>>8))
 
 nscolor   nsLookAndFeel::sInfoText = 0;
 nscolor   nsLookAndFeel::sInfoBackground = 0;
 nscolor   nsLookAndFeel::sMenuBarText = 0;
 nscolor   nsLookAndFeel::sMenuBarHoverText = 0;
 nscolor   nsLookAndFeel::sMenuText = 0;
@@ -68,24 +83,22 @@ nscolor   nsLookAndFeel::sButtonInnerDar
 nscolor   nsLookAndFeel::sOddCellBackground = 0;
 nscolor   nsLookAndFeel::sNativeHyperLinkText = 0;
 nscolor   nsLookAndFeel::sComboBoxText = 0;
 nscolor   nsLookAndFeel::sComboBoxBackground = 0;
 PRUnichar nsLookAndFeel::sInvisibleCharacter = PRUnichar('*');
 float     nsLookAndFeel::sCaretRatio = 0;
 bool      nsLookAndFeel::sMenuSupportsDrag = false;
 
-//-------------------------------------------------------------------------
-//
-// Query interface implementation
-//
-//-------------------------------------------------------------------------
-nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
+nsLookAndFeel::nsLookAndFeel()
+    : nsXPLookAndFeel(),
+      mStyle(nsnull),
+      mDefaultFontCached(false), mButtonFontCached(false),
+      mFieldFontCached(false), mMenuFontCached(false)
 {
-    mStyle = nsnull;
     InitWidget();
 
     static bool sInitialized = false;
 
     if (!sInitialized) {
         sInitialized = true;
         InitLookAndFeel();
     }
@@ -612,16 +625,199 @@ nsLookAndFeel::GetFloatImpl(FloatID aID,
         break;
     default:
         aResult = -1.0;
         res = NS_ERROR_FAILURE;
     }
     return res;
 }
 
+#ifdef MOZ_PANGO
+static void
+GetSystemFontInfo(GtkWidget *aWidget,
+                  nsString *aFontName,
+                  gfxFontStyle *aFontStyle)
+{
+    GtkSettings *settings = gtk_widget_get_settings(aWidget);
+
+    aFontStyle->style       = FONT_STYLE_NORMAL;
+
+    gchar *fontname;
+    g_object_get(settings, "gtk-font-name", &fontname, NULL);
+
+    PangoFontDescription *desc;
+    desc = pango_font_description_from_string(fontname);
+
+    aFontStyle->systemFont = true;
+
+    g_free(fontname);
+
+    NS_NAMED_LITERAL_STRING(quote, "\"");
+    NS_ConvertUTF8toUTF16 family(pango_font_description_get_family(desc));
+    *aFontName = quote + family + quote;
+
+    aFontStyle->weight = pango_font_description_get_weight(desc);
+
+    // FIXME: Set aFontStyle->stretch correctly!
+    aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
+
+    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::GetDPI()) / POINTS_PER_INCH_FLOAT;
+    }
+
+    // |size| is now pixels
+
+    aFontStyle->size = size;
+
+    pango_font_description_free(desc);
+}
+
+static void
+GetSystemFontInfo(LookAndFeel::FontID aID,
+                  nsString *aFontName,
+                  gfxFontStyle *aFontStyle)
+{
+    if (aID == LookAndFeel::eFont_Widget) {
+        GtkWidget *label = gtk_label_new("M");
+        GtkWidget *parent = gtk_fixed_new();
+        GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
+
+        gtk_container_add(GTK_CONTAINER(parent), label);
+        gtk_container_add(GTK_CONTAINER(window), parent);
+
+        gtk_widget_ensure_style(label);
+        GetSystemFontInfo(label, aFontName, aFontStyle);
+        gtk_widget_destroy(window);  // no unref, windows are different
+
+    } else if (aID == LookAndFeel::eFont_Button) {
+        GtkWidget *label = gtk_label_new("M");
+        GtkWidget *parent = gtk_fixed_new();
+        GtkWidget *button = gtk_button_new();
+        GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
+
+        gtk_container_add(GTK_CONTAINER(button), label);
+        gtk_container_add(GTK_CONTAINER(parent), button);
+        gtk_container_add(GTK_CONTAINER(window), parent);
+
+        gtk_widget_ensure_style(label);
+        GetSystemFontInfo(label, aFontName, aFontStyle);
+        gtk_widget_destroy(window);  // no unref, windows are different
+
+    } else if (aID == LookAndFeel::eFont_Field) {
+        GtkWidget *entry = gtk_entry_new();
+        GtkWidget *parent = gtk_fixed_new();
+        GtkWidget *window = gtk_window_new(GTK_WINDOW_POPUP);
+
+        gtk_container_add(GTK_CONTAINER(parent), entry);
+        gtk_container_add(GTK_CONTAINER(window), parent);
+
+        gtk_widget_ensure_style(entry);
+        GetSystemFontInfo(entry, aFontName, aFontStyle);
+        gtk_widget_destroy(window);  // no unref, windows are different
+
+    } else {
+        NS_ABORT_IF_FALSE(aID == LookAndFeel::eFont_Menu, "unexpected font ID");
+        GtkWidget *accel_label = gtk_accel_label_new("M");
+        GtkWidget *menuitem = gtk_menu_item_new();
+        GtkWidget *menu = gtk_menu_new();
+        g_object_ref_sink(GTK_OBJECT(menu));
+
+        gtk_container_add(GTK_CONTAINER(menuitem), accel_label);
+        gtk_menu_shell_append((GtkMenuShell *)GTK_MENU(menu), menuitem);
+
+        gtk_widget_ensure_style(accel_label);
+        GetSystemFontInfo(accel_label, aFontName, aFontStyle);
+        g_object_unref(menu);
+    }
+}
+
+#else // not MOZ_PANGO
+
+static void
+GetSystemFontInfo(LookAndFeel::FontID /*unused */,
+                  nsString *aFontName,
+                  gfxFontStyle *aFontStyle)
+{
+    /* FIXME: DFB FT2 Hardcoding the system font info for now. */
+    aFontStyle->style      = FONT_STYLE_NORMAL;
+    aFontStyle->weight     = 400;
+    aFontStyle->size       = 40/3;
+    aFontStyle->stretch    = NS_FONT_STRETCH_NORMAL;
+    aFontStyle->systemFont = true;
+    aFontName->AssignLiteral("\"Sans\"");
+}
+
+#endif // not MOZ_PANGO
+
+bool
+nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
+                           gfxFontStyle& aFontStyle)
+{
+  nsString *cachedFontName = NULL;
+  gfxFontStyle *cachedFontStyle = NULL;
+  bool *isCached = NULL;
+
+  switch (aID) {
+    case eFont_Menu:         // css2
+    case eFont_PullDownMenu: // css3
+      cachedFontName = &mMenuFontName;
+      cachedFontStyle = &mMenuFontStyle;
+      isCached = &mMenuFontCached;
+      aID = eFont_Menu;
+      break;
+
+    case eFont_Field:        // css3
+    case eFont_List:         // css3
+      cachedFontName = &mFieldFontName;
+      cachedFontStyle = &mFieldFontStyle;
+      isCached = &mFieldFontCached;
+      aID = eFont_Field;
+      break;
+
+    case eFont_Button:       // css3
+      cachedFontName = &mButtonFontName;
+      cachedFontStyle = &mButtonFontStyle;
+      isCached = &mButtonFontCached;
+      break;
+
+    case eFont_Caption:      // css2
+    case eFont_Icon:         // css2
+    case eFont_MessageBox:   // css2
+    case eFont_SmallCaption: // css2
+    case eFont_StatusBar:    // css2
+    case eFont_Window:       // css3
+    case eFont_Document:     // css3
+    case eFont_Workspace:    // css3
+    case eFont_Desktop:      // css3
+    case eFont_Info:         // css3
+    case eFont_Dialog:       // css3
+    case eFont_Tooltips:     // moz
+    case eFont_Widget:       // moz
+      cachedFontName = &mDefaultFontName;
+      cachedFontStyle = &mDefaultFontStyle;
+      isCached = &mDefaultFontCached;
+      aID = eFont_Widget;
+      break;
+  }
+
+  if (!*isCached) {
+    GetSystemFontInfo(aID, cachedFontName, cachedFontStyle);
+    *isCached = true;
+  }
+
+  aFontName = *cachedFontName;
+  aFontStyle = *cachedFontStyle;
+  return true;
+}
+
 void
 nsLookAndFeel::InitLookAndFeel()
 {
     GtkStyle *style;
 
     // tooltip foreground and background
     style = gtk_rc_get_style_by_paths(gtk_settings_get_default(),
                                       "gtk-tooltips", "GtkWindow",
@@ -794,31 +990,61 @@ nsLookAndFeel::InitLookAndFeel()
     // caret styles
     gtk_widget_style_get(entry,
                          "cursor-aspect-ratio", &sCaretRatio,
                          NULL);
 
     gtk_widget_destroy(window);
 }
 
+void
+nsLookAndFeel::InitWidget()
+{
+    NS_ASSERTION(!mStyle, "already initialized");
+    // GtkInvisibles come with a refcount that is not floating
+    // (since their initialization code calls g_object_ref_sink) and
+    // their destroy code releases that reference (which means they
+    // have to be explicitly destroyed, since calling unref enough
+    // to cause destruction would lead to *another* unref).
+    // However, this combination means that it's actually still ok
+    // to use the normal pattern, which is to g_object_ref_sink
+    // after construction, and then destroy *and* unref when we're
+    // done.  (Though we could skip the g_object_ref_sink and the
+    // corresponding g_object_unref, but that's particular to
+    // GtkInvisibles and GtkWindows.)
+    GtkWidget *widget = gtk_invisible_new();
+    g_object_ref_sink(widget); // effectively g_object_ref (see above)
+
+    gtk_widget_ensure_style(widget);
+    mStyle = gtk_style_copy(gtk_widget_get_style(widget));
+
+    gtk_widget_destroy(widget);
+    g_object_unref(widget);
+}
+
 // virtual
 PRUnichar
 nsLookAndFeel::GetPasswordCharacterImpl()
 {
     return sInvisibleCharacter;
 }
 
 void
 nsLookAndFeel::RefreshImpl()
 {
     nsXPLookAndFeel::RefreshImpl();
 
+    mDefaultFontCached = false;
+    mButtonFontCached = false;
+    mFieldFontCached = false;
+    mMenuFontCached = false;
+
     g_object_unref(mStyle);
     mStyle = nsnull;
- 
+
     InitWidget();
     InitLookAndFeel();
 }
 
 bool
 nsLookAndFeel::GetEchoPasswordImpl() {
 #ifdef MOZ_PLATFORM_MAEMO
     return true;
--- a/widget/gtk2/nsLookAndFeel.h
+++ b/widget/gtk2/nsLookAndFeel.h
@@ -34,34 +34,54 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #ifndef __nsLookAndFeel
 #define __nsLookAndFeel
+
 #include "nsXPLookAndFeel.h"
 #include "nsCOMPtr.h"
-#include <gtk/gtk.h>
+#include "gfxFont.h"
+
+struct _GtkStyle;
 
 class nsLookAndFeel: public nsXPLookAndFeel {
 public:
     nsLookAndFeel();
     virtual ~nsLookAndFeel();
 
     virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult);
     virtual nsresult GetIntImpl(IntID aID, PRInt32 &aResult);
     virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
+    virtual bool GetFontImpl(FontID aID, nsString& aFontName,
+                             gfxFontStyle& aFontStyle);
+
     virtual void RefreshImpl();
     virtual PRUnichar GetPasswordCharacterImpl();
     virtual bool GetEchoPasswordImpl();
 
 protected:
-    GtkStyle *mStyle;
+    struct _GtkStyle *mStyle;
+
+    // Cached fonts
+    bool mDefaultFontCached;
+    bool mButtonFontCached;
+    bool mFieldFontCached;
+    bool mMenuFontCached;
+    nsString mDefaultFontName;
+    nsString mButtonFontName;
+    nsString mFieldFontName;
+    nsString mMenuFontName;
+    gfxFontStyle mDefaultFontStyle;
+    gfxFontStyle mButtonFontStyle;
+    gfxFontStyle mFieldFontStyle;
+    gfxFontStyle mMenuFontStyle;
 
     // Cached colors, we have to create a dummy widget to actually
     // get the style
 
     static nscolor sInfoBackground;
     static nscolor sInfoText;
     static nscolor sMenuBackground;
     static nscolor sMenuBarText;
@@ -77,33 +97,12 @@ protected:
     static nscolor sNativeHyperLinkText;
     static nscolor sComboBoxText;
     static nscolor sComboBoxBackground;
     static PRUnichar sInvisibleCharacter;
     static float   sCaretRatio;
     static bool    sMenuSupportsDrag;
 
     static void InitLookAndFeel();
-    void InitWidget() {
-        NS_ASSERTION(!mStyle, "already initialized");
-        // GtkInvisibles come with a refcount that is not floating
-        // (since their initialization code calls g_object_ref_sink) and
-        // their destroy code releases that reference (which means they
-        // have to be explicitly destroyed, since calling unref enough
-        // to cause destruction would lead to *another* unref).
-        // However, this combination means that it's actually still ok
-        // to use the normal pattern, which is to g_object_ref_sink
-        // after construction, and then destroy *and* unref when we're
-        // done.  (Though we could skip the g_object_ref_sink and the
-        // corresponding g_object_unref, but that's particular to
-        // GtkInvisibles and GtkWindows.)
-        GtkWidget *widget = gtk_invisible_new();
-        g_object_ref_sink(widget); // effectively g_object_ref (see above)
-
-        gtk_widget_ensure_style(widget);
-        mStyle = gtk_style_copy(gtk_widget_get_style(widget));
-
-        gtk_widget_destroy(widget);
-        g_object_unref(widget);
-    }
+    void InitWidget();
 };
 
 #endif
--- a/widget/gtk2/nsNativeThemeGTK.cpp
+++ b/widget/gtk2/nsNativeThemeGTK.cpp
@@ -1312,18 +1312,16 @@ nsNativeThemeGTK::WidgetStateChanged(nsI
   }
 
   return NS_OK;
 }
 
 NS_IMETHODIMP
 nsNativeThemeGTK::ThemeChanged()
 {
-  nsDeviceContext::ClearCachedSystemFonts();
-
   memset(mDisabledWidgetTypes, 0, sizeof(mDisabledWidgetTypes));
   return NS_OK;
 }
 
 NS_IMETHODIMP_(bool)
 nsNativeThemeGTK::ThemeSupportsWidget(nsPresContext* aPresContext,
                                       nsIFrame* aFrame,
                                       PRUint8 aWidgetType)
--- a/widget/os2/nsLookAndFeel.cpp
+++ b/widget/os2/nsLookAndFeel.cpp
@@ -34,22 +34,31 @@
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #define INCL_WIN
+#define INCL_WINWINDOWMGR
+#define INCL_WINSHELLDATA
+#define INCL_DOSNLS
+#define INCL_DOSERRORS
 #include <os2.h>
+#include <stdlib.h>
+
 #include "nsLookAndFeel.h"
 #include "nsFont.h"
 #include "nsSize.h"
 #include "nsStyleConsts.h"
 
+static bool bIsDBCS;
+static bool bIsDBCSSet = false;
+
 nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
 {
 }
 
 nsLookAndFeel::~nsLookAndFeel()
 {
 }
 
@@ -65,17 +74,17 @@ nsLookAndFeel::NativeGetColor(ColorID aI
         break;
     case eColorID_WindowForeground:
         idx = SYSCLR_WINDOWTEXT;
         break;
     case eColorID_WidgetBackground:
         idx = SYSCLR_BUTTONMIDDLE;
         break;
     case eColorID_WidgetForeground:
-        idx = SYSCLR_WINDOWTEXT; 
+        idx = SYSCLR_WINDOWTEXT;
         break;
     case eColorID_WidgetSelectBackground:
         idx = SYSCLR_HILITEBACKGROUND;
         break;
     case eColorID_WidgetSelectForeground:
         idx = SYSCLR_HILITEFOREGROUND;
         break;
     case eColorID_Widget3DHighlight:
@@ -267,17 +276,17 @@ nsLookAndFeel::NativeGetColor(ColorID aI
   int iRed = (lColor & RGB_RED) >> 16;
   int iGreen = (lColor & RGB_GREEN) >> 8;
   int iBlue = (lColor & RGB_BLUE);
 
   aColor = NS_RGB( iRed, iGreen, iBlue);
 
   return res;
 }
-  
+
 nsresult
 nsLookAndFeel::GetIntImpl(IntID aID, PRInt32 &aResult)
 {
   nsresult res = nsXPLookAndFeel::GetIntImpl(aID, aResult);
   if (NS_SUCCEEDED(res))
       return res;
   res = NS_OK;
 
@@ -379,8 +388,194 @@ nsLookAndFeel::GetFloatImpl(FloatID aID,
         aResult = 1.0f;
         break;
     default:
         aResult = -1.0;
         res = NS_ERROR_FAILURE;
   }
   return res;
 }
+
+/* Helper function to determine if we are running on DBCS */
+static bool
+IsDBCS()
+{
+  if (!bIsDBCSSet) {
+    APIRET rc;
+    COUNTRYCODE ctrycodeInfo = {0};
+    CHAR        achDBCSInfo[12] = {0};  // DBCS environmental vector
+    ctrycodeInfo.country  = 0;          // current country
+    ctrycodeInfo.codepage = 0;          // current codepage
+
+    rc = DosQueryDBCSEnv(sizeof(achDBCSInfo), &ctrycodeInfo, achDBCSInfo);
+    if (rc == NO_ERROR) {
+      // DBCS countries will have at least one nonzero byte in the
+      // first four bytes of the DBCS environmental vector
+      bIsDBCS = (achDBCSInfo[0] != 0 || achDBCSInfo[1] != 0 ||
+                 achDBCSInfo[2] != 0 || achDBCSInfo[3] != 0);
+    } else {
+      bIsDBCS = false;
+    }
+    bIsDBCSSet = true;
+  }
+  return bIsDBCS;
+}
+
+/* Helper function to query font from INI file */
+static void
+QueryFontFromINI(char* fontType, char* fontName, ULONG ulLength)
+{
+  ULONG ulMaxNameL = ulLength;
+
+  // We must use PrfQueryProfileData here, because some users have
+  // binary font data in their INI files.
+  if (PrfQueryProfileData(HINI_USER,
+                          (PCSZ)"PM_SystemFonts",
+                          (PCSZ)fontType,
+                          fontName, &ulMaxNameL)) {
+    // PrfQueryProfileData does not nul-terminate for us.
+    fontName[ulMaxNameL] = '\0';
+  } else {
+    // If there was no entry in the INI, default to something sensible.
+    // Make sure to use a DBCS-capable font in a DBCS-capable environment.
+    if (IsDBCS()) {
+      strcpy(fontName, "9.WarpSans Combined");
+    } else {
+      strcpy(fontName, "9.WarpSans");
+    }
+  }
+}
+
+/*
+ * Query the font used for various CSS properties (aID) from the system.
+ * For OS/2, only very few fonts are defined in the system, so most of the IDs
+ * resolve to the same system font.
+ * The font queried will give back a string like
+ *    9.WarpSans Bold
+ *    12.Times New Roman Bold Italic
+ *    10.Times New Roman.Strikeout.Underline
+ *    20.Bitstream Vera Sans Mono Obli
+ * (always restricted to 32 chars, at least before the second dot)
+ * We use the value before the dot as the font size (in pt, and convert it to
+ * px using the screen resolution) and then try to use the rest of the string
+ * to determine the font style from it.
+ */
+bool
+nsLookAndFeel::GetFont(FontID aID, nsString& aFontName,
+                       gfxFontStyle& aFontStyle)
+{
+  char szFontNameSize[MAXNAMEL];
+
+  switch (aID)
+    {
+    case eFont_Icon:
+      QueryFontFromINI("IconText", szFontNameSize, MAXNAMEL);
+      break;
+
+    case eFont_Menu:
+      QueryFontFromINI("Menus", szFontNameSize, MAXNAMEL);
+      break;
+
+    case eFont_Caption:
+    case eFont_MessageBox:
+    case eFont_SmallCaption:
+    case eFont_StatusBar:
+    case eFont_Tooltips:
+    case eFont_Widget:
+
+    case eFont_Window:      // css3
+    case eFont_Document:
+    case eFont_Workspace:
+    case eFont_Desktop:
+    case eFont_Info:
+    case eFont_Dialog:
+    case eFont_Button:
+    case eFont_PullDownMenu:
+    case eFont_List:
+    case eFont_Field:
+      QueryFontFromINI("WindowText", szFontNameSize, MAXNAMEL);
+      break;
+
+    default:
+      NS_WARNING("None of the listed font types, using WarpSans");
+      if (!IsDBCS()) {
+        strcpy(szFontNameSize, "9.WarpSans");
+      } else {
+        strcpy(szFontNameSize, "9.WarpSans Combined");
+      }
+    }
+
+  char *szFacename = strchr(szFontNameSize, '.');
+  if (!szFacename || (*(szFacename++) == '\0'))
+    return false;
+
+  // local DPI for size will be taken into account below
+  aFontStyle.size = atof(szFontNameSize);
+
+  // determine DPI resolution of screen device to compare compute
+  // font size in pixels
+  HPS ps = WinGetScreenPS(HWND_DESKTOP);
+  HDC dc = GpiQueryDevice(ps);
+  // effective vertical resolution in DPI
+  LONG vertScreenRes = 120; // assume 120 dpi as default
+  DevQueryCaps(dc, CAPS_VERTICAL_FONT_RES, 1, &vertScreenRes);
+  WinReleasePS(ps);
+
+  // now scale to make pixels from points (1 pt = 1/72in)
+  aFontStyle.size *= vertScreenRes / 72.0;
+
+  NS_ConvertUTF8toUTF16 fontFace(szFacename);
+  int pos = 0;
+
+  // this is a system font in any case
+  aFontStyle.systemFont = true;
+
+  // bold fonts should have " Bold" in their names, at least we hope that they
+  // do, otherwise it's bad luck
+  NS_NAMED_LITERAL_CSTRING(spcBold, " Bold");
+  if ((pos = fontFace.Find(spcBold.get(), false, 0, -1)) > -1) {
+    aFontStyle.weight = FONT_WEIGHT_BOLD;
+    // strip the attribute, now that we have set it in the gfxFontStyle
+    fontFace.Cut(pos, spcBold.Length());
+  } else {
+    aFontStyle.weight = FONT_WEIGHT_NORMAL;
+  }
+
+  // FIXME: Set aFontStyle.stretch correctly!
+  aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
+
+  // similar hopes for italic and oblique fonts...
+  NS_NAMED_LITERAL_CSTRING(spcItalic, " Italic");
+  NS_NAMED_LITERAL_CSTRING(spcOblique, " Oblique");
+  NS_NAMED_LITERAL_CSTRING(spcObli, " Obli");
+  if ((pos = fontFace.Find(spcItalic.get(), false, 0, -1)) > -1) {
+    aFontStyle.style = FONT_STYLE_ITALIC;
+    fontFace.Cut(pos, spcItalic.Length());
+  } else if ((pos = fontFace.Find(spcOblique.get(), false, 0, -1)) > -1) {
+    // oblique fonts are rare on OS/2 and not specially supported by
+    // the GPI system, but at least we are trying...
+    aFontStyle.style = FONT_STYLE_OBLIQUE;
+    fontFace.Cut(pos, spcOblique.Length());
+  } else if ((pos = fontFace.Find(spcObli.get(), false, 0, -1)) > -1) {
+    // especially oblique often gets cut by the 32 char limit to "Obli",
+    // so search for that, too (anything shorter would be ambiguous)
+    aFontStyle.style = FONT_STYLE_OBLIQUE;
+    // In this case, assume that this is the last property in the line
+    // and cut off everything else, too
+    // This is needed in case it was really Obliq or Obliqu...
+    fontFace.Cut(pos, fontFace.Length());
+  } else {
+    aFontStyle.style = FONT_STYLE_NORMAL;
+  }
+
+  // just throw away any modifiers that are separated by dots (which are either
+  // .Strikeout, .Underline, or .Outline, none of which have a corresponding
+  // gfxFont property)
+  if ((pos = fontFace.Find(".", false, 0, -1)) > -1) {
+    fontFace.Cut(pos, fontFace.Length());
+  }
+
+  // seems like we need quotes around the font name
+  NS_NAMED_LITERAL_STRING(quote, "\"");
+  aFontName = quote + fontFace + quote;
+
+  return true;
+}
--- a/widget/os2/nsLookAndFeel.h
+++ b/widget/os2/nsLookAndFeel.h
@@ -42,11 +42,13 @@
 class nsLookAndFeel: public nsXPLookAndFeel {
 public:
   nsLookAndFeel();
   virtual ~nsLookAndFeel();
 
   virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult);
   virtual nsresult GetIntImpl(IntID aID, PRInt32 &aResult);
   virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
+  virtual bool GetFontImpl(FontID aID, nsString& aFontName,
+                           gfxFontStyle& aFontStyle);
 };
 
 #endif
--- a/widget/qt/nsLookAndFeel.cpp
+++ b/widget/qt/nsLookAndFeel.cpp
@@ -1,9 +1,9 @@
-/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* ***** BEGIN LICENSE BLOCK *****
  * Version: MPL 1.1/GPL 2.0/LGPL 2.1
  *
  * The contents of this file are subject to the Mozilla Public License Version
  * 1.1 (the "License"); you may not use this file except in compliance with
  * the License. You may obtain a copy of the License at
  * http://www.mozilla.org/MPL/
  *
@@ -33,34 +33,40 @@
  * use your version of this file under the terms of the MPL, indicate your
  * decision by deleting the provisions above and replace them with the notice
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
-#include <QPalette>
+// Qt headers must be included before anything that might pull in our
+// malloc wrappers.
 #include <QApplication>
+#include <QFont>
+#include <QPalette>
 #include <QStyle>
 
+#undef NS_LOOKANDFEEL_DEBUG
+#ifdef NS_LOOKANDFEEL_DEBUG
+#include <QDebug>
+#endif
+
 #include "nsLookAndFeel.h"
 #include "nsStyleConsts.h"
 
 #include <qglobal.h>
 
-#undef NS_LOOKANDFEEL_DEBUG
-#ifdef NS_LOOKANDFEEL_DEBUG
-#include <QDebug>
-#endif
+#define QCOLOR_TO_NS_RGB(c)                     \
+  ((nscolor)NS_RGB(c.red(),c.green(),c.blue()))
 
-#define QCOLOR_TO_NS_RGB(c) \
-    ((nscolor)NS_RGB(c.red(),c.green(),c.blue()))
-
-nsLookAndFeel::nsLookAndFeel() : nsXPLookAndFeel()
+nsLookAndFeel::nsLookAndFeel()
+  : nsXPLookAndFeel(),
+    mDefaultFontCached(false), mButtonFontCached(false),
+    mFieldFontCached(false), mMenuFontCached(false)
 {
 }
 
 nsLookAndFeel::~nsLookAndFeel()
 {
 }
 
 nsresult
@@ -254,18 +260,18 @@ nsLookAndFeel::NativeGetColor(ColorID aI
     case eColorID_windowframe:
       aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Window));
       break;
 
     case eColorID_windowtext:
       aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Text));
       break;
 
-     // from the CSS3 working draft (not yet finalized)
-     // http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
+      // from the CSS3 working draft (not yet finalized)
+      // http://www.w3.org/tr/2000/wd-css3-userint-20000216.html#color
 
     case eColorID__moz_buttondefault:
       aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Button));
       break;
 
     case eColorID__moz_field:
     case eColorID__moz_combobox:
       aColor = QCOLOR_TO_NS_RGB(palette.color(QPalette::Normal, QPalette::Base));
@@ -302,58 +308,58 @@ nsLookAndFeel::NativeGetColor(ColorID aI
       res    = NS_ERROR_FAILURE;
       break;
   }
   return res;
 }
 
 #ifdef NS_LOOKANDFEEL_DEBUG
 static const char *metricToString[] = {
-    "eIntID_CaretBlinkTime",
-    "eIntID_CaretWidth",
-    "eIntID_ShowCaretDuringSelection",
-    "eIntID_SelectTextfieldsOnKeyFocus",
-    "eIntID_SubmenuDelay",
-    "eIntID_MenusCanOverlapOSBar",
-    "eIntID_SkipNavigatingDisabledMenuItem",
-    "eIntID_DragThresholdX",
-    "eIntID_DragThresholdY",
-    "eIntID_UseAccessibilityTheme",
-    "eIntID_ScrollArrowStyle",
-    "eIntID_ScrollSliderStyle",
-    "eIntID_ScrollButtonLeftMouseButtonAction",
-    "eIntID_ScrollButtonMiddleMouseButtonAction",
-    "eIntID_ScrollButtonRightMouseButtonAction",
-    "eIntID_TreeOpenDelay",
-    "eIntID_TreeCloseDelay",
-    "eIntID_TreeLazyScrollDelay",
-    "eIntID_TreeScrollDelay",
-    "eIntID_TreeScrollLinesMax",
-    "eIntID_TabFocusModel",
-    "eIntID_WindowsDefaultTheme",
-    "eIntID_AlertNotificationOrigin",
-    "eIntID_ScrollToClick",
-    "eIntID_IMERawInputUnderlineStyle",
-    "eIntID_IMESelectedRawTextUnderlineStyle",
-    "eIntID_IMEConvertedTextUnderlineStyle",
-    "eIntID_IMESelectedConvertedTextUnderline",
-    "eIntID_ImagesInMenus"
-    };
+  "eIntID_CaretBlinkTime",
+  "eIntID_CaretWidth",
+  "eIntID_ShowCaretDuringSelection",
+  "eIntID_SelectTextfieldsOnKeyFocus",
+  "eIntID_SubmenuDelay",
+  "eIntID_MenusCanOverlapOSBar",
+  "eIntID_SkipNavigatingDisabledMenuItem",
+  "eIntID_DragThresholdX",
+  "eIntID_DragThresholdY",
+  "eIntID_UseAccessibilityTheme",
+  "eIntID_ScrollArrowStyle",
+  "eIntID_ScrollSliderStyle",
+  "eIntID_ScrollButtonLeftMouseButtonAction",
+  "eIntID_ScrollButtonMiddleMouseButtonAction",
+  "eIntID_ScrollButtonRightMouseButtonAction",
+  "eIntID_TreeOpenDelay",
+  "eIntID_TreeCloseDelay",
+  "eIntID_TreeLazyScrollDelay",
+  "eIntID_TreeScrollDelay",
+  "eIntID_TreeScrollLinesMax",
+  "eIntID_TabFocusModel",
+  "eIntID_WindowsDefaultTheme",
+  "eIntID_AlertNotificationOrigin",
+  "eIntID_ScrollToClick",
+  "eIntID_IMERawInputUnderlineStyle",
+  "eIntID_IMESelectedRawTextUnderlineStyle",
+  "eIntID_IMEConvertedTextUnderlineStyle",
+  "eIntID_IMESelectedConvertedTextUnderline",
+  "eIntID_ImagesInMenus"
+};
 #endif
 
 nsresult
 nsLookAndFeel::GetIntImpl(IntID aID, PRInt32 &aResult)
 {
 #ifdef NS_LOOKANDFEEL_DEBUG
   qDebug("nsLookAndFeel::GetIntImpl aID = %s", metricToString[aID]);
 #endif
 
   nsresult res = nsXPLookAndFeel::GetIntImpl(aID, aResult);
   if (NS_SUCCEEDED(res))
-      return res;
+    return res;
 
   res = NS_OK;
 
   switch (aID) {
     case eIntID_CaretBlinkTime:
       aResult = 500;
       break;
 
@@ -420,30 +426,30 @@ nsLookAndFeel::GetIntImpl(IntID aID, PRI
       aResult = 0;
       res = NS_ERROR_FAILURE;
   }
   return res;
 }
 
 #ifdef NS_LOOKANDFEEL_DEBUG
 static const char *floatMetricToString[] = {
-    "eFloatID_IMEUnderlineRelativeSize"
+  "eFloatID_IMEUnderlineRelativeSize"
 };
 #endif
 
 nsresult
 nsLookAndFeel::GetFloatImpl(FloatID aID, float &aResult)
 {
 #ifdef NS_LOOKANDFEEL_DEBUG
   qDebug("nsLookAndFeel::GetFloatImpl aID = %s", floatMetricToString[aID]);
 #endif
 
   nsresult res = nsXPLookAndFeel::GetFloatImpl(aID, aResult);
   if (NS_SUCCEEDED(res))
-      return res;
+    return res;
   res = NS_OK;
 
   switch (aID) {
     case eFloatID_IMEUnderlineRelativeSize:
       aResult = 1.0f;
       break;
 
     case eFloatID_SpellCheckerUnderlineRelativeSize:
@@ -452,8 +458,104 @@ nsLookAndFeel::GetFloatImpl(FloatID aID,
 
     default:
       aResult = -1.0;
       res = NS_ERROR_FAILURE;
       break;
   }
   return res;
 }
+
+static void
+GetSystemFontInfo(const char *aClassName, nsString *aFontName,
+                  gfxFontStyle *aFontStyle)
+{
+  QFont qFont = QApplication::font(aClassName);
+
+  NS_NAMED_LITERAL_STRING(quote, "\"");
+  nsString family((PRUnichar*)qFont.family().data());
+  *aFontName = quote + family + quote;
+
+  aFontStyle->systemFont = true;
+  aFontStyle->style = FONT_STYLE_NORMAL;
+  aFontStyle->weight = qFont.weight();
+  // FIXME: Set aFontStyle->stretch correctly!
+  aFontStyle->stretch = NS_FONT_STRETCH_NORMAL;
+  // use pixel size directly if it is set, otherwise compute from point size
+  if (qFont.pixelSize() != -1) {
+    aFontStyle->size = qFont.pixelSize();
+  } else {
+    aFontStyle->size = qFont.pointSizeF() * 96.0f / 72.0f;
+  }
+}
+
+bool
+nsLookAndFeel::GetFontImpl(FontID aID, nsString& aFontName,
+                           gfxFontStyle& aFontStyle)
+{
+  const char *className = NULL;
+  nsString *cachedFontName = NULL;
+  gfxFontStyle *cachedFontStyle = NULL;
+  bool *isCached = NULL;
+
+  switch (aID) {
+    case eFont_Menu:         // css2
+    case eFont_PullDownMenu: // css3
+      cachedFontName = &mMenuFontName;
+      cachedFontStyle = &mMenuFontStyle;
+      isCached = &mMenuFontCached;
+      className = "QAction";
+      break;
+
+    case eFont_Field:        // css3
+    case eFont_List:         // css3
+      cachedFontName = &mFieldFontName;
+      cachedFontStyle = &mFieldFontStyle;
+      isCached = &mFieldFontCached;
+      className = "QlineEdit";
+      break;
+
+    case eFont_Button:       // css3
+      cachedFontName = &mButtonFontName;
+      cachedFontStyle = &mButtonFontStyle;
+      isCached = &mButtonFontCached;
+      className = "QPushButton";
+      break;
+
+    case eFont_Caption:      // css2
+    case eFont_Icon:         // css2
+    case eFont_MessageBox:   // css2
+    case eFont_SmallCaption: // css2
+    case eFont_StatusBar:    // css2
+    case eFont_Window:       // css3
+    case eFont_Document:     // css3
+    case eFont_Workspace:    // css3
+    case eFont_Desktop:      // css3
+    case eFont_Info:         // css3
+    case eFont_Dialog:       // css3
+    case eFont_Tooltips:     // moz
+    case eFont_Widget:       // moz
+      cachedFontName = &mDefaultFontName;
+      cachedFontStyle = &mDefaultFontStyle;
+      isCached = &mDefaultFontCached;
+      className = "Qlabel";
+      break;
+  }
+
+  if (!*isCached) {
+    GetSystemFontInfo(className, cachedFontName, cachedFontStyle);
+    *isCached = true;
+  }
+
+  aFontName = *cachedFontName;
+  aFontStyle = *cachedFontStyle;
+  return true;
+}
+
+void
+nsLookAndFeel::RefreshImpl()
+{
+  nsXPLookAndFeel::RefreshImpl();
+  mDefaultFontCached = false;
+  mButtonFontCached = false;
+  mFieldFontCached = false;
+  mMenuFontCached = false;
+}
--- a/widget/qt/nsLookAndFeel.h
+++ b/widget/qt/nsLookAndFeel.h
@@ -35,21 +35,39 @@
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 #ifndef __nsLookAndFeel
 #define __nsLookAndFeel
 
 #include "nsXPLookAndFeel.h"
+#include "gfxFont.h"
 
 class nsLookAndFeel: public nsXPLookAndFeel
 {
 public:
     nsLookAndFeel();
     virtual ~nsLookAndFeel();
 
     virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult);
     virtual nsresult GetIntImpl(IntID aID, PRInt32 &aResult);
     virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
+    virtual bool GetFontImpl(FontID aID, nsString& aFontName,
+                             gfxFontStyle& aFontStyle);
+    virtual void RefreshImpl();
+
+private:
+    bool mDefaultFontCached;
+    bool mButtonFontCached;
+    bool mFieldFontCached;
+    bool mMenuFontCached;
+    nsString mDefaultFontName;
+    nsString mButtonFontName;
+    nsString mFieldFontName;
+    nsString mMenuFontName;
+    gfxFontStyle mDefaultFontStyle;
+    gfxFontStyle mButtonFontStyle;
+    gfxFontStyle mFieldFontStyle;
+    gfxFontStyle mMenuFontStyle;
 };
 
 #endif
--- a/widget/windows/nsLookAndFeel.cpp
+++ b/widget/windows/nsLookAndFeel.cpp
@@ -41,19 +41,21 @@
 
 #include "nsLookAndFeel.h"
 #include <windows.h>
 #include <shellapi.h>
 #include "nsWindow.h"
 #include "nsStyleConsts.h"
 #include "nsUXThemeData.h"
 #include "nsUXThemeConstants.h"
+#include "gfxFont.h"
 #include "WinUtils.h"
 
 using namespace mozilla::widget;
+using mozilla::LookAndFeel;
 
 typedef UINT (CALLBACK *SHAppBarMessagePtr)(DWORD, PAPPBARDATA);
 SHAppBarMessagePtr gSHAppBarMessage = NULL;
 static HINSTANCE gShell32DLLInst = NULL;
 
 static nsresult GetColorFromTheme(nsUXThemeClass cls,
                            PRInt32 aPart,
                            PRInt32 aState,
@@ -516,15 +518,152 @@ nsLookAndFeel::GetFloatImpl(FloatID aID,
         break;
     default:
         aResult = -1.0;
         res = NS_ERROR_FAILURE;
     }
   return res;
 }
 
+static bool
+GetSysFontInfo(HDC aHDC, LookAndFeel::FontID anID,
+               nsString &aFontName,
+               gfxFontStyle &aFontStyle)
+{
+  LOGFONTW* ptrLogFont = NULL;
+  LOGFONTW logFont;
+  NONCLIENTMETRICSW ncm;
+  HGDIOBJ hGDI;
+  PRUnichar name[LF_FACESIZE];
+
+  // Depending on which stock font we want, there are three different
+  // places we might have to look it up.
+  switch (anID) {
+  case LookAndFeel::eFont_Icon:
+    if (!::SystemParametersInfoW(SPI_GETICONTITLELOGFONT,
+                                 sizeof(logFont), (PVOID)&logFont, 0))
+      return false;
+
+    ptrLogFont = &logFont;
+    break;
+
+  case LookAndFeel::eFont_Menu:
+  case LookAndFeel::eFont_MessageBox:
+  case LookAndFeel::eFont_SmallCaption:
+  case LookAndFeel::eFont_StatusBar:
+  case LookAndFeel::eFont_Tooltips:
+    ncm.cbSize = sizeof(NONCLIENTMETRICSW);
+    if (!::SystemParametersInfoW(SPI_GETNONCLIENTMETRICS,
+                                 sizeof(ncm), (PVOID)&ncm, 0))
+      return false;
+
+    switch (anID) {
+    case LookAndFeel::eFont_Menu:
+      ptrLogFont = &ncm.lfMenuFont;
+      break;
+    case LookAndFeel::eFont_MessageBox:
+      ptrLogFont = &ncm.lfMessageFont;
+      break;
+    case LookAndFeel::eFont_SmallCaption:
+      ptrLogFont = &ncm.lfSmCaptionFont;
+      break;
+    case LookAndFeel::eFont_StatusBar:
+    case LookAndFeel::eFont_Tooltips:
+      ptrLogFont = &ncm.lfStatusFont;
+      break;
+    }
+    break;
+
+  case LookAndFeel::eFont_Widget:
+  case LookAndFeel::eFont_Window:      // css3
+  case LookAndFeel::eFont_Document:
+  case LookAndFeel::eFont_Workspace:
+  case LookAndFeel::eFont_Desktop:
+  case LookAndFeel::eFont_Info:
+  case LookAndFeel::eFont_Dialog:
+  case LookAndFeel::eFont_Button:
+  case LookAndFeel::eFont_PullDownMenu:
+  case LookAndFeel::eFont_List:
+  case LookAndFeel::eFont_Field:
+  case LookAndFeel::eFont_Caption:
+    hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
+    if (!hGDI)
+      return false;
+
+    if (::GetObjectW(hGDI, sizeof(logFont), &logFont) <= 0)
+      return false;
+
+    ptrLogFont = &logFont;
+    break;
+  }
+
+  // FIXME?: mPixelScale is currently hardcoded to 1.
+  float mPixelScale = 1.0f;
+
+  // The lfHeight is in pixels, and it needs to be adjusted for the
+  // device it will be displayed on.
+  // Screens and Printers will differ in DPI
+  //
+  // So this accounts for the difference in the DeviceContexts
+  // The mPixelScale will be a "1" for the screen and could be
+  // any value when going to a printer, for example mPixleScale is
+  // 6.25 when going to a 600dpi printer.
+  // round, but take into account whether it is negative
+  float pixelHeight = -ptrLogFont->lfHeight;
+  if (pixelHeight < 0) {
+    HFONT hFont = ::CreateFontIndirectW(ptrLogFont);
+    if (!hFont)
+      return false;
+    HGDIOBJ hObject = ::SelectObject(aHDC, hFont);
+    TEXTMETRIC tm;
+    ::GetTextMetrics(aHDC, &tm);
+    ::SelectObject(aHDC, hObject);
+    ::DeleteObject(hFont);
+    pixelHeight = tm.tmAscent;
+  }
+  pixelHeight *= mPixelScale;
+
+  // 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;
+
+  aFontStyle.size = pixelHeight;
+
+  // FIXME: What about oblique?
+  aFontStyle.style =
+    (ptrLogFont->lfItalic) ? FONT_STYLE_ITALIC : FONT_STYLE_NORMAL;
+
+  // FIXME: Other weights?
+  aFontStyle.weight =
+    (ptrLogFont->lfWeight == FW_BOLD ? FONT_WEIGHT_BOLD : FONT_WEIGHT_NORMAL);
+
+  // FIXME: Set aFontStyle->stretch correctly!
+  aFontStyle.stretch = NS_FONT_STRETCH_NORMAL;
+
+  aFontStyle.systemFont = true;
+
+  name[0] = 0;
+  memcpy(name, ptrLogFont->lfFaceName, LF_FACESIZE*sizeof(PRUnichar));
+  aFontName = name;
+
+  return true;
+}
+
+bool
+nsLookAndFeel::GetFontImpl(FontID anID, nsString &aFontName,
+                           gfxFontStyle &aFontStyle)
+{
+  HDC tdc = GetDC(NULL);
+  bool status = GetSysFontInfo(tdc, anID, aFontName, aFontStyle);
+  ReleaseDC(NULL, tdc);
+  return status;
+}
+
 /* virtual */
 PRUnichar
 nsLookAndFeel::GetPasswordCharacterImpl()
 {
 #define UNICODE_BLACK_CIRCLE_CHAR 0x25cf
   return UNICODE_BLACK_CIRCLE_CHAR;
 }
--- a/widget/windows/nsLookAndFeel.h
+++ b/widget/windows/nsLookAndFeel.h
@@ -56,12 +56,14 @@
 class nsLookAndFeel: public nsXPLookAndFeel {
 public:
   nsLookAndFeel();
   virtual ~nsLookAndFeel();
 
   virtual nsresult NativeGetColor(ColorID aID, nscolor &aResult);
   virtual nsresult GetIntImpl(IntID aID, PRInt32 &aResult);
   virtual nsresult GetFloatImpl(FloatID aID, float &aResult);
+  virtual bool GetFontImpl(FontID aID, nsString& aFontName,
+                           gfxFontStyle& aFontStyle);
   virtual PRUnichar GetPasswordCharacterImpl();
 };
 
 #endif
--- a/widget/xpwidgets/nsXPLookAndFeel.cpp
+++ b/widget/xpwidgets/nsXPLookAndFeel.cpp
@@ -735,16 +735,23 @@ LookAndFeel::GetInt(IntID aID, PRInt32* 
 // static
 nsresult
 LookAndFeel::GetFloat(FloatID aID, float* aResult)
 {
   return nsLookAndFeel::GetInstance()->GetFloatImpl(aID, *aResult);
 }
 
 // static
+bool
+LookAndFeel::GetFont(FontID aID, nsString& aName, gfxFontStyle& aStyle)
+{
+  return nsLookAndFeel::GetInstance()->GetFontImpl(aID, aName, aStyle);
+}
+
+// static
 PRUnichar
 LookAndFeel::GetPasswordCharacter()
 {
   return nsLookAndFeel::GetInstance()->GetPasswordCharacterImpl();
 }
 
 // static
 bool
--- a/widget/xpwidgets/nsXPLookAndFeel.h
+++ b/widget/xpwidgets/nsXPLookAndFeel.h
@@ -83,16 +83,21 @@ public:
   // in which case the nsLookAndFeel should use that value;
   // otherwise we'll return NS_ERROR_NOT_AVAILABLE, in which case, the
   // platform-specific nsLookAndFeel should use its own values instead.
   //
   nsresult GetColorImpl(ColorID aID, nscolor &aResult);
   virtual nsresult GetIntImpl(IntID aID, PRInt32 &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) = 0;
+
   virtual void RefreshImpl();
 
   virtual PRUnichar GetPasswordCharacterImpl()
   {
     return PRUnichar('*');
   }
 
   virtual bool GetEchoPasswordImpl()