Title: [219215] trunk/Source/WebCore
Revision
219215
Author
mmaxfi...@apple.com
Date
2017-07-06 14:07:19 -0700 (Thu, 06 Jul 2017)

Log Message

Unify FontCascadeFonts::glyphDataForVariant() and FontCascadeFonts::glyphDataForNormalVariant()
https://bugs.webkit.org/show_bug.cgi?id=174213

Reviewed by Zalan Bujtas.

They have almost identical code. This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=173962

No new tests because there is no behavior change.

* platform/graphics/FontCascadeFonts.cpp:
(WebCore::FontCascadeFonts::glyphDataForVariant):
(WebCore::FontCascadeFonts::glyphDataForCharacter):
(WebCore::FontCascadeFonts::glyphDataForNormalVariant): Deleted.
* platform/graphics/FontCascadeFonts.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (219214 => 219215)


--- trunk/Source/WebCore/ChangeLog	2017-07-06 20:51:20 UTC (rev 219214)
+++ trunk/Source/WebCore/ChangeLog	2017-07-06 21:07:19 UTC (rev 219215)
@@ -1,3 +1,20 @@
+2017-07-06  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        Unify FontCascadeFonts::glyphDataForVariant() and FontCascadeFonts::glyphDataForNormalVariant()
+        https://bugs.webkit.org/show_bug.cgi?id=174213
+
+        Reviewed by Zalan Bujtas.
+
+        They have almost identical code. This is in preparation for https://bugs.webkit.org/show_bug.cgi?id=173962
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/FontCascadeFonts.cpp:
+        (WebCore::FontCascadeFonts::glyphDataForVariant):
+        (WebCore::FontCascadeFonts::glyphDataForCharacter):
+        (WebCore::FontCascadeFonts::glyphDataForNormalVariant): Deleted.
+        * platform/graphics/FontCascadeFonts.h:
+
 2017-07-06  Don Olmstead  <don.olmst...@sony.com>
 
         [PAL] Move KillRing into PAL

Modified: trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp (219214 => 219215)


--- trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp	2017-07-06 20:51:20 UTC (rev 219214)
+++ trunk/Source/WebCore/platform/graphics/FontCascadeFonts.cpp	2017-07-06 21:07:19 UTC (rev 219215)
@@ -356,17 +356,19 @@
     return fallbackGlyphData;
 }
 
-GlyphData FontCascadeFonts::glyphDataForVariant(UChar32 c, const FontCascadeDescription& description, FontVariant variant, unsigned fallbackIndex)
+GlyphData FontCascadeFonts::glyphDataForVariant(UChar32 character, const FontCascadeDescription& description, FontVariant variant, unsigned fallbackIndex)
 {
     ExternalResourceDownloadPolicy policy = ExternalResourceDownloadPolicy::Allow;
     GlyphData loadingResult;
-    while (true) {
-        auto& fontRanges = realizeFallbackRangesAt(description, fallbackIndex++);
+    for (; ; ++fallbackIndex) {
+        auto& fontRanges = realizeFallbackRangesAt(description, fallbackIndex);
         if (fontRanges.isNull())
             break;
-        GlyphData data = "" policy);
+
+        GlyphData data = "" policy);
         if (!data.font)
             continue;
+
         if (data.font->isInterstitial()) {
             policy = ExternalResourceDownloadPolicy::Forbid;
             if (!loadingResult.font)
@@ -373,51 +375,31 @@
                 loadingResult = data;
             continue;
         }
-        // The variantFont function should not normally return 0.
-        // But if it does, we will just render the capital letter big.
-        if (const Font* variantFont = data.font->variantFont(description, variant))
-            return variantFont->glyphDataForCharacter(c);
-        return data;
-    }
 
-    if (loadingResult.font)
-        return loadingResult;
-    return glyphDataForSystemFallback(c, description, variant);
-}
+        if (variant == NormalVariant) {
+            if (data.font->platformData().orientation() == Vertical && !data.font->isTextOrientationFallback()) {
+                if (!FontCascade::isCJKIdeographOrSymbol(character))
+                    return glyphDataForNonCJKCharacterWithGlyphOrientation(character, description.nonCJKGlyphOrientation(), data);
 
-GlyphData FontCascadeFonts::glyphDataForNormalVariant(UChar32 c, const FontCascadeDescription& description)
-{
-    ExternalResourceDownloadPolicy policy = ExternalResourceDownloadPolicy::Allow;
-    GlyphData loadingResult;
-    for (unsigned fallbackIndex = 0; ; ++fallbackIndex) {
-        auto& fontRanges = realizeFallbackRangesAt(description, fallbackIndex);
-        if (fontRanges.isNull())
-            break;
-        GlyphData data = "" policy);
-        if (!data.font)
-            continue;
-        if (data.font->isInterstitial()) {
-            policy = ExternalResourceDownloadPolicy::Forbid;
-            if (!loadingResult.font)
-                loadingResult = data;
-            continue;
+                if (!data.font->hasVerticalGlyphs()) {
+                    // Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs
+                    // to make sure you get a square (even for broken glyphs like symbols used for punctuation).
+                    return glyphDataForVariant(character, description, BrokenIdeographVariant, fallbackIndex);
+                }
+            }
+        } else {
+            // The variantFont function should not normally return 0.
+            // But if it does, we will just render the capital letter big.
+            if (const Font* variantFont = data.font->variantFont(description, variant))
+                return variantFont->glyphDataForCharacter(character);
         }
-        if (data.font->platformData().orientation() == Vertical && !data.font->isTextOrientationFallback()) {
-            if (!FontCascade::isCJKIdeographOrSymbol(c))
-                return glyphDataForNonCJKCharacterWithGlyphOrientation(c, description.nonCJKGlyphOrientation(), data);
 
-            if (!data.font->hasVerticalGlyphs()) {
-                // Use the broken ideograph font data. The broken ideograph font will use the horizontal width of glyphs
-                // to make sure you get a square (even for broken glyphs like symbols used for punctuation).
-                return glyphDataForVariant(c, description, BrokenIdeographVariant, fallbackIndex);
-            }
-        }
         return data;
     }
 
     if (loadingResult.font)
         return loadingResult;
-    return glyphDataForSystemFallback(c, description, NormalVariant);
+    return glyphDataForSystemFallback(character, description, variant);
 }
 
 static RefPtr<GlyphPage> glyphPageFromFontRanges(unsigned pageNumber, const FontRanges& fontRanges)
@@ -452,7 +434,7 @@
     ASSERT(variant != AutoVariant);
 
     if (variant != NormalVariant)
-        return glyphDataForVariant(c, description, variant, 0);
+        return glyphDataForVariant(c, description, variant);
 
     const unsigned pageNumber = GlyphPage::pageNumberForCodePoint(c);
 
@@ -465,7 +447,8 @@
     GlyphData glyphData = cacheEntry.glyphDataForCharacter(c);
     if (!glyphData.glyph) {
         // No glyph, resolve per-character.
-        glyphData = glyphDataForNormalVariant(c, description);
+        ASSERT(variant == NormalVariant);
+        glyphData = glyphDataForVariant(c, description, variant);
         // Cache the results.
         cacheEntry.setGlyphDataForCharacter(c, glyphData);
     }

Modified: trunk/Source/WebCore/platform/graphics/FontCascadeFonts.h (219214 => 219215)


--- trunk/Source/WebCore/platform/graphics/FontCascadeFonts.h	2017-07-06 20:51:20 UTC (rev 219214)
+++ trunk/Source/WebCore/platform/graphics/FontCascadeFonts.h	2017-07-06 21:07:19 UTC (rev 219215)
@@ -77,8 +77,7 @@
     FontCascadeFonts(const FontPlatformData&);
 
     GlyphData glyphDataForSystemFallback(UChar32, const FontCascadeDescription&, FontVariant);
-    GlyphData glyphDataForNormalVariant(UChar32, const FontCascadeDescription&);
-    GlyphData glyphDataForVariant(UChar32, const FontCascadeDescription&, FontVariant, unsigned fallbackIndex);
+    GlyphData glyphDataForVariant(UChar32, const FontCascadeDescription&, FontVariant, unsigned fallbackIndex = 0);
 
     Vector<FontRanges, 1> m_realizedFallbackRanges;
     unsigned m_lastRealizedFallbackIndex { 0 };
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to