Changeset 196969 in webkit
- Timestamp:
- Feb 22, 2016, 11:17:29 PM (11 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 13 edited
-
LayoutTests/ChangeLog (modified) (1 diff)
-
LayoutTests/css3/font-feature-font-face-local-expected.html (added)
-
LayoutTests/css3/font-feature-font-face-local.html (added)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/css/CSSFontFaceSource.cpp (modified) (1 diff)
-
Source/WebCore/platform/graphics/FontCache.cpp (modified) (8 diffs)
-
Source/WebCore/platform/graphics/FontCache.h (modified) (3 diffs)
-
Source/WebCore/platform/graphics/FontFeatureSettings.h (modified) (2 diffs)
-
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (modified) (4 diffs)
-
Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp (modified) (2 diffs)
-
Source/WebCore/platform/graphics/ios/FontCacheIOS.mm (modified) (1 diff)
-
Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm (modified) (1 diff)
-
Source/WebCore/platform/graphics/mac/FontCacheMac.mm (modified) (2 diffs)
-
Source/WebCore/platform/graphics/win/FontCacheWin.cpp (modified) (1 diff)
-
Source/WebCore/platform/text/TextFlags.h (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r196961 r196969 1 2016-02-22 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Font features specified in @font-face blocks don't apply to local() families 4 https://bugs.webkit.org/show_bug.cgi?id=154554 5 6 Reviewed by Dean Jackson. 7 8 * css3/font-feature-font-face-local-expected.html: Added. 9 * css3/font-feature-font-face-local.html: Added. 10 1 11 2016-02-22 Chris Dumez <cdumez@apple.com> 2 12 -
trunk/Source/WebCore/ChangeLog
r196965 r196969 1 2016-02-22 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Font features specified in @font-face blocks don't apply to local() families 4 https://bugs.webkit.org/show_bug.cgi?id=154554 5 6 Reviewed by Dean Jackson. 7 8 The correct variables just need to be wired up. In addition, our caches need to be sensitive 9 to the new data. 10 11 Test: css3/font-feature-font-face-local.html 12 13 * css/CSSFontFaceSource.cpp: 14 (WebCore::CSSFontFaceSource::font): 15 * platform/graphics/FontCache.cpp: 16 (WebCore::FontPlatformDataCacheKey::FontPlatformDataCacheKey): 17 (WebCore::FontPlatformDataCacheKey::operator==): 18 (WebCore::FontPlatformDataCacheKeyHash::hash): 19 (WebCore::FontCache::getCachedFontPlatformData): 20 (WebCore::FontCache::fontForFamily): 21 * platform/graphics/FontCache.h: 22 * platform/graphics/FontFeatureSettings.h: 23 (WebCore::FontFeature::operator!=): 24 (WebCore::FontFeatureSettings::operator!=): 25 * platform/graphics/cocoa/FontCacheCoreText.cpp: 26 (WebCore::fontWithFamily): 27 (WebCore::FontCache::createFontPlatformData): 28 * platform/graphics/mac/ComplexTextControllerCoreText.mm: 29 (WebCore::ComplexTextController::collectComplexTextRunsForCharacters): 30 * platform/graphics/mac/FontCacheMac.mm: 31 (WebCore::FontCache::lastResortFallbackFont): 32 * platform/text/TextFlags.h: 33 (WebCore::FontVariantSettings::operator==): 34 (WebCore::FontVariantSettings::operator!=): 35 (WebCore::FontVariantSettings::uniqueValue): 36 1 37 2016-02-22 Daniel Bates <dabates@apple.com> 2 38 -
trunk/Source/WebCore/css/CSSFontFaceSource.cpp
r196835 r196969 138 138 // We're local. Just return a Font from the normal cache. 139 139 // We don't want to check alternate font family names here, so pass true as the checkingAlternateName parameter. 140 return FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, true);140 return FontCache::singleton().fontForFamily(fontDescription, m_familyNameOrURI, &fontFaceFeatures, &fontFaceVariantSettings, true); 141 141 } 142 142 -
trunk/Source/WebCore/platform/graphics/FontCache.cpp
r196393 r196969 101 101 public: 102 102 FontPlatformDataCacheKey() { } 103 FontPlatformDataCacheKey(const AtomicString& family, const FontDescription& description )103 FontPlatformDataCacheKey(const AtomicString& family, const FontDescription& description, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings) 104 104 : m_fontDescriptionKey(description) 105 105 , m_family(family) 106 , m_fontFaceFeatures(fontFaceFeatures ? *fontFaceFeatures : FontFeatureSettings()) 107 , m_fontFaceVariantSettings(fontFaceVariantSettings ? *fontFaceVariantSettings : FontVariantSettings()) 106 108 { } 107 109 … … 114 116 bool operator==(const FontPlatformDataCacheKey& other) const 115 117 { 116 if (m_fontDescriptionKey != other.m_fontDescriptionKey) 118 if (m_fontDescriptionKey != other.m_fontDescriptionKey 119 || m_fontFaceFeatures != other.m_fontFaceFeatures 120 || m_fontFaceVariantSettings != other.m_fontFaceVariantSettings) 117 121 return false; 118 122 if (m_family.impl() == other.m_family.impl()) … … 125 129 FontDescriptionKey m_fontDescriptionKey; 126 130 AtomicString m_family; 131 FontFeatureSettings m_fontFaceFeatures; 132 FontVariantSettings m_fontFaceVariantSettings; 127 133 }; 128 134 … … 130 136 static unsigned hash(const FontPlatformDataCacheKey& fontKey) 131 137 { 132 return pairIntHash(ASCIICaseInsensitiveHash::hash(fontKey.m_family), fontKey.m_fontDescriptionKey.computeHash()); 138 IntegerHasher hasher; 139 hasher.add(ASCIICaseInsensitiveHash::hash(fontKey.m_family)); 140 hasher.add(fontKey.m_fontDescriptionKey.computeHash()); 141 hasher.add(fontKey.m_fontFaceFeatures.hash()); 142 hasher.add(fontKey.m_fontFaceVariantSettings.uniqueValue()); 143 return hasher.hash(); 133 144 } 134 145 … … 208 219 } 209 220 210 FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription, 211 const AtomicString& passedFamilyName, 212 bool checkingAlternateName) 221 FontPlatformData* FontCache::getCachedFontPlatformData(const FontDescription& fontDescription, const AtomicString& passedFamilyName, 222 const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, bool checkingAlternateName) 213 223 { 214 224 #if PLATFORM(IOS) … … 232 242 } 233 243 234 FontPlatformDataCacheKey key(familyName, fontDescription );244 FontPlatformDataCacheKey key(familyName, fontDescription, fontFaceFeatures, fontFaceVariantSettings); 235 245 236 246 auto addResult = fontPlatformDataCache().add(key, nullptr); 237 247 FontPlatformDataCache::iterator it = addResult.iterator; 238 248 if (addResult.isNewEntry) { 239 it->value = createFontPlatformData(fontDescription, familyName );249 it->value = createFontPlatformData(fontDescription, familyName, fontFaceFeatures, fontFaceVariantSettings); 240 250 241 251 if (!it->value && !checkingAlternateName) { … … 244 254 const AtomicString alternateName = alternateFamilyName(familyName); 245 255 if (!alternateName.isNull()) { 246 FontPlatformData* fontPlatformDataForAlternateName = getCachedFontPlatformData(fontDescription, alternateName, true);256 FontPlatformData* fontPlatformDataForAlternateName = getCachedFontPlatformData(fontDescription, alternateName, fontFaceFeatures, fontFaceVariantSettings, true); 247 257 // Lookup the key in the hash table again as the previous iterator may have 248 258 // been invalidated by the recursive call to getCachedFontPlatformData(). … … 365 375 const unsigned cTargetUnderMemoryPressureInactiveFontData = 30; 366 376 367 RefPtr<Font> FontCache::fontForFamily(const FontDescription& fontDescription, const AtomicString& family, bool checkingAlternateName)377 RefPtr<Font> FontCache::fontForFamily(const FontDescription& fontDescription, const AtomicString& family, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, bool checkingAlternateName) 368 378 { 369 379 if (!m_purgeTimer.isActive()) 370 380 m_purgeTimer.startOneShot(std::chrono::milliseconds::zero()); 371 381 372 FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, checkingAlternateName);382 FontPlatformData* platformData = getCachedFontPlatformData(fontDescription, family, fontFaceFeatures, fontFaceVariantSettings, checkingAlternateName); 373 383 if (!platformData) 374 384 return nullptr; -
trunk/Source/WebCore/platform/graphics/FontCache.h
r196393 r196969 189 189 Vector<FontTraitsMask> getTraitsInFamily(const AtomicString&); 190 190 191 WEBCORE_EXPORT RefPtr<Font> fontForFamily(const FontDescription&, const AtomicString&, bool checkingAlternateName = false);191 WEBCORE_EXPORT RefPtr<Font> fontForFamily(const FontDescription&, const AtomicString&, const FontFeatureSettings* fontFaceFeatures = nullptr, const FontVariantSettings* fontFaceVariantSettings = nullptr, bool checkingAlternateName = false); 192 192 WEBCORE_EXPORT Ref<Font> lastResortFallbackFont(const FontDescription&); 193 193 WEBCORE_EXPORT Ref<Font> fontForPlatformData(const FontPlatformData&); … … 221 221 222 222 // FIXME: This method should eventually be removed. 223 FontPlatformData* getCachedFontPlatformData(const FontDescription&, const AtomicString& family, bool checkingAlternateName = false);223 FontPlatformData* getCachedFontPlatformData(const FontDescription&, const AtomicString& family, const FontFeatureSettings* fontFaceFeatures = nullptr, const FontVariantSettings* fontFaceVariantSettings = nullptr, bool checkingAlternateName = false); 224 224 225 225 // These methods are implemented by each platform. … … 227 227 FontPlatformData* getCustomFallbackFont(const UInt32, const FontDescription&); 228 228 #endif 229 std::unique_ptr<FontPlatformData> createFontPlatformData(const FontDescription&, const AtomicString& family );229 std::unique_ptr<FontPlatformData> createFontPlatformData(const FontDescription&, const AtomicString& family, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings); 230 230 231 231 Timer m_purgeTimer; -
trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h
r190402 r196969 61 61 62 62 bool operator==(const FontFeature& other) const; 63 bool operator!=(const FontFeature& other) const { return !(*this == other); } 63 64 bool operator<(const FontFeature& other) const; 64 65 … … 76 77 void insert(FontFeature&&); 77 78 bool operator==(const FontFeatureSettings& other) const { return m_list == other.m_list; } 79 bool operator!=(const FontFeatureSettings& other) const { return !(*this == other); } 78 80 79 81 size_t size() const { return m_list.size(); } -
trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
r195928 r196969 672 672 #endif 673 673 674 static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, CTFontSymbolicTraits desiredTraits, FontWeight weight, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const TextRenderingMode& textRenderingMode, float size)674 static RetainPtr<CTFontRef> fontWithFamily(const AtomicString& family, CTFontSymbolicTraits desiredTraits, FontWeight weight, const FontFeatureSettings& featureSettings, const FontVariantSettings& variantSettings, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings, const TextRenderingMode& textRenderingMode, float size) 675 675 { 676 676 if (family.isEmpty()) … … 685 685 #endif 686 686 } 687 return preparePlatformFont(foundFont.get(), textRenderingMode, nullptr, nullptr, featureSettings, variantSettings);687 return preparePlatformFont(foundFont.get(), textRenderingMode, fontFaceFeatures, fontFaceVariantSettings, featureSettings, variantSettings); 688 688 } 689 689 … … 720 720 #endif 721 721 722 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family )722 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family, const FontFeatureSettings* fontFaceFeatures, const FontVariantSettings* fontFaceVariantSettings) 723 723 { 724 724 CTFontSymbolicTraits traits = computeTraits(fontDescription); 725 725 float size = fontDescription.computedPixelSize(); 726 726 727 RetainPtr<CTFontRef> font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), font Description.textRenderingMode(), size);727 RetainPtr<CTFontRef> font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size); 728 728 729 729 #if PLATFORM(MAC) … … 736 736 autoActivateFont(family.string(), size); 737 737 738 font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), font Description.textRenderingMode(), size);738 font = fontWithFamily(family, traits, fontDescription.weight(), fontDescription.featureSettings(), fontDescription.variantSettings(), fontFaceFeatures, fontFaceVariantSettings, fontDescription.textRenderingMode(), size); 739 739 } 740 740 #endif -
trunk/Source/WebCore/platform/graphics/freetype/FontCacheFreeType.cpp
r195743 r196969 135 135 // matches for non-fallback fonts might return 0. See isFallbackFontAllowed. 136 136 static AtomicString timesStr("serif"); 137 return *fontForFamily(fontDescription, timesStr , false);137 return *fontForFamily(fontDescription, timesStr); 138 138 } 139 139 … … 327 327 } 328 328 329 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family )329 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family, const FontFeatureSettings*, const FontVariantSettings*) 330 330 { 331 331 // The CSS font matching algorithm (http://www.w3.org/TR/css3-fonts/#font-matching-algorithm) -
trunk/Source/WebCore/platform/graphics/ios/FontCacheIOS.mm
r195452 r196969 121 121 Ref<Font> FontCache::lastResortFallbackFont(const FontDescription& fontDescription) 122 122 { 123 return *fontForFamily(fontDescription, AtomicString(".PhoneFallback", AtomicString::ConstructFromLiteral) , false);123 return *fontForFamily(fontDescription, AtomicString(".PhoneFallback", AtomicString::ConstructFromLiteral)); 124 124 } 125 125 -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
r191331 r196969 287 287 } 288 288 auto& fontCache = FontCache::singleton(); 289 runFont = fontCache.fontForFamily(m_font.fontDescription(), fontName.get() , false).get();289 runFont = fontCache.fontForFamily(m_font.fontDescription(), fontName.get()).get(); 290 290 // Core Text may have used a font that our font lookup path cannot find. In that case, fall back on 291 291 // using the font as returned. -
trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm
r195452 r196969 396 396 // FIXME: Would be even better to somehow get the user's default font here. For now we'll pick 397 397 // the default that the user would get without changing any prefs. 398 if (RefPtr<Font> font = fontForFamily(fontDescription, AtomicString("Times", AtomicString::ConstructFromLiteral) , false))398 if (RefPtr<Font> font = fontForFamily(fontDescription, AtomicString("Times", AtomicString::ConstructFromLiteral))) 399 399 return *font; 400 400 … … 403 403 // guaranteed to be there, according to Nathan Taylor. This is good enough 404 404 // to avoid a crash at least. 405 return *fontForFamily(fontDescription, AtomicString("Lucida Grande", AtomicString::ConstructFromLiteral), false);405 return *fontForFamily(fontDescription, AtomicString("Lucida Grande", AtomicString::ConstructFromLiteral), nullptr, nullptr, false); 406 406 } 407 407 -
trunk/Source/WebCore/platform/graphics/win/FontCacheWin.cpp
r195743 r196969 561 561 } 562 562 563 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family )563 std::unique_ptr<FontPlatformData> FontCache::createFontPlatformData(const FontDescription& fontDescription, const AtomicString& family, const FontFeatureSettings*, const FontVariantSettings*) 564 564 { 565 565 bool isLucidaGrande = equalLettersIgnoringASCIICase(family, "lucida grande"); -
trunk/Source/WebCore/platform/text/TextFlags.h
r196510 r196969 213 213 } 214 214 215 bool operator==(const FontVariantSettings& other) 215 bool operator==(const FontVariantSettings& other) const 216 216 { 217 217 return commonLigatures == other.commonLigatures … … 232 232 } 233 233 234 bool operator!=(const FontVariantSettings& other) const { return !(*this == other); } 235 236 unsigned uniqueValue() const 237 { 238 return static_cast<unsigned>(commonLigatures) << 26 239 | static_cast<unsigned>(discretionaryLigatures) << 24 240 | static_cast<unsigned>(historicalLigatures) << 22 241 | static_cast<unsigned>(contextualAlternates) << 20 242 | static_cast<unsigned>(position) << 18 243 | static_cast<unsigned>(caps) << 15 244 | static_cast<unsigned>(numericFigure) << 13 245 | static_cast<unsigned>(numericSpacing) << 11 246 | static_cast<unsigned>(numericFraction) << 9 247 | static_cast<unsigned>(numericOrdinal) << 8 248 | static_cast<unsigned>(numericSlashedZero) << 7 249 | static_cast<unsigned>(alternates) << 6 250 | static_cast<unsigned>(eastAsianVariant) << 3 251 | static_cast<unsigned>(eastAsianWidth) << 1 252 | static_cast<unsigned>(eastAsianRuby) << 0; 253 } 254 234 255 FontVariantLigatures commonLigatures; 235 256 FontVariantLigatures discretionaryLigatures;
Note:
See TracChangeset
for help on using the changeset viewer.