|
Lines 37-42
a/Source/WebCore/platform/graphics/FontCache.h_sec1
|
| 37 |
#include <wtf/PassRefPtr.h> |
37 |
#include <wtf/PassRefPtr.h> |
| 38 |
#include <wtf/RefPtr.h> |
38 |
#include <wtf/RefPtr.h> |
| 39 |
#include <wtf/Vector.h> |
39 |
#include <wtf/Vector.h> |
|
|
40 |
#include <wtf/text/AtomicStringHash.h> |
| 40 |
#include <wtf/text/WTFString.h> |
41 |
#include <wtf/text/WTFString.h> |
| 41 |
|
42 |
|
| 42 |
#if PLATFORM(IOS) |
43 |
#if PLATFORM(IOS) |
|
Lines 67-84
typedef IMLangFontLink IMLangFontLinkType;
a/Source/WebCore/platform/graphics/FontCache.h_sec2
|
| 67 |
|
68 |
|
| 68 |
// This key contains the FontDescription fields other than family that matter when fetching FontDatas (platform fonts). |
69 |
// This key contains the FontDescription fields other than family that matter when fetching FontDatas (platform fonts). |
| 69 |
struct FontDescriptionKey { |
70 |
struct FontDescriptionKey { |
| 70 |
explicit FontDescriptionKey(unsigned size = 0) |
71 |
FontDescriptionKey() |
| 71 |
: size(size) |
72 |
: m_size(0) |
| 72 |
, weight(0) |
73 |
, m_weight(0) |
| 73 |
, flags(0) |
74 |
, m_flags(0) |
| 74 |
, localeHash(0) |
75 |
, m_featureSettings(0) |
| 75 |
{ } |
76 |
{ } |
|
|
77 |
|
| 76 |
FontDescriptionKey(const FontDescription& description) |
78 |
FontDescriptionKey(const FontDescription& description) |
| 77 |
: size(description.computedPixelSize()) |
79 |
: m_size(description.computedPixelSize()) |
| 78 |
, weight(description.weight()) |
80 |
, m_weight(description.weight()) |
| 79 |
, flags(makeFlagKey(description)) |
81 |
, m_flags(makeFlagKey(description)) |
| 80 |
, localeHash(description.locale().isNull() ? 0 : description.locale().impl()->existingHash()) |
82 |
, m_locale(description.locale()) |
|
|
83 |
, m_featureSettings(description.featureSettings()) |
| 84 |
{ } |
| 85 |
|
| 86 |
explicit FontDescriptionKey(WTF::HashTableDeletedValueType) |
| 87 |
: m_size(cHashTableDeletedSize) |
| 81 |
{ } |
88 |
{ } |
|
|
89 |
|
| 90 |
bool operator==(const FontDescriptionKey& other) const |
| 91 |
{ |
| 92 |
return m_size == other.m_size && m_weight == other.m_weight && m_flags == other.m_flags && m_locale == other.m_locale |
| 93 |
&& ((m_featureSettings == other.m_featureSettings) || (m_featureSettings && other.m_featureSettings && m_featureSettings.get() == other.m_featureSettings.get())); |
| 94 |
} |
| 95 |
|
| 96 |
bool operator!=(const FontDescriptionKey& other) const |
| 97 |
{ |
| 98 |
return !(*this == other); |
| 99 |
} |
| 100 |
|
| 101 |
bool isHashTableDeletedValue() const { return m_size == cHashTableDeletedSize; } |
| 102 |
|
| 103 |
inline unsigned computeHash() const |
| 104 |
{ |
| 105 |
unsigned result = WTF::intHash(m_size); |
| 106 |
result = WTF::pairIntHash(result, WTF::intHash(m_weight)); |
| 107 |
result = WTF::pairIntHash(result, WTF::intHash(m_flags)); |
| 108 |
result = WTF::pairIntHash(result, WTF::intHash(m_flags)); |
| 109 |
result = WTF::PairHash<AtomicString, unsigned>::hash(std::make_pair(m_locale, result)); |
| 110 |
result = WTF::pairIntHash(result, m_featureSettings ? m_featureSettings->hash() : 0); |
| 111 |
return result; |
| 112 |
} |
| 113 |
|
| 114 |
private: |
| 82 |
static unsigned makeFlagKey(const FontDescription& description) |
115 |
static unsigned makeFlagKey(const FontDescription& description) |
| 83 |
{ |
116 |
{ |
| 84 |
static_assert(USCRIPT_CODE_LIMIT < 0x1000, "Script code must fit in an unsigned along with the other flags"); |
117 |
static_assert(USCRIPT_CODE_LIMIT < 0x1000, "Script code must fit in an unsigned along with the other flags"); |
|
Lines 91-112
struct FontDescriptionKey {
a/Source/WebCore/platform/graphics/FontCache.h_sec3
|
| 91 |
| static_cast<unsigned>(description.italic()) << 1 |
124 |
| static_cast<unsigned>(description.italic()) << 1 |
| 92 |
| static_cast<unsigned>(description.renderingMode()); |
125 |
| static_cast<unsigned>(description.renderingMode()); |
| 93 |
} |
126 |
} |
| 94 |
bool operator==(const FontDescriptionKey& other) const |
127 |
|
| 95 |
{ |
128 |
static const unsigned cHashTableDeletedSize = 0xFFFFFFFFU; |
| 96 |
return size == other.size && weight == other.weight && flags == other.flags && localeHash == other.localeHash; |
129 |
|
| 97 |
} |
130 |
unsigned m_size; |
| 98 |
bool operator!=(const FontDescriptionKey& other) const |
131 |
unsigned m_weight; |
| 99 |
{ |
132 |
unsigned m_flags; |
| 100 |
return !(*this == other); |
133 |
AtomicString m_locale; |
| 101 |
} |
134 |
RefPtr<FontFeatureSettings> m_featureSettings; |
| 102 |
inline unsigned computeHash() const |
|
|
| 103 |
{ |
| 104 |
return StringHasher::hashMemory<sizeof(FontDescriptionKey)>(this); |
| 105 |
} |
| 106 |
unsigned size; |
| 107 |
unsigned weight; |
| 108 |
unsigned flags; |
| 109 |
unsigned localeHash; // FIXME: Here, and every client of us, makes hashes of hashes. |
| 110 |
}; |
135 |
}; |
| 111 |
|
136 |
|
| 112 |
class FontCache { |
137 |
class FontCache { |