Changeset 188025 in webkit


Ignore:
Timestamp:
Aug 5, 2015 10:16:09 PM (9 years ago)
Author:
mmaxfield@apple.com
Message:

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):

Location:
trunk/Source/WebCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r188024 r188025  
     12015-08-05  Myles C. Maxfield  <mmaxfield@apple.com>
     2
     3        CharacterFallbackMapKey should be locale-specific
     4        https://bugs.webkit.org/show_bug.cgi?id=147532
     5
     6        Reviewed by Dean Jackson.
     7
     8        This is in preparation for locale-specific font fallback.
     9
     10        No new tests because there is no behavior change.
     11
     12        * platform/graphics/Font.cpp:
     13        (WebCore::CharacterFallbackMapKey::CharacterFallbackMapKey):
     14        (WebCore::CharacterFallbackMapKey::operator==):
     15        (WebCore::CharacterFallbackMapKeyHash::hash):
     16        (WebCore::Font::systemFallbackFontForCharacter):
     17
    1182015-08-05  Myles C. Maxfield  <mmaxfield@apple.com>
    219
  • trunk/Source/WebCore/platform/graphics/Font.cpp

    r188024 r188025  
    3939#include <wtf/MathExtras.h>
    4040#include <wtf/NeverDestroyed.h>
     41#include <wtf/text/AtomicStringHash.h>
    4142
    4243#if ENABLE(OPENTYPE_VERTICAL)
     
    397398}
    398399
    399 struct CharacterFallbackMapKey {
     400class CharacterFallbackMapKey {
     401public:
    400402    CharacterFallbackMapKey()
    401403    {
    402404    }
    403405
    404     CharacterFallbackMapKey(UChar32 character, bool isForPlatformFont)
    405         : character(character)
     406    CharacterFallbackMapKey(const AtomicString& locale, UChar32 character, bool isForPlatformFont)
     407        : locale(locale)
     408        , character(character)
    406409        , isForPlatformFont(isForPlatformFont)
    407410    {
     
    417420    bool operator==(const CharacterFallbackMapKey& other) const
    418421    {
    419         return character == other.character && isForPlatformFont == other.isForPlatformFont;
     422        return locale == other.locale && character == other.character && isForPlatformFont == other.isForPlatformFont;
    420423    }
    421424
    422425    static const bool emptyValueIsZero = true;
    423426
     427private:
     428    friend struct CharacterFallbackMapKeyHash;
     429
     430    AtomicString locale;
    424431    UChar32 character { 0 };
    425432    bool isForPlatformFont { false };
     
    429436    static unsigned hash(const CharacterFallbackMapKey& key)
    430437    {
    431         return WTF::pairIntHash(key.character, key.isForPlatformFont);
     438        return WTF::pairIntHash(key.locale.isNull() ? 0 : WTF::AtomicStringHash::hash(key.locale), WTF::pairIntHash(key.character, key.isForPlatformFont));
    432439    }
    433440
     
    441448
    442449// Fonts are not ref'd to avoid cycles.
     450// FIXME: Shouldn't these be WeakPtrs?
    443451typedef HashMap<CharacterFallbackMapKey, Font*, CharacterFallbackMapKeyHash, WTF::SimpleClassHashTraits<CharacterFallbackMapKey>> CharacterFallbackMap;
    444452typedef HashMap<const Font*, CharacterFallbackMap> SystemFallbackCache;
     
    459467    }
    460468
    461     auto key = CharacterFallbackMapKey(character, isForPlatformFont);
     469    auto key = CharacterFallbackMapKey(description.locale(), character, isForPlatformFont);
    462470    auto characterAddResult = fontAddResult.iterator->value.add(WTF::move(key), nullptr);
    463471
Note: See TracChangeset for help on using the changeset viewer.