- Revision
- 220997
- Author
- mmaxfi...@apple.com
- Date
- 2017-08-21 18:50:34 -0700 (Mon, 21 Aug 2017)
Log 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):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (220996 => 220997)
--- trunk/Source/WebCore/ChangeLog 2017-08-22 01:32:24 UTC (rev 220996)
+++ trunk/Source/WebCore/ChangeLog 2017-08-22 01:50:34 UTC (rev 220997)
@@ -1,3 +1,30 @@
+2017-08-21 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ DataInteractionTests.ExternalSourceAttributedStringToContentEditable hits a debug assertion
+ https://bugs.webkit.org/show_bug.cgi?id=175787
+ <rdar://problem/33996612>
+
+ Reviewed by Wenson Hsieh.
+
+ 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):
+
2017-08-21 Chris Dumez <cdu...@apple.com>
[Beacon] Content extensions should be able to intercept Beacon / Ping redirects
Modified: trunk/Source/WebCore/platform/graphics/FontSelectionAlgorithm.h (220996 => 220997)
--- trunk/Source/WebCore/platform/graphics/FontSelectionAlgorithm.h 2017-08-22 01:32:24 UTC (rev 220996)
+++ trunk/Source/WebCore/platform/graphics/FontSelectionAlgorithm.h 2017-08-22 01:50:34 UTC (rev 220997)
@@ -40,6 +40,8 @@
// the maximum representable value is 8191.75, and the minimum representable value is -8192.
class FontSelectionValue {
public:
+ typedef int16_t BackingType;
+
FontSelectionValue() = default;
// Explicit because it is lossy.
@@ -72,7 +74,7 @@
bool operator>(const FontSelectionValue other) const;
bool operator>=(const FontSelectionValue other) const;
- int16_t rawValue() const
+ BackingType rawValue() const
{
return m_backing;
}
@@ -79,13 +81,13 @@
static FontSelectionValue maximumValue()
{
- static NeverDestroyed<FontSelectionValue> result = FontSelectionValue(std::numeric_limits<int16_t>::max(), RawTag::RawTag);
+ static NeverDestroyed<FontSelectionValue> result = FontSelectionValue(std::numeric_limits<BackingType>::max(), RawTag::RawTag);
return result.get();
}
static FontSelectionValue minimumValue()
{
- static NeverDestroyed<FontSelectionValue> result = FontSelectionValue(std::numeric_limits<int16_t>::min(), RawTag::RawTag);
+ static NeverDestroyed<FontSelectionValue> result = FontSelectionValue(std::numeric_limits<BackingType>::min(), RawTag::RawTag);
return result.get();
}
@@ -101,13 +103,13 @@
private:
enum class RawTag { RawTag };
- FontSelectionValue(int16_t rawValue, RawTag)
+ FontSelectionValue(BackingType rawValue, RawTag)
: m_backing(rawValue)
{
}
static constexpr int fractionalEntropy = 4;
- int16_t m_backing { 0 };
+ BackingType m_backing { 0 };
};
inline FontSelectionValue FontSelectionValue::operator+(const FontSelectionValue other) const
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (220996 => 220997)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2017-08-22 01:32:24 UTC (rev 220996)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2017-08-22 01:50:34 UTC (rev 220997)
@@ -998,7 +998,12 @@
result.slope = extractVariationBounds(axis);
}
- if (FontType(font.get()).variationType == FontType::VariationType::TrueTypeGX) {
+ bool optOutFromGXNormalization = false;
+#if ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110000))
+ optOutFromGXNormalization = CTFontDescriptorIsSystemUIFont(fontDescriptor);
+#endif
+
+ if (FontType(font.get()).variationType == FontType::VariationType::TrueTypeGX && !optOutFromGXNormalization) {
if (result.weight)
result.weight = {{ normalizeWeight(result.weight.value().minimum), normalizeWeight(result.weight.value().maximum) }};
if (result.width)
@@ -1006,6 +1011,15 @@
if (result.slope)
result.slope = {{ normalizeSlope(result.slope.value().minimum), normalizeSlope(result.slope.value().maximum) }};
}
+
+ auto minimum = static_cast<float>(FontSelectionValue::minimumValue());
+ auto maximum = static_cast<float>(FontSelectionValue::maximumValue());
+ if (result.weight && (result.weight.value().minimum < minimum || result.weight.value().maximum > maximum))
+ result.weight = { };
+ if (result.width && (result.width.value().minimum < minimum || result.width.value().maximum > maximum))
+ result.width = { };
+ if (result.slope && (result.slope.value().minimum < minimum || result.slope.value().maximum > maximum))
+ result.slope = { };
#else
UNUSED_PARAM(fontDescriptor);
#endif
@@ -1091,9 +1105,13 @@
}
#endif
- return {{ FontSelectionValue(variationCapabilities.weight.value().minimum), FontSelectionValue(variationCapabilities.weight.value().maximum) },
+ FontSelectionCapabilities result = {{ FontSelectionValue(variationCapabilities.weight.value().minimum), FontSelectionValue(variationCapabilities.weight.value().maximum) },
{ FontSelectionValue(variationCapabilities.width.value().minimum), FontSelectionValue(variationCapabilities.width.value().maximum) },
{ FontSelectionValue(variationCapabilities.slope.value().minimum), FontSelectionValue(variationCapabilities.slope.value().maximum) }};
+ ASSERT(result.weight.isValid());
+ ASSERT(result.width.isValid());
+ ASSERT(result.slope.isValid());
+ return result;
}
#if !SHOULD_USE_CORE_TEXT_FONT_LOOKUP
Modified: trunk/Tools/ChangeLog (220996 => 220997)
--- trunk/Tools/ChangeLog 2017-08-22 01:32:24 UTC (rev 220996)
+++ trunk/Tools/ChangeLog 2017-08-22 01:50:34 UTC (rev 220997)
@@ -1,5 +1,16 @@
2017-08-21 Myles C. Maxfield <mmaxfi...@apple.com>
+ DataInteractionTests.ExternalSourceAttributedStringToContentEditable hits a debug assertion
+ https://bugs.webkit.org/show_bug.cgi?id=175787
+ <rdar://problem/33996612>
+
+ Reviewed by Wenson Hsieh.
+
+ * TestWebKitAPI/Tests/ios/DataInteractionTests.mm:
+ (TestWebKitAPI::TEST):
+
+2017-08-21 Myles C. Maxfield <mmaxfi...@apple.com>
+
Typo in "webkit-patch land"
https://bugs.webkit.org/show_bug.cgi?id=175788
Modified: trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm (220996 => 220997)
--- trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-08-22 01:32:24 UTC (rev 220996)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/DataInteractionTests.mm 2017-08-22 01:50:34 UTC (rev 220997)
@@ -685,7 +685,7 @@
EXPECT_TRUE([webView stringByEvaluatingJavaScript:@"!!editor.querySelector('h1')"].boolValue);
}
-TEST(DataInteractionTests, DISABLED_ExternalSourceBoldSystemAttributedStringToContentEditable)
+TEST(DataInteractionTests, ExternalSourceBoldSystemAttributedStringToContentEditable)
{
auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
[webView synchronouslyLoadTestPageNamed:@"autofocus-contenteditable"];