⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 176202 in webkit


Ignore:
Timestamp:
Nov 17, 2014, 8:43:59 AM (12 years ago)
Author:
Chris Dumez
Message:

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):

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176201 r176202  
     12014-11-17  Chris Dumez  <cdumez@apple.com>
     2
     3        Move more CSS properties to the new StyleBuilder
     4        https://bugs.webkit.org/show_bug.cgi?id=138766
     5
     6        Reviewed by Darin Adler.
     7
     8        Move more CSS properties from DeprecatedStyleBuilder to the new
     9        StyleBuilder:
     10        line-height
     11        word-spacing
     12        -webkit-marquee-repetition
     13        -webkit-text-underline-position
     14
     15        No new tests, no behavior change.
     16
     17        * css/CSSPropertyNames.in:
     18        * css/DeprecatedStyleBuilder.cpp:
     19        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
     20        (WebCore::csstoLengthConversionDataWithTextZoomFactor): Deleted.
     21        (WebCore::ApplyPropertyMarqueeRepetition::applyValue): Deleted.
     22        (WebCore::ApplyPropertyMarqueeRepetition::createHandler): Deleted.
     23        (WebCore::ApplyPropertyTextUnderlinePosition::applyValue): Deleted.
     24        (WebCore::ApplyPropertyTextUnderlinePosition::createHandler): Deleted.
     25        (WebCore::ApplyPropertyLineHeight::applyValue): Deleted.
     26        (WebCore::ApplyPropertyLineHeight::createHandler): Deleted.
     27        (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyValue): Deleted.
     28        (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyInitialValue): Deleted.
     29        (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::applyInheritValue): Deleted.
     30        (WebCore::ApplyPropertyLineHeightForIOSTextAutosizing::createHandler): Deleted.
     31        (WebCore::ApplyPropertyWordSpacing::applyValue): Deleted.
     32        (WebCore::ApplyPropertyWordSpacing::createHandler): Deleted.
     33        * css/StyleBuilderConverter.h:
     34        (WebCore::StyleBuilderConverter::convertMarqueeRepetition):
     35        (WebCore::StyleBuilderConverter::convertTextUnderlinePosition):
     36        * css/StyleBuilderCustom.h:
     37        (WebCore::StyleBuilderFunctions::csstoLengthConversionDataWithTextZoomFactor):
     38        (WebCore::StyleBuilderFunctions::convertLineHeight):
     39        (WebCore::StyleBuilderFunctions::applyValueWordSpacing):
     40        (WebCore::StyleBuilderFunctions::applyInheritLineHeight):
     41        (WebCore::StyleBuilderFunctions::applyInitialLineHeight):
     42        (WebCore::StyleBuilderFunctions::applyValueLineHeight):
     43
    1442014-11-16  Andreas Kling  <akling@apple.com>
    245
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r176168 r176202  
    8181
    8282// line height needs to be right after the above high-priority properties
    83 line-height [Inherited]
     83#if defined(ENABLE_IOS_TEXT_AUTOSIZING) && ENABLE_IOS_TEXT_AUTOSIZING
     84line-height [Inherited, NewStyleBuilder, Custom=All]
     85#else
     86line-height [Inherited, NewStyleBuilder, Getter=specifiedLineHeight, Custom=Value]
     87#endif
    8488
    8589// Keep this in between the highest priority props and the lower ones.
     
    263267word-break [Inherited, NewStyleBuilder]
    264268-epub-word-break = word-break
    265 word-spacing [Inherited]
     269word-spacing [Inherited, NewStyleBuilder, Custom=Value]
    266270word-wrap [Inherited, NewStyleBuilder=EOverflowWrap, NameForMethods=OverflowWrap]
    267271z-index
     
    430434-webkit-marquee-direction [NewStyleBuilder]
    431435-webkit-marquee-increment [NewStyleBuilder, Custom=Value]
    432 -webkit-marquee-repetition
     436-webkit-marquee-repetition [NewStyleBuilder, NameForMethods=MarqueeLoopCount, Converter=MarqueeRepetition]
    433437-webkit-marquee-speed [NewStyleBuilder, Converter=MarqueeSpeed]
    434438-webkit-marquee-style [NewStyleBuilder, TypeName=EMarqueeBehavior, NameForMethods=MarqueeBehavior]
     
    487491-webkit-text-decoration-color
    488492-webkit-text-decoration-skip [Inherited]
    489 -webkit-text-underline-position [Inherited]
     493-webkit-text-underline-position [Inherited, NewStyleBuilder, Converter=TextUnderlinePosition]
    490494-webkit-text-decorations-in-effect [Inherited]
    491495-webkit-text-emphasis [Inherited]
  • trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp

    r176168 r176202  
    926926}
    927927
    928 static inline CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver)
    929 {
    930     if (Frame* frame = styleResolver.document().frame())
    931         return styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(styleResolver.style()->effectiveZoom() * frame->textZoomFactor());
    932 
    933     return styleResolver.state().cssToLengthConversionData();
    934 }
    935 
    936928class ApplyPropertyTextDecorationSkip {
    937929public:
     
    953945    {
    954946        PropertyHandler handler = ApplyPropertyDefaultBase<TextDecorationSkip, &RenderStyle::textDecorationSkip, TextDecorationSkip, &RenderStyle::setTextDecorationSkip, TextDecorationSkip, &RenderStyle::initialTextDecorationSkip>::createHandler();
    955         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
    956     }
    957 };
    958 
    959 class ApplyPropertyMarqueeRepetition {
    960 public:
    961     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
    962     {
    963         if (!is<CSSPrimitiveValue>(*value))
    964             return;
    965 
    966         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
    967         if (primitiveValue.getValueID() == CSSValueInfinite)
    968             styleResolver->style()->setMarqueeLoopCount(-1); // -1 means repeat forever.
    969         else if (primitiveValue.isNumber())
    970             styleResolver->style()->setMarqueeLoopCount(primitiveValue.getIntValue());
    971     }
    972     static PropertyHandler createHandler()
    973     {
    974         PropertyHandler handler = ApplyPropertyDefault<int, &RenderStyle::marqueeLoopCount, int, &RenderStyle::setMarqueeLoopCount, int, &RenderStyle::initialMarqueeLoopCount>::createHandler();
    975         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
    976     }
    977 };
    978 
    979 class ApplyPropertyTextUnderlinePosition {
    980 public:
    981     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
    982     {
    983         // This is true if value is 'auto' or 'alphabetic'.
    984         if (is<CSSPrimitiveValue>(*value)) {
    985             TextUnderlinePosition t = downcast<CSSPrimitiveValue>(*value);
    986             styleResolver->style()->setTextUnderlinePosition(t);
    987             return;
    988         }
    989 
    990         unsigned t = 0;
    991         if (is<CSSValueList>(*value)) {
    992             for (auto& currentValue : downcast<CSSValueList>(*value)) {
    993                 TextUnderlinePosition t2 = downcast<CSSPrimitiveValue>(currentValue.get());
    994                 t |= t2;
    995             }
    996         }
    997         styleResolver->style()->setTextUnderlinePosition(static_cast<TextUnderlinePosition>(t));
    998     }
    999     static PropertyHandler createHandler()
    1000     {
    1001         PropertyHandler handler = ApplyPropertyDefaultBase<TextUnderlinePosition, &RenderStyle::textUnderlinePosition, TextUnderlinePosition, &RenderStyle::setTextUnderlinePosition, TextUnderlinePosition, &RenderStyle::initialTextUnderlinePosition>::createHandler();
    1002         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
    1003     }
    1004 };
    1005 
    1006 class ApplyPropertyLineHeight {
    1007 public:
    1008     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
    1009     {
    1010         if (!is<CSSPrimitiveValue>(*value))
    1011             return;
    1012 
    1013         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
    1014         Length lineHeight;
    1015 
    1016         if (primitiveValue.getValueID() == CSSValueNormal)
    1017             lineHeight = RenderStyle::initialLineHeight();
    1018         else if (primitiveValue.isLength())
    1019             lineHeight = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
    1020         else if (primitiveValue.isPercentage()) {
    1021             // FIXME: percentage should not be restricted to an integer here.
    1022             lineHeight = Length((styleResolver->style()->computedFontSize() * primitiveValue.getIntValue()) / 100, Fixed);
    1023         } else if (primitiveValue.isNumber()) {
    1024             // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
    1025             lineHeight = Length(primitiveValue.getDoubleValue() * 100.0, Percent);
    1026         } else
    1027             return;
    1028         styleResolver->style()->setLineHeight(lineHeight);
    1029     }
    1030     static PropertyHandler createHandler()
    1031     {
    1032         PropertyHandler handler = ApplyPropertyDefaultBase<const Length&, &RenderStyle::specifiedLineHeight, Length, &RenderStyle::setLineHeight, Length, &RenderStyle::initialLineHeight>::createHandler();
    1033         return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
    1034     }
    1035 };
    1036 
    1037 #if ENABLE(IOS_TEXT_AUTOSIZING)
    1038 // FIXME: Share more code with class ApplyPropertyLineHeight.
    1039 class ApplyPropertyLineHeightForIOSTextAutosizing {
    1040 public:
    1041     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
    1042     {
    1043         if (!is<CSSPrimitiveValue>(*value))
    1044             return;
    1045 
    1046         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
    1047         Length lineHeight;
    1048 
    1049         if (primitiveValue.getValueID() == CSSValueNormal)
    1050             lineHeight = RenderStyle::initialLineHeight();
    1051         else if (primitiveValue.isLength()) {
    1052             lineHeight = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
    1053             if (styleResolver->style()->textSizeAdjust().isPercentage())
    1054                 lineHeight = Length(lineHeight.value() * styleResolver->style()->textSizeAdjust().multiplier(), Fixed);
    1055         } else if (primitiveValue.isPercentage()) {
    1056             // FIXME: percentage should not be restricted to an integer here.
    1057             lineHeight = Length((styleResolver->style()->fontSize() * primitiveValue.getIntValue()) / 100, Fixed);
    1058         } else if (primitiveValue.isNumber()) {
    1059             // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
    1060             if (styleResolver->style()->textSizeAdjust().isPercentage())
    1061                 lineHeight = Length(primitiveValue.getDoubleValue() * styleResolver->style()->textSizeAdjust().multiplier() * 100.0, Percent);
    1062             else
    1063                 lineHeight = Length(primitiveValue.getDoubleValue() * 100.0, Percent);
    1064         } else
    1065             return;
    1066         styleResolver->style()->setLineHeight(lineHeight);
    1067         styleResolver->style()->setSpecifiedLineHeight(lineHeight);
    1068     }
    1069 
    1070     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
    1071     {
    1072         styleResolver->style()->setLineHeight(RenderStyle::initialLineHeight());
    1073         styleResolver->style()->setSpecifiedLineHeight(RenderStyle::initialSpecifiedLineHeight());
    1074     }
    1075 
    1076     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
    1077     {
    1078         styleResolver->style()->setLineHeight(styleResolver->parentStyle()->lineHeight());
    1079         styleResolver->style()->setSpecifiedLineHeight(styleResolver->parentStyle()->specifiedLineHeight());
    1080     }
    1081 
    1082     static PropertyHandler createHandler()
    1083     {
    1084         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
    1085     }
    1086 };
    1087 #endif
    1088 
    1089 class ApplyPropertyWordSpacing {
    1090 public:
    1091     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
    1092     {
    1093         if (!is<CSSPrimitiveValue>(*value))
    1094             return;
    1095 
    1096         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
    1097         Length wordSpacing;
    1098 
    1099         if (primitiveValue.getValueID() == CSSValueNormal)
    1100             wordSpacing = RenderStyle::initialWordSpacing();
    1101         else if (primitiveValue.isLength()) {
    1102             wordSpacing = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(*styleResolver));
    1103         } else if (primitiveValue.isPercentage())
    1104             wordSpacing = Length(clampTo<float>(primitiveValue.getDoubleValue(), minValueForCssLength, maxValueForCssLength), Percent);
    1105         else if (primitiveValue.isNumber())
    1106             wordSpacing = Length(primitiveValue.getDoubleValue(), Fixed);
    1107         else
    1108             return;
    1109         styleResolver->style()->setWordSpacing(wordSpacing);
    1110     }
    1111     static PropertyHandler createHandler()
    1112     {
    1113         PropertyHandler handler = ApplyPropertyDefaultBase<const Length&, &RenderStyle::wordSpacing, Length, &RenderStyle::setWordSpacing, Length, &RenderStyle::initialWordSpacing>::createHandler();
    1114947        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
    1115948    }
     
    14051238    setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::createHandler());
    14061239    setPropertyHandler(CSSPropertyFontWeight, ApplyPropertyFontWeight::createHandler());
    1407 #if ENABLE(IOS_TEXT_AUTOSIZING)
    1408     setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeightForIOSTextAutosizing::createHandler());
    1409 #else
    1410     setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeight::createHandler());
    1411 #endif
    14121240    setPropertyHandler(CSSPropertyListStyleImage, ApplyPropertyStyleImage<&RenderStyle::listStyleImage, &RenderStyle::setListStyleImage, &RenderStyle::initialListStyleImage, CSSPropertyListStyleImage>::createHandler());
    14131241    setPropertyHandler(CSSPropertyOrphans, ApplyPropertyAuto<short, &RenderStyle::orphans, &RenderStyle::setOrphans, &RenderStyle::hasAutoOrphans, &RenderStyle::setHasAutoOrphans>::createHandler());
     
    14161244    setPropertyHandler(CSSPropertyWebkitTextDecorationColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textDecorationColor, &RenderStyle::setTextDecorationColor, &RenderStyle::setVisitedLinkTextDecorationColor, &RenderStyle::color>::createHandler());
    14171245    setPropertyHandler(CSSPropertyWebkitTextDecorationSkip, ApplyPropertyTextDecorationSkip::createHandler());
    1418     setPropertyHandler(CSSPropertyWebkitTextUnderlinePosition, ApplyPropertyTextUnderlinePosition::createHandler());
    14191246    setPropertyHandler(CSSPropertyTextRendering, ApplyPropertyFont<TextRenderingMode, &FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering>::createHandler());
    14201247
     
    14481275    setPropertyHandler(CSSPropertyWebkitFontSmoothing, ApplyPropertyFont<FontSmoothingMode, &FontDescription::fontSmoothing, &FontDescription::setFontSmoothing, AutoSmoothing>::createHandler());
    14491276    setPropertyHandler(CSSPropertyWebkitFontVariantLigatures, ApplyPropertyFontVariantLigatures::createHandler());
    1450     setPropertyHandler(CSSPropertyWebkitMarqueeRepetition, ApplyPropertyMarqueeRepetition::createHandler());
    14511277    setPropertyHandler(CSSPropertyWebkitMaskClip, ApplyPropertyFillLayer<EFillBox, CSSPropertyWebkitMaskClip, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isClipSet, &FillLayer::clip, &FillLayer::setClip, &FillLayer::clearClip, &FillLayer::initialFillClip, &CSSToStyleMap::mapFillClip>::createHandler());
    14521278    setPropertyHandler(CSSPropertyWebkitMaskComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitMaskComposite, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSToStyleMap::mapFillComposite>::createHandler());
     
    14691295    setPropertyHandler(CSSPropertyWebkitTransitionTimingFunction, ApplyPropertyAnimation<const PassRefPtr<TimingFunction>, &Animation::timingFunction, &Animation::setTimingFunction, &Animation::isTimingFunctionSet, &Animation::clearTimingFunction, &Animation::initialAnimationTimingFunction, &CSSToStyleMap::mapAnimationTimingFunction, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
    14701296    setPropertyHandler(CSSPropertyWidows, ApplyPropertyAuto<short, &RenderStyle::widows, &RenderStyle::setWidows, &RenderStyle::hasAutoWidows, &RenderStyle::setHasAutoWidows>::createHandler());
    1471     setPropertyHandler(CSSPropertyWordSpacing, ApplyPropertyWordSpacing::createHandler());
    14721297
    14731298    setPropertyHandler(CSSPropertyZIndex, ApplyPropertyAuto<int, &RenderStyle::zIndex, &RenderStyle::setZIndex, &RenderStyle::hasAutoZIndex, &RenderStyle::setHasAutoZIndex>::createHandler());
  • trunk/Source/WebCore/css/StyleBuilderConverter.h

    r175932 r176202  
    6464    static PassRefPtr<ClipPathOperation> convertClipPath(StyleResolver&, CSSValue&);
    6565    static EResize convertResize(StyleResolver&, CSSValue&);
     66    static int convertMarqueeRepetition(StyleResolver&, CSSValue&);
    6667    static int convertMarqueeSpeed(StyleResolver&, CSSValue&);
     68    static TextUnderlinePosition convertTextUnderlinePosition(StyleResolver&, CSSValue&);
    6769
    6870private:
     
    387389
    388390    return resize;
     391}
     392
     393inline int StyleBuilderConverter::convertMarqueeRepetition(StyleResolver&, CSSValue& value)
     394{
     395    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     396    if (primitiveValue.getValueID() == CSSValueInfinite)
     397        return -1; // -1 means repeat forever.
     398
     399    ASSERT(primitiveValue.isNumber());
     400    return primitiveValue.getIntValue();
    389401}
    390402
     
    418430}
    419431
     432inline TextUnderlinePosition StyleBuilderConverter::convertTextUnderlinePosition(StyleResolver&, CSSValue& value)
     433{
     434    // This is true if value is 'auto' or 'alphabetic'.
     435    if (is<CSSPrimitiveValue>(value))
     436        return downcast<CSSPrimitiveValue>(value);
     437
     438    unsigned combinedPosition = 0;
     439    for (auto& currentValue : downcast<CSSValueList>(value)) {
     440        TextUnderlinePosition position = downcast<CSSPrimitiveValue>(currentValue.get());
     441        combinedPosition |= position;
     442    }
     443    return static_cast<TextUnderlinePosition>(combinedPosition);
     444}
     445
    420446} // namespace WebCore
    421447
  • trunk/Source/WebCore/css/StyleBuilderCustom.h

    r176168 r176202  
    3232#include "CSSImageSetValue.h"
    3333#include "CSSImageValue.h"
     34#include "Frame.h"
    3435#include "StyleResolver.h"
    3536
     
    7273}
    7374
    74 static inline void resetEffectiveZoom(StyleResolver& styleResolver)
     75inline void resetEffectiveZoom(StyleResolver& styleResolver)
    7576{
    7677    // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect.
     
    150151#endif // ENABLE(CSS_SHAPES)
    151152
    152 static inline Length mmLength(double mm)
     153inline Length mmLength(double mm)
    153154{
    154155    Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM));
    155156    return value.get().computeLength<Length>(CSSToLengthConversionData());
    156157}
    157 static inline Length inchLength(double inch)
     158inline Length inchLength(double inch)
    158159{
    159160    Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(inch, CSSPrimitiveValue::CSS_IN));
     
    503504DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Width)
    504505
     506inline CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver)
     507{
     508    if (Frame* frame = styleResolver.document().frame())
     509        return styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(styleResolver.style()->effectiveZoom() * frame->textZoomFactor());
     510
     511    return styleResolver.state().cssToLengthConversionData();
     512}
     513
     514inline bool convertLineHeight(StyleResolver& styleResolver, const CSSValue& value, Length& length, float multiplier = 1.f)
     515{
     516    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     517    if (primitiveValue.getValueID() == CSSValueNormal) {
     518        length = RenderStyle::initialLineHeight();
     519        return true;
     520    }
     521    if (primitiveValue.isLength()) {
     522        length = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(styleResolver));
     523        return true;
     524    }
     525    if (primitiveValue.isPercentage()) {
     526        // FIXME: percentage should not be restricted to an integer here.
     527        length = Length((styleResolver.style()->computedFontSize() * primitiveValue.getIntValue()) * multiplier / 100, Fixed);
     528        return true;
     529    }
     530    if (primitiveValue.isNumber()) {
     531        // FIXME: number and percentage values should produce the same type of Length (ie. Fixed or Percent).
     532        length = Length(primitiveValue.getDoubleValue() * multiplier * 100.0, Percent);
     533        return true;
     534    }
     535    return false;
     536}
     537
     538inline void applyValueWordSpacing(StyleResolver& styleResolver, CSSValue& value)
     539{
     540    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     541
     542    Length wordSpacing;
     543    if (primitiveValue.getValueID() == CSSValueNormal)
     544        wordSpacing = RenderStyle::initialWordSpacing();
     545    else if (primitiveValue.isLength())
     546        wordSpacing = primitiveValue.computeLength<Length>(csstoLengthConversionDataWithTextZoomFactor(styleResolver));
     547    else if (primitiveValue.isPercentage())
     548        wordSpacing = Length(clampTo<float>(primitiveValue.getDoubleValue(), minValueForCssLength, maxValueForCssLength), Percent);
     549    else if (primitiveValue.isNumber())
     550        wordSpacing = Length(primitiveValue.getDoubleValue(), Fixed);
     551    else
     552        return;
     553    styleResolver.style()->setWordSpacing(wordSpacing);
     554}
     555
     556#if ENABLE(IOS_TEXT_AUTOSIZING)
     557
     558inline void applyInheritLineHeight(StyleResolver& styleResolver)
     559{
     560    styleResolver.style()->setLineHeight(styleResolver.parentStyle()->lineHeight());
     561    styleResolver.style()->setSpecifiedLineHeight(styleResolver.parentStyle()->specifiedLineHeight());
     562}
     563
     564inline void applyInitialLineHeight(StyleResolver& styleResolver)
     565{
     566    styleResolver.style()->setLineHeight(RenderStyle::initialLineHeight());
     567    styleResolver.style()->setSpecifiedLineHeight(RenderStyle::initialSpecifiedLineHeight());
     568}
     569
     570inline void applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)
     571{
     572    Length lineHeight;
     573    if (!convertLineHeight(styleResolver, value, lineHeight, styleResolver.style()->textSizeAdjust().multiplier()))
     574        return;
     575
     576    styleResolver.style()->setLineHeight(lineHeight);
     577    styleResolver.style()->setSpecifiedLineHeight(lineHeight);
     578}
     579
     580#else
     581
     582inline void applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)
     583{
     584    Length lineHeight;
     585    if (!convertLineHeight(styleResolver, value, lineHeight))
     586        return;
     587
     588    styleResolver.style()->setLineHeight(lineHeight);
     589}
     590
     591#endif
     592
    505593} // namespace StyleBuilderFunctions
    506594
Note: See TracChangeset for help on using the changeset viewer.