Move more CSS properties to the new StyleBuilder
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Nov 2014 16:43:59 +0000 (16:43 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 17 Nov 2014 16:43:59 +0000 (16:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=138766

Reviewed by Darin Adler.

Move more CSS properties from DeprecatedStyleBuilder to the new
StyleBuilder:
line-height
word-spacing
-webkit-marquee-repetition
-webkit-text-underline-position

No new tests, no behavior change.

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::csstoLengthConversionDataWithTextZoomFactor): Deleted.
(WebCore::ApplyPropertyMarqueeRepetition::applyValue): Deleted.
(WebCore::ApplyPropertyMarqueeRepetition::createHandler): Deleted.
(WebCore::ApplyPropertyTextUnderlinePosition::applyValue): Deleted.
(WebCore::ApplyPropertyTextUnderlinePosition::createHandler): Deleted.
(WebCore::ApplyPropertyLineHeight::applyValue): Deleted.
(WebCore::ApplyPropertyLineHeight::createHandler): Deleted.
(WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): Deleted.
(WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyInitialValue): Deleted.
(WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyInheritValue): Deleted.
(WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::createHandler): Deleted.
(WebCore::ApplyPropertyWordSpacing::applyValue): Deleted.
(WebCore::ApplyPropertyWordSpacing::createHandler): Deleted.
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertMarqueeRepetition):
(WebCore::StyleBuilderConverter::convertTextUnderlinePosition):
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderFunctions::csstoLengthConversionDataWithTextZoomFactor):
(WebCore::StyleBuilderFunctions::convertLineHeight):
(WebCore::StyleBuilderFunctions::applyValueWordSpacing):
(WebCore::StyleBuilderFunctions::applyInheritLineHeight):
(WebCore::StyleBuilderFunctions::applyInitialLineHeight):
(WebCore::StyleBuilderFunctions::applyValueLineHeight):

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

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

index 14ee2cc..0d1d848 100644 (file)
@@ -1,3 +1,46 @@
+2014-11-17  Chris Dumez  <cdumez@apple.com>
+
+        Move more CSS properties to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=138766
+
+        Reviewed by Darin Adler.
+
+        Move more CSS properties from DeprecatedStyleBuilder to the new
+        StyleBuilder:
+        line-height
+        word-spacing
+        -webkit-marquee-repetition
+        -webkit-text-underline-position
+
+        No new tests, no behavior change.
+
+        * css/CSSPropertyNames.in:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        (WebCore::csstoLengthConversionDataWithTextZoomFactor): Deleted.
+        (WebCore::ApplyPropertyMarqueeRepetition::applyValue): Deleted.
+        (WebCore::ApplyPropertyMarqueeRepetition::createHandler): Deleted.
+        (WebCore::ApplyPropertyTextUnderlinePosition::applyValue): Deleted.
+        (WebCore::ApplyPropertyTextUnderlinePosition::createHandler): Deleted.
+        (WebCore::ApplyPropertyLineHeight::applyValue): Deleted.
+        (WebCore::ApplyPropertyLineHeight::createHandler): Deleted.
+        (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): Deleted.
+        (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyInitialValue): Deleted.
+        (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyInheritValue): Deleted.
+        (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::createHandler): Deleted.
+        (WebCore::ApplyPropertyWordSpacing::applyValue): Deleted.
+        (WebCore::ApplyPropertyWordSpacing::createHandler): Deleted.
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::convertMarqueeRepetition):
+        (WebCore::StyleBuilderConverter::convertTextUnderlinePosition):
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderFunctions::csstoLengthConversionDataWithTextZoomFactor):
+        (WebCore::StyleBuilderFunctions::convertLineHeight):
+        (WebCore::StyleBuilderFunctions::applyValueWordSpacing):
+        (WebCore::StyleBuilderFunctions::applyInheritLineHeight):
+        (WebCore::StyleBuilderFunctions::applyInitialLineHeight):
+        (WebCore::StyleBuilderFunctions::applyValueLineHeight):
+
 2014-11-16  Andreas Kling  <akling@apple.com>
 
         Avoid synchronous style recalc when mutating a Node inside FrameSelection.
index 273a1ab..024c7ef 100644 (file)
@@ -80,7 +80,11 @@ text-rendering [Inherited]
 zoom [NewStyleBuilder, Custom=All]
 
 // line height needs to be right after the above high-priority properties
-line-height [Inherited]
+#if defined(ENABLE_IOS_TEXT_AUTOSIZING) && ENABLE_IOS_TEXT_AUTOSIZING
+line-height [Inherited, NewStyleBuilder, Custom=All]
+#else
+line-height [Inherited, NewStyleBuilder, Getter=specifiedLineHeight, Custom=Value]
+#endif
 
 // Keep this in between the highest priority props and the lower ones.
 -webkit-ruby-position [Inherited, NewStyleBuilder, TypeName=RubyPosition]
@@ -262,7 +266,7 @@ widows [Inherited]
 width [NewStyleBuilder, Initial=initialSize, Converter=LengthSizing]
 word-break [Inherited, NewStyleBuilder]
 -epub-word-break = word-break
-word-spacing [Inherited]
+word-spacing [Inherited, NewStyleBuilder, Custom=Value]
 word-wrap [Inherited, NewStyleBuilder=EOverflowWrap, NameForMethods=OverflowWrap]
 z-index
 alt
@@ -429,7 +433,7 @@ justify-content [NewStyleBuilder]
 -webkit-marquee
 -webkit-marquee-direction [NewStyleBuilder]
 -webkit-marquee-increment [NewStyleBuilder, Custom=Value]
--webkit-marquee-repetition
+-webkit-marquee-repetition [NewStyleBuilder, NameForMethods=MarqueeLoopCount, Converter=MarqueeRepetition]
 -webkit-marquee-speed [NewStyleBuilder, Converter=MarqueeSpeed]
 -webkit-marquee-style [NewStyleBuilder, TypeName=EMarqueeBehavior, NameForMethods=MarqueeBehavior]
 -webkit-mask
@@ -486,7 +490,7 @@ order [NewStyleBuilder, TypeName=int]
 -webkit-text-decoration-style [NewStyleBuilder, TypeName=TextDecorationStyle]
 -webkit-text-decoration-color
 -webkit-text-decoration-skip [Inherited]
--webkit-text-underline-position [Inherited]
+-webkit-text-underline-position [Inherited, NewStyleBuilder, Converter=TextUnderlinePosition]
 -webkit-text-decorations-in-effect [Inherited]
 -webkit-text-emphasis [Inherited]
 -epub-text-emphasis = -webkit-text-emphasis
index 4e36000..ab139d5 100644 (file)
@@ -925,14 +925,6 @@ static TextDecorationSkip valueToDecorationSkip(CSSPrimitiveValue& primitiveValu
     return TextDecorationSkipNone;
 }
 
-static inline CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver)
-{
-    if (Frame* frame = styleResolver.document().frame())
-        return styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(styleResolver.style()->effectiveZoom() * frame->textZoomFactor());
-
-    return styleResolver.state().cssToLengthConversionData();
-}
-
 class ApplyPropertyTextDecorationSkip {
 public:
     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
@@ -956,165 +948,6 @@ public:
     }
 };
 
-class ApplyPropertyMarqueeRepetition {
-public:
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        if (!is<CSSPrimitiveValue>(*value))
-            return;
-
-        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-        if (primitiveValue.getValueID() == CSSValueInfinite)
-            styleResolver->style()->setMarqueeLoopCount(-1); // -1 means repeat forever.
-        else if (primitiveValue.isNumber())
-            styleResolver->style()->setMarqueeLoopCount(primitiveValue.getIntValue());
-    }
-    static PropertyHandler createHandler()
-    {
-        PropertyHandler handler = ApplyPropertyDefault<int, &RenderStyle::marqueeLoopCount, int, &RenderStyle::setMarqueeLoopCount, int, &RenderStyle::initialMarqueeLoopCount>::createHandler();
-        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
-    }
-};
-
-class ApplyPropertyTextUnderlinePosition {
-public:
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        // This is true if value is 'auto' or 'alphabetic'.
-        if (is<CSSPrimitiveValue>(*value)) {
-            TextUnderlinePosition t = downcast<CSSPrimitiveValue>(*value);
-            styleResolver->style()->setTextUnderlinePosition(t);
-            return;
-        }
-
-        unsigned t = 0;
-        if (is<CSSValueList>(*value)) {
-            for (auto& currentValue : downcast<CSSValueList>(*value)) {
-                TextUnderlinePosition t2 = downcast<CSSPrimitiveValue>(currentValue.get());
-                t |= t2;
-            }
-        }
-        styleResolver->style()->setTextUnderlinePosition(static_cast<TextUnderlinePosition>(t));
-    }
-    static PropertyHandler createHandler()
-    {
-        PropertyHandler handler = ApplyPropertyDefaultBase<TextUnderlinePosition, &RenderStyle::textUnderlinePosition, TextUnderlinePosition, &RenderStyle::setTextUnderlinePosition, TextUnderlinePosition, &RenderStyle::initialTextUnderlinePosition>::createHandler();
-        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
-    }
-};
-
-class ApplyPropertyLineHeight {
-public:
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        if (!is<CSSPrimitiveValue>(*value))
-            return;
-
-        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-        Length lineHeight;
-
-        if (primitiveValue.getValueID() == CSSValueNormal)
-            lineHeight = RenderStyle::initialLineHeight();
-        else if (primitiveValue.isLength())
-            lineHeight = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
-        else if (primitiveValue.isPercentage()) {
-            // FIXME: percentage should not be restricted to an integer here.
-            lineHeight = Length((styleResolver->style()->computedFontSize() * primitiveValue.getIntValue()) / 100, Fixed);
-        } else if (primitiveValue.isNumber()) {
-            // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
-            lineHeight = Length(primitiveValue.getDoubleValue() * 100.0, Percent);
-        } else
-            return;
-        styleResolver->style()->setLineHeight(lineHeight);
-    }
-    static PropertyHandler createHandler()
-    {
-        PropertyHandler handler = ApplyPropertyDefaultBase<const Length&, &RenderStyle::specifiedLineHeight, Length, &RenderStyle::setLineHeight, Length, &RenderStyle::initialLineHeight>::createHandler();
-        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
-    }
-};
-
-#if ENABLE(IOS_TEXT_AUTOSIZING)
-// FIXME: Share more code with class ApplyPropertyLineHeight.
-class ApplyPropertyLineHeightForIOSTextAutosizing {
-public:
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        if (!is<CSSPrimitiveValue>(*value))
-            return;
-
-        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-        Length lineHeight;
-
-        if (primitiveValue.getValueID() == CSSValueNormal)
-            lineHeight = RenderStyle::initialLineHeight();
-        else if (primitiveValue.isLength()) {
-            lineHeight = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
-            if (styleResolver->style()->textSizeAdjust().isPercentage())
-                lineHeight = Length(lineHeight.value() * styleResolver->style()->textSizeAdjust().multiplier(), Fixed);
-        } else if (primitiveValue.isPercentage()) {
-            // FIXME: percentage should not be restricted to an integer here.
-            lineHeight = Length((styleResolver->style()->fontSize() * primitiveValue.getIntValue()) / 100, Fixed);
-        } else if (primitiveValue.isNumber()) {
-            // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
-            if (styleResolver->style()->textSizeAdjust().isPercentage())
-                lineHeight = Length(primitiveValue.getDoubleValue() * styleResolver->style()->textSizeAdjust().multiplier() * 100.0, Percent);
-            else
-                lineHeight = Length(primitiveValue.getDoubleValue() * 100.0, Percent);
-        } else
-            return;
-        styleResolver->style()->setLineHeight(lineHeight);
-        styleResolver->style()->setSpecifiedLineHeight(lineHeight);
-    }
-
-    static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
-    {
-        styleResolver->style()->setLineHeight(RenderStyle::initialLineHeight());
-        styleResolver->style()->setSpecifiedLineHeight(RenderStyle::initialSpecifiedLineHeight());
-    }
-
-    static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
-    {
-        styleResolver->style()->setLineHeight(styleResolver->parentStyle()->lineHeight());
-        styleResolver->style()->setSpecifiedLineHeight(styleResolver->parentStyle()->specifiedLineHeight());
-    }
-
-    static PropertyHandler createHandler()
-    {
-        return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
-    }
-};
-#endif
-
-class ApplyPropertyWordSpacing {
-public:
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        if (!is<CSSPrimitiveValue>(*value))
-            return;
-
-        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-        Length wordSpacing;
-
-        if (primitiveValue.getValueID() == CSSValueNormal)
-            wordSpacing = RenderStyle::initialWordSpacing();
-        else if (primitiveValue.isLength()) {
-            wordSpacing = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
-        } else if (primitiveValue.isPercentage())
-            wordSpacing = Length(clampTo<float>(primitiveValue.getDoubleValue(), minValueForCssLength, maxValueForCssLength), Percent);
-        else if (primitiveValue.isNumber())
-            wordSpacing = Length(primitiveValue.getDoubleValue(), Fixed);
-        else
-            return;
-        styleResolver->style()->setWordSpacing(wordSpacing);
-    }
-    static PropertyHandler createHandler()
-    {
-        PropertyHandler handler = ApplyPropertyDefaultBase<const Length&, &RenderStyle::wordSpacing, Length, &RenderStyle::setWordSpacing, Length, &RenderStyle::initialWordSpacing>::createHandler();
-        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
-    }
-};
-
 class ApplyPropertyTextEmphasisStyle {
 public:
     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
@@ -1404,18 +1237,12 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder()
     setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());
     setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::createHandler());
     setPropertyHandler(CSSPropertyFontWeight, ApplyPropertyFontWeight::createHandler());
-#if ENABLE(IOS_TEXT_AUTOSIZING)
-    setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeightForIOSTextAutosizing::createHandler());
-#else
-    setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeight::createHandler());
-#endif
     setPropertyHandler(CSSPropertyListStyleImage, ApplyPropertyStyleImage<&RenderStyle::listStyleImage, &RenderStyle::setListStyleImage, &RenderStyle::initialListStyleImage, CSSPropertyListStyleImage>::createHandler());
     setPropertyHandler(CSSPropertyOrphans, ApplyPropertyAuto<short, &RenderStyle::orphans, &RenderStyle::setOrphans, &RenderStyle::hasAutoOrphans, &RenderStyle::setHasAutoOrphans>::createHandler());
     setPropertyHandler(CSSPropertyOutlineColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::outlineColor, &RenderStyle::setOutlineColor, &RenderStyle::setVisitedLinkOutlineColor, &RenderStyle::color>::createHandler());
     setPropertyHandler(CSSPropertyOutlineStyle, ApplyPropertyOutlineStyle::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextDecorationColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textDecorationColor, &RenderStyle::setTextDecorationColor, &RenderStyle::setVisitedLinkTextDecorationColor, &RenderStyle::color>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextDecorationSkip, ApplyPropertyTextDecorationSkip::createHandler());
-    setPropertyHandler(CSSPropertyWebkitTextUnderlinePosition, ApplyPropertyTextUnderlinePosition::createHandler());
     setPropertyHandler(CSSPropertyTextRendering, ApplyPropertyFont<TextRenderingMode, &FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering>::createHandler());
 
     setPropertyHandler(CSSPropertyAnimationDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSToStyleMap::mapAnimationDelay, &RenderStyle::accessAnimations, &RenderStyle::animations>::createHandler());
@@ -1447,7 +1274,6 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder()
     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(CSSPropertyWebkitMarqueeRepetition, ApplyPropertyMarqueeRepetition::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(CSSPropertyWebkitMaskImage, ApplyPropertyFillLayer<StyleImage*, CSSPropertyWebkitMaskImage, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSToStyleMap::mapFillImage>::createHandler());
@@ -1468,7 +1294,6 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder()
     setPropertyHandler(CSSPropertyWebkitTransitionProperty, ApplyPropertyAnimation<CSSPropertyID, &Animation::property, &Animation::setProperty, &Animation::isPropertySet, &Animation::clearProperty, &Animation::initialAnimationProperty, &CSSToStyleMap::mapAnimationProperty, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTransitionTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
     setPropertyHandler(CSSPropertyWidows, ApplyPropertyAuto<short, &RenderStyle::widows, &RenderStyle::setWidows, &RenderStyle::hasAutoWidows, &RenderStyle::setHasAutoWidows>::createHandler());
-    setPropertyHandler(CSSPropertyWordSpacing, ApplyPropertyWordSpacing::createHandler());
 
     setPropertyHandler(CSSPropertyZIndex, ApplyPropertyAuto<int, &RenderStyle::zIndex, &RenderStyle::setZIndex, &RenderStyle::hasAutoZIndex, &RenderStyle::setHasAutoZIndex>::createHandler());
 }
index 63e3eb3..9a836cd 100644 (file)
@@ -63,7 +63,9 @@ public:
     static ETextAlign convertTextAlign(StyleResolver&, CSSValue&);
     static PassRefPtr<ClipPathOperation> convertClipPath(StyleResolver&, CSSValue&);
     static EResize convertResize(StyleResolver&, CSSValue&);
+    static int convertMarqueeRepetition(StyleResolver&, CSSValue&);
     static int convertMarqueeSpeed(StyleResolver&, CSSValue&);
+    static TextUnderlinePosition convertTextUnderlinePosition(StyleResolver&, CSSValue&);
 
 private:
     static Length convertToRadiusLength(CSSToLengthConversionData&, CSSPrimitiveValue&);
@@ -388,6 +390,16 @@ inline EResize StyleBuilderConverter::convertResize(StyleResolver& styleResolver
     return resize;
 }
 
+inline int StyleBuilderConverter::convertMarqueeRepetition(StyleResolver&, CSSValue& value)
+{
+    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+    if (primitiveValue.getValueID() == CSSValueInfinite)
+        return -1; // -1 means repeat forever.
+
+    ASSERT(primitiveValue.isNumber());
+    return primitiveValue.getIntValue();
+}
+
 inline int StyleBuilderConverter::convertMarqueeSpeed(StyleResolver&, CSSValue& value)
 {
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
@@ -417,6 +429,20 @@ inline int StyleBuilderConverter::convertMarqueeSpeed(StyleResolver&, CSSValue&
     return speed;
 }
 
+inline TextUnderlinePosition StyleBuilderConverter::convertTextUnderlinePosition(StyleResolver&, CSSValue& value)
+{
+    // This is true if value is 'auto' or 'alphabetic'.
+    if (is<CSSPrimitiveValue>(value))
+        return downcast<CSSPrimitiveValue>(value);
+
+    unsigned combinedPosition = 0;
+    for (auto& currentValue : downcast<CSSValueList>(value)) {
+        TextUnderlinePosition position = downcast<CSSPrimitiveValue>(currentValue.get());
+        combinedPosition |= position;
+    }
+    return static_cast<TextUnderlinePosition>(combinedPosition);
+}
+
 } // namespace WebCore
 
 #endif // StyleBuilderConverter_h
index 3a15818..58161df 100644 (file)
@@ -31,6 +31,7 @@
 #include "CSSImageGeneratorValue.h"
 #include "CSSImageSetValue.h"
 #include "CSSImageValue.h"
+#include "Frame.h"
 #include "StyleResolver.h"
 
 namespace WebCore {
@@ -71,7 +72,7 @@ inline void applyValueDirection(StyleResolver& styleResolver, CSSValue& value)
         element->document().setDirectionSetOnDocumentElement(true);
 }
 
-static inline void resetEffectiveZoom(StyleResolver& styleResolver)
+inline void resetEffectiveZoom(StyleResolver& styleResolver)
 {
     // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect.
     styleResolver.setEffectiveZoom(styleResolver.parentStyle() ? styleResolver.parentStyle()->effectiveZoom() : RenderStyle::initialZoom());
@@ -149,12 +150,12 @@ inline void applyValueWebkitShapeOutside(StyleResolver& styleResolver, CSSValue&
 }
 #endif // ENABLE(CSS_SHAPES)
 
-static inline Length mmLength(double mm)
+inline Length mmLength(double mm)
 {
     Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM));
     return value.get().computeLength<Length>(CSSToLengthConversionData());
 }
-static inline Length inchLength(double inch)
+inline Length inchLength(double inch)
 {
     Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(inch, CSSPrimitiveValue::CSS_IN));
     return value.get().computeLength<Length>(CSSToLengthConversionData());
@@ -502,6 +503,93 @@ DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Repeat)
 DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Slice)
 DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Width)
 
+inline CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver)
+{
+    if (Frame* frame = styleResolver.document().frame())
+        return styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(styleResolver.style()->effectiveZoom() * frame->textZoomFactor());
+
+    return styleResolver.state().cssToLengthConversionData();
+}
+
+inline bool convertLineHeight(StyleResolver& styleResolver, const CSSValue& value, Length& length, float multiplier = 1.f)
+{
+    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+    if (primitiveValue.getValueID() == CSSValueNormal) {
+        length = RenderStyle::initialLineHeight();
+        return true;
+    }
+    if (primitiveValue.isLength()) {
+        length = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(styleResolver));
+        return true;
+    }
+    if (primitiveValue.isPercentage()) {
+        // FIXME: percentage should not be restricted to an integer here.
+        length = Length((styleResolver.style()->computedFontSize() * primitiveValue.getIntValue()) * multiplier / 100, Fixed);
+        return true;
+    }
+    if (primitiveValue.isNumber()) {
+        // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
+        length = Length(primitiveValue.getDoubleValue() * multiplier * 100.0, Percent);
+        return true;
+    }
+    return false;
+}
+
+inline void applyValueWordSpacing(StyleResolver& styleResolver, CSSValue& value)
+{
+    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+
+    Length wordSpacing;
+    if (primitiveValue.getValueID() == CSSValueNormal)
+        wordSpacing = RenderStyle::initialWordSpacing();
+    else if (primitiveValue.isLength())
+        wordSpacing = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(styleResolver));
+    else if (primitiveValue.isPercentage())
+        wordSpacing = Length(clampTo<float>(primitiveValue.getDoubleValue(), minValueForCssLength, maxValueForCssLength), Percent);
+    else if (primitiveValue.isNumber())
+        wordSpacing = Length(primitiveValue.getDoubleValue(), Fixed);
+    else
+        return;
+    styleResolver.style()->setWordSpacing(wordSpacing);
+}
+
+#if ENABLE(IOS_TEXT_AUTOSIZING)
+
+inline void applyInheritLineHeight(StyleResolver& styleResolver)
+{
+    styleResolver.style()->setLineHeight(styleResolver.parentStyle()->lineHeight());
+    styleResolver.style()->setSpecifiedLineHeight(styleResolver.parentStyle()->specifiedLineHeight());
+}
+
+inline void applyInitialLineHeight(StyleResolver& styleResolver)
+{
+    styleResolver.style()->setLineHeight(RenderStyle::initialLineHeight());
+    styleResolver.style()->setSpecifiedLineHeight(RenderStyle::initialSpecifiedLineHeight());
+}
+
+inline void applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)
+{
+    Length lineHeight;
+    if (!convertLineHeight(styleResolver, value, lineHeight, styleResolver.style()->textSizeAdjust().multiplier()))
+        return;
+
+    styleResolver.style()->setLineHeight(lineHeight);
+    styleResolver.style()->setSpecifiedLineHeight(lineHeight);
+}
+
+#else
+
+inline void applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)
+{
+    Length lineHeight;
+    if (!convertLineHeight(styleResolver, value, lineHeight))
+        return;
+
+    styleResolver.style()->setLineHeight(lineHeight);
+}
+
+#endif
+
 } // namespace StyleBuilderFunctions
 
 } // namespace WebCore