Changeset 220997 in webkit


Ignore:
Timestamp:
Aug 21, 2017 6:50:34 PM (7 years ago)
Author:
mmaxfield@apple.com
Message:

DataInteractionTests.ExternalSourceAttributedStringToContentEditable hits a debug assertion
https://bugs.webkit.org/show_bug.cgi?id=175787
<rdar://problem/33996612>

Reviewed by Wenson Hsieh.

Source/WebCore:

The variation axis values of San Francisco changed from the GX-style scale to the CSS-style
scale. Previously, we were normalizing the values we got from Core Text to fit the CSS scale;
however, this is no longer necessary since the font now does this itself.

The assertion was getting hit because the normalized values were huge and were overflowing
a single FontSelectionValue (and going negative). This patch adds handling for this
situation.

Test: DataInteractionTests.ExternalSourceBoldSystemAttributedStringToContentEditable

  • platform/graphics/FontSelectionAlgorithm.h: Typedef the backing type for a FontSelectionValue.

(WebCore::FontSelectionValue::rawValue const):
(WebCore::FontSelectionValue::maximumValue):
(WebCore::FontSelectionValue::minimumValue):
(WebCore::FontSelectionValue::FontSelectionValue):

  • platform/graphics/cocoa/FontCacheCoreText.cpp: Opt-out of normalization for San Francisco.

(WebCore::variationCapabilitiesForFontDescriptor):
(WebCore::capabilitiesForFontDescriptor):

Tools:

  • TestWebKitAPI/Tests/ios/DataInteractionTests.mm:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r220996 r220997  
     12017-08-21  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        DataInteractionTests.ExternalSourceAttributedStringToContentEditable hits a debug assertion
     4        https://bugs.webkit.org/show_bug.cgi?id=175787
     5        <rdar://problem/33996612>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        The variation axis values of San Francisco changed from the GX-style scale to the CSS-style
     10        scale. Previously, we were normalizing the values we got from Core Text to fit the CSS scale;
     11        however, this is no longer necessary since the font now does this itself.
     12
     13        The assertion was getting hit because the normalized values were huge and were overflowing
     14        a single FontSelectionValue (and going negative). This patch adds handling for this
     15        situation.
     16
     17        Test: DataInteractionTests.ExternalSourceBoldSystemAttributedStringToContentEditable
     18
     19        * platform/graphics/FontSelectionAlgorithm.h: Typedef the backing type for a FontSelectionValue.
     20        (WebCore::FontSelectionValue::rawValue const):
     21        (WebCore::FontSelectionValue::maximumValue):
     22        (WebCore::FontSelectionValue::minimumValue):
     23        (WebCore::FontSelectionValue::FontSelectionValue):
     24        * platform/graphics/cocoa/FontCacheCoreText.cpp: Opt-out of normalization for San Francisco.
     25        (WebCore::variationCapabilitiesForFontDescriptor):
     26        (WebCore::capabilitiesForFontDescriptor):
     27
    1282017-08-21  Chris Dumez  <cdumez@apple.com>
    229
  • trunk/Source/WebCore/platform/graphics/FontSelectionAlgorithm.h

    r218464 r220997  
    4141class FontSelectionValue {
    4242public:
     43    typedef int16_t BackingType;
     44
    4345    FontSelectionValue() = default;
    4446
     
    7375    bool operator>=(const FontSelectionValue other) const;
    7476
    75     int16_t rawValue() const
     77    BackingType rawValue() const
    7678    {
    7779        return m_backing;
     
    8082    static FontSelectionValue maximumValue()
    8183    {
    82         static NeverDestroyed<FontSelectionValue> result = FontSelectionValue(std::numeric_limits<int16_t>::max(), RawTag::RawTag);
     84        static NeverDestroyed<FontSelectionValue> result = FontSelectionValue(std::numeric_limits<BackingType>::max(), RawTag::RawTag);
    8385        return result.get();
    8486    }
     
    8688    static FontSelectionValue minimumValue()
    8789    {
    88         static NeverDestroyed<FontSelectionValue> result = FontSelectionValue(std::numeric_limits<int16_t>::min(), RawTag::RawTag);
     90        static NeverDestroyed<FontSelectionValue> result = FontSelectionValue(std::numeric_limits<BackingType>::min(), RawTag::RawTag);
    8991        return result.get();
    9092    }
     
    102104    enum class RawTag { RawTag };
    103105
    104     FontSelectionValue(int16_t rawValue, RawTag)
     106    FontSelectionValue(BackingType rawValue, RawTag)
    105107        : m_backing(rawValue)
    106108    {
     
    108110
    109111    static constexpr int fractionalEntropy = 4;
    110     int16_t m_backing { 0 };
     112    BackingType m_backing { 0 };
    111113};
    112114
  • trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp

    r220506 r220997  
    999999    }
    10001000
    1001     if (FontType(font.get()).variationType == FontType::VariationType::TrueTypeGX) {
     1001    bool optOutFromGXNormalization = false;
     1002#if ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000))
     1003    optOutFromGXNormalization = CTFontDescriptorIsSystemUIFont(fontDescriptor);
     1004#endif
     1005
     1006    if (FontType(font.get()).variationType == FontType::VariationType::TrueTypeGX && !optOutFromGXNormalization) {
    10021007        if (result.weight)
    10031008            result.weight = {{ normalizeWeight(result.weight.value().minimum), normalizeWeight(result.weight.value().maximum) }};
     
    10071012            result.slope = {{ normalizeSlope(result.slope.value().minimum), normalizeSlope(result.slope.value().maximum) }};
    10081013    }
     1014
     1015    auto minimum = static_cast<float>(FontSelectionValue::minimumValue());
     1016    auto maximum = static_cast<float>(FontSelectionValue::maximumValue());
     1017    if (result.weight && (result.weight.value().minimum < minimum || result.weight.value().maximum > maximum))
     1018        result.weight = { };
     1019    if (result.width && (result.width.value().minimum < minimum || result.width.value().maximum > maximum))
     1020        result.width = { };
     1021    if (result.slope && (result.slope.value().minimum < minimum || result.slope.value().maximum > maximum))
     1022        result.slope = { };
    10091023#else
    10101024    UNUSED_PARAM(fontDescriptor);
     
    10921106#endif
    10931107
    1094     return {{ FontSelectionValue(variationCapabilities.weight.value().minimum), FontSelectionValue(variationCapabilities.weight.value().maximum) },
     1108    FontSelectionCapabilities result = {{ FontSelectionValue(variationCapabilities.weight.value().minimum), FontSelectionValue(variationCapabilities.weight.value().maximum) },
    10951109        { FontSelectionValue(variationCapabilities.width.value().minimum), FontSelectionValue(variationCapabilities.width.value().maximum) },
    10961110        { FontSelectionValue(variationCapabilities.slope.value().minimum), FontSelectionValue(variationCapabilities.slope.value().maximum) }};
     1111    ASSERT(result.weight.isValid());
     1112    ASSERT(result.width.isValid());
     1113    ASSERT(result.slope.isValid());
     1114    return result;
    10971115}
    10981116
  • trunk/Tools/ChangeLog

    r220991 r220997  
     12017-08-21  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        DataInteractionTests.ExternalSourceAttributedStringToContentEditable hits a debug assertion
     4        https://bugs.webkit.org/show_bug.cgi?id=175787
     5        <rdar://problem/33996612>
     6
     7        Reviewed by Wenson Hsieh.
     8
     9        * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
     10        (TestWebKitAPI::TEST):
     11
    1122017-08-21  Myles C. Maxfield  <mmaxfield@apple.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm

    r220952 r220997  
    686686}
    687687
    688 TEST(DataInteractionTests, DISABLED_ExternalSourceBoldSystemAttributedStringToContentEditable)
     688TEST(DataInteractionTests, ExternalSourceBoldSystemAttributedStringToContentEditable)
    689689{
    690690    auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
Note: See TracChangeset for help on using the changeset viewer.