Diff
Modified: branches/safari-604-branch/LayoutTests/ChangeLog (220028 => 220029)
--- branches/safari-604-branch/LayoutTests/ChangeLog 2017-07-28 22:20:04 UTC (rev 220028)
+++ branches/safari-604-branch/LayoutTests/ChangeLog 2017-07-28 22:20:09 UTC (rev 220029)
@@ -1,5 +1,20 @@
2017-07-28 Jason Marcell <[email protected]>
+ Cherry-pick r220003. rdar://problem/33595572
+
+ 2017-07-28 Myles C. Maxfield <[email protected]>
+
+ REGRESSION(r216944): Fallback fonts erroneously visible when the primary font is loading
+ https://bugs.webkit.org/show_bug.cgi?id=174772
+ <rdar://problem/33267643>
+
+ Reviewed by Simon Fraser.
+
+ * http/tests/webfont/font-loading-system-fallback-visibility-FontRanges-expected.html: Added.
+ * http/tests/webfont/font-loading-system-fallback-visibility-FontRanges.html: Added.
+
+2017-07-28 Jason Marcell <[email protected]>
+
Cherry-pick r219950. rdar://problem/33595459
2017-07-26 Chris Dumez <[email protected]>
Added: branches/safari-604-branch/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges-expected.html (0 => 220029)
--- branches/safari-604-branch/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges-expected.html (rev 0)
+++ branches/safari-604-branch/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges-expected.html 2017-07-28 22:20:09 UTC (rev 220029)
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+This test makes sure that system fallback fonts during loading are invisible when the loading font is invisible. The test passes if this text is the only text on the page.
+</body>
+</html>
Added: branches/safari-604-branch/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges.html (0 => 220029)
--- branches/safari-604-branch/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges.html (rev 0)
+++ branches/safari-604-branch/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges.html 2017-07-28 22:20:09 UTC (rev 220029)
@@ -0,0 +1,26 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script>
+if (window.internals) {
+ internals.clearMemoryCache();
+ internals.invalidateFontCache();
+}
+</script>
+<style>
+@font-face {
+ font-family: "WebFont";
+ src: url("slow-ahem-loading.cgi");
+}
+
+@font-face {
+ font-family: "WebFont";
+ src: url("../resources/Ahem.woff");
+}
+</style>
+</head>
+<body>
+This test makes sure that system fallback fonts during loading are invisible when the loading font is invisible. The test passes if this text is the only text on the page.
+<div style="font: 48px 'WebFont', 'Helvetica';">の</div>
+</body>
+</html>
Modified: branches/safari-604-branch/Source/WebCore/ChangeLog (220028 => 220029)
--- branches/safari-604-branch/Source/WebCore/ChangeLog 2017-07-28 22:20:04 UTC (rev 220028)
+++ branches/safari-604-branch/Source/WebCore/ChangeLog 2017-07-28 22:20:09 UTC (rev 220029)
@@ -1,5 +1,38 @@
2017-07-28 Jason Marcell <[email protected]>
+ Cherry-pick r220003. rdar://problem/33595572
+
+ 2017-07-28 Myles C. Maxfield <[email protected]>
+
+ REGRESSION(r216944): Fallback fonts erroneously visible when the primary font is loading
+ https://bugs.webkit.org/show_bug.cgi?id=174772
+ <rdar://problem/33267643>
+
+ Reviewed by Simon Fraser.
+
+ During a font load, we try pretty hard to find a font to use that isn't the
+ last resort font (which happens to be Times). We do this by iterating through
+ all the fonts in the font-family list, as well as through all the relevant
+ @font-face blocks which share the requested font family name.
+
+ Unfortunately, if we find one of these fallback fonts, we were simply using it
+ directly, which means that it was being drawn as visible (because the
+ visibility setting lives inside the Font object). Instead, we should carry the
+ invisibility setting from the interstitial font to this used fallback font.
+
+ This patch is an extension of r219221, which fixed the problem only for system
+ fallback fonts. This patch adopts the same methodology to all fallback fonts.
+
+ Test: http/tests/webfont/font-loading-system-fallback-visibility-FontRanges.html
+
+ * platform/graphics/FontCascadeFonts.cpp:
+ (WebCore::FontCascadeFonts::glyphDataForVariant):
+ (WebCore::glyphPageFromFontRanges):
+ * platform/graphics/FontRanges.cpp:
+ (WebCore::FontRanges::glyphDataForCharacter):
+
+2017-07-28 Jason Marcell <[email protected]>
+
Cherry-pick r219998. rdar://problem/33595610
2017-07-28 Wenson Hsieh <[email protected]>
Modified: branches/safari-604-branch/Source/WebCore/platform/graphics/FontCascadeFonts.cpp (220028 => 220029)
--- branches/safari-604-branch/Source/WebCore/platform/graphics/FontCascadeFonts.cpp 2017-07-28 22:20:04 UTC (rev 220028)
+++ branches/safari-604-branch/Source/WebCore/platform/graphics/FontCascadeFonts.cpp 2017-07-28 22:20:09 UTC (rev 220029)
@@ -375,7 +375,7 @@
return fallbackGlyphData;
}
-enum class SystemFallbackVisibility {
+enum class FallbackVisibility {
Immaterial,
Visible,
Invisible
@@ -383,7 +383,7 @@
GlyphData FontCascadeFonts::glyphDataForVariant(UChar32 character, const FontCascadeDescription& description, FontVariant variant, unsigned fallbackIndex)
{
- SystemFallbackVisibility systemFallbackVisibility = SystemFallbackVisibility::Immaterial;
+ FallbackVisibility fallbackVisibility = FallbackVisibility::Immaterial;
ExternalResourceDownloadPolicy policy = ExternalResourceDownloadPolicy::Allow;
GlyphData loadingResult;
for (; ; ++fallbackIndex) {
@@ -397,13 +397,16 @@
if (data.font->isInterstitial()) {
policy = ExternalResourceDownloadPolicy::Forbid;
- if (systemFallbackVisibility == SystemFallbackVisibility::Immaterial)
- systemFallbackVisibility = data.font->visibility() == Font::Visibility::Visible ? SystemFallbackVisibility::Visible : SystemFallbackVisibility::Invisible;
+ if (fallbackVisibility == FallbackVisibility::Immaterial)
+ fallbackVisibility = data.font->visibility() == Font::Visibility::Visible ? FallbackVisibility::Visible : FallbackVisibility::Invisible;
if (!loadingResult.font && data.glyph)
loadingResult = data;
continue;
}
+ if (fallbackVisibility == FallbackVisibility::Invisible && data.font->visibility() == Font::Visibility::Visible)
+ data.font = &data.font->invisibleFont();
+
if (variant == NormalVariant) {
if (data.font->platformData().orientation() == Vertical && !data.font->isTextOrientationFallback()) {
if (!FontCascade::isCJKIdeographOrSymbol(character))
@@ -427,7 +430,7 @@
if (loadingResult.font)
return loadingResult;
- return glyphDataForSystemFallback(character, description, variant, systemFallbackVisibility == SystemFallbackVisibility::Invisible);
+ return glyphDataForSystemFallback(character, description, variant, fallbackVisibility == FallbackVisibility::Invisible);
}
static RefPtr<GlyphPage> glyphPageFromFontRanges(unsigned pageNumber, const FontRanges& fontRanges)
@@ -436,6 +439,7 @@
UChar32 pageRangeFrom = pageNumber * GlyphPage::size;
UChar32 pageRangeTo = pageRangeFrom + GlyphPage::size - 1;
auto policy = ExternalResourceDownloadPolicy::Allow;
+ FallbackVisibility desiredVisibility = FallbackVisibility::Immaterial;
for (unsigned i = 0; i < fontRanges.size(); ++i) {
auto& range = fontRanges.rangeAt(i);
if (range.from() <= pageRangeFrom && pageRangeTo <= range.to()) {
@@ -443,6 +447,15 @@
if (!font)
continue;
if (font->isInterstitial()) {
+ if (desiredVisibility == FallbackVisibility::Immaterial) {
+ auto fontVisibility = font->visibility();
+ if (fontVisibility == Font::Visibility::Visible)
+ desiredVisibility = FallbackVisibility::Visible;
+ else {
+ ASSERT(fontVisibility == Font::Visibility::Invisible);
+ desiredVisibility = FallbackVisibility::Invisible;
+ }
+ }
font = nullptr;
policy = ExternalResourceDownloadPolicy::Forbid;
continue;
@@ -453,6 +466,8 @@
if (!font || font->platformData().orientation() == Vertical)
return nullptr;
+ if (desiredVisibility == FallbackVisibility::Invisible && font->visibility() == Font::Visibility::Visible)
+ return const_cast<GlyphPage*>(font->invisibleFont().glyphPage(pageNumber));
return const_cast<GlyphPage*>(font->glyphPage(pageNumber));
}
Modified: branches/safari-604-branch/Source/WebCore/platform/graphics/FontRanges.cpp (220028 => 220029)
--- branches/safari-604-branch/Source/WebCore/platform/graphics/FontRanges.cpp 2017-07-28 22:20:04 UTC (rev 220028)
+++ branches/safari-604-branch/Source/WebCore/platform/graphics/FontRanges.cpp 2017-07-28 22:20:09 UTC (rev 220029)
@@ -90,8 +90,12 @@
resultFont = font;
} else {
auto glyphData = font->glyphDataForCharacter(character);
- if (glyphData.glyph)
+ if (glyphData.glyph) {
+ auto* glyphDataFont = glyphData.font;
+ if (glyphDataFont && glyphDataFont->visibility() == Font::Visibility::Visible && resultFont && resultFont->visibility() == Font::Visibility::Invisible)
+ return GlyphData(glyphData.glyph, &glyphDataFont->invisibleFont());
return glyphData;
+ }
}
}
}