Split TypesettingFeatures into kerning and ligatures bools
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Oct 2015 23:40:38 +0000 (23:40 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 13 Oct 2015 23:40:38 +0000 (23:40 +0000)
https://bugs.webkit.org/show_bug.cgi?id=150074

Reviewed by Simon Fraser.

Source/WebCore:

Our TypesettingFeatures type represents whether kerning or ligatures are enabled
when laying out text. However, now that I have implemented font-feature-settings
and font-variant-*, this type is wildly inadequate. There are now multiple kinds
of ligatures, and many other features which are neither kerning nor ligatures.
Adding tons of information to this type doesn't make sense because 1) We already
have a FontVariantSettings struct which contains this information, and 2) None
of the users of TypesettingFeatures care about most of these new features.

In this new world of font features, the font-kerning property isn't changing.
Therefore, all the code which relies only on the Kerning value in
TypesettingFeatures doesn't need to change. The places which rely on Ligatures,
however, need to be updated to understand that there are many different kinds
of ligatures.

Indeed, after inspection, all of the places which inspect ligatures are more
interested in a high-level concept of whether or not we can trust some simple
computation. Therefore, we really have two things we care about: Kerning, and
this high-level concept.

This patch is the second step to update our view of the world to include
font-feature-settings and font-variant-*. In particular, this patch simply
splits TypesettingFeatures into two Booleans, one for Kerning, and one for
Ligatures (which has no behavior change). Then, once they are separated, I can
migrate the Ligatures Boolean to take on its new meaning.

This change is purely mechanical.

No new tests because there is no behavior change.

* WebCore.xcodeproj/project.pbxproj:
* css/CSSPrimitiveValueMappings.h:
(WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
(WebCore::CSSPrimitiveValue::operator FontCascadeDescription::Kerning):
* platform/graphics/Font.cpp:
(WebCore::Font::applyTransforms):
* platform/graphics/Font.h:
* platform/graphics/FontCascade.cpp:
(WebCore::FontCascade::FontCascade):
(WebCore::FontCascade::operator=):
(WebCore::FontCascade::update):
(WebCore::FontCascade::drawText):
(WebCore::FontCascade::drawEmphasisMarks):
(WebCore::FontCascade::width):
(WebCore::FontCascade::adjustSelectionRectForText):
(WebCore::FontCascade::offsetForPosition):
(WebCore::FontCascade::setDefaultKerning):
(WebCore::FontCascade::setDefaultLigatures):
(WebCore::FontCascade::codePath):
(WebCore::FontCascade::floatWidthForSimpleText):
(WebCore::FontCascade::setDefaultTypesettingFeatures): Deleted.
(WebCore::FontCascade::defaultTypesettingFeatures): Deleted.
* platform/graphics/FontCascade.h:
(WebCore::FontCascade::enableKerning):
(WebCore::FontCascade::enableLigatures):
(WebCore::FontCascade::computeEnableKerning):
(WebCore::FontCascade::computeEnableLigatures):
(WebCore::FontCascade::typesettingFeatures): Deleted.
(WebCore::FontCascade::computeTypesettingFeatures): Deleted.
* platform/graphics/FontDescription.cpp:
(WebCore::FontCascadeDescription::FontCascadeDescription):
* platform/graphics/FontDescription.h:
(WebCore::FontCascadeDescription::setKerning):
(WebCore::FontCascadeDescription::initialKerning):
* platform/graphics/TypesettingFeatures.h: Removed.
* platform/graphics/WidthIterator.cpp:
(WebCore::WidthIterator::WidthIterator):
(WebCore::WidthIterator::applyFontTransforms):
(WebCore::WidthIterator::advanceInternal):
* platform/graphics/WidthIterator.h:
* platform/graphics/cocoa/FontCocoa.mm:
(WebCore::Font::canRenderCombiningCharacterSequence):
* platform/graphics/mac/ComplexTextControllerCoreText.mm:
(WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
* platform/graphics/mac/SimpleFontDataCoreText.cpp:
(WebCore::Font::getCFStringAttributes):
* rendering/RenderBlockLineLayout.cpp:
(WebCore::setLogicalWidthForTextRun):
* rendering/line/BreakingContext.h:
(WebCore::WordTrailingSpace::width):
* svg/SVGFontData.h:

Source/WebKit/mac:

* WebView/WebView.mm:
(+[WebView initialize]):

Source/WebKit2:

* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::WebProcessCreationParameters):
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:
* UIProcess/Cocoa/WebProcessPoolCocoa.mm:
(WebKit::WebProcessPool::platformInitializeWebProcess):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::platformInitializeWebProcess):

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

27 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
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/FontDescription.cpp
Source/WebCore/platform/graphics/FontDescription.h
Source/WebCore/platform/graphics/TypesettingFeatures.h [deleted file]
Source/WebCore/platform/graphics/WidthIterator.cpp
Source/WebCore/platform/graphics/WidthIterator.h
Source/WebCore/platform/graphics/cocoa/FontCocoa.mm
Source/WebCore/platform/graphics/harfbuzz/HarfBuzzShaper.cpp
Source/WebCore/platform/graphics/mac/ComplexTextControllerCoreText.mm
Source/WebCore/platform/graphics/mac/SimpleFontDataCoreText.cpp
Source/WebCore/platform/text/TextFlags.h
Source/WebCore/rendering/RenderBlockLineLayout.cpp
Source/WebCore/rendering/line/BreakingContext.h
Source/WebCore/svg/SVGFontData.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebView.mm
Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/UIProcess/Cocoa/WebProcessPoolCocoa.mm
Source/WebKit2/WebProcess/cocoa/WebProcessCocoa.mm

index b34ffb7..6223ce5 100644 (file)
@@ -1,3 +1,91 @@
+2015-10-13  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Split TypesettingFeatures into kerning and ligatures bools
+        https://bugs.webkit.org/show_bug.cgi?id=150074
+
+        Reviewed by Simon Fraser.
+
+        Our TypesettingFeatures type represents whether kerning or ligatures are enabled
+        when laying out text. However, now that I have implemented font-feature-settings
+        and font-variant-*, this type is wildly inadequate. There are now multiple kinds
+        of ligatures, and many other features which are neither kerning nor ligatures.
+        Adding tons of information to this type doesn't make sense because 1) We already
+        have a FontVariantSettings struct which contains this information, and 2) None
+        of the users of TypesettingFeatures care about most of these new features.
+
+        In this new world of font features, the font-kerning property isn't changing.
+        Therefore, all the code which relies only on the Kerning value in
+        TypesettingFeatures doesn't need to change. The places which rely on Ligatures,
+        however, need to be updated to understand that there are many different kinds
+        of ligatures.
+
+        Indeed, after inspection, all of the places which inspect ligatures are more
+        interested in a high-level concept of whether or not we can trust some simple
+        computation. Therefore, we really have two things we care about: Kerning, and
+        this high-level concept.
+
+        This patch is the second step to update our view of the world to include
+        font-feature-settings and font-variant-*. In particular, this patch simply
+        splits TypesettingFeatures into two Booleans, one for Kerning, and one for
+        Ligatures (which has no behavior change). Then, once they are separated, I can
+        migrate the Ligatures Boolean to take on its new meaning.
+
+        This change is purely mechanical.
+
+        No new tests because there is no behavior change.
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSPrimitiveValueMappings.h:
+        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue):
+        (WebCore::CSSPrimitiveValue::operator FontCascadeDescription::Kerning):
+        * platform/graphics/Font.cpp:
+        (WebCore::Font::applyTransforms):
+        * platform/graphics/Font.h:
+        * platform/graphics/FontCascade.cpp:
+        (WebCore::FontCascade::FontCascade):
+        (WebCore::FontCascade::operator=):
+        (WebCore::FontCascade::update):
+        (WebCore::FontCascade::drawText):
+        (WebCore::FontCascade::drawEmphasisMarks):
+        (WebCore::FontCascade::width):
+        (WebCore::FontCascade::adjustSelectionRectForText):
+        (WebCore::FontCascade::offsetForPosition):
+        (WebCore::FontCascade::setDefaultKerning):
+        (WebCore::FontCascade::setDefaultLigatures):
+        (WebCore::FontCascade::codePath):
+        (WebCore::FontCascade::floatWidthForSimpleText):
+        (WebCore::FontCascade::setDefaultTypesettingFeatures): Deleted.
+        (WebCore::FontCascade::defaultTypesettingFeatures): Deleted.
+        * platform/graphics/FontCascade.h:
+        (WebCore::FontCascade::enableKerning):
+        (WebCore::FontCascade::enableLigatures):
+        (WebCore::FontCascade::computeEnableKerning):
+        (WebCore::FontCascade::computeEnableLigatures):
+        (WebCore::FontCascade::typesettingFeatures): Deleted.
+        (WebCore::FontCascade::computeTypesettingFeatures): Deleted.
+        * platform/graphics/FontDescription.cpp:
+        (WebCore::FontCascadeDescription::FontCascadeDescription):
+        * platform/graphics/FontDescription.h:
+        (WebCore::FontCascadeDescription::setKerning):
+        (WebCore::FontCascadeDescription::initialKerning):
+        * platform/graphics/TypesettingFeatures.h: Removed.
+        * platform/graphics/WidthIterator.cpp:
+        (WebCore::WidthIterator::WidthIterator):
+        (WebCore::WidthIterator::applyFontTransforms):
+        (WebCore::WidthIterator::advanceInternal):
+        * platform/graphics/WidthIterator.h:
+        * platform/graphics/cocoa/FontCocoa.mm:
+        (WebCore::Font::canRenderCombiningCharacterSequence):
+        * platform/graphics/mac/ComplexTextControllerCoreText.mm:
+        (WebCore::ComplexTextController::collectComplexTextRunsForCharacters):
+        * platform/graphics/mac/SimpleFontDataCoreText.cpp:
+        (WebCore::Font::getCFStringAttributes):
+        * rendering/RenderBlockLineLayout.cpp:
+        (WebCore::setLogicalWidthForTextRun):
+        * rendering/line/BreakingContext.h:
+        (WebCore::WordTrailingSpace::width):
+        * svg/SVGFontData.h:
+
 2015-10-13  Zalan Bujtas  <zalan@apple.com>
 
         Anonymous table objects: inline parent box requires inline-table child.
index 9dcbaec..0277fb8 100644 (file)
                37C236101097EE7700EF9F72 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37C2360E1097EE7700EF9F72 /* ComplexTextController.cpp */; };
                37C236111097EE7700EF9F72 /* ComplexTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C2360F1097EE7700EF9F72 /* ComplexTextController.h */; };
                37C238221098C84200EF9F72 /* ComplexTextControllerCoreText.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.mm */; };
-               37C28A6810F659CC008C7813 /* TypesettingFeatures.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C28A6710F659CC008C7813 /* TypesettingFeatures.h */; settings = {ATTRIBUTES = (Private, ); }; };
                37C61F0112095C87007A3C67 /* AtomicStringKeyedMRUCache.h in Headers */ = {isa = PBXBuildFile; fileRef = 37C61F0012095C87007A3C67 /* AtomicStringKeyedMRUCache.h */; };
                37D456FD1A9A50D8003330A1 /* LocalizableStrings.pm in Copy Scripts */ = {isa = PBXBuildFile; fileRef = 37D456FB1A9A50B6003330A1 /* LocalizableStrings.pm */; };
                37DDCD9413844FD50008B793 /* MIMEHeader.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 37DDCD9213844FD50008B793 /* MIMEHeader.cpp */; };
                37C2360E1097EE7700EF9F72 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = "<group>"; };
                37C2360F1097EE7700EF9F72 /* ComplexTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComplexTextController.h; sourceTree = "<group>"; };
                37C238201098C84200EF9F72 /* ComplexTextControllerCoreText.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ComplexTextControllerCoreText.mm; sourceTree = "<group>"; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; };
-               37C28A6710F659CC008C7813 /* TypesettingFeatures.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TypesettingFeatures.h; sourceTree = "<group>"; };
                37C61F0012095C87007A3C67 /* AtomicStringKeyedMRUCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AtomicStringKeyedMRUCache.h; sourceTree = "<group>"; };
                37D456FB1A9A50B6003330A1 /* LocalizableStrings.pm */ = {isa = PBXFileReference; lastKnownFileType = text.script.perl; path = LocalizableStrings.pm; sourceTree = "<group>"; };
                37DDCD9213844FD50008B793 /* MIMEHeader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MIMEHeader.cpp; sourceTree = "<group>"; };
                                CDD1E525167BA56400CE820B /* TextTrackRepresentation.h */,
                                1AF89A411518FDEA00E547B5 /* TiledBacking.h */,
                                BE913D7F181EF8E500DCB09E /* TrackPrivateBase.h */,
-                               37C28A6710F659CC008C7813 /* TypesettingFeatures.h */,
                                E4AFCFA40DAF29A300F5F55C /* UnitBezier.h */,
                                BEF29EEA1715DD0900C4B4C9 /* VideoTrackPrivate.h */,
                                1411DCB0164C39A800D49BC1 /* WidthCache.h */,
                                2D232C001A326F02006BF2DB /* TUCallSPI.h in Headers */,
                                C375D7FE16639519006184AB /* TypeAhead.h in Headers */,
                                E46A2B1C17CA65B9000DBCD8 /* TypedElementDescendantIterator.h in Headers */,
-                               37C28A6810F659CC008C7813 /* TypesettingFeatures.h in Headers */,
                                93309E1A099E64920056E581 /* TypingCommand.h in Headers */,
                                31DF63591AF194F00078FD91 /* UIColorSPI.h in Headers */,
                                85031B4E0A44EFC700F992E0 /* UIEvent.h in Headers */,
index ee2f0d8..14fb90d 100644 (file)
@@ -3438,18 +3438,18 @@ template<> inline CSSPrimitiveValue::operator EPointerEvents() const
     return PE_ALL;
 }
 
-template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontCascadeDescription::Kerning kerning)
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(Kerning kerning)
     : CSSValue(PrimitiveClass)
 {
     m_primitiveUnitType = CSS_VALUE_ID;
     switch (kerning) {
-    case FontCascadeDescription::AutoKerning:
+    case Kerning::Auto:
         m_value.valueID = CSSValueAuto;
         return;
-    case FontCascadeDescription::NormalKerning:
+    case Kerning::Normal:
         m_value.valueID = CSSValueNormal;
         return;
-    case FontCascadeDescription::NoneKerning:
+    case Kerning::NoShift:
         m_value.valueID = CSSValueNone;
         return;
     }
@@ -3458,23 +3458,23 @@ template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontCascadeDescription::K
     m_value.valueID = CSSValueAuto;
 }
 
-template<> inline CSSPrimitiveValue::operator FontCascadeDescription::Kerning() const
+template<> inline CSSPrimitiveValue::operator Kerning() const
 {
     ASSERT(isValueID());
 
     switch (m_value.valueID) {
     case CSSValueAuto:
-        return FontCascadeDescription::AutoKerning;
+        return Kerning::Auto;
     case CSSValueNormal:
-        return FontCascadeDescription::NormalKerning;
+        return Kerning::Normal;
     case CSSValueNone:
-        return FontCascadeDescription::NoneKerning;
+        return Kerning::NoShift;
     default:
         break;
     }
 
     ASSERT_NOT_REACHED();
-    return FontCascadeDescription::AutoKerning;
+    return Kerning::Auto;
 }
 
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(ObjectFit fit)
index bf726a0..8eccee6 100644 (file)
@@ -371,18 +371,19 @@ PassRefPtr<Font> Font::createScaledFont(const FontDescription& fontDescription,
     return platformCreateScaledFont(fontDescription, scaleFactor);
 }
 
-bool Font::applyTransforms(GlyphBufferGlyph* glyphs, GlyphBufferAdvance* advances, size_t glyphCount, TypesettingFeatures typesettingFeatures) const
+bool Font::applyTransforms(GlyphBufferGlyph* glyphs, GlyphBufferAdvance* advances, size_t glyphCount, bool enableKerning, bool enableLigatures) const
 {
     // We need to handle transforms on SVG fonts internally, since they are rendered internally.
     ASSERT(!isSVGFont());
 #if PLATFORM(COCOA)
-    CTFontTransformOptions options = (typesettingFeatures & Kerning ? kCTFontTransformApplyPositioning : 0) | (typesettingFeatures & Ligatures ? kCTFontTransformApplyShaping : 0);
+    CTFontTransformOptions options = (enableKerning ? kCTFontTransformApplyPositioning : 0) | (enableLigatures ? kCTFontTransformApplyShaping : 0);
     return CTFontTransformGlyphs(m_platformData.ctFont(), glyphs, reinterpret_cast<CGSize*>(advances), glyphCount, options);
 #else
     UNUSED_PARAM(glyphs);
     UNUSED_PARAM(advances);
     UNUSED_PARAM(glyphCount);
-    UNUSED_PARAM(typesettingFeatures);
+    UNUSED_PARAM(enableKerning);
+    UNUSED_PARAM(enableLigatures);
     return false;
 #endif
 }
index 075cbe0..c408a45 100644 (file)
@@ -35,7 +35,6 @@
 #if ENABLE(OPENTYPE_VERTICAL)
 #include "OpenTypeVerticalData.h"
 #endif
-#include "TypesettingFeatures.h"
 #include <wtf/TypeCasts.h>
 #include <wtf/text/StringHash.h>
 
@@ -193,7 +192,7 @@ public:
     bool shouldNotBeUsedForArabic() const { return m_shouldNotBeUsedForArabic; };
 #endif
 #if PLATFORM(COCOA)
-    CFDictionaryRef getCFStringAttributes(TypesettingFeatures, FontOrientation) const;
+    CFDictionaryRef getCFStringAttributes(bool enableKerning, bool enableLigatures, FontOrientation) const;
     bool hasCustomTracking() const { return isSystemFont(); }
 #endif
 
@@ -201,7 +200,7 @@ public:
     bool canRenderCombiningCharacterSequence(const UChar*, size_t) const;
 #endif
 
-    bool applyTransforms(GlyphBufferGlyph*, GlyphBufferAdvance*, size_t glyphCount, TypesettingFeatures) const;
+    bool applyTransforms(GlyphBufferGlyph*, GlyphBufferAdvance*, size_t glyphCount, bool enableKerning, bool enableLigatures) const;
 
 #if PLATFORM(COCOA) || PLATFORM(WIN)
     bool isSystemFont() const { return m_isSystemFont; }
index d7077b4..244e777 100644 (file)
@@ -92,7 +92,8 @@ static bool useBackslashAsYenSignForFamily(const AtomicString& family)
 
 FontCascade::CodePath FontCascade::s_codePath = Auto;
 
-TypesettingFeatures FontCascade::s_defaultTypesettingFeatures = 0;
+bool FontCascade::s_defaultKerning = false;
+bool FontCascade::s_defaultLigatures = false;
 
 // ============================================================================================
 // FontCascade Implementation (Cross-Platform Portion)
@@ -103,7 +104,8 @@ FontCascade::FontCascade()
     , m_letterSpacing(0)
     , m_wordSpacing(0)
     , m_useBackslashAsYenSymbol(false)
-    , m_typesettingFeatures(0)
+    , m_enableKerning(false)
+    , m_enableLigatures(false)
 {
 }
 
@@ -113,7 +115,8 @@ FontCascade::FontCascade(const FontCascadeDescription& fd, float letterSpacing,
     , m_letterSpacing(letterSpacing)
     , m_wordSpacing(wordSpacing)
     , m_useBackslashAsYenSymbol(useBackslashAsYenSignForFamily(fd.firstFamily()))
-    , m_typesettingFeatures(computeTypesettingFeatures())
+    , m_enableKerning(computeEnableKerning())
+    , m_enableLigatures(computeEnableKerning())
 {
 }
 
@@ -124,7 +127,8 @@ FontCascade::FontCascade(const FontPlatformData& fontData, FontSmoothingMode fon
     , m_letterSpacing(0)
     , m_wordSpacing(0)
     , m_useBackslashAsYenSymbol(false)
-    , m_typesettingFeatures(computeTypesettingFeatures())
+    , m_enableKerning(computeEnableKerning())
+    , m_enableLigatures(computeEnableKerning())
 {
     m_fontDescription.setFontSmoothing(fontSmoothingMode);
 #if PLATFORM(IOS)
@@ -142,7 +146,8 @@ FontCascade::FontCascade(const FontCascade& other)
     , m_letterSpacing(other.m_letterSpacing)
     , m_wordSpacing(other.m_wordSpacing)
     , m_useBackslashAsYenSymbol(other.m_useBackslashAsYenSymbol)
-    , m_typesettingFeatures(computeTypesettingFeatures())
+    , m_enableKerning(computeEnableKerning())
+    , m_enableLigatures(computeEnableKerning())
 {
 }
 
@@ -153,7 +158,8 @@ FontCascade& FontCascade::operator=(const FontCascade& other)
     m_letterSpacing = other.m_letterSpacing;
     m_wordSpacing = other.m_wordSpacing;
     m_useBackslashAsYenSymbol = other.m_useBackslashAsYenSymbol;
-    m_typesettingFeatures = other.m_typesettingFeatures;
+    m_enableKerning = other.m_enableKerning;
+    m_enableLigatures = other.m_enableLigatures;
     return *this;
 }
 
@@ -298,7 +304,8 @@ void FontCascade::update(RefPtr<FontSelector>&& fontSelector) const
 {
     m_fonts = retrieveOrAddCachedFonts(m_fontDescription, WTF::move(fontSelector));
     m_useBackslashAsYenSymbol = useBackslashAsYenSignForFamily(firstFamily());
-    m_typesettingFeatures = computeTypesettingFeatures();
+    m_enableKerning = computeEnableKerning();
+    m_enableLigatures = computeEnableLigatures();
 }
 
 float FontCascade::drawText(GraphicsContext& context, const TextRun& run, const FloatPoint& point, int from, int to, CustomFontNotReadyAction customFontNotReadyAction) const
@@ -313,7 +320,7 @@ float FontCascade::drawText(GraphicsContext& context, const TextRun& run, const
 
     CodePath codePathToUse = codePath(run);
     // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
-    if (codePathToUse != Complex && typesettingFeatures() && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
+    if (codePathToUse != Complex && (enableKerning() || enableLigatures()) && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
         codePathToUse = Complex;
 
     if (codePathToUse != Complex)
@@ -332,7 +339,7 @@ void FontCascade::drawEmphasisMarks(GraphicsContext& context, const TextRun& run
 
     CodePath codePathToUse = codePath(run);
     // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
-    if (codePathToUse != Complex && typesettingFeatures() && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
+    if (codePathToUse != Complex && (enableKerning() || enableLigatures()) && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
         codePathToUse = Complex;
 
     if (codePathToUse != Complex)
@@ -353,7 +360,7 @@ float FontCascade::width(const TextRun& run, HashSet<const Font*>* fallbackFonts
             glyphOverflow = 0;
     }
 
-    bool hasKerningOrLigatures = typesettingFeatures() & (Kerning | Ligatures);
+    bool hasKerningOrLigatures = enableKerning() || enableLigatures();
     bool hasWordSpacingOrLetterSpacing = wordSpacing() || letterSpacing();
     float* cacheEntry = m_fonts->widthCache().add(run, std::numeric_limits<float>::quiet_NaN(), hasKerningOrLigatures, hasWordSpacingOrLetterSpacing, glyphOverflow);
     if (cacheEntry && !std::isnan(*cacheEntry))
@@ -505,7 +512,7 @@ void FontCascade::adjustSelectionRectForText(const TextRun& run, LayoutRect& sel
 
     CodePath codePathToUse = codePath(run);
     // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
-    if (codePathToUse != Complex && typesettingFeatures() && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
+    if (codePathToUse != Complex && (enableKerning() || enableLigatures()) && (from || static_cast<unsigned>(to) != run.length()) && !isDrawnWithSVGFont(run))
         codePathToUse = Complex;
 
     if (codePathToUse != Complex)
@@ -517,7 +524,7 @@ void FontCascade::adjustSelectionRectForText(const TextRun& run, LayoutRect& sel
 int FontCascade::offsetForPosition(const TextRun& run, float x, bool includePartialGlyphs) const
 {
     // FIXME: Use the fast code path once it handles partial runs with kerning and ligatures. See http://webkit.org/b/100050
-    if (codePath(run) != Complex && (!typesettingFeatures() || isDrawnWithSVGFont(run)))
+    if (codePath(run) != Complex && (!(enableKerning() || enableLigatures()) || isDrawnWithSVGFont(run)))
         return offsetForPositionForSimpleText(run, x, includePartialGlyphs);
 
     return offsetForPositionForComplexText(run, x, includePartialGlyphs);
@@ -580,14 +587,14 @@ FontCascade::CodePath FontCascade::codePath()
     return s_codePath;
 }
 
-void FontCascade::setDefaultTypesettingFeatures(TypesettingFeatures typesettingFeatures)
+void FontCascade::setDefaultKerning(bool enable)
 {
-    s_defaultTypesettingFeatures = typesettingFeatures;
+    s_defaultKerning = enable;
 }
 
-TypesettingFeatures FontCascade::defaultTypesettingFeatures()
+void FontCascade::setDefaultLigatures(bool enable)
 {
-    return s_defaultTypesettingFeatures;
+    s_defaultLigatures = enable;
 }
 
 FontCascade::CodePath FontCascade::codePath(const TextRun& run) const
@@ -605,7 +612,7 @@ FontCascade::CodePath FontCascade::codePath(const TextRun& run) const
         return Complex;
 
 #if !PLATFORM(COCOA)
-    if (run.length() > 1 && typesettingFeatures())
+    if (run.length() > 1 && (enableKerning() || enableLigatures()))
         return Complex;
 #endif
 
@@ -1427,7 +1434,7 @@ float FontCascade::floatWidthForSimpleText(const TextRun& run, HashSet<const Fon
 {
     WidthIterator it(this, run, fallbackFonts, glyphOverflow);
     GlyphBuffer glyphBuffer;
-    it.advance(run.length(), (typesettingFeatures() & (Kerning | Ligatures)) ? &glyphBuffer : 0);
+    it.advance(run.length(), (enableKerning() || enableLigatures()) ? &glyphBuffer : nullptr);
 
     if (glyphOverflow) {
         glyphOverflow->top = std::max<int>(glyphOverflow->top, ceilf(-it.minGlyphBoundingBoxY()) - (glyphOverflow->computeBounds ? 0 : fontMetrics().ascent()));
index df7eea7..9c706a8 100644 (file)
@@ -31,7 +31,6 @@
 #include "FontDescription.h"
 #include "Path.h"
 #include "TextFlags.h"
-#include "TypesettingFeatures.h"
 #include <wtf/HashMap.h>
 #include <wtf/HashSet.h>
 #include <wtf/WeakPtr.h>
@@ -158,7 +157,8 @@ public:
     
     FontRenderingMode renderingMode() const { return m_fontDescription.renderingMode(); }
 
-    TypesettingFeatures typesettingFeatures() const { return static_cast<TypesettingFeatures>(m_typesettingFeatures); }
+    bool enableKerning() const { return m_enableKerning; }
+    bool enableLigatures() const { return m_enableLigatures; }
 
     const AtomicString& firstFamily() const { return m_fontDescription.firstFamily(); }
     unsigned familyCount() const { return m_fontDescription.familyCount(); }
@@ -265,9 +265,8 @@ public:
     static CodePath codePath();
     static CodePath s_codePath;
 
-    WEBCORE_EXPORT static void setDefaultTypesettingFeatures(TypesettingFeatures);
-    static TypesettingFeatures defaultTypesettingFeatures();
-
+    WEBCORE_EXPORT static void setDefaultKerning(bool);
+    WEBCORE_EXPORT static void setDefaultLigatures(bool);
     static const uint8_t s_roundingHackCharacterTable[256];
     static bool isRoundingHackCharacter(UChar32 c)
     {
@@ -300,49 +299,38 @@ public:
 private:
     bool isLoadingCustomFonts() const;
 
-    TypesettingFeatures computeTypesettingFeatures() const
+    bool advancedTextRenderingMode() const
+    {
+        auto textRenderingMode = m_fontDescription.textRenderingMode();
+        if (textRenderingMode == GeometricPrecision || textRenderingMode == OptimizeLegibility)
+            return true;
+        if (textRenderingMode == OptimizeSpeed)
+            return false;
+        return s_defaultKerning;
+    }
+
+    bool computeEnableKerning() const
+    {
+        auto kerning = m_fontDescription.kerning();
+        if (kerning == Kerning::Normal)
+            return true;
+        if (kerning == Kerning::NoShift)
+            return false;
+        return advancedTextRenderingMode();
+    }
+
+    bool computeEnableLigatures() const
     {
-        TextRenderingMode textRenderingMode = m_fontDescription.textRenderingMode();
-        TypesettingFeatures features = s_defaultTypesettingFeatures;
-
-        switch (textRenderingMode) {
-        case AutoTextRendering:
-            break;
-        case OptimizeSpeed:
-            features &= ~(Kerning | Ligatures);
-            break;
-        case GeometricPrecision:
-        case OptimizeLegibility:
-            features |= Kerning | Ligatures;
-            break;
-        }
-
-        switch (m_fontDescription.kerning()) {
-        case FontCascadeDescription::NoneKerning:
-            features &= ~Kerning;
-            break;
-        case FontCascadeDescription::NormalKerning:
-            features |= Kerning;
-            break;
-        case FontCascadeDescription::AutoKerning:
-            break;
-        }
-
-        switch (m_fontDescription.variantCommonLigatures()) {
-        case FontVariantLigatures::No:
-            features &= ~Ligatures;
-            break;
-        case FontVariantLigatures::Yes:
-            features |= Ligatures;
-            break;
-        default:
-            break;
-        }
-
-        return features;
+        auto ligatures = m_fontDescription.variantCommonLigatures();
+        if (ligatures == FontVariantLigatures::Yes)
+            return true;
+        if (ligatures == FontVariantLigatures::No)
+            return false;
+        return advancedTextRenderingMode();
     }
 
-    static TypesettingFeatures s_defaultTypesettingFeatures;
+    static bool s_defaultKerning;
+    static bool s_defaultLigatures;
 
     FontCascadeDescription m_fontDescription;
     mutable RefPtr<FontCascadeFonts> m_fonts;
@@ -350,7 +338,8 @@ private:
     float m_letterSpacing;
     float m_wordSpacing;
     mutable bool m_useBackslashAsYenSymbol;
-    mutable unsigned m_typesettingFeatures : 2; // (TypesettingFeatures) Caches values computed from m_fontDescription.
+    mutable unsigned m_enableKerning : 1; // Computed from m_fontDescription.
+    mutable unsigned m_enableLigatures : 1; // Computed from m_fontDescription.
 };
 
 void invalidateFontCascadeCache();
index af3770d..ad271d5 100644 (file)
@@ -83,7 +83,7 @@ FontTraitsMask FontDescription::traitsMask() const
 
 FontCascadeDescription::FontCascadeDescription()
     : m_isAbsoluteSize(false)
-    , m_kerning(AutoKerning)
+    , m_kerning(static_cast<unsigned>(Kerning::Auto))
     , m_keywordSize(0)
     , m_fontSmoothing(AutoSmoothing)
     , m_isSpecifiedFont(false)
index 4902bbc..9cf8549 100644 (file)
@@ -192,8 +192,6 @@ inline bool FontDescription::operator==(const FontDescription& other) const
 // FIXME: Move to a file of its own.
 class FontCascadeDescription : public FontDescription {
 public:
-    enum Kerning { AutoKerning, NormalKerning, NoneKerning };
-
     FontCascadeDescription();
 
     bool operator==(const FontCascadeDescription&) const;
@@ -228,7 +226,7 @@ public:
     void setFamilies(const RefCountedArray<AtomicString>& families) { m_families = families; }
     void setSpecifiedSize(float s) { m_specifiedSize = clampToFloat(s); }
     void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
-    void setKerning(Kerning kerning) { m_kerning = kerning; }
+    void setKerning(Kerning kerning) { m_kerning = static_cast<unsigned>(kerning); }
     void setKeywordSize(unsigned size)
     {
         ASSERT(size <= 8);
@@ -259,7 +257,7 @@ public:
     // Initial values for font properties.
     static FontItalic initialItalic() { return FontItalicOff; }
     static FontSmallCaps initialSmallCaps() { return FontSmallCapsOff; }
-    static Kerning initialKerning() { return AutoKerning; }
+    static Kerning initialKerning() { return Kerning::Auto; }
     static FontSmoothingMode initialFontSmoothing() { return AutoSmoothing; }
     static TextRenderingMode initialTextRenderingMode() { return AutoTextRendering; }
     static FontSynthesis initialFontSynthesis() { return FontSynthesisWeight | FontSynthesisStyle; }
diff --git a/Source/WebCore/platform/graphics/TypesettingFeatures.h b/Source/WebCore/platform/graphics/TypesettingFeatures.h
deleted file mode 100644 (file)
index aa46beb..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
- * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
- * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
- * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
- * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
- * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
- * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
- * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
- * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
- * THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#ifndef TypesettingFeatures_h
-#define TypesettingFeatures_h
-
-namespace WebCore {
-    enum TypesettingFeature {
-        Kerning = 1 << 0,
-        Ligatures = 1 << 1,
-    };
-
-    typedef unsigned TypesettingFeatures;
-} // namespace WebCore
-
-#endif // TypesettingFeatures_h
index 4981441..b0a5f58 100644 (file)
@@ -41,13 +41,10 @@ WidthIterator::WidthIterator(const FontCascade* font, const TextRun& run, HashSe
     , m_runWidthSoFar(0)
     , m_isAfterExpansion((run.expansionBehavior() & LeadingExpansionMask) == ForbidLeadingExpansion)
     , m_finalRoundingWidth(0)
-    , m_typesettingFeatures(font->typesettingFeatures())
     , m_fallbackFonts(fallbackFonts)
     , m_accountForGlyphBounds(accountForGlyphBounds)
-    , m_maxGlyphBoundingBoxY(std::numeric_limits<float>::min())
-    , m_minGlyphBoundingBoxY(std::numeric_limits<float>::max())
-    , m_firstGlyphOverflow(0)
-    , m_lastGlyphOverflow(0)
+    , m_enableKerning(font->enableKerning())
+    , m_enableLigatures(font->enableLigatures())
     , m_forTextEmphasis(forTextEmphasis)
 {
     // If the padding is non-zero, count the number of spaces in the run
@@ -104,12 +101,12 @@ inline auto WidthIterator::shouldApplyFontTransforms(const GlyphBuffer* glyphBuf
 {
     if (glyphBuffer && glyphBuffer->size() == (lastGlyphCount + 1) && isSoftBankEmoji(previousCharacter))
         return TransformsType::Forced;
-    if (m_run.length() <= 1 || !(m_typesettingFeatures & (Kerning | Ligatures)))
+    if (m_run.length() <= 1 || !(m_enableKerning || m_enableLigatures))
         return TransformsType::None;
     return TransformsType::NotForced;
 }
 
-inline float WidthIterator::applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, int& lastGlyphCount, const Font* font, TypesettingFeatures typesettingFeatures, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace& charactersTreatedAsSpace)
+inline float WidthIterator::applyFontTransforms(GlyphBuffer* glyphBuffer, bool ltr, int& lastGlyphCount, const Font* font, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace& charactersTreatedAsSpace)
 {
     ASSERT_UNUSED(previousCharacter, shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter) != WidthIterator::TransformsType::None);
 
@@ -134,14 +131,14 @@ inline float WidthIterator::applyFontTransforms(GlyphBuffer* glyphBuffer, bool l
     // We need to handle transforms on SVG fonts internally, since they are rendered internally.
     if (font->isSVGFont()) {
         // SVG font ligatures are handled during glyph selection, only kerning remaining.
-        if (run().renderingContext() && (typesettingFeatures & Kerning)) {
+        if (run().renderingContext() && m_enableKerning) {
             // FIXME: We could pass the necessary context down to this level so we can lazily create rendering contexts at this point.
             // However, a larger refactoring of SVG fonts might necessary to sidestep this problem completely.
             run().renderingContext()->applySVGKerning(font, *this, glyphBuffer, lastGlyphCount);
         }
     } else
 #endif
-        font->applyTransforms(glyphBuffer->glyphs(lastGlyphCount), advances + lastGlyphCount, glyphBufferSize - lastGlyphCount, typesettingFeatures);
+        font->applyTransforms(glyphBuffer->glyphs(lastGlyphCount), advances + lastGlyphCount, glyphBufferSize - lastGlyphCount, m_enableKerning, m_enableLigatures);
 
     if (!ltr)
         glyphBuffer->reverse(lastGlyphCount, glyphBufferSize - lastGlyphCount);
@@ -252,7 +249,7 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph
         if (font != lastFontData && width) {
             auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
             if (transformsType != TransformsType::None) {
-                m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, m_typesettingFeatures, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
+                m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
                 if (glyphBuffer)
                     glyphBuffer->shrink(lastGlyphCount);
             }
@@ -410,7 +407,7 @@ inline unsigned WidthIterator::advanceInternal(TextIterator& textIterator, Glyph
 
     auto transformsType = shouldApplyFontTransforms(glyphBuffer, lastGlyphCount, previousCharacter);
     if (transformsType != TransformsType::None) {
-        m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, m_typesettingFeatures, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
+        m_runWidthSoFar += applyFontTransforms(glyphBuffer, m_run.ltr(), lastGlyphCount, lastFontData, previousCharacter, transformsType == TransformsType::Forced, charactersTreatedAsSpace);
         if (glyphBuffer)
             glyphBuffer->shrink(lastGlyphCount);
     }
index 2ed4eb1..b356341 100644 (file)
@@ -84,16 +84,17 @@ private:
 
     enum class TransformsType { None, Forced, NotForced };
     TransformsType shouldApplyFontTransforms(const GlyphBuffer*, int lastGlyphCount, UChar32 previousCharacter) const;
-    float applyFontTransforms(GlyphBuffer*, bool ltr, int& lastGlyphCount, const Font*, TypesettingFeatures, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace&);
-
-    TypesettingFeatures m_typesettingFeatures;
-    HashSet<const Font*>* m_fallbackFonts;
-    bool m_accountForGlyphBounds;
-    float m_maxGlyphBoundingBoxY;
-    float m_minGlyphBoundingBoxY;
-    float m_firstGlyphOverflow;
-    float m_lastGlyphOverflow;
-    bool m_forTextEmphasis;
+    float applyFontTransforms(GlyphBuffer*, bool ltr, int& lastGlyphCount, const Font*, UChar32 previousCharacter, bool force, CharactersTreatedAsSpace&);
+
+    HashSet<const Font*>* m_fallbackFonts { nullptr };
+    bool m_accountForGlyphBounds { false };
+    bool m_enableKerning { false };
+    bool m_enableLigatures { false };
+    bool m_forTextEmphasis { false };
+    float m_maxGlyphBoundingBoxY { std::numeric_limits<float>::min() };
+    float m_minGlyphBoundingBoxY { std::numeric_limits<float>::max() };
+    float m_firstGlyphOverflow { 0 };
+    float m_lastGlyphOverflow { 0 };
 };
 
 }
index f5f45b1..045256b 100644 (file)
@@ -475,7 +475,7 @@ bool Font::canRenderCombiningCharacterSequence(const UChar* characters, size_t l
 
     RetainPtr<CFTypeRef> fontEqualityObject = platformData().objectForEqualityCheck();
 
-    ProviderInfo info = { characters, length, getCFStringAttributes(0, platformData().orientation()) };
+    ProviderInfo info = { characters, length, getCFStringAttributes(false, false, platformData().orientation()) };
     RetainPtr<CTLineRef> line = adoptCF(CTLineCreateWithUniCharProvider(&provideStringAndAttributes, 0, &info));
 
     CFArrayRef runArray = CTLineGetGlyphRuns(line.get());
index 3481973..fde8e06 100644 (file)
@@ -338,15 +338,15 @@ void HarfBuzzShaper::setFontFeatures()
 
     hb_feature_t kerning = { HarfBuzzFace::kernTag, 0, 0, static_cast<unsigned>(-1) };
     switch (description.kerning()) {
-    case FontCascadeDescription::NormalKerning:
+    case Kerning::Normal:
         kerning.value = 1;
         m_features.append(kerning);
         break;
-    case FontCascadeDescription::NoneKerning:
+    case Kerning::NoShift:
         kerning.value = 0;
         m_features.append(kerning);
         break;
-    case FontCascadeDescription::AutoKerning:
+    case Kerning::Auto:
         break;
     default:
         ASSERT_NOT_REACHED();
index 4816a22..1a15480 100644 (file)
@@ -217,7 +217,7 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
 
         RetainPtr<WebCascadeList> cascadeList = adoptNS([[WebCascadeList alloc] initWithFont:&m_font character:baseCharacter]);
 
-        stringAttributes = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, font->getCFStringAttributes(m_font.typesettingFeatures(), font->platformData().orientation())));
+        stringAttributes = adoptCF(CFDictionaryCreateMutableCopy(kCFAllocatorDefault, 0, font->getCFStringAttributes(m_font.enableKerning(), m_font.enableLigatures(), font->platformData().orientation())));
         static const void* attributeKeys[] = { kCTFontCascadeListAttribute };
         const void* values[] = { cascadeList.get() };
         RetainPtr<CFDictionaryRef> attributes = adoptCF(CFDictionaryCreate(kCFAllocatorDefault, attributeKeys, values, sizeof(attributeKeys) / sizeof(*attributeKeys), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks));
@@ -225,7 +225,7 @@ void ComplexTextController::collectComplexTextRunsForCharacters(const UChar* cp,
         RetainPtr<CTFontRef> fontWithCascadeList = adoptCF(CTFontCreateCopyWithAttributes(font->platformData().ctFont(), m_font.pixelSize(), 0, fontDescriptor.get()));
         CFDictionarySetValue(const_cast<CFMutableDictionaryRef>(stringAttributes.get()), kCTFontAttributeName, fontWithCascadeList.get());
     } else
-        stringAttributes = font->getCFStringAttributes(m_font.typesettingFeatures(), font->platformData().orientation());
+        stringAttributes = font->getCFStringAttributes(m_font.enableKerning(), m_font.enableLigatures(), font->platformData().orientation());
 
     RetainPtr<CTLineRef> line;
 
index 0f83017..c1afccf 100644 (file)
@@ -35,9 +35,9 @@
 
 namespace WebCore {
 
-CFDictionaryRef Font::getCFStringAttributes(TypesettingFeatures typesettingFeatures, FontOrientation orientation) const
+CFDictionaryRef Font::getCFStringAttributes(bool enableKerning, bool enableLigatures, FontOrientation orientation) const
 {
-    unsigned key = typesettingFeatures + 1;
+    unsigned key = (enableKerning << 1 | enableLigatures) + 1;
     HashMap<unsigned, RetainPtr<CFDictionaryRef>>::AddResult addResult = m_CFStringAttributes.add(key, RetainPtr<CFDictionaryRef>());
     RetainPtr<CFDictionaryRef>& attributesDictionary = addResult.iterator->value;
     if (!addResult.isNewEntry)
@@ -48,14 +48,13 @@ CFDictionaryRef Font::getCFStringAttributes(TypesettingFeatures typesettingFeatu
 
     CFDictionarySetValue(mutableAttributes, kCTFontAttributeName, platformData().ctFont());
 
-    if (!(typesettingFeatures & Kerning)) {
+    if (!enableKerning) {
         const float zero = 0;
         static CFNumberRef zeroKerningValue = CFNumberCreate(kCFAllocatorDefault, kCFNumberFloatType, &zero);
         CFDictionarySetValue(mutableAttributes, kCTKernAttributeName, zeroKerningValue);
     }
 
-    bool allowLigatures = (orientation == Horizontal && platformData().allowsLigatures()) || (typesettingFeatures & Ligatures);
-    if (!allowLigatures) {
+    if (!((orientation == Horizontal && platformData().allowsLigatures()) || enableLigatures)) {
         const int zero = 0;
         static CFNumberRef essentialLigaturesValue = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &zero);
         CFDictionarySetValue(mutableAttributes, kCTLigatureAttributeName, essentialLigaturesValue);
index a0910f6..043fd2b 100644 (file)
@@ -259,6 +259,12 @@ enum FontTraitsMask {
     FontWeightMask = FontWeight100Mask | FontWeight200Mask | FontWeight300Mask | FontWeight400Mask | FontWeight500Mask | FontWeight600Mask | FontWeight700Mask | FontWeight800Mask | FontWeight900Mask
 };
 
+enum class Kerning {
+    Auto,
+    Normal,
+    NoShift
+};
+
 }
 
 #endif
index 746ac3e..3653939 100644 (file)
@@ -482,7 +482,7 @@ static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* ru
 
     float measuredWidth = 0;
 
-    bool kerningIsEnabled = font.typesettingFeatures() & Kerning;
+    bool kerningIsEnabled = font.enableKerning();
     bool canUseSimpleFontCodePath = renderer.canUseSimpleFontCodePath();
     
     // Since we don't cache glyph overflows, we need to re-measure the run if
index 0668940..69968bc 100644 (file)
@@ -78,7 +78,7 @@ struct WordTrailingSpace {
             return m_width;
 
         const FontCascade& font = m_style.fontCascade();
-        if ((font.typesettingFeatures() & Kerning) && !m_textLayout)
+        if (font.enableKerning() && !m_textLayout)
             m_width = font.width(RenderBlock::constructTextRun(&m_renderer, font, &space, 1, m_style), &fallbackFonts) + font.wordSpacing();
         m_state = WordTrailingSpaceState::Computed;
         return m_width;
index 2a6d394..ec031fe 100644 (file)
@@ -53,7 +53,7 @@ private:
     bool fillBMPGlyphs(SVGFontElement*, GlyphPage*, UChar* buffer) const;
     bool fillNonBMPGlyphs(SVGFontElement*, GlyphPage*, UChar* buffer) const;
 
-    bool applyTransforms(GlyphBufferGlyph*, GlyphBufferAdvance*, size_t, TypesettingFeatures) const = delete;
+    bool applyTransforms(GlyphBufferGlyph*, GlyphBufferAdvance*, size_t, bool enableKerning, bool enableLigatures) const = delete;
 
     // Ths SVGFontFaceElement is kept alive --
     // 1) in the external font case: by the CSSFontFaceSource, which holds a reference to the external SVG document
index ea3ea4e..cb65e7b 100644 (file)
@@ -1,3 +1,13 @@
+2015-10-13  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Split TypesettingFeatures into kerning and ligatures bools
+        https://bugs.webkit.org/show_bug.cgi?id=150074
+
+        Reviewed by Simon Fraser.
+
+        * WebView/WebView.mm:
+        (+[WebView initialize]):
+
 2015-10-13  Chris Dumez  <cdumez@apple.com>
 
         Avoid useless copies in range-loops that are using 'auto'
index ef8a783..877dfe4 100644 (file)
@@ -4708,7 +4708,9 @@ static Vector<String> toStringVector(NSArray* patterns)
     grammarCheckingEnabled = [defaults boolForKey:WebGrammarCheckingEnabled];
 #endif
 
-    FontCascade::setDefaultTypesettingFeatures([defaults boolForKey:WebKitKerningAndLigaturesEnabledByDefaultDefaultsKey] ? Kerning | Ligatures : 0);
+    bool defaultKerningAndLigatures = [defaults boolForKey:WebKitKerningAndLigaturesEnabledByDefaultDefaultsKey];
+    FontCascade::setDefaultKerning(defaultKerningAndLigatures);
+    FontCascade::setDefaultLigatures(defaultKerningAndLigatures);
 
 #if !PLATFORM(IOS)
     automaticQuoteSubstitutionEnabled = [self _shouldAutomaticQuoteSubstitutionBeEnabled];
index af42550..c2f9a14 100644 (file)
@@ -1,3 +1,20 @@
+2015-10-13  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Split TypesettingFeatures into kerning and ligatures bools
+        https://bugs.webkit.org/show_bug.cgi?id=150074
+
+        Reviewed by Simon Fraser.
+
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::WebProcessCreationParameters):
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+        * UIProcess/Cocoa/WebProcessPoolCocoa.mm:
+        (WebKit::WebProcessPool::platformInitializeWebProcess):
+        * WebProcess/cocoa/WebProcessCocoa.mm:
+        (WebKit::WebProcess::platformInitializeWebProcess):
+
 2015-10-13  Dean Jackson  <dino@apple.com>
 
         Fix iOS-family builds.
index 1294c97..8f17386 100644 (file)
@@ -40,7 +40,8 @@ WebProcessCreationParameters::WebProcessCreationParameters()
     , shouldUseFontSmoothing(true)
     , defaultRequestTimeoutInterval(INT_MAX)
 #if PLATFORM(COCOA)
-    , shouldEnableKerningAndLigaturesByDefault(false)
+    , shouldEnableKerningByDefault(false)
+    , shouldEnableLigaturesByDefault(false)
     , shouldEnableJIT(false)
     , shouldEnableFTLJIT(false)
 #endif
@@ -122,7 +123,8 @@ void WebProcessCreationParameters::encode(IPC::ArgumentEncoder& encoder) const
     encoder << acceleratedCompositingPort;
     encoder << uiProcessBundleResourcePath;
     encoder << uiProcessBundleResourcePathExtensionHandle;
-    encoder << shouldEnableKerningAndLigaturesByDefault;
+    encoder << shouldEnableKerningByDefault;
+    encoder << shouldEnableLigaturesByDefault;
     encoder << shouldEnableJIT;
     encoder << shouldEnableFTLJIT;
     encoder << !!bundleParameterData;
@@ -267,7 +269,9 @@ bool WebProcessCreationParameters::decode(IPC::ArgumentDecoder& decoder, WebProc
         return false;
     if (!decoder.decode(parameters.uiProcessBundleResourcePathExtensionHandle))
         return false;
-    if (!decoder.decode(parameters.shouldEnableKerningAndLigaturesByDefault))
+    if (!decoder.decode(parameters.shouldEnableKerningByDefault))
+        return false;
+    if (!decoder.decode(parameters.shouldEnableLigaturesByDefault))
         return false;
     if (!decoder.decode(parameters.shouldEnableJIT))
         return false;
index a49402c..69d4ea0 100644 (file)
@@ -142,7 +142,8 @@ struct WebProcessCreationParameters {
     String uiProcessBundleResourcePath;
     SandboxExtension::Handle uiProcessBundleResourcePathExtensionHandle;
 
-    bool shouldEnableKerningAndLigaturesByDefault;
+    bool shouldEnableKerningByDefault;
+    bool shouldEnableLigaturesByDefault;
     bool shouldEnableJIT;
     bool shouldEnableFTLJIT;
     
index 8bb974c..2c999fb 100644 (file)
@@ -175,7 +175,9 @@ void WebProcessPool::platformInitializeWebProcess(WebProcessCreationParameters&
     parameters.accessibilityEnhancedUserInterfaceEnabled = false;
 #endif
 
-    parameters.shouldEnableKerningAndLigaturesByDefault = [[NSUserDefaults standardUserDefaults] boolForKey:WebKitKerningAndLigaturesEnabledByDefaultDefaultsKey];
+    bool shouldEnableKerningAndLigaturesByDefault = [[NSUserDefaults standardUserDefaults] boolForKey:WebKitKerningAndLigaturesEnabledByDefaultDefaultsKey];
+    parameters.shouldEnableKerningByDefault = shouldEnableKerningAndLigaturesByDefault;
+    parameters.shouldEnableLigaturesByDefault = shouldEnableKerningAndLigaturesByDefault;
     parameters.shouldEnableJIT = [[NSUserDefaults standardUserDefaults] boolForKey:WebKitJSCJITEnabledDefaultsKey];
     parameters.shouldEnableFTLJIT = [[NSUserDefaults standardUserDefaults] boolForKey:WebKitJSCFTLJITEnabledDefaultsKey];
     parameters.shouldEnableMemoryPressureReliefLogging = [[NSUserDefaults standardUserDefaults] boolForKey:@"LogMemoryJetsamDetails"];
index 0348f0f..be78732 100644 (file)
@@ -144,7 +144,8 @@ void WebProcess::platformInitializeWebProcess(WebProcessCreationParameters&& par
 
     m_compositingRenderServerPort = WTF::move(parameters.acceleratedCompositingPort);
     m_presenterApplicationPid = parameters.presenterApplicationPid;
-    FontCascade::setDefaultTypesettingFeatures(parameters.shouldEnableKerningAndLigaturesByDefault ? Kerning | Ligatures : 0);
+    FontCascade::setDefaultKerning(parameters.shouldEnableKerningByDefault);
+    FontCascade::setDefaultLigatures(parameters.shouldEnableLigaturesByDefault);
 
     MemoryPressureHandler::ReliefLogger::setLoggingEnabled(parameters.shouldEnableMemoryPressureReliefLogging);