[Mac] Font lookups are flakey due to caching
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 May 2015 22:52:35 +0000 (22:52 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 19 May 2015 22:52:35 +0000 (22:52 +0000)
commit3ea1e68ee1b1fecb7d43611ff96249245c69f111
treed022dd38273b0221ddbac857672a340c730c37e3
parent5ce9b796c99c0fa39ab1444aa94409501e0c851b
[Mac] Font lookups are flakey due to caching
https://bugs.webkit.org/show_bug.cgi?id=145180
<rdar://problem/21012406>

Reviewed by Darin Adler.

Source/WebCore:

Font lookups were flakey on Mac due to the cache in fontWithFamily().
The reason is that the "desired family" to "available family" mapping
is sometimes dependent on the desired traits. However, our cache was
only using the "desired family" as key.

This patch now uses a std::pair as key containing both the "desired
family" and the "desired traits" for correctness. I also updated the
cache to use WTF types instead of NS types.

Test: platform/mac/fast/text/font-weights.html

* platform/graphics/mac/FontCacheMac.mm:
(WebCore::desiredFamilyToAvailableFamilyMap):
(WebCore::hasDesiredFamilyToAvailableFamilyMapping):
(WebCore::rememberDesiredFamilyToAvailableFamilyMapping):
(WebCore::fontWithFamily):
(WebCore::invalidateFontCache):
(WebCore::desiredFamilyToAvailableFamilyDictionary): Deleted.

LayoutTests:

* platform/mac/TestExpectations:
Unskip platform/mac/fast/text/font-weights.html as it is no longer
flakey after this change.

* platform/mac/fast/text/font-weights-expected.txt:
Rebaseline the test as the expected results were those based on the
bad caching behavior.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184599 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/mac/fast/text/font-weights-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/mac/FontCacheMac.mm