Title: [189005] trunk/Source/WebCore
Revision
189005
Author
mmaxfi...@apple.com
Date
2015-08-26 17:20:14 -0700 (Wed, 26 Aug 2015)

Log Message

[Cocoa] PerformanceTest Layout/RegionsShapes.html is failing
https://bugs.webkit.org/show_bug.cgi?id=148464

Reviewed by Andy Estes.

The test is failing because Core Text emits a warning message when you use CTFontCreateWithName()
and it cannot find the name you provide. However, this is exactly the situation we are creating
(by attempting to auto-activate a font if we could not otherwise find it). The fix is to simply
not use that API function in favor of using CTFontCreateWithFontDescriptor(), which does not emit
a warning message..

No new tests because there is no behavior change.

* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::autoActivateFont):
(WebCore::FontCache::createFontPlatformData):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (189004 => 189005)


--- trunk/Source/WebCore/ChangeLog	2015-08-27 00:04:20 UTC (rev 189004)
+++ trunk/Source/WebCore/ChangeLog	2015-08-27 00:20:14 UTC (rev 189005)
@@ -1,3 +1,22 @@
+2015-08-26  Myles C. Maxfield  <mmaxfi...@apple.com>
+
+        [Cocoa] PerformanceTest Layout/RegionsShapes.html is failing
+        https://bugs.webkit.org/show_bug.cgi?id=148464
+
+        Reviewed by Andy Estes.
+
+        The test is failing because Core Text emits a warning message when you use CTFontCreateWithName()
+        and it cannot find the name you provide. However, this is exactly the situation we are creating
+        (by attempting to auto-activate a font if we could not otherwise find it). The fix is to simply
+        not use that API function in favor of using CTFontCreateWithFontDescriptor(), which does not emit
+        a warning message..
+
+        No new tests because there is no behavior change.
+
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::autoActivateFont):
+        (WebCore::FontCache::createFontPlatformData):
+
 2015-08-26  Joseph Pecoraro  <pecor...@apple.com>
 
         Web Inspector: Implement tracking of active stylesheets in the frontend

Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (189004 => 189005)


--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2015-08-27 00:04:20 UTC (rev 189004)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp	2015-08-27 00:20:14 UTC (rev 189005)
@@ -462,6 +462,17 @@
     // Only attempt to auto-activate fonts once for performance reasons.
     return knownFamilies.get().add(family).isNewEntry;
 }
+
+static void autoActivateFont(const String& name, CGFloat size)
+{
+    auto fontName = name.createCFString();
+    CFTypeRef keys[] = { kCTFontNameAttribute };
+    CFTypeRef values[] = { fontName.get() };
+    auto attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, keys, values, WTF_ARRAY_LENGTH(keys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
+    auto descriptor = adoptCF(CTFontDescriptorCreateWithAttributes(attributes.get()));
+    if (auto newFont = CTFontCreateWithFontDescriptor(descriptor.get(), size, nullptr))
+        CFRelease(newFont);
+}
 #endif
 
 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family)
@@ -478,7 +489,7 @@
 
         // Auto activate the font before looking for it a second time.
         // Ignore the result because we want to use our own algorithm to actually find the font.
-        CFRelease(CTFontCreateWithName(family.string().createCFString().get(), size, nullptr));
+        autoActivateFont(family.string(), size);
 
         font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.textRenderingMode(), size);
     }
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to