Resolve mirroring and variant in Font instead of FontGlyphs
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jan 2015 14:49:24 +0000 (14:49 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 6 Jan 2015 14:49:24 +0000 (14:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140079

Reviewed by Darin Adler.

Make FontGlyphs more focused. It doesn't need to know about resolving variants and mirroring.

* platform/graphics/Font.cpp:
(WebCore::Font::glyphDataForCharacter):
* platform/graphics/Font.h:
(WebCore::Font::glyphDataForCharacter): Deleted.
* platform/graphics/FontGlyphs.cpp:
(WebCore::FontGlyphs::glyphDataForCharacter):
* platform/graphics/FontGlyphs.h:

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/Font.h
Source/WebCore/platform/graphics/FontGlyphs.cpp
Source/WebCore/platform/graphics/FontGlyphs.h

index 2e5d248..421fc9b 100644 (file)
@@ -1,3 +1,20 @@
+2015-01-06  Antti Koivisto  <antti@apple.com>
+
+        Resolve mirroring and variant in Font instead of FontGlyphs
+        https://bugs.webkit.org/show_bug.cgi?id=140079
+
+        Reviewed by Darin Adler.
+
+        Make FontGlyphs more focused. It doesn't need to know about resolving variants and mirroring.
+
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::glyphDataForCharacter):
+        * platform/graphics/Font.h:
+        (WebCore::Font::glyphDataForCharacter): Deleted.
+        * platform/graphics/FontGlyphs.cpp:
+        (WebCore::FontGlyphs::glyphDataForCharacter):
+        * platform/graphics/FontGlyphs.h:
+
 2015-01-06  Shivakumar JM  <shiva.jm@samsung.com>
 
         Fix Unused parameter warning in Webcore bindings.
index a49b7dc..40615e1 100644 (file)
@@ -417,6 +417,26 @@ float Font::width(const TextRun& run, int& charsConsumed, String& glyphName) con
     return width(run);
 }
 
+GlyphData Font::glyphDataForCharacter(UChar32 c, bool mirror, FontDataVariant variant) const
+{
+    if (variant == AutoVariant) {
+        if (m_fontDescription.smallCaps() && !primaryFontData().isSVGFont()) {
+            UChar32 upperC = u_toupper(c);
+            if (upperC != c) {
+                c = upperC;
+                variant = SmallCapsVariant;
+            } else
+                variant = NormalVariant;
+        } else
+            variant = NormalVariant;
+    }
+
+    if (mirror)
+        c = u_charMirror(c);
+
+    return m_glyphs->glyphDataForCharacter(c, m_fontDescription, variant);
+}
+
 #if !PLATFORM(COCOA)
 PassOwnPtr<TextLayout> Font::createLayout(RenderText*, float, bool) const
 {
index 8ace9cc..16ff611 100644 (file)
@@ -185,10 +185,8 @@ public:
 
     const SimpleFontData& primaryFontData() const;
     const FontData* fontDataAt(unsigned) const;
-    GlyphData glyphDataForCharacter(UChar32 c, bool mirror, FontDataVariant variant = AutoVariant) const
-    {
-        return m_glyphs->glyphDataForCharacter(m_fontDescription, c, mirror, variant);
-    }
+    GlyphData glyphDataForCharacter(UChar32, bool mirror, FontDataVariant = AutoVariant) const;
+    
 #if PLATFORM(COCOA)
     const SimpleFontData* fontDataForCombiningCharacterSequence(const UChar*, size_t length, FontDataVariant) const;
 #endif
index 62d7d9c..e0225ab 100644 (file)
@@ -360,24 +360,10 @@ static RefPtr<GlyphPage> glyphPageFromFontData(unsigned pageNumber, const FontDa
     return const_cast<GlyphPage*>(simpleFontData->glyphPage(pageNumber));
 }
 
-GlyphData FontGlyphs::glyphDataForCharacter(const FontDescription& description, UChar32 c, bool mirror, FontDataVariant variant)
+GlyphData FontGlyphs::glyphDataForCharacter( UChar32 c, const FontDescription& description, FontDataVariant variant)
 {
     ASSERT(isMainThread());
-
-    if (variant == AutoVariant) {
-        if (description.smallCaps() && !primarySimpleFontData(description).isSVGFont()) {
-            UChar32 upperC = u_toupper(c);
-            if (upperC != c) {
-                c = upperC;
-                variant = SmallCapsVariant;
-            } else
-                variant = NormalVariant;
-        } else
-            variant = NormalVariant;
-    }
-
-    if (mirror)
-        c = u_charMirror(c);
+    ASSERT(variant != AutoVariant);
 
     if (variant != NormalVariant)
         return glyphDataForVariant(c, description, variant, 0);
index d463350..a809f89 100644 (file)
@@ -52,7 +52,7 @@ public:
 
     bool isForPlatformFont() const { return m_isForPlatformFont; }
 
-    GlyphData glyphDataForCharacter(const FontDescription&, UChar32, bool mirror, FontDataVariant);
+    GlyphData glyphDataForCharacter(UChar32, const FontDescription&, FontDataVariant);
 
     bool isFixedPitch(const FontDescription&);
     void determinePitch(const FontDescription&);