Changeset 182824 in webkit


Ignore:
Timestamp:
Apr 14, 2015, 5:26:23 PM (11 years ago)
Author:
Simon Fraser
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):

Location:
trunk
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r182823 r182824  
     12015-04-14  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Re-enable custom dilation for antialiased fonts
     4        https://bugs.webkit.org/show_bug.cgi?id=143738
     5
     6        Reviewed by Tim Horton.
     7       
     8        Enabling custom dilation for antialised fonts broke layout tests, so re-land it,
     9        but disable in WebKitTestRunner and DumpRenderTree. The latter requires adding
     10        a private WebKit pref. This pref defaults to YES, enabling the feature by default
     11        in WK1 as we do for WK2.
     12
     13        * platform/graphics/cocoa/FontCascadeCocoa.mm:
     14        (WebCore::dilationSizeForTextColor):
     15        (WebCore::FontCascade::drawGlyphs):
     16
    1172015-04-14  Andy Estes  <aestes@apple.com>
    218
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm

    r182605 r182824  
    204204#endif
    205205
     206#if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
     207static CGSize dilationSizeForTextColor(const Color& color)
     208{
     209    double hue;
     210    double saturation;
     211    double lightness;
     212    color.getHSL(hue, saturation, lightness);
     213   
     214    // These values were derived empirically, and are only experimental.
     215    if (lightness < 0.3333) // Dark
     216        return CGSizeMake(0.007, 0.019);
     217
     218    if (lightness < 0.6667) // Medium
     219        return CGSizeMake(0.032, 0.032);
     220
     221    // Light
     222    return CGSizeMake(0.0475, 0.039);
     223}
     224#endif
     225
    206226void FontCascade::drawGlyphs(GraphicsContext* context, const Font* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& anchorPoint) const
    207227{
     
    258278        CGContextSetShouldSmoothFonts(cgContext, shouldSmoothFonts);
    259279    }
     280   
     281#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
     282    CGFontAntialiasingStyle oldAntialiasingStyle;
     283    bool resetAntialiasingStyle = false;
     284    if (antialiasedFontDilationEnabled() && !CGContextGetShouldSmoothFonts(cgContext) && matchAntialiasedAndSmoothedFonts) {
     285        resetAntialiasingStyle = true;
     286        oldAntialiasingStyle = CGContextGetFontAntialiasingStyle(cgContext);
     287        CGContextSetFontAntialiasingStyle(cgContext, kCGFontAntialiasingStyleUnfilteredCustomDilation);
     288        CGContextSetFontDilation(cgContext, dilationSizeForTextColor(context->fillColor()));
     289    }
     290#endif
    260291#endif
    261292
     
    375406
    376407#if !PLATFORM(IOS)
     408#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101100
     409    if (resetAntialiasingStyle)
     410        CGContextSetFontAntialiasingStyle(cgContext, oldAntialiasingStyle);
     411#endif
     412   
    377413    if (changeFontSmoothing)
    378414        CGContextSetShouldSmoothFonts(cgContext, originalShouldUseFontSmoothing);
  • trunk/Source/WebKit/mac/ChangeLog

    r182756 r182824  
     12015-04-14  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Re-enable custom dilation for antialiased fonts
     4        https://bugs.webkit.org/show_bug.cgi?id=143738
     5
     6        Reviewed by Tim Horton.
     7       
     8        Enabling custom dilation for antialised fonts broke layout tests, so re-land it,
     9        but disable in WebKitTestRunner and DumpRenderTree. The latter requires adding
     10        a private WebKit pref. This pref defaults to YES, enabling the feature by default
     11        in WK1 as we do for WK2.
     12
     13        * WebView/WebPreferenceKeysPrivate.h:
     14        * WebView/WebPreferences.mm:
     15        (+[WebPreferences initialize]):
     16        (-[WebPreferences setAntialiasedFontDilationEnabled:]):
     17        (-[WebPreferences antialiasedFontDilationEnabled]):
     18        * WebView/WebPreferencesPrivate.h:
     19        * WebView/WebView.mm:
     20        (-[WebView _preferencesChanged:]):
     21
    1222015-04-13  Brady Eidson  <beidson@apple.com>
    223
  • trunk/Source/WebKit/mac/WebView/WebPreferenceKeysPrivate.h

    r180570 r182824  
    160160#define WebKitPDFScaleFactorPreferenceKey @"WebKitPDFScaleFactor"
    161161#endif
     162
    162163#define WebKitUseSiteSpecificSpoofingPreferenceKey @"WebKitUseSiteSpecificSpoofing"
    163164#define WebKitEditableLinkBehaviorPreferenceKey @"WebKitEditableLinkBehavior"
     
    168169#define WebKitIncrementalRenderingSuppressionTimeoutInSecondsKey @"WebKitIncrementalRenderingSuppressionTimeoutInSeconds"
    169170#define WebKitWantsBalancedSetDefersLoadingBehaviorKey @"WebKitWantsBalancedSetDefersLoadingBehavior"
    170 
    171171#define WebKitDebugFullPageZoomPreferenceKey @"WebKitDebugFullPageZoomPreferenceKey"
    172 
    173172#define WebKitMinimumZoomFontSizePreferenceKey @"WebKitMinimumZoomFontSizePreferenceKey"
     173#define WebKitAntialiasedFontDilationEnabledKey @"AntialiasedFontDilationEnabled"
    174174
    175175#if TARGET_OS_IPHONE
  • trunk/Source/WebKit/mac/WebView/WebPreferences.mm

    r182623 r182824  
    418418        @"9",                           WebKitMinimumLogicalFontSizePreferenceKey,
    419419        @"16",                          WebKitDefaultFontSizePreferenceKey,
     420        @(YES),                         WebKitAntialiasedFontDilationEnabledKey,
    420421        @"13",                          WebKitDefaultFixedFontSizePreferenceKey,
    421422        @"ISO-8859-1",                  WebKitDefaultTextEncodingNamePreferenceKey,
     
    24842485}
    24852486
     2487- (void)setAntialiasedFontDilationEnabled:(BOOL)enabled
     2488{
     2489    [self _setBoolValue:enabled forKey:WebKitAntialiasedFontDilationEnabledKey];
     2490}
     2491
     2492- (BOOL)antialiasedFontDilationEnabled
     2493{
     2494    return [self _boolValueForKey:WebKitAntialiasedFontDilationEnabledKey];
     2495}
     2496
    24862497@end
    24872498
  • trunk/Source/WebKit/mac/WebView/WebPreferencesPrivate.h

    r182653 r182824  
    437437- (NSString *)mediaKeysStorageDirectory;
    438438
     439- (void)setAntialiasedFontDilationEnabled:(BOOL)flag;
     440- (BOOL)antialiasedFontDilationEnabled;
     441
    439442#if TARGET_OS_IPHONE && __IPHONE_OS_VERSION_MIN_REQUIRED < 80000
    440443- (void)_setAllowCompositingLayerVisualDegradation:(BOOL)flag;
  • trunk/Source/WebKit/mac/WebView/WebView.mm

    r182623 r182824  
    22132213    settings.setFantasyFontFamily([preferences fantasyFontFamily]);
    22142214    settings.setFixedFontFamily([preferences fixedFontFamily]);
     2215    settings.setAntialiasedFontDilationEnabled([preferences antialiasedFontDilationEnabled]);
    22152216    settings.setForceFTPDirectoryListings([preferences _forceFTPDirectoryListings]);
    22162217    settings.setFTPDirectoryTemplatePath([preferences _ftpDirectoryTemplatePath]);
     
    22602261    settings.setDNSPrefetchingEnabled([preferences isDNSPrefetchingEnabled]);
    22612262   
    2262     // FIXME: Enabling accelerated compositing when WebGL is enabled causes tests to fail on Leopard which expect HW compositing to be disabled.
    2263     // Until we fix that, I will comment out the test (CFM)
    22642263    settings.setAcceleratedCompositingEnabled([preferences acceleratedCompositingEnabled]);
    22652264    settings.setAcceleratedDrawingEnabled([preferences acceleratedDrawingEnabled]);
  • trunk/Tools/ChangeLog

    r182821 r182824  
     12015-04-14  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Re-enable custom dilation for antialiased fonts
     4        https://bugs.webkit.org/show_bug.cgi?id=143738
     5
     6        Reviewed by Tim Horton.
     7       
     8        Enabling custom dilation for antialised fonts broke layout tests, so re-land it,
     9        but disable in WebKitTestRunner and DumpRenderTree. The latter requires adding
     10        a private WebKit pref. This pref defaults to YES, enabling the feature by default
     11        in WK1 as we do for WK2.
     12
     13        * DumpRenderTree/mac/DumpRenderTree.mm:
     14        (resetWebPreferencesToConsistentValues):
     15        * WebKitTestRunner/TestController.cpp:
     16        (WTR::TestController::resetPreferencesToConsistentValues):
     17
    1182015-04-14  Brent Fulgham  <bfulgham@apple.com>
    219
  • trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm

    r182666 r182824  
    857857    [preferences setDefaultFontSize:16];
    858858    [preferences setDefaultFixedFontSize:13];
     859    [preferences setAntialiasedFontDilationEnabled:NO];
    859860    [preferences setMinimumFontSize:0];
    860861    [preferences setDefaultTextEncodingName:@"ISO-8859-1"];
  • trunk/Tools/WebKitTestRunner/TestController.cpp

    r182428 r182824  
    561561    WKPreferencesSetOfflineWebApplicationCacheEnabled(preferences, true);
    562562    WKPreferencesSetFontSmoothingLevel(preferences, kWKFontSmoothingLevelNoSubpixelAntiAliasing);
     563    WKPreferencesSetAntialiasedFontDilationEnabled(preferences, false);
    563564    WKPreferencesSetXSSAuditorEnabled(preferences, false);
    564565    WKPreferencesSetWebAudioEnabled(preferences, true);
Note: See TracChangeset for help on using the changeset viewer.