Move '-webkit-font-variant-ligature' CSS property to the new StyleBuilder
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Dec 2014 22:25:32 +0000 (22:25 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 30 Dec 2014 22:25:32 +0000 (22:25 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140007

Reviewed by Darin Adler.

Move '-webkit-font-variant-ligature' CSS property to the new StyleBuilder
by using custom code.

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyFontVariantLigatures::applyInheritValue): Deleted.
(WebCore::ApplyPropertyFontVariantLigatures::applyInitialValue): Deleted.
(WebCore::ApplyPropertyFontVariantLigatures::applyValue): Deleted.
(WebCore::ApplyPropertyFontVariantLigatures::createHandler): Deleted.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyInitialWebkitFontVariantLigatures):
(WebCore::StyleBuilderCustom::applyInheritWebkitFontVariantLigatures):
(WebCore::StyleBuilderCustom::applyValueWebkitFontVariantLigatures):

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

Source/WebCore/ChangeLog
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/DeprecatedStyleBuilder.cpp
Source/WebCore/css/StyleBuilderCustom.h

index 32ef407..1b96b88 100644 (file)
@@ -1,3 +1,25 @@
+2014-12-30  Chris Dumez  <cdumez@apple.com>
+
+        Move '-webkit-font-variant-ligature' CSS property to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=140007
+
+        Reviewed by Darin Adler.
+
+        Move '-webkit-font-variant-ligature' CSS property to the new StyleBuilder
+        by using custom code.
+
+        * css/CSSPropertyNames.in:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        (WebCore::ApplyPropertyFontVariantLigatures::applyInheritValue): Deleted.
+        (WebCore::ApplyPropertyFontVariantLigatures::applyInitialValue): Deleted.
+        (WebCore::ApplyPropertyFontVariantLigatures::applyValue): Deleted.
+        (WebCore::ApplyPropertyFontVariantLigatures::createHandler): Deleted.
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyInitialWebkitFontVariantLigatures):
+        (WebCore::StyleBuilderCustom::applyInheritWebkitFontVariantLigatures):
+        (WebCore::StyleBuilderCustom::applyValueWebkitFontVariantLigatures):
+
 2014-12-29  Chris Dumez  <cdumez@apple.com>
 
         Move animation / transition CSS properties to the new StyleBuilder
index 2826845..9018a89 100644 (file)
@@ -93,7 +93,7 @@ text-rendering [Inherited, LegacyStyleBuilder]
 -webkit-font-feature-settings [Inherited, LegacyStyleBuilder]
 -webkit-font-kerning [Inherited, LegacyStyleBuilder]
 -webkit-font-smoothing [Inherited, LegacyStyleBuilder]
--webkit-font-variant-ligatures [Inherited, LegacyStyleBuilder]
+-webkit-font-variant-ligatures [Inherited, Custom=All]
 -webkit-locale [Inherited, Custom=Value]
 -webkit-text-orientation [Inherited, Custom=Value]
 -epub-text-orientation = -webkit-text-orientation
index b646f0d..506fd2c 100644 (file)
@@ -313,86 +313,6 @@ public:
     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
 };
 
-class ApplyPropertyFontVariantLigatures {
-public:
-    static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
-    {
-        const FontDescription& parentFontDescription = styleResolver->parentFontDescription();
-        FontDescription fontDescription = styleResolver->fontDescription();
-
-        fontDescription.setCommonLigaturesState(parentFontDescription.commonLigaturesState());
-        fontDescription.setDiscretionaryLigaturesState(parentFontDescription.discretionaryLigaturesState());
-        fontDescription.setHistoricalLigaturesState(parentFontDescription.historicalLigaturesState());
-
-        styleResolver->setFontDescription(fontDescription);
-    }
-
-    static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
-    {
-        FontDescription fontDescription = styleResolver->fontDescription();
-
-        fontDescription.setCommonLigaturesState(FontDescription::NormalLigaturesState);
-        fontDescription.setDiscretionaryLigaturesState(FontDescription::NormalLigaturesState);
-        fontDescription.setHistoricalLigaturesState(FontDescription::NormalLigaturesState);
-
-        styleResolver->setFontDescription(fontDescription);
-    }
-
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        FontDescription::LigaturesState commonLigaturesState = FontDescription::NormalLigaturesState;
-        FontDescription::LigaturesState discretionaryLigaturesState = FontDescription::NormalLigaturesState;
-        FontDescription::LigaturesState historicalLigaturesState = FontDescription::NormalLigaturesState;
-
-        if (is<CSSValueList>(*value)) {
-            CSSValueList& valueList = downcast<CSSValueList>(*value);
-            for (size_t i = 0; i < valueList.length(); ++i) {
-                CSSValue* item = valueList.itemWithoutBoundsCheck(i);
-                if (is<CSSPrimitiveValue>(*item)) {
-                    switch (downcast<CSSPrimitiveValue>(*item).getValueID()) {
-                    case CSSValueNoCommonLigatures:
-                        commonLigaturesState = FontDescription::DisabledLigaturesState;
-                        break;
-                    case CSSValueCommonLigatures:
-                        commonLigaturesState = FontDescription::EnabledLigaturesState;
-                        break;
-                    case CSSValueNoDiscretionaryLigatures:
-                        discretionaryLigaturesState = FontDescription::DisabledLigaturesState;
-                        break;
-                    case CSSValueDiscretionaryLigatures:
-                        discretionaryLigaturesState = FontDescription::EnabledLigaturesState;
-                        break;
-                    case CSSValueNoHistoricalLigatures:
-                        historicalLigaturesState = FontDescription::DisabledLigaturesState;
-                        break;
-                    case CSSValueHistoricalLigatures:
-                        historicalLigaturesState = FontDescription::EnabledLigaturesState;
-                        break;
-                    default:
-                        ASSERT_NOT_REACHED();
-                        break;
-                    }
-                }
-            }
-        }
-#if !ASSERT_DISABLED
-        else
-            ASSERT(downcast<CSSPrimitiveValue>(*value).getValueID() == CSSValueNormal);
-#endif
-
-        FontDescription fontDescription = styleResolver->fontDescription();
-        fontDescription.setCommonLigaturesState(commonLigaturesState);
-        fontDescription.setDiscretionaryLigaturesState(discretionaryLigaturesState);
-        fontDescription.setHistoricalLigaturesState(historicalLigaturesState);
-        styleResolver->setFontDescription(fontDescription);
-    }
-
-    static PropertyHandler createHandler()
-    {
-        return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
-    }
-};
-
 const DeprecatedStyleBuilder& DeprecatedStyleBuilder::sharedStyleBuilder()
 {
     static NeverDestroyed<DeprecatedStyleBuilder> styleBuilderInstance;
@@ -426,7 +346,6 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder()
     setPropertyHandler(CSSPropertyWebkitBackgroundSize, CSSPropertyBackgroundSize);
     setPropertyHandler(CSSPropertyWebkitFontKerning, ApplyPropertyFont<FontDescription::Kerning, &FontDescription::kerning, &FontDescription::setKerning, FontDescription::AutoKerning>::createHandler());
     setPropertyHandler(CSSPropertyWebkitFontSmoothing, ApplyPropertyFont<FontSmoothingMode, &FontDescription::fontSmoothing, &FontDescription::setFontSmoothing, AutoSmoothing>::createHandler());
-    setPropertyHandler(CSSPropertyWebkitFontVariantLigatures, ApplyPropertyFontVariantLigatures::createHandler());
     setPropertyHandler(CSSPropertyWebkitMaskClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskClip, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSToStyleMap::mapFillClip>::createHandler());
     setPropertyHandler(CSSPropertyWebkitMaskComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitMaskComposite, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSToStyleMap::mapFillComposite>::createHandler());
     setPropertyHandler(CSSPropertyWebkitMaskOrigin, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskOrigin, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSToStyleMap::mapFillOrigin>::createHandler());
index 7209638..1c219e6 100644 (file)
@@ -74,6 +74,7 @@ public:
     DECLARE_PROPERTY_CUSTOM_HANDLERS(TextShadow);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(WebkitAspectRatio);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(WebkitBoxShadow);
+    DECLARE_PROPERTY_CUSTOM_HANDLERS(WebkitFontVariantLigatures);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(WebkitMaskBoxImageOutset);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(WebkitMaskBoxImageRepeat);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(WebkitMaskBoxImageSlice);
@@ -1202,6 +1203,71 @@ inline void StyleBuilderCustom::applyValueColumnGap(StyleResolver& styleResolver
         styleResolver.style()->setColumnGap(StyleBuilderConverter::convertComputedLength<float>(styleResolver, value));
 }
 
+inline void StyleBuilderCustom::applyInitialWebkitFontVariantLigatures(StyleResolver& styleResolver)
+{
+    FontDescription fontDescription = styleResolver.fontDescription();
+
+    fontDescription.setCommonLigaturesState(FontDescription::NormalLigaturesState);
+    fontDescription.setDiscretionaryLigaturesState(FontDescription::NormalLigaturesState);
+    fontDescription.setHistoricalLigaturesState(FontDescription::NormalLigaturesState);
+
+    styleResolver.setFontDescription(fontDescription);
+}
+
+inline void StyleBuilderCustom::applyInheritWebkitFontVariantLigatures(StyleResolver& styleResolver)
+{
+    const FontDescription& parentFontDescription = styleResolver.parentFontDescription();
+    FontDescription fontDescription = styleResolver.fontDescription();
+
+    fontDescription.setCommonLigaturesState(parentFontDescription.commonLigaturesState());
+    fontDescription.setDiscretionaryLigaturesState(parentFontDescription.discretionaryLigaturesState());
+    fontDescription.setHistoricalLigaturesState(parentFontDescription.historicalLigaturesState());
+
+    styleResolver.setFontDescription(fontDescription);
+}
+
+inline void StyleBuilderCustom::applyValueWebkitFontVariantLigatures(StyleResolver& styleResolver, CSSValue& value)
+{
+    FontDescription::LigaturesState commonLigaturesState = FontDescription::NormalLigaturesState;
+    FontDescription::LigaturesState discretionaryLigaturesState = FontDescription::NormalLigaturesState;
+    FontDescription::LigaturesState historicalLigaturesState = FontDescription::NormalLigaturesState;
+
+    if (is<CSSValueList>(value)) {
+        for (auto& item : downcast<CSSValueList>(value)) {
+            switch (downcast<CSSPrimitiveValue>(item.get()).getValueID()) {
+            case CSSValueNoCommonLigatures:
+                commonLigaturesState = FontDescription::DisabledLigaturesState;
+                break;
+            case CSSValueCommonLigatures:
+                commonLigaturesState = FontDescription::EnabledLigaturesState;
+                break;
+            case CSSValueNoDiscretionaryLigatures:
+                discretionaryLigaturesState = FontDescription::DisabledLigaturesState;
+                break;
+            case CSSValueDiscretionaryLigatures:
+                discretionaryLigaturesState = FontDescription::EnabledLigaturesState;
+                break;
+            case CSSValueNoHistoricalLigatures:
+                historicalLigaturesState = FontDescription::DisabledLigaturesState;
+                break;
+            case CSSValueHistoricalLigatures:
+                historicalLigaturesState = FontDescription::EnabledLigaturesState;
+                break;
+            default:
+                ASSERT_NOT_REACHED();
+                break;
+            }
+        }
+    } else
+        ASSERT(downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueNormal);
+
+    FontDescription fontDescription = styleResolver.fontDescription();
+    fontDescription.setCommonLigaturesState(commonLigaturesState);
+    fontDescription.setDiscretionaryLigaturesState(discretionaryLigaturesState);
+    fontDescription.setHistoricalLigaturesState(historicalLigaturesState);
+    styleResolver.setFontDescription(fontDescription);
+}
+
 } // namespace WebCore
 
 #endif // StyleBuilderCustom_h