<rdar://problem/11025217> [Mac] Assertion failure in collectComplexTextRunsForCharact...
authormitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Mar 2012 23:57:32 +0000 (23:57 +0000)
committermitz@apple.com <mitz@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Mar 2012 23:57:32 +0000 (23:57 +0000)
https://bugs.webkit.org/show_bug.cgi?id=77044

Reviewed by Sam Weinig.

Source/WebCore:

Test: platform/mac/fast/text/core-text-fallback-to-unknown-font.html

Handle the case of Core Text choosing a fallback font that NSFontManager cannot find by name.

* platform/graphics/FontCache.h:
(FontCache): Made ComplexTextController a friend class.
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText): Removed the
failing assertion, which was not true, and added code to handle the case where a font
cannot be found by name by using the font as returned from Core Text.

LayoutTests:

* platform/mac/fast/text/core-text-fallback-to-unknown-font-expected.txt: Added.
* platform/mac/fast/text/core-text-fallback-to-unknown-font.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/platform/mac/fast/text/core-text-fallback-to-unknown-font-expected.txt [new file with mode: 0644]
LayoutTests/platform/mac/fast/text/core-text-fallback-to-unknown-font.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/FontCache.h
Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm

index 078f1a963ee35166c7bf2014d83c10ce44948b83..606898782bb63ba3e7f70703dbc5259656a1e7f4 100644 (file)
@@ -1,3 +1,13 @@
+2012-03-13  Dan Bernstein  <mitz@apple.com>
+
+        <rdar://problem/11025217> [Mac] Assertion failure in collectComplexTextRunsForCharactersCoreText
+        https://bugs.webkit.org/show_bug.cgi?id=77044
+
+        Reviewed by Sam Weinig.
+
+        * platform/mac/fast/text/core-text-fallback-to-unknown-font-expected.txt: Added.
+        * platform/mac/fast/text/core-text-fallback-to-unknown-font.html: Added.
+
 2012-03-13  Erik Arvidsson  <arv@chromium.org>
 
         [V8] Use v8::V8::AddImplicitReferences instead of SetHiddenValue
diff --git a/LayoutTests/platform/mac/fast/text/core-text-fallback-to-unknown-font-expected.txt b/LayoutTests/platform/mac/fast/text/core-text-fallback-to-unknown-font-expected.txt
new file mode 100644 (file)
index 0000000..7848090
--- /dev/null
@@ -0,0 +1,3 @@
+This test passes if it does not cause an assertion failure or a crash.
+
+◌̣
diff --git a/LayoutTests/platform/mac/fast/text/core-text-fallback-to-unknown-font.html b/LayoutTests/platform/mac/fast/text/core-text-fallback-to-unknown-font.html
new file mode 100644 (file)
index 0000000..0af5d22
--- /dev/null
@@ -0,0 +1,8 @@
+<script>
+    if (window.layoutTestController)
+        layoutTestController.dumpAsText();
+</script>
+<p>
+    This test passes if it does not cause an assertion failure or a crash.
+</p>
+<span style="font-weight: bold; font-family: helvetica">&#x25cc;&#x0323;</span>
index 0951b0a821ce7072199f944a5d39c8892063d26e..1e911f8a0f6830a9cbb163ebbd668b190bd902fd 100644 (file)
@@ -1,3 +1,21 @@
+2012-03-13  Dan Bernstein  <mitz@apple.com>
+
+        <rdar://problem/11025217> [Mac] Assertion failure in collectComplexTextRunsForCharactersCoreText
+        https://bugs.webkit.org/show_bug.cgi?id=77044
+
+        Reviewed by Sam Weinig.
+
+        Test: platform/mac/fast/text/core-text-fallback-to-unknown-font.html
+
+        Handle the case of Core Text choosing a fallback font that NSFontManager cannot find by name.
+
+        * platform/graphics/FontCache.h:
+        (FontCache): Made ComplexTextController a friend class.
+        * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharactersCoreText): Removed the
+        failing assertion, which was not true, and added code to handle the case where a font
+        cannot be found by name by using the font as returned from Core Text.
+
 2012-03-13  Erik Arvidsson  <arv@chromium.org>
 
         [V8] Use v8::V8::AddImplicitReferences instead of SetHiddenValue
index ed399bbc840e985485d25c68480ce94de7281338..89e71d0928f092643524749c3b4055fd6c2bcaf3 100644 (file)
@@ -130,6 +130,9 @@ private:
     // Don't purge if this count is > 0;
     int m_purgePreventCount;
 
+#if USE(CORE_TEXT)
+    friend class ComplexTextController;
+#endif
     friend class SimpleFontData; // For getCachedFontData(const FontPlatformData*)
     friend class FontFallbackList;
 };
index 1a544a7a1ff51bf2ea5f4db8b89feb7e7bb7eb17..0c7ad1b4a0f3e1a3a2bb11a3111022ad5446ba7b 100644 (file)
@@ -271,8 +271,13 @@ void ComplexTextController::collectComplexTextRunsForCharactersCoreText(const UC
                         continue;
                     }
                     runFontData = fontCache()->getCachedFontData(m_font.fontDescription(), fontName.get(), false, FontCache::DoNotRetain);
+                    // Core Text may have used a font that is not known to NSFontManager. In that case, fall back on
+                    // using the font as returned, even though it may not have the best NSFontRenderingMode.
+                    if (!runFontData) {
+                        FontPlatformData runFontPlatformData((NSFont *)runFont, CTFontGetSize(runFont));
+                        runFontData = fontCache()->getCachedFontData(&runFontPlatformData, FontCache::DoNotRetain);
+                    }
                 }
-                ASSERT(runFontData);
                 if (m_fallbackFonts && runFontData != m_font.primaryFont())
                     m_fallbackFonts->add(runFontData);
             }