Unreviewed, rolling out r93771.
authorpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Aug 2011 13:08:05 +0000 (13:08 +0000)
committerpodivilov@chromium.org <podivilov@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 25 Aug 2011 13:08:05 +0000 (13:08 +0000)
http://trac.webkit.org/changeset/93771
https://bugs.webkit.org/show_bug.cgi?id=66933

Broke css3/font-feature-settings-rendering.html on chromium
mac 10.5 (Requested by podivilov on #webkit).

Patch by Sheriff Bot <webkit.review.bot@gmail.com> on 2011-08-25

* platform/graphics/mac/FontCustomPlatformData.cpp:
(WebCore::FontCustomPlatformData::~FontCustomPlatformData):
(WebCore::createFontCustomPlatformData):
* platform/graphics/mac/FontCustomPlatformData.h:
(WebCore::FontCustomPlatformData::FontCustomPlatformData):

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

Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/mac/FontCustomPlatformData.cpp
Source/WebCore/platform/graphics/mac/FontCustomPlatformData.h

index 325eb45..1248e09 100644 (file)
@@ -1,3 +1,18 @@
+2011-08-25  Sheriff Bot  <webkit.review.bot@gmail.com>
+
+        Unreviewed, rolling out r93771.
+        http://trac.webkit.org/changeset/93771
+        https://bugs.webkit.org/show_bug.cgi?id=66933
+
+        Broke css3/font-feature-settings-rendering.html on chromium
+        mac 10.5 (Requested by podivilov on #webkit).
+
+        * platform/graphics/mac/FontCustomPlatformData.cpp:
+        (WebCore::FontCustomPlatformData::~FontCustomPlatformData):
+        (WebCore::createFontCustomPlatformData):
+        * platform/graphics/mac/FontCustomPlatformData.h:
+        (WebCore::FontCustomPlatformData::FontCustomPlatformData):
+
 2011-08-23  Jocelyn Turcotte  <jocelyn.turcotte@nokia.com>
 
         [Qt][WK2] Drive tiling from the WebProcess and reuse TiledBackingStore.
index a589ba3..47d1f21 100644 (file)
@@ -78,6 +78,10 @@ private:
 
 FontCustomPlatformData::~FontCustomPlatformData()
 {
+#ifdef BUILDING_ON_LEOPARD
+    if (m_atsContainer)
+        ATSFontDeactivate(m_atsContainer, NULL, kATSOptionFlagsDefault);
+#endif
 #if USE(SKIA_ON_MAC_CHROMIUM)
     SkSafeUnref(m_typeface);
 #endif
@@ -111,16 +115,51 @@ FontCustomPlatformData* createFontCustomPlatformData(SharedBuffer* buffer)
     }
 #endif
 
+    ATSFontContainerRef containerRef = 0;
+
     RetainPtr<CGFontRef> cgFontRef;
 
+#ifndef BUILDING_ON_LEOPARD
     RetainPtr<CFDataRef> bufferData(AdoptCF, buffer->createCFData());
     RetainPtr<CGDataProviderRef> dataProvider(AdoptCF, CGDataProviderCreateWithCFData(bufferData.get()));
 
     cgFontRef.adoptCF(CGFontCreateWithDataProvider(dataProvider.get()));
     if (!cgFontRef)
         return 0;
+#else
+    // Use ATS to activate the font.
+
+    // The value "3" means that the font is private and can't be seen by anyone else.
+    ATSFontActivateFromMemory((void*)buffer->data(), buffer->size(), 3, kATSFontFormatUnspecified, NULL, kATSOptionFlagsDefault, &containerRef);
+    if (!containerRef)
+        return 0;
+    ItemCount fontCount;
+    ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 0, NULL, &fontCount);
+    
+    // We just support the first font in the list.
+    if (fontCount == 0) {
+        ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
+        return 0;
+    }
+    
+    ATSFontRef fontRef = 0;
+    ATSFontFindFromContainer(containerRef, kATSOptionFlagsDefault, 1, &fontRef, NULL);
+    if (!fontRef) {
+        ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
+        return 0;
+    }
+    
+    cgFontRef.adoptCF(CGFontCreateWithPlatformFont(&fontRef));
+    // Workaround for <rdar://problem/5675504>.
+    if (cgFontRef && !CGFontGetNumberOfGlyphs(cgFontRef.get()))
+        cgFontRef = 0;
+    if (!cgFontRef) {
+        ATSFontDeactivate(containerRef, NULL, kATSOptionFlagsDefault);
+        return 0;
+    }
+#endif // !defined(BUILDING_ON_LEOPARD)
 
-    FontCustomPlatformData* fontCustomPlatformData = new FontCustomPlatformData(cgFontRef.releaseRef());
+    FontCustomPlatformData* fontCustomPlatformData = new FontCustomPlatformData(containerRef, cgFontRef.releaseRef());
 #if USE(SKIA_ON_MAC_CHROMIUM)
     RemoteFontStream* stream = new RemoteFontStream(buffer);
     fontCustomPlatformData->m_typeface = SkTypeface::CreateFromStream(stream);
index b0a9f69..d63ebf0 100644 (file)
@@ -45,8 +45,9 @@ class SharedBuffer;
 struct FontCustomPlatformData {
     WTF_MAKE_NONCOPYABLE(FontCustomPlatformData);
 public:
-    explicit FontCustomPlatformData(CGFontRef cgFont)
-        : m_cgFont(cgFont)
+    FontCustomPlatformData(ATSFontContainerRef container, CGFontRef cgFont)
+        : m_atsContainer(container)
+        , m_cgFont(cgFont)
 #if USE(SKIA_ON_MAC_CHROMIUM)
         , m_typeface(0)
 #endif
@@ -59,6 +60,7 @@ public:
 
     static bool supportsFormat(const String&);
 
+    ATSFontContainerRef m_atsContainer;
     CGFontRef m_cgFont;
 #if USE(SKIA_ON_MAC_CHROMIUM)
     SkTypeface* m_typeface;