Title: [182824] trunk
Revision
182824
Author
simon.fra...@apple.com
Date
2015-04-14 17:26:23 -0700 (Tue, 14 Apr 2015)

Log Message

Re-enable custom dilation for antialiased fonts
https://bugs.webkit.org/show_bug.cgi?id=143738

Reviewed by Tim Horton.

Enabling custom dilation for antialised fonts broke layout tests, so re-land it,
but disable in WebKitTestRunner and DumpRenderTree. The latter requires adding
a private WebKit pref. This pref defaults to YES, enabling the feature by default
in WK1 as we do for WK2.

Source/WebCore:

* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::dilationSizeForTextColor):
(WebCore::FontCascade::drawGlyphs):

Source/WebKit/mac:

* WebView/WebPreferenceKeysPrivate.h:
* WebView/WebPreferences.mm:
(+[WebPreferences initialize]):
(-[WebPreferences setAntialiasedFontDilationEnabled:]):
(-[WebPreferences antialiasedFontDilationEnabled]):
* WebView/WebPreferencesPrivate.h:
* WebView/WebView.mm:
(-[WebView _preferencesChanged:]):

Tools:

* DumpRenderTree/mac/DumpRenderTree.mm:
(resetWebPreferencesToConsistentValues):
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::resetPreferencesToConsistentValues):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (182823 => 182824)


--- trunk/Source/WebCore/ChangeLog	2015-04-15 00:20:54 UTC (rev 182823)
+++ trunk/Source/WebCore/ChangeLog	2015-04-15 00:26:23 UTC (rev 182824)
@@ -1,3 +1,19 @@
+2015-04-14  Simon Fraser  <simon.fra...@apple.com>
+
+        Re-enable custom dilation for antialiased fonts
+        https://bugs.webkit.org/show_bug.cgi?id=143738
+
+        Reviewed by Tim Horton.
+        
+        Enabling custom dilation for antialised fonts broke layout tests, so re-land it,
+        but disable in WebKitTestRunner and DumpRenderTree. The latter requires adding
+        a private WebKit pref. This pref defaults to YES, enabling the feature by default
+        in WK1 as we do for WK2.
+
+        * platform/graphics/cocoa/FontCascadeCocoa.mm:
+        (WebCore::dilationSizeForTextColor):
+        (WebCore::FontCascade::drawGlyphs):
+
 2015-04-14  Andy Estes  <aes...@apple.com>
 
         [Content Filtering] Use ASSERT_WITH_SECURITY_IMPLICATION for verifying types from NEFilterSource

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (182823 => 182824)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2015-04-15 00:20:54 UTC (rev 182823)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2015-04-15 00:26:23 UTC (rev 182824)
@@ -203,6 +203,26 @@
 }
 #endif
 
+#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+static CGSize dilationSizeForTextColor(const Color& color)
+{
+    double hue;
+    double saturation;
+    double lightness;
+    color.getHSL(hue, saturation, lightness);
+    
+    // These values were derived empirically, and are only experimental.
+    if (lightness < 0.3333) // Dark
+        return CGSizeMake(0.007, 0.019);
+
+    if (lightness < 0.6667) // Medium
+        return CGSizeMake(0.032, 0.032);
+
+    // Light
+    return CGSizeMake(0.0475, 0.039);
+}
+#endif
+
 void FontCascade::drawGlyphs(GraphicsContext* context, const Font* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& anchorPoint) const
 {
     const FontPlatformData& platformData = font->platformData();
@@ -257,7 +277,18 @@
         originalShouldUseFontSmoothing = CGContextGetShouldSmoothFonts(cgContext);
         CGContextSetShouldSmoothFonts(cgContext, shouldSmoothFonts);
     }
+    
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+    CGFontAntialiasingStyle oldAntialiasingStyle;
+    bool resetAntialiasingStyle = false;
+    if (antialiasedFontDilationEnabled() && !CGContextGetShouldSmoothFonts(cgContext) && matchAntialiasedAndSmoothedFonts) {
+        resetAntialiasingStyle = true;
+        oldAntialiasingStyle = CGContextGetFontAntialiasingStyle(cgContext);
+        CGContextSetFontAntialiasingStyle(cgContext, kCGFontAntialiasingStyleUnfilteredCustomDilation);
+        CGContextSetFontDilation(cgContext, dilationSizeForTextColor(context->fillColor()));
+    }
 #endif
+#endif
 
 #if !PLATFORM(IOS)
     NSFont* drawFont = [platformData.nsFont() printerFont];
@@ -374,6 +405,11 @@
         context->setShadow(shadowOffset, shadowBlur, shadowColor, shadowColorSpace);
 
 #if !PLATFORM(IOS)
+#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
+    if (resetAntialiasingStyle)
+        CGContextSetFontAntialiasingStyle(cgContext, oldAntialiasingStyle);
+#endif
+    
     if (changeFontSmoothing)
         CGContextSetShouldSmoothFonts(cgContext, originalShouldUseFontSmoothing);
 #endif

Modified: trunk/Source/WebKit/mac/ChangeLog (182823 => 182824)


--- trunk/Source/WebKit/mac/ChangeLog	2015-04-15 00:20:54 UTC (rev 182823)
+++ trunk/Source/WebKit/mac/ChangeLog	2015-04-15 00:26:23 UTC (rev 182824)
@@ -1,3 +1,24 @@
+2015-04-14  Simon Fraser  <simon.fra...@apple.com>
+
+        Re-enable custom dilation for antialiased fonts
+        https://bugs.webkit.org/show_bug.cgi?id=143738
+
+        Reviewed by Tim Horton.
+        
+        Enabling custom dilation for antialised fonts broke layout tests, so re-land it,
+        but disable in WebKitTestRunner and DumpRenderTree. The latter requires adding
+        a private WebKit pref. This pref defaults to YES, enabling the feature by default
+        in WK1 as we do for WK2.
+
+        * WebView/WebPreferenceKeysPrivate.h:
+        * WebView/WebPreferences.mm:
+        (+[WebPreferences initialize]):
+        (-[WebPreferences setAntialiasedFontDilationEnabled:]):
+        (-[WebPreferences antialiasedFontDilationEnabled]):
+        * WebView/WebPreferencesPrivate.h:
+        * WebView/WebView.mm:
+        (-[WebView _preferencesChanged:]):
+
 2015-04-13  Brady Eidson  <beid...@apple.com>
 
         Share sheets from Share menus appear outside the browser window.

Modified: trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h (182823 => 182824)


--- trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h	2015-04-15 00:20:54 UTC (rev 182823)
+++ trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h	2015-04-15 00:26:23 UTC (rev 182824)
@@ -159,6 +159,7 @@
 #define WebKitPDFDisplayModePreferenceKey @"WebKitPDFDisplayMode"
 #define WebKitPDFScaleFactorPreferenceKey @"WebKitPDFScaleFactor"
 #endif
+
 #define WebKitUseSiteSpecificSpoofingPreferenceKey @"WebKitUseSiteSpecificSpoofing"
 #define WebKitEditableLinkBehaviorPreferenceKey @"WebKitEditableLinkBehavior"
 #define WebKitCacheModelPreferenceKey @"WebKitCacheModelPreferenceKey"
@@ -167,10 +168,9 @@
 #define WebKitBackspaceKeyNavigationEnabledKey @"WebKitBackspaceKeyNavigationEnabled"
 #define WebKitIncrementalRenderingSuppressionTimeoutInSecondsKey @"WebKitIncrementalRenderingSuppressionTimeoutInSeconds"
 #define WebKitWantsBalancedSetDefersLoadingBehaviorKey @"WebKitWantsBalancedSetDefersLoadingBehavior"
-
 #define WebKitDebugFullPageZoomPreferenceKey @"WebKitDebugFullPageZoomPreferenceKey"
-
 #define WebKitMinimumZoomFontSizePreferenceKey @"WebKitMinimumZoomFontSizePreferenceKey"
+#define WebKitAntialiasedFontDilationEnabledKey @"AntialiasedFontDilationEnabled"
 
 #if TARGET_OS_IPHONE
 #define WebKitStandalonePreferenceKey @"WebKitStandalonePreferenceKey"

Modified: trunk/Source/WebKit/mac/WebView/WebPreferences.mm (182823 => 182824)


--- trunk/Source/WebKit/mac/WebView/WebPreferences.mm	2015-04-15 00:20:54 UTC (rev 182823)
+++ trunk/Source/WebKit/mac/WebView/WebPreferences.mm	2015-04-15 00:26:23 UTC (rev 182824)
@@ -417,6 +417,7 @@
         @"0",                           WebKitMinimumFontSizePreferenceKey,
         @"9",                           WebKitMinimumLogicalFontSizePreferenceKey, 
         @"16",                          WebKitDefaultFontSizePreferenceKey,
+        @(YES),                         WebKitAntialiasedFontDilationEnabledKey,
         @"13",                          WebKitDefaultFixedFontSizePreferenceKey,
         @"ISO-8859-1",                  WebKitDefaultTextEncodingNamePreferenceKey,
         [NSNumber numberWithBool:NO],   WebKitUsesEncodingDetectorPreferenceKey,
@@ -2483,6 +2484,16 @@
     [self _setStringValue:directory forKey:WebKitMediaKeysStorageDirectoryKey];
 }
 
+- (void)setAntialiasedFontDilationEnabled:(BOOL)enabled
+{
+    [self _setBoolValue:enabled forKey:WebKitAntialiasedFontDilationEnabledKey];
+}
+
+- (BOOL)antialiasedFontDilationEnabled
+{
+    return [self _boolValueForKey:WebKitAntialiasedFontDilationEnabledKey];
+}
+
 @end
 
 @implementation WebPreferences (WebInternal)

Modified: trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h (182823 => 182824)


--- trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h	2015-04-15 00:20:54 UTC (rev 182823)
+++ trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h	2015-04-15 00:26:23 UTC (rev 182824)
@@ -436,6 +436,9 @@
 - (void)setMediaKeysStorageDirectory:(NSString *)directory;
 - (NSString *)mediaKeysStorageDirectory;
 
+- (void)setAntialiasedFontDilationEnabled:(BOOL)flag;
+- (BOOL)antialiasedFontDilationEnabled;
+
 #if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
 - (void)_setAllowCompositingLayerVisualDegradation:(BOOL)flag;
 #endif

Modified: trunk/Source/WebKit/mac/WebView/WebView.mm (182823 => 182824)


--- trunk/Source/WebKit/mac/WebView/WebView.mm	2015-04-15 00:20:54 UTC (rev 182823)
+++ trunk/Source/WebKit/mac/WebView/WebView.mm	2015-04-15 00:26:23 UTC (rev 182824)
@@ -2212,6 +2212,7 @@
     settings.setUsesEncodingDetector([preferences usesEncodingDetector]);
     settings.setFantasyFontFamily([preferences fantasyFontFamily]);
     settings.setFixedFontFamily([preferences fixedFontFamily]);
+    settings.setAntialiasedFontDilationEnabled([preferences antialiasedFontDilationEnabled]);
     settings.setForceFTPDirectoryListings([preferences _forceFTPDirectoryListings]);
     settings.setFTPDirectoryTemplatePath([preferences _ftpDirectoryTemplatePath]);
     settings.setLocalStorageDatabasePath([preferences _localStorageDatabasePath]);
@@ -2259,8 +2260,6 @@
     settings.setXSSAuditorEnabled([preferences isXSSAuditorEnabled]);
     settings.setDNSPrefetchingEnabled([preferences isDNSPrefetchingEnabled]);
     
-    // FIXME: Enabling accelerated compositing when WebGL is enabled causes tests to fail on Leopard which expect HW compositing to be disabled.
-    // Until we fix that, I will comment out the test (CFM)
     settings.setAcceleratedCompositingEnabled([preferences acceleratedCompositingEnabled]);
     settings.setAcceleratedDrawingEnabled([preferences acceleratedDrawingEnabled]);
     settings.setCanvasUsesAcceleratedDrawing([preferences canvasUsesAcceleratedDrawing]);    

Modified: trunk/Tools/ChangeLog (182823 => 182824)


--- trunk/Tools/ChangeLog	2015-04-15 00:20:54 UTC (rev 182823)
+++ trunk/Tools/ChangeLog	2015-04-15 00:26:23 UTC (rev 182824)
@@ -1,3 +1,20 @@
+2015-04-14  Simon Fraser  <simon.fra...@apple.com>
+
+        Re-enable custom dilation for antialiased fonts
+        https://bugs.webkit.org/show_bug.cgi?id=143738
+
+        Reviewed by Tim Horton.
+        
+        Enabling custom dilation for antialised fonts broke layout tests, so re-land it,
+        but disable in WebKitTestRunner and DumpRenderTree. The latter requires adding
+        a private WebKit pref. This pref defaults to YES, enabling the feature by default
+        in WK1 as we do for WK2.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (resetWebPreferencesToConsistentValues):
+        * WebKitTestRunner/TestController.cpp:
+        (WTR::TestController::resetPreferencesToConsistentValues):
+
 2015-04-14  Brent Fulgham  <bfulg...@apple.com>
 
         Correct layering violation in DumpRenderTree Build

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (182823 => 182824)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2015-04-15 00:20:54 UTC (rev 182823)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2015-04-15 00:26:23 UTC (rev 182824)
@@ -856,6 +856,7 @@
     [preferences setPictographFontFamily:@"Apple Color Emoji"];
     [preferences setDefaultFontSize:16];
     [preferences setDefaultFixedFontSize:13];
+    [preferences setAntialiasedFontDilationEnabled:NO];
     [preferences setMinimumFontSize:0];
     [preferences setDefaultTextEncodingName:@"ISO-8859-1"];
     [preferences setJavaEnabled:NO];

Modified: trunk/Tools/WebKitTestRunner/TestController.cpp (182823 => 182824)


--- trunk/Tools/WebKitTestRunner/TestController.cpp	2015-04-15 00:20:54 UTC (rev 182823)
+++ trunk/Tools/WebKitTestRunner/TestController.cpp	2015-04-15 00:26:23 UTC (rev 182824)
@@ -560,6 +560,7 @@
     WKPreferencesResetTestRunnerOverrides(preferences);
     WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
     WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing);
+    WKPreferencesSetAntialiasedFontDilationEnabled(preferences, false);
     WKPreferencesSetXSSAuditorEnabled(preferences, false);
     WKPreferencesSetWebAudioEnabled(preferences, true);
     WKPreferencesSetMediaStreamEnabled(preferences, true);
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to