WebCore: Fix for <rdar://problem/7083741> Implement a CSS extension to
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Sep 2009 22:08:20 +0000 (22:08 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 16 Sep 2009 22:08:20 +0000 (22:08 +0000)
adjust sub-pixel anti-aliasing for text
-and corresponding-
https://bugs.webkit.org/show_bug.cgi?id=29291

Reviewed by Darin Adler.

Added tests:
* fast/css/font-smoothing.html: Added.
* fast/css/parsing-webkit-font-smoothing.html: Added.

This patch adds a new CSS property called -webkit-font-smoothing
that accepts the following as valid input: auto | none |
antialiased | subpixel-antialiased

Return appropriate computed style for -webkit-font-smoothing
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::):
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):

Add a case for CSSPropertyWebkitFontSmoothing, and accept valid
input.
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):

Add mappings for FontSmoothing to the right CSS values.
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator FontSmoothing):

Add -webkit-font-smoothing
* css/CSSPropertyNames.in:

Set fontSmoothing on the FontDescription.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyProperty):

Add antialiased and subpixel-antialiased as possible new CSS
values.
* css/CSSValueKeywords.in:
Store the font smoothing CSS value in the FontDescription.
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::FontDescription):
(WebCore::FontDescription::fontSmoothing):
(WebCore::FontDescription::setFontSmoothing):
(WebCore::FontDescription::operator==):

Call setShouldAntialias() and setShouldUseSmoothing() appropriately
based on the CSS fontSmoothing() value.
* platform/graphics/mac/FontMac.mm:
(WebCore::Font::drawGlyphs):
* platform/graphics/win/FontCGWin.cpp:
(WebCore::Font::drawGlyphs):

New function fontSmoothing()
* rendering/style/RenderStyle.h:
(WebCore::InheritedFlags::fontSmoothing):

New enum FontSmoothing.
* rendering/style/RenderStyleConstants.h:
(WebCore::):

LayoutTests: Tests for <rdar://problem/7083741> Implement a CSS extension to
adjust sub-pixel anti-aliasing for text

Reviewed by Darin Adler.

New tests:
* fast/css/font-smoothing.html: Added.
* fast/css/parsing-webkit-font-smoothing-expected.txt: Added.
* fast/css/parsing-webkit-font-smoothing.html: Added.
* fast/css/resources/parsing-webkit-font-smoothing.js: Added.
(test):
* platform/mac/fast/css/font-smoothing-expected.checksum: Added.
* platform/mac/fast/css/font-smoothing-expected.png: Added.
* platform/mac/fast/css/font-smoothing-expected.txt: Added.

These tests have updated results now that -webkit-font-smoothing is
reported with computed style.
* platform/mac/fast/css/getComputedStyle/computed-style-expected.txt:
* platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
* svg/css/getComputedStyle-basic-expected.txt:

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

23 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/font-smoothing.html [new file with mode: 0644]
LayoutTests/fast/css/parsing-webkit-font-smoothing-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/parsing-webkit-font-smoothing.html [new file with mode: 0644]
LayoutTests/fast/css/resources/parsing-webkit-font-smoothing.js [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/font-smoothing-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/font-smoothing-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/font-smoothing-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-expected.txt
LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
LayoutTests/svg/css/getComputedStyle-basic-expected.txt
WebCore/ChangeLog
WebCore/css/CSSComputedStyleDeclaration.cpp
WebCore/css/CSSParser.cpp
WebCore/css/CSSPrimitiveValueMappings.h
WebCore/css/CSSPropertyNames.in
WebCore/css/CSSStyleSelector.cpp
WebCore/css/CSSValueKeywords.in
WebCore/platform/graphics/FontDescription.h
WebCore/platform/graphics/mac/FontMac.mm
WebCore/platform/graphics/win/FontCGWin.cpp
WebCore/rendering/style/RenderStyle.h
WebCore/rendering/style/RenderStyleConstants.h

index 9104eac..d4a8b8f 100644 (file)
@@ -1,3 +1,26 @@
+2009-09-16  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Tests for <rdar://problem/7083741> Implement a CSS extension to 
+        adjust sub-pixel anti-aliasing for text
+
+        New tests:
+        * fast/css/font-smoothing.html: Added.
+        * fast/css/parsing-webkit-font-smoothing-expected.txt: Added.
+        * fast/css/parsing-webkit-font-smoothing.html: Added.
+        * fast/css/resources/parsing-webkit-font-smoothing.js: Added.
+        (test):
+        * platform/mac/fast/css/font-smoothing-expected.checksum: Added.
+        * platform/mac/fast/css/font-smoothing-expected.png: Added.
+        * platform/mac/fast/css/font-smoothing-expected.txt: Added.
+
+        These tests have updated results now that -webkit-font-smoothing is 
+        reported with computed style.
+        * platform/mac/fast/css/getComputedStyle/computed-style-expected.txt:
+        * platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
+        * svg/css/getComputedStyle-basic-expected.txt:
+
 2009-09-16  Yury Semikhatsky  <yurys@chromium.org>
 
         Reviewed by Timothy Hatcher.
diff --git a/LayoutTests/fast/css/font-smoothing.html b/LayoutTests/fast/css/font-smoothing.html
new file mode 100644 (file)
index 0000000..925b03c
--- /dev/null
@@ -0,0 +1,10 @@
+<span style="font-size:20px">Hello. This is absolutely regular text.</span>
+<br>
+<span style="font-size:20px; -webkit-font-smoothing:auto;">Hello. This is text with -webkit-font-smoothing:auto. It should look like absolutely regular text.</span>
+<br>
+<span style="font-size:20px; -webkit-font-smoothing:none;">Hello. This is text with -webkit-font-smoothing:none.</span>
+<br>
+<span style="font-size:20px; -webkit-font-smoothing:antialiased">Hello. This is text with -webkit-font-smoothing:antialiased.</span>
+<br>
+<span style="font-size:20px; -webkit-font-smoothing:subpixel-antialiased;">Hello. This is text with -webkit-font-smoothing:subpixel-antialiased. It should look like absolutely regular text.</span>
+<br>
diff --git a/LayoutTests/fast/css/parsing-webkit-font-smoothing-expected.txt b/LayoutTests/fast/css/parsing-webkit-font-smoothing-expected.txt
new file mode 100644 (file)
index 0000000..8e9c914
--- /dev/null
@@ -0,0 +1,16 @@
+This tests checks that all of the input values for -webkit-font-smoothing parse correctly.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS test("-webkit-font-smoothing: auto;") is "auto"
+PASS test("-webkit-font-smoothing: none;") is "none"
+PASS test("-webkit-font-smoothing: antialiased;") is "antialiased"
+PASS test("-webkit-font-smoothing: subpixel-antialiased;") is "subpixel-antialiased"
+PASS test("-webkit-font-smoothing: apple;") is null
+PASS test("-webkit-font-smoothing: 15;") is null
+PASS test("-webkit-font-smoothing: auto auto;") is null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/parsing-webkit-font-smoothing.html b/LayoutTests/fast/css/parsing-webkit-font-smoothing.html
new file mode 100644 (file)
index 0000000..95862bf
--- /dev/null
@@ -0,0 +1,14 @@
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html>
+<head>
+<style type="text/css"></style>
+<link rel="stylesheet" href="../js/resources/js-test-style.css">
+<script src="../js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<p id="description"></p>
+<div id="console"></div>
+<script src="resources/parsing-webkit-font-smoothing.js"></script>
+<script src="../js/resources/js-test-post.js"></script>
+</body>
+</html>
diff --git a/LayoutTests/fast/css/resources/parsing-webkit-font-smoothing.js b/LayoutTests/fast/css/resources/parsing-webkit-font-smoothing.js
new file mode 100644 (file)
index 0000000..01a3d5f
--- /dev/null
@@ -0,0 +1,23 @@
+description("This tests checks that all of the input values for -webkit-font-smoothing parse correctly.");
+
+function test(value)
+{
+    var span = document.createElement("span");
+    span.setAttribute("style", value);
+    document.body.appendChild(span);
+    
+    var result = span.style.getPropertyValue("-webkit-font-smoothing");
+    document.body.removeChild(span);
+    return result;
+}
+
+shouldBe('test("-webkit-font-smoothing: auto;")', '"auto"');
+shouldBe('test("-webkit-font-smoothing: none;")', '"none"');
+shouldBe('test("-webkit-font-smoothing: antialiased;")', '"antialiased"');
+shouldBe('test("-webkit-font-smoothing: subpixel-antialiased;")', '"subpixel-antialiased"');
+
+shouldBe('test("-webkit-font-smoothing: apple;")', 'null');
+shouldBe('test("-webkit-font-smoothing: 15;")', 'null');
+shouldBe('test("-webkit-font-smoothing: auto auto;")', 'null');
+
+var successfullyParsed = true;
diff --git a/LayoutTests/platform/mac/fast/css/font-smoothing-expected.checksum b/LayoutTests/platform/mac/fast/css/font-smoothing-expected.checksum
new file mode 100644 (file)
index 0000000..3d5badc
--- /dev/null
@@ -0,0 +1 @@
+62e66d05f8ed400283caefb669f6a769
\ No newline at end of file
diff --git a/LayoutTests/platform/mac/fast/css/font-smoothing-expected.png b/LayoutTests/platform/mac/fast/css/font-smoothing-expected.png
new file mode 100644 (file)
index 0000000..b45d8e7
Binary files /dev/null and b/LayoutTests/platform/mac/fast/css/font-smoothing-expected.png differ
diff --git a/LayoutTests/platform/mac/fast/css/font-smoothing-expected.txt b/LayoutTests/platform/mac/fast/css/font-smoothing-expected.txt
new file mode 100644 (file)
index 0000000..82c8905
--- /dev/null
@@ -0,0 +1,36 @@
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderInline {SPAN} at (0,0) size 303x23
+        RenderText {#text} at (0,0) size 303x23
+          text run at (0,0) width 303: "Hello. This is absolutely regular text."
+      RenderText {#text} at (303,4) size 4x18
+        text run at (303,4) width 4: " "
+      RenderBR {BR} at (307,18) size 0x0
+      RenderInline {SPAN} at (0,0) size 780x23
+        RenderText {#text} at (0,23) size 780x23
+          text run at (0,23) width 780: "Hello. This is text with -webkit-font-smoothing:auto. It should look like absolutely regular text."
+      RenderText {#text} at (780,27) size 4x18
+        text run at (780,27) width 4: " "
+      RenderBR {BR} at (784,41) size 0x0
+      RenderInline {SPAN} at (0,0) size 437x23
+        RenderText {#text} at (0,46) size 437x23
+          text run at (0,46) width 437: "Hello. This is text with -webkit-font-smoothing:none."
+      RenderText {#text} at (437,50) size 4x18
+        text run at (437,50) width 4: " "
+      RenderBR {BR} at (441,64) size 0x0
+      RenderInline {SPAN} at (0,0) size 486x23
+        RenderText {#text} at (0,69) size 486x23
+          text run at (0,69) width 486: "Hello. This is text with -webkit-font-smoothing:antialiased."
+      RenderText {#text} at (486,73) size 4x18
+        text run at (486,73) width 4: " "
+      RenderBR {BR} at (490,87) size 0x0
+      RenderInline {SPAN} at (0,0) size 716x46
+        RenderText {#text} at (0,92) size 716x46
+          text run at (0,92) width 716: "Hello. This is text with -webkit-font-smoothing:subpixel-antialiased. It should look like"
+          text run at (0,115) width 188: "absolutely regular text."
+      RenderText {#text} at (188,119) size 4x18
+        text run at (188,119) width 4: " "
+      RenderBR {BR} at (192,133) size 0x0
index 8a6a4da..25da2ce 100644 (file)
@@ -129,6 +129,7 @@ zoom: 1;
 -webkit-column-rule-width: 0px;
 -webkit-column-width: auto;
 -webkit-dashboard-region: null;
+-webkit-font-smoothing: auto;
 -webkit-highlight: none;
 -webkit-line-break: normal;
 -webkit-line-clamp: none;
index 9f3de73..c01c7f9 100644 (file)
@@ -128,6 +128,7 @@ Computed style of an element whose parent's 'display' value is 'none':
     -webkit-column-rule-width: 0px
     -webkit-column-width: auto
     -webkit-dashboard-region: null
+    -webkit-font-smoothing: auto
     -webkit-highlight: none
     -webkit-line-break: normal
     -webkit-line-clamp: none
index ea0380c..59b7be2 100644 (file)
@@ -256,6 +256,8 @@ rect: style.getPropertyValue(-webkit-column-width) : auto
 rect: style.getPropertyCSSValue(-webkit-column-width) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-dashboard-region) : null
 rect: style.getPropertyCSSValue(-webkit-dashboard-region) : [object CSSPrimitiveValue]
+rect: style.getPropertyValue(-webkit-font-smoothing) : auto
+rect: style.getPropertyCSSValue(-webkit-font-smoothing) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-highlight) : none
 rect: style.getPropertyCSSValue(-webkit-highlight) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(-webkit-line-break) : normal
@@ -662,6 +664,8 @@ g: style.getPropertyValue(-webkit-column-width) : auto
 g: style.getPropertyCSSValue(-webkit-column-width) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-dashboard-region) : null
 g: style.getPropertyCSSValue(-webkit-dashboard-region) : [object CSSPrimitiveValue]
+g: style.getPropertyValue(-webkit-font-smoothing) : auto
+g: style.getPropertyCSSValue(-webkit-font-smoothing) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-highlight) : none
 g: style.getPropertyCSSValue(-webkit-highlight) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(-webkit-line-break) : normal
index d0c5872..a06e940 100644 (file)
@@ -1,3 +1,67 @@
+2009-09-16  Beth Dakin  <bdakin@apple.com>
+
+        Reviewed by Darin Adler.
+
+        Fix for <rdar://problem/7083741> Implement a CSS extension to 
+        adjust sub-pixel anti-aliasing for text
+        -and corresponding-
+        https://bugs.webkit.org/show_bug.cgi?id=29291
+
+        Added tests:
+        * fast/css/font-smoothing.html: Added.
+        * fast/css/parsing-webkit-font-smoothing.html: Added.
+
+        This patch adds a new CSS property called -webkit-font-smoothing 
+        that accepts the following as valid input: auto | none | 
+        antialiased | subpixel-antialiased
+
+        Return appropriate computed style for -webkit-font-smoothing
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::):
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
+
+        Add a case for CSSPropertyWebkitFontSmoothing, and accept valid 
+        input.
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+
+        Add mappings for FontSmoothing to the right CSS values.
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator FontSmoothing):
+
+        Add -webkit-font-smoothing
+        * css/CSSPropertyNames.in:
+
+        Set fontSmoothing on the FontDescription.
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyProperty):
+
+        Add antialiased and subpixel-antialiased as possible new CSS 
+        values.
+        * css/CSSValueKeywords.in:
+        Store the font smoothing CSS value in the FontDescription.
+        * platform/graphics/FontDescription.h:
+        (WebCore::FontDescription::FontDescription):
+        (WebCore::FontDescription::fontSmoothing):
+        (WebCore::FontDescription::setFontSmoothing):
+        (WebCore::FontDescription::operator==):
+
+        Call setShouldAntialias() and setShouldUseSmoothing() appropriately 
+        based on the CSS fontSmoothing() value.
+        * platform/graphics/mac/FontMac.mm:
+        (WebCore::Font::drawGlyphs):
+        * platform/graphics/win/FontCGWin.cpp:
+        (WebCore::Font::drawGlyphs):
+
+        New function fontSmoothing()
+        * rendering/style/RenderStyle.h:
+        (WebCore::InheritedFlags::fontSmoothing):
+
+        New enum FontSmoothing.
+        * rendering/style/RenderStyleConstants.h:
+        (WebCore::):
+
 2009-09-16  Albert J. Wong  <ajwong@chromium.org>
 
         Reviewed by David Levin.
index 8e55baa..debd396 100644 (file)
@@ -183,6 +183,7 @@ static const int computedProperties[] = {
 #if ENABLE(DASHBOARD_SUPPORT)
     CSSPropertyWebkitDashboardRegion,
 #endif
+    CSSPropertyWebkitFontSmoothing,
     CSSPropertyWebkitHighlight,
     CSSPropertyWebkitLineBreak,
     CSSPropertyWebkitLineClamp,
@@ -1120,6 +1121,8 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             return CSSPrimitiveValue::create(style->matchNearestMailBlockquoteColor());
         case CSSPropertyResize:
             return CSSPrimitiveValue::create(style->resize());
+        case CSSPropertyWebkitFontSmoothing:
+            return CSSPrimitiveValue::create(style->fontSmoothing());
         case CSSPropertyZIndex:
             if (style->hasAutoZIndex())
                 return CSSPrimitiveValue::createIdentifier(CSSValueAuto);
index 1a66a11..aa2be59 100644 (file)
@@ -1523,6 +1523,12 @@ bool CSSParser::parseValue(int propId, bool important)
             valid_primitive = true;
         break;
 
+    case CSSPropertyWebkitFontSmoothing:
+        if (id == CSSValueAuto || id == CSSValueNone 
+            || id == CSSValueAntialiased || id == CSSValueSubpixelAntialiased)
+            valid_primitive = true;
+        break;
+
 #if ENABLE(DASHBOARD_SUPPORT)
     case CSSPropertyWebkitDashboardRegion:                 // <dashboard-region> | <dashboard-region> 
         if (value->unit == CSSParserValue::Function || id == CSSValueNone)
index f8be75a..70b21c4 100644 (file)
@@ -1798,6 +1798,45 @@ template<> inline CSSPrimitiveValue::operator EPointerEvents() const
     }
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmoothing smoothing)
+    : m_type(CSS_IDENT)
+{
+    switch (smoothing) {
+    case AutoSmoothing:
+        m_value.ident = CSSValueAuto;
+        return;
+    case NoSmoothing:
+        m_value.ident = CSSValueNone;
+        return;
+    case Antialiased:
+        m_value.ident = CSSValueAntialiased;
+        return;
+    case SubpixelAntialiased:
+        m_value.ident = CSSValueSubpixelAntialiased;
+        return;
+    }
+    
+    ASSERT_NOT_REACHED();
+    m_value.ident = CSSValueAuto;
+}
+
+template<> inline CSSPrimitiveValue::operator FontSmoothing() const
+{
+    switch (m_value.ident) {
+    case CSSValueAuto:
+        return AutoSmoothing;
+    case CSSValueNone:
+        return NoSmoothing;
+    case CSSValueAntialiased:
+        return Antialiased;
+    case CSSValueSubpixelAntialiased:
+        return SubpixelAntialiased;
+    }
+    
+    ASSERT_NOT_REACHED();
+    return AutoSmoothing;
+}
+
 #if ENABLE(SVG)
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(LineCap e)
index 8cda7b8..1bf526b 100644 (file)
@@ -192,6 +192,7 @@ zoom
 -webkit-column-width
 -webkit-columns
 -webkit-font-size-delta
+-webkit-font-smoothing
 -webkit-highlight
 -webkit-line-break
 -webkit-line-clamp
index 6ba3557..f80769c 100644 (file)
@@ -3495,6 +3495,38 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         return;
     }
 
+    case CSSPropertyWebkitFontSmoothing: {
+        FontDescription fontDescription = m_style->fontDescription();
+        if (isInherit) 
+            fontDescription.setFontSmoothing(m_parentStyle->fontSmoothing());
+        else if (isInitial)
+            fontDescription.setFontSmoothing(AutoSmoothing);
+        else {
+            if (!primitiveValue)
+                return;
+            int id = primitiveValue->getIdent();
+            FontSmoothing smoothing;
+            switch (id) {
+                case CSSValueAuto:
+                    smoothing = AutoSmoothing;
+                    break;
+                case CSSValueNone:
+                    smoothing = NoSmoothing;
+                    break;
+                case CSSValueAntialiased:
+                    smoothing = Antialiased;
+                    break;
+                case CSSValueSubpixelAntialiased:
+                    smoothing = SubpixelAntialiased;
+                    break;
+            }
+            fontDescription.setFontSmoothing(smoothing);
+        }
+        if (m_style->setFontDescription(fontDescription))
+            m_fontDirty = true;
+        return;
+    }
+
     case CSSPropertyLetterSpacing:
     case CSSPropertyWordSpacing:
     {
index 824ba5d..791f425 100644 (file)
@@ -623,3 +623,11 @@ fill
 stroke
 #all
 #none
+
+#
+# -webkit-font-smoothing
+#
+# auto
+# none
+antialiased
+subpixel-antialiased
index e5c52bf..27b3a05 100644 (file)
@@ -28,6 +28,7 @@
 #include "FontFamily.h"
 #include "FontRenderingMode.h"
 #include "FontTraitsMask.h"
+#include "RenderStyleConstants.h"
 
 namespace WebCore {
 
@@ -61,6 +62,7 @@ public:
         , m_usePrinterFont(false)
         , m_renderingMode(NormalRenderingMode)
         , m_keywordSize(0)
+        , m_fontSmoothing(AutoSmoothing)
     {
     }
 
@@ -84,6 +86,7 @@ public:
     bool useFixedDefaultSize() const { return genericFamily() == MonospaceFamily && !family().next() && family().family() == "-webkit-monospace"; }
     FontRenderingMode renderingMode() const { return static_cast<FontRenderingMode>(m_renderingMode); }
     unsigned keywordSize() const { return m_keywordSize; }
+    FontSmoothing fontSmoothing() const { return static_cast<FontSmoothing>(m_fontSmoothing); }
 
     FontTraitsMask traitsMask() const;
 
@@ -98,6 +101,7 @@ public:
     void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
     void setRenderingMode(FontRenderingMode mode) { m_renderingMode = mode; }
     void setKeywordSize(unsigned s) { m_keywordSize = s; }
+    void setFontSmoothing(FontSmoothing smoothing) { m_fontSmoothing = smoothing; }
 
 private:
     FontFamily m_familyList; // The list of font families to be used.
@@ -119,6 +123,8 @@ private:
     unsigned m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium).  If so,
                            // then we can accurately translate across different generic families to adjust for different preference settings
                            // (e.g., 13px monospace vs. 16px everything else).  Sizes are 1-8 (like the HTML size values for <font>).
+
+    unsigned m_fontSmoothing : 2; // FontSmoothing
 };
 
 inline bool FontDescription::operator==(const FontDescription& other) const
@@ -133,7 +139,8 @@ inline bool FontDescription::operator==(const FontDescription& other) const
         && m_genericFamily == other.m_genericFamily
         && m_usePrinterFont == other.m_usePrinterFont
         && m_renderingMode == other.m_renderingMode
-        && m_keywordSize == other.m_keywordSize;
+        && m_keywordSize == other.m_keywordSize
+        && m_fontSmoothing == other.m_fontSmoothing;
 }
 
 }
index df9494a..b2b9a5c 100644 (file)
@@ -50,10 +50,33 @@ bool Font::canReturnFallbackFontsForComplexText()
 void Font::drawGlyphs(GraphicsContext* context, const SimpleFontData* font, const GlyphBuffer& glyphBuffer, int from, int numGlyphs, const FloatPoint& point) const
 {
     CGContextRef cgContext = context->platformContext();
+    bool newShouldUseFontSmoothing = shouldUseSmoothing();
+
+    switch(fontDescription().fontSmoothing()) {
+    case Antialiased: {
+        context->setShouldAntialias(true);
+        newShouldUseFontSmoothing = false;
+        break;
+    }
+    case SubpixelAntialiased: {
+        context->setShouldAntialias(true);
+        newShouldUseFontSmoothing = true;
+        break;
+    }
+    case NoSmoothing: {
+        context->setShouldAntialias(false);
+        newShouldUseFontSmoothing = false;
+        break;
+    }
+    case AutoSmoothing: {
+        // For the AutoSmooth case, don't do anything! Keep the default settings.
+        break; 
+    }
+    default: 
+        ASSERT_NOT_REACHED();
+    }
 
     bool originalShouldUseFontSmoothing = wkCGContextGetShouldSmoothFonts(cgContext);
-    bool newShouldUseFontSmoothing = shouldUseSmoothing();
-    
     if (originalShouldUseFontSmoothing != newShouldUseFontSmoothing)
         CGContextSetShouldSmoothFonts(cgContext, newShouldUseFontSmoothing);
     
index 803f5db..e2ed130 100644 (file)
@@ -297,6 +297,30 @@ void Font::drawGlyphs(GraphicsContext* graphicsContext, const SimpleFontData* fo
     CGContextRef cgContext = graphicsContext->platformContext();
     bool shouldUseFontSmoothing = WebCoreShouldUseFontSmoothing();
 
+    switch(fontDescription().fontSmoothing()) {
+    case Antialiased: {
+        graphicsContext->setShouldAntialias(true);
+        shouldUseFontSmoothing = false;
+        break;
+    }
+    case SubpixelAntialiased: {
+        graphicsContext->setShouldAntialias(true);
+        shouldUseFontSmoothing = true;
+        break;
+    }
+    case NoSmoothing: {
+        graphicsContext->setShouldAntialias(false);
+        shouldUseFontSmoothing = false;
+        break;
+    }
+    case AutoSmoothing: {
+        // For the AutoSmooth case, don't do anything! Keep the default settings.
+        break; 
+    }
+    default: 
+        ASSERT_NOT_REACHED();
+    }
+
     if (font->platformData().useGDI()) {
         if (!shouldUseFontSmoothing || (graphicsContext->textDrawingMode() & cTextStroke)) {
             drawGDIGlyphs(graphicsContext, font, glyphBuffer, from, numGlyphs, point);
index c19b44f..1a216fe 100644 (file)
@@ -434,6 +434,7 @@ public:
     const Font& font() const { return inherited->font; }
     const FontDescription& fontDescription() const { return inherited->font.fontDescription(); }
     int fontSize() const { return inherited->font.pixelSize(); }
+    FontSmoothing fontSmoothing() const { return inherited->font.fontDescription().fontSmoothing(); }
 
     const Color& color() const { return inherited->color; }
     Length textIndent() const { return inherited->indent; }
index a47defb..6a7277d 100644 (file)
@@ -321,6 +321,10 @@ enum EBackfaceVisibility {
     BackfaceVisibilityVisible, BackfaceVisibilityHidden
 };
 
+enum FontSmoothing {
+    AutoSmoothing, NoSmoothing, Antialiased, SubpixelAntialiased
+};
+
 } // namespace WebCore
 
 #endif // RenderStyleConstants_h