Diff
Modified: trunk/LayoutTests/ChangeLog (262795 => 262796)
--- trunk/LayoutTests/ChangeLog 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/LayoutTests/ChangeLog 2020-06-09 17:15:34 UTC (rev 262796)
@@ -1,3 +1,16 @@
+2020-06-09 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ lang=zh needs to defer to system preferences to know whether it should be simplified or traditional
+ https://bugs.webkit.org/show_bug.cgi?id=212626
+ <rdar://problem/60227623>
+
+ Reviewed by Darin Adler.
+
+ Make sure the new locale isn't exposed.
+
+ * fast/text/locale-getComputedStyle-expected.txt: Added.
+ * fast/text/locale-getComputedStyle.html: Added.
+
2020-06-09 Zalan Bujtas <za...@apple.com>
[LFC][TFC] Add support for empty table
Added: trunk/LayoutTests/fast/text/locale-getComputedStyle-expected.txt (0 => 262796)
--- trunk/LayoutTests/fast/text/locale-getComputedStyle-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/text/locale-getComputedStyle-expected.txt 2020-06-09 17:15:34 UTC (rev 262796)
@@ -0,0 +1,10 @@
+This test makes sure that lang='zh' round-trips through getComputedStyle.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS window.getComputedStyle(target).getPropertyValue('-webkit-locale') is "zh"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/text/locale-getComputedStyle.html (0 => 262796)
--- trunk/LayoutTests/fast/text/locale-getComputedStyle.html (rev 0)
+++ trunk/LayoutTests/fast/text/locale-getComputedStyle.html 2020-06-09 17:15:34 UTC (rev 262796)
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+<div lang="zh" id="target"></div>
+<script>
+description("This test makes sure that lang='zh' round-trips through getComputedStyle.");
+let target = document.getElementById("target");
+shouldBeEqualToString("window.getComputedStyle(target).getPropertyValue('-webkit-locale')", "zh");
+</script>
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (262795 => 262796)
--- trunk/Source/WebCore/ChangeLog 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/ChangeLog 2020-06-09 17:15:34 UTC (rev 262796)
@@ -1,3 +1,96 @@
+2020-06-09 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ lang=zh needs to defer to system preferences to know whether it should be simplified or traditional
+ https://bugs.webkit.org/show_bug.cgi?id=212626
+ <rdar://problem/60227623>
+
+ Reviewed by Darin Adler.
+
+ If the content says lang="zh" font-family: sans-serif, we have no signal for whether
+ the content should be traditional or simplified. In this case, we should pick based
+ on system preferences to make it more likely that we get the right answer.
+
+ This is actually what some Cocoa platform text functions were doing, but not all of them.
+ We need to do it at our level in WebKit to make sure that all our calls to the platform
+ have consistent behavior. Also, we can cache the result at our level, which is more
+ performant than if the platform cached it at each platform entry point.
+
+ We already started consulting with system preferences to make this decision in r189038.
+ This patch extends that and fixes it to throughout WebKit.
+
+ This doesn't expose any new fingerprinting data, because this information was already
+ exposed (e.g. by drawing fallback fonts to the canvas and then reading back the pixels).
+
+ Tests: fast/text/locale-getComputedStyle.html
+ fast/text/international/generic-font-family-language-traditional.html
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
+ * css/CSSFontSelector.cpp:
+ (WebCore::resolveGenericFamily):
+ * css/CSSProperties.json:
+ * layout/inlineformatting/InlineLineBreaker.cpp:
+ (WebCore::Layout::LineBreaker::wordBreakBehavior const):
+ (WebCore::Layout::LineBreaker::tryBreakingTextRun const):
+ * platform/graphics/Font.cpp:
+ (WebCore::Font::systemFallbackFontForCharacter const):
+ * platform/graphics/FontCache.h:
+ (WebCore::FontDescriptionKey::FontDescriptionKey):
+ * platform/graphics/FontCascade.cpp:
+ (WebCore::FontCascade::widthForSimpleText const):
+ * platform/graphics/FontCascadeDescription.cpp:
+ * platform/graphics/FontCascadeDescription.h:
+ (WebCore::FontCascadeDescription::initialSpecifiedLocale):
+ (WebCore::FontCascadeDescription::initialLocale): Deleted.
+ * platform/graphics/FontDescription.cpp:
+ (WebCore::computeSpecializedChineseLocale):
+ (WebCore::cachedSpecializedChineseLocale):
+ (WebCore::fontDescriptionLanguageChanged):
+ (WebCore::specializedChineseLocale):
+ (WebCore::FontDescription::setSpecifiedLocale):
+ (WebCore::FontDescription::setLocale): Deleted.
+ * platform/graphics/FontDescription.h:
+ (WebCore::FontDescription::computedLocale const):
+ (WebCore::FontDescription::specifiedLocale const):
+ (WebCore::FontDescription::operator== const):
+ (WebCore::FontDescription::encode const):
+ (WebCore::FontDescription::decode):
+ (WebCore::FontDescription::locale const): Deleted.
+ * platform/graphics/WidthIterator.cpp:
+ (WebCore::WidthIterator::applyFontTransforms):
+ * platform/graphics/cocoa/FontCacheCoreText.cpp:
+ (WebCore::FontCache::systemFallbackForCharacters):
+ * platform/graphics/cocoa/FontDescriptionCocoa.cpp:
+ (WebCore::FontDescription::platformResolveGenericFamily):
+ (WebCore::computeSpecializedChineseLocale): Deleted.
+ (WebCore::cachedSpecializedChineseLocale): Deleted.
+ (WebCore::languageChanged): Deleted.
+ * platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp:
+ (WebCore::SystemFontDatabaseCoreText::systemFontParameters):
+ * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+ (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
+ * rendering/RenderQuote.cpp:
+ (WebCore::RenderQuote::computeText const):
+ * rendering/RenderText.cpp:
+ (WebCore::maxWordFragmentWidth):
+ (WebCore::RenderText::computePreferredLogicalWidths):
+ (WebCore::applyTextTransform):
+ * rendering/RenderThemeCocoa.mm:
+ (WebCore::RenderThemeCocoa::paintApplePayButton):
+ * rendering/SimpleLineLayoutTextFragmentIterator.cpp:
+ (WebCore::SimpleLineLayout::TextFragmentIterator::Style::Style):
+ (WebCore::SimpleLineLayout::TextFragmentIterator::TextFragmentIterator):
+ * rendering/line/BreakingContext.h:
+ (WebCore::BreakingContext::handleText):
+ * rendering/style/RenderStyle.h:
+ (WebCore::RenderStyle::computedLocale const):
+ (WebCore::RenderStyle::specifiedLocale const):
+ (WebCore::RenderStyle::locale const): Deleted.
+ * style/StyleBuilderCustom.h:
+ (WebCore::Style::BuilderCustom::applyValueWebkitLocale):
+ * style/StyleResolveForDocument.cpp:
+ (WebCore::Style::resolveForDocument):
+
2020-06-09 Zalan Bujtas <za...@apple.com>
[LFC][TFC] Add support for empty table
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (262795 => 262796)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -2954,9 +2954,9 @@
case CSSPropertyListStyleType:
return cssValuePool.createValue(style.listStyleType());
case CSSPropertyWebkitLocale:
- if (style.locale().isNull())
+ if (style.specifiedLocale().isNull())
return cssValuePool.createIdentifierValue(CSSValueAuto);
- return cssValuePool.createValue(style.locale(), CSSUnitType::CSS_STRING);
+ return cssValuePool.createValue(style.specifiedLocale(), CSSUnitType::CSS_STRING);
case CSSPropertyMarginTop:
return zoomAdjustedPaddingOrMarginPixelValue<&RenderStyle::marginTop, &RenderBoxModelObject::marginTop>(style, renderer);
case CSSPropertyMarginRight: {
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (262795 => 262796)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -265,7 +265,7 @@
static Optional<AtomString> resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomString& familyName)
{
- auto platformResult = FontDescription::platformResolveGenericFamily(fontDescription.script(), fontDescription.locale(), familyName);
+ auto platformResult = FontDescription::platformResolveGenericFamily(fontDescription.script(), fontDescription.computedLocale(), familyName);
if (!platformResult.isNull())
return platformResult;
Modified: trunk/Source/WebCore/css/CSSProperties.json (262795 => 262796)
--- trunk/Source/WebCore/css/CSSProperties.json 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/css/CSSProperties.json 2020-06-09 17:15:34 UTC (rev 262796)
@@ -620,7 +620,8 @@
"codegen-properties": {
"custom": "Value",
"font-property": true,
- "high-priority": true
+ "high-priority": true,
+ "name-for-methods": "SpecifiedLocale"
},
"status": "non-standard"
},
Modified: trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp (262795 => 262796)
--- trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/layout/inlineformatting/InlineLineBreaker.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -289,7 +289,7 @@
if (style.overflowWrap() == OverflowWrap::Break && !m_hasWrapOpportunityAtPreviousPosition)
return WordBreakRule::AtArbitraryPosition;
- if (!n_hyphenationIsDisabled && style.hyphens() == Hyphens::Auto && canHyphenate(style.locale()))
+ if (!n_hyphenationIsDisabled && style.hyphens() == Hyphens::Auto && canHyphenate(style.computedLocale()))
return WordBreakRule::OnlyHyphenationAllowed;
return WordBreakRule::NoBreak;
@@ -339,7 +339,7 @@
return { };
// Adjust before index to accommodate the limit-after value (it's the last potential hyphen location in this run).
auto hyphenBefore = std::min(leftSideLength, runLength - limitAfter) + 1;
- unsigned hyphenLocation = lastHyphenLocation(StringView(inlineTextItem.inlineTextBox().content()).substring(inlineTextItem.start(), inlineTextItem.length()), hyphenBefore, style.locale());
+ unsigned hyphenLocation = lastHyphenLocation(StringView(inlineTextItem.inlineTextBox().content()).substring(inlineTextItem.start(), inlineTextItem.length()), hyphenBefore, style.computedLocale());
if (!hyphenLocation || hyphenLocation < limitBefore)
return { };
// hyphenLocation is relative to the start of this InlineItemText.
Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/Font.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -581,7 +581,7 @@
return FontCache::singleton().systemFallbackForCharacters(description, this, isForPlatformFont, FontCache::PreferColoredFont::No, &codeUnit, 1);
}
- auto key = CharacterFallbackMapKey(description.locale(), character, isForPlatformFont);
+ auto key = CharacterFallbackMapKey(description.computedLocale(), character, isForPlatformFont);
auto characterAddResult = fontAddResult.iterator->value.add(WTFMove(key), nullptr);
Font*& fallbackFont = characterAddResult.iterator->value;
Modified: trunk/Source/WebCore/platform/graphics/FontCache.h (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/FontCache.h 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/FontCache.h 2020-06-09 17:15:34 UTC (rev 262796)
@@ -78,7 +78,7 @@
: m_size(description.computedPixelSize())
, m_fontSelectionRequest(description.fontSelectionRequest())
, m_flags(makeFlagsKey(description))
- , m_locale(description.locale())
+ , m_locale(description.specifiedLocale())
, m_featureSettings(description.featureSettings())
#if ENABLE(VARIATION_FONTS)
, m_variationSettings(description.variationSettings())
@@ -157,7 +157,6 @@
return {{ first, second }};
}
- // FontCascade::locale() is explicitly not included in this struct.
bool m_isDeletedValue { false };
unsigned m_size { 0 };
FontSelectionRequest m_fontSelectionRequest;
Modified: trunk/Source/WebCore/platform/graphics/FontCascade.cpp (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/FontCascade.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -440,7 +440,7 @@
glyphBuffer.add(glyph, &font, glyphWidth);
}
if (hasKerningOrLigatures) {
- font.applyTransforms(glyphBuffer, 0, enableKerning(), requiresShaping(), fontDescription().locale());
+ font.applyTransforms(glyphBuffer, 0, enableKerning(), requiresShaping(), fontDescription().computedLocale());
// This is needed only to match the result of the slow path. Same glyph widths but different floating point arithmentics can
// produce different run width.
float runWidthDifferenceWithTransformApplied = -runWidth;
Modified: trunk/Source/WebCore/platform/graphics/FontCascadeDescription.cpp (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/FontCascadeDescription.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/FontCascadeDescription.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -42,6 +42,7 @@
char c;
#endif
AtomString string;
+ AtomString string2;
int16_t fontSelectionRequest[3];
float size;
unsigned bitfields1;
Modified: trunk/Source/WebCore/platform/graphics/FontCascadeDescription.h (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/FontCascadeDescription.h 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/FontCascadeDescription.h 2020-06-09 17:15:34 UTC (rev 262796)
@@ -132,7 +132,7 @@
static FontVariantCaps initialVariantCaps() { return FontVariantCaps::Normal; }
static FontVariantAlternates initialVariantAlternates() { return FontVariantAlternates::Normal; }
static FontOpticalSizing initialOpticalSizing() { return FontOpticalSizing::Enabled; }
- static const AtomString& initialLocale() { return nullAtom(); }
+ static const AtomString& initialSpecifiedLocale() { return nullAtom(); }
private:
RefCountedArray<AtomString> m_families { 1 };
Modified: trunk/Source/WebCore/platform/graphics/FontDescription.cpp (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/FontDescription.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2007 Nicholas Shanks <cont...@nickshanks.com>
- * Copyright (C) 2008, 2013 Apple Inc. All rights reserved.
+ * Copyright (C) 2008, 2013 - 2020 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@@ -32,6 +32,7 @@
#include "FontCascadeDescription.h"
#include "LocaleToScriptMapping.h"
+#include <wtf/Language.h>
namespace WebCore {
@@ -65,12 +66,44 @@
{
}
-void FontDescription::setLocale(const AtomString& locale)
+static AtomString computeSpecializedChineseLocale()
{
- m_locale = locale;
- m_script = localeToScriptCodeForFontSelection(m_locale);
+ for (auto& language : userPreferredLanguages()) {
+ if (startsWithLettersIgnoringASCIICase(language, "zh-"))
+ return language;
+ }
+ return AtomString("zh-hans", AtomString::ConstructFromLiteral); // We have no signal. Pick one option arbitrarily.
}
+static AtomString& cachedSpecializedChineseLocale()
+{
+ static NeverDestroyed<AtomString> specializedChineseLocale;
+ return specializedChineseLocale.get();
+}
+
+static void fontDescriptionLanguageChanged(void*)
+{
+ cachedSpecializedChineseLocale() = computeSpecializedChineseLocale();
+}
+
+static const AtomString& specializedChineseLocale()
+{
+ auto& locale = cachedSpecializedChineseLocale();
+ if (cachedSpecializedChineseLocale().isNull()) {
+ static char forNonNullPointer;
+ addLanguageChangeObserver(&forNonNullPointer, &fontDescriptionLanguageChanged); // We will never remove the observer, so all we need is a non-null pointer.
+ fontDescriptionLanguageChanged(nullptr);
+ }
+ return locale;
+}
+
+void FontDescription::setSpecifiedLocale(const AtomString& locale)
+{
+ m_specifiedLocale = locale;
+ m_script = localeToScriptCodeForFontSelection(m_specifiedLocale);
+ m_locale = m_script == USCRIPT_HAN ? specializedChineseLocale() : m_specifiedLocale;
+}
+
#if !PLATFORM(COCOA)
AtomString FontDescription::platformResolveGenericFamily(UScriptCode, const AtomString&, const AtomString&)
{
Modified: trunk/Source/WebCore/platform/graphics/FontDescription.h (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/FontDescription.h 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/FontDescription.h 2020-06-09 17:15:34 UTC (rev 262796)
@@ -51,7 +51,8 @@
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 AtomString& locale() const { return m_locale; }
+ const AtomString& computedLocale() const { return m_locale; } // This is what you should be using for things like text shaping and font fallback
+ const AtomString& specifiedLocale() const { return m_specifiedLocale; } // This is what you should be using for web-exposed things like -webkit-locale
FontOrientation orientation() const { return static_cast<FontOrientation>(m_orientation); }
NonCJKGlyphOrientation nonCJKGlyphOrientation() const { return static_cast<NonCJKGlyphOrientation>(m_nonCJKGlyphOrientation); }
@@ -106,7 +107,7 @@
void setOrientation(FontOrientation orientation) { m_orientation = static_cast<unsigned>(orientation); }
void setNonCJKGlyphOrientation(NonCJKGlyphOrientation orientation) { m_nonCJKGlyphOrientation = static_cast<unsigned>(orientation); }
void setWidthVariant(FontWidthVariant widthVariant) { m_widthVariant = static_cast<unsigned>(widthVariant); } // Make sure new callers of this sync with FontPlatformData::isForTextCombine()!
- WEBCORE_EXPORT void setLocale(const AtomString&);
+ WEBCORE_EXPORT void setSpecifiedLocale(const AtomString&);
void setFeatureSettings(FontFeatureSettings&& settings) { m_featureSettings = WTFMove(settings); }
#if ENABLE(VARIATION_FONTS)
void setVariationSettings(FontVariationSettings&& settings) { m_variationSettings = WTFMove(settings); }
@@ -144,6 +145,7 @@
FontFeatureSettings m_featureSettings;
FontVariationSettings m_variationSettings;
AtomString m_locale;
+ AtomString m_specifiedLocale;
FontSelectionRequest m_fontSelectionRequest;
float m_computedSize { 0 }; // Computed size adjusted for the minimum font size and the zoom factor.
@@ -183,7 +185,7 @@
&& m_orientation == other.m_orientation
&& m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation
&& m_widthVariant == other.m_widthVariant
- && m_locale == other.m_locale
+ && m_specifiedLocale == other.m_specifiedLocale
&& m_featureSettings == other.m_featureSettings
#if ENABLE(VARIATION_FONTS)
&& m_variationSettings == other.m_variationSettings
@@ -216,7 +218,7 @@
#if ENABLE(VARIATION_FONTS)
encoder << variationSettings();
#endif
- encoder << locale();
+ encoder << computedLocale();
encoder << italic();
encoder << stretch();
encoder << weight();
@@ -412,7 +414,7 @@
#if ENABLE(VARIATION_FONTS)
fontDescription.setVariationSettings(WTFMove(*variationSettings));
#endif
- fontDescription.setLocale(*locale);
+ fontDescription.setSpecifiedLocale(*locale);
fontDescription.setItalic(*italic);
fontDescription.setStretch(*stretch);
fontDescription.setWeight(*weight);
Modified: trunk/Source/WebCore/platform/graphics/WidthIterator.cpp (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/WidthIterator.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -113,7 +113,7 @@
if (!ltr)
glyphBuffer->reverse(lastGlyphCount, glyphBufferSize - lastGlyphCount);
- font->applyTransforms(*glyphBuffer, lastGlyphCount, m_enableKerning, m_requiresShaping, m_font->fontDescription().locale());
+ font->applyTransforms(*glyphBuffer, lastGlyphCount, m_enableKerning, m_requiresShaping, m_font->fontDescription().computedLocale());
glyphBufferSize = glyphBuffer->size();
for (unsigned i = lastGlyphCount; i < glyphBufferSize; ++i)
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -1465,7 +1465,7 @@
if (!fullName.isEmpty())
m_fontNamesRequiringSystemFallbackForPrewarming.add(fullName);
- auto result = lookupFallbackFont(platformData.font(), description.weight(), description.locale(), description.shouldAllowUserInstalledFonts(), characters, length);
+ auto result = lookupFallbackFont(platformData.font(), description.weight(), description.computedLocale(), description.shouldAllowUserInstalledFonts(), characters, length);
result = preparePlatformFont(result.get(), description, nullptr, { });
if (!result)
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontDescriptionCocoa.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -28,7 +28,6 @@
#include "SystemFontDatabaseCoreText.h"
#include <mutex>
-#include <wtf/Language.h>
namespace WebCore {
@@ -145,27 +144,6 @@
#endif // USE(PLATFORM_SYSTEM_FALLBACK_LIST)
-static String computeSpecializedChineseLocale()
-{
- const Vector<String>& preferredLanguages = userPreferredLanguages();
- for (auto& language : preferredLanguages) {
- if (equalIgnoringASCIICase(language, "zh") || startsWithLettersIgnoringASCIICase(language, "zh-"))
- return language;
- }
- return "zh-hans"_str; // We have no signal. Pick one option arbitrarily.
-}
-
-static String& cachedSpecializedChineseLocale()
-{
- static NeverDestroyed<String> specializedChineseLocale;
- return specializedChineseLocale.get();
-}
-
-static void languageChanged(void*)
-{
- cachedSpecializedChineseLocale() = computeSpecializedChineseLocale();
-}
-
AtomString FontDescription::platformResolveGenericFamily(UScriptCode script, const AtomString& locale, const AtomString& familyName)
{
ASSERT((locale.isNull() && script == USCRIPT_COMMON) || !locale.isNull());
@@ -172,27 +150,17 @@
if (script == USCRIPT_COMMON)
return nullAtom();
- static std::once_flag onceFlag;
- std::call_once(onceFlag, [&] {
- static char dummy;
- addLanguageChangeObserver(&dummy, &languageChanged); // We will never remove the observer, so all we need is a non-null pointer.
- languageChanged(nullptr);
- });
-
- // FIXME: Delete this once <rdar://problem/47682577> is fixed.
- auto& usedLocale = script == USCRIPT_HAN ? cachedSpecializedChineseLocale() : locale.string();
-
// FIXME: Use the system font database to handle standardFamily
if (familyName == serifFamily)
- return SystemFontDatabaseCoreText::singleton().serifFamily(usedLocale);
+ return SystemFontDatabaseCoreText::singleton().serifFamily(locale.string());
if (familyName == sansSerifFamily)
- return SystemFontDatabaseCoreText::singleton().sansSerifFamily(usedLocale);
+ return SystemFontDatabaseCoreText::singleton().sansSerifFamily(locale.string());
if (familyName == cursiveFamily)
- return SystemFontDatabaseCoreText::singleton().cursiveFamily(usedLocale);
+ return SystemFontDatabaseCoreText::singleton().cursiveFamily(locale.string());
if (familyName == fantasyFamily)
- return SystemFontDatabaseCoreText::singleton().fantasyFamily(usedLocale);
+ return SystemFontDatabaseCoreText::singleton().fantasyFamily(locale.string());
if (familyName == monospaceFamily)
- return SystemFontDatabaseCoreText::singleton().monospaceFamily(usedLocale);
+ return SystemFontDatabaseCoreText::singleton().monospaceFamily(locale.string());
return nullAtom();
}
Modified: trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/cocoa/SystemFontDatabaseCoreText.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -183,7 +183,7 @@
SystemFontDatabaseCoreText::CascadeListParameters SystemFontDatabaseCoreText::systemFontParameters(const FontDescription& description, const AtomString& familyName, SystemFontKind systemFontKind, AllowUserInstalledFonts allowUserInstalledFonts)
{
CascadeListParameters result;
- result.locale = description.locale();
+ result.locale = description.computedLocale();
result.size = description.computedSize();
result.italic = isItalic(description.italic());
result.allowUserInstalledFonts = allowUserInstalledFonts;
Modified: trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm (262795 => 262796)
--- trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm 2020-06-09 17:15:34 UTC (rev 262796)
@@ -128,11 +128,11 @@
font = m_font.fallbackRangesAt(0).fontForCharacter(baseCharacter);
if (!font)
font = &m_font.fallbackRangesAt(0).fontForFirstRange();
- stringAttributes = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, font->getCFStringAttributes(m_font.enableKerning(), font->platformData().orientation(), m_font.fontDescription().locale()).get()));
+ stringAttributes = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, font->getCFStringAttributes(m_font.enableKerning(), font->platformData().orientation(), m_font.fontDescription().computedLocale()).get()));
// We don't know which font should be used to render this grapheme cluster, so enable CoreText's fallback mechanism by using the CTFont which doesn't have CoreText's fallback disabled.
CFDictionarySetValue(const_cast<CFMutableDictionaryRef>(stringAttributes.get()), kCTFontAttributeName, font->platformData().font());
} else
- stringAttributes = font->getCFStringAttributes(m_font.enableKerning(), font->platformData().orientation(), m_font.fontDescription().locale());
+ stringAttributes = font->getCFStringAttributes(m_font.enableKerning(), font->platformData().orientation(), m_font.fontDescription().computedLocale());
RetainPtr<CTLineRef> line;
Modified: trunk/Source/WebCore/rendering/RenderQuote.cpp (262795 => 262796)
--- trunk/Source/WebCore/rendering/RenderQuote.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/rendering/RenderQuote.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -380,7 +380,7 @@
case QuoteType::CloseQuote:
if (const QuotesData* quotes = style().quotes())
return isOpenQuote ? quotes->openQuote(m_depth).impl() : quotes->closeQuote(m_depth).impl();
- if (const QuotesForLanguage* quotes = quotesForLanguage(style().locale()))
+ if (const QuotesForLanguage* quotes = quotesForLanguage(style().specifiedLocale()))
return stringForQuoteCharacter(isOpenQuote ? (m_depth ? quotes->open2 : quotes->open1) : (m_depth ? quotes->close2 : quotes->close1));
// FIXME: Should the default be the quotes for "en" rather than straight quotes?
return m_depth ? apostropheString() : quotationMarkString();
Modified: trunk/Source/WebCore/rendering/RenderText.cpp (262795 => 262796)
--- trunk/Source/WebCore/rendering/RenderText.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/rendering/RenderText.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -739,7 +739,7 @@
Vector<int, 8> hyphenLocations;
ASSERT(word.length() >= minimumSuffixLength);
unsigned hyphenLocation = word.length() - minimumSuffixLength;
- while ((hyphenLocation = lastHyphenLocation(word, hyphenLocation, style.locale())) >= std::max(minimumPrefixLength, 1U))
+ while ((hyphenLocation = lastHyphenLocation(word, hyphenLocation, style.computedLocale())) >= std::max(minimumPrefixLength, 1U))
hyphenLocations.append(hyphenLocation);
if (hyphenLocations.isEmpty())
@@ -793,7 +793,7 @@
auto& string = text();
unsigned length = string.length();
auto iteratorMode = mapLineBreakToIteratorMode(style.lineBreak());
- LazyLineBreakIterator breakIterator(string, style.locale(), iteratorMode);
+ LazyLineBreakIterator breakIterator(string, style.computedLocale(), iteratorMode);
bool needsWordSpacing = false;
bool ignoringSpaces = false;
bool isSpace = false;
@@ -808,7 +808,7 @@
float maxWordWidth = std::numeric_limits<float>::max();
unsigned minimumPrefixLength = 0;
unsigned minimumSuffixLength = 0;
- if (style.hyphens() == Hyphens::Auto && canHyphenate(style.locale())) {
+ if (style.hyphens() == Hyphens::Auto && canHyphenate(style.computedLocale())) {
maxWordWidth = 0;
// Map 'hyphenate-limit-{before,after}: auto;' to 2.
@@ -1143,9 +1143,9 @@
case TextTransform::Capitalize:
return capitalize(text, previousCharacter); // FIXME: Need to take locale into account.
case TextTransform::Uppercase:
- return text.convertToUppercaseWithLocale(style.locale());
+ return text.convertToUppercaseWithLocale(style.computedLocale());
case TextTransform::Lowercase:
- return text.convertToLowercaseWithLocale(style.locale());
+ return text.convertToLowercaseWithLocale(style.computedLocale());
}
ASSERT_NOT_REACHED();
return text;
Modified: trunk/Source/WebCore/rendering/RenderThemeCocoa.mm (262795 => 262796)
--- trunk/Source/WebCore/rendering/RenderThemeCocoa.mm 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/rendering/RenderThemeCocoa.mm 2020-06-09 17:15:34 UTC (rev 262796)
@@ -137,7 +137,7 @@
floatValueForLength(style.borderBottomRightRadius().width, paintRect.width())
});
- PKDrawApplePayButtonWithCornerRadius(paintInfo.context().platformContext(), CGRectMake(paintRect.x(), -paintRect.maxY(), paintRect.width(), paintRect.height()), 1.0, largestCornerRadius, toPKPaymentButtonType(style.applePayButtonType()), toPKPaymentButtonStyle(style.applePayButtonStyle()), style.locale());
+ PKDrawApplePayButtonWithCornerRadius(paintInfo.context().platformContext(), CGRectMake(paintRect.x(), -paintRect.maxY(), paintRect.width(), paintRect.height()), 1.0, largestCornerRadius, toPKPaymentButtonType(style.applePayButtonType()), toPKPaymentButtonStyle(style.applePayButtonStyle()), style.computedLocale());
return false;
}
Modified: trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp (262795 => 262796)
--- trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/rendering/SimpleLineLayoutTextFragmentIterator.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -50,11 +50,11 @@
, keepAllWordsForCJK(style.wordBreak() == WordBreak::KeepAll)
, wordSpacing(font.wordSpacing())
, tabWidth(collapseWhitespace ? TabSize(0) : style.tabSize())
- , shouldHyphenate(style.hyphens() == Hyphens::Auto && canHyphenate(style.locale()))
+ , shouldHyphenate(style.hyphens() == Hyphens::Auto && canHyphenate(style.computedLocale()))
, hyphenStringWidth(shouldHyphenate ? font.width(TextRun(String(style.hyphenString()))) : 0)
, hyphenLimitBefore(style.hyphenationLimitBefore() < 0 ? 2 : style.hyphenationLimitBefore())
, hyphenLimitAfter(style.hyphenationLimitAfter() < 0 ? 2 : style.hyphenationLimitAfter())
- , locale(style.locale())
+ , locale(style.computedLocale())
{
if (style.hyphenationLimitLines() > -1)
hyphenLimitLines = style.hyphenationLimitLines();
@@ -63,7 +63,7 @@
TextFragmentIterator::TextFragmentIterator(const RenderBlockFlow& flow)
: m_flowContents(flow)
, m_currentSegment(m_flowContents.begin())
- , m_lineBreakIterator(m_currentSegment->text, flow.style().locale())
+ , m_lineBreakIterator(m_currentSegment->text, flow.style().computedLocale())
, m_style(flow.style())
{
}
Modified: trunk/Source/WebCore/rendering/line/BreakingContext.h (262795 => 262796)
--- trunk/Source/WebCore/rendering/line/BreakingContext.h 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/rendering/line/BreakingContext.h 2020-06-09 17:15:34 UTC (rev 262796)
@@ -695,7 +695,7 @@
const RenderStyle& style = lineStyle(renderText, m_lineInfo);
const FontCascade& font = style.fontCascade();
bool isFixedPitch = font.isFixedPitch();
- bool canHyphenate = style.hyphens() == Hyphens::Auto && WebCore::canHyphenate(style.locale());
+ bool canHyphenate = style.hyphens() == Hyphens::Auto && WebCore::canHyphenate(style.computedLocale());
bool canHangPunctuationAtStart = style.hangingPunctuation().contains(HangingPunctuation::First);
bool canHangPunctuationAtEnd = style.hangingPunctuation().contains(HangingPunctuation::Last);
bool canHangStopOrCommaAtLineEnd = style.hangingPunctuation().contains(HangingPunctuation::AllowEnd);
@@ -731,7 +731,7 @@
m_renderTextInfo.text = &renderText;
m_renderTextInfo.font = &font;
m_renderTextInfo.layout = font.createLayout(renderText, m_width.currentWidth(), m_collapseWhiteSpace);
- m_renderTextInfo.lineBreakIterator.resetStringAndReleaseIterator(renderText.text(), style.locale(), iteratorMode);
+ m_renderTextInfo.lineBreakIterator.resetStringAndReleaseIterator(renderText.text(), style.computedLocale(), iteratorMode);
} else if (m_renderTextInfo.layout && m_renderTextInfo.font != &font) {
m_renderTextInfo.font = &font;
m_renderTextInfo.layout = font.createLayout(renderText, m_width.currentWidth(), m_collapseWhiteSpace);
@@ -877,7 +877,7 @@
// no more content, and a hyphenated single word would end up on a line by itself. This looks
// bad so just don't allow it.
if (canHyphenate && !m_width.fitsOnLine() && (m_nextObject || !renderText.containsOnlyHTMLWhitespace(m_current.offset(), renderText.text().length() - m_current.offset()) || isLineEmpty)) {
- tryHyphenating(renderText, font, style.locale(), consecutiveHyphenatedLines, m_blockStyle.hyphenationLimitLines(), style.hyphenationLimitBefore(), style.hyphenationLimitAfter(), lastSpace, m_current.offset(), m_width.currentWidth() - additionalTempWidth, m_width.availableWidth(), isFixedPitch, m_collapseWhiteSpace, lastSpaceWordSpacing, m_lineBreak, m_current.nextBreakablePosition(), m_lineBreaker.m_hyphenated);
+ tryHyphenating(renderText, font, style.computedLocale(), consecutiveHyphenatedLines, m_blockStyle.hyphenationLimitLines(), style.hyphenationLimitBefore(), style.hyphenationLimitAfter(), lastSpace, m_current.offset(), m_width.currentWidth() - additionalTempWidth, m_width.availableWidth(), isFixedPitch, m_collapseWhiteSpace, lastSpaceWordSpacing, m_lineBreak, m_current.nextBreakablePosition(), m_lineBreaker.m_hyphenated);
if (m_lineBreaker.m_hyphenated) {
m_atEnd = true;
return false;
@@ -1071,7 +1071,7 @@
// no more content, and a hyphenated single word would end up on a line by itself. This looks
// bad so just don't allow it.
if (canHyphenate && (m_nextObject || isLineEmpty))
- tryHyphenating(renderText, font, style.locale(), consecutiveHyphenatedLines, m_blockStyle.hyphenationLimitLines(), style.hyphenationLimitBefore(), style.hyphenationLimitAfter(), lastSpace, m_current.offset(), m_width.currentWidth() - additionalTempWidth, m_width.availableWidth(), isFixedPitch, m_collapseWhiteSpace, lastSpaceWordSpacing, m_lineBreak, m_current.nextBreakablePosition(), m_lineBreaker.m_hyphenated);
+ tryHyphenating(renderText, font, style.computedLocale(), consecutiveHyphenatedLines, m_blockStyle.hyphenationLimitLines(), style.hyphenationLimitBefore(), style.hyphenationLimitAfter(), lastSpace, m_current.offset(), m_width.currentWidth() - additionalTempWidth, m_width.availableWidth(), isFixedPitch, m_collapseWhiteSpace, lastSpaceWordSpacing, m_lineBreak, m_current.nextBreakablePosition(), m_lineBreaker.m_hyphenated);
if (!hyphenated && m_lineBreak.previousInSameNode() == softHyphen && style.hyphens() != Hyphens::None) {
hyphenated = true;
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (262795 => 262796)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2020-06-09 17:15:34 UTC (rev 262796)
@@ -593,7 +593,8 @@
short hyphenationLimitAfter() const { return m_rareInheritedData->hyphenationLimitAfter; }
short hyphenationLimitLines() const { return m_rareInheritedData->hyphenationLimitLines; }
const AtomString& hyphenationString() const { return m_rareInheritedData->hyphenationString; }
- const AtomString& locale() const { return fontDescription().locale(); }
+ const AtomString& computedLocale() const { return fontDescription().computedLocale(); }
+ const AtomString& specifiedLocale() const { return fontDescription().specifiedLocale(); }
BorderFit borderFit() const { return static_cast<BorderFit>(m_rareNonInheritedData->borderFit); }
Resize resize() const { return static_cast<Resize>(m_rareNonInheritedData->resize); }
ColumnAxis columnAxis() const { return static_cast<ColumnAxis>(m_rareNonInheritedData->multiCol->axis); }
Modified: trunk/Source/WebCore/style/StyleBuilderCustom.h (262795 => 262796)
--- trunk/Source/WebCore/style/StyleBuilderCustom.h 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/style/StyleBuilderCustom.h 2020-06-09 17:15:34 UTC (rev 262796)
@@ -751,9 +751,9 @@
FontCascadeDescription fontDescription = builderState.style().fontDescription();
if (primitiveValue.valueID() == CSSValueAuto)
- fontDescription.setLocale(nullAtom());
+ fontDescription.setSpecifiedLocale(nullAtom());
else
- fontDescription.setLocale(primitiveValue.stringValue());
+ fontDescription.setSpecifiedLocale(primitiveValue.stringValue());
builderState.setFontDescription(WTFMove(fontDescription));
}
Modified: trunk/Source/WebCore/style/StyleResolveForDocument.cpp (262795 => 262796)
--- trunk/Source/WebCore/style/StyleResolveForDocument.cpp 2020-06-09 15:59:29 UTC (rev 262795)
+++ trunk/Source/WebCore/style/StyleResolveForDocument.cpp 2020-06-09 17:15:34 UTC (rev 262796)
@@ -63,7 +63,7 @@
documentStyle.setZoom(!document.printing() ? renderView.frame().pageZoomFactor() : 1);
documentStyle.setPageScaleTransform(renderView.frame().frameScaleFactor());
FontCascadeDescription documentFontDescription = documentStyle.fontDescription();
- documentFontDescription.setLocale(document.contentLanguage());
+ documentFontDescription.setSpecifiedLocale(document.contentLanguage());
documentStyle.setFontDescription(WTFMove(documentFontDescription));
// This overrides any -webkit-user-modify inherited from the parent iframe.
@@ -108,7 +108,7 @@
const Settings& settings = renderView.frame().settings();
FontCascadeDescription fontDescription;
- fontDescription.setLocale(document.contentLanguage());
+ fontDescription.setSpecifiedLocale(document.contentLanguage());
fontDescription.setRenderingMode(settings.fontRenderingMode());
fontDescription.setOneFamily(standardFamily);
fontDescription.setShouldAllowUserInstalledFonts(settings.shouldAllowUserInstalledFonts() ? AllowUserInstalledFonts::Yes : AllowUserInstalledFonts::No);