Title: [187724] trunk/Source/WebCore
- Revision
- 187724
- Author
- mmaxfi...@apple.com
- Date
- 2015-08-01 13:15:23 -0700 (Sat, 01 Aug 2015)
Log Message
Expand CharacterFallbackMapKey to a struct
https://bugs.webkit.org/show_bug.cgi?id=147530
Reviewed by Dean Jackson.
This is in prepraration for making this struct locale-specific.
No new tests because there is no behavior change.
* platform/graphics/Font.cpp:
(WebCore::CharacterFallbackMapKey::CharacterFallbackMapKey):
(WebCore::CharacterFallbackMapKey::isHashTableDeletedValue):
(WebCore::CharacterFallbackMapKey::operator==):
(WebCore::CharacterFallbackMapKeyHash::hash):
(WebCore::CharacterFallbackMapKeyHash::equal):
(WebCore::Font::systemFallbackFontForCharacter):
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (187723 => 187724)
--- trunk/Source/WebCore/ChangeLog 2015-08-01 20:14:20 UTC (rev 187723)
+++ trunk/Source/WebCore/ChangeLog 2015-08-01 20:15:23 UTC (rev 187724)
@@ -1,5 +1,24 @@
2015-08-01 Myles C. Maxfield <mmaxfi...@apple.com>
+ Expand CharacterFallbackMapKey to a struct
+ https://bugs.webkit.org/show_bug.cgi?id=147530
+
+ Reviewed by Dean Jackson.
+
+ This is in prepraration for making this struct locale-specific.
+
+ No new tests because there is no behavior change.
+
+ * platform/graphics/Font.cpp:
+ (WebCore::CharacterFallbackMapKey::CharacterFallbackMapKey):
+ (WebCore::CharacterFallbackMapKey::isHashTableDeletedValue):
+ (WebCore::CharacterFallbackMapKey::operator==):
+ (WebCore::CharacterFallbackMapKeyHash::hash):
+ (WebCore::CharacterFallbackMapKeyHash::equal):
+ (WebCore::Font::systemFallbackFontForCharacter):
+
+2015-08-01 Myles C. Maxfield <mmaxfi...@apple.com>
+
Fix the build after r187721
Unreviewed.
Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (187723 => 187724)
--- trunk/Source/WebCore/platform/graphics/Font.cpp 2015-08-01 20:14:20 UTC (rev 187723)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp 2015-08-01 20:15:23 UTC (rev 187724)
@@ -396,9 +396,51 @@
#endif
}
+struct CharacterFallbackMapKey {
+ CharacterFallbackMapKey()
+ {
+ }
+
+ CharacterFallbackMapKey(UChar32 character, bool isForPlatformFont)
+ : character(character)
+ , isForPlatformFont(isForPlatformFont)
+ {
+ }
+
+ CharacterFallbackMapKey(WTF::HashTableDeletedValueType)
+ : character(-1)
+ {
+ }
+
+ bool isHashTableDeletedValue() const { return character == -1; }
+
+ bool operator==(const CharacterFallbackMapKey& other) const
+ {
+ return character == other.character && isForPlatformFont == other.isForPlatformFont;
+ }
+
+ static const bool emptyValueIsZero = true;
+
+ UChar32 character { 0 };
+ bool isForPlatformFont { false };
+};
+
+struct CharacterFallbackMapKeyHash {
+ static unsigned hash(const CharacterFallbackMapKey& key)
+ {
+ return WTF::pairIntHash(key.character, key.isForPlatformFont);
+ }
+
+ static bool equal(const CharacterFallbackMapKey& a, const CharacterFallbackMapKey& b)
+ {
+ return a == b;
+ }
+
+ static const bool safeToCompareToEmptyOrDeleted = true;
+};
+
// Fonts are not ref'd to avoid cycles.
-typedef std::pair<UChar32, bool /* isForPlatformFont */> CharacterFallbackMapKey;
-typedef HashMap<CharacterFallbackMapKey, Font*> CharacterFallbackMap;
+typedef HashMap<CharacterFallbackMapKey, Font*, CharacterFallbackMapKeyHash, WTF::SimpleClassHashTraits<CharacterFallbackMapKey>> CharacterFallbackMap;
typedef HashMap<const Font*, CharacterFallbackMap> SystemFallbackCache;
static SystemFallbackCache& systemFallbackCache()
@@ -416,8 +458,8 @@
return FontCache::singleton().systemFallbackForCharacters(description, this, isForPlatformFont, &codeUnit, 1);
}
- auto key = std::make_pair(character, isForPlatformFont);
- auto characterAddResult = fontAddResult.iterator->value.add(key, nullptr);
+ auto key = CharacterFallbackMapKey(character, isForPlatformFont);
+ auto characterAddResult = fontAddResult.iterator->value.add(WTF::move(key), nullptr);
Font*& fallbackFont = characterAddResult.iterator->value;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes