Move locale information into FontDescription
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Nov 2015 04:21:36 +0000 (04:21 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 11 Nov 2015 04:21:36 +0000 (04:21 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147457

Reviewed by Andreas Kling.

Currently, the "lang" attribute on a node sets locale information in RenderStyle.
Font selection is sensitive to this locale information, and occurs deep within
platform/ code, far away from RenderStyle. Because every RenderStyle owns a
FontDescription, and font selection can consult with FontDescriptions, it makes
sense to move the variable from RenderStyle to FontDescription, and provide
convenience methods on RenderStyle which inspect its FontDescription for locale
information.

This patch is in preparation for correctly obeying locale information when
performing font fallback.

No new tests because there is no behavior change.

* css/CSSPropertyNames.in:
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyValueWebkitLocale):
* platform/graphics/FontCache.h:
* platform/graphics/FontDescription.cpp:
(WebCore::FontDescription::setLocale):
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::locale):
(WebCore::FontDescription::operator==):
(WebCore::FontCascadeDescription::initialLocale):
(WebCore::FontDescription::setScript): Deleted.
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::changeRequiresLayout): Deleted.
* rendering/style/RenderStyle.h:
* rendering/style/StyleRareInheritedData.cpp:
(WebCore::StyleRareInheritedData::StyleRareInheritedData): Deleted.
(WebCore::StyleRareInheritedData::operator==): Deleted.
* rendering/style/StyleRareInheritedData.h:
* style/StyleResolveForDocument.cpp:
(WebCore::Style::resolveForDocument):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192290 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/StyleBuilderCustom.h
Source/WebCore/platform/graphics/FontCache.h
Source/WebCore/platform/graphics/FontDescription.cpp
Source/WebCore/platform/graphics/FontDescription.h
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/style/RenderStyle.h
Source/WebCore/rendering/style/StyleRareInheritedData.cpp
Source/WebCore/rendering/style/StyleRareInheritedData.h
Source/WebCore/style/StyleResolveForDocument.cpp

index bd08024..b8346b6 100644 (file)
@@ -1,3 +1,44 @@
+2015-11-10  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Move locale information into FontDescription
+        https://bugs.webkit.org/show_bug.cgi?id=147457
+
+        Reviewed by Andreas Kling.
+
+        Currently, the "lang" attribute on a node sets locale information in RenderStyle.
+        Font selection is sensitive to this locale information, and occurs deep within
+        platform/ code, far away from RenderStyle. Because every RenderStyle owns a
+        FontDescription, and font selection can consult with FontDescriptions, it makes
+        sense to move the variable from RenderStyle to FontDescription, and provide
+        convenience methods on RenderStyle which inspect its FontDescription for locale
+        information.
+
+        This patch is in preparation for correctly obeying locale information when
+        performing font fallback.
+
+        No new tests because there is no behavior change.
+
+        * css/CSSPropertyNames.in:
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyValueWebkitLocale):
+        * platform/graphics/FontCache.h:
+        * platform/graphics/FontDescription.cpp:
+        (WebCore::FontDescription::setLocale):
+        * platform/graphics/FontDescription.h:
+        (WebCore::FontDescription::locale):
+        (WebCore::FontDescription::operator==):
+        (WebCore::FontCascadeDescription::initialLocale):
+        (WebCore::FontDescription::setScript): Deleted.
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::changeRequiresLayout): Deleted.
+        * rendering/style/RenderStyle.h:
+        * rendering/style/StyleRareInheritedData.cpp:
+        (WebCore::StyleRareInheritedData::StyleRareInheritedData): Deleted.
+        (WebCore::StyleRareInheritedData::operator==): Deleted.
+        * rendering/style/StyleRareInheritedData.h:
+        * style/StyleResolveForDocument.cpp:
+        (WebCore::Style::resolveForDocument):
+
 2015-11-10  Gyuyoung Kim  <gyuyoung.kim@webkit.org>
 
         [EFL] Support an applicationVersion argument to UserAgentEfl::standardUserAgent() 
index f2c205a..3599cb9 100644 (file)
@@ -115,7 +115,7 @@ font-variant-caps [Inherited, FontProperty, NameForMethods=VariantCaps]
 font-variant-numeric [Inherited, FontProperty, NameForMethods=VariantNumeric, Custom=All]
 font-variant-alternates [Inherited, FontProperty, NameForMethods=VariantAlternates]
 font-variant-east-asian [Inherited, FontProperty, NameForMethods=VariantEastAsian, Custom=All]
--webkit-locale [Inherited, Custom=Value]
+-webkit-locale [Inherited, FontProperty, Custom=Value]
 -webkit-text-orientation [Inherited, Custom=Value]
 -epub-text-orientation = -webkit-text-orientation
 #if defined(ENABLE_IOS_TEXT_AUTOSIZING) && ENABLE_IOS_TEXT_AUTOSIZING
index e647378..5cb8a67 100644 (file)
@@ -41,7 +41,6 @@
 #include "FontVariantBuilder.h"
 #include "Frame.h"
 #include "HTMLElement.h"
-#include "LocaleToScriptMapping.h"
 #include "Rect.h"
 #include "RenderTheme.h"
 #include "SVGElement.h"
@@ -696,13 +695,12 @@ inline void StyleBuilderCustom::applyValueClip(StyleResolver& styleResolver, CSS
 inline void StyleBuilderCustom::applyValueWebkitLocale(StyleResolver& styleResolver, CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
-    if (primitiveValue.getValueID() == CSSValueAuto)
-        styleResolver.style()->setLocale(nullAtom);
-    else
-        styleResolver.style()->setLocale(primitiveValue.getStringValue());
 
     FontCascadeDescription fontDescription = styleResolver.style()->fontDescription();
-    fontDescription.setScript(localeToScriptCodeForFontSelection(styleResolver.style()->locale()));
+    if (primitiveValue.getValueID() == CSSValueAuto)
+        fontDescription.setLocale(nullAtom);
+    else
+        fontDescription.setLocale(primitiveValue.getStringValue());
     styleResolver.setFontDescription(fontDescription);
 }
 
index f2eeba2..f9cfffb 100644 (file)
@@ -139,6 +139,7 @@ private:
 
     static const unsigned cHashTableDeletedSize = 0xFFFFFFFFU;
 
+    // FontCascade::locale() is explicitly not included in this struct.
     unsigned m_size { 0 };
     unsigned m_weight { 0 };
     std::array<unsigned, 2> m_flags {{ 0, 0 }};
index 40d0744..45ddd33 100644 (file)
 #include "config.h"
 #include "FontDescription.h"
 
+#include "LocaleToScriptMapping.h"
+
 namespace WebCore {
 
 struct SameSizeAsFontCascadeDescription {
     Vector<void*> vector;
+    AtomicString string;
     float size;
     unsigned bitfields1;
     unsigned bitfields2 : 22;
@@ -81,6 +84,12 @@ FontTraitsMask FontDescription::traitsMask() const
     
 }
 
+void FontDescription::setLocale(const AtomicString& locale)
+{
+    m_locale = locale;
+    m_script = localeToScriptCodeForFontSelection(m_locale);
+}
+
 FontCascadeDescription::FontCascadeDescription()
     : m_isAbsoluteSize(false)
     , m_kerning(static_cast<unsigned>(Kerning::Auto))
index b3ca70d..85acfc0 100644 (file)
@@ -55,6 +55,7 @@ public:
     FontRenderingMode renderingMode() const { return static_cast<FontRenderingMode>(m_renderingMode); }
     TextRenderingMode textRenderingMode() const { return static_cast<TextRenderingMode>(m_textRendering); }
     UScriptCode script() const { return static_cast<UScriptCode>(m_script); }
+    const AtomicString& locale() const { return m_locale; }
 
     FontOrientation orientation() const { return static_cast<FontOrientation>(m_orientation); }
     NonCJKGlyphOrientation nonCJKGlyphOrientation() const { return static_cast<NonCJKGlyphOrientation>(m_nonCJKGlyphOrientation); }
@@ -106,7 +107,7 @@ public:
     void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
     void setNonCJKGlyphOrientation(NonCJKGlyphOrientation orientation) { m_nonCJKGlyphOrientation = static_cast<unsigned>(orientation); }
     void setWidthVariant(FontWidthVariant widthVariant) { m_widthVariant = widthVariant; } // Make sure new callers of this sync with FontPlatformData::isForTextCombine()!
-    void setScript(UScriptCode s) { m_script = s; }
+    void setLocale(const AtomicString&);
     void setFeatureSettings(FontFeatureSettings&& settings) { m_featureSettings = WTF::move(settings); }
     void setFontSynthesis(FontSynthesis fontSynthesis) { m_fontSynthesis = fontSynthesis; }
     void setVariantCommonLigatures(FontVariantLigatures variant) { m_variantCommonLigatures = static_cast<unsigned>(variant); }
@@ -129,6 +130,7 @@ public:
 
 private:
     FontFeatureSettings m_featureSettings;
+    AtomicString m_locale;
 
     float m_computedSize { 0 }; // Computed size adjusted for the minimum font size and the zoom factor.
     unsigned m_orientation : 1; // FontOrientation - Whether the font is rendering on a horizontal line or a vertical line.
@@ -169,7 +171,7 @@ inline bool FontDescription::operator==(const FontDescription& other) const
         && m_orientation == other.m_orientation
         && m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation
         && m_widthVariant == other.m_widthVariant
-        && m_script == other.m_script
+        && m_locale == other.m_locale
         && m_featureSettings == other.m_featureSettings
         && m_fontSynthesis == other.m_fontSynthesis
         && m_variantCommonLigatures == other.m_variantCommonLigatures
@@ -264,6 +266,7 @@ public:
     static FontVariantPosition initialVariantPosition() { return FontVariantPosition::Normal; }
     static FontVariantCaps initialVariantCaps() { return FontVariantCaps::Normal; }
     static FontVariantAlternates initialVariantAlternates() { return FontVariantAlternates::Normal; }
+    static const AtomicString& initialLocale() { return nullAtom; }
 
 private:
     RefCountedArray<AtomicString> m_families { 1 };
index 2b4c6f6..bad9035 100644 (file)
@@ -595,7 +595,6 @@ bool RenderStyle::changeRequiresLayout(const RenderStyle& other, unsigned& chang
             || rareInheritedData->hyphenationLimitBefore != other.rareInheritedData->hyphenationLimitBefore
             || rareInheritedData->hyphenationLimitAfter != other.rareInheritedData->hyphenationLimitAfter
             || rareInheritedData->hyphenationString != other.rareInheritedData->hyphenationString
-            || rareInheritedData->locale != other.rareInheritedData->locale
             || rareInheritedData->m_rubyPosition != other.rareInheritedData->m_rubyPosition
             || rareInheritedData->textEmphasisMark != other.rareInheritedData->textEmphasisMark
             || rareInheritedData->textEmphasisPosition != other.rareInheritedData->textEmphasisPosition
index bf1c219..4f34d77 100644 (file)
@@ -1007,7 +1007,7 @@ public:
     short hyphenationLimitAfter() const { return rareInheritedData->hyphenationLimitAfter; }
     short hyphenationLimitLines() const { return rareInheritedData->hyphenationLimitLines; }
     const AtomicString& hyphenationString() const { return rareInheritedData->hyphenationString; }
-    const AtomicString& locale() const { return rareInheritedData->locale; }
+    const AtomicString& locale() const { return fontDescription().locale(); }
     EBorderFit borderFit() const { return static_cast<EBorderFit>(rareNonInheritedData->m_borderFit); }
     EResize resize() const { return static_cast<EResize>(rareInheritedData->resize); }
     ColumnAxis columnAxis() const { return static_cast<ColumnAxis>(rareNonInheritedData->m_multiCol->m_axis); }
@@ -1588,7 +1588,6 @@ public:
     void setHyphenationLimitAfter(short limit) { SET_VAR(rareInheritedData, hyphenationLimitAfter, limit); }
     void setHyphenationLimitLines(short limit) { SET_VAR(rareInheritedData, hyphenationLimitLines, limit); }
     void setHyphenationString(const AtomicString& h) { SET_VAR(rareInheritedData, hyphenationString, h); }
-    void setLocale(const AtomicString& locale) { SET_VAR(rareInheritedData, locale, locale); }
     void setBorderFit(EBorderFit b) { SET_VAR(rareNonInheritedData, m_borderFit, b); }
     void setResize(EResize r) { SET_VAR(rareInheritedData, resize, r); }
     void setColumnAxis(ColumnAxis axis) { SET_VAR(rareNonInheritedData.access()->m_multiCol, m_axis, axis); }
@@ -1997,7 +1996,6 @@ public:
     static short initialHyphenationLimitAfter() { return -1; }
     static short initialHyphenationLimitLines() { return -1; }
     static const AtomicString& initialHyphenationString() { return nullAtom; }
-    static const AtomicString& initialLocale() { return nullAtom; }
     static EBorderFit initialBorderFit() { return BorderFitBorder; }
     static EResize initialResize() { return RESIZE_NONE; }
     static ControlPart initialAppearance() { return NoControlPart; }
index ff87796..d16b91f 100644 (file)
@@ -211,7 +211,6 @@ inline StyleRareInheritedData::StyleRareInheritedData(const StyleRareInheritedDa
     , hyphenationLimitBefore(o.hyphenationLimitBefore)
     , hyphenationLimitAfter(o.hyphenationLimitAfter)
     , hyphenationLimitLines(o.hyphenationLimitLines)
-    , locale(o.locale)
     , textEmphasisCustomMark(o.textEmphasisCustomMark)
     , m_lineGrid(o.m_lineGrid)
     , m_tabSize(o.m_tabSize)
@@ -288,7 +287,6 @@ bool StyleRareInheritedData::operator==(const StyleRareInheritedData& o) const
         && touchCalloutEnabled == o.touchCalloutEnabled
 #endif
         && hyphenationString == o.hyphenationString
-        && locale == o.locale
         && textEmphasisCustomMark == o.textEmphasisCustomMark
         && arePointingToEqualData(quotes, o.quotes)
         && m_tabSize == o.m_tabSize
index ecbb079..bf4021f 100644 (file)
@@ -142,8 +142,6 @@ public:
     short hyphenationLimitAfter;
     short hyphenationLimitLines;
 
-    AtomicString locale;
-
     AtomicString textEmphasisCustomMark;
     RefPtr<QuotesData> quotes;
 
index 4bcb4c4..d4d115c 100644 (file)
@@ -59,7 +59,9 @@ Ref<RenderStyle> resolveForDocument(const Document& document)
     documentStyle.get().setRTLOrdering(document.visuallyOrdered() ? VisualOrder : LogicalOrder);
     documentStyle.get().setZoom(!document.printing() ? renderView.frame().pageZoomFactor() : 1);
     documentStyle.get().setPageScaleTransform(renderView.frame().frameScaleFactor());
-    documentStyle.get().setLocale(document.contentLanguage());
+    FontCascadeDescription documentFontDescription = documentStyle.get().fontDescription();
+    documentFontDescription.setLocale(document.contentLanguage());
+    documentStyle.get().setFontDescription(WTF::move(documentFontDescription));
 
     // This overrides any -webkit-user-modify inherited from the parent iframe.
     documentStyle.get().setUserModify(document.inDesignMode() ? READ_WRITE : READ_ONLY);
@@ -97,7 +99,7 @@ Ref<RenderStyle> resolveForDocument(const Document& document)
     const Settings& settings = renderView.frame().settings();
 
     FontCascadeDescription fontDescription;
-    fontDescription.setScript(localeToScriptCodeForFontSelection(documentStyle.get().locale()));
+    fontDescription.setLocale(document.contentLanguage());
     fontDescription.setRenderingMode(settings.fontRenderingMode());
     fontDescription.setOneFamily(standardFamily);