Modified: trunk/Source/WebCore/ChangeLog (188024 => 188025)
--- trunk/Source/WebCore/ChangeLog 2015-08-06 05:13:40 UTC (rev 188024)
+++ trunk/Source/WebCore/ChangeLog 2015-08-06 05:16:09 UTC (rev 188025)
@@ -1,5 +1,22 @@
2015-08-05 Myles C. Maxfield <mmaxfi...@apple.com>
+ CharacterFallbackMapKey should be locale-specific
+ https://bugs.webkit.org/show_bug.cgi?id=147532
+
+ Reviewed by Dean Jackson.
+
+ This is in preparation for locale-specific font fallback.
+
+ No new tests because there is no behavior change.
+
+ * platform/graphics/Font.cpp:
+ (WebCore::CharacterFallbackMapKey::CharacterFallbackMapKey):
+ (WebCore::CharacterFallbackMapKey::operator==):
+ (WebCore::CharacterFallbackMapKeyHash::hash):
+ (WebCore::Font::systemFallbackFontForCharacter):
+
+2015-08-05 Myles C. Maxfield <mmaxfi...@apple.com>
+
Expand CharacterFallbackMapKey to a struct
https://bugs.webkit.org/show_bug.cgi?id=147530
Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (188024 => 188025)
--- trunk/Source/WebCore/platform/graphics/Font.cpp 2015-08-06 05:13:40 UTC (rev 188024)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp 2015-08-06 05:16:09 UTC (rev 188025)
@@ -38,6 +38,7 @@
#include "OpenTypeMathData.h"
#include <wtf/MathExtras.h>
#include <wtf/NeverDestroyed.h>
+#include <wtf/text/AtomicStringHash.h>
#if ENABLE(OPENTYPE_VERTICAL)
#include "OpenTypeVerticalData.h"
@@ -396,13 +397,15 @@
#endif
}
-struct CharacterFallbackMapKey {
+class CharacterFallbackMapKey {
+public:
CharacterFallbackMapKey()
{
}
- CharacterFallbackMapKey(UChar32 character, bool isForPlatformFont)
- : character(character)
+ CharacterFallbackMapKey(const AtomicString& locale, UChar32 character, bool isForPlatformFont)
+ : locale(locale)
+ , character(character)
, isForPlatformFont(isForPlatformFont)
{
}
@@ -416,11 +419,15 @@
bool operator==(const CharacterFallbackMapKey& other) const
{
- return character == other.character && isForPlatformFont == other.isForPlatformFont;
+ return locale == other.locale && character == other.character && isForPlatformFont == other.isForPlatformFont;
}
static const bool emptyValueIsZero = true;
+private:
+ friend struct CharacterFallbackMapKeyHash;
+
+ AtomicString locale;
UChar32 character { 0 };
bool isForPlatformFont { false };
};
@@ -428,7 +435,7 @@
struct CharacterFallbackMapKeyHash {
static unsigned hash(const CharacterFallbackMapKey& key)
{
- return WTF::pairIntHash(key.character, key.isForPlatformFont);
+ return WTF::pairIntHash(key.locale.isNull() ? 0 : WTF::AtomicStringHash::hash(key.locale), WTF::pairIntHash(key.character, key.isForPlatformFont));
}
static bool equal(const CharacterFallbackMapKey& a, const CharacterFallbackMapKey& b)
@@ -440,6 +447,7 @@
};
// Fonts are not ref'd to avoid cycles.
+// FIXME: Shouldn't these be WeakPtrs?
typedef HashMap<CharacterFallbackMapKey, Font*, CharacterFallbackMapKeyHash, WTF::SimpleClassHashTraits<CharacterFallbackMapKey>> CharacterFallbackMap;
typedef HashMap<const Font*, CharacterFallbackMap> SystemFallbackCache;
@@ -458,7 +466,7 @@
return FontCache::singleton().systemFallbackForCharacters(description, this, isForPlatformFont, &codeUnit, 1);
}
- auto key = CharacterFallbackMapKey(character, isForPlatformFont);
+ auto key = CharacterFallbackMapKey(description.locale(), character, isForPlatformFont);
auto characterAddResult = fontAddResult.iterator->value.add(WTF::move(key), nullptr);
Font*& fallbackFont = characterAddResult.iterator->value;