Diff
Modified: trunk/Source/WebCore/ChangeLog (216895 => 216896)
--- trunk/Source/WebCore/ChangeLog 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/ChangeLog 2017-05-16 01:37:43 UTC (rev 216896)
@@ -1,3 +1,51 @@
+2017-05-15 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ Migrate Font constructor from bools to enums
+ https://bugs.webkit.org/show_bug.cgi?id=172140
+
+ Reviewed by Tim Horton.
+
+ In https://bugs.webkit.org/show_bug.cgi?id=168487, I'm adding a new flag to Font. We can't
+ keep having just a pile of bools in this class. Instead, we should be using enums.
+
+ No new tests because there is no behavior change.
+
+ * css/CSSFontFace.cpp:
+ (WebCore::CSSFontFace::font):
+ * css/CSSFontFaceSource.cpp:
+ (WebCore::CSSFontFaceSource::font):
+ * css/CSSSegmentedFontFace.cpp:
+ * loader/cache/CachedFont.cpp:
+ (WebCore::CachedFont::createFont):
+ * platform/graphics/Font.cpp:
+ (WebCore::Font::Font):
+ (WebCore::Font::verticalRightOrientationFont):
+ (WebCore::Font::uprightOrientationFont):
+ (WebCore::Font::brokenIdeographFont):
+ (WebCore::Font::description):
+ (WebCore::Font::mathData):
+ * platform/graphics/Font.h:
+ (WebCore::Font::create):
+ (WebCore::Font::origin):
+ (WebCore::Font::isInterstitial):
+ (WebCore::Font::widthForGlyph):
+ (WebCore::Font::isCustomFont): Deleted.
+ (WebCore::Font::isLoading): Deleted.
+ * platform/graphics/FontRanges.cpp:
+ * platform/graphics/cocoa/FontCocoa.mm:
+ (WebCore::Font::platformInit):
+ * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
+ (WebCore::Font::platformCreateScaledFont):
+ * platform/graphics/win/SimpleFontDataCGWin.cpp:
+ (WebCore::Font::platformInit):
+ * platform/graphics/win/SimpleFontDataDirect2D.cpp:
+ (WebCore::Font::platformInit):
+ * platform/graphics/win/SimpleFontDataWin.cpp:
+ (WebCore::Font::platformCreateScaledFont):
+ (WebCore::Font::determinePitch):
+ * rendering/SimpleLineLayout.cpp:
+ (WebCore::SimpleLineLayout::canUseForFontAndText):
+
2017-05-15 Youenn Fablet <you...@apple.com>
WebRTC outgoing muted video sources should send black frames
Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (216895 => 216896)
--- trunk/Source/WebCore/css/CSSFontFace.cpp 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp 2017-05-16 01:37:43 UTC (rev 216896)
@@ -625,7 +625,7 @@
fontIsLoading = true;
if (status() == Status::TimedOut)
continue;
- return Font::create(FontCache::singleton().lastResortFallbackFontForEveryCharacter(fontDescription)->platformData(), true, true);
+ return Font::create(FontCache::singleton().lastResortFallbackFontForEveryCharacter(fontDescription)->platformData(), Font::Origin::Remote, Font::Interstitial::Yes);
case CSSFontFaceSource::Status::Success:
if (RefPtr<Font> result = source->font(fontDescription, syntheticBold, syntheticItalic, m_featureSettings, m_variantSettings, m_fontSelectionCapabilities))
return result;
Modified: trunk/Source/WebCore/css/CSSFontFaceSource.cpp (216895 => 216896)
--- trunk/Source/WebCore/css/CSSFontFaceSource.cpp 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/css/CSSFontFaceSource.cpp 2017-05-16 01:37:43 UTC (rev 216896)
@@ -181,7 +181,7 @@
if (m_immediateSource) {
if (!m_immediateFontCustomPlatformData)
return nullptr;
- return Font::create(CachedFont::platformDataFromCustomData(*m_immediateFontCustomPlatformData, fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities), true);
+ return Font::create(CachedFont::platformDataFromCustomData(*m_immediateFontCustomPlatformData, fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities), Font::Origin::Remote);
}
// We're local. Just return a Font from the normal cache.
@@ -206,9 +206,9 @@
if (!m_inDocumentCustomPlatformData)
return nullptr;
#if PLATFORM(COCOA)
- return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities), true);
+ return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities), Font::Origin::Remote);
#else
- return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic), true);
+ return Font::create(m_inDocumentCustomPlatformData->fontPlatformData(fontDescription, syntheticBold, syntheticItalic), Font::Origin::Remote);
#endif
#endif
Modified: trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp (216895 => 216896)
--- trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/css/CSSSegmentedFontFace.cpp 2017-05-16 01:37:43 UTC (rev 216896)
@@ -84,7 +84,7 @@
bool isLoading() const final
{
- return m_result && m_result.value() && m_result.value()->isLoading();
+ return m_result && m_result.value() && m_result.value()->isInterstitial();
}
mutable std::optional<RefPtr<Font>> m_result; // Caches nullptr too
Modified: trunk/Source/WebCore/loader/cache/CachedFont.cpp (216895 => 216896)
--- trunk/Source/WebCore/loader/cache/CachedFont.cpp 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/loader/cache/CachedFont.cpp 2017-05-16 01:37:43 UTC (rev 216896)
@@ -124,7 +124,7 @@
RefPtr<Font> CachedFont::createFont(const FontDescription& fontDescription, const AtomicString&, bool syntheticBold, bool syntheticItalic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
{
- return Font::create(platformDataFromCustomData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities), true);
+ return Font::create(platformDataFromCustomData(fontDescription, syntheticBold, syntheticItalic, fontFaceFeatures, fontFaceVariantSettings, fontFaceCapabilities), Font::Origin::Remote);
}
FontPlatformData CachedFont::platformDataFromCustomData(const FontDescription& fontDescription, bool bold, bool italic, const FontFeatureSettings& fontFaceFeatures, const FontVariantSettings& fontFaceVariantSettings, FontSelectionSpecifiedCapabilities fontFaceCapabilities)
Modified: trunk/Source/WebCore/platform/graphics/Font.cpp (216895 => 216896)
--- trunk/Source/WebCore/platform/graphics/Font.cpp 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/platform/graphics/Font.cpp 2017-05-16 01:37:43 UTC (rev 216896)
@@ -55,15 +55,15 @@
const float smallCapsFontSizeMultiplier = 0.7f;
const float emphasisMarkFontSizeMultiplier = 0.5f;
-Font::Font(const FontPlatformData& platformData, bool isCustomFont, bool isLoading, bool isTextOrientationFallback)
+Font::Font(const FontPlatformData& platformData, Origin origin, Interstitial interstitial, OrientationFallback orientationFallback)
: m_maxCharWidth(-1)
, m_avgCharWidth(-1)
, m_platformData(platformData)
, m_mathData(nullptr)
, m_treatAsFixedPitch(false)
- , m_isCustomFont(isCustomFont)
- , m_isLoading(isLoading)
- , m_isTextOrientationFallback(isTextOrientationFallback)
+ , m_origin(origin == Origin::Remote)
+ , m_isInterstitial(interstitial == Interstitial::Yes)
+ , m_isTextOrientationFallback(orientationFallback == OrientationFallback::Fallback)
, m_isBrokenIdeographFallback(false)
, m_hasVerticalGlyphs(false)
, m_isUsedInSystemFallbackCache(false)
@@ -75,7 +75,7 @@
platformGlyphInit();
platformCharWidthInit();
#if ENABLE(OPENTYPE_VERTICAL)
- if (platformData.orientation() == Vertical && !isTextOrientationFallback) {
+ if (platformData.orientation() == Vertical && orientationFallback == OrientationFallback::NoFallback) {
m_verticalData = FontCache::singleton().verticalData(platformData);
m_hasVerticalGlyphs = m_verticalData.get() && m_verticalData->hasVerticalMetrics();
}
@@ -266,7 +266,7 @@
m_derivedFontData = std::make_unique<DerivedFonts>();
if (!m_derivedFontData->verticalRightOrientation) {
auto verticalRightPlatformData = FontPlatformData::cloneWithOrientation(m_platformData, Horizontal);
- m_derivedFontData->verticalRightOrientation = create(verticalRightPlatformData, isCustomFont(), false, true);
+ m_derivedFontData->verticalRightOrientation = create(verticalRightPlatformData, origin(), Interstitial::No, OrientationFallback::Fallback);
}
ASSERT(m_derivedFontData->verticalRightOrientation != this);
return *m_derivedFontData->verticalRightOrientation;
@@ -277,7 +277,7 @@
if (!m_derivedFontData)
m_derivedFontData = std::make_unique<DerivedFonts>();
if (!m_derivedFontData->uprightOrientation)
- m_derivedFontData->uprightOrientation = create(m_platformData, isCustomFont(), false, true);
+ m_derivedFontData->uprightOrientation = create(m_platformData, origin(), Interstitial::No, OrientationFallback::Fallback);
ASSERT(m_derivedFontData->uprightOrientation != this);
return *m_derivedFontData->uprightOrientation;
}
@@ -321,7 +321,7 @@
if (!m_derivedFontData)
m_derivedFontData = std::make_unique<DerivedFonts>();
if (!m_derivedFontData->brokenIdeograph) {
- m_derivedFontData->brokenIdeograph = create(m_platformData, isCustomFont(), false);
+ m_derivedFontData->brokenIdeograph = create(m_platformData, origin(), Interstitial::No);
m_derivedFontData->brokenIdeograph->m_isBrokenIdeographFallback = true;
}
ASSERT(m_derivedFontData->brokenIdeograph != this);
@@ -331,7 +331,7 @@
#ifndef NDEBUG
String Font::description() const
{
- if (isCustomFont())
+ if (origin() == Origin::Remote)
return "[custom font]";
return platformData().description();
@@ -340,7 +340,7 @@
const OpenTypeMathData* Font::mathData() const
{
- if (m_isLoading)
+ if (isInterstitial())
return nullptr;
if (!m_mathData) {
m_mathData = OpenTypeMathData::create(m_platformData);
Modified: trunk/Source/WebCore/platform/graphics/Font.h (216895 => 216896)
--- trunk/Source/WebCore/platform/graphics/Font.h 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/platform/graphics/Font.h 2017-05-16 01:37:43 UTC (rev 216896)
@@ -76,9 +76,21 @@
class Font : public RefCounted<Font> {
public:
// Used to create platform fonts.
- static Ref<Font> create(const FontPlatformData& platformData, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false)
+ enum class Origin {
+ Remote,
+ Local
+ };
+ enum class Interstitial {
+ Yes,
+ No
+ };
+ enum class OrientationFallback {
+ Fallback,
+ NoFallback
+ };
+ static Ref<Font> create(const FontPlatformData& platformData, Origin origin = Origin::Local, Interstitial interstitial = Interstitial::No, OrientationFallback orientationFallback = OrientationFallback::NoFallback)
{
- return adoptRef(*new Font(platformData, isCustomFont, isLoading, isTextOrientationFallback));
+ return adoptRef(*new Font(platformData, origin, interstitial, orientationFallback));
}
WEBCORE_EXPORT ~Font();
@@ -169,8 +181,8 @@
void determinePitch();
Pitch pitch() const { return m_treatAsFixedPitch ? FixedPitch : VariablePitch; }
- bool isCustomFont() const { return m_isCustomFont; }
- bool isLoading() const { return m_isLoading; }
+ Origin origin() const { return m_origin ? Origin::Remote : Origin::Local; }
+ bool isInterstitial() const { return m_isInterstitial; }
#ifndef NDEBUG
String description() const;
@@ -208,7 +220,7 @@
#endif
private:
- Font(const FontPlatformData&, bool isCustomFont = false, bool isLoading = false, bool isTextOrientationFallback = false);
+ Font(const FontPlatformData&, Origin, Interstitial, OrientationFallback);
void platformInit();
void platformGlyphInit();
@@ -292,8 +304,8 @@
#endif
unsigned m_treatAsFixedPitch : 1;
- unsigned m_isCustomFont : 1; // Whether or not we are custom font loaded via @font-face
- unsigned m_isLoading : 1; // Whether or not this custom font is still in the act of loading.
+ unsigned m_origin : 1; // Whether or not we are custom font loaded via @font-face
+ unsigned m_isInterstitial : 1; // Whether or not this custom font is the last resort placeholder for a loading font
unsigned m_isTextOrientationFallback : 1;
unsigned m_isBrokenIdeographFallback : 1;
@@ -335,7 +347,7 @@
// used in place of the actual font when isLoading() is true on both macOS and iOS.
// The zero-width-space glyph in that font does not have a width of zero and, further, that glyph is used
// for many other characters and must not be zero width when used for them.
- if (isZeroWidthSpaceGlyph(glyph) && !isLoading())
+ if (isZeroWidthSpaceGlyph(glyph) && !isInterstitial())
return 0;
float width = m_glyphToWidthMap.metricsForGlyph(glyph);
Modified: trunk/Source/WebCore/platform/graphics/FontRanges.cpp (216895 => 216896)
--- trunk/Source/WebCore/platform/graphics/FontRanges.cpp 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/platform/graphics/FontRanges.cpp 2017-05-16 01:37:43 UTC (rev 216896)
@@ -62,7 +62,7 @@
bool isLoading() const final
{
- return m_font->isLoading();
+ return m_font->isInterstitial();
}
RefPtr<Font> m_font;
Modified: trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm (216895 => 216896)
--- trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/platform/graphics/cocoa/FontCocoa.mm 2017-05-16 01:37:43 UTC (rev 216896)
@@ -156,7 +156,7 @@
// web standard. The AppKit adjustment of 20% is too big and is
// incorrectly added to line spacing, so we use a 15% adjustment instead
// and add it to the ascent.
- if (!m_isCustomFont && needsAscentAdjustment(familyName.get()))
+ if (origin() == Origin::Local && needsAscentAdjustment(familyName.get()))
ascent += std::round((ascent + descent) * 0.15f);
#endif
Modified: trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp (216895 => 216896)
--- trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp 2017-05-16 01:37:43 UTC (rev 216896)
@@ -125,7 +125,7 @@
scaledFontDescription,
m_platformData.syntheticBold(),
m_platformData.syntheticOblique()),
- isCustomFont(), false);
+ origin(), Interstitial::No);
}
void Font::determinePitch()
Modified: trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp (216895 => 216896)
--- trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/platform/graphics/win/SimpleFontDataCGWin.cpp 2017-05-16 01:37:43 UTC (rev 216896)
@@ -83,7 +83,7 @@
float fCapHeight = scaleEmToUnits(iCapHeight, unitsPerEm) * pointSize;
float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
- if (!isCustomFont()) {
+ if (origin() == Origin::Local) {
HWndDC dc(0);
HGDIOBJ oldFont = SelectObject(dc, m_platformData.hfont());
int faceLength = GetTextFace(dc, 0, 0);
Modified: trunk/Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp (216895 => 216896)
--- trunk/Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp 2017-05-16 01:37:43 UTC (rev 216896)
@@ -134,7 +134,7 @@
float fCapHeight = scaleEmToUnits(iCapHeight, unitsPerEm) * pointSize;
float fLineGap = scaleEmToUnits(iLineGap, unitsPerEm) * pointSize;
- if (!isCustomFont()) {
+ if (origin() == Origin::Local) {
Vector<WCHAR> faceName = getFaceName(font);
fAscent = ascentConsideringMacAscentHack(faceName.data(), fAscent, fDescent);
}
Modified: trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp (216895 => 216896)
--- trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/platform/graphics/win/SimpleFontDataWin.cpp 2017-05-16 01:37:43 UTC (rev 216896)
@@ -139,19 +139,19 @@
RefPtr<Font> Font::platformCreateScaledFont(const FontDescription& fontDescription, float scaleFactor) const
{
float scaledSize = scaleFactor * m_platformData.size();
- if (isCustomFont())
- return Font::create(FontPlatformData::cloneWithSize(m_platformData, scaledSize), true, false);
+ if (origin() == Origin::Remote)
+ return Font::create(FontPlatformData::cloneWithSize(m_platformData, scaledSize), Font::Origin::Remote);
LOGFONT winfont;
GetObject(m_platformData.hfont(), sizeof(LOGFONT), &winfont);
winfont.lfHeight = -lroundf(scaledSize * (m_platformData.useGDI() ? 1 : 32));
auto hfont = adoptGDIObject(::CreateFontIndirect(&winfont));
- return Font::create(FontPlatformData(WTFMove(hfont), scaledSize, m_platformData.syntheticBold(), m_platformData.syntheticOblique(), m_platformData.useGDI()), isCustomFont(), false);
+ return Font::create(FontPlatformData(WTFMove(hfont), scaledSize, m_platformData.syntheticBold(), m_platformData.syntheticOblique(), m_platformData.useGDI()), origin());
}
void Font::determinePitch()
{
- if (isCustomFont()) {
+ if (origin() == Origin::Remote) {
m_treatAsFixedPitch = false;
return;
}
Modified: trunk/Source/WebCore/rendering/SimpleLineLayout.cpp (216895 => 216896)
--- trunk/Source/WebCore/rendering/SimpleLineLayout.cpp 2017-05-16 01:29:39 UTC (rev 216895)
+++ trunk/Source/WebCore/rendering/SimpleLineLayout.cpp 2017-05-16 01:37:43 UTC (rev 216896)
@@ -156,7 +156,7 @@
// We assume that all lines have metrics based purely on the primary font.
const auto& style = flow.style();
auto& fontCascade = style.fontCascade();
- if (fontCascade.primaryFont().isLoading())
+ if (fontCascade.primaryFont().isInterstitial())
SET_REASON_AND_RETURN_IF_NEEDED(FlowIsMissingPrimaryFont, reasons, includeReasons);
std::optional<float> lineHeightConstraint;
if (style.lineBoxContain() & LineBoxContainGlyphs)