Shrink some font-related classes and enums
authorsimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2018 17:59:29 +0000 (17:59 +0000)
committersimon.fraser@apple.com <simon.fraser@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Jul 2018 17:59:29 +0000 (17:59 +0000)
https://bugs.webkit.org/show_bug.cgi?id=187686

Reviewed by Myles Maxfield.

Use enum class for enums in TextFlags.h and make them one byte big.

Re-order members of Font to shrink it from 360 to 328 bytes.

* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator FontSmoothingMode const):
(WebCore::CSSPrimitiveValue::operator FontSmallCaps const):
(WebCore::CSSPrimitiveValue::operator TextRenderingMode const):
* platform/graphics/Font.cpp:
(WebCore::Font::Font):
(WebCore::Font::verticalRightOrientationFont const):
* platform/graphics/Font.h:
* platform/graphics/FontCascade.cpp:
(WebCore::offsetToMiddleOfGlyph):
* platform/graphics/FontCascade.h:
(WebCore::FontCascade::advancedTextRenderingMode const):
* platform/graphics/FontCascadeFonts.cpp:
(WebCore::FontCascadeFonts::glyphDataForSystemFallback):
(WebCore::FontCascadeFonts::glyphDataForVariant):
(WebCore::glyphPageFromFontRanges):
* platform/graphics/FontDescription.cpp:
(WebCore::FontCascadeDescription::FontCascadeDescription):
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::setTextRenderingMode):
(WebCore::FontDescription::setOrientation):
(WebCore::FontDescription::setWidthVariant):
(WebCore::FontCascadeDescription::setFontSmoothing):
(WebCore::FontCascadeDescription::initialSmallCaps):
(WebCore::FontCascadeDescription::initialFontSmoothing):
(WebCore::FontCascadeDescription::initialTextRenderingMode):
* platform/graphics/FontPlatformData.h:
(WebCore::FontPlatformData::isForTextCombine const):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
(WebCore::preparePlatformFont):
* platform/graphics/cocoa/FontCascadeCocoa.mm:
(WebCore::showLetterpressedGlyphsWithAdvances):
(WebCore::showGlyphsWithAdvances):
(WebCore::FontCascade::drawGlyphs):
(WebCore::FontCascade::fontForCombiningCharacterSequence const):
* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::Font::platformInit):
(WebCore::Font::platformBoundsForGlyph const):
(WebCore::Font::platformWidthForGlyph const):
* platform/graphics/cocoa/FontPlatformDataCocoa.mm:
(WebCore::FontPlatformData::hash const):
(WebCore::mapFontWidthVariantToCTFeatureSelector):
(WebCore::FontPlatformData::ctFont const):
(WebCore::FontPlatformData::description const):
* platform/graphics/freetype/FontPlatformDataFreeType.cpp:
(WebCore::FontPlatformData::buildScaledFont):
* platform/graphics/freetype/SimpleFontDataFreeType.cpp:
(WebCore::Font::platformInit):
(WebCore::Font::platformWidthForGlyph const):
* platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp:
(WebCore::fontFeatures):
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
* platform/graphics/mac/SimpleFontDataCoreText.cpp:
(WebCore::Font::getCFStringAttributes const):
* platform/graphics/win/FontCGWin.cpp:
(WebCore::FontCascade::drawGlyphs):
* platform/graphics/win/FontCascadeDirect2D.cpp:
(WebCore::FontCascade::drawGlyphs):
* platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp:
(WebCore::GlyphPage::fill):
* platform/graphics/win/SimpleFontDataDirect2D.cpp:
(WebCore::Font::platformInit):
(WebCore::Font::platformBoundsForGlyph const):
(WebCore::Font::platformWidthForGlyph const):
* platform/text/TextFlags.h:
* rendering/RenderCombineText.cpp:
(WebCore::RenderCombineText::combineTextIfNeeded):
* rendering/RenderLayer.cpp:
(WebCore::RenderLayer::calculateClipRects const):
* rendering/TextPainter.cpp:
(WebCore::TextPainter::paintTextWithShadows):
* rendering/TextPainter.h:
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::fontAndGlyphOrientation):
* rendering/svg/RenderSVGInlineText.cpp:
(WebCore::RenderSVGInlineText::computeNewScaledFontForStyle):

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

29 files changed:
Source/WebCore/ChangeLog
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/platform/graphics/Font.cpp
Source/WebCore/platform/graphics/Font.h
Source/WebCore/platform/graphics/FontCascade.cpp
Source/WebCore/platform/graphics/FontCascade.h
Source/WebCore/platform/graphics/FontCascadeFonts.cpp
Source/WebCore/platform/graphics/FontDescription.cpp
Source/WebCore/platform/graphics/FontDescription.h
Source/WebCore/platform/graphics/FontPlatformData.h
Source/WebCore/platform/graphics/cocoa/FontCacheCoreText.cpp
Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm
Source/WebCore/platform/graphics/cocoa/FontCocoa.mm
Source/WebCore/platform/graphics/cocoa/FontPlatformDataCocoa.mm
Source/WebCore/platform/graphics/freetype/FontPlatformDataFreeType.cpp
Source/WebCore/platform/graphics/freetype/SimpleFontDataFreeType.cpp
Source/WebCore/platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp
Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp
Source/WebCore/platform/graphics/win/FontCGWin.cpp
Source/WebCore/platform/graphics/win/FontCascadeDirect2D.cpp
Source/WebCore/platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp
Source/WebCore/platform/graphics/win/SimpleFontDataDirect2D.cpp
Source/WebCore/platform/text/TextFlags.h
Source/WebCore/rendering/RenderCombineText.cpp
Source/WebCore/rendering/RenderLayer.cpp
Source/WebCore/rendering/TextPainter.cpp
Source/WebCore/rendering/TextPainter.h
Source/WebCore/rendering/style/RenderStyle.cpp
Source/WebCore/rendering/svg/RenderSVGInlineText.cpp

index 2aa8259..5a3dd14 100644 (file)
@@ -1,3 +1,92 @@
+2018-07-16  Simon Fraser  <simon.fraser@apple.com>
+
+        Shrink some font-related classes and enums
+        https://bugs.webkit.org/show_bug.cgi?id=187686
+
+        Reviewed by Myles Maxfield.
+        
+        Use enum class for enums in TextFlags.h and make them one byte big.
+
+        Re-order members of Font to shrink it from 360 to 328 bytes.
+
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator FontSmoothingMode const):
+        (WebCore::CSSPrimitiveValue::operator FontSmallCaps const):
+        (WebCore::CSSPrimitiveValue::operator TextRenderingMode const):
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::Font):
+        (WebCore::Font::verticalRightOrientationFont const):
+        * platform/graphics/Font.h:
+        * platform/graphics/FontCascade.cpp:
+        (WebCore::offsetToMiddleOfGlyph):
+        * platform/graphics/FontCascade.h:
+        (WebCore::FontCascade::advancedTextRenderingMode const):
+        * platform/graphics/FontCascadeFonts.cpp:
+        (WebCore::FontCascadeFonts::glyphDataForSystemFallback):
+        (WebCore::FontCascadeFonts::glyphDataForVariant):
+        (WebCore::glyphPageFromFontRanges):
+        * platform/graphics/FontDescription.cpp:
+        (WebCore::FontCascadeDescription::FontCascadeDescription):
+        * platform/graphics/FontDescription.h:
+        (WebCore::FontDescription::setTextRenderingMode):
+        (WebCore::FontDescription::setOrientation):
+        (WebCore::FontDescription::setWidthVariant):
+        (WebCore::FontCascadeDescription::setFontSmoothing):
+        (WebCore::FontCascadeDescription::initialSmallCaps):
+        (WebCore::FontCascadeDescription::initialFontSmoothing):
+        (WebCore::FontCascadeDescription::initialTextRenderingMode):
+        * platform/graphics/FontPlatformData.h:
+        (WebCore::FontPlatformData::isForTextCombine const):
+        * platform/graphics/cocoa/FontCacheCoreText.cpp:
+        (WebCore::preparePlatformFont):
+        * platform/graphics/cocoa/FontCascadeCocoa.mm:
+        (WebCore::showLetterpressedGlyphsWithAdvances):
+        (WebCore::showGlyphsWithAdvances):
+        (WebCore::FontCascade::drawGlyphs):
+        (WebCore::FontCascade::fontForCombiningCharacterSequence const):
+        * platform/graphics/cocoa/FontCocoa.mm:
+        (WebCore::Font::platformInit):
+        (WebCore::Font::platformBoundsForGlyph const):
+        (WebCore::Font::platformWidthForGlyph const):
+        * platform/graphics/cocoa/FontPlatformDataCocoa.mm:
+        (WebCore::FontPlatformData::hash const):
+        (WebCore::mapFontWidthVariantToCTFeatureSelector):
+        (WebCore::FontPlatformData::ctFont const):
+        (WebCore::FontPlatformData::description const):
+        * platform/graphics/freetype/FontPlatformDataFreeType.cpp:
+        (WebCore::FontPlatformData::buildScaledFont):
+        * platform/graphics/freetype/SimpleFontDataFreeType.cpp:
+        (WebCore::Font::platformInit):
+        (WebCore::Font::platformWidthForGlyph const):
+        * platform/graphics/harfbuzz/ComplexTextControllerHarfBuzz.cpp:
+        (WebCore::fontFeatures):
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
+        * platform/graphics/mac/SimpleFontDataCoreText.cpp:
+        (WebCore::Font::getCFStringAttributes const):
+        * platform/graphics/win/FontCGWin.cpp:
+        (WebCore::FontCascade::drawGlyphs):
+        * platform/graphics/win/FontCascadeDirect2D.cpp:
+        (WebCore::FontCascade::drawGlyphs):
+        * platform/graphics/win/GlyphPageTreeNodeDirect2D.cpp:
+        (WebCore::GlyphPage::fill):
+        * platform/graphics/win/SimpleFontDataDirect2D.cpp:
+        (WebCore::Font::platformInit):
+        (WebCore::Font::platformBoundsForGlyph const):
+        (WebCore::Font::platformWidthForGlyph const):
+        * platform/text/TextFlags.h:
+        * rendering/RenderCombineText.cpp:
+        (WebCore::RenderCombineText::combineTextIfNeeded):
+        * rendering/RenderLayer.cpp:
+        (WebCore::RenderLayer::calculateClipRects const):
+        * rendering/TextPainter.cpp:
+        (WebCore::TextPainter::paintTextWithShadows):
+        * rendering/TextPainter.h:
+        * rendering/style/RenderStyle.cpp:
+        (WebCore::RenderStyle::fontAndGlyphOrientation):
+        * rendering/svg/RenderSVGInlineText.cpp:
+        (WebCore::RenderSVGInlineText::computeNewScaledFontForStyle):
+
 2018-07-16  Sergio Villar Senin  <svillar@igalia.com>
 
         [WebVR] Add support for connect/disconnect and mount/unmount device events
index 54b4e56..424a05b 100644 (file)
@@ -3605,16 +3605,16 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmoothingMode smoothi
 {
     m_primitiveUnitType = CSS_VALUE_ID;
     switch (smoothing) {
-    case AutoSmoothing:
+    case FontSmoothingMode::AutoSmoothing:
         m_value.valueID = CSSValueAuto;
         return;
-    case NoSmoothing:
+    case FontSmoothingMode::NoSmoothing:
         m_value.valueID = CSSValueNone;
         return;
-    case Antialiased:
+    case FontSmoothingMode::Antialiased:
         m_value.valueID = CSSValueAntialiased;
         return;
-    case SubpixelAntialiased:
+    case FontSmoothingMode::SubpixelAntialiased:
         m_value.valueID = CSSValueSubpixelAntialiased;
         return;
     }
@@ -3629,19 +3629,19 @@ template<> inline CSSPrimitiveValue::operator FontSmoothingMode() const
 
     switch (m_value.valueID) {
     case CSSValueAuto:
-        return AutoSmoothing;
+        return FontSmoothingMode::AutoSmoothing;
     case CSSValueNone:
-        return NoSmoothing;
+        return FontSmoothingMode::NoSmoothing;
     case CSSValueAntialiased:
-        return Antialiased;
+        return FontSmoothingMode::Antialiased;
     case CSSValueSubpixelAntialiased:
-        return SubpixelAntialiased;
+        return FontSmoothingMode::SubpixelAntialiased;
     default:
         break;
     }
 
     ASSERT_NOT_REACHED();
-    return AutoSmoothing;
+    return FontSmoothingMode::AutoSmoothing;
 }
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmallCaps smallCaps)
@@ -3649,10 +3649,10 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmallCaps smallCaps)
 {
     m_primitiveUnitType = CSS_VALUE_ID;
     switch (smallCaps) {
-    case FontSmallCapsOff:
+    case FontSmallCaps::Off:
         m_value.valueID = CSSValueNormal;
         return;
-    case FontSmallCapsOn:
+    case FontSmallCaps::On:
         m_value.valueID = CSSValueSmallCaps;
         return;
     }
@@ -3667,14 +3667,14 @@ template<> inline CSSPrimitiveValue::operator FontSmallCaps() const
 
     switch (m_value.valueID) {
     case CSSValueSmallCaps:
-        return FontSmallCapsOn;
+        return FontSmallCaps::On;
     case CSSValueNormal:
-        return FontSmallCapsOff;
+        return FontSmallCaps::Off;
     default:
         break;
     }
     ASSERT_NOT_REACHED();
-    return FontSmallCapsOff;
+    return FontSmallCaps::Off;
 }
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextRenderingMode e)
@@ -3682,16 +3682,16 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextRenderingMode e)
 {
     m_primitiveUnitType = CSS_VALUE_ID;
     switch (e) {
-    case AutoTextRendering:
+    case TextRenderingMode::AutoTextRendering:
         m_value.valueID = CSSValueAuto;
         break;
-    case OptimizeSpeed:
+    case TextRenderingMode::OptimizeSpeed:
         m_value.valueID = CSSValueOptimizeSpeed;
         break;
-    case OptimizeLegibility:
+    case TextRenderingMode::OptimizeLegibility:
         m_value.valueID = CSSValueOptimizeLegibility;
         break;
-    case GeometricPrecision:
+    case TextRenderingMode::GeometricPrecision:
         m_value.valueID = CSSValueGeometricPrecision;
         break;
     }
@@ -3703,19 +3703,19 @@ template<> inline CSSPrimitiveValue::operator TextRenderingMode() const
 
     switch (m_value.valueID) {
     case CSSValueAuto:
-        return AutoTextRendering;
+        return TextRenderingMode::AutoTextRendering;
     case CSSValueOptimizeSpeed:
-        return OptimizeSpeed;
+        return TextRenderingMode::OptimizeSpeed;
     case CSSValueOptimizeLegibility:
-        return OptimizeLegibility;
+        return TextRenderingMode::OptimizeLegibility;
     case CSSValueGeometricPrecision:
-        return GeometricPrecision;
+        return TextRenderingMode::GeometricPrecision;
     default:
         break;
     }
 
     ASSERT_NOT_REACHED();
-    return AutoTextRendering;
+    return TextRenderingMode::AutoTextRendering;
 }
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Hyphens hyphens)
index 52a3482..55e86ca 100644 (file)
@@ -56,10 +56,7 @@ const float smallCapsFontSizeMultiplier = 0.7f;
 const float emphasisMarkFontSizeMultiplier = 0.5f;
 
 Font::Font(const FontPlatformData& platformData, Origin origin, Interstitial interstitial, Visibility visibility, OrientationFallback orientationFallback)
-    : m_maxCharWidth(-1)
-    , m_avgCharWidth(-1)
-    , m_platformData(platformData)
-    , m_mathData(nullptr)
+    : m_platformData(platformData)
     , m_origin(origin)
     , m_visibility(visibility)
     , m_treatAsFixedPitch(false)
@@ -76,7 +73,7 @@ Font::Font(const FontPlatformData& platformData, Origin origin, Interstitial int
     platformGlyphInit();
     platformCharWidthInit();
 #if ENABLE(OPENTYPE_VERTICAL)
-    if (platformData.orientation() == Vertical && orientationFallback == OrientationFallback::No) {
+    if (platformData.orientation() == FontOrientation::Vertical && orientationFallback == OrientationFallback::No) {
         m_verticalData = FontCache::singleton().verticalData(platformData);
         m_hasVerticalGlyphs = m_verticalData.get() && m_verticalData->hasVerticalMetrics();
     }
@@ -390,7 +387,7 @@ const Font& Font::verticalRightOrientationFont() const
 {
     DerivedFonts& derivedFontData = ensureDerivedFontData();
     if (!derivedFontData.verticalRightOrientationFont) {
-        auto verticalRightPlatformData = FontPlatformData::cloneWithOrientation(m_platformData, Horizontal);
+        auto verticalRightPlatformData = FontPlatformData::cloneWithOrientation(m_platformData, FontOrientation::Horizontal);
         derivedFontData.verticalRightOrientationFont = create(verticalRightPlatformData, origin(), Interstitial::No, Visibility::Visible, OrientationFallback::Yes);
     }
     ASSERT(derivedFontData.verticalRightOrientationFont != this);
index 12a72fd..52edbae 100644 (file)
@@ -69,19 +69,19 @@ enum Pitch { UnknownPitch, FixedPitch, VariablePitch };
 class Font : public RefCounted<Font> {
 public:
     // Used to create platform fonts.
-    enum class Origin {
+    enum class Origin : uint8_t {
         Remote,
         Local
     };
-    enum class Interstitial {
+    enum class Interstitial : uint8_t {
         Yes,
         No
     };
-    enum class Visibility {
+    enum class Visibility : uint8_t {
         Visible,
         Invisible
     };
-    enum class OrientationFallback {
+    enum class OrientationFallback : uint8_t {
         Yes,
         No
     };
@@ -244,8 +244,8 @@ private:
 #endif
 
     FontMetrics m_fontMetrics;
-    float m_maxCharWidth;
-    float m_avgCharWidth;
+    float m_maxCharWidth { -1 };
+    float m_avgCharWidth { -1 };
 
     const FontPlatformData m_platformData;
 
@@ -260,13 +260,6 @@ private:
     RefPtr<OpenTypeVerticalData> m_verticalData;
 #endif
 
-    Glyph m_spaceGlyph { 0 };
-    float m_spaceWidth { 0 };
-    Glyph m_zeroGlyph { 0 };
-    float m_adjustedSpaceWidth { 0 };
-
-    Glyph m_zeroWidthSpaceGlyph { 0 };
-
     struct DerivedFonts {
 #if !COMPILER(MSVC)
         WTF_MAKE_FAST_ALLOCATED;
@@ -284,10 +277,6 @@ private:
 
     mutable std::unique_ptr<DerivedFonts> m_derivedFontData;
 
-#if USE(CG) || USE(DIRECT2D) || USE(CAIRO)
-    float m_syntheticBoldOffset;
-#endif
-
 #if PLATFORM(COCOA)
     mutable RetainPtr<CFMutableDictionaryRef> m_nonKernedCFStringAttributes;
     mutable RetainPtr<CFMutableDictionaryRef> m_kernedCFStringAttributes;
@@ -302,9 +291,20 @@ private:
     mutable SCRIPT_FONTPROPERTIES* m_scriptFontProperties;
 #endif
 
+    Glyph m_spaceGlyph { 0 };
+    Glyph m_zeroGlyph { 0 };
+    Glyph m_zeroWidthSpaceGlyph { 0 };
+
     Origin m_origin; // Whether or not we are custom font loaded via @font-face
     Visibility m_visibility; // @font-face's internal timer can cause us to show fonts even when a font is being downloaded.
 
+    float m_spaceWidth { 0 };
+    float m_adjustedSpaceWidth { 0 };
+
+#if USE(CG) || USE(DIRECT2D) || USE(CAIRO)
+    float m_syntheticBoldOffset { 0 };
+#endif
+
     unsigned m_treatAsFixedPitch : 1;
     unsigned m_isInterstitial : 1; // Whether or not this custom font is the last resort placeholder for a loading font
 
index 79c9aa6..5462209 100644 (file)
@@ -1450,7 +1450,7 @@ void FontCascade::drawGlyphBuffer(GraphicsContext& context, const GlyphBuffer& g
 
 inline static float offsetToMiddleOfGlyph(const Font* fontData, Glyph glyph)
 {
-    if (fontData->platformData().orientation() == Horizontal) {
+    if (fontData->platformData().orientation() == FontOrientation::Horizontal) {
         FloatRect bounds = fontData->boundsForGlyph(glyph);
         return bounds.x() + bounds.width() / 2;
     }
index 0059075..58c0a89 100644 (file)
@@ -103,7 +103,7 @@ public:
     WEBCORE_EXPORT FontCascade();
     WEBCORE_EXPORT FontCascade(FontCascadeDescription&&, float letterSpacing = 0, float wordSpacing = 0);
     // This constructor is only used if the platform wants to start with a native font.
-    WEBCORE_EXPORT FontCascade(const FontPlatformData&, FontSmoothingMode = AutoSmoothing);
+    WEBCORE_EXPORT FontCascade(const FontPlatformData&, FontSmoothingMode = FontSmoothingMode::AutoSmoothing);
 
     FontCascade(const FontCascade&);
     WEBCORE_EXPORT FontCascade& operator=(const FontCascade&);
@@ -275,9 +275,9 @@ private:
     bool advancedTextRenderingMode() const
     {
         auto textRenderingMode = m_fontDescription.textRenderingMode();
-        if (textRenderingMode == GeometricPrecision || textRenderingMode == OptimizeLegibility)
+        if (textRenderingMode == TextRenderingMode::GeometricPrecision || textRenderingMode == TextRenderingMode::OptimizeLegibility)
             return true;
-        if (textRenderingMode == OptimizeSpeed)
+        if (textRenderingMode == TextRenderingMode::OptimizeSpeed)
             return false;
 #if PLATFORM(COCOA) || USE(FREETYPE)
         return true;
index 5dccc19..04239bf 100644 (file)
@@ -352,7 +352,7 @@ GlyphData FontCascadeFonts::glyphDataForSystemFallback(UChar32 character, const
     if (systemFallbackShouldBeInvisible)
         systemFallbackFont = const_cast<Font*>(&systemFallbackFont->invisibleFont());
 
-    if (systemFallbackFont->platformData().orientation() == Vertical && !systemFallbackFont->hasVerticalGlyphs() && FontCascade::isCJKIdeographOrSymbol(character))
+    if (systemFallbackFont->platformData().orientation() == FontOrientation::Vertical && !systemFallbackFont->hasVerticalGlyphs() && FontCascade::isCJKIdeographOrSymbol(character))
         variant = BrokenIdeographVariant;
 
     GlyphData fallbackGlyphData;
@@ -361,7 +361,7 @@ GlyphData FontCascadeFonts::glyphDataForSystemFallback(UChar32 character, const
     else
         fallbackGlyphData = systemFallbackFont->variantFont(description, variant)->glyphDataForCharacter(character);
 
-    if (fallbackGlyphData.font && fallbackGlyphData.font->platformData().orientation() == Vertical && !fallbackGlyphData.font->isTextOrientationFallback()) {
+    if (fallbackGlyphData.font && fallbackGlyphData.font->platformData().orientation() == FontOrientation::Vertical && !fallbackGlyphData.font->isTextOrientationFallback()) {
         if (variant == NormalVariant && !FontCascade::isCJKIdeographOrSymbol(character))
             fallbackGlyphData = glyphDataForNonCJKCharacterWithGlyphOrientation(character, description.nonCJKGlyphOrientation(), fallbackGlyphData);
     }
@@ -421,7 +421,7 @@ GlyphData FontCascadeFonts::glyphDataForVariant(UChar32 character, const FontCas
             data.font = &data.font->invisibleFont();
 
         if (variant == NormalVariant) {
-            if (data.font->platformData().orientation() == Vertical && !data.font->isTextOrientationFallback()) {
+            if (data.font->platformData().orientation() == FontOrientation::Vertical && !data.font->isTextOrientationFallback()) {
                 if (!FontCascade::isCJKIdeographOrSymbol(character))
                     return glyphDataForNonCJKCharacterWithGlyphOrientation(character, description.nonCJKGlyphOrientation(), data);
 
@@ -476,7 +476,7 @@ static RefPtr<GlyphPage> glyphPageFromFontRanges(unsigned pageNumber, const Font
         }
         break;
     }
-    if (!font || font->platformData().orientation() == Vertical)
+    if (!font || font->platformData().orientation() == FontOrientation::Vertical)
         return nullptr;
 
     if (desiredVisibility == FallbackVisibility::Invisible && font->visibility() == Font::Visibility::Visible)
index 3d5dd35..130002d 100644 (file)
@@ -56,11 +56,11 @@ COMPILE_ASSERT(sizeof(FontCascadeDescription) == sizeof(SameSizeAsFontCascadeDes
 
 FontDescription::FontDescription()
     : m_fontSelectionRequest { FontCascadeDescription::initialWeight(), FontCascadeDescription::initialStretch(), FontCascadeDescription::initialItalic() }
-    , m_orientation(Horizontal)
+    , m_orientation(static_cast<unsigned>(FontOrientation::Horizontal))
     , m_nonCJKGlyphOrientation(static_cast<unsigned>(NonCJKGlyphOrientation::Mixed))
-    , m_widthVariant(RegularWidth)
+    , m_widthVariant(static_cast<unsigned>(FontWidthVariant::RegularWidth))
     , m_renderingMode(static_cast<unsigned>(FontRenderingMode::Normal))
-    , m_textRendering(AutoTextRendering)
+    , m_textRendering(static_cast<unsigned>(TextRenderingMode::AutoTextRendering))
     , m_script(USCRIPT_COMMON)
     , m_fontSynthesis(FontSynthesisWeight | FontSynthesisStyle | FontSynthesisSmallCaps)
     , m_variantCommonLigatures(static_cast<unsigned>(FontVariantLigatures::Normal))
@@ -94,7 +94,7 @@ FontCascadeDescription::FontCascadeDescription()
     : m_isAbsoluteSize(false)
     , m_kerning(static_cast<unsigned>(Kerning::Auto))
     , m_keywordSize(0)
-    , m_fontSmoothing(AutoSmoothing)
+    , m_fontSmoothing(static_cast<unsigned>(FontSmoothingMode::AutoSmoothing))
     , m_isSpecifiedFont(false)
 {
 }
index 96e286e..62befa9 100644 (file)
@@ -122,10 +122,10 @@ public:
     void setIsItalic(bool i) { setItalic(i ? italicValue() : normalItalicValue()); }
     void setWeight(FontSelectionValue weight) { m_fontSelectionRequest.weight = weight; }
     void setRenderingMode(FontRenderingMode mode) { m_renderingMode = static_cast<unsigned>(mode); }
-    void setTextRenderingMode(TextRenderingMode rendering) { m_textRendering = rendering; }
-    void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
+    void setTextRenderingMode(TextRenderingMode rendering) { m_textRendering = static_cast<unsigned>(rendering); }
+    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 = widthVariant; } // Make sure new callers of this sync with FontPlatformData::isForTextCombine()!
+    void setWidthVariant(FontWidthVariant widthVariant) { m_widthVariant = static_cast<unsigned>(widthVariant); } // Make sure new callers of this sync with FontPlatformData::isForTextCombine()!
     void setLocale(const AtomicString&);
     void setFeatureSettings(FontFeatureSettings&& settings) { m_featureSettings = WTFMove(settings); }
 #if ENABLE(VARIATION_FONTS)
@@ -282,7 +282,7 @@ public:
         static_assert(CSSValueWebkitXxxLarge - CSSValueXxSmall + 1 == 8, "Maximum keyword size should be 8.");
         setKeywordSize(identifier ? identifier - CSSValueXxSmall + 1 : 0);
     }
-    void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = smoothing; }
+    void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = static_cast<unsigned>(smoothing); }
     void setIsSpecifiedFont(bool isSpecifiedFont) { m_isSpecifiedFont = isSpecifiedFont; }
 
 #if ENABLE(TEXT_AUTOSIZING)
@@ -302,10 +302,10 @@ public:
     static FontStyleAxis initialFontStyleAxis() { return FontStyleAxis::slnt; }
     static FontSelectionValue initialWeight() { return normalWeightValue(); }
     static FontSelectionValue initialStretch() { return normalStretchValue(); }
-    static FontSmallCaps initialSmallCaps() { return FontSmallCapsOff; }
+    static FontSmallCaps initialSmallCaps() { return FontSmallCaps::Off; }
     static Kerning initialKerning() { return Kerning::Auto; }
-    static FontSmoothingMode initialFontSmoothing() { return AutoSmoothing; }
-    static TextRenderingMode initialTextRenderingMode() { return AutoTextRendering; }
+    static FontSmoothingMode initialFontSmoothing() { return FontSmoothingMode::AutoSmoothing; }
+    static TextRenderingMode initialTextRenderingMode() { return TextRenderingMode::AutoTextRendering; }
     static FontSynthesis initialFontSynthesis() { return FontSynthesisWeight | FontSynthesisStyle | FontSynthesisSmallCaps; }
     static FontVariantPosition initialVariantPosition() { return FontVariantPosition::Normal; }
     static FontVariantCaps initialVariantCaps() { return FontVariantCaps::Normal; }
index 11dd54c..ead9c3f 100644 (file)
@@ -76,10 +76,10 @@ public:
     FontPlatformData();
 
     FontPlatformData(const FontDescription&, const AtomicString& family);
-    FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, TextRenderingMode = AutoTextRendering);
+    FontPlatformData(float size, bool syntheticBold, bool syntheticOblique, FontOrientation = FontOrientation::Horizontal, FontWidthVariant = FontWidthVariant::RegularWidth, TextRenderingMode = TextRenderingMode::AutoTextRendering);
 
 #if PLATFORM(COCOA)
-    WEBCORE_EXPORT FontPlatformData(CTFontRef, float size, bool syntheticBold = false, bool syntheticOblique = false, FontOrientation = Horizontal, FontWidthVariant = RegularWidth, TextRenderingMode = AutoTextRendering);
+    WEBCORE_EXPORT FontPlatformData(CTFontRef, float size, bool syntheticBold = false, bool syntheticOblique = false, FontOrientation = FontOrientation::Horizontal, FontWidthVariant = FontWidthVariant::RegularWidth, TextRenderingMode = TextRenderingMode::AutoTextRendering);
 #endif
 
     static FontPlatformData cloneWithOrientation(const FontPlatformData&, FontOrientation);
@@ -155,7 +155,7 @@ public:
     FontOrientation orientation() const { return m_orientation; }
     FontWidthVariant widthVariant() const { return m_widthVariant; }
     TextRenderingMode textRenderingMode() const { return m_textRenderingMode; }
-    bool isForTextCombine() const { return widthVariant() != RegularWidth; } // Keep in sync with callers of FontDescription::setWidthVariant().
+    bool isForTextCombine() const { return widthVariant() != FontWidthVariant::RegularWidth; } // Keep in sync with callers of FontDescription::setWidthVariant().
 
 #if USE(CAIRO)
     cairo_scaled_font_t* scaledFont() const { return m_scaledFont.get(); }
@@ -248,9 +248,9 @@ private:
     // FIXME: If they're common to all ports, they should move to Font
     float m_size { 0 };
 
-    FontOrientation m_orientation { Horizontal };
-    FontWidthVariant m_widthVariant { RegularWidth };
-    TextRenderingMode m_textRenderingMode { AutoTextRendering };
+    FontOrientation m_orientation { FontOrientation::Horizontal };
+    FontWidthVariant m_widthVariant { FontWidthVariant::RegularWidth };
+    TextRenderingMode m_textRenderingMode { TextRenderingMode::AutoTextRendering };
 
     bool m_syntheticBold { false };
     bool m_syntheticOblique { false };
index c4f9946..ff3f87f 100644 (file)
@@ -542,7 +542,7 @@ RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescr
     const auto& variations = fontDescription.variationSettings();
     auto textRenderingMode = fontDescription.textRenderingMode();
 
-    if (!originalFont || (!features.size() && (!alwaysAddVariations && variations.isEmpty()) && (textRenderingMode == AutoTextRendering) && variantSettings.isAllNormal()
+    if (!originalFont || (!features.size() && (!alwaysAddVariations && variations.isEmpty()) && (textRenderingMode == TextRenderingMode::AutoTextRendering) && variantSettings.isAllNormal()
         && (!fontFaceFeatures || !fontFaceFeatures->size()) && (!fontFaceVariantSettings || fontFaceVariantSettings->isAllNormal())))
         return originalFont;
 
@@ -566,7 +566,7 @@ RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescr
         featuresToBeApplied.set(newFeature.key, newFeature.value);
 
     // Step 5: Other properties (text-rendering)
-    if (textRenderingMode == OptimizeSpeed) {
+    if (textRenderingMode == TextRenderingMode::OptimizeSpeed) {
         featuresToBeApplied.set(fontFeatureTag("liga"), 0);
         featuresToBeApplied.set(fontFeatureTag("clig"), 0);
         featuresToBeApplied.set(fontFeatureTag("dlig"), 0);
@@ -653,7 +653,7 @@ RetainPtr<CTFontRef> preparePlatformFont(CTFontRef originalFont, const FontDescr
     }
 #endif
 
-    if (textRenderingMode == OptimizeLegibility) {
+    if (textRenderingMode == TextRenderingMode::OptimizeLegibility) {
         CGFloat size = CTFontGetSize(originalFont);
         auto sizeNumber = adoptCF(CFNumberCreate(kCFAllocatorDefault, kCFNumberCGFloatType, &size));
         CFDictionaryAddValue(attributes.get(), kCTFontOpticalSizeAttribute, sizeNumber.get());
index 29d30e4..6342362 100644 (file)
@@ -95,7 +95,7 @@ static void showLetterpressedGlyphsWithAdvances(const FloatPoint& point, const F
         return;
 
     const FontPlatformData& platformData = font.platformData();
-    if (platformData.orientation() == Vertical) {
+    if (platformData.orientation() == FontOrientation::Vertical) {
         // FIXME: Implement support for vertical text. See <rdar://problem/13737298>.
         return;
     }
@@ -143,7 +143,7 @@ static void showGlyphsWithAdvances(const FloatPoint& point, const Font& font, CG
 
     const FontPlatformData& platformData = font.platformData();
     Vector<CGPoint, 256> positions(count);
-    if (platformData.orientation() == Vertical) {
+    if (platformData.orientation() == FontOrientation::Vertical) {
         CGAffineTransform rotateLeftTransform = CGAffineTransformMake(0, -1, 1, 0, 0, 0);
         CGAffineTransform textMatrix = CGContextGetTextMatrix(context);
         CGAffineTransform runMatrix = CGAffineTransformConcat(textMatrix, rotateLeftTransform);
@@ -194,25 +194,25 @@ void FontCascade::drawGlyphs(GraphicsContext& context, const Font& font, const G
     bool changeFontSmoothing;
     
     switch (smoothingMode) {
-    case Antialiased: {
+    case FontSmoothingMode::Antialiased: {
         context.setShouldAntialias(true);
         shouldSmoothFonts = false;
         changeFontSmoothing = true;
         break;
     }
-    case SubpixelAntialiased: {
+    case FontSmoothingMode::SubpixelAntialiased: {
         context.setShouldAntialias(true);
         shouldSmoothFonts = true;
         changeFontSmoothing = true;
         break;
     }
-    case NoSmoothing: {
+    case FontSmoothingMode::NoSmoothing: {
         context.setShouldAntialias(false);
         shouldSmoothFonts = false;
         changeFontSmoothing = true;
         break;
     }
-    case AutoSmoothing: {
+    case FontSmoothingMode::AutoSmoothing: {
         shouldSmoothFonts = true;
         changeFontSmoothing = false;
         break;
@@ -242,7 +242,7 @@ void FontCascade::drawGlyphs(GraphicsContext& context, const Font& font, const G
     matrix.d = -matrix.d;
     if (platformData.syntheticOblique()) {
         static float obliqueSkew = tanf(syntheticObliqueAngle() * piFloat / 180);
-        if (platformData.orientation() == Vertical) {
+        if (platformData.orientation() == FontOrientation::Vertical) {
             if (font.isTextOrientationFallback())
                 matrix = CGAffineTransformConcat(matrix, CGAffineTransformMake(1, obliqueSkew, 0, 1, 0, 0));
             else
@@ -515,7 +515,7 @@ const Font* FontCascade::fontForCombiningCharacterSequence(const UChar* characte
         if (baseCharacter >= 0x0600 && baseCharacter <= 0x06ff && font->shouldNotBeUsedForArabic())
             continue;
 #endif
-        if (font->platformData().orientation() == Vertical) {
+        if (font->platformData().orientation() == FontOrientation::Vertical) {
             if (isCJKIdeographOrSymbol(baseCharacter) && !font->hasVerticalGlyphs())
                 font = &font->brokenIdeographFont();
             else if (m_fontDescription.nonCJKGlyphOrientation() == NonCJKGlyphOrientation::Mixed) {
index 0938738..f379106 100644 (file)
@@ -163,7 +163,7 @@ void Font::platformInit()
     }
 #endif
     
-    if (platformData().orientation() == Vertical && !isTextOrientationFallback())
+    if (platformData().orientation() == FontOrientation::Vertical && !isTextOrientationFallback())
         m_hasVerticalGlyphs = fontHasVerticalGlyphs(m_platformData.ctFont());
 
 #if PLATFORM(IOS)
@@ -179,7 +179,7 @@ void Font::platformInit()
 
     CGFloat xHeight = 0;
     if (m_platformData.size()) {
-        if (platformData().orientation() == Horizontal) {
+        if (platformData().orientation() == FontOrientation::Horizontal) {
             // Measure the actual character "x", since it's possible for it to extend below the baseline, and we need the
             // reported x-height to only include the portion of the glyph that is above the baseline.
             Glyph xGlyph = glyphForCharacter('x');
@@ -572,7 +572,7 @@ void Font::determinePitch()
 FloatRect Font::platformBoundsForGlyph(Glyph glyph) const
 {
     FloatRect boundingBox;
-    boundingBox = CTFontGetBoundingRectsForGlyphs(m_platformData.ctFont(), platformData().orientation() == Vertical ? kCTFontOrientationVertical : kCTFontOrientationHorizontal, &glyph, 0, 1);
+    boundingBox = CTFontGetBoundingRectsForGlyphs(m_platformData.ctFont(), platformData().orientation() == FontOrientation::Vertical ? kCTFontOrientationVertical : kCTFontOrientationHorizontal, &glyph, 0, 1);
     boundingBox.setY(-boundingBox.maxY());
     if (m_syntheticBoldOffset)
         boundingBox.setWidth(boundingBox.width() + m_syntheticBoldOffset);
@@ -583,7 +583,7 @@ FloatRect Font::platformBoundsForGlyph(Glyph glyph) const
 float Font::platformWidthForGlyph(Glyph glyph) const
 {
     CGSize advance = CGSizeZero;
-    bool horizontal = platformData().orientation() == Horizontal;
+    bool horizontal = platformData().orientation() == FontOrientation::Horizontal;
     CGFontRenderingStyle style = kCGFontRenderingStyleAntialiasing | kCGFontRenderingStyleSubpixelPositioning | kCGFontRenderingStyleSubpixelQuantization | kCGFontAntialiasingStyleUnfiltered;
 
     if (platformData().size()) {
index 5594ef4..aae492f 100644 (file)
@@ -55,7 +55,13 @@ FontPlatformData::FontPlatformData(CTFontRef font, float size, bool syntheticBol
 
 unsigned FontPlatformData::hash() const
 {
-    uintptr_t flags = static_cast<uintptr_t>(m_widthVariant << 6 | m_isHashTableDeletedValue << 5 | m_textRenderingMode << 3 | m_orientation << 2 | m_syntheticBold << 1 | m_syntheticOblique);
+    uintptr_t flags = static_cast<uintptr_t>(static_cast<unsigned>(m_widthVariant) << 6
+        | m_isHashTableDeletedValue << 5
+        | static_cast<unsigned>(m_textRenderingMode) << 3
+        | static_cast<unsigned>(m_orientation) << 2
+        | m_syntheticBold << 1
+        | m_syntheticOblique);
+
     uintptr_t fontHash = reinterpret_cast<uintptr_t>(CFHash(m_font.get()));
     uintptr_t hashCodes[] = { fontHash, flags };
     return StringHasher::hashMemory<sizeof(hashCodes)>(hashCodes);
@@ -80,16 +86,16 @@ CTFontRef FontPlatformData::registeredFont() const
 inline int mapFontWidthVariantToCTFeatureSelector(FontWidthVariant variant)
 {
     switch(variant) {
-    case RegularWidth:
+    case FontWidthVariant::RegularWidth:
         return TextSpacingProportional;
 
-    case HalfWidth:
+    case FontWidthVariant::HalfWidth:
         return TextSpacingHalfWidth;
 
-    case ThirdWidth:
+    case FontWidthVariant::ThirdWidth:
         return TextSpacingThirdWidth;
 
-    case QuarterWidth:
+    case FontWidthVariant::QuarterWidth:
         return TextSpacingQuarterWidth;
     }
 
@@ -151,7 +157,7 @@ CTFontRef FontPlatformData::ctFont() const
     ASSERT(m_font);
     m_ctFont = adoptCF(CTFontCreateCopyWithAttributes(m_font.get(), m_size, 0, cascadeToLastResortAndVariationsFontDescriptor(m_font.get()).get()));
 
-    if (m_widthVariant != RegularWidth) {
+    if (m_widthVariant != FontWidthVariant::RegularWidth) {
         int featureTypeValue = kTextSpacingType;
         int featureSelectorValue = mapFontWidthVariantToCTFeatureSelector(m_widthVariant);
         RetainPtr<CTFontDescriptorRef> sourceDescriptor = adoptCF(CTFontCopyFontDescriptor(m_ctFont.get()));
@@ -195,7 +201,7 @@ String FontPlatformData::description() const
 {
     auto fontDescription = adoptCF(CFCopyDescription(font()));
     return String(fontDescription.get()) + " " + String::number(m_size)
-            + (m_syntheticBold ? " synthetic bold" : "") + (m_syntheticOblique ? " synthetic oblique" : "") + (m_orientation ? " vertical orientation" : "");
+        + (m_syntheticBold ? " synthetic bold" : "") + (m_syntheticOblique ? " synthetic oblique" : "") + (m_orientation == FontOrientation::Vertical ? " vertical orientation" : "");
 }
 #endif
 
index 19af676..1cfc5f2 100644 (file)
@@ -303,10 +303,10 @@ void FontPlatformData::buildScaledFont(cairo_font_face_t* fontFace)
         static const float syntheticObliqueSkew = -tanf(14 * acosf(0) / 90);
         static const cairo_matrix_t skew = {1, 0, syntheticObliqueSkew, 1, 0, 0};
         static const cairo_matrix_t verticalSkew = {1, -syntheticObliqueSkew, 0, 1, 0, 0};
-        cairo_matrix_multiply(&fontMatrix, m_orientation == Vertical ? &verticalSkew : &skew, &fontMatrix);
+        cairo_matrix_multiply(&fontMatrix, m_orientation == FontOrientation::Vertical ? &verticalSkew : &skew, &fontMatrix);
     }
 
-    if (m_orientation == Vertical) {
+    if (m_orientation == FontOrientation::Vertical) {
         // The resulting transformation matrix for vertical glyphs (V) is a
         // combination of rotation (R) and translation (T) applied on the
         // horizontal matrix (H). V = H . R . T, where R rotates by -90 degrees
index 48be5a8..622a3e6 100644 (file)
@@ -110,7 +110,7 @@ void Font::platformInit()
     if (!xHeight) {
         cairo_text_extents_t textExtents;
         cairo_scaled_font_text_extents(m_platformData.scaledFont(), "x", &textExtents);
-        xHeight = narrowPrecisionToFloat((platformData().orientation() == Horizontal) ? textExtents.height : textExtents.width);
+        xHeight = narrowPrecisionToFloat((platformData().orientation() == FontOrientation::Horizontal) ? textExtents.height : textExtents.width);
     }
 
     m_fontMetrics.setAscent(ascent);
@@ -122,9 +122,9 @@ void Font::platformInit()
 
     cairo_text_extents_t textExtents;
     cairo_scaled_font_text_extents(m_platformData.scaledFont(), " ", &textExtents);
-    m_spaceWidth = narrowPrecisionToFloat((platformData().orientation() == Horizontal) ? textExtents.x_advance : -textExtents.y_advance);
+    m_spaceWidth = narrowPrecisionToFloat((platformData().orientation() == FontOrientation::Horizontal) ? textExtents.x_advance : -textExtents.y_advance);
 
-    if ((platformData().orientation() == Vertical) && !isTextOrientationFallback()) {
+    if ((platformData().orientation() == FontOrientation::Vertical) && !isTextOrientationFallback()) {
         CairoFtFaceLocker cairoFtFaceLocker(m_platformData.scaledFont());
         FT_Face freeTypeFace = cairoFtFaceLocker.ftFace();
         m_fontMetrics.setUnitsPerEm(freeTypeFace->units_per_EM);
@@ -183,7 +183,7 @@ float Font::platformWidthForGlyph(Glyph glyph) const
     cairo_glyph_t cairoGlyph = { glyph, 0, 0 };
     cairo_text_extents_t extents;
     cairo_scaled_font_glyph_extents(m_platformData.scaledFont(), &cairoGlyph, 1, &extents);
-    float width = platformData().orientation() == Horizontal ? extents.x_advance : -extents.y_advance;
+    float width = platformData().orientation() == FontOrientation::Horizontal ? extents.x_advance : -extents.y_advance;
     return width ? width : m_spaceWidth;
 }
 
index 37f66b6..c9c1f71 100644 (file)
@@ -89,7 +89,7 @@ static Vector<hb_feature_t, 4> fontFeatures(const FontCascade& font, FontOrienta
 {
     Vector<hb_feature_t, 4> features;
 
-    if (orientation == Vertical) {
+    if (orientation == FontOrientation::Vertical) {
         features.append({ HarfBuzzFace::vertTag, 1, 0, hbEnd });
         features.append({ HarfBuzzFace::vrt2Tag, 1, 0, hbEnd });
     }
@@ -208,7 +208,7 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cha
         hb_buffer_add_utf16(buffer.get(), reinterpret_cast<const uint16_t*>(characters), length, run.startIndex, run.endIndex - run.startIndex);
 
         auto& face = fontPlatformData.harfBuzzFace();
-        if (fontPlatformData.orientation() == Vertical)
+        if (fontPlatformData.orientation() == FontOrientation::Vertical)
             face.setScriptForVerticalGlyphSubstitution(buffer.get());
 
         HbUniquePtr<hb_font_t> harfBuzzFont(face.createFont());
index 796c951..3358490 100644 (file)
@@ -47,7 +47,7 @@ CFDictionaryRef Font::getCFStringAttributes(bool enableKerning, FontOrientation
         CFDictionarySetValue(attributesDictionary.get(), kCTKernAttributeName, zeroKerningValue);
     }
 
-    if (orientation == Vertical)
+    if (orientation == FontOrientation::Vertical)
         CFDictionarySetValue(attributesDictionary.get(), kCTVerticalFormsAttributeName, kCFBooleanTrue);
 
     return attributesDictionary.get();
index 7af943a..d70e6e4 100644 (file)
@@ -133,22 +133,22 @@ void FontCascade::drawGlyphs(GraphicsContext& graphicsContext, const Font& font,
     bool shouldUseFontSmoothing = WebCoreShouldUseFontSmoothing();
 
     switch (smoothingMode) {
-    case Antialiased: {
+    case FontSmoothingMode::Antialiased: {
         graphicsContext.setShouldAntialias(true);
         shouldUseFontSmoothing = false;
         break;
     }
-    case SubpixelAntialiased: {
+    case FontSmoothingMode::SubpixelAntialiased: {
         graphicsContext.setShouldAntialias(true);
         shouldUseFontSmoothing = true;
         break;
     }
-    case NoSmoothing: {
+    case FontSmoothingMode::NoSmoothing: {
         graphicsContext.setShouldAntialias(false);
         shouldUseFontSmoothing = false;
         break;
     }
-    case AutoSmoothing: {
+    case FontSmoothingMode::AutoSmoothing: {
         // For the AutoSmooth case, don't do anything! Keep the default settings.
         break; 
     }
index bd54cba..d18addf 100644 (file)
@@ -51,19 +51,19 @@ void FontCascade::drawGlyphs(GraphicsContext& graphicsContext, const Font& font,
     bool shouldUseFontSmoothing = WebCoreShouldUseFontSmoothing();
 
     switch (smoothingMode) {
-    case Antialiased:
+    case FontSmoothingMode::Antialiased:
         graphicsContext.setShouldAntialias(true);
         shouldUseFontSmoothing = false;
         break;
-    case SubpixelAntialiased:
+    case FontSmoothingMode::SubpixelAntialiased:
         graphicsContext.setShouldAntialias(true);
         shouldUseFontSmoothing = true;
         break;
-    case NoSmoothing:
+    case FontSmoothingMode::NoSmoothing:
         graphicsContext.setShouldAntialias(false);
         shouldUseFontSmoothing = false;
         break;
-    case AutoSmoothing:
+    case FontSmoothingMode::AutoSmoothing:
         // For the AutoSmooth case, don't do anything! Keep the default settings.
         break;
     default:
@@ -111,7 +111,7 @@ void FontCascade::drawGlyphs(GraphicsContext& graphicsContext, const Font& font,
     glyphRun.glyphIndices = glyphBuffer.glyphs(from);
     glyphRun.glyphAdvances = horizontalAdvances.data();
     glyphRun.glyphOffsets = nullptr;
-    glyphRun.isSideways = platformData.orientation() == Vertical;
+    glyphRun.isSideways = platformData.orientation() == FontOrientation::Vertical;
     glyphRun.bidiLevel = 0;
 
     FloatSize shadowOffset;
index 949a56e..4d63cae 100644 (file)
@@ -64,7 +64,7 @@ bool GlyphPage::fill(UChar* buffer, unsigned bufferLength)
     Vector<DWRITE_SHAPING_TEXT_PROPERTIES> textProperties(GlyphPage::size);
     Vector<DWRITE_SHAPING_GLYPH_PROPERTIES> glyphProperties(GlyphPage::size);
 
-    hr = analyzer->GetGlyphs(buffer, bufferLength, fontPlatformData.dwFontFace(), fontPlatformData.orientation() == Vertical, false,
+    hr = analyzer->GetGlyphs(buffer, bufferLength, fontPlatformData.dwFontFace(), fontPlatformData.orientation() == FontOrientation::Vertical, false,
         &helper.m_analysis, nullptr, nullptr, nullptr, nullptr, 0, GlyphPage::size, clusterMap, textProperties.data(),
         localGlyphBuffer, glyphProperties.data(), &returnedCount);
     if (!SUCCEEDED(hr))
index 93af571..b1b390a 100644 (file)
@@ -151,7 +151,7 @@ void Font::platformInit()
         // Measure the actual character "x", since it's possible for it to extend below the baseline, and we need the
         // reported x-height to only include the portion of the glyph that is above the baseline.
         Vector<DWRITE_GLYPH_METRICS> glyphMetrics(1);
-        HRESULT hr = fontFace->GetDesignGlyphMetrics(&xGlyph, 1, glyphMetrics.data(), m_platformData.orientation() == Vertical);
+        HRESULT hr = fontFace->GetDesignGlyphMetrics(&xGlyph, 1, glyphMetrics.data(), m_platformData.orientation() == FontOrientation::Vertical);
         RELEASE_ASSERT(SUCCEEDED(hr));
         m_fontMetrics.setXHeight(scaleEmToUnits(glyphMetrics.first().verticalOriginY, unitsPerEm) * pointSize);
     } else {
@@ -177,10 +177,10 @@ FloatRect Font::platformBoundsForGlyph(Glyph glyph) const
     RELEASE_ASSERT(fontFace);
 
     float pointSize = m_platformData.size();
-    bool vertical = m_platformData.orientation() == Vertical;
+    bool vertical = m_platformData.orientation() == FontOrientation::Vertical;
 
     Vector<DWRITE_GLYPH_METRICS> glyphMetrics(1);
-    HRESULT hr = fontFace->GetDesignGlyphMetrics(&glyph, 1, glyphMetrics.data(), m_platformData.orientation() == Vertical);
+    HRESULT hr = fontFace->GetDesignGlyphMetrics(&glyph, 1, glyphMetrics.data(), m_platformData.orientation() == FontOrientation::Vertical);
     RELEASE_ASSERT(SUCCEEDED(hr));
 
     const auto& metrics = glyphMetrics.first();
@@ -214,7 +214,7 @@ float Font::platformWidthForGlyph(Glyph glyph) const
     auto fontFace = m_platformData.dwFontFace();
     RELEASE_ASSERT(fontFace);
 
-    bool isVertical = m_platformData.orientation() == Vertical;
+    bool isVertical = m_platformData.orientation() == FontOrientation::Vertical;
 
     Vector<DWRITE_GLYPH_METRICS> glyphMetrics(1);
     HRESULT hr = fontFace->GetDesignGlyphMetrics(&glyph, 1, glyphMetrics.data(), isVertical);
index c48574b..f8cb3bd 100644 (file)
 
 namespace WebCore {
 
-enum TextRenderingMode { AutoTextRendering, OptimizeSpeed, OptimizeLegibility, GeometricPrecision };
+enum class TextRenderingMode : uint8_t {
+    AutoTextRendering,
+    OptimizeSpeed,
+    OptimizeLegibility,
+    GeometricPrecision
+};
 
-enum FontSmoothingMode { AutoSmoothing, NoSmoothing, Antialiased, SubpixelAntialiased };
+enum class FontSmoothingMode : uint8_t {
+    AutoSmoothing,
+    NoSmoothing,
+    Antialiased,
+    SubpixelAntialiased
+};
 
 // This setting is used to provide ways of switching between multiple rendering modes that may have different
 // metrics. It is used to switch between CG and GDI text on Windows.
-enum class FontRenderingMode { Normal, Alternate };
+enum class FontRenderingMode : uint8_t {
+    Normal,
+    Alternate
+};
 
-enum FontOrientation { Horizontal, Vertical };
+enum class FontOrientation : uint8_t {
+    Horizontal,
+    Vertical
+};
 
-enum class NonCJKGlyphOrientation { Mixed, Upright };
+enum class NonCJKGlyphOrientation : uint8_t {
+    Mixed,
+    Upright
+};
 
 // Here, "Leading" and "Trailing" are relevant after the line has been rearranged for bidi.
 // ("Leading" means "left" and "Trailing" means "right.")
@@ -329,7 +348,7 @@ struct FontVariantEastAsianValues {
     FontVariantEastAsianRuby ruby;
 };
 
-enum FontWidthVariant {
+enum class FontWidthVariant : uint8_t {
     RegularWidth,
     HalfWidth,
     ThirdWidth,
@@ -339,11 +358,11 @@ enum FontWidthVariant {
 
 const unsigned FontWidthVariantWidth = 2;
 
-COMPILE_ASSERT(!(LastFontWidthVariant >> FontWidthVariantWidth), FontWidthVariantWidth_is_correct);
+COMPILE_ASSERT(!(static_cast<unsigned>(FontWidthVariant::LastFontWidthVariant) >> FontWidthVariantWidth), FontWidthVariantWidth_is_correct);
 
-enum FontSmallCaps {
-    FontSmallCapsOff = 0,
-    FontSmallCapsOn = 1
+enum class FontSmallCaps : uint8_t {
+    Off = 0,
+    On = 1
 };
 
 enum class Kerning : uint8_t {
index d616329..cc86c3d 100644 (file)
@@ -122,7 +122,7 @@ void RenderCombineText::combineTextIfNeeded()
 
     FontSelector* fontSelector = style().fontCascade().fontSelector();
 
-    description.setOrientation(Horizontal); // We are going to draw combined text horizontally.
+    description.setOrientation(FontOrientation::Horizontal); // We are going to draw combined text horizontally.
 
     FontCascade horizontalFont(FontCascadeDescription { description }, style().fontCascade().letterSpacing(), style().fontCascade().wordSpacing());
     horizontalFont.update(fontSelector);
@@ -140,7 +140,7 @@ void RenderCombineText::combineTextIfNeeded()
         shouldUpdateFont = m_combineFontStyle->setFontDescription(WTFMove(description)); // Need to change font orientation to horizontal.
     else {
         // Need to try compressed glyphs.
-        static const FontWidthVariant widthVariants[] = { HalfWidth, ThirdWidth, QuarterWidth };
+        static const FontWidthVariant widthVariants[] = { FontWidthVariant::HalfWidth, FontWidthVariant::ThirdWidth, FontWidthVariant::QuarterWidth };
         for (auto widthVariant : widthVariants) {
             description.setWidthVariant(widthVariant); // When modifying this, make sure to keep it in sync with FontPlatformData::isForTextCombine()!
 
index f4fd4ef..cf1b457 100644 (file)
@@ -6405,7 +6405,7 @@ static bool hasVisibleBoxDecorationsOrBackground(const RenderElement& renderer)
 static bool styleHasSmoothingTextMode(const RenderStyle& style)
 {
     FontSmoothingMode smoothingMode = style.fontDescription().fontSmoothing();
-    return smoothingMode == AutoSmoothing || smoothingMode == SubpixelAntialiased;
+    return smoothingMode == FontSmoothingMode::AutoSmoothing || smoothingMode == FontSmoothingMode::SubpixelAntialiased;
 }
 
 // Constrain the depth and breadth of the search for performance.
index 25ff5d1..7c3aa52 100644 (file)
@@ -46,8 +46,8 @@ ShadowApplier::ShadowApplier(GraphicsContext& context, const ShadowData* shadow,
         return;
     }
 
-    int shadowX = orientation == Horizontal ? shadow->x() : shadow->y();
-    int shadowY = orientation == Horizontal ? shadow->y() : -shadow->x();
+    int shadowX = orientation == FontOrientation::Horizontal ? shadow->x() : shadow->y();
+    int shadowY = orientation == FontOrientation::Horizontal ? shadow->y() : -shadow->x();
     FloatSize shadowOffset(shadowX, shadowY);
     int shadowRadius = shadow->radius();
     Color shadowColor = shadow->color();
@@ -130,7 +130,7 @@ void TextPainter::paintTextWithShadows(const ShadowData* shadow, const FilterOpe
     if (!opaque)
         m_context.setFillColor(Color::black);
     while (shadow) {
-        ShadowApplier shadowApplier(m_context, shadow, colorFilter, boxRect, lastShadowIterationShouldDrawText, opaque, m_textBoxIsHorizontal ? Horizontal : Vertical);
+        ShadowApplier shadowApplier(m_context, shadow, colorFilter, boxRect, lastShadowIterationShouldDrawText, opaque, m_textBoxIsHorizontal ? FontOrientation::Horizontal : FontOrientation::Vertical);
         if (!shadowApplier.nothingToDraw())
             paintTextOrEmphasisMarks(font, textRun, emphasisMark, emphasisMarkOffset, textOrigin + shadowApplier.extraOffset(), startOffset, endOffset);
         shadow = shadow->next();
index c2bfda1..1797f16 100644 (file)
@@ -104,7 +104,7 @@ inline void TextPainter::setEmphasisMark(const AtomicString& mark, float offset,
 
 class ShadowApplier {
 public:
-    ShadowApplier(GraphicsContext&, const ShadowData*, const FilterOperations* colorFilter, const FloatRect& textRect, bool lastShadowIterationShouldDrawText = true, bool opaque = false, FontOrientation = Horizontal);
+    ShadowApplier(GraphicsContext&, const ShadowData*, const FilterOperations* colorFilter, const FloatRect& textRect, bool lastShadowIterationShouldDrawText = true, bool opaque = false, FontOrientation = FontOrientation::Horizontal);
     FloatSize extraOffset() const { return m_extraOffset; }
     bool nothingToDraw() const { return m_nothingToDraw; }
     bool didSaveContext() const { return m_didSaveContext; }
index ff43e3b..6623c15 100644 (file)
@@ -2015,18 +2015,18 @@ std::pair<FontOrientation, NonCJKGlyphOrientation> RenderStyle::fontAndGlyphOrie
     // FIXME: TextOrientationSideways should map to sideways-left in vertical-lr, which is not supported yet.
 
     if (isHorizontalWritingMode())
-        return { Horizontal, NonCJKGlyphOrientation::Mixed };
+        return { FontOrientation::Horizontal, NonCJKGlyphOrientation::Mixed };
 
     switch (textOrientation()) {
     case TextOrientation::Mixed:
-        return { Vertical, NonCJKGlyphOrientation::Mixed };
+        return { FontOrientation::Vertical, NonCJKGlyphOrientation::Mixed };
     case TextOrientation::Upright:
-        return { Vertical, NonCJKGlyphOrientation::Upright };
+        return { FontOrientation::Vertical, NonCJKGlyphOrientation::Upright };
     case TextOrientation::Sideways:
-        return { Horizontal, NonCJKGlyphOrientation::Mixed };
+        return { FontOrientation::Horizontal, NonCJKGlyphOrientation::Mixed };
     default:
         ASSERT_NOT_REACHED();
-        return { Horizontal, NonCJKGlyphOrientation::Mixed };
+        return { FontOrientation::Horizontal, NonCJKGlyphOrientation::Mixed };
     }
 }
 
index d72936b..8e8645e 100644 (file)
@@ -231,7 +231,7 @@ void RenderSVGInlineText::computeNewScaledFontForStyle(const RenderObject& rende
 {
     // Alter font-size to the right on-screen value to avoid scaling the glyphs themselves, except when GeometricPrecision is specified
     scalingFactor = SVGRenderingContext::calculateScreenFontSizeScalingFactor(renderer);
-    if (!scalingFactor || style.fontDescription().textRenderingMode() == GeometricPrecision) {
+    if (!scalingFactor || style.fontDescription().textRenderingMode() == TextRenderingMode::GeometricPrecision) {
         scalingFactor = 1;
         scaledFont = style.fontCascade();
         return;