Changeset 214546 in webkit


Ignore:
Timestamp:
Mar 29, 2017 10:40:21 AM (7 years ago)
Author:
mmaxfield@apple.com
Message:

Variation fonts: Make sure that feature detection and preprocessor macros are right
https://bugs.webkit.org/show_bug.cgi?id=169518

Reviewed by Simon Fraser.

Source/WebCore:

When I added variable fonts support, I made all OSes parse the newly accepted values,
instead of just the OSes which support variable fonts.

Test: fast/text/font-variations-feature-detection.html

  • css/parser/CSSPropertyParser.cpp:

(WebCore::consumeFontStretch):
(WebCore::consumeFontStyle):

  • css/parser/CSSPropertyParserHelpers.cpp:

(WebCore::CSSPropertyParserHelpers::divisibleBy100):
(WebCore::CSSPropertyParserHelpers::consumeFontWeightNumber):

LayoutTests:

Create platform-specific results for mac-elcapitan which doesn't support variation fonts.

  • fast/text/font-variations-feature-detection-expected.html: Added.
  • fast/text/font-variations-feature-detection.html: Added.
  • platform/ios-simulator/TestExpectations:
  • platform/mac-elcapitan/fast/text/font-selection-font-face-parse-expected.txt:
  • platform/mac-elcapitan/fast/text/font-selection-font-loading-api-parse-expected.txt: Added.
  • platform/mac-elcapitan/fast/text/font-stretch-parse-expected.txt: Added.
  • platform/mac-elcapitan/fast/text/font-style-parse-expected.txt: Added.
  • platform/mac-elcapitan/fast/text/font-weight-parse-expected.txt: Added.
  • platform/mac/TestExpectations:
Location:
trunk
Files:
6 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r214545 r214546  
     12017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Variation fonts: Make sure that feature detection and preprocessor macros are right
     4        https://bugs.webkit.org/show_bug.cgi?id=169518
     5
     6        Reviewed by Simon Fraser.
     7
     8        Create platform-specific results for mac-elcapitan which doesn't support variation fonts.
     9
     10        * fast/text/font-variations-feature-detection-expected.html: Added.
     11        * fast/text/font-variations-feature-detection.html: Added.
     12        * platform/ios-simulator/TestExpectations:
     13        * platform/mac-elcapitan/fast/text/font-selection-font-face-parse-expected.txt:
     14        * platform/mac-elcapitan/fast/text/font-selection-font-loading-api-parse-expected.txt: Added.
     15        * platform/mac-elcapitan/fast/text/font-stretch-parse-expected.txt: Added.
     16        * platform/mac-elcapitan/fast/text/font-style-parse-expected.txt: Added.
     17        * platform/mac-elcapitan/fast/text/font-weight-parse-expected.txt: Added.
     18        * platform/mac/TestExpectations:
     19
    1202017-03-29  Antoine Quint  <graouts@apple.com>
    221
  • trunk/LayoutTests/platform/ios/TestExpectations

    r214506 r214546  
    27432743webkit.org/b/163093 fast/text/variations/outofbounds.html [ ImageOnlyFailure ]
    27442744webkit.org/b/163093 fast/text/variations/default-value.html [ ImageOnlyFailure ]
     2745webkit.org/b/169518 fast/text/font-variations-feature-detection.html [ ImageOnlyFailure ]
    27452746
    27462747webkit.org/b/162647 http/tests/xmlhttprequest/onabort-response-getters.html [ Pass Failure ]
  • trunk/LayoutTests/platform/mac-elcapitan/fast/text/font-selection-font-face-parse-expected.txt

    r214507 r214546  
    1 PASS weightTestSheet.cssRules[0].style.fontWeight is "1"
     1FAIL weightTestSheet.cssRules[0].style.fontWeight should be 1. Was .
    22PASS weightTestSheet.cssRules[1].style.fontWeight is "100"
    33PASS weightTestSheet.cssRules[2].style.fontWeight is "200"
     
    1414PASS weightTestSheet.cssRules[13].style.fontWeight is ""
    1515PASS weightTestSheet.cssRules[14].style.fontWeight is ""
    16 PASS weightTestSheet.cssRules[15].style.fontWeight is "7"
     16FAIL weightTestSheet.cssRules[15].style.fontWeight should be 7. Was .
    1717PASS weightTestSheet.cssRules[16].style.fontWeight is "300"
    1818PASS weightTestSheet.cssRules[17].style.fontWeight is "200"
     
    3030FAIL weightTestSheet.cssRules[29].style.fontWeight should be 7 8. Was .
    3131FAIL weightTestSheet.cssRules[30].style.fontWeight should be 2 7. Was .
    32 PASS stretchTestSheet.cssRules[0].style.fontStretch is "1%"
     32FAIL stretchTestSheet.cssRules[0].style.fontStretch should be 1%. Was .
    3333PASS stretchTestSheet.cssRules[1].style.fontStretch is ""
    3434PASS stretchTestSheet.cssRules[2].style.fontStretch is "ultra-condensed"
     
    7272FAIL stretchTestSheet.cssRules[40].style.fontStretch should be calc(7%) 8%. Was .
    7373FAIL stretchTestSheet.cssRules[41].style.fontStretch should be 2% calc(7%). Was .
    74 PASS styleTestSheet.cssRules[0].style.fontStyle is "oblique 1deg"
    75 PASS styleTestSheet.cssRules[1].style.fontStyle is "oblique 20grad"
    76 PASS styleTestSheet.cssRules[2].style.fontStyle is "oblique 0.28318rad"
    77 PASS styleTestSheet.cssRules[3].style.fontStyle is "oblique 0.04turn"
     74FAIL styleTestSheet.cssRules[0].style.fontStyle should be oblique 1deg. Was .
     75FAIL styleTestSheet.cssRules[1].style.fontStyle should be oblique 20grad. Was .
     76FAIL styleTestSheet.cssRules[2].style.fontStyle should be oblique 0.28318rad. Was .
     77FAIL styleTestSheet.cssRules[3].style.fontStyle should be oblique 0.04turn. Was .
    7878PASS styleTestSheet.cssRules[4].style.fontStyle is ""
    7979PASS styleTestSheet.cssRules[5].style.fontStyle is ""
     
    8484PASS styleTestSheet.cssRules[10].style.fontStyle is ""
    8585PASS styleTestSheet.cssRules[11].style.fontStyle is ""
    86 PASS styleTestSheet.cssRules[12].style.fontStyle is "oblique calc(15.4deg)"
     86FAIL styleTestSheet.cssRules[12].style.fontStyle should be oblique calc(15.4deg). Was .
    8787PASS styleTestSheet.cssRules[13].style.fontStyle is ""
    8888PASS styleTestSheet.cssRules[14].style.fontStyle is ""
  • trunk/LayoutTests/platform/mac/TestExpectations

    r214539 r214546  
    14321432[ ElCapitan Yosemite ] animations/font-variations [ Pass Failure ImageOnlyFailure ]
    14331433
     1434# This test makes sure that variation fonts are disabled on OSes which don't support them. So,
     1435# the test should be skipped on OSes which do support them. As soon as all OSes support them,
     1436# we should delete the test.
     1437[ Sierra+ ] fast/text/font-variations-feature-detection.html [ ImageOnlyFailure ]
     1438
    14341439[ Debug ] fast/selectors/slow-style-sharing-with-long-cousin-list.html [ Skip ]
    14351440
  • trunk/Source/WebCore/ChangeLog

    r214545 r214546  
     12017-03-29  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        Variation fonts: Make sure that feature detection and preprocessor macros are right
     4        https://bugs.webkit.org/show_bug.cgi?id=169518
     5
     6        Reviewed by Simon Fraser.
     7
     8        When I added variable fonts support, I made all OSes parse the newly accepted values,
     9        instead of just the OSes which support variable fonts.
     10
     11        Test: fast/text/font-variations-feature-detection.html
     12
     13        * css/parser/CSSPropertyParser.cpp:
     14        (WebCore::consumeFontStretch):
     15        (WebCore::consumeFontStyle):
     16        * css/parser/CSSPropertyParserHelpers.cpp:
     17        (WebCore::CSSPropertyParserHelpers::divisibleBy100):
     18        (WebCore::CSSPropertyParserHelpers::consumeFontWeightNumber):
     19
    1202017-03-29  Antoine Quint  <graouts@apple.com>
    221
  • trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp

    r214507 r214546  
    904904}
    905905
     906#if ENABLE(VARIATION_FONTS)
    906907static bool fontStretchIsWithinRange(float stretch)
    907908{
    908909    return stretch > 0;
    909910}
     911#endif
    910912
    911913static RefPtr<CSSPrimitiveValue> consumeFontStretch(CSSParserTokenRange& range)
     
    913915    if (auto result = consumeFontStretchKeywordValue(range))
    914916        return result;
     917#if ENABLE(VARIATION_FONTS)
    915918    if (auto percent = consumePercent(range, ValueRangeNonNegative))
    916919        return fontStretchIsWithinRange(percent->value<float>()) ? percent : nullptr;
     920#endif
    917921    return nullptr;
    918922}
     
    943947}
    944948
     949#if ENABLE(VARIATION_FONTS)
    945950static bool fontStyleIsWithinRange(float oblique)
    946951{
    947952    return oblique > -90 && oblique < 90;
    948953}
     954#endif
    949955
    950956static RefPtr<CSSFontStyleValue> consumeFontStyle(CSSParserTokenRange& range, CSSParserMode cssParserMode)
     
    954960        return nullptr;
    955961
    956     if (result->valueID() == CSSValueNormal)
    957         return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueNormal));
    958     if (result->valueID() == CSSValueItalic)
    959         return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueItalic));
     962    auto valueID = result->valueID();
     963    if (valueID == CSSValueNormal || valueID == CSSValueItalic)
     964        return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(valueID));
    960965    ASSERT(result->valueID() == CSSValueOblique);
    961     if (range.atEnd())
    962         return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique));
    963     if (auto angle = consumeAngle(range, cssParserMode)) {
    964         if (fontStyleIsWithinRange(angle->value<float>(CSSPrimitiveValue::CSS_DEG)))
    965             return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique), WTFMove(angle));
    966         return nullptr;
    967     }
     966#if ENABLE(VARIATION_FONTS)
     967    if (!range.atEnd()) {
     968        if (auto angle = consumeAngle(range, cssParserMode)) {
     969            if (fontStyleIsWithinRange(angle->value<float>(CSSPrimitiveValue::CSS_DEG)))
     970                return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique), WTFMove(angle));
     971            return nullptr;
     972        }
     973    }
     974#else
     975    UNUSED_PARAM(cssParserMode);
     976#endif
    968977    return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique));
    969978}
  • trunk/Source/WebCore/css/parser/CSSPropertyParserHelpers.cpp

    r214324 r214546  
    198198}
    199199
     200#if !ENABLE(VARIATION_FONTS)
     201static inline bool divisibleBy100(double value)
     202{
     203    return static_cast<int>(value / 100) * 100 == value;
     204}
     205#endif
     206
    200207RefPtr<CSSPrimitiveValue> consumeFontWeightNumber(CSSParserTokenRange& range)
    201208{
    202209    // Values less than or equal to 0 or greater than or equal to 1000 are parse errors.
    203210    auto& token = range.peek();
    204     if (token.type() == NumberToken && token.numericValue() > 0 && token.numericValue() < 1000)
     211    if (token.type() == NumberToken && token.numericValue() > 0 && token.numericValue() < 1000
     212#if !ENABLE(VARIATION_FONTS)
     213        && token.numericValueType() == IntegerValueType && divisibleBy100(token.numericValue())
     214#endif
     215    )
    205216        return consumeNumber(range, ValueRangeAll);
    206217
     
    208219    CalcParser calcParser(range, ValueRangeAll);
    209220    double result;
    210     if (calcParser.consumeNumberRaw(result)) {
     221    if (calcParser.consumeNumberRaw(result)
     222#if !ENABLE(VARIATION_FONTS)
     223        && result > 0 && result < 1000 && divisibleBy100(result)
     224#endif
     225    ) {
    211226        result = std::min(std::max(result, std::nextafter(0., 1.)), std::nextafter(1000., 0.));
    212227        return CSSValuePool::singleton().createValue(result, CSSPrimitiveValue::UnitType::CSS_NUMBER);
Note: See TracChangeset for help on using the changeset viewer.