Title: [131703] trunk/Source/WebCore
Revision
131703
Author
[email protected]
Date
2012-10-17 22:01:00 -0700 (Wed, 17 Oct 2012)

Log Message

REGRESSION (r95391): ComplexTextController is unnecessarily slow with characters with combining marks when the base character is not covered by any font
https://bugs.webkit.org/show_bug.cgi?id=99654

Reviewed by Adele Peterson.

When the base character of a combining character sequence is not covered by any one of the
available fonts, there is no point looking for a font that covers the entire sequence, nor
to try to use a combination of fallback fonts for the entire sequence.

* platform/graphics/SimpleFontData.h:
(WebCore::SimpleFontData::systemFallback): Moved ComplexTextController::systemFallbackFontData
here and renamed it.
* platform/graphics/mac/ComplexTextController.cpp:
(WebCore::ComplexTextController::collectComplexTextRuns): This function used to use
systemFallbackFontData() whenever Font::fontDataForCombiningCharacterSequence returned 0
for a base character with combining marks, regardless of whether the base character was
covered by any font. Changed it to preserve the return value of
fontDataForCombiningCharacterSequence, which is now 0 only if the base charcater is not in
any font, while systemFallbackFontData() is used to indicate that no single font in the
fallback list covers all characters in the sequence, but the base character is in some font.
* platform/graphics/mac/ComplexTextController.h:
(ComplexTextController): Moved systemFallbackFontData from here to SimpleFontData.
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Updated for the above
move.
* platform/graphics/mac/FontComplexTextMac.cpp:
(WebCore::Font::fontDataForCombiningCharacterSequence): Changed to return
systemFallbackFontData() if no single font in the fallback list covers all characters in the
sequence, while using 0 to signal the base character does not exist in any font.

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (131702 => 131703)


--- trunk/Source/WebCore/ChangeLog	2012-10-18 04:34:18 UTC (rev 131702)
+++ trunk/Source/WebCore/ChangeLog	2012-10-18 05:01:00 UTC (rev 131703)
@@ -1,5 +1,37 @@
 2012-10-17  Dan Bernstein  <[email protected]>
 
+        REGRESSION (r95391): ComplexTextController is unnecessarily slow with characters with combining marks when the base character is not covered by any font
+        https://bugs.webkit.org/show_bug.cgi?id=99654
+
+        Reviewed by Adele Peterson.
+
+        When the base character of a combining character sequence is not covered by any one of the
+        available fonts, there is no point looking for a font that covers the entire sequence, nor
+        to try to use a combination of fallback fonts for the entire sequence.
+
+        * platform/graphics/SimpleFontData.h:
+        (WebCore::SimpleFontData::systemFallback): Moved ComplexTextController::systemFallbackFontData
+        here and renamed it.
+        * platform/graphics/mac/ComplexTextController.cpp:
+        (WebCore::ComplexTextController::collectComplexTextRuns): This function used to use
+        systemFallbackFontData() whenever Font::fontDataForCombiningCharacterSequence returned 0
+        for a base character with combining marks, regardless of whether the base character was
+        covered by any font. Changed it to preserve the return value of
+        fontDataForCombiningCharacterSequence, which is now 0 only if the base charcater is not in
+        any font, while systemFallbackFontData() is used to indicate that no single font in the
+        fallback list covers all characters in the sequence, but the base character is in some font.
+        * platform/graphics/mac/ComplexTextController.h:
+        (ComplexTextController): Moved systemFallbackFontData from here to SimpleFontData.
+        * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): Updated for the above
+        move.
+        * platform/graphics/mac/FontComplexTextMac.cpp:
+        (WebCore::Font::fontDataForCombiningCharacterSequence): Changed to return
+        systemFallbackFontData() if no single font in the fallback list covers all characters in the
+        sequence, while using 0 to signal the base character does not exist in any font.
+
+2012-10-17  Dan Bernstein  <[email protected]>
+
         Try to fix the build after r131701.
 
         * WebCore.exp.in:

Modified: trunk/Source/WebCore/platform/graphics/SimpleFontData.h (131702 => 131703)


--- trunk/Source/WebCore/platform/graphics/SimpleFontData.h	2012-10-18 04:34:18 UTC (rev 131702)
+++ trunk/Source/WebCore/platform/graphics/SimpleFontData.h	2012-10-18 05:01:00 UTC (rev 131703)
@@ -98,6 +98,8 @@
 
     virtual ~SimpleFontData();
 
+    static const SimpleFontData* systemFallback() { return reinterpret_cast<const SimpleFontData*>(-1); }
+
     const FontPlatformData& platformData() const { return m_platformData; }
 #if ENABLE(OPENTYPE_VERTICAL)
     const OpenTypeVerticalData* verticalData() const { return m_verticalData; }

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp (131702 => 131703)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2012-10-18 04:34:18 UTC (rev 131702)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp	2012-10-18 05:01:00 UTC (rev 131703)
@@ -329,12 +329,8 @@
     nextIsMissingGlyph = false;
 #if !PLATFORM(WX)
     nextFontData = m_font.fontDataForCombiningCharacterSequence(sequenceStart, curr - sequenceStart, nextIsSmallCaps ? SmallCapsVariant : NormalVariant);
-    if (!nextFontData) {
-        if (markCount)
-            nextFontData = systemFallbackFontData();
-        else
-            nextIsMissingGlyph = true;
-    }
+    if (!nextFontData)
+        nextIsMissingGlyph = true;
 #endif
 
     while (curr < end) {
@@ -361,12 +357,8 @@
 #if !PLATFORM(WX)
         else {
             nextFontData = m_font.fontDataForCombiningCharacterSequence(cp + index, curr - cp - index, nextIsSmallCaps ? SmallCapsVariant : NormalVariant);
-            if (!nextFontData) {
-                if (markCount)
-                    nextFontData = systemFallbackFontData();
-                else
-                    nextIsMissingGlyph = true;
-            }
+            if (!nextFontData)
+                nextIsMissingGlyph = true;
         }
 #endif
 

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h (131702 => 131703)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h	2012-10-18 04:34:18 UTC (rev 131702)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.h	2012-10-18 05:01:00 UTC (rev 131703)
@@ -72,8 +72,6 @@
     float maxGlyphBoundingBoxY() const { return m_maxGlyphBoundingBoxY; }
     
 private:
-    static const SimpleFontData* systemFallbackFontData() { return reinterpret_cast<const SimpleFontData*>(-1); }
-
     class ComplexTextRun : public RefCounted<ComplexTextRun> {
     public:
         static PassRefPtr<ComplexTextRun> create(CTRunRef ctRun, const SimpleFontData* fontData, const UChar* characters, unsigned stringLocation, size_t stringLength, CFRange runRange)

Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm (131702 => 131703)


--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2012-10-18 04:34:18 UTC (rev 131702)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm	2012-10-18 05:01:00 UTC (rev 131703)
@@ -200,7 +200,7 @@
 
     UChar32 baseCharacter = 0;
     RetainPtr<CFDictionaryRef> stringAttributes;
-    if (fontData == systemFallbackFontData()) {
+    if (fontData == SimpleFontData::systemFallback()) {
         // FIXME: This code path does not support small caps.
         isSystemFallback = true;
 

Modified: trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp (131702 => 131703)


--- trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp	2012-10-18 04:34:18 UTC (rev 131702)
+++ trunk/Source/WebCore/platform/graphics/mac/FontComplexTextMac.cpp	2012-10-18 05:01:00 UTC (rev 131703)
@@ -176,8 +176,11 @@
 
     GlyphData baseCharacterGlyphData = glyphDataForCharacter(baseCharacter, false, variant);
 
+    if (!baseCharacterGlyphData.glyph)
+        return 0;
+
     if (length == baseCharacterLength)
-        return baseCharacterGlyphData.glyph ? baseCharacterGlyphData.fontData : 0;
+        return baseCharacterGlyphData.fontData;
 
     bool triedBaseCharacterFontData = false;
 
@@ -216,7 +219,7 @@
     if (!triedBaseCharacterFontData && baseCharacterGlyphData.fontData && baseCharacterGlyphData.fontData->canRenderCombiningCharacterSequence(characters, length))
         return baseCharacterGlyphData.fontData;
 
-    return 0;
+    return SimpleFontData::systemFallback();
 }
 
 } // namespace WebCore
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to