font-weight in @font-face can cause a font to be downloaded even when it's not used
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Feb 2017 01:28:00 +0000 (01:28 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 17 Feb 2017 01:28:00 +0000 (01:28 +0000)
https://bugs.webkit.org/show_bug.cgi?id=168114
<rdar://problem/30301317>

Reviewed by Darin Adler.

Source/WebCore:

There were two problems with our font loading code.

When we are in the middle of a download, we will use a special interstitial font,
and this special font has a flag set which will cause it to be invisible when it is
drawn. However, when we start using this font during the load, we give it a
unicode-range of U+0-0 which means that it will never be used, and fallback will
happen to other weights immediately.

The second problem with the font loading code is that this interstital font is just
Times. Times doesn't support every character, which means that if we are trying
to render some exotic character, we fall back to other weights. The solution here
is to use LastResort as the interstitial font, because it supports all characters.
Because its metrics are reasonable and we don't ever actually paint this
interstitial font, this choice is no worse than Times.

Tests: fast/text/font-style-download.html
       fast/text/font-weight-download-2.html
       fast/text/font-weight-download.html
       fast/text/font-weight-fallback.html

* css/CSSFontFace.cpp:
(WebCore::CSSFontFace::font):
* css/CSSSegmentedFontFace.cpp:
(WebCore::appendFont):
(WebCore::CSSSegmentedFontFace::fontRanges):
(WebCore::appendFontWithInvalidUnicodeRangeIfLoading): Deleted.
* platform/graphics/Font.h:
(WebCore::Font::widthForGlyph):
* platform/graphics/FontCache.h:
* platform/graphics/freetype/FontCacheFreeType.cpp:
(WebCore::FontCache::lastResortFallbackFontForEveryCharacter):
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::FontCache::lastResortFallbackFontForEveryCharacter):
* platform/graphics/win/FontCacheWin.cpp:
(WebCore::FontCache::lastResortFallbackFontForEveryCharacter):

Tools:

LastResort needs to be usable in tests.

* DumpRenderTree/mac/DumpRenderTree.mm:
(allowedFontFamilySet):
* WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
(WTR::allowedFontFamilySet):
* WebKitTestRunner/mac/TestControllerMac.mm:
(WTR::allowedFontFamilySet):

LayoutTests:

* fast/text/font-style-download-expected.txt: Added.
* fast/text/font-style-download.html: Added.
* fast/text/font-weight-download-2-expected.txt: Added.
* fast/text/font-weight-download-2.html: Added.
* fast/text/font-weight-download-expected.txt: Added.
* fast/text/font-weight-download.html: Added.
* fast/text/font-weight-fallback-expected.html: Added.
* fast/text/font-weight-fallback.html: Added.
* http/tests/webfont/fallback-font-while-loading-expected.txt: We don't want to use the
fallback font while an earlier font is loading because the fallback font might require
an extra download. This represents a policy change.
* http/tests/webfont/fallback-font-while-loading.html: Ditto.
* resources/Ahem_CJK.ttf: Added.
* svg/W3C-SVG-1.1-SE/struct-dom-11-f.svg: The metrics of LastResort are different from
the metrics of the previous interstitial font, which means the new font causes elements
to intersect when they previously didn't. However, the web font isn't actually necessary
here, so we can just stop using it, thereby sidestepping the entire problem.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@212513 268f45cc-cd09-0410-ab3c-d52691b4dbfc

25 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/font-style-download-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/font-style-download.html [new file with mode: 0644]
LayoutTests/fast/text/font-weight-download-2-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/font-weight-download-2.html [new file with mode: 0644]
LayoutTests/fast/text/font-weight-download-expected.txt [new file with mode: 0644]
LayoutTests/fast/text/font-weight-download.html [new file with mode: 0644]
LayoutTests/fast/text/font-weight-fallback-expected.html [new file with mode: 0644]
LayoutTests/fast/text/font-weight-fallback.html [new file with mode: 0644]
LayoutTests/http/tests/webfont/fallback-font-while-loading-expected.txt
LayoutTests/http/tests/webfont/fallback-font-while-loading.html
LayoutTests/resources/Ahem_CJK.ttf [new file with mode: 0644]
LayoutTests/svg/W3C-SVG-1.1-SE/struct-dom-11-f.svg
Source/WebCore/ChangeLog
Source/WebCore/css/CSSFontFace.cpp
Source/WebCore/css/CSSSegmentedFontFace.cpp
Source/WebCore/platform/graphics/Font.h
Source/WebCore/platform/graphics/FontCache.h
Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
Source/WebCore/platform/graphics/mac/FontCacheMac.mm
Source/WebCore/platform/graphics/win/FontCacheWin.cpp
Tools/ChangeLog
Tools/DumpRenderTree/mac/DumpRenderTree.mm
Tools/WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm
Tools/WebKitTestRunner/mac/TestControllerMac.mm

index 0281287..cb32f0c 100644 (file)
@@ -1,3 +1,29 @@
+2017-02-16  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        font-weight in @font-face can cause a font to be downloaded even when it's not used
+        https://bugs.webkit.org/show_bug.cgi?id=168114
+        <rdar://problem/30301317>
+
+        Reviewed by Darin Adler.
+
+        * fast/text/font-style-download-expected.txt: Added.
+        * fast/text/font-style-download.html: Added.
+        * fast/text/font-weight-download-2-expected.txt: Added.
+        * fast/text/font-weight-download-2.html: Added.
+        * fast/text/font-weight-download-expected.txt: Added.
+        * fast/text/font-weight-download.html: Added.
+        * fast/text/font-weight-fallback-expected.html: Added.
+        * fast/text/font-weight-fallback.html: Added.
+        * http/tests/webfont/fallback-font-while-loading-expected.txt: We don't want to use the
+        fallback font while an earlier font is loading because the fallback font might require
+        an extra download. This represents a policy change.
+        * http/tests/webfont/fallback-font-while-loading.html: Ditto.
+        * resources/Ahem_CJK.ttf: Added.
+        * svg/W3C-SVG-1.1-SE/struct-dom-11-f.svg: The metrics of LastResort are different from
+        the metrics of the previous interstitial font, which means the new font causes elements
+        to intersect when they previously didn't. However, the web font isn't actually necessary
+        here, so we can just stop using it, thereby sidestepping the entire problem.
+
 2017-02-16  Ryan Haddad  <ryanhaddad@apple.com>
 
         Skip imported/w3c/web-platform-tests/resource-timing tests on Debug.
diff --git a/LayoutTests/fast/text/font-style-download-expected.txt b/LayoutTests/fast/text/font-style-download-expected.txt
new file mode 100644 (file)
index 0000000..cac3239
--- /dev/null
@@ -0,0 +1,6 @@
+font-style-download.html - didFinishLoading
+Ahem.ttf - willSendRequest <NSURLRequest URL Ahem.ttf, main document URL font-style-download.html, http method GET> redirectResponse (null)
+Ahem.ttf - didReceiveResponse <NSURLResponse Ahem.ttf, http status code 0>
+Ahem.ttf - didFinishLoading
+This test makes sure that unnecessary fonts aren't downloaded. The test fails if Ahem.otf is downloaded.
+Hello
diff --git a/LayoutTests/fast/text/font-style-download.html b/LayoutTests/fast/text/font-style-download.html
new file mode 100644 (file)
index 0000000..ad73235
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+    testRunner.dumpResourceLoadCallbacks();
+    testRunner.dumpAsText();
+}
+if (window.internals) {
+    internals.invalidateFontCache();
+    internals.clearMemoryCache();
+}
+</script>
+<style>
+@font-face {
+    font-family: "WebFont";
+    font-style: italic;
+    src: url("../../resources/Ahem.ttf") format("truetype");
+}
+@font-face {
+    font-family: "WebFont";
+    font-style: normal;
+    src: url("../../resources/Ahem.otf") format("opentype");
+}
+</style>
+</head>
+<body>
+This test makes sure that unnecessary fonts aren't downloaded. The test fails if Ahem.otf is downloaded.
+<div style="font: italic 100px 'WebFont';">Hello</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/text/font-weight-download-2-expected.txt b/LayoutTests/fast/text/font-weight-download-2-expected.txt
new file mode 100644 (file)
index 0000000..be6b115
--- /dev/null
@@ -0,0 +1,6 @@
+font-weight-download-2.html - didFinishLoading
+Ahem_CJK.ttf - willSendRequest <NSURLRequest URL Ahem_CJK.ttf, main document URL font-weight-download-2.html, http method GET> redirectResponse (null)
+Ahem_CJK.ttf - didReceiveResponse <NSURLResponse Ahem_CJK.ttf, http status code 0>
+Ahem_CJK.ttf - didFinishLoading
+This test makes sure that unnecessary fonts aren't downloaded. The test fails if Ahem.otf is downloaded.
+цик
diff --git a/LayoutTests/fast/text/font-weight-download-2.html b/LayoutTests/fast/text/font-weight-download-2.html
new file mode 100644 (file)
index 0000000..f8aeedd
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+    testRunner.dumpResourceLoadCallbacks();
+    testRunner.dumpAsText();
+}
+if (window.internals) {
+    internals.invalidateFontCache();
+    internals.clearMemoryCache();
+}
+</script>
+<style>
+@font-face {
+    font-family: "WebFont";
+    font-weight: 100;
+    src: url("../../resources/Ahem_CJK.ttf") format("truetype");
+}
+@font-face {
+    font-family: "WebFont";
+    font-weight: 900;
+    src: url("../../resources/Ahem.otf") format("opentype");
+}
+</style>
+</head>
+<body>
+This test makes sure that unnecessary fonts aren't downloaded. The test fails if Ahem.otf is downloaded.
+<div style="font: 100 100px 'WebFont';">&#x6A2A;</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/text/font-weight-download-expected.txt b/LayoutTests/fast/text/font-weight-download-expected.txt
new file mode 100644 (file)
index 0000000..3b26dd1
--- /dev/null
@@ -0,0 +1,6 @@
+font-weight-download.html - didFinishLoading
+Ahem.ttf - willSendRequest <NSURLRequest URL Ahem.ttf, main document URL font-weight-download.html, http method GET> redirectResponse (null)
+Ahem.ttf - didReceiveResponse <NSURLResponse Ahem.ttf, http status code 0>
+Ahem.ttf - didFinishLoading
+This test makes sure that unnecessary fonts aren't downloaded. The test fails if Ahem.otf is downloaded.
+Hello
diff --git a/LayoutTests/fast/text/font-weight-download.html b/LayoutTests/fast/text/font-weight-download.html
new file mode 100644 (file)
index 0000000..8a9a0da
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+    testRunner.dumpResourceLoadCallbacks();
+    testRunner.dumpAsText();
+}
+if (window.internals) {
+    internals.invalidateFontCache();
+    internals.clearMemoryCache();
+}
+</script>
+<style>
+@font-face {
+    font-family: "WebFont";
+    font-weight: 100;
+    src: url("../../resources/Ahem.ttf") format("truetype");
+}
+@font-face {
+    font-family: "WebFont";
+    font-weight: 900;
+    src: url("../../resources/Ahem.otf") format("opentype");
+}
+</style>
+</head>
+<body>
+This test makes sure that unnecessary fonts aren't downloaded. The test fails if Ahem.otf is downloaded.
+<div style="font: 100 100px 'WebFont';">Hello</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/text/font-weight-fallback-expected.html b/LayoutTests/fast/text/font-weight-fallback-expected.html
new file mode 100644 (file)
index 0000000..00fefc2
--- /dev/null
@@ -0,0 +1,16 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "WebFont";
+    font-weight: 100;
+    src: url("../../resources/Ahem_CJK.ttf") format("truetype");
+}
+</style>
+</head>
+<body>
+This test makes sure that chaining font downloads works as expected. Specifically, Ahem.otf should be downloaded, but then we should realize that it doesn't support the character below, so we should download Ahem_CJK.ttf and use it because it supports the character.
+<div style="font: 100 100px 'WebFont';">&#x6A2A;</div>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/fast/text/font-weight-fallback.html b/LayoutTests/fast/text/font-weight-fallback.html
new file mode 100644 (file)
index 0000000..a7545d3
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html>
+<html>
+<head>
+<style>
+@font-face {
+    font-family: "WebFont";
+    font-weight: 100;
+    src: url("../../resources/Ahem_CJK.ttf") format("truetype");
+}
+@font-face {
+    font-family: "WebFont";
+    font-weight: 300;
+    src: url("../../resources/Ahem.otf") format("opentype");
+}
+</style>
+</head>
+<body>
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+var promises = [];
+
+document.fonts.forEach(function(f) {
+    promises.push(f.loaded);
+});
+
+Promise.all(promises).then(function() {
+    if (window.testRunner)
+        testRunner.notifyDone();
+});
+</script>
+This test makes sure that chaining font downloads works as expected. Specifically, Ahem.otf should be downloaded, but then we should realize that it doesn't support the character below, so we should download Ahem_CJK.ttf and use it because it supports the character.
+<div style="font: 300 100px 'WebFont';">&#x6A2A;</div>
+</body>
+</html>
\ No newline at end of file
index 969aa03..3ae57b4 100644 (file)
@@ -1,7 +1,7 @@
-This test checks that the fallback font is used for layout while a webfont is loading.
+This test checks that the fallback font is not used for layout while a webfont is loading.
 
 Target:
 A text to be measured.
 Reference:
 A text to be measured.
-PASS: The width of target text and reference text is the same.
+PASS: The width of target text and reference text are different.
index ec8ed0f..b15a3bf 100644 (file)
@@ -5,7 +5,7 @@
 }
 </style>
 <p>
-This test checks that the fallback font is used for layout while a webfont is loading.
+This test checks that the fallback font is not used for layout while a webfont is loading.
 </p>
 Target:
 <div>
@@ -26,10 +26,10 @@ function checkSize() {
     var targetWidth = document.getElementById('target').offsetWidth;
     var referenceWidth = document.getElementById('reference').offsetWidth;
     var result = document.getElementById('result');
-    if (targetWidth == referenceWidth)
-        result.innerText = 'PASS: The width of target text and reference text is the same.';
+    if (targetWidth != referenceWidth)
+        result.innerText = 'PASS: The width of target text and reference text are different.';
     else
-        result.innerText = 'FAIL: The width of target text and reference text is different: ' + targetWidth + ' != ' + referenceWidth;
+        result.innerText = 'FAIL: The width of target text and reference text are the same.';
 }
 
 checkSize();
diff --git a/LayoutTests/resources/Ahem_CJK.ttf b/LayoutTests/resources/Ahem_CJK.ttf
new file mode 100644 (file)
index 0000000..306f065
Binary files /dev/null and b/LayoutTests/resources/Ahem_CJK.ttf differ
index 6a562f0..9028428 100644 (file)
@@ -44,7 +44,7 @@
       </font-face-src>
     </font-face>
   </defs>
-  <g id="test-body-content" font-family="SVGFreeSansASCII,sans-serif" font-size="18">
+  <g id="test-body-content" font-family="sans-serif" font-size="18">
 
     <text x='10' y='40' font-size='13'>Test getIntersectionList and getEnclosureList return value liveness</text>
 
index a4da00c..4de0e95 100644 (file)
@@ -1,3 +1,47 @@
+2017-02-16  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        font-weight in @font-face can cause a font to be downloaded even when it's not used
+        https://bugs.webkit.org/show_bug.cgi?id=168114
+        <rdar://problem/30301317>
+
+        Reviewed by Darin Adler.
+
+        There were two problems with our font loading code.
+
+        When we are in the middle of a download, we will use a special interstitial font,
+        and this special font has a flag set which will cause it to be invisible when it is
+        drawn. However, when we start using this font during the load, we give it a
+        unicode-range of U+0-0 which means that it will never be used, and fallback will
+        happen to other weights immediately. 
+
+        The second problem with the font loading code is that this interstital font is just
+        Times. Times doesn't support every character, which means that if we are trying
+        to render some exotic character, we fall back to other weights. The solution here
+        is to use LastResort as the interstitial font, because it supports all characters.
+        Because its metrics are reasonable and we don't ever actually paint this
+        interstitial font, this choice is no worse than Times.
+
+        Tests: fast/text/font-style-download.html
+               fast/text/font-weight-download-2.html
+               fast/text/font-weight-download.html
+               fast/text/font-weight-fallback.html
+
+        * css/CSSFontFace.cpp:
+        (WebCore::CSSFontFace::font):
+        * css/CSSSegmentedFontFace.cpp:
+        (WebCore::appendFont):
+        (WebCore::CSSSegmentedFontFace::fontRanges):
+        (WebCore::appendFontWithInvalidUnicodeRangeIfLoading): Deleted.
+        * platform/graphics/Font.h:
+        (WebCore::Font::widthForGlyph):
+        * platform/graphics/FontCache.h:
+        * platform/graphics/freetype/FontCacheFreeType.cpp:
+        (WebCore::FontCache::lastResortFallbackFontForEveryCharacter):
+        * platform/graphics/mac/FontCacheMac.mm:
+        (WebCore::FontCache::lastResortFallbackFontForEveryCharacter):
+        * platform/graphics/win/FontCacheWin.cpp:
+        (WebCore::FontCache::lastResortFallbackFontForEveryCharacter):
+
 2017-02-16  Alex Christensen  <achristensen@webkit.org>
 
         Remove EFL-specific files in Source.
index 4d9dc2a..9bae31c 100644 (file)
@@ -597,7 +597,7 @@ RefPtr<Font> CSSFontFace::font(const FontDescription& fontDescription, bool synt
             fontIsLoading = true;
             if (status() == Status::TimedOut)
                 continue;
-            return Font::create(FontCache::singleton().lastResortFallbackFont(fontDescription)->platformData(), true, true);
+            return Font::create(FontCache::singleton().lastResortFallbackFontForEveryCharacter(fontDescription)->platformData(), true, true);
         case CSSFontFaceSource::Status::Success:
             if (RefPtr<Font> result = source->font(fontDescription, syntheticBold, syntheticItalic, m_featureSettings, m_variantSettings))
                 return result;
index 850185b..6213441 100644 (file)
@@ -94,13 +94,8 @@ private:
     bool m_syntheticItalic;
 };
 
-static void appendFontWithInvalidUnicodeRangeIfLoading(FontRanges& ranges, Ref<FontAccessor>&& fontAccessor, const Vector<CSSFontFace::UnicodeRange>& unicodeRanges)
+static void appendFont(FontRanges& ranges, Ref<FontAccessor>&& fontAccessor, const Vector<CSSFontFace::UnicodeRange>& unicodeRanges)
 {
-    if (fontAccessor->isLoading()) {
-        ranges.appendRange({ 0, 0, WTFMove(fontAccessor) });
-        return;
-    }
-
     if (unicodeRanges.isEmpty()) {
         ranges.appendRange({ 0, 0x7FFFFFFF, WTFMove(fontAccessor) });
         return;
@@ -132,7 +127,7 @@ FontRanges CSSSegmentedFontFace::fontRanges(const FontDescription& fontDescripti
             auto fontAccessor = CSSFontAccessor::create(face, fontDescription, syntheticBold, syntheticItalic);
             if (result.isNull() && !fontAccessor->font())
                 continue;
-            appendFontWithInvalidUnicodeRangeIfLoading(result, WTFMove(fontAccessor), face->ranges());
+            appendFont(result, WTFMove(fontAccessor), face->ranges());
         }
     }
     return result;
index 5374e72..83a20d5 100644 (file)
@@ -339,7 +339,11 @@ ALWAYS_INLINE FloatRect Font::boundsForGlyph(Glyph glyph) const
 
 ALWAYS_INLINE float Font::widthForGlyph(Glyph glyph) const
 {
-    if (isZeroWidthSpaceGlyph(glyph))
+    // The optimization of returning 0 for the zero-width-space glyph is incorrect for the LastResort font,
+    // used in place of the actual font when isLoading() is true on both macOS and iOS.
+    // The zero-width-space glyph in that font does not have a width of zero and, further, that glyph is used
+    // for many other characters and must not be zero width when used for them.
+    if (isZeroWidthSpaceGlyph(glyph) && !isLoading())
         return 0;
 
     float width = m_glyphToWidthMap.metricsForGlyph(glyph);
index cb04a45..e5a3f19 100644 (file)
@@ -202,6 +202,7 @@ public:
 
     WEBCORE_EXPORT RefPtr<Font> fontForFamily(const FontDescription&, const AtomicString&, const FontFeatureSettings* fontFaceFeatures = nullptr, const FontVariantSettings* fontFaceVariantSettings = nullptr, bool checkingAlternateName = false);
     WEBCORE_EXPORT Ref<Font> lastResortFallbackFont(const FontDescription&);
+    Ref<Font> lastResortFallbackFontForEveryCharacter(const FontDescription&);
     WEBCORE_EXPORT Ref<Font> fontForPlatformData(const FontPlatformData&);
     RefPtr<Font> similarFont(const FontDescription&, const AtomicString& family);
 
index 8e04bd1..428d095 100644 (file)
@@ -121,6 +121,11 @@ Vector<String> FontCache::systemFontFamilies()
     return fontFamilies;
 }
 
+Ref<Font> FontCache::lastResortFallbackFontForEveryCharacter(const FontDescription& fontDescription)
+{
+    return lastResortFallbackFont(fontDescription);
+}
+
 Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescription)
 {
     // We want to return a fallback font here, otherwise the logic preventing FontConfig
index 9782773..13cfb95 100644 (file)
 #import "config.h"
 #import "FontCache.h"
 
-#if !PLATFORM(IOS)
-
 #import "CoreGraphicsSPI.h"
 #import "CoreTextSPI.h"
 #import "Font.h"
 #import "FontCascade.h"
 #import "FontPlatformData.h"
+
+#if PLATFORM(MAC)
 #import "NSFontSPI.h"
 #import "WebCoreNSStringExtras.h"
 #import "WebCoreSystemInterface.h"
 #import <wtf/StdLibExtras.h>
 #import <wtf/Threading.h>
 #import <wtf/text/AtomicStringHash.h>
+#endif
 
 namespace WebCore {
 
+#if PLATFORM(MAC)
+
 #if !ENABLE(PLATFORM_FONT_LOOKUP)
 
 #define SYNTHESIZED_FONT_TRAITS (NSBoldFontMask | NSItalicFontMask)
@@ -390,6 +393,13 @@ Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescripti
     return *fontForFamily(fontDescription, AtomicString("Lucida Grande", AtomicString::ConstructFromLiteral), nullptr, nullptr, false);
 }
 
-} // namespace WebCore
+#endif // PLATFORM(MAC)
 
-#endif // !PLATFORM(IOS)
+Ref<Font> FontCache::lastResortFallbackFontForEveryCharacter(const FontDescription& fontDescription)
+{
+    auto result = fontForFamily(fontDescription, AtomicString("LastResort", AtomicString::ConstructFromLiteral));
+    ASSERT(result);
+    return *result;
+}
+
+} // namespace WebCore
index 53dea06..9f5733c 100644 (file)
@@ -338,6 +338,11 @@ RefPtr<Font> FontCache::fontFromDescriptionAndLogFont(const FontDescription& fon
     return fontData;
 }
 
+Ref<Font> FontCache::lastResortFallbackFontForEveryCharacter(const FontDescription& fontDescription)
+{
+    return lastResortFallbackFont(fontDescription);
+}
+
 Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescription)
 {
     DEPRECATED_DEFINE_STATIC_LOCAL(AtomicString, fallbackFontName, ());
index fc211df..04e198f 100644 (file)
@@ -1,3 +1,20 @@
+2017-02-16  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        font-weight in @font-face can cause a font to be downloaded even when it's not used
+        https://bugs.webkit.org/show_bug.cgi?id=168114
+        <rdar://problem/30301317>
+
+        Reviewed by Darin Adler.
+
+        LastResort needs to be usable in tests.
+
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (allowedFontFamilySet):
+        * WebKitTestRunner/InjectedBundle/cocoa/ActivateFontsCocoa.mm:
+        (WTR::allowedFontFamilySet):
+        * WebKitTestRunner/mac/TestControllerMac.mm:
+        (WTR::allowedFontFamilySet):
+
 2017-02-16  Alex Christensen  <achristensen@webkit.org>
 
         Remove old URL parser
index f80a8b1..4fc33a8 100644 (file)
@@ -378,6 +378,7 @@ static NSSet *allowedFontFamilySet()
         @"Kokonor",
         @"Krungthep",
         @"KufiStandardGK",
+        @"LastResort",
         @"LiHei Pro",
         @"LiSong Pro",
         @"Lucida Grande",
index e4cef35..5a49e46 100644 (file)
@@ -123,6 +123,7 @@ static NSSet *allowedFontFamilySet()
         @"Kokonor",
         @"Krungthep",
         @"KufiStandardGK",
+        @"LastResort",
         @"LiHei Pro",
         @"LiSong Pro",
         @"Lucida Grande",
index f41159c..d95ca7e 100644 (file)
@@ -221,6 +221,7 @@ static NSSet *allowedFontFamilySet()
         @"Kokonor",
         @"Krungthep",
         @"KufiStandardGK",
+        @"LastResort",
         @"LiHei Pro",
         @"LiSong Pro",
         @"Lucida Grande",