WebCore:
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jan 2009 03:45:20 +0000 (03:45 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 9 Jan 2009 03:45:20 +0000 (03:45 +0000)
        Reviewed by Adam Roben.

        - use native glyph support in Core Graphics when available

        * platform/graphics/win/FontCGWin.cpp:
        (WebCore::Font::drawGlyphs): Changed to use drawGDIGlyphs() only if
        native glyph support is not available or stroking is required. Changed
        to pass the font's useGDI() flag to wkSetCGContextFontRenderingStyle to
        request the use of native glyphs.
        * platform/graphics/win/FontCustomPlatformData.cpp:
        (WebCore::FontCustomPlatformData::fontPlatformData): Added a call to
        wkSetFontPlatformInfo to attach the LOGFONT to the CGFont.
        * platform/graphics/win/FontPlatformDataCGWin.cpp:
        (WebCore::FontPlatformData::platformDataInit): Ditto.

WebKit/win:

        Reviewed by Adam Roben.

        - WebPreferences changes to support Core Graphics native glyph drawing

        * Interfaces/IWebPreferencesPrivate.idl: Added font smoothing contrast
        getter and setter.
        * WebPreferenceKeysPrivate.h: Added
        WebKitFontSmoothingContrastPreferenceKey.
        * WebPreferences.cpp:
        (WebPreferences::initializeDefaultSettings): Initialized
        WebKitFontSmoothingContrastPreferenceKey to 2.
        (WebPreferences::setFloatValue): Added.
        (WebPreferences::setFontSmoothing): Changed to map
        FontSmoothingTypeWindows to FontSmoothingTypeMedium.
        (WebPreferences::fontSmoothingContrast): Added.
        (WebPreferences::setFontSmoothingContrast): Added. Calls
        wkSetFontSmoothingContrast().
        * WebPreferences.h:

WebKitLibraries:

        Reviewed by Adam Roben.

        - WebKitSystemInterface changes to support Core Graphics native glyph drawing

        * win/include/WebKitSystemInterface/WebKitSystemInterface.h:
        * win/lib/WebKitSystemInterface.lib:
        * win/lib/WebKitSystemInterface_debug.lib:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@39736 268f45cc-cd09-0410-ab3c-d52691b4dbfc

13 files changed:
WebCore/ChangeLog
WebCore/platform/graphics/win/FontCGWin.cpp
WebCore/platform/graphics/win/FontCustomPlatformData.cpp
WebCore/platform/graphics/win/FontPlatformDataCGWin.cpp
WebKit/win/ChangeLog
WebKit/win/Interfaces/IWebPreferencesPrivate.idl
WebKit/win/WebPreferenceKeysPrivate.h
WebKit/win/WebPreferences.cpp
WebKit/win/WebPreferences.h
WebKitLibraries/ChangeLog
WebKitLibraries/win/include/WebKitSystemInterface/WebKitSystemInterface.h
WebKitLibraries/win/lib/WebKitSystemInterface.lib
WebKitLibraries/win/lib/WebKitSystemInterface_debug.lib

index 2c68c380651f568176791fcb1379ab8d05a98ecd..417e63dd52a72be1ea6936fcb4f643079237761d 100644 (file)
@@ -1,3 +1,20 @@
+2009-01-08  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Adam Roben.
+
+        - use native glyph support in Core Graphics when available
+
+        * platform/graphics/win/FontCGWin.cpp:
+        (WebCore::Font::drawGlyphs): Changed to use drawGDIGlyphs() only if
+        native glyph support is not available or stroking is required. Changed
+        to pass the font's useGDI() flag to wkSetCGContextFontRenderingStyle to
+        request the use of native glyphs.
+        * platform/graphics/win/FontCustomPlatformData.cpp:
+        (WebCore::FontCustomPlatformData::fontPlatformData): Added a call to
+        wkSetFontPlatformInfo to attach the LOGFONT to the CGFont.
+        * platform/graphics/win/FontPlatformDataCGWin.cpp:
+        (WebCore::FontPlatformData::platformDataInit): Ditto.
+
 2009-01-08  Peter Kasting  <pkasting@google.com>
 
         Reviewed by Sam Weinig.
index 4fa02ac874da3f9329290f34d0d69cb055ab5318..24a4b17193b379584d1b41916bfadf2ff72b8653 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -294,13 +294,16 @@ static void drawGDIGlyphs(GraphicsContext* graphicsContext, const SimpleFontData
 void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, 
                       int from, int numGlyphs, const FloatPoint& point) const
 {
-    if (font->m_font.useGDI()) {
-        drawGDIGlyphs(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
-        return;
-    }
-
     CGContextRef cgContext = graphicsContext->platformContext();
 
+    if (font->platformData().useGDI()) {
+        static bool canUsePlatformNativeGlyphs = wkCanUsePlatformNativeGlyphs();
+        if (!canUsePlatformNativeGlyphs || (graphicsContext->textDrawingMode() & cTextStroke)) {
+            drawGDIGlyphs(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
+            return;
+        }
+    }
+
     uint32_t oldFontSmoothingStyle = wkSetFontSmoothingStyle(cgContext, WebCoreShouldUseFontSmoothing());
 
     const FontPlatformData& platformData = font->platformData();
@@ -322,7 +325,7 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* fo
     FloatSize translation = glyphBuffer.offsetAt(from);
 
     CGContextSetFontSize(cgContext, platformData.size());
-    wkSetCGContextFontRenderingStyle(cgContext, font->isSystemFont(), false);
+    wkSetCGContextFontRenderingStyle(cgContext, font->isSystemFont(), false, font->platformData().useGDI());
 
     IntSize shadowSize;
     int shadowBlur;
index 26fceba51f42cfcbaea22fe82e3d0821c8bd5537..ba8afe729ce59c999812395400034254abf50872 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -27,6 +27,7 @@
 #include "SharedBuffer.h"
 #include "SoftLinking.h"
 #include <ApplicationServices/ApplicationServices.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <wtf/RetainPtr.h>
 
 // From t2embapi.h, which is missing from the Microsoft Platform SDK.
@@ -64,7 +65,10 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b
     ASSERT(m_fontReference);
     ASSERT(T2embedLibrary());
 
-    LOGFONT logFont;
+    static bool canUsePlatformNativeGlyphs = wkCanUsePlatformNativeGlyphs();
+    LOGFONT _logFont;
+
+    LOGFONT& logFont = canUsePlatformNativeGlyphs ? *static_cast<LOGFONT*>(malloc(sizeof(LOGFONT))) : _logFont;
     if (m_name.isNull())
         TTGetNewFontName(&m_fontReference, logFont.lfFaceName, LF_FACESIZE, 0, 0);
     else
@@ -86,6 +90,8 @@ FontPlatformData FontCustomPlatformData::fontPlatformData(int size, bool bold, b
     logFont.lfWeight = bold ? 700 : 400;
 
     HFONT hfont = CreateFontIndirect(&logFont);
+    if (canUsePlatformNativeGlyphs)
+        wkSetFontPlatformInfo(m_cgFont, &logFont, free);
     return FontPlatformData(hfont, m_cgFont, size, bold, italic, renderingMode == AlternateRenderingMode);
 }
 
index bbfdb9fdde5ba98e87ae81b836930b1ecd4d3854..c7e59ab4de5cf560e84f72b777a12bacba468ba6 100644 (file)
@@ -2,7 +2,7 @@
  * This file is part of the internal font implementation.  It should not be included by anyone other than
  * FontMac.cpp, FontWin.cpp and Font.cpp.
  *
- * Copyright (C) 2006, 2007, 2008 Apple Inc.
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -27,6 +27,7 @@
 #include "PlatformString.h"
 #include "StringHash.h"
 #include <ApplicationServices/ApplicationServices.h>
+#include <WebKitSystemInterface/WebKitSystemInterface.h>
 #include <wtf/HashMap.h>
 #include <wtf/RetainPtr.h>
 #include <wtf/Vector.h>
@@ -119,6 +120,11 @@ void FontPlatformData::platformDataInit(HFONT font, float size, HDC hdc, WCHAR*
             ASSERT(m_cgFont);
         }
     }
+    if (m_useGDI && wkCanUsePlatformNativeGlyphs()) {
+        LOGFONT* logfont = static_cast<LOGFONT*>(malloc(sizeof(LOGFONT)));
+        GetObject(font, sizeof(*logfont), logfont);
+        wkSetFontPlatformInfo(m_cgFont.get(), logfont, free);
+    }
 }
 
 FontPlatformData::FontPlatformData(HFONT hfont, CGFontRef font, float size, bool bold, bool oblique, bool useGDI)
index 5122d34e83f681f3c635875e3394d961a2af9780..cca9b5335f6b0b5b665bbd5b6abc747c45814bcf 100644 (file)
@@ -1,3 +1,24 @@
+2009-01-08  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Adam Roben.
+
+        - WebPreferences changes to support Core Graphics native glyph drawing
+
+        * Interfaces/IWebPreferencesPrivate.idl: Added font smoothing contrast
+        getter and setter.
+        * WebPreferenceKeysPrivate.h: Added
+        WebKitFontSmoothingContrastPreferenceKey.
+        * WebPreferences.cpp:
+        (WebPreferences::initializeDefaultSettings): Initialized
+        WebKitFontSmoothingContrastPreferenceKey to 2.
+        (WebPreferences::setFloatValue): Added.
+        (WebPreferences::setFontSmoothing): Changed to map
+        FontSmoothingTypeWindows to FontSmoothingTypeMedium.
+        (WebPreferences::fontSmoothingContrast): Added.
+        (WebPreferences::setFontSmoothingContrast): Added. Calls
+        wkSetFontSmoothingContrast().
+        * WebPreferences.h:
+
 2009-01-08  Steve Falkenburg  <sfalken@apple.com>
 
         <rdar://problem/6474244> REGRESSION(39561-39603): Heap corruption when saving passwords?
index 62ed0be4336918e25ba40b5903ab05d272a2d02e..aa1073f9772eb5029cce668251f932a5ee97fd31 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2007, 2008, 2009 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -65,5 +65,8 @@ interface IWebPreferencesPrivate : IUnknown
     HRESULT databasesEnabled([out, retval] BOOL *enabled);
 
     HRESULT setLocalStorageEnabled([in] BOOL enabled);
-    HRESULT localStorageEnabled([out, retval] BOOL *enabled);
+    HRESULT localStorageEnabled([out, retval] BOOL* enabled);
+
+    HRESULT setFontSmoothingContrast([in] float contrast);
+    HRESULT fontSmoothingContrast([out, retval] float* contrast);
 }
index b74fc0496b0e81477c163b05808c59d7fd2bc327..758254ee008c86dbd57bfc0ead8b823806ea9f34 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2005, 2006, 2007, 2008 Apple Inc.  All rights reserved.
+ * Copyright (C) 2005, 2006, 2007, 2008, 2009 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -91,6 +91,7 @@
 
 // Windows-specific keys
 #define WebKitFontSmoothingTypePreferenceKey "WebKitFontSmoothingType" // default: FontSmoothingTypeMedium (2)
+#define WebKitFontSmoothingContrastPreferenceKey "WebKitFontSmoothingContrast" // default: "2"
 #define WebKitCookieStorageAcceptPolicyPreferenceKey "WebKitCookieStorageAcceptPolicy" // default: WebKitCookieStorageAcceptPolicyOnlyFromMainDocumentDomain
 
 #define WebContinuousSpellCheckingEnabledPreferenceKey "WebContinuousSpellCheckingEnabled" // default: false
index 5ad5cb1bef69bcd4bcb958145150c849dd720d95..1355acbddc6587cde0c4caf35daffc1cc7b6d8fd 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -223,6 +223,7 @@ void WebPreferences::initializeDefaultSettings()
     CFDictionaryAddValue(defaults, CFSTR(WebKitIconDatabaseLocationKey), CFSTR(""));
     CFDictionaryAddValue(defaults, CFSTR(WebKitIconDatabaseEnabledPreferenceKey), kCFBooleanTrue);
     CFDictionaryAddValue(defaults, CFSTR(WebKitFontSmoothingTypePreferenceKey), CFSTR("2"));
+    CFDictionaryAddValue(defaults, CFSTR(WebKitFontSmoothingContrastPreferenceKey), CFSTR("2"));
     CFDictionaryAddValue(defaults, CFSTR(WebKitCookieStorageAcceptPolicyPreferenceKey), CFSTR("2"));
     CFDictionaryAddValue(defaults, CFSTR(WebContinuousSpellCheckingEnabledPreferenceKey), kCFBooleanFalse);
     CFDictionaryAddValue(defaults, CFSTR(WebGrammarCheckingEnabledPreferenceKey), kCFBooleanFalse);
@@ -336,6 +337,16 @@ void WebPreferences::setIntegerValue(CFStringRef key, int value)
     postPreferencesChangesNotification();
 }
 
+void WebPreferences::setFloatValue(CFStringRef key, float value)
+{
+    if (floatValueForKey(key) == value)
+        return;
+
+    setValueForKey(key, cfNumber(value).get());
+
+    postPreferencesChangesNotification();
+}
+
 void WebPreferences::setBoolValue(CFStringRef key, BOOL value)
 {
     if (boolValueForKey(key) == value)
@@ -965,11 +976,26 @@ HRESULT STDMETHODCALLTYPE WebPreferences::setFontSmoothing(
 {
     setIntegerValue(CFSTR(WebKitFontSmoothingTypePreferenceKey), smoothingType);
     if (smoothingType == FontSmoothingTypeWindows)
-        smoothingType = FontSmoothingTypeStandard;
+        smoothingType = FontSmoothingTypeMedium;
     wkSetFontSmoothingLevel((int)smoothingType);
     return S_OK;
 }
 
+HRESULT STDMETHODCALLTYPE WebPreferences::fontSmoothingContrast( 
+    /* [retval][out] */ float* contrast)
+{
+    *contrast = floatValueForKey(CFSTR(WebKitFontSmoothingContrastPreferenceKey));
+    return S_OK;
+}
+
+HRESULT STDMETHODCALLTYPE WebPreferences::setFontSmoothingContrast( 
+    /* [in] */ float contrast)
+{
+    setFloatValue(CFSTR(WebKitFontSmoothingContrastPreferenceKey), contrast);
+    wkSetFontSmoothingContrast(contrast);
+    return S_OK;
+}
+
 HRESULT STDMETHODCALLTYPE WebPreferences::editableLinkBehavior(
     /* [out, retval] */ WebKitEditableLinkBehavior* editableLinkBehavior)
 {
index 1dbcd31346b2c6338f22fcac1324e65fcc2ac729..6ab3dcb4789de1703d6a61f9c055208779ea5477 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2006, 2007, 2008 Apple Inc.  All rights reserved.
+ * Copyright (C) 2006, 2007, 2008, 2009 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -338,6 +338,12 @@ public:
     virtual HRESULT STDMETHODCALLTYPE zoomsTextOnly( 
     /* [retval][out] */ BOOL *zoomsTextOnly);
 
+    virtual HRESULT STDMETHODCALLTYPE fontSmoothingContrast( 
+    /* [retval][out] */ float* contrast);
+    
+    virtual HRESULT STDMETHODCALLTYPE setFontSmoothingContrast( 
+    /* [in] */ float contrast);
+
     // WebPreferences
 
     // This method accesses a different preference key than developerExtrasEnabled.
@@ -373,6 +379,7 @@ protected:
     void setStringValue(CFStringRef key, LPCTSTR value);
     void setIntegerValue(CFStringRef key, int value);
     void setBoolValue(CFStringRef key, BOOL value);
+    void setFloatValue(CFStringRef key, float value);
     void setLongLongValue(CFStringRef key, LONGLONG value);
     static WebPreferences* getInstanceForIdentifier(BSTR identifier);
     static void initializeDefaultSettings();
index 48a2123664fc7dd0eb55227763964a87ef3be0e9..e6d04bbf0c93f2675744bb89bba3cee9504cdca5 100644 (file)
@@ -1,3 +1,13 @@
+2009-01-08  Dan Bernstein  <mitz@apple.com>
+
+        Reviewed by Adam Roben.
+
+        - WebKitSystemInterface changes to support Core Graphics native glyph drawing
+
+        * win/include/WebKitSystemInterface/WebKitSystemInterface.h:
+        * win/lib/WebKitSystemInterface.lib:
+        * win/lib/WebKitSystemInterface_debug.lib:
+
 2008-11-11  Ada Chan  <adachan@apple.com>
 
         Fix: https://bugs.webkit.org/show_bug.cgi?id=22187
index 9d3c969a593065d106253a38eecc03381334f70f..0196031f5f5870c0b5380f92c88fbeb006b39049 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007 Apple Inc.  All rights reserved.
+ * Copyright (C) 2007, 2008, 2009 Apple Inc.  All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -45,11 +45,15 @@ typedef const struct _CFURLRequest* CFURLRequestRef;
 
 void wkSetFontSmoothingLevel(int type);
 int wkGetFontSmoothingLevel();
+void wkSetFontSmoothingContrast(CGFloat);
+CGFloat wkGetFontSmoothingContrast();
 uint32_t wkSetFontSmoothingStyle(CGContextRef cg, bool fontAllowsSmoothing);
 void wkRestoreFontSmoothingStyle(CGContextRef cg, uint32_t oldStyle);
-void wkSetCGContextFontRenderingStyle(CGContextRef, bool isSystemFont, bool isPrinterFont);
+bool wkCanUsePlatformNativeGlyphs();
+void wkSetCGContextFontRenderingStyle(CGContextRef, bool isSystemFont, bool isPrinterFont, bool usePlatformNativeGlyphs);
 void wkGetGlyphAdvances(CGFontRef, const CGAffineTransform&, bool isSystemFont, bool isPrinterFont, CGGlyph, CGSize& advance);
 void wkGetGlyphs(CGFontRef, const UChar[], CGGlyph[], size_t count);
+void wkSetFontPlatformInfo(CGFontRef, LOGFONT*, void(*)(void*));
 void wkSetUpFontCache(size_t s);
 void wkAddFontsInDirectory(CFStringRef);
 void wkAddFontsAtPath(CFStringRef);
index 2d8df77a11872ad3a95bf1ef6f252ec9c98e6557..3189db7502aa4e30926fd58575596e4b2e44d1b3 100644 (file)
Binary files a/WebKitLibraries/win/lib/WebKitSystemInterface.lib and b/WebKitLibraries/win/lib/WebKitSystemInterface.lib differ
index 9bc4e470146dc61334b9daa6caf55c17d882957a..68785e460f89f7e85ca4ba8afd5c60bde8c655bd 100644 (file)
Binary files a/WebKitLibraries/win/lib/WebKitSystemInterface_debug.lib and b/WebKitLibraries/win/lib/WebKitSystemInterface_debug.lib differ