Title: [252622] trunk
Revision
252622
Author
[email protected]
Date
2019-11-18 19:38:09 -0800 (Mon, 18 Nov 2019)

Log Message

-webkit-font-smoothing: none leaves subsequent elements unantialiased
https://bugs.webkit.org/show_bug.cgi?id=204334

Reviewed by Myles C. Maxfield.

Source/WebCore:

FontCascade::drawGlyphs() never called context.setShouldAntialias(true) for the
FontSmoothingMode::AutoSmoothing state, leaving it off for later elements.

Fix this function to save and restore antialiasing and smoothing in similar ways, and rather
than handle FontSmoothingMode::AutoSmoothing as "do nothing and let the platform decide"
(which caused this bug), explicitly treat it as equivalent to
FontSmoothingMode::SubpixelAntialiased. Note that FontSmoothingMode::SubpixelAntialiased
does not render with subpixel antialiasing on macOS Mojave and later.

Test: fast/text/font-antialiasing-save-restore.html

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

LayoutTests:

* fast/text/font-antialiasing-save-restore-expected.html: Added.
* fast/text/font-antialiasing-save-restore.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (252621 => 252622)


--- trunk/LayoutTests/ChangeLog	2019-11-19 03:29:12 UTC (rev 252621)
+++ trunk/LayoutTests/ChangeLog	2019-11-19 03:38:09 UTC (rev 252622)
@@ -1,3 +1,13 @@
+2019-11-18  Simon Fraser  <[email protected]>
+
+        -webkit-font-smoothing: none leaves subsequent elements unantialiased
+        https://bugs.webkit.org/show_bug.cgi?id=204334
+
+        Reviewed by Myles C. Maxfield.
+
+        * fast/text/font-antialiasing-save-restore-expected.html: Added.
+        * fast/text/font-antialiasing-save-restore.html: Added.
+
 2019-11-18  Devin Rousso  <[email protected]>
 
         Web Inspector: Local Resource Overrides: allow substitution based on a url pattern

Added: trunk/LayoutTests/fast/text/font-antialiasing-save-restore-expected.html (0 => 252622)


--- trunk/LayoutTests/fast/text/font-antialiasing-save-restore-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/font-antialiasing-save-restore-expected.html	2019-11-19 03:38:09 UTC (rev 252622)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        p {
+            font-size: 16pt;
+        }
+    </style>
+</head>
+<body>
+    <p style="-webkit-font-smoothing: none">This should not be antialiased<p>
+    <p>This should be antialiased<p>
+</body>
+</html>

Added: trunk/LayoutTests/fast/text/font-antialiasing-save-restore.html (0 => 252622)


--- trunk/LayoutTests/fast/text/font-antialiasing-save-restore.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/font-antialiasing-save-restore.html	2019-11-19 03:38:09 UTC (rev 252622)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+    <style>
+        p {
+            font-size: 16pt;
+        }
+    </style>
+</head>
+<body>
+    <p style="-webkit-font-smoothing: none">This should not be antialiased<p>
+    <p style="-webkit-font-smoothing: subpixel-antialiased">This should be antialiased<p>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (252621 => 252622)


--- trunk/Source/WebCore/ChangeLog	2019-11-19 03:29:12 UTC (rev 252621)
+++ trunk/Source/WebCore/ChangeLog	2019-11-19 03:38:09 UTC (rev 252622)
@@ -1,3 +1,24 @@
+2019-11-18  Simon Fraser  <[email protected]>
+
+        -webkit-font-smoothing: none leaves subsequent elements unantialiased
+        https://bugs.webkit.org/show_bug.cgi?id=204334
+
+        Reviewed by Myles C. Maxfield.
+
+        FontCascade::drawGlyphs() never called context.setShouldAntialias(true) for the
+        FontSmoothingMode::AutoSmoothing state, leaving it off for later elements.
+
+        Fix this function to save and restore antialiasing and smoothing in similar ways, and rather
+        than handle FontSmoothingMode::AutoSmoothing as "do nothing and let the platform decide"
+        (which caused this bug), explicitly treat it as equivalent to
+        FontSmoothingMode::SubpixelAntialiased. Note that FontSmoothingMode::SubpixelAntialiased
+        does not render with subpixel antialiasing on macOS Mojave and later.
+
+        Test: fast/text/font-antialiasing-save-restore.html
+
+        * platform/graphics/cocoa/FontCascadeCocoa.mm:
+        (WebCore::FontCascade::drawGlyphs):
+
 2019-11-18  Zalan Bujtas  <[email protected]>
 
         Flex layout triggers excessive layout on height percentage descendants

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


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2019-11-19 03:29:12 UTC (rev 252621)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2019-11-19 03:38:09 UTC (rev 252622)
@@ -206,48 +206,36 @@
 
     CGContextRef cgContext = context.platformContext();
 
-    bool shouldSmoothFonts;
-    bool changeFontSmoothing;
+    bool shouldAntialias = true;
+    bool shouldSmoothFonts = true;
     
     switch (smoothingMode) {
-    case FontSmoothingMode::Antialiased: {
-        context.setShouldAntialias(true);
+    case FontSmoothingMode::Antialiased:
         shouldSmoothFonts = false;
-        changeFontSmoothing = true;
         break;
-    }
-    case FontSmoothingMode::SubpixelAntialiased: {
-        context.setShouldAntialias(true);
-        shouldSmoothFonts = true;
-        changeFontSmoothing = true;
+    case FontSmoothingMode::AutoSmoothing:
+    case FontSmoothingMode::SubpixelAntialiased:
+        shouldAntialias = true;
         break;
-    }
-    case FontSmoothingMode::NoSmoothing: {
-        context.setShouldAntialias(false);
+    case FontSmoothingMode::NoSmoothing:
+        shouldAntialias = false;
         shouldSmoothFonts = false;
-        changeFontSmoothing = true;
         break;
     }
-    case FontSmoothingMode::AutoSmoothing: {
-        shouldSmoothFonts = true;
-        changeFontSmoothing = false;
-        break;
-    }
-    }
-    
-    if (!shouldUseSmoothing()) {
+
+    if (!shouldUseSmoothing())
         shouldSmoothFonts = false;
-        changeFontSmoothing = true;
-    }
 
 #if !PLATFORM(IOS_FAMILY)
-    bool originalShouldUseFontSmoothing = false;
-    if (changeFontSmoothing) {
-        originalShouldUseFontSmoothing = CGContextGetShouldSmoothFonts(cgContext);
+    bool originalShouldUseFontSmoothing = CGContextGetShouldSmoothFonts(cgContext);
+    if (shouldSmoothFonts != originalShouldUseFontSmoothing)
         CGContextSetShouldSmoothFonts(cgContext, shouldSmoothFonts);
-    }
 #endif
 
+    bool originalShouldAntialias = CGContextGetShouldAntialias(cgContext);
+    if (shouldAntialias != originalShouldAntialias)
+        CGContextSetShouldAntialias(cgContext, shouldAntialias);
+
     bool useLetterpressEffect = shouldUseLetterpressEffect(context);
     FloatPoint point = anchorPoint;
 
@@ -271,7 +259,6 @@
     setCGFontRenderingMode(context);
     CGContextSetFontSize(cgContext, platformData.size());
 
-
     FloatSize shadowOffset;
     float shadowBlur;
     Color shadowColor;
@@ -315,9 +302,12 @@
         context.setShadow(shadowOffset, shadowBlur, shadowColor);
 
 #if !PLATFORM(IOS_FAMILY)
-    if (changeFontSmoothing)
+    if (shouldSmoothFonts != originalShouldUseFontSmoothing)
         CGContextSetShouldSmoothFonts(cgContext, originalShouldUseFontSmoothing);
 #endif
+
+    if (shouldAntialias != originalShouldAntialias)
+        CGContextSetShouldAntialias(cgContext, originalShouldAntialias);
 }
 
 bool FontCascade::primaryFontIsSystemFont() const
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to