Title: [217272] trunk
Revision
217272
Author
mmaxfi...@apple.com
Date
2017-05-23 00:37:42 -0700 (Tue, 23 May 2017)

Log Message

Update font-style's implementation in the font selection algorithm
https://bugs.webkit.org/show_bug.cgi?id=169453

Reviewed by Simon Fraser.

Source/WebCore:

Previously, we were treating "font-style: oblique" exactly the same as "font-style: italic".
These values were parsed to the same internal data type. However, variation fonts may have two
distinct axes: 'slnt' and 'ital'. Therefore, we need to keep a bool of state which represents
which of these two axes we should be setting when we apply font variations. We can do this by
making the "font-style" parser a "custom" parser. The implementation of these custom functions
will set both the italic value on the FontDescription as well as this extra bool.

We don't, however, want to treat these values as distinct for the purposese of font selection.
The fact that we treat oblique fonts the same as italic fonts is a feature, not a bug. Therefore,
the font selection algorithm is not made aware of this distinction. This is why we don't want to
package up the bool and FontSelectionValue into a class: font selection only cares about the
FontSelectionValue, so conceptually they shouldn't be joined. (The FontSelectionValue already
exists within a collection of all the things font selection needs to know about.)

Now that there is this extra bit of state on the FontDescription, we can do a little better when
computing the result of getComputedStyle(). Previously, we were always returning "italic" even
when "oblique" was specified. Now, we can return the correct one. However, this extra bit of
state is not kept on the CSSFontFace (because it doesn't need to be), which means we can only
improve the computed style of an element, rather than the cssText of an @font-face rule.

Test: fast/text/font-style-parse.html

* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::fontStyleFromStyleValue):
(WebCore::fontStyleFromStyle):
(WebCore::fontShorthandValueForSelectionProperties):
* css/CSSComputedStyleDeclaration.h:
* css/CSSFontFaceSet.h:
* css/CSSProperties.json:
* css/FontFace.cpp:
(WebCore::FontFace::style):
* css/FontSelectionValueInlines.h:
(WebCore::fontStyleKeyword):
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertFontStyle): Deleted.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyInitialFontStyle):
(WebCore::StyleBuilderCustom::applyInheritFontStyle):
(WebCore::StyleBuilderCustom::applyValueFontStyle):
* platform/graphics/FontCache.h:
(WebCore::FontDescriptionKey::makeFlagsKey):
* platform/graphics/FontDescription.cpp:
(WebCore::FontDescription::FontDescription):
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::shouldUseItalicVariationAxis):
(WebCore::FontDescription::setShouldUseItalicVariationAxis):
(WebCore::FontDescription::operator==):
(WebCore::FontCascadeDescription::initialShouldUseItalicVariationAxis):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::preparePlatformFont):
(WebCore::fontWithFamily):
(WebCore::FontCache::createFontPlatformData):
(WebCore::FontCache::systemFallbackForCharacters):
* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::fontPlatformData):

LayoutTests:

* fast/text/font-style-parse-expected.txt:
* fast/text/font-style-parse.html:
* platform/mac-elcapitan/fast/text/font-style-parse-expected.txt:

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (217271 => 217272)


--- trunk/LayoutTests/ChangeLog	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/LayoutTests/ChangeLog	2017-05-23 07:37:42 UTC (rev 217272)
@@ -1,3 +1,14 @@
+2017-05-22  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Update font-style's implementation in the font selection algorithm
+        https://bugs.webkit.org/show_bug.cgi?id=169453
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/font-style-parse-expected.txt:
+        * fast/text/font-style-parse.html:
+        * platform/mac-elcapitan/fast/text/font-style-parse-expected.txt:
+
 2017-05-22  Per Arne Vollan  <pvol...@apple.com>
 
         [Win] Update expectations for layout tests.

Modified: trunk/LayoutTests/fast/text/font-style-parse-expected.txt (217271 => 217272)


--- trunk/LayoutTests/fast/text/font-style-parse-expected.txt	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/LayoutTests/fast/text/font-style-parse-expected.txt	2017-05-23 07:37:42 UTC (rev 217272)
@@ -6,7 +6,7 @@
 PASS window.getComputedStyle(document.getElementById('test6')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test7')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test8')).fontStyle is "italic"
-PASS window.getComputedStyle(document.getElementById('test9')).fontStyle is "italic"
+PASS window.getComputedStyle(document.getElementById('test9')).fontStyle is "oblique"
 PASS window.getComputedStyle(document.getElementById('test10')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test11')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test12')).fontStyle is "normal"
@@ -19,6 +19,7 @@
 PASS window.getComputedStyle(document.getElementById('test19')).fontStyle is "italic"
 PASS window.getComputedStyle(document.getElementById('test20')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test21')).fontStyle is "oblique 14deg"
+PASS window.getComputedStyle(document.getElementById('test22')).fontStyle is "oblique"
 PASS window.getComputedStyle(document.getElementById('test1')).font is "normal normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test2')).font is "16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test3')).font is "16px/18px Times"
@@ -27,7 +28,7 @@
 PASS window.getComputedStyle(document.getElementById('test6')).font is "normal normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test7')).font is "normal normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test8')).font is "italic normal normal normal 16px/18px Times"
-PASS window.getComputedStyle(document.getElementById('test9')).font is "italic normal normal normal 16px/18px Times"
+PASS window.getComputedStyle(document.getElementById('test9')).font is "oblique normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test10')).font is "normal normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test11')).font is "normal normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test12')).font is "normal normal normal normal 16px/18px Times"
@@ -40,6 +41,7 @@
 PASS window.getComputedStyle(document.getElementById('test19')).font is "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'"
 PASS window.getComputedStyle(document.getElementById('test20')).font is "normal normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test21')).font is "48px/49px 'Helvetica Neue'"
+PASS window.getComputedStyle(document.getElementById('test22')).font is "oblique normal normal normal 16px/18px Times"
 PASS document.getElementById('test1').style.font is ""
 PASS document.getElementById('test15').style.font is "italic 100 48px/49px 'Helvetica Neue'"
 PASS document.getElementById('test16').style.font is "italic 100 48px/49px 'Helvetica Neue'"

Modified: trunk/LayoutTests/fast/text/font-style-parse.html (217271 => 217272)


--- trunk/LayoutTests/fast/text/font-style-parse.html	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/LayoutTests/fast/text/font-style-parse.html	2017-05-23 07:37:42 UTC (rev 217272)
@@ -26,6 +26,7 @@
 <div id="test19" style="font: italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue';"></div>
 <div id="test20" style="font: 13deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue';"></div>
 <div id="test21" style="font: oblique 14deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue';"></div>
+<div id="test22" style="font-style: oblique 20deg;"></div>
 </div>
 <script>
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test1')).fontStyle", "normal");
@@ -36,7 +37,7 @@
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test6')).fontStyle", "normal");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test7')).fontStyle", "normal");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test8')).fontStyle", "italic");
-shouldBeEqualToString("window.getComputedStyle(document.getElementById('test9')).fontStyle", "italic");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test9')).fontStyle", "oblique");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test10')).fontStyle", "normal");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test11')).fontStyle", "normal");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test12')).fontStyle", "normal");
@@ -49,6 +50,7 @@
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test19')).fontStyle", "italic");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test20')).fontStyle", "normal");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test21')).fontStyle", "oblique 14deg");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test22')).fontStyle", "oblique");
 
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test1')).font", "normal normal normal normal 16px/18px Times");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test2')).font", "16px/18px Times");
@@ -58,7 +60,7 @@
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test6')).font", "normal normal normal normal 16px/18px Times");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test7')).font", "normal normal normal normal 16px/18px Times");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test8')).font", "italic normal normal normal 16px/18px Times");
-shouldBeEqualToString("window.getComputedStyle(document.getElementById('test9')).font", "italic normal normal normal 16px/18px Times");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test9')).font", "oblique normal normal normal 16px/18px Times");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test10')).font", "normal normal normal normal 16px/18px Times");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test11')).font", "normal normal normal normal 16px/18px Times");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test12')).font", "normal normal normal normal 16px/18px Times");
@@ -71,6 +73,7 @@
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test19')).font", "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test20')).font", "normal normal normal normal 16px/18px Times");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test21')).font", "48px/49px 'Helvetica Neue'");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test22')).font", "oblique normal normal normal 16px/18px Times");
 
 shouldBeEqualToString("document.getElementById('test1').style.font", "");
 shouldBeEqualToString("document.getElementById('test15').style.font", "italic 100 48px/49px 'Helvetica Neue'");

Modified: trunk/LayoutTests/platform/mac-elcapitan/fast/text/font-style-parse-expected.txt (217271 => 217272)


--- trunk/LayoutTests/platform/mac-elcapitan/fast/text/font-style-parse-expected.txt	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/LayoutTests/platform/mac-elcapitan/fast/text/font-style-parse-expected.txt	2017-05-23 07:37:42 UTC (rev 217272)
@@ -6,7 +6,7 @@
 PASS window.getComputedStyle(document.getElementById('test6')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test7')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test8')).fontStyle is "italic"
-PASS window.getComputedStyle(document.getElementById('test9')).fontStyle is "italic"
+PASS window.getComputedStyle(document.getElementById('test9')).fontStyle is "oblique"
 PASS window.getComputedStyle(document.getElementById('test10')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test11')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test12')).fontStyle is "normal"
@@ -19,6 +19,7 @@
 PASS window.getComputedStyle(document.getElementById('test19')).fontStyle is "italic"
 PASS window.getComputedStyle(document.getElementById('test20')).fontStyle is "normal"
 FAIL window.getComputedStyle(document.getElementById('test21')).fontStyle should be oblique 14deg. Was normal.
+FAIL window.getComputedStyle(document.getElementById('test22')).fontStyle should be oblique. Was normal.
 PASS window.getComputedStyle(document.getElementById('test1')).font is "normal normal normal normal 16px/18px Times"
 FAIL window.getComputedStyle(document.getElementById('test2')).font should be 16px/18px Times. Was normal normal normal normal 16px/18px Times.
 FAIL window.getComputedStyle(document.getElementById('test3')).font should be 16px/18px Times. Was normal normal normal normal 16px/18px Times.
@@ -27,7 +28,7 @@
 PASS window.getComputedStyle(document.getElementById('test6')).font is "normal normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test7')).font is "normal normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test8')).font is "italic normal normal normal 16px/18px Times"
-PASS window.getComputedStyle(document.getElementById('test9')).font is "italic normal normal normal 16px/18px Times"
+PASS window.getComputedStyle(document.getElementById('test9')).font is "oblique normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test10')).font is "normal normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test11')).font is "normal normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test12')).font is "normal normal normal normal 16px/18px Times"
@@ -40,6 +41,7 @@
 PASS window.getComputedStyle(document.getElementById('test19')).font is "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'"
 PASS window.getComputedStyle(document.getElementById('test20')).font is "normal normal normal normal 16px/18px Times"
 FAIL window.getComputedStyle(document.getElementById('test21')).font should be 48px/49px 'Helvetica Neue'. Was normal normal normal normal 16px/18px Times.
+FAIL window.getComputedStyle(document.getElementById('test22')).font should be oblique normal normal normal 16px/18px Times. Was normal normal normal normal 16px/18px Times.
 PASS document.getElementById('test1').style.font is ""
 PASS document.getElementById('test15').style.font is "italic 100 48px/49px 'Helvetica Neue'"
 PASS document.getElementById('test16').style.font is "italic 100 48px/49px 'Helvetica Neue'"

Modified: trunk/Source/WebCore/ChangeLog (217271 => 217272)


--- trunk/Source/WebCore/ChangeLog	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/ChangeLog	2017-05-23 07:37:42 UTC (rev 217272)
@@ -1,5 +1,68 @@
 2017-05-22  Myles C. Maxfield  <mmaxfi...@apple.com>
 
+        Update font-style's implementation in the font selection algorithm
+        https://bugs.webkit.org/show_bug.cgi?id=169453
+
+        Reviewed by Simon Fraser.
+
+        Previously, we were treating "font-style: oblique" exactly the same as "font-style: italic".
+        These values were parsed to the same internal data type. However, variation fonts may have two
+        distinct axes: 'slnt' and 'ital'. Therefore, we need to keep a bool of state which represents
+        which of these two axes we should be setting when we apply font variations. We can do this by
+        making the "font-style" parser a "custom" parser. The implementation of these custom functions
+        will set both the italic value on the FontDescription as well as this extra bool.
+
+        We don't, however, want to treat these values as distinct for the purposese of font selection.
+        The fact that we treat oblique fonts the same as italic fonts is a feature, not a bug. Therefore,
+        the font selection algorithm is not made aware of this distinction. This is why we don't want to
+        package up the bool and FontSelectionValue into a class: font selection only cares about the
+        FontSelectionValue, so conceptually they shouldn't be joined. (The FontSelectionValue already
+        exists within a collection of all the things font selection needs to know about.)
+
+        Now that there is this extra bit of state on the FontDescription, we can do a little better when
+        computing the result of getComputedStyle(). Previously, we were always returning "italic" even
+        when "oblique" was specified. Now, we can return the correct one. However, this extra bit of
+        state is not kept on the CSSFontFace (because it doesn't need to be), which means we can only
+        improve the computed style of an element, rather than the cssText of an @font-face rule.
+
+        Test: fast/text/font-style-parse.html
+
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::ComputedStyleExtractor::fontStyleFromStyleValue):
+        (WebCore::fontStyleFromStyle):
+        (WebCore::fontShorthandValueForSelectionProperties):
+        * css/CSSComputedStyleDeclaration.h:
+        * css/CSSFontFaceSet.h:
+        * css/CSSProperties.json:
+        * css/FontFace.cpp:
+        (WebCore::FontFace::style):
+        * css/FontSelectionValueInlines.h:
+        (WebCore::fontStyleKeyword):
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::convertFontStyle): Deleted.
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyInitialFontStyle):
+        (WebCore::StyleBuilderCustom::applyInheritFontStyle):
+        (WebCore::StyleBuilderCustom::applyValueFontStyle):
+        * platform/graphics/FontCache.h:
+        (WebCore::FontDescriptionKey::makeFlagsKey):
+        * platform/graphics/FontDescription.cpp:
+        (WebCore::FontDescription::FontDescription):
+        * platform/graphics/FontDescription.h:
+        (WebCore::FontDescription::shouldUseItalicVariationAxis):
+        (WebCore::FontDescription::setShouldUseItalicVariationAxis):
+        (WebCore::FontDescription::operator==):
+        (WebCore::FontCascadeDescription::initialShouldUseItalicVariationAxis):
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::preparePlatformFont):
+        (WebCore::fontWithFamily):
+        (WebCore::FontCache::createFontPlatformData):
+        (WebCore::FontCache::systemFallbackForCharacters):
+        * platform/graphics/mac/FontCustomPlatformData.cpp:
+        (WebCore::FontCustomPlatformData::fontPlatformData):
+
+2017-05-22  Myles C. Maxfield  <mmaxfi...@apple.com>
+
         Support calc() in font-variation-settings and font-feature-settings
         https://bugs.webkit.org/show_bug.cgi?id=171032
 

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (217271 => 217272)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp	2017-05-23 07:37:42 UTC (rev 217272)
@@ -1967,9 +1967,9 @@
     return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique), CSSValuePool::singleton().createValue(static_cast<float>(italic), CSSPrimitiveValue::CSS_DEG));
 }
 
-Ref<CSSFontStyleValue> ComputedStyleExtractor::fontStyleFromStyleValue(FontSelectionValue italic)
+Ref<CSSFontStyleValue> ComputedStyleExtractor::fontStyleFromStyleValue(FontSelectionValue italic, FontStyleAxis fontStyleAxis)
 {
-    if (auto keyword = fontStyleKeyword(italic))
+    if (auto keyword = fontStyleKeyword(italic, fontStyleAxis))
         return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(keyword.value()));
     return fontNonKeywordStyleFromStyleValue(italic);
 }
@@ -1976,7 +1976,7 @@
 
 static Ref<CSSFontStyleValue> fontStyleFromStyle(const RenderStyle& style)
 {
-    return ComputedStyleExtractor::fontStyleFromStyleValue(style.fontDescription().italic());
+    return ComputedStyleExtractor::fontStyleFromStyleValue(style.fontDescription().italic(), style.fontDescription().fontStyleAxis());
 }
 
 static Ref<CSSValue> fontVariantFromStyle(const RenderStyle& style)
@@ -2610,7 +2610,7 @@
     else
         return CSSFontValue::create();
 
-    if (auto italic = fontStyleKeyword(fontDescription.italic()))
+    if (auto italic = fontStyleKeyword(fontDescription.italic(), fontDescription.fontStyleAxis()))
         computedFont->style = CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(italic.value()));
     else
         return CSSFontValue::create();

Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h (217271 => 217272)


--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.h	2017-05-23 07:37:42 UTC (rev 217272)
@@ -21,6 +21,7 @@
 #pragma once
 
 #include "CSSStyleDeclaration.h"
+#include "FontDescription.h"
 #include "RenderStyleConstants.h"
 #include "SVGRenderStyleDefs.h"
 #include <wtf/RefPtr.h>
@@ -71,7 +72,7 @@
     static Ref<CSSPrimitiveValue> fontNonKeywordStretchFromStyleValue(FontSelectionValue);
     static Ref<CSSPrimitiveValue> fontStretchFromStyleValue(FontSelectionValue);
     static Ref<CSSFontStyleValue> fontNonKeywordStyleFromStyleValue(FontSelectionValue);
-    static Ref<CSSFontStyleValue> fontStyleFromStyleValue(FontSelectionValue);
+    static Ref<CSSFontStyleValue> fontStyleFromStyleValue(FontSelectionValue, FontStyleAxis);
 
 private:
     // The styled element is either the element passed into computedPropertyValue, or the

Modified: trunk/Source/WebCore/css/CSSFontFaceSet.h (217271 => 217272)


--- trunk/Source/WebCore/css/CSSFontFaceSet.h	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/css/CSSFontFaceSet.h	2017-05-23 07:37:42 UTC (rev 217272)
@@ -52,10 +52,6 @@
     }
     ~CSSFontFaceSet();
 
-    static FontSelectionValue convertFontWeightFromValue(const CSSValue&);
-    static FontSelectionValue convertFontStretchFromValue(const CSSValue&);
-    static FontSelectionValue convertFontStyleFromValue(const CSSValue&);
-
     void addClient(CSSFontFaceSetClient&);
     void removeClient(CSSFontFaceSetClient&);
 

Modified: trunk/Source/WebCore/css/CSSProperties.json (217271 => 217272)


--- trunk/Source/WebCore/css/CSSProperties.json	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/css/CSSProperties.json	2017-05-23 07:37:42 UTC (rev 217272)
@@ -307,10 +307,9 @@
                 "oblique"
             ],
             "codegen-properties": {
-                "name-for-methods": "Italic",
+                "custom": "All",
                 "font-property": true,
-                "high-priority": true,
-                "converter": "FontStyle"
+                "high-priority": true
             },
             "specification": {
                 "category": "css-fonts",

Modified: trunk/Source/WebCore/css/FontFace.cpp (217271 => 217272)


--- trunk/Source/WebCore/css/FontFace.cpp	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/css/FontFace.cpp	2017-05-23 07:37:42 UTC (rev 217272)
@@ -289,8 +289,8 @@
     m_backing->updateStyleIfNeeded();
     auto style = m_backing->italic();
 
-    auto minimum = ComputedStyleExtractor::fontStyleFromStyleValue(style.minimum);
-    auto maximum = ComputedStyleExtractor::fontStyleFromStyleValue(style.maximum);
+    auto minimum = ComputedStyleExtractor::fontStyleFromStyleValue(style.minimum, FontStyleAxis::ital);
+    auto maximum = ComputedStyleExtractor::fontStyleFromStyleValue(style.maximum, FontStyleAxis::ital);
 
     if (minimum.get().equals(maximum.get()))
         return minimum->cssText();

Modified: trunk/Source/WebCore/css/FontSelectionValueInlines.h (217271 => 217272)


--- trunk/Source/WebCore/css/FontSelectionValueInlines.h	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/css/FontSelectionValueInlines.h	2017-05-23 07:37:42 UTC (rev 217272)
@@ -121,12 +121,12 @@
     }
 }
 
-inline std::optional<CSSValueID> fontStyleKeyword(FontSelectionValue style)
+inline std::optional<CSSValueID> fontStyleKeyword(FontSelectionValue style, FontStyleAxis axis)
 {
     if (style == normalItalicValue())
         return CSSValueNormal;
     if (style == italicValue())
-        return CSSValueItalic;
+        return axis == FontStyleAxis::ital ? CSSValueItalic : CSSValueOblique;
     return std::nullopt;
 }
 

Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (217271 => 217272)


--- trunk/Source/WebCore/css/StyleBuilderConverter.h	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h	2017-05-23 07:37:42 UTC (rev 217272)
@@ -1238,11 +1238,6 @@
     return convertFontStretchFromValue(value);
 }
 
-inline FontSelectionValue StyleBuilderConverter::convertFontStyle(StyleResolver&, const CSSValue& value)
-{
-    return convertFontStyleFromValue(value);
-}
-
 #if ENABLE(VARIATION_FONTS)
 inline FontVariationSettings StyleBuilderConverter::convertFontVariationSettings(StyleResolver&, const CSSValue& value)
 {

Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (217271 => 217272)


--- trunk/Source/WebCore/css/StyleBuilderCustom.h	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h	2017-05-23 07:37:42 UTC (rev 217272)
@@ -81,6 +81,7 @@
     DECLARE_PROPERTY_CUSTOM_HANDLERS(Fill);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(FontFamily);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(FontSize);
+    DECLARE_PROPERTY_CUSTOM_HANDLERS(FontStyle);
 #if ENABLE(CSS_IMAGE_RESOLUTION)
     DECLARE_PROPERTY_CUSTOM_HANDLERS(ImageResolution);
 #endif
@@ -1582,6 +1583,31 @@
     return 0.25f;
 }
 
+inline void StyleBuilderCustom::applyInitialFontStyle(StyleResolver& styleResolver)
+{
+    auto fontDescription = styleResolver.fontDescription();
+    fontDescription.setItalic(FontCascadeDescription::initialItalic());
+    fontDescription.setFontStyleAxis(FontCascadeDescription::initialFontStyleAxis());
+    styleResolver.setFontDescription(fontDescription);
+}
+
+inline void StyleBuilderCustom::applyInheritFontStyle(StyleResolver& styleResolver)
+{
+    auto fontDescription = styleResolver.fontDescription();
+    fontDescription.setItalic(styleResolver.parentFontDescription().italic());
+    fontDescription.setFontStyleAxis(styleResolver.parentFontDescription().fontStyleAxis());
+    styleResolver.setFontDescription(fontDescription);
+}
+
+inline void StyleBuilderCustom::applyValueFontStyle(StyleResolver& styleResolver, CSSValue& value)
+{
+    auto& fontStyleValue = downcast<CSSFontStyleValue>(value);
+    auto fontDescription = styleResolver.fontDescription();
+    fontDescription.setItalic(StyleBuilderConverter::convertFontStyleFromValue(fontStyleValue));
+    fontDescription.setFontStyleAxis(fontStyleValue.fontStyleValue->valueID() == CSSValueItalic ? FontStyleAxis::ital : FontStyleAxis::slnt);
+    styleResolver.setFontDescription(fontDescription);
+}
+
 inline void StyleBuilderCustom::applyValueFontSize(StyleResolver& styleResolver, CSSValue& value)
 {
     auto fontDescription = styleResolver.style()->fontDescription();

Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (217271 => 217272)


--- trunk/Source/WebCore/platform/graphics/FontCache.h	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h	2017-05-23 07:37:42 UTC (rev 217272)
@@ -122,7 +122,8 @@
     static std::array<unsigned, 2> makeFlagsKey(const FontDescription& description)
     {
         static_assert(USCRIPT_CODE_LIMIT < 0x1000, "Script code must fit in an unsigned along with the other flags");
-        unsigned first = static_cast<unsigned>(description.script()) << 12
+        unsigned first = static_cast<unsigned>(description.script()) << 13
+            | static_cast<unsigned>(description.fontStyleAxis() == FontStyleAxis::slnt) << 12
             | static_cast<unsigned>(description.opticalSizing()) << 11
             | static_cast<unsigned>(description.textRenderingMode()) << 9
             | static_cast<unsigned>(description.fontSynthesis()) << 6
@@ -275,7 +276,7 @@
     bool needsSyntheticOblique;
 };
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, TextRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const FontFeatureSettings& features, const FontVariantSettings&, FontSelectionRequest, const FontVariationSettings&, FontOpticalSizing, float size);
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef, TextRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const FontFeatureSettings& features, const FontVariantSettings&, FontSelectionRequest, const FontVariationSettings&, FontOpticalSizing, float size, FontStyleAxis);
 SynthesisPair computeNecessarySynthesis(CTFontRef, const FontDescription&, bool isPlatformFont = false);
 RetainPtr<CTFontRef> platformFontWithFamilySpecialCase(const AtomicString& family, FontSelectionRequest, float size);
 RetainPtr<CTFontRef> platformFontWithFamily(const AtomicString& family, FontSelectionRequest, TextRenderingMode, float size);

Modified: trunk/Source/WebCore/platform/graphics/FontDescription.cpp (217271 => 217272)


--- trunk/Source/WebCore/platform/graphics/FontDescription.cpp	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.cpp	2017-05-23 07:37:42 UTC (rev 217272)
@@ -78,6 +78,7 @@
     , m_variantEastAsianWidth(static_cast<unsigned>(FontVariantEastAsianWidth::Normal))
     , m_variantEastAsianRuby(static_cast<unsigned>(FontVariantEastAsianRuby::Normal))
     , m_opticalSizing(static_cast<unsigned>(FontOpticalSizing::Enabled))
+    , m_fontStyleAxis(FontCascadeDescription::initialFontStyleAxis() == FontStyleAxis::ital)
 {
 }
 

Modified: trunk/Source/WebCore/platform/graphics/FontDescription.h (217271 => 217272)


--- trunk/Source/WebCore/platform/graphics/FontDescription.h	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.h	2017-05-23 07:37:42 UTC (rev 217272)
@@ -96,6 +96,7 @@
             variantEastAsianRuby() };
     }
     FontOpticalSizing opticalSizing() const { return static_cast<FontOpticalSizing>(m_opticalSizing); }
+    FontStyleAxis fontStyleAxis() const { return m_fontStyleAxis ? FontStyleAxis::ital : FontStyleAxis::slnt; }
 
     void setComputedSize(float s) { m_computedSize = clampToFloat(s); }
     void setItalic(FontSelectionValue italic) { m_fontSelectionRequest.slope = italic; }
@@ -129,6 +130,7 @@
     void setVariantEastAsianWidth(FontVariantEastAsianWidth variant) { m_variantEastAsianWidth = static_cast<unsigned>(variant); }
     void setVariantEastAsianRuby(FontVariantEastAsianRuby variant) { m_variantEastAsianRuby = static_cast<unsigned>(variant); }
     void setOpticalSizing(FontOpticalSizing sizing) { m_opticalSizing = static_cast<unsigned>(sizing); }
+    void setFontStyleAxis(FontStyleAxis axis) { m_fontStyleAxis = axis == FontStyleAxis::ital; }
 
 private:
     // FIXME: Investigate moving these into their own object on the heap (to save memory).
@@ -161,6 +163,7 @@
     unsigned m_variantEastAsianWidth : 2; // FontVariantEastAsianWidth
     unsigned m_variantEastAsianRuby : 1; // FontVariantEastAsianRuby
     unsigned m_opticalSizing : 1; // FontOpticalSizing
+    unsigned m_fontStyleAxis : 1; // Whether "font-style: italic" or "font-style: oblique 20deg" was specified
 };
 
 inline bool FontDescription::operator==(const FontDescription& other) const
@@ -193,7 +196,8 @@
         && m_variantEastAsianVariant == other.m_variantEastAsianVariant
         && m_variantEastAsianWidth == other.m_variantEastAsianWidth
         && m_variantEastAsianRuby == other.m_variantEastAsianRuby
-        && m_opticalSizing == other.m_opticalSizing;
+        && m_opticalSizing == other.m_opticalSizing
+        && m_fontStyleAxis == other.m_fontStyleAxis;
 }
 
 // FIXME: Move to a file of its own.
@@ -265,6 +269,7 @@
 
     // Initial values for font properties.
     static FontSelectionValue initialItalic() { return normalItalicValue(); }
+    static FontStyleAxis initialFontStyleAxis() { return FontStyleAxis::slnt; }
     static FontSelectionValue initialWeight() { return normalWeightValue(); }
     static FontSelectionValue initialStretch() { return normalStretchValue(); }
     static FontSmallCaps initialSmallCaps() { return FontSmallCapsOff; }

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (217271 => 217272)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2017-05-23 07:37:42 UTC (rev 217272)
@@ -497,7 +497,7 @@
 }
 #endif
 
-RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const FontFeatureSettings& features, const FontVariantSettings& variantSettings, FontSelectionRequest fontSelectionRequest, const FontVariationSettings& variations, FontOpticalSizing fontOpticalSizing, float size)
+RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, TextRenderingMode textRenderingMode, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const FontFeatureSettings& features, const FontVariantSettings& variantSettings, FontSelectionRequest fontSelectionRequest, const FontVariationSettings& variations, FontOpticalSizing fontOpticalSizing, float size, FontStyleAxis axis)
 {
     bool alwaysAddVariations = false;
 
@@ -510,6 +510,7 @@
     UNUSED_PARAM(fontOpticalSizing);
     UNUSED_PARAM(fontFaceCapabilities);
     UNUSED_PARAM(size);
+    UNUSED_PARAM(axis);
 #endif
 
     if (!originalFont || (!features.size() && (!alwaysAddVariations && variations.isEmpty()) && (textRenderingMode == AutoTextRendering) && variantSettings.isAllNormal()
@@ -592,7 +593,10 @@
         }
         applyVariation({{'w', 'g', 'h', 't'}}, weight);
         applyVariation({{'w', 'd', 't', 'h'}}, width);
-        applyVariation({{'s', 'l', 'n', 't'}}, slope);
+        if (axis == FontStyleAxis::ital)
+            applyVariation({{'i', 't', 'a', 'l'}}, 1);
+        else
+            applyVariation({{'s', 'l', 'n', 't'}}, slope);
     }
 
     if (fontOpticalSizing == FontOpticalSizing::Enabled) {
@@ -1162,7 +1166,7 @@
     FontCache::singleton().invalidate();
 }
 
-static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, FontSelectionRequest request, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontVariationSettings& variationSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const TextRenderingMode& textRenderingMode, FontSelectionRequest fontSelectionRequest, FontOpticalSizing fontOpticalSizing, float size)
+static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, FontSelectionRequest request, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontVariationSettings& variationSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities, const TextRenderingMode& textRenderingMode, FontSelectionRequest fontSelectionRequest, FontOpticalSizing fontOpticalSizing, float size, FontStyleAxis axis)
 {
     if (family.isEmpty())
         return nullptr;
@@ -1170,7 +1174,7 @@
     auto foundFont = platformFontWithFamilySpecialCase(family, request, size);
     if (!foundFont)
         foundFont = platformFontLookupWithFamily(family, request, size);
-    return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, featureSettings, variantSettings, fontSelectionRequest, variationSettings, fontOpticalSizing, size);
+    return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, featureSettings, variantSettings, fontSelectionRequest, variationSettings, fontOpticalSizing, size, axis);
 }
 
 #if PLATFORM(MAC)
@@ -1209,7 +1213,7 @@
 {
     float size = fontDescription.computedPixelSize();
 
-    auto font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), fontDescription.opticalSizing(), size);
+    auto font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), fontDescription.opticalSizing(), size, fontDescription.fontStyleAxis());
 
 #if PLATFORM(MAC)
     if (!font) {
@@ -1220,7 +1224,7 @@
         // Ignore the result because we want to use our own algorithm to actually find the font.
         autoActivateFont(family.string(), size);
 
-        font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), fontDescription.opticalSizing(), size);
+        font = fontWithFamily(family, fontDescription.fontSelectionRequest(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.variationSettings(), fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities, fontDescription.textRenderingMode(), fontDescription.fontSelectionRequest(), fontDescription.opticalSizing(), size, fontDescription.fontStyleAxis());
     }
 #endif
 
@@ -1308,7 +1312,7 @@
 
     const FontPlatformData& platformData = originalFontData->platformData();
     auto result = lookupFallbackFont(platformData.font(), description.weight(), description.locale(), characters, length);
-    result = preparePlatformFont(result.get(), description.textRenderingMode(), nullptr, nullptr, { }, description.featureSettings(), description.variantSettings(), description.fontSelectionRequest(), description.variationSettings(), description.opticalSizing(), description.computedSize());
+    result = preparePlatformFont(result.get(), description.textRenderingMode(), nullptr, nullptr, { }, description.featureSettings(), description.variantSettings(), description.fontSelectionRequest(), description.variationSettings(), description.opticalSizing(), description.computedSize(), description.fontStyleAxis());
     if (!result)
         return lastResortFallbackFont(description);
 

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp (217271 => 217272)


--- trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp	2017-05-23 07:37:42 UTC (rev 217272)
@@ -40,7 +40,7 @@
     FontOrientation orientation = fontDescription.orientation();
     FontWidthVariant widthVariant = fontDescription.widthVariant();
     RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(m_fontDescriptor.get(), size, nullptr));
-    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), &fontFaceFeatures, &fontFaceVariantSettings, fontFaceCapabilities, fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.fontSelectionRequest(), fontDescription.variationSettings(), fontDescription.opticalSizing(), fontDescription.computedSize());
+    font = preparePlatformFont(font.get(), fontDescription.textRenderingMode(), &fontFaceFeatures, &fontFaceVariantSettings, fontFaceCapabilities, fontDescription.featureSettings(), fontDescription.variantSettings(), fontDescription.fontSelectionRequest(), fontDescription.variationSettings(), fontDescription.opticalSizing(), fontDescription.computedSize(), fontDescription.fontStyleAxis());
     ASSERT(font);
     return FontPlatformData(font.get(), size, bold, italic, orientation, widthVariant, fontDescription.textRenderingMode());
 }

Modified: trunk/Source/WebCore/platform/text/TextFlags.h (217271 => 217272)


--- trunk/Source/WebCore/platform/text/TextFlags.h	2017-05-23 07:21:21 UTC (rev 217271)
+++ trunk/Source/WebCore/platform/text/TextFlags.h	2017-05-23 07:37:42 UTC (rev 217272)
@@ -356,4 +356,10 @@
     Disabled
 };
 
+// https://www.microsoft.com/typography/otspec/fvar.htm#VAT
+enum class FontStyleAxis {
+    slnt,
+    ital
+};
+
 }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to