Changeset 187626 in webkit
- Timestamp:
- Jul 30, 2015 5:12:38 PM (9 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r187622 r187626 1 2015-07-30 Myles C. Maxfield <mmaxfield@apple.com> 2 3 Move locale information into FontDescription 4 https://bugs.webkit.org/show_bug.cgi?id=147457 5 6 Reviewed by Andreas Kling. 7 8 Currently, the "lang" attribute on a node sets locale information in RenderStyle. 9 Font selection is sensitive to this locale information, and occurs deep within 10 platform/ code, far away from RenderStyle. Because every RenderStyle owns a 11 FontDescription, and font selection can consult with FontDescriptions, it makes 12 sense to move the variable from RenderStyle to FontDescription, and provide 13 convenience methods on RenderStyle which inspect its FontDescription for locale 14 information. 15 16 This patch is in preparation for correctly obeying locale information when 17 performing font fallback. 18 19 No new tests because there is no behavior change. 20 21 * css/CSSPropertyNames.in: 22 * css/StyleBuilderCustom.h: 23 (WebCore::StyleBuilderCustom::applyValueWebkitLocale): 24 * platform/graphics/FontCache.h: 25 (WebCore::FontDescriptionKey::FontDescriptionKey): 26 (WebCore::FontDescriptionKey::operator==): 27 * platform/graphics/FontCascade.cpp: 28 * platform/graphics/FontDescription.cpp: 29 (WebCore::FontDescription::FontDescription): 30 (WebCore::FontDescription::setLocale): 31 * platform/graphics/FontDescription.h: 32 (WebCore::FontDescription::locale): 33 (WebCore::FontDescription::initialLocale): 34 (WebCore::FontDescription::operator==): 35 (WebCore::FontDescription::FontDescription): Deleted. 36 (WebCore::FontDescription::setScript): Deleted. 37 * platform/text/LocaleToScriptMappingDefault.cpp: 38 (WebCore::localeToScriptCodeForFontSelection): 39 * rendering/style/RenderStyle.cpp: 40 (WebCore::RenderStyle::changeRequiresLayout): Deleted. 41 * rendering/style/RenderStyle.h: 42 * rendering/style/StyleRareInheritedData.cpp: 43 (WebCore::StyleRareInheritedData::StyleRareInheritedData): Deleted. 44 (WebCore::StyleRareInheritedData::operator==): Deleted. 45 * rendering/style/StyleRareInheritedData.h: 46 * style/StyleResolveForDocument.cpp: 47 (WebCore::Style::resolveForDocument): 48 1 49 2015-07-30 Anders Carlsson <andersca@apple.com> 2 50 -
trunk/Source/WebCore/css/CSSPropertyNames.in
r187110 r187626 110 110 -webkit-font-smoothing [Inherited, FontProperty] 111 111 -webkit-font-variant-ligatures [Inherited, Custom=All] 112 -webkit-locale [Inherited, Custom=Value]112 -webkit-locale [Inherited, FontProperty, Custom=Value] 113 113 -webkit-text-orientation [Inherited, Custom=Value] 114 114 -epub-text-orientation = -webkit-text-orientation -
trunk/Source/WebCore/css/StyleBuilderCustom.h
r187110 r187626 41 41 #include "Frame.h" 42 42 #include "HTMLElement.h" 43 #include "LocaleToScriptMapping.h"44 43 #include "Rect.h" 45 44 #include "RenderTheme.h" … … 692 691 { 693 692 auto& primitiveValue = downcast<CSSPrimitiveValue>(value); 694 695 if (primitiveValue.getValueID() == CSSValueAuto)696 styleResolver.style()->setLocale(nullAtom);697 else698 styleResolver.style()->setLocale(primitiveValue.getStringValue());699 693 700 694 FontDescription fontDescription = styleResolver.style()->fontDescription(); 701 fontDescription.setScript(localeToScriptCodeForFontSelection(styleResolver.style()->locale())); 695 if (primitiveValue.getValueID() == CSSValueAuto) 696 fontDescription.setLocale(nullAtom); 697 else 698 fontDescription.setLocale(primitiveValue.getStringValue()); 702 699 styleResolver.setFontDescription(fontDescription); 703 700 } -
trunk/Source/WebCore/platform/graphics/FontCache.h
r187615 r187626 72 72 , weight(0) 73 73 , flags(0) 74 , localeHash(0) 74 75 { } 75 76 FontDescriptionKey(const FontDescription& description) … … 77 78 , weight(description.weight()) 78 79 , flags(makeFlagKey(description)) 80 , localeHash(description.locale().isNull() ? 0 : description.locale().impl()->existingHash()) 79 81 { } 80 82 static unsigned makeFlagKey(const FontDescription& description) … … 92 94 bool operator==(const FontDescriptionKey& other) const 93 95 { 94 return size == other.size && weight == other.weight && flags == other.flags ;96 return size == other.size && weight == other.weight && flags == other.flags && localeHash == other.localeHash; 95 97 } 96 98 bool operator!=(const FontDescriptionKey& other) const … … 105 107 unsigned weight; 106 108 unsigned flags; 109 unsigned localeHash; // FIXME: Here, and every client of us, makes hashes of hashes. 107 110 }; 108 111 -
trunk/Source/WebCore/platform/graphics/FontCascade.cpp
r187615 r187626 179 179 180 180 struct FontCascadeCacheKey { 181 // This part of the key is shared with the lower level FontCache (caching FontData objects). 182 FontDescriptionKey fontDescriptionKey; 181 FontDescriptionKey fontDescriptionKey; // Shared with the lower level FontCache (caching Font objects) 183 182 Vector<AtomicString, 3> families; 184 183 unsigned fontSelectorId; … … 242 241 } 243 242 243 // FIXME: Why can't we just teach HashMap about FontCascadeCacheKey instead of hashing a hash? 244 244 static unsigned computeFontCascadeCacheHash(const FontCascadeCacheKey& key) 245 245 { -
trunk/Source/WebCore/platform/graphics/FontDescription.cpp
r178149 r187626 1 1 2 /* 2 3 * Copyright (C) 2007 Nicholas Shanks <contact@nickshanks.com> … … 30 31 #include "config.h" 31 32 #include "FontDescription.h" 33 #include "LocaleToScriptMapping.h" 32 34 33 35 namespace WebCore { 34 36 35 37 struct SameSizeAsFontDescription { 36 void* pointers[ 2];38 void* pointers[3]; 37 39 float sizes[2]; 38 // F XIME: Make them fit into one word.40 // FIXME: Make them fit into one word. 39 41 uint32_t bitfields; 40 42 uint32_t bitfields2 : 8; … … 42 44 43 45 COMPILE_ASSERT(sizeof(FontDescription) == sizeof(SameSizeAsFontDescription), FontDescription_should_stay_small); 46 47 FontDescription::FontDescription() 48 : m_orientation(Horizontal) 49 , m_nonCJKGlyphOrientation(NonCJKGlyphOrientationVerticalRight) 50 , m_widthVariant(RegularWidth) 51 , m_italic(FontItalicOff) 52 , m_smallCaps(FontSmallCapsOff) 53 , m_isAbsoluteSize(false) 54 , m_weight(FontWeightNormal) 55 , m_renderingMode(NormalRenderingMode) 56 , m_kerning(AutoKerning) 57 , m_commonLigaturesState(NormalLigaturesState) 58 , m_discretionaryLigaturesState(NormalLigaturesState) 59 , m_historicalLigaturesState(NormalLigaturesState) 60 , m_keywordSize(0) 61 , m_fontSmoothing(AutoSmoothing) 62 , m_textRendering(AutoTextRendering) 63 , m_isSpecifiedFont(false) 64 , m_script(localeToScriptCodeForFontSelection(m_locale)) 65 , m_fontSynthesis(initialFontSynthesis()) 66 { 67 } 44 68 45 69 FontWeight FontDescription::lighterWeight(void) const … … 95 119 } 96 120 121 void FontDescription::setLocale(const AtomicString& locale) 122 { 123 m_locale = locale; 124 m_script = localeToScriptCodeForFontSelection(m_locale); 125 } 126 97 127 #if ENABLE(IOS_TEXT_AUTOSIZING) 98 128 bool FontDescription::familiesEqualForTextAutoSizing(const FontDescription& other) const -
trunk/Source/WebCore/platform/graphics/FontDescription.h
r183494 r187626 45 45 enum LigaturesState { NormalLigaturesState, DisabledLigaturesState, EnabledLigaturesState }; 46 46 47 FontDescription() 48 : m_families(1) 49 , m_specifiedSize(0) 50 , m_computedSize(0) 51 , m_orientation(Horizontal) 52 , m_nonCJKGlyphOrientation(NonCJKGlyphOrientationVerticalRight) 53 , m_widthVariant(RegularWidth) 54 , m_italic(FontItalicOff) 55 , m_smallCaps(FontSmallCapsOff) 56 , m_isAbsoluteSize(false) 57 , m_weight(FontWeightNormal) 58 , m_renderingMode(NormalRenderingMode) 59 , m_kerning(AutoKerning) 60 , m_commonLigaturesState(NormalLigaturesState) 61 , m_discretionaryLigaturesState(NormalLigaturesState) 62 , m_historicalLigaturesState(NormalLigaturesState) 63 , m_keywordSize(0) 64 , m_fontSmoothing(AutoSmoothing) 65 , m_textRendering(AutoTextRendering) 66 , m_isSpecifiedFont(false) 67 , m_script(USCRIPT_COMMON) 68 , m_fontSynthesis(initialFontSynthesis()) 69 { 70 } 47 WEBCORE_EXPORT FontDescription(); 71 48 72 49 bool operator==(const FontDescription&) const; … … 104 81 TextRenderingMode textRenderingMode() const { return static_cast<TextRenderingMode>(m_textRendering); } 105 82 UScriptCode script() const { return static_cast<UScriptCode>(m_script); } 83 const AtomicString& locale() const { return m_locale; } 106 84 107 85 FontTraitsMask traitsMask() const; … … 148 126 void setNonCJKGlyphOrientation(NonCJKGlyphOrientation orientation) { m_nonCJKGlyphOrientation = orientation; } 149 127 void setWidthVariant(FontWidthVariant widthVariant) { m_widthVariant = widthVariant; } 150 void set Script(UScriptCode s) { m_script = s; }128 void setLocale(const AtomicString&); 151 129 void setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) { m_featureSettings = settings; } 152 130 void setFontSynthesis(FontSynthesis fontSynthesis) { m_fontSynthesis = fontSynthesis; } … … 171 149 static TextRenderingMode initialTextRenderingMode() { return AutoTextRendering; } 172 150 static FontSynthesis initialFontSynthesis() { return FontSynthesisWeight | FontSynthesisStyle; } 151 static const AtomicString& initialLocale() { return nullAtom; } 173 152 174 153 private: 175 RefCountedArray<AtomicString> m_families ;154 RefCountedArray<AtomicString> m_families { 1 }; 176 155 RefPtr<FontFeatureSettings> m_featureSettings; 177 178 float m_specifiedSize; // Specified CSS value. Independent of rendering issues such as integer 156 AtomicString m_locale { initialLocale() }; 157 158 float m_specifiedSize { 0 }; // Specified CSS value. Independent of rendering issues such as integer 179 159 // rounding, minimum font sizes, and zooming. 180 float m_computedSize ; // Computed size adjusted for the minimum font size and the zoom factor.160 float m_computedSize { 0 }; // Computed size adjusted for the minimum font size and the zoom factor. 181 161 182 162 unsigned m_orientation : 1; // FontOrientation - Whether the font is rendering on a horizontal line or a vertical line. … … 230 210 && m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation 231 211 && m_widthVariant == other.m_widthVariant 232 && m_ script == other.m_script212 && m_locale == other.m_locale 233 213 && m_featureSettings == other.m_featureSettings 234 214 && m_fontSynthesis == other.m_fontSynthesis; -
trunk/Source/WebCore/platform/text/LocaleToScriptMappingDefault.cpp
r165607 r187626 34 34 #include <wtf/HashMap.h> 35 35 #include <wtf/HashSet.h> 36 #include <wtf/NeverDestroyed.h> 36 37 #include <wtf/text/StringHash.h> 37 38 … … 390 391 UScriptCode localeToScriptCodeForFontSelection(const String& locale) 391 392 { 392 DEPRECATED_DEFINE_STATIC_LOCAL(LocaleScriptMap, localeScriptMap, ());393 if (localeScriptMap. isEmpty()) {393 static NeverDestroyed<LocaleScriptMap> localeScriptMap; 394 if (localeScriptMap.get().isEmpty()) { 394 395 for (size_t i = 0; i < sizeof(localeScriptList) / sizeof(LocaleScript); ++i) 395 localeScriptMap. set(ASCIILiteral(localeScriptList[i].locale), localeScriptList[i].script);396 localeScriptMap.get().set(ASCIILiteral(localeScriptList[i].locale), localeScriptList[i].script); 396 397 } 397 398 398 399 String canonicalLocale = locale.lower().replace('-', '_'); 399 400 while (!canonicalLocale.isEmpty()) { 400 LocaleScriptMap::iterator it = localeScriptMap. find(canonicalLocale);401 if (it != localeScriptMap. end())401 LocaleScriptMap::iterator it = localeScriptMap.get().find(canonicalLocale); 402 if (it != localeScriptMap.get().end()) 402 403 return it->value; 403 404 size_t pos = canonicalLocale.reverseFind('_'); -
trunk/Source/WebCore/rendering/style/RenderStyle.cpp
r187110 r187626 577 577 || rareInheritedData->hyphenationLimitAfter != other.rareInheritedData->hyphenationLimitAfter 578 578 || rareInheritedData->hyphenationString != other.rareInheritedData->hyphenationString 579 || rareInheritedData->locale != other.rareInheritedData->locale580 579 || rareInheritedData->m_rubyPosition != other.rareInheritedData->m_rubyPosition 581 580 || rareInheritedData->textEmphasisMark != other.rareInheritedData->textEmphasisMark -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r187110 r187626 999 999 short hyphenationLimitLines() const { return rareInheritedData->hyphenationLimitLines; } 1000 1000 const AtomicString& hyphenationString() const { return rareInheritedData->hyphenationString; } 1001 const AtomicString& locale() const { return rareInheritedData->locale; }1001 const AtomicString& locale() const { return fontDescription().locale(); } 1002 1002 EBorderFit borderFit() const { return static_cast<EBorderFit>(rareNonInheritedData->m_borderFit); } 1003 1003 EResize resize() const { return static_cast<EResize>(rareInheritedData->resize); } … … 1573 1573 void setHyphenationLimitLines(short limit) { SET_VAR(rareInheritedData, hyphenationLimitLines, limit); } 1574 1574 void setHyphenationString(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenationString, h); } 1575 void setLocale(const AtomicString& locale) { SET_VAR(rareInheritedData, locale, locale); }1576 1575 void setBorderFit(EBorderFit b) { SET_VAR(rareNonInheritedData, m_borderFit, b); } 1577 1576 void setResize(EResize r) { SET_VAR(rareInheritedData, resize, r); } … … 1967 1966 static short initialHyphenationLimitLines() { return -1; } 1968 1967 static const AtomicString& initialHyphenationString() { return nullAtom; } 1969 static const AtomicString& initialLocale() { return nullAtom; }1970 1968 static EBorderFit initialBorderFit() { return BorderFitBorder; } 1971 1969 static EResize initialResize() { return RESIZE_NONE; } -
trunk/Source/WebCore/rendering/style/StyleRareInheritedData.cpp
r187110 r187626 207 207 , hyphenationLimitAfter(o.hyphenationLimitAfter) 208 208 , hyphenationLimitLines(o.hyphenationLimitLines) 209 , locale(o.locale)210 209 , textEmphasisCustomMark(o.textEmphasisCustomMark) 211 210 , m_lineGrid(o.m_lineGrid) … … 303 302 #endif 304 303 && hyphenationString == o.hyphenationString 305 && locale == o.locale306 304 && textEmphasisCustomMark == o.textEmphasisCustomMark 307 305 && quotesDataEquivalent(quotes.get(), o.quotes.get()) -
trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h
r187110 r187626 140 140 short hyphenationLimitLines; 141 141 142 AtomicString locale;143 144 142 AtomicString textEmphasisCustomMark; 145 143 RefPtr<QuotesData> quotes; -
trunk/Source/WebCore/style/StyleResolveForDocument.cpp
r179368 r187626 60 60 documentStyle.get().setZoom(!document.printing() ? renderView.frame().pageZoomFactor() : 1); 61 61 documentStyle.get().setPageScaleTransform(renderView.frame().frameScaleFactor()); 62 documentStyle.get().setLocale(document.contentLanguage()); 62 FontDescription documentFontDescription = documentStyle.get().fontDescription(); 63 documentFontDescription.setLocale(document.contentLanguage()); 64 documentStyle.get().setFontDescription(WTF::move(documentFontDescription)); 63 65 64 66 // This overrides any -webkit-user-modify inherited from the parent iframe. … … 98 100 99 101 FontDescription fontDescription; 100 fontDescription.set Script(localeToScriptCodeForFontSelection(documentStyle.get().locale()));102 fontDescription.setLocale(document.contentLanguage()); 101 103 fontDescription.setRenderingMode(settings.fontRenderingMode()); 102 104 fontDescription.setOneFamily(standardFamily);
Note: See TracChangeset
for help on using the changeset viewer.