<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!--
#msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; }
#msg ul, pre { overflow: auto; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<title>[24835] trunk/WebCore</title>
</head>
<body>

<div id="msg">
<dl>
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/24835">24835</a></dd>
<dt>Author</dt> <dd>oliver</dd>
<dt>Date</dt> <dd>2007-08-02 20:17:33 -0700 (Thu, 02 Aug 2007)</dd>
</dl>

<h3>Log Message</h3>
<pre>        Reviewed by Geoff

        Fix for &lt;rdar://problem/5369332&gt; Xcode crashes while selecting a hyperlink within a AppleScript dictionary (WebCore::Font::drawGlyphBuffer)

        There were many places where we were not correctly retaining/releasing the
        NSFont object stored in the C++ PlatformFontData object, this resulted in
        the GC incorrectly collecting the NSFont.

        This patch fixes the problem by prevent direct modification of the PlatformFontData
        font pointer, allowing us to enforce correct CFRetain/Release behaviour.

        * platform/FontData.h:
        (WebCore::FontData::getNSFont):
        * platform/mac/FontCacheMac.mm:
        (WebCore::FontCache::getFontDataForCharacters):
        (WebCore::FontCache::createFontPlatformData):
        * platform/mac/FontDataMac.mm:
        (WebCore::initFontData):
        (WebCore::FontData::platformInit):
        (WebCore::FontData::platformDestroy):
        (WebCore::FontData::smallCapsFontData):
        (WebCore::FontData::containsCharacters):
        (WebCore::FontData::determinePitch):
        (WebCore::FontData::platformWidthForGlyph):
        (WebCore::FontData::checkShapesArabic):
        * platform/mac/FontMac.mm:
        (WebCore::initializeATSUStyle):
        (WebCore::overrideLayoutOperation):
        (WebCore::Font::drawGlyphs):
        * platform/mac/FontPlatformData.h:
        (WebCore::FontPlatformData::FontPlatformData):
        (WebCore::FontPlatformData::~FontPlatformData):
        (WebCore::FontPlatformData::hash):
        (WebCore::FontPlatformData::operator==):
        (WebCore::FontPlatformData::font):
        (WebCore::FontPlatformData::setFont):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkWebCoreChangeLog">trunk/WebCore/ChangeLog</a></li>
<li><a href="#trunkWebCoreplatformFontDatah">trunk/WebCore/platform/FontData.h</a></li>
<li><a href="#trunkWebCoreplatformmacFontCacheMacmm">trunk/WebCore/platform/mac/FontCacheMac.mm</a></li>
<li><a href="#trunkWebCoreplatformmacFontDataMacmm">trunk/WebCore/platform/mac/FontDataMac.mm</a></li>
<li><a href="#trunkWebCoreplatformmacFontMacmm">trunk/WebCore/platform/mac/FontMac.mm</a></li>
<li><a href="#trunkWebCoreplatformmacFontPlatformDatah">trunk/WebCore/platform/mac/FontPlatformData.h</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/ChangeLog (24834 => 24835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/ChangeLog        2007-08-03 00:24:05 UTC (rev 24834)
+++ trunk/WebCore/ChangeLog        2007-08-03 03:17:33 UTC (rev 24835)
</span><span class="lines">@@ -1,3 +1,42 @@
</span><ins>+2007-08-02  Oliver Hunt  &lt;oliver@apple.com&gt;
+
+        Reviewed by Geoff
+
+        Fix for &lt;rdar://problem/5369332&gt; Xcode crashes while selecting a hyperlink within a AppleScript dictionary (WebCore::Font::drawGlyphBuffer)
+
+        There were many places where we were not correctly retaining/releasing the
+        NSFont object stored in the C++ PlatformFontData object, this resulted in
+        the GC incorrectly collecting the NSFont.
+
+        This patch fixes the problem by prevent direct modification of the PlatformFontData
+        font pointer, allowing us to enforce correct CFRetain/Release behaviour.
+
+        * platform/FontData.h:
+        (WebCore::FontData::getNSFont):
+        * platform/mac/FontCacheMac.mm:
+        (WebCore::FontCache::getFontDataForCharacters):
+        (WebCore::FontCache::createFontPlatformData):
+        * platform/mac/FontDataMac.mm:
+        (WebCore::initFontData):
+        (WebCore::FontData::platformInit):
+        (WebCore::FontData::platformDestroy):
+        (WebCore::FontData::smallCapsFontData):
+        (WebCore::FontData::containsCharacters):
+        (WebCore::FontData::determinePitch):
+        (WebCore::FontData::platformWidthForGlyph):
+        (WebCore::FontData::checkShapesArabic):
+        * platform/mac/FontMac.mm:
+        (WebCore::initializeATSUStyle):
+        (WebCore::overrideLayoutOperation):
+        (WebCore::Font::drawGlyphs):
+        * platform/mac/FontPlatformData.h:
+        (WebCore::FontPlatformData::FontPlatformData):
+        (WebCore::FontPlatformData::~FontPlatformData):
+        (WebCore::FontPlatformData::hash):
+        (WebCore::FontPlatformData::operator==):
+        (WebCore::FontPlatformData::font):
+        (WebCore::FontPlatformData::setFont):
+
</ins><span class="cx"> 2007-08-03  Antti Koivisto  &lt;antti@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Oops, this change wasn't supposed to be commited.
</span></span></pre></div>
<a id="trunkWebCoreplatformFontDatah"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/FontData.h (24834 => 24835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/FontData.h        2007-08-03 00:24:05 UTC (rev 24834)
+++ trunk/WebCore/platform/FontData.h        2007-08-03 03:17:33 UTC (rev 24835)
</span><span class="lines">@@ -73,7 +73,7 @@
</span><span class="cx">     const GlyphData&amp; missingGlyphData() const { return m_missingGlyphData; }
</span><span class="cx"> 
</span><span class="cx"> #if PLATFORM(MAC)
</span><del>-    NSFont* getNSFont() const { return m_font.font; }
</del><ins>+    NSFont* getNSFont() const { return m_font.font(); }
</ins><span class="cx">     void checkShapesArabic() const;
</span><span class="cx">     bool shapesArabic() const
</span><span class="cx">     {
</span></span></pre></div>
<a id="trunkWebCoreplatformmacFontCacheMacmm"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/mac/FontCacheMac.mm (24834 => 24835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/mac/FontCacheMac.mm        2007-08-03 00:24:05 UTC (rev 24834)
+++ trunk/WebCore/platform/mac/FontCacheMac.mm        2007-08-03 03:17:33 UTC (rev 24835)
</span><span class="lines">@@ -120,7 +120,7 @@
</span><span class="cx"> const FontData* FontCache::getFontDataForCharacters(const Font&amp; font, const UChar* characters, int length)
</span><span class="cx"> {
</span><span class="cx">     const FontPlatformData&amp; platformData = font.primaryFont()-&gt;platformData();
</span><del>-    NSFont *nsFont = platformData.font;
</del><ins>+    NSFont *nsFont = platformData.font();
</ins><span class="cx"> 
</span><span class="cx">     NSString *string = [[NSString alloc] initWithCharactersNoCopy:const_cast&lt;UChar*&gt;(characters)
</span><span class="cx">         length:length freeWhenDone:NO];
</span><span class="lines">@@ -223,7 +223,7 @@
</span><span class="cx">     FontPlatformData* result = new FontPlatformData;
</span><span class="cx">     
</span><span class="cx">     // Use the correct font for print vs. screen.
</span><del>-    result-&gt;font = fontDescription.usePrinterFont() ? [nsFont printerFont] : [nsFont screenFont];
</del><ins>+    result-&gt;setFont(fontDescription.usePrinterFont() ? [nsFont printerFont] : [nsFont screenFont]);
</ins><span class="cx">     result-&gt;syntheticBold = (traits &amp; NSBoldFontMask) &amp;&amp; !(actualTraits &amp; NSBoldFontMask);
</span><span class="cx">     result-&gt;syntheticOblique = (traits &amp; NSItalicFontMask) &amp;&amp; !(actualTraits &amp; NSItalicFontMask);
</span><span class="cx">     return result;
</span></span></pre></div>
<a id="trunkWebCoreplatformmacFontDataMacmm"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/mac/FontDataMac.mm (24834 => 24835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/mac/FontDataMac.mm        2007-08-03 00:24:05 UTC (rev 24834)
+++ trunk/WebCore/platform/mac/FontDataMac.mm        2007-08-03 03:17:33 UTC (rev 24835)
</span><span class="lines">@@ -58,7 +58,7 @@
</span><span class="cx">     if (ATSUCreateStyle(&amp;fontStyle) != noErr)
</span><span class="cx">         return false;
</span><span class="cx">     
</span><del>-    ATSUFontID fontId = wkGetNSFontATSUFontId(fontData-&gt;m_font.font);
</del><ins>+    ATSUFontID fontId = wkGetNSFontATSUFontId(fontData-&gt;m_font.font());
</ins><span class="cx">     if (!fontId) {
</span><span class="cx">         ATSUDisposeStyle(fontStyle);
</span><span class="cx">         return false;
</span><span class="lines">@@ -111,7 +111,7 @@
</span><span class="cx">         // It overrides the normal &quot;Times&quot; family font.
</span><span class="cx">         // It also appears to have a corrupt regular variant.
</span><span class="cx">         NSString *fallbackFontFamily;
</span><del>-        if ([[m_font.font familyName] isEqual:@&quot;Times&quot;])
</del><ins>+        if ([[m_font.font() familyName] isEqual:@&quot;Times&quot;])
</ins><span class="cx">             fallbackFontFamily = @&quot;Times New Roman&quot;;
</span><span class="cx">         else
</span><span class="cx">             fallbackFontFamily = webFallbackFontFamily();
</span><span class="lines">@@ -119,11 +119,11 @@
</span><span class="cx">         // Try setting up the alternate font.
</span><span class="cx">         // This is a last ditch effort to use a substitute font when something has gone wrong.
</span><span class="cx"> #if !ERROR_DISABLED
</span><del>-        NSFont *initialFont = m_font.font;
</del><ins>+        RetainPtr&lt;NSFont&gt; initialFont = m_font.font();
</ins><span class="cx"> #endif
</span><del>-        m_font.font = [[NSFontManager sharedFontManager] convertFont:m_font.font toFamily:fallbackFontFamily];
</del><ins>+        m_font.setFont([[NSFontManager sharedFontManager] convertFont:m_font.font() toFamily:fallbackFontFamily]);
</ins><span class="cx"> #if !ERROR_DISABLED
</span><del>-        NSString *filePath = wkPathFromFont(initialFont);
</del><ins>+        NSString *filePath = wkPathFromFont(initialFont.get());
</ins><span class="cx">         if (!filePath)
</span><span class="cx">             filePath = @&quot;not known&quot;;
</span><span class="cx"> #endif
</span><span class="lines">@@ -131,29 +131,29 @@
</span><span class="cx">             if ([fallbackFontFamily isEqual:@&quot;Times New Roman&quot;]) {
</span><span class="cx">                 // OK, couldn't setup Times New Roman as an alternate to Times, fallback
</span><span class="cx">                 // on the system font.  If this fails we have no alternative left.
</span><del>-                m_font.font = [[NSFontManager sharedFontManager] convertFont:m_font.font toFamily:webFallbackFontFamily()];
</del><ins>+                m_font.setFont([[NSFontManager sharedFontManager] convertFont:m_font.font() toFamily:webFallbackFontFamily()]);
</ins><span class="cx">                 if (!initFontData(this)) {
</span><span class="cx">                     // We tried, Times, Times New Roman, and the system font. No joy. We have to give up.
</span><del>-                    LOG_ERROR(&quot;unable to initialize with font %@ at %@&quot;, initialFont, filePath);
</del><ins>+                    LOG_ERROR(&quot;unable to initialize with font %@ at %@&quot;, initialFont.get(), filePath);
</ins><span class="cx">                     failedSetup = true;
</span><span class="cx">                 }
</span><span class="cx">             } else {
</span><span class="cx">                 // We tried the requested font and the system font. No joy. We have to give up.
</span><del>-                LOG_ERROR(&quot;unable to initialize with font %@ at %@&quot;, initialFont, filePath);
</del><ins>+                LOG_ERROR(&quot;unable to initialize with font %@ at %@&quot;, initialFont.get(), filePath);
</ins><span class="cx">                 failedSetup = true;
</span><span class="cx">             }
</span><span class="cx">         }
</span><span class="cx"> 
</span><span class="cx">         // Report the problem.
</span><span class="cx">         LOG_ERROR(&quot;Corrupt font detected, using %@ in place of %@ located at \&quot;%@\&quot;.&quot;,
</span><del>-            [m_font.font familyName], [initialFont familyName], filePath);
</del><ins>+            [m_font.font() familyName], [initialFont.get() familyName], filePath);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     // If all else fails, try to set up using the system font.
</span><span class="cx">     // This is probably because Times and Times New Roman are both unavailable.
</span><span class="cx">     if (failedSetup) {
</span><del>-        m_font.font = [NSFont systemFontOfSize:[m_font.font pointSize]];
-        LOG_ERROR(&quot;failed to set up font, using system font %s&quot;, m_font.font);
</del><ins>+        m_font.setFont([NSFont systemFontOfSize:[m_font.font() pointSize]]);
+        LOG_ERROR(&quot;failed to set up font, using system font %s&quot;, m_font.font());
</ins><span class="cx">         initFontData(this);
</span><span class="cx">     }
</span><span class="cx">     
</span><span class="lines">@@ -161,8 +161,8 @@
</span><span class="cx">     int iDescent;
</span><span class="cx">     int iLineGap;
</span><span class="cx">     unsigned unitsPerEm;
</span><del>-    wkGetFontMetrics(m_font.font, &amp;iAscent, &amp;iDescent, &amp;iLineGap, &amp;unitsPerEm); 
-    float pointSize = [m_font.font pointSize];
</del><ins>+    wkGetFontMetrics(m_font.font(), &amp;iAscent, &amp;iDescent, &amp;iLineGap, &amp;unitsPerEm); 
+    float pointSize = [m_font.font() pointSize];
</ins><span class="cx">     float fAscent = scaleEmToUnits(iAscent, unitsPerEm) * pointSize;
</span><span class="cx">     float fDescent = -scaleEmToUnits(iDescent, unitsPerEm) * pointSize;
</span><span class="cx">     float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
</span><span class="lines">@@ -172,7 +172,7 @@
</span><span class="cx">     // web standard. The AppKit adjustment of 20% is too big and is
</span><span class="cx">     // incorrectly added to line spacing, so we use a 15% adjustment instead
</span><span class="cx">     // and add it to the ascent.
</span><del>-    NSString *familyName = [m_font.font familyName];
</del><ins>+    NSString *familyName = [m_font.font() familyName];
</ins><span class="cx">     if ([familyName isEqualToString:@&quot;Times&quot;] || [familyName isEqualToString:@&quot;Helvetica&quot;] || [familyName isEqualToString:@&quot;Courier&quot;])
</span><span class="cx">         fAscent += floorf(((fAscent + fDescent) * 0.15f) + 0.5f);
</span><span class="cx"> 
</span><span class="lines">@@ -185,16 +185,14 @@
</span><span class="cx">     // Unfortunately, NSFont will round this for us so we don't quite get the right value.
</span><span class="cx">     NSGlyph xGlyph = GlyphPageTreeNode::getRootChild(this, 0)-&gt;page()-&gt;glyphDataForCharacter('x').glyph;
</span><span class="cx">     if (xGlyph) {
</span><del>-        NSRect xBox = [m_font.font boundingRectForGlyph:xGlyph];
</del><ins>+        NSRect xBox = [m_font.font() boundingRectForGlyph:xGlyph];
</ins><span class="cx">         // Use the maximum of either width or height because &quot;x&quot; is nearly square
</span><span class="cx">         // and web pages that foolishly use this metric for width will be laid out
</span><span class="cx">         // poorly if we return an accurate height. Classic case is Times 13 point,
</span><span class="cx">         // which has an &quot;x&quot; that is 7x6 pixels.
</span><span class="cx">         m_xHeight = MAX(NSMaxX(xBox), NSMaxY(xBox));
</span><span class="cx">     } else
</span><del>-        m_xHeight = [m_font.font xHeight];
-
-    [m_font.font retain];
</del><ins>+        m_xHeight = [m_font.font() xHeight];
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> void FontData::platformDestroy()
</span><span class="lines">@@ -204,31 +202,29 @@
</span><span class="cx"> 
</span><span class="cx">     if (m_ATSUStyleInitialized)
</span><span class="cx">         ATSUDisposeStyle(m_ATSUStyle);
</span><del>-        
-    [m_font.font release];
</del><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> FontData* FontData::smallCapsFontData(const FontDescription&amp; fontDescription) const
</span><span class="cx"> {
</span><span class="cx">     if (!m_smallCapsFontData) {
</span><span class="cx">         NS_DURING
</span><del>-            float size = [m_font.font pointSize] * smallCapsFontSizeMultiplier;
-            FontPlatformData smallCapsFont([[NSFontManager sharedFontManager] convertFont:m_font.font toSize:size]);
</del><ins>+            float size = [m_font.font() pointSize] * smallCapsFontSizeMultiplier;
+            FontPlatformData smallCapsFont([[NSFontManager sharedFontManager] convertFont:m_font.font() toSize:size]);
</ins><span class="cx">             
</span><span class="cx">             // AppKit resets the type information (screen/printer) when you convert a font to a different size.
</span><span class="cx">             // We have to fix up the font that we're handed back.
</span><del>-            smallCapsFont.font = fontDescription.usePrinterFont() ? [smallCapsFont.font printerFont] : [smallCapsFont.font screenFont];
</del><ins>+            smallCapsFont.setFont(fontDescription.usePrinterFont() ? [smallCapsFont.font() printerFont] : [smallCapsFont.font() screenFont]);
</ins><span class="cx"> 
</span><del>-            if (smallCapsFont.font) {
</del><ins>+            if (smallCapsFont.font()) {
</ins><span class="cx">                 NSFontManager *fontManager = [NSFontManager sharedFontManager];
</span><del>-                NSFontTraitMask fontTraits = [fontManager traitsOfFont:m_font.font];
</del><ins>+                NSFontTraitMask fontTraits = [fontManager traitsOfFont:m_font.font()];
</ins><span class="cx"> 
</span><span class="cx">                 if (m_font.syntheticBold)
</span><span class="cx">                     fontTraits |= NSBoldFontMask;
</span><span class="cx">                 if (m_font.syntheticOblique)
</span><span class="cx">                     fontTraits |= NSItalicFontMask;
</span><span class="cx"> 
</span><del>-                NSFontTraitMask smallCapsFontTraits = [fontManager traitsOfFont:smallCapsFont.font];
</del><ins>+                NSFontTraitMask smallCapsFontTraits = [fontManager traitsOfFont:smallCapsFont.font()];
</ins><span class="cx">                 smallCapsFont.syntheticBold = (fontTraits &amp; NSBoldFontMask) &amp;&amp; !(smallCapsFontTraits &amp; NSBoldFontMask);
</span><span class="cx">                 smallCapsFont.syntheticOblique = (fontTraits &amp; NSItalicFontMask) &amp;&amp; !(smallCapsFontTraits &amp; NSItalicFontMask);
</span><span class="cx"> 
</span><span class="lines">@@ -244,7 +240,7 @@
</span><span class="cx"> bool FontData::containsCharacters(const UChar* characters, int length) const
</span><span class="cx"> {
</span><span class="cx">     NSString *string = [[NSString alloc] initWithCharactersNoCopy:(UniChar*)characters length:length freeWhenDone:NO];
</span><del>-    NSCharacterSet *set = [[m_font.font coveredCharacterSet] invertedSet];
</del><ins>+    NSCharacterSet *set = [[m_font.font() coveredCharacterSet] invertedSet];
</ins><span class="cx">     bool result = set &amp;&amp; [string rangeOfCharacterFromSet:set].location == NSNotFound;
</span><span class="cx">     [string release];
</span><span class="cx">     return result;
</span><span class="lines">@@ -252,7 +248,7 @@
</span><span class="cx"> 
</span><span class="cx"> void FontData::determinePitch()
</span><span class="cx"> {
</span><del>-    NSFont* f = m_font.font;
</del><ins>+    NSFont* f = m_font.font();
</ins><span class="cx">     // Special case Osaka-Mono.
</span><span class="cx">     // According to &lt;rdar://problem/3999467&gt;, we should treat Osaka-Mono as fixed pitch.
</span><span class="cx">     // Note that the AppKit does not report Osaka-Mono as fixed pitch.
</span><span class="lines">@@ -269,7 +265,7 @@
</span><span class="cx"> 
</span><span class="cx"> float FontData::platformWidthForGlyph(Glyph glyph) const
</span><span class="cx"> {
</span><del>-    NSFont *font = m_font.font;
</del><ins>+    NSFont *font = m_font.font();
</ins><span class="cx">     float pointSize = [font pointSize];
</span><span class="cx">     CGAffineTransform m = CGAffineTransformMakeScale(pointSize, pointSize);
</span><span class="cx">     CGSize advance;
</span><span class="lines">@@ -286,9 +282,9 @@
</span><span class="cx"> 
</span><span class="cx">     m_checkedShapesArabic = true;
</span><span class="cx">     
</span><del>-    ATSUFontID fontID = wkGetNSFontATSUFontId(m_font.font);
</del><ins>+    ATSUFontID fontID = wkGetNSFontATSUFontId(m_font.font());
</ins><span class="cx">     if (!fontID) {
</span><del>-        LOG_ERROR(&quot;unable to get ATSUFontID for %@&quot;, m_font.font);
</del><ins>+        LOG_ERROR(&quot;unable to get ATSUFontID for %@&quot;, m_font.font());
</ins><span class="cx">         return;
</span><span class="cx">     }
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkWebCoreplatformmacFontMacmm"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/mac/FontMac.mm (24834 => 24835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/mac/FontMac.mm        2007-08-03 00:24:05 UTC (rev 24834)
+++ trunk/WebCore/platform/mac/FontMac.mm        2007-08-03 03:17:33 UTC (rev 24835)
</span><span class="lines">@@ -107,17 +107,17 @@
</span><span class="cx">         if (status != noErr)
</span><span class="cx">             LOG_ERROR(&quot;ATSUCreateStyle failed (%d)&quot;, status);
</span><span class="cx">     
</span><del>-        ATSUFontID fontID = wkGetNSFontATSUFontId(fontData-&gt;m_font.font);
</del><ins>+        ATSUFontID fontID = wkGetNSFontATSUFontId(fontData-&gt;m_font.font());
</ins><span class="cx">         if (fontID == 0) {
</span><span class="cx">             ATSUDisposeStyle(fontData-&gt;m_ATSUStyle);
</span><del>-            LOG_ERROR(&quot;unable to get ATSUFontID for %@&quot;, fontData-&gt;m_font.font);
</del><ins>+            LOG_ERROR(&quot;unable to get ATSUFontID for %@&quot;, fontData-&gt;m_font.font());
</ins><span class="cx">             return;
</span><span class="cx">         }
</span><span class="cx">         
</span><span class="cx">         CGAffineTransform transform = CGAffineTransformMakeScale(1, -1);
</span><span class="cx">         if (fontData-&gt;m_font.syntheticOblique)
</span><span class="cx">             transform = CGAffineTransformConcat(transform, CGAffineTransformMake(1, 0, -tanf(SYNTHETIC_OBLIQUE_ANGLE * acosf(0) / 90), 1, 0, 0)); 
</span><del>-        Fixed fontSize = FloatToFixed([fontData-&gt;m_font.font pointSize]);
</del><ins>+        Fixed fontSize = FloatToFixed([fontData-&gt;m_font.font() pointSize]);
</ins><span class="cx">         // Turn off automatic kerning until it is supported in the CG code path (6136 in bugzilla)
</span><span class="cx">         Fract kerningInhibitFactor = FloatToFract(1.0);
</span><span class="cx">         ATSUAttributeTag styleTags[4] = { kATSUSizeTag, kATSUFontTag, kATSUFontMatrixTag, kATSUKerningInhibitFactorTag };
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx">         // Don't be too aggressive: if the font doesn't contain 'a', then assume that any ligatures it contains are
</span><span class="cx">         // in characters that always go through ATSUI, and therefore allow them. Geeza Pro is an example.
</span><span class="cx">         // See bugzilla 5166.
</span><del>-        if ([[fontData-&gt;m_font.font coveredCharacterSet] characterIsMember:'a']) {
</del><ins>+        if ([[fontData-&gt;m_font.font() coveredCharacterSet] characterIsMember:'a']) {
</ins><span class="cx">             ATSUFontFeatureType featureTypes[] = { kLigaturesType };
</span><span class="cx">             ATSUFontFeatureSelector featureSelectors[] = { kCommonLigaturesOffSelector };
</span><span class="cx">             status = ATSUSetFontFeatures(fontData-&gt;m_ATSUStyle, 1, featureTypes, featureSelectors);
</span><span class="lines">@@ -191,7 +191,7 @@
</span><span class="cx">                 // The CoreGraphics interpretation of NSFontAntialiasedIntegerAdvancementsRenderingMode seems
</span><span class="cx">                 // to be &quot;round each glyph's width to the nearest integer&quot;. This is not the same as ATSUI
</span><span class="cx">                 // does in any of its device-metrics modes.
</span><del>-                shouldRound = [renderer-&gt;m_font.font renderingMode] == NSFontAntialiasedIntegerAdvancementsRenderingMode;
</del><ins>+                shouldRound = [renderer-&gt;m_font.font() renderingMode] == NSFontAntialiasedIntegerAdvancementsRenderingMode;
</ins><span class="cx">                 if (syntheticBoldPass)
</span><span class="cx">                     syntheticBoldOffset = FloatToFixed(renderer-&gt;m_syntheticBoldOffset);
</span><span class="cx">             }
</span><span class="lines">@@ -609,16 +609,16 @@
</span><span class="cx">     const FontPlatformData&amp; platformData = font-&gt;platformData();
</span><span class="cx">     NSFont* drawFont;
</span><span class="cx">     if (!isPrinterFont()) {
</span><del>-        drawFont = [platformData.font screenFont];
-        if (drawFont != platformData.font)
</del><ins>+        drawFont = [platformData.font() screenFont];
+        if (drawFont != platformData.font())
</ins><span class="cx">             // We are getting this in too many places (3406411); use ERROR so it only prints on debug versions for now. (We should debug this also, eventually).
</span><span class="cx">             LOG_ERROR(&quot;Attempting to set non-screen font (%@) when drawing to screen.  Using screen font anyway, may result in incorrect metrics.&quot;,
</span><del>-                [[[platformData.font fontDescriptor] fontAttributes] objectForKey:NSFontNameAttribute]);
</del><ins>+                [[[platformData.font() fontDescriptor] fontAttributes] objectForKey:NSFontNameAttribute]);
</ins><span class="cx">     } else {
</span><del>-        drawFont = [platformData.font printerFont];
-        if (drawFont != platformData.font)
</del><ins>+        drawFont = [platformData.font() printerFont];
+        if (drawFont != platformData.font())
</ins><span class="cx">             NSLog(@&quot;Attempting to set non-printer font (%@) when printing.  Using printer font anyway, may result in incorrect metrics.&quot;,
</span><del>-                [[[platformData.font fontDescriptor] fontAttributes] objectForKey:NSFontNameAttribute]);
</del><ins>+                [[[platformData.font() fontDescriptor] fontAttributes] objectForKey:NSFontNameAttribute]);
</ins><span class="cx">     }
</span><span class="cx">     
</span><span class="cx">     CGContextSetFont(cgContext, wkGetCGFontFromNSFont(drawFont));
</span></span></pre></div>
<a id="trunkWebCoreplatformmacFontPlatformDatah"></a>
<div class="modfile"><h4>Modified: trunk/WebCore/platform/mac/FontPlatformData.h (24834 => 24835)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/WebCore/platform/mac/FontPlatformData.h        2007-08-03 00:24:05 UTC (rev 24834)
+++ trunk/WebCore/platform/mac/FontPlatformData.h        2007-08-03 03:17:33 UTC (rev 24835)
</span><span class="lines">@@ -41,11 +41,11 @@
</span><span class="cx">     class Deleted {};
</span><span class="cx"> 
</span><span class="cx">     FontPlatformData(Deleted)
</span><del>-    : font((NSFont*)-1), syntheticBold(false), syntheticOblique(false)
</del><ins>+    : syntheticBold(false), syntheticOblique(false), m_font((NSFont*)-1)
</ins><span class="cx">     {}
</span><span class="cx"> 
</span><span class="cx">     FontPlatformData(NSFont* f = 0, bool b = false, bool o = false)
</span><del>-    : font(f), syntheticBold(b), syntheticOblique(o)
</del><ins>+    : syntheticBold(b), syntheticOblique(o), m_font(f)
</ins><span class="cx">     {
</span><span class="cx">         if (f) 
</span><span class="cx">             CFRetain(f);
</span><span class="lines">@@ -53,31 +53,42 @@
</span><span class="cx"> 
</span><span class="cx">     FontPlatformData(const FontPlatformData&amp; f)
</span><span class="cx">     {
</span><del>-        font = (f.font &amp;&amp; f.font != (NSFont*)-1) ? (NSFont*)CFRetain(f.font) : f.font;
</del><ins>+        m_font = (f.m_font &amp;&amp; f.m_font != (NSFont*)-1) ? (NSFont*)CFRetain(f.m_font) : f.m_font;
</ins><span class="cx">         syntheticBold = f.syntheticBold;
</span><span class="cx">         syntheticOblique = f.syntheticOblique;
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     ~FontPlatformData()
</span><span class="cx">     {
</span><del>-        if (font &amp;&amp; font != (NSFont*)-1)
-            CFRelease(font);
</del><ins>+        if (m_font &amp;&amp; m_font != (NSFont*)-1)
+            CFRelease(m_font);
</ins><span class="cx">     }
</span><span class="cx"> 
</span><del>-    NSFont *font;
</del><span class="cx">     bool syntheticBold;
</span><span class="cx">     bool syntheticOblique;
</span><span class="cx"> 
</span><span class="cx">     unsigned hash() const
</span><span class="cx">     { 
</span><del>-        uintptr_t hashCodes[2] = { (uintptr_t)font, syntheticBold &lt;&lt; 1 | syntheticOblique };
</del><ins>+        uintptr_t hashCodes[2] = { (uintptr_t)m_font, syntheticBold &lt;&lt; 1 | syntheticOblique };
</ins><span class="cx">         return StringImpl::computeHash(reinterpret_cast&lt;UChar*&gt;(hashCodes), sizeof(hashCodes) / sizeof(UChar));
</span><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     bool operator==(const FontPlatformData&amp; other) const
</span><span class="cx">     { 
</span><del>-        return font == other.font &amp;&amp; syntheticBold == other.syntheticBold &amp;&amp; syntheticOblique == other.syntheticOblique;
</del><ins>+        return m_font == other.m_font &amp;&amp; syntheticBold == other.syntheticBold &amp;&amp; syntheticOblique == other.syntheticOblique;
</ins><span class="cx">     }
</span><ins>+    NSFont *font() const { return m_font; }
+    void setFont(NSFont* font) {
+        if (m_font == font)
+            return;
+        if (font &amp;&amp; font != (NSFont*)-1)
+            CFRetain(font);
+        if (m_font &amp;&amp; m_font != (NSFont*)-1)
+            CFRelease(m_font);
+        m_font = font;
+    }
+private:
+    NSFont *m_font;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> }
</span></span></pre>
</div>
</div>

</body>
</html>