[Cocoa] Break internal reference cycle in WebCore::Font.
authorakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Feb 2015 16:46:18 +0000 (16:46 +0000)
committerakling@apple.com <akling@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 24 Feb 2015 16:46:18 +0000 (16:46 +0000)
commitd8cdf751862ec7f4e127822b1980bcc95c96fc8c
treeaa19c56e42c080a76de3ce7fceba4298241fde34
parentd78529abd1c0eb0c4ba0881d73455797c59ad4d5
[Cocoa] Break internal reference cycle in WebCore::Font.
<https://webkit.org/b/141941>
<rdar://problem/19650570>

Reviewed by Antti Koivisto.

The Cocoa implementation of Font::platformCreateScaledFont() tried to be smart and use the FontCache.
This didn't work out well when scaling a 0pt Font, since scaling 0pt by any factor will return 0pt.

We'd have a 0pt font, scale it by 0.7 to get a small-caps variant, and then cache that small-caps
variant (really "this") in Font::m_derivedData->smallCaps.

Fix this by having Cocoa Font scaling do exactly what other platforms do: create a new Font every time.
This stops us from accumulating tons of abandoned Font objects over time.

* platform/graphics/Font.cpp:
(WebCore::Font::verticalRightOrientationFont):
(WebCore::Font::uprightOrientationFont):
(WebCore::Font::smallCapsFont):
(WebCore::Font::emphasisMarkFont):
(WebCore::Font::brokenIdeographFont):
(WebCore::Font::nonSyntheticItalicFont): Add assertions to guard against reference cycles inside a Font.

* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::Font::platformCreateScaledFont): Always create a new Font when scaling an existing Font to a different size.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180561 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/cocoa/FontCocoa.mm