- Revision
- 220003
- Author
- mmaxfi...@apple.com
- Date
- 2017-07-28 10:06:29 -0700 (Fri, 28 Jul 2017)
Log Message
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.
Source/WebCore:
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):
LayoutTests:
* http/tests/webfont/font-loading-system-fallback-visibility-FontRanges-expected.html: Added.
* http/tests/webfont/font-loading-system-fallback-visibility-FontRanges.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (220002 => 220003)
--- trunk/LayoutTests/ChangeLog 2017-07-28 16:52:35 UTC (rev 220002)
+++ trunk/LayoutTests/ChangeLog 2017-07-28 17:06:29 UTC (rev 220003)
@@ -1,3 +1,14 @@
+2017-07-28 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ 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 Per Arne Vollan <pvol...@apple.com>
REGRESSION(r125147): Layout Test svg/dom/SVGScriptElement/script-change-externalResourcesRequired-while-loading.svg is failing
Added: trunk/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges-expected.html (0 => 220003)
--- trunk/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges-expected.html (rev 0)
+++ trunk/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges-expected.html 2017-07-28 17:06:29 UTC (rev 220003)
@@ -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: trunk/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges.html (0 => 220003)
--- trunk/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges.html (rev 0)
+++ trunk/LayoutTests/http/tests/webfont/font-loading-system-fallback-visibility-FontRanges.html 2017-07-28 17:06:29 UTC (rev 220003)
@@ -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: trunk/Source/WebCore/ChangeLog (220002 => 220003)
--- trunk/Source/WebCore/ChangeLog 2017-07-28 16:52:35 UTC (rev 220002)
+++ trunk/Source/WebCore/ChangeLog 2017-07-28 17:06:29 UTC (rev 220003)
@@ -1,3 +1,32 @@
+2017-07-28 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ 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 Frederic Wang <fw...@igalia.cpm>
Fix typo in scrollPositionChangedViaDelegatedScrolling
Modified: trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp (220002 => 220003)
--- trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp 2017-07-28 16:52:35 UTC (rev 220002)
+++ trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp 2017-07-28 17:06:29 UTC (rev 220003)
@@ -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: trunk/Source/WebCore/platform/graphics/FontRanges.cpp (220002 => 220003)
--- trunk/Source/WebCore/platform/graphics/FontRanges.cpp 2017-07-28 16:52:35 UTC (rev 220002)
+++ trunk/Source/WebCore/platform/graphics/FontRanges.cpp 2017-07-28 17:06:29 UTC (rev 220003)
@@ -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;
+ }
}
}
}