Title: [183494] trunk
Revision
183494
Author
[email protected]
Date
2015-04-28 11:36:59 -0700 (Tue, 28 Apr 2015)

Log Message

Source/WebCore:
[Mac] [iOS] Implement font-synthesis CSS property
https://bugs.webkit.org/show_bug.cgi?id=144305

Reviewed by Andreas Kling.

This patch is fairly straightforward, though there are some particular pieces to the patch listed below.

The implementation of this font-synthesis CSS property lives inside FontCacheIOS and FontCacheMac. We already
determine if we should synthesize bold and italics, this CSS property simply guards that decision.

Because FontCache interacts with FontDescriptions and not RenderStyles, this patch moves the source of truth
regarding font-synthesis into FontDescription (from RenderStyle).

Test: fast/css3-text/font-synthesis.html

* css/CSSPropertyNames.in: Mark font-synthesis as a FontProperty, which means that the relevant state is kept
inside FontDescription. This also means that the property must be marked as a "high priority" property, which
is enforced by it existing at the top of CSSPropertyNames.in. The move to FontDescription must be done so that
FontCacheIOS and FontCacheMac have access to the saved state.
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::fontSynthesisFromStyle): Update to look for state in FontDescription instead of RenderStyle.
* css/CSSSegmentedFontFace.cpp:
(WebCore::CSSSegmentedFontFace::fontRanges): Guard the synthetic bold and synthic italic decision on the new
FontSynthesis state inside FontDescription.
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertFontSynthesis): Moved from
StyleBuilderCustom::applyValueFontSynthesis(). This is because of the updated options inside of
CSSPropertyNames.in
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyValueFontSynthesis): Deleted.
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::FontDescription): Moved from RenderStyle.
(WebCore::FontDescription::fontSynthesis): Ditto.
(WebCore::FontDescription::setFontSynthesis): Ditto.
(WebCore::FontDescription::initialFontSynthesis): Ditto.
(WebCore::FontDescription::operator==): Update to include new state.
* platform/graphics/FontCache.h:
(WebCore::FontDescriptionFontDataCacheKey::makeFlagKey): Make FontDescription hashes sensitive to the new
state inside FontDescription.
* platform/graphics/ios/FontCacheIOS.mm:
(WebCore::FontCache::createFontPlatformData): Guard the synthetic bold and synthetic italic decision on the
new FontSynthesis state inside FontDescription.
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::FontCache::createFontPlatformData): Ditto.
* platform/text/TextFlags.h: Move FontSynthesis type from RenderStyleConstants.
* rendering/style/RenderStyle.h:
(WebCore::RenderStyle::fontSynthesis): Moved to FontDescription.
(WebCore::RenderStyle::setFontSynthesis): Ditto.
(WebCore::RenderStyle::initialFontSynthesis): Ditto.
* rendering/style/RenderStyleConstants.h: Moved FontSynthesis type to TextFlags.
* rendering/style/StyleRareInheritedData.h: Remove state regarding font synthesis (moved to FontDescription)

LayoutTests:
Implement font-synthesis CSS property
https://bugs.webkit.org/show_bug.cgi?id=144305

Reviewed by Andreas Kling.

Test all combinations of font-weight, font-style, and font-synthesis.

* fast/css3-text/font-synthesis-expected.html: Added.
* fast/css3-text/font-synthesis.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (183493 => 183494)


--- trunk/LayoutTests/ChangeLog	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/LayoutTests/ChangeLog	2015-04-28 18:36:59 UTC (rev 183494)
@@ -1,3 +1,15 @@
+2015-04-27  Myles C. Maxfield  <[email protected]>
+
+        Implement font-synthesis CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=144305
+
+        Reviewed by Andreas Kling.
+
+        Test all combinations of font-weight, font-style, and font-synthesis.
+
+        * fast/css3-text/font-synthesis-expected.html: Added.
+        * fast/css3-text/font-synthesis.html: Added.
+
 2015-04-28  Brent Fulgham  <[email protected]>
 
         [Win] Temporarily disable WebGL support

Added: trunk/LayoutTests/fast/css3-text/font-synthesis-expected.html (0 => 183494)


--- trunk/LayoutTests/fast/css3-text/font-synthesis-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css3-text/font-synthesis-expected.html	2015-04-28 18:36:59 UTC (rev 183494)
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "CustomAhem";
+    font-weight: 400;
+    font-style: normal;
+    src: url("../../resources/Ahem.ttf") format("truetype");
+}
+</style>
+</head>
+<body>
+This test makes sure that the font-synthesis property disallows synthesis when it is specified.
+<div style="font: 20px CustomAhem; position: relative;">
+<div style="position: absolute; left: 0px; top: 0px;">
+<div>ABCD</div>
+<div>ABCD</div>
+<div>ABCD</div>
+<div>ABCD</div>
+</div>
+<div style="position: absolute; left: 150px; top: 0px;">
+<div>ABCD</div>
+<div style="font-weight: 700;">ABCD</div>
+<div>ABCD</div>
+<div style="font-weight: 700;">ABCD</div>
+</div>
+<div style="position: absolute; left: 300px; top: 0px;">
+<div>ABCD</div>
+<div>ABCD</div>
+<div style="font-style: italic;">ABCD</div>
+<div style="font-style: italic;">ABCD</div>
+</div>
+<div style="position: absolute; left: 450px; top: 0px;">
+<div>ABCD</div>
+<div style="font-weight: 700;">ABCD</div>
+<div style="font-style: italic;">ABCD</div>
+<div style="font-weight: 700; font-style: italic;">ABCD</div>
+</div>
+</div>
+<div style="font: 20px CustomAhem; position: relative; top: 100px;">
+<div style="position: absolute; left: 0px; top: 0px;">
+<div>ABCD</div>
+<div>ABCD</div>
+<div>ABCD</div>
+<div>ABCD</div>
+</div>
+<div style="position: absolute; left: 150px; top: 0px;">
+<div>ABCD</div>
+<div style="font-weight: 700;">ABCD</div>
+<div>ABCD</div>
+<div style="font-weight: 700;">ABCD</div>
+</div>
+<div style="position: absolute; left: 300px; top: 0px;">
+<div>ABCD</div>
+<div>ABCD</div>
+<div style="font-style: italic;">ABCD</div>
+<div style="font-style: italic;">ABCD</div>
+</div>
+<div style="position: absolute; left: 450px; top: 0px;">
+<div>ABCD</div>
+<div style="font-weight: 700;">ABCD</div>
+<div style="font-style: italic;">ABCD</div>
+<div style="font-weight: 700; font-style: italic;">ABCD</div>
+</div>
+</div>
+<div style="font: 20px Ahem; position: relative; top: 200px;">
+<div>
+ABCD
+</div>
+</div>
+</body>
+</html>

Modified: trunk/LayoutTests/fast/css3-text/font-synthesis-parse-expected.txt (183493 => 183494)


--- trunk/LayoutTests/fast/css3-text/font-synthesis-parse-expected.txt	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/LayoutTests/fast/css3-text/font-synthesis-parse-expected.txt	2015-04-28 18:36:59 UTC (rev 183494)
@@ -1,7 +1,7 @@
 PASS cssRule.type is cssRule.STYLE_RULE
 PASS declaration.length is 0
 PASS declaration.getPropertyValue('font-synthesis') is null
-PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight"
 PASS cssRule.type is cssRule.STYLE_RULE
 PASS declaration.length is 1
 PASS declaration.getPropertyValue('font-synthesis') is "initial"
@@ -33,23 +33,23 @@
 PASS cssRule.type is cssRule.STYLE_RULE
 PASS declaration.length is 0
 PASS declaration.getPropertyValue('font-synthesis') is null
-PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight"
 PASS cssRule.type is cssRule.STYLE_RULE
 PASS declaration.length is 0
 PASS declaration.getPropertyValue('font-synthesis') is null
-PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight"
 PASS cssRule.type is cssRule.STYLE_RULE
 PASS declaration.length is 0
 PASS declaration.getPropertyValue('font-synthesis') is null
-PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight"
 PASS cssRule.type is cssRule.STYLE_RULE
 PASS declaration.length is 0
 PASS declaration.getPropertyValue('font-synthesis') is null
-PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight"
 PASS cssRule.type is cssRule.STYLE_RULE
 PASS declaration.length is 0
 PASS declaration.getPropertyValue('font-synthesis') is null
-PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight"
 PASS successfullyParsed is true
 
 TEST COMPLETE

Modified: trunk/LayoutTests/fast/css3-text/font-synthesis-parse.html (183493 => 183494)


--- trunk/LayoutTests/fast/css3-text/font-synthesis-parse.html	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/LayoutTests/fast/css3-text/font-synthesis-parse.html	2015-04-28 18:36:59 UTC (rev 183494)
@@ -7,14 +7,14 @@
   <div id="p"></div>
   <div id="q"><div id="r"></div></div>
   <script type="text/_javascript_">
-    function testEmptyIsNone(stylesheet, target) {
+    function testEmptyIsBoth(stylesheet, target) {
       cssRule = stylesheet.cssRules.item(0);
       shouldBe("cssRule.type", "cssRule.STYLE_RULE");
       declaration = cssRule.style;
       shouldBe("declaration.length", "0");
       shouldBe("declaration.getPropertyValue('font-synthesis')", "null");
       computedStyle = window.getComputedStyle(target, null);
-      shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "none");
+      shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "style weight");
       stylesheet.deleteRule(0);
     }
 
@@ -79,7 +79,7 @@
     var target = document.getElementById("p");
 
     stylesheet.insertRule("#p { }", 0);
-    testEmptyIsNone(stylesheet, target);
+    testEmptyIsBoth(stylesheet, target);
 
     stylesheet.insertRule("#p { font-synthesis: initial; }", 0);
     testInitialIsBoth(stylesheet, target);
@@ -103,19 +103,19 @@
     testStyleAndWeight(stylesheet, target);
 
     stylesheet.insertRule("#p { font-synthesis: garbage style }", 0);
-    testEmptyIsNone(stylesheet, target);
+    testEmptyIsBoth(stylesheet, target);
 
     stylesheet.insertRule("#p { font-synthesis: style garbage }", 0);
-    testEmptyIsNone(stylesheet, target);
+    testEmptyIsBoth(stylesheet, target);
 
     stylesheet.insertRule("#p { font-synthesis: garbage style garbage }", 0);
-    testEmptyIsNone(stylesheet, target);
+    testEmptyIsBoth(stylesheet, target);
 
     stylesheet.insertRule("#p { font-synthesis: style garbage style }", 0);
-    testEmptyIsNone(stylesheet, target);
+    testEmptyIsBoth(stylesheet, target);
 
     stylesheet.insertRule("#p { font-synthesis: weight garbage }", 0);
-    testEmptyIsNone(stylesheet, target);
+    testEmptyIsBoth(stylesheet, target);
 
   </script>
 <script src=""

Added: trunk/LayoutTests/fast/css3-text/font-synthesis.html (0 => 183494)


--- trunk/LayoutTests/fast/css3-text/font-synthesis.html	                        (rev 0)
+++ trunk/LayoutTests/fast/css3-text/font-synthesis.html	2015-04-28 18:36:59 UTC (rev 183494)
@@ -0,0 +1,73 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "CustomAhem";
+    font-weight: 400;
+    font-style: normal;
+    src: url("../../resources/Ahem.ttf") format("truetype");
+}
+</style>
+</head>
+<body>
+This test makes sure that the font-synthesis property disallows synthesis when it is specified.
+<div style="font: 20px CustomAhem; position: relative;">
+<div style="position: absolute; left: 0px; top: 0px;">
+<div style="font-synthesis: none;">ABCD</div>
+<div style="font-synthesis: weight;">ABCD</div>
+<div style="font-synthesis: style;">ABCD</div>
+<div style="font-synthesis: weight style;">ABCD</div>
+</div>
+<div style="font-weight: 700; position: absolute; left: 150px; top: 0px;">
+<div style="font-synthesis: none;">ABCD</div>
+<div style="font-synthesis: weight;">ABCD</div>
+<div style="font-synthesis: style;">ABCD</div>
+<div style="font-synthesis: weight style;">ABCD</div>
+</div>
+<div style="font-style: italic; position: absolute; left: 300px; top: 0px;">
+<div style="font-synthesis: none;">ABCD</div>
+<div style="font-synthesis: weight;">ABCD</div>
+<div style="font-synthesis: style;">ABCD</div>
+<div style="font-synthesis: weight style;">ABCD</div>
+</div>
+<div style="font-weight: 700; font-style: italic; position: absolute; left: 450px; top: 0px;">
+<div style="font-synthesis: none;">ABCD</div>
+<div style="font-synthesis: weight;">ABCD</div>
+<div style="font-synthesis: style;">ABCD</div>
+<div style="font-synthesis: weight style;">ABCD</div>
+</div>
+</div>
+<div style="font: 20px Ahem; position: relative; top: 100px;">
+<div style="position: absolute; left: 0px; top: 0px;">
+<div style="font-synthesis: none;">ABCD</div>
+<div style="font-synthesis: weight;">ABCD</div>
+<div style="font-synthesis: style;">ABCD</div>
+<div style="font-synthesis: weight style;">ABCD</div>
+</div>
+<div style="font-weight: 700; position: absolute; left: 150px; top: 0px;">
+<div style="font-synthesis: none;">ABCD</div>
+<div style="font-synthesis: weight;">ABCD</div>
+<div style="font-synthesis: style;">ABCD</div>
+<div style="font-synthesis: weight style;">ABCD</div>
+</div>
+<div style="font-style: italic; position: absolute; left: 300px; top: 0px;">
+<div style="font-synthesis: none;">ABCD</div>
+<div style="font-synthesis: weight;">ABCD</div>
+<div style="font-synthesis: style;">ABCD</div>
+<div style="font-synthesis: weight style;">ABCD</div>
+</div>
+<div style="font-weight: 700; font-style: italic; position: absolute; left: 450px; top: 0px;">
+<div style="font-synthesis: none;">ABCD</div>
+<div style="font-synthesis: weight;">ABCD</div>
+<div style="font-synthesis: style;">ABCD</div>
+<div style="font-synthesis: weight style;">ABCD</div>
+</div>
+</div>
+<div style="font: 20px Ahem; position: relative; top: 200px; font-synthesis: none;">
+<div style="font-style: italic;">
+ABCD
+</div>
+</div>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (183493 => 183494)


--- trunk/Source/WebCore/ChangeLog	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/ChangeLog	2015-04-28 18:36:59 UTC (rev 183494)
@@ -1,3 +1,57 @@
+2015-04-27  Myles C. Maxfield  <[email protected]>
+
+        [Mac] [iOS] Implement font-synthesis CSS property
+        https://bugs.webkit.org/show_bug.cgi?id=144305
+
+        Reviewed by Andreas Kling.
+
+        This patch is fairly straightforward, though there are some particular pieces to the patch listed below.
+
+        The implementation of this font-synthesis CSS property lives inside FontCacheIOS and FontCacheMac. We already
+        determine if we should synthesize bold and italics, this CSS property simply guards that decision.
+
+        Because FontCache interacts with FontDescriptions and not RenderStyles, this patch moves the source of truth
+        regarding font-synthesis into FontDescription (from RenderStyle).
+
+        Test: fast/css3-text/font-synthesis.html
+
+        * css/CSSPropertyNames.in: Mark font-synthesis as a FontProperty, which means that the relevant state is kept
+        inside FontDescription. This also means that the property must be marked as a "high priority" property, which
+        is enforced by it existing at the top of CSSPropertyNames.in. The move to FontDescription must be done so that
+        FontCacheIOS and FontCacheMac have access to the saved state.
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::fontSynthesisFromStyle): Update to look for state in FontDescription instead of RenderStyle.
+        * css/CSSSegmentedFontFace.cpp:
+        (WebCore::CSSSegmentedFontFace::fontRanges): Guard the synthetic bold and synthic italic decision on the new
+        FontSynthesis state inside FontDescription.
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::convertFontSynthesis): Moved from
+        StyleBuilderCustom::applyValueFontSynthesis(). This is because of the updated options inside of
+        CSSPropertyNames.in
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyValueFontSynthesis): Deleted.
+        * platform/graphics/FontDescription.h:
+        (WebCore::FontDescription::FontDescription): Moved from RenderStyle.
+        (WebCore::FontDescription::fontSynthesis): Ditto.
+        (WebCore::FontDescription::setFontSynthesis): Ditto.
+        (WebCore::FontDescription::initialFontSynthesis): Ditto.
+        (WebCore::FontDescription::operator==): Update to include new state.
+        * platform/graphics/FontCache.h:
+        (WebCore::FontDescriptionFontDataCacheKey::makeFlagKey): Make FontDescription hashes sensitive to the new
+        state inside FontDescription.
+        * platform/graphics/ios/FontCacheIOS.mm:
+        (WebCore::FontCache::createFontPlatformData): Guard the synthetic bold and synthetic italic decision on the
+        new FontSynthesis state inside FontDescription.
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::FontCache::createFontPlatformData): Ditto.
+        * platform/text/TextFlags.h: Move FontSynthesis type from RenderStyleConstants.
+        * rendering/style/RenderStyle.h:
+        (WebCore::RenderStyle::fontSynthesis): Moved to FontDescription.
+        (WebCore::RenderStyle::setFontSynthesis): Ditto.
+        (WebCore::RenderStyle::initialFontSynthesis): Ditto.
+        * rendering/style/RenderStyleConstants.h: Moved FontSynthesis type to TextFlags.
+        * rendering/style/StyleRareInheritedData.h: Remove state regarding font synthesis (moved to FontDescription)
+
 2015-04-28  Youenn Fablet  <[email protected]>
 
         SharedBuffer::copy is not computing the buffer size correctly when having m_dataArray

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (183493 => 183494)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2015-04-28 18:36:59 UTC (rev 183494)
@@ -1613,13 +1613,13 @@
 
 static Ref<CSSValue> fontSynthesisFromStyle(RenderStyle& style)
 {
-    if (style.fontSynthesis() == FontSynthesisNone)
+    if (style.fontDescription().fontSynthesis() == FontSynthesisNone)
         return cssValuePool().createIdentifierValue(CSSValueNone);
 
     auto list = CSSValueList::createSpaceSeparated();
-    if (style.fontSynthesis() & FontSynthesisStyle)
+    if (style.fontDescription().fontSynthesis() & FontSynthesisStyle)
         list.get().append(cssValuePool().createIdentifierValue(CSSValueStyle));
-    if (style.fontSynthesis() & FontSynthesisWeight)
+    if (style.fontDescription().fontSynthesis() & FontSynthesisWeight)
         list.get().append(cssValuePool().createIdentifierValue(CSSValueWeight));
     return Ref<CSSValue>(list.get());
 }

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (183493 => 183494)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2015-04-28 18:36:59 UTC (rev 183494)
@@ -118,6 +118,7 @@
 -webkit-writing-mode [Inherited, Custom=Value]
 -epub-writing-mode = -webkit-writing-mode
 zoom [Custom=All]
+font-synthesis [Inherited, FontProperty, Converter=FontSynthesis]
 
 // Keep this in between the highest priority props and the lower ones.
 -webkit-ruby-position [Inherited]
@@ -223,7 +224,6 @@
 flood-opacity [SVG, Converter=Opacity]
 font [Inherited, Longhands=font-family|font-size|font-style|font-variant|font-weight|line-height]
 font-stretch [SkipBuilder]
-font-synthesis [Inherited, Custom=Value]
 glyph-orientation-horizontal [Inherited, SVG, Converter=GlyphOrientation]
 glyph-orientation-vertical [Inherited, SVG, Converter=GlyphOrientationOrAuto]
 height [Initial=initialSize, Converter=LengthSizing]

Modified: trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp (183493 => 183494)


--- trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp	2015-04-28 18:36:59 UTC (rev 183494)
@@ -113,7 +113,9 @@
         return FontRanges();
 
     FontTraitsMask desiredTraitsMask = fontDescription.traitsMask();
-    unsigned hashKey = ((fontDescription.computedPixelSize() + 1) << (FontTraitsMaskWidth + FontWidthVariantWidth + 1))
+    // FIXME: Unify this function with FontDescriptionFontDataCacheKey in FontCache.h (Or just use the regular FontCache instead of this)
+    unsigned hashKey = ((fontDescription.computedPixelSize() + 1) << (FontTraitsMaskWidth + FontWidthVariantWidth + FontSynthesisWidth + 1))
+        | (fontDescription.fontSynthesis() << (FontTraitsMaskWidth + FontWidthVariantWidth + 1))
         | ((fontDescription.orientation() == Vertical ? 1 : 0) << (FontTraitsMaskWidth + FontWidthVariantWidth))
         | fontDescription.widthVariant() << FontTraitsMaskWidth
         | desiredTraitsMask;
@@ -125,9 +127,11 @@
         for (auto& face : m_fontFaces) {
             if (!face->isValid())
                 continue;
+
             FontTraitsMask traitsMask = face->traitsMask();
-            bool syntheticBold = !(traitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)) && (desiredTraitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask));
-            bool syntheticItalic = !(traitsMask & FontStyleItalicMask) && (desiredTraitsMask & FontStyleItalicMask);
+            bool syntheticBold = (fontDescription.fontSynthesis() & FontSynthesisWeight) && !(traitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask)) && (desiredTraitsMask & (FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask));
+            bool syntheticItalic = (fontDescription.fontSynthesis() & FontSynthesisStyle) && !(traitsMask & FontStyleItalicMask) && (desiredTraitsMask & FontStyleItalicMask);
+
             if (RefPtr<Font> faceFont = face->font(fontDescription, syntheticBold, syntheticItalic))
                 appendFontWithInvalidUnicodeRangeIfLoading(fontRanges, faceFont.releaseNonNull(), face->ranges());
         }

Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (183493 => 183494)


--- trunk/Source/WebCore/css/StyleBuilderConverter.h	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h	2015-04-28 18:36:59 UTC (rev 183494)
@@ -124,6 +124,7 @@
     static EGlyphOrientation convertGlyphOrientation(StyleResolver&, CSSValue&);
     static EGlyphOrientation convertGlyphOrientationOrAuto(StyleResolver&, CSSValue&);
     static Optional<Length> convertLineHeight(StyleResolver&, CSSValue&, float multiplier = 1.f);
+    static FontSynthesis convertFontSynthesis(StyleResolver&, CSSValue&);
 
 private:
     friend class StyleBuilderCustom;
@@ -1211,6 +1212,32 @@
     return Nullopt;
 }
 
+FontSynthesis StyleBuilderConverter::convertFontSynthesis(StyleResolver&, CSSValue& value)
+{
+    if (is<CSSPrimitiveValue>(value)) {
+        ASSERT(downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueNone);
+        return FontSynthesisNone;
+    }
+
+    FontSynthesis result = FontSynthesisNone;
+    ASSERT(is<CSSValueList>(value));
+    for (CSSValue& v : downcast<CSSValueList>(value)) {
+        switch (downcast<CSSPrimitiveValue>(v).getValueID()) {
+        case CSSValueWeight:
+            result |= FontSynthesisWeight;
+            break;
+        case CSSValueStyle:
+            result |= FontSynthesisStyle;
+            break;
+        default:
+            ASSERT_NOT_REACHED();
+            break;
+        }
+    }
+
+    return result;
+}
+
 } // namespace WebCore
 
 #endif // StyleBuilderConverter_h

Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (183493 => 183494)


--- trunk/Source/WebCore/css/StyleBuilderCustom.h	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h	2015-04-28 18:36:59 UTC (rev 183494)
@@ -76,7 +76,6 @@
     DECLARE_PROPERTY_CUSTOM_HANDLERS(FontFamily);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(FontSize);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(FontWeight);
-    DECLARE_PROPERTY_CUSTOM_HANDLERS(FontSynthesis);
 #if ENABLE(CSS_IMAGE_RESOLUTION)
     DECLARE_PROPERTY_CUSTOM_HANDLERS(ImageResolution);
 #endif
@@ -1376,32 +1375,6 @@
     styleResolver.setFontDescription(fontDescription);
 }
 
-inline void StyleBuilderCustom::applyValueFontSynthesis(StyleResolver& styleResolver, CSSValue& value)
-{
-    if (is<CSSPrimitiveValue>(value)) {
-        ASSERT(downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueNone);
-        styleResolver.style()->setFontSynthesis(FontSynthesisNone);
-    }
-
-    FontSynthesis result = FontSynthesisNone;
-    ASSERT(is<CSSValueList>(value));
-    for (CSSValue& i : downcast<CSSValueList>(value)) {
-        switch (downcast<CSSPrimitiveValue>(i).getValueID()) {
-        case CSSValueWeight:
-            result |= FontSynthesisWeight;
-            break;
-        case CSSValueStyle:
-            result |= FontSynthesisStyle;
-            break;
-        default:
-            ASSERT_NOT_REACHED();
-            break;
-        }
-    }
-
-    styleResolver.style()->setFontSynthesis(result);
-}
-
 inline void StyleBuilderCustom::applyInitialColumnGap(StyleResolver& styleResolver)
 {
     styleResolver.style()->setHasNormalColumnGap();

Modified: trunk/Source/WebCore/css/StyleResolver.cpp (183493 => 183494)


--- trunk/Source/WebCore/css/StyleResolver.cpp	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/css/StyleResolver.cpp	2015-04-28 18:36:59 UTC (rev 183494)
@@ -168,7 +168,7 @@
 
 using namespace HTMLNames;
 
-static const CSSPropertyID lastHighPriorityProperty = CSSPropertyZoom;
+static const CSSPropertyID lastHighPriorityProperty = CSSPropertyFontSynthesis;
 static const CSSPropertyID firstLowPriorityProperty = static_cast<CSSPropertyID>(lastHighPriorityProperty + 1);
 
 class StyleResolver::CascadedProperties {

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (183493 => 183494)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2015-04-28 18:36:59 UTC (rev 183494)
@@ -79,7 +79,8 @@
     { }
     static unsigned makeFlagKey(const FontDescription& description)
     {
-        return static_cast<unsigned>(description.widthVariant()) << 4
+        return static_cast<unsigned>(description.fontSynthesis()) << 6
+            | static_cast<unsigned>(description.widthVariant()) << 4
             | static_cast<unsigned>(description.nonCJKGlyphOrientation()) << 3
             | static_cast<unsigned>(description.orientation()) << 2
             | static_cast<unsigned>(description.italic()) << 1

Modified: trunk/Source/WebCore/platform/graphics/FontDescription.h (183493 => 183494)


--- trunk/Source/WebCore/platform/graphics/FontDescription.h	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.h	2015-04-28 18:36:59 UTC (rev 183494)
@@ -65,6 +65,7 @@
         , m_textRendering(AutoTextRendering)
         , m_isSpecifiedFont(false)
         , m_script(USCRIPT_COMMON)
+        , m_fontSynthesis(initialFontSynthesis())
     {
     }
 
@@ -109,6 +110,7 @@
     NonCJKGlyphOrientation nonCJKGlyphOrientation() const { return static_cast<NonCJKGlyphOrientation>(m_nonCJKGlyphOrientation); }
     FontWidthVariant widthVariant() const { return static_cast<FontWidthVariant>(m_widthVariant); }
     FontFeatureSettings* featureSettings() const { return m_featureSettings.get(); }
+    FontSynthesis fontSynthesis() const { return static_cast<FontSynthesis>(m_fontSynthesis); }
 
     void setOneFamily(const AtomicString& family) { ASSERT(m_families.size() == 1); m_families[0] = family; }
     void setFamilies(const Vector<AtomicString>& families) { m_families = RefCountedArray<AtomicString>(families); }
@@ -147,6 +149,7 @@
     void setWidthVariant(FontWidthVariant widthVariant) { m_widthVariant = widthVariant; }
     void setScript(UScriptCode s) { m_script = s; }
     void setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) { m_featureSettings = settings; }
+    void setFontSynthesis(FontSynthesis fontSynthesis) { m_fontSynthesis = fontSynthesis; }
 
 #if ENABLE(IOS_TEXT_AUTOSIZING)
     bool familiesEqualForTextAutoSizing(const FontDescription& other) const;
@@ -166,6 +169,7 @@
     static Kerning initialKerning() { return AutoKerning; }
     static FontSmoothingMode initialFontSmoothing() { return AutoSmoothing; }
     static TextRenderingMode initialTextRenderingMode() { return AutoTextRendering; }
+    static FontSynthesis initialFontSynthesis() { return FontSynthesisWeight | FontSynthesisStyle; }
 
 private:
     RefCountedArray<AtomicString> m_families;
@@ -201,6 +205,7 @@
     unsigned m_textRendering : 2; // TextRenderingMode
     unsigned m_isSpecifiedFont : 1; // True if a web page specifies a non-generic font family as the first font family.
     unsigned m_script : 7; // Used to help choose an appropriate font for generic font families.
+    unsigned m_fontSynthesis : 2; // FontSynthesis type
 };
 
 inline bool FontDescription::operator==(const FontDescription& other) const
@@ -225,7 +230,8 @@
         && m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation
         && m_widthVariant == other.m_widthVariant
         && m_script == other.m_script
-        && m_featureSettings == other.m_featureSettings;
+        && m_featureSettings == other.m_featureSettings
+        && m_fontSynthesis == other.m_fontSynthesis;
 }
 
 }

Modified: trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (183493 => 183494)


--- trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm	2015-04-28 18:36:59 UTC (rev 183494)
@@ -694,8 +694,8 @@
 
     bool isAppleColorEmoji = CTFontIsAppleColorEmoji(ctFont.get());
 
-    bool syntheticBold = (traits & kCTFontTraitBold) && !(actualTraits & kCTFontTraitBold) && !isAppleColorEmoji;
-    bool syntheticOblique = (traits & kCTFontTraitItalic) && !(actualTraits & kCTFontTraitItalic) && !isAppleColorEmoji;
+    bool syntheticBold = (fontDescription.fontSynthesis() & FontSynthesisWeight) && (traits & kCTFontTraitBold) && !(actualTraits & kCTFontTraitBold) && !isAppleColorEmoji;
+    bool syntheticOblique = (fontDescription.fontSynthesis() & FontSynthesisStyle) && (traits & kCTFontTraitItalic) && !(actualTraits & kCTFontTraitItalic) && !isAppleColorEmoji;
 
     auto result = std::make_unique<FontPlatformData>(ctFont.get(), size, syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant());
     if (isAppleColorEmoji)

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (183493 => 183494)


--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-04-28 18:36:59 UTC (rev 183494)
@@ -509,8 +509,8 @@
     NSInteger actualWeight = [fontManager weightOfFont:nsFont];
 
     NSFont *platformFont = [nsFont printerFont];
-    bool syntheticBold = isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(actualWeight);
-    bool syntheticOblique = (traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait);
+    bool syntheticBold = (fontDescription.fontSynthesis() & FontSynthesisWeight) && isAppKitFontWeightBold(weight) && !isAppKitFontWeightBold(actualWeight);
+    bool syntheticOblique = (fontDescription.fontSynthesis() & FontSynthesisStyle) && (traits & NSFontItalicTrait) && !(actualTraits & NSFontItalicTrait);
 
     return std::make_unique<FontPlatformData>(reinterpret_cast<CTFontRef>(platformFont), size, syntheticBold, syntheticOblique, fontDescription.orientation(), fontDescription.widthVariant());
 }

Modified: trunk/Source/WebCore/platform/text/TextFlags.h (183493 => 183494)


--- trunk/Source/WebCore/platform/text/TextFlags.h	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/platform/text/TextFlags.h	2015-04-28 18:36:59 UTC (rev 183494)
@@ -59,6 +59,14 @@
 };
 typedef unsigned ExpansionBehavior;
 
+enum FontSynthesisValues {
+    FontSynthesisNone = 0x0,
+    FontSynthesisWeight = 0x1,
+    FontSynthesisStyle = 0x2
+};
+typedef unsigned FontSynthesis;
+const unsigned FontSynthesisWidth = 2;
+
 enum FontWidthVariant {
     RegularWidth,
     HalfWidth,

Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (183493 => 183494)


--- trunk/Source/WebCore/rendering/style/RenderStyle.h	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h	2015-04-28 18:36:59 UTC (rev 183494)
@@ -1025,8 +1025,6 @@
 
     TextOrientation textOrientation() const { return static_cast<TextOrientation>(rareInheritedData->m_textOrientation); }
 
-    FontSynthesis fontSynthesis() const { return static_cast<FontSynthesis>(rareInheritedData->fontSynthesis); }
-
     ObjectFit objectFit() const { return static_cast<ObjectFit>(rareNonInheritedData->m_objectFit); }
     
     // Return true if any transform related property (currently transform, transformStyle3D or perspective) 
@@ -1541,7 +1539,6 @@
     void setMarginAfterCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginAfterCollapse, c); }
     void setWordBreak(EWordBreak b) { SET_VAR(rareInheritedData, wordBreak, b); }
     void setOverflowWrap(EOverflowWrap b) { SET_VAR(rareInheritedData, overflowWrap, b); }
-    void setFontSynthesis(FontSynthesis synthesis) { SET_VAR(rareInheritedData, fontSynthesis, synthesis); }
     void setNBSPMode(ENBSPMode b) { SET_VAR(rareInheritedData, nbspMode, b); }
     void setLineBreak(LineBreak b) { SET_VAR(rareInheritedData, lineBreak, b); }
     void setHyphens(Hyphens h) { SET_VAR(rareInheritedData, hyphens, h); }
@@ -2070,7 +2067,6 @@
     static BlendMode initialBlendMode() { return BlendModeNormal; }
     static Isolation initialIsolation() { return IsolationAuto; }
 #endif
-    static FontSynthesis initialFontSynthesis() { return FontSynthesisStyle | FontSynthesisWeight; }
 
     static ptrdiff_t noninheritedFlagsMemoryOffset() { return OBJECT_OFFSETOF(RenderStyle, noninherited_flags); }
 

Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (183493 => 183494)


--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h	2015-04-28 18:36:59 UTC (rev 183494)
@@ -417,13 +417,6 @@
     CAPITALIZE, UPPERCASE, LOWERCASE, TTNONE
 };
 
-enum FontSynthesisValues {
-    FontSynthesisNone = 0x0,
-    FontSynthesisWeight = 0x1,
-    FontSynthesisStyle = 0x2
-};
-typedef unsigned FontSynthesis;
-
 #if ENABLE(LETTERPRESS)
 static const size_t TextDecorationBits = 5;
 #else

Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h (183493 => 183494)


--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2015-04-28 18:04:11 UTC (rev 183493)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h	2015-04-28 18:36:59 UTC (rev 183494)
@@ -133,8 +133,6 @@
     unsigned trailingWord : 1;
 #endif
 
-    unsigned fontSynthesis : 2;
-
     AtomicString hyphenationString;
     short hyphenationLimitBefore;
     short hyphenationLimitAfter;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to