Title: [175169] trunk/Source/WebCore
Revision
175169
Author
[email protected]
Date
2014-10-24 11:32:34 -0700 (Fri, 24 Oct 2014)

Log Message

Move ComputeLength CSS properties to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=138036

Reviewed by Andreas Kling.

Move ComputeLength CSS properties from DeprecatedStyleBuilder to the
new StyleBuilder so that they are now generated. 3 Converters are
provided for these properties: ComputedLength / LineWidth / Spacing.

This is inspired by the following Blink revision by
<[email protected]>:
https://src.chromium.org/viewvc/blink?view=rev&revision=154012

No new tests, no behavior change.

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyComputeLength::setValue): Deleted.
(WebCore::ApplyPropertyComputeLength::applyValue): Deleted.
(WebCore::ApplyPropertyComputeLength::createHandler): Deleted.
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertComputedLength):
(WebCore::StyleBuilderConverter::convertLineWidth):
(WebCore::StyleBuilderConverter::convertSpacing):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (175168 => 175169)


--- trunk/Source/WebCore/ChangeLog	2014-10-24 18:13:30 UTC (rev 175168)
+++ trunk/Source/WebCore/ChangeLog	2014-10-24 18:32:34 UTC (rev 175169)
@@ -1,5 +1,33 @@
 2014-10-24  Chris Dumez  <[email protected]>
 
+        Move ComputeLength CSS properties to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=138036
+
+        Reviewed by Andreas Kling.
+
+        Move ComputeLength CSS properties from DeprecatedStyleBuilder to the
+        new StyleBuilder so that they are now generated. 3 Converters are
+        provided for these properties: ComputedLength / LineWidth / Spacing.
+
+        This is inspired by the following Blink revision by
+        <[email protected]>:
+        https://src.chromium.org/viewvc/blink?view=rev&revision=154012
+
+        No new tests, no behavior change.
+
+        * css/CSSPropertyNames.in:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        (WebCore::ApplyPropertyComputeLength::setValue): Deleted.
+        (WebCore::ApplyPropertyComputeLength::applyValue): Deleted.
+        (WebCore::ApplyPropertyComputeLength::createHandler): Deleted.
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::convertComputedLength):
+        (WebCore::StyleBuilderConverter::convertLineWidth):
+        (WebCore::StyleBuilderConverter::convertSpacing):
+
+2014-10-24  Chris Dumez  <[email protected]>
+
         Make ScriptWrappable's destructor protected instead of public
         https://bugs.webkit.org/show_bug.cgi?id=138037
 

Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (175168 => 175169)


--- trunk/Source/WebCore/css/CSSPropertyNames.in	2014-10-24 18:13:30 UTC (rev 175168)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in	2014-10-24 18:32:34 UTC (rev 175169)
@@ -64,7 +64,7 @@
 border-bottom-right-radius
 -webkit-border-bottom-right-radius = border-bottom-right-radius
 border-bottom-style [NewStyleBuilder, TypeName=EBorderStyle, Initial=initialBorderStyle]
-border-bottom-width
+border-bottom-width [NewStyleBuilder, Initial=initialBorderWidth, Converter=LineWidth<float>]
 border-collapse [Inherited, NewStyleBuilder]
 border-color
 border-image
@@ -76,12 +76,12 @@
 border-left
 border-left-color
 border-left-style [NewStyleBuilder, TypeName=EBorderStyle, Initial=initialBorderStyle]
-border-left-width
+border-left-width [NewStyleBuilder, Initial=initialBorderWidth, Converter=LineWidth<float>]
 border-radius
 border-right
 border-right-color
 border-right-style [NewStyleBuilder, TypeName=EBorderStyle, Initial=initialBorderStyle]
-border-right-width
+border-right-width [NewStyleBuilder, Initial=initialBorderWidth, Converter=LineWidth<float>]
 border-spacing [Inherited]
 border-style
 border-top
@@ -91,7 +91,7 @@
 border-top-right-radius
 -webkit-border-top-right-radius = border-top-right-radius
 border-top-style [NewStyleBuilder, TypeName=EBorderStyle, Initial=initialBorderStyle]
-border-top-width
+border-top-width [NewStyleBuilder, Initial=initialBorderWidth, Converter=LineWidth<float>]
 border-width
 bottom [NewStyleBuilder, Initial=initialOffset, Converter=LengthOrAuto]
 box-shadow
@@ -122,7 +122,7 @@
 image-resolution [Inherited]
 #endif
 left [NewStyleBuilder, Initial=initialOffset, Converter=LengthOrAuto]
-letter-spacing [Inherited]
+letter-spacing [Inherited, NewStyleBuilder, Converter=Spacing]
 list-style [Inherited]
 list-style-image [Inherited]
 list-style-position [Inherited, NewStyleBuilder]
@@ -144,9 +144,9 @@
 orphans [Inherited]
 outline
 outline-color
-outline-offset
+outline-offset [NewStyleBuilder, Converter=ComputedLength<int>]
 outline-style
-outline-width
+outline-width [NewStyleBuilder, Converter=LineWidth<unsigned short>]
 overflow
 overflow-wrap [NewStyleBuilder]
 overflow-x [NewStyleBuilder, TypeName=EOverflow]
@@ -245,7 +245,7 @@
 -webkit-border-end-style
 -webkit-border-end-width
 -webkit-border-fit [NewStyleBuilder]
--webkit-border-horizontal-spacing [Inherited]
+-webkit-border-horizontal-spacing [Inherited, NewStyleBuilder, NameForMethods=HorizontalBorderSpacing, Converter=ComputedLength<short>]
 -webkit-border-image
 // -webkit-border-radius differs from border-radius only in the interpretation of
 // a value consisting of two lengths: "-webkit-border-radius: l1 l2;" is equivalent
@@ -255,7 +255,7 @@
 -webkit-border-start-color
 -webkit-border-start-style
 -webkit-border-start-width
--webkit-border-vertical-spacing [Inherited]
+-webkit-border-vertical-spacing [Inherited, NewStyleBuilder, NameForMethods=VerticalBorderSpacing, Converter=ComputedLength<short>]
 -webkit-box-align [NewStyleBuilder, TypeName=EBoxAlignment]
 -webkit-box-direction [Inherited, NewStyleBuilder]
 -webkit-box-flex [NewStyleBuilder, TypeName=float]
@@ -281,7 +281,7 @@
 -webkit-column-rule
 -webkit-column-rule-color
 -webkit-column-rule-style [NewStyleBuilder, TypeName=EBorderStyle, Initial=initialBorderStyle]
--webkit-column-rule-width
+-webkit-column-rule-width [NewStyleBuilder, Converter=LineWidth<unsigned short>]
 -webkit-column-span [NewStyleBuilder, TypeName=ColumnSpan]
 -webkit-column-width
 -webkit-columns
@@ -440,7 +440,7 @@
 -webkit-transform-origin
 -webkit-transform-origin-x [NewStyleBuilder, Converter=Length]
 -webkit-transform-origin-y [NewStyleBuilder, Converter=Length]
--webkit-transform-origin-z
+-webkit-transform-origin-z [NewStyleBuilder, Converter=ComputedLength<float>]
 -webkit-transform-style [NewStyleBuilder, TypeName=ETransformStyle3D, NameForMethods=TransformStyle3D]
 -webkit-transition
 -webkit-transition-delay

Modified: trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp (175168 => 175169)


--- trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-10-24 18:13:30 UTC (rev 175168)
+++ trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp	2014-10-24 18:32:34 UTC (rev 175169)
@@ -580,62 +580,6 @@
     static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
 };
 
-enum ComputeLengthNormal {NormalDisabled = 0, NormalEnabled};
-enum ComputeLengthThickness {ThicknessDisabled = 0, ThicknessEnabled};
-enum ComputeLengthSVGZoom {SVGZoomDisabled = 0, SVGZoomEnabled};
-template <typename T,
-          T (RenderStyle::*getterFunction)() const,
-          void (RenderStyle::*setterFunction)(T),
-          T (*initialFunction)(),
-          ComputeLengthNormal normalEnabled = NormalDisabled,
-          ComputeLengthThickness thicknessEnabled = ThicknessDisabled,
-          ComputeLengthSVGZoom svgZoomEnabled = SVGZoomDisabled>
-class ApplyPropertyComputeLength {
-public:
-    static void setValue(RenderStyle* style, T value) { (style->*setterFunction)(value); }
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        // note: CSSPropertyLetter/WordSpacing right now sets to zero if it's not a primitive value for some reason...
-        if (!is<CSSPrimitiveValue>(*value))
-            return;
-
-        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-
-        CSSValueID ident = primitiveValue.getValueID();
-        T length;
-        if (normalEnabled && ident == CSSValueNormal) {
-            length = 0;
-        } else if (thicknessEnabled && ident == CSSValueThin) {
-            length = 1;
-        } else if (thicknessEnabled && ident == CSSValueMedium) {
-            length = 3;
-        } else if (thicknessEnabled && ident == CSSValueThick) {
-            length = 5;
-        } else if (ident == CSSValueInvalid) {
-            CSSToLengthConversionData conversionData = (svgZoomEnabled && styleResolver->useSVGZoomRules()) ? styleResolver->state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f) : styleResolver->state().cssToLengthConversionData();
-
-            // Any original result that was >= 1 should not be allowed to fall below 1.
-            // This keeps border lines from vanishing.
-            length = primitiveValue.computeLength<T>(conversionData);
-            if (conversionData.zoom() < 1.0f && length < 1.0) {
-                T originalLength = primitiveValue.computeLength<T>(conversionData.copyWithAdjustedZoom(1.0f));
-                if (originalLength >= 1.0)
-                    length = 1.0;
-            }
-        } else {
-            ASSERT_NOT_REACHED();
-            length = 0;
-        }
-
-        setValue(styleResolver->style(), length);
-    }
-    static PropertyHandler createHandler()
-    {
-        PropertyHandler handler = ApplyPropertyDefaultBase<T, getterFunction, T, setterFunction, T, initialFunction>::createHandler();
-        return PropertyHandler(handler.inheritFunction(), handler.initialFunction(), &applyValue);
-    }
-};
-
 template <typename T, T (FontDescription::*getterFunction)() const, void (FontDescription::*setterFunction)(T), T initialValue>
 class ApplyPropertyFont {
 public:
@@ -2358,20 +2302,16 @@
     setPropertyHandler(CSSPropertyBorderBottomColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderBottomColor, &RenderStyle::setBorderBottomColor, &RenderStyle::setVisitedLinkBorderBottomColor, &RenderStyle::color>::createHandler());
     setPropertyHandler(CSSPropertyBorderBottomLeftRadius, ApplyPropertyBorderRadius<&RenderStyle::borderBottomLeftRadius, &RenderStyle::setBorderBottomLeftRadius, &RenderStyle::initialBorderRadius>::createHandler());
     setPropertyHandler(CSSPropertyBorderBottomRightRadius, ApplyPropertyBorderRadius<&RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius, &RenderStyle::initialBorderRadius>::createHandler());
-    setPropertyHandler(CSSPropertyBorderBottomWidth, ApplyPropertyComputeLength<float, &RenderStyle::borderBottomWidth, &RenderStyle::setBorderBottomWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     setPropertyHandler(CSSPropertyBorderImageOutset, ApplyPropertyBorderImageModifier<BorderImage, Outset>::createHandler());
     setPropertyHandler(CSSPropertyBorderImageRepeat, ApplyPropertyBorderImageModifier<BorderImage, Repeat>::createHandler());
     setPropertyHandler(CSSPropertyBorderImageSlice, ApplyPropertyBorderImageModifier<BorderImage, Slice>::createHandler());
     setPropertyHandler(CSSPropertyBorderImageSource, ApplyPropertyBorderImageSource<CSSPropertyBorderImageSource, &RenderStyle::borderImageSource, &RenderStyle::setBorderImageSource, &RenderStyle::initialBorderImageSource>::createHandler());
     setPropertyHandler(CSSPropertyBorderImageWidth, ApplyPropertyBorderImageModifier<BorderImage, Width>::createHandler());
     setPropertyHandler(CSSPropertyBorderLeftColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderLeftColor, &RenderStyle::setBorderLeftColor, &RenderStyle::setVisitedLinkBorderLeftColor, &RenderStyle::color>::createHandler());
-    setPropertyHandler(CSSPropertyBorderLeftWidth, ApplyPropertyComputeLength<float, &RenderStyle::borderLeftWidth, &RenderStyle::setBorderLeftWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     setPropertyHandler(CSSPropertyBorderRightColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderRightColor, &RenderStyle::setBorderRightColor, &RenderStyle::setVisitedLinkBorderRightColor, &RenderStyle::color>::createHandler());
-    setPropertyHandler(CSSPropertyBorderRightWidth, ApplyPropertyComputeLength<float, &RenderStyle::borderRightWidth, &RenderStyle::setBorderRightWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     setPropertyHandler(CSSPropertyBorderTopColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::borderTopColor, &RenderStyle::setBorderTopColor, &RenderStyle::setVisitedLinkBorderTopColor, &RenderStyle::color>::createHandler());
     setPropertyHandler(CSSPropertyBorderTopLeftRadius, ApplyPropertyBorderRadius<&RenderStyle::borderTopLeftRadius, &RenderStyle::setBorderTopLeftRadius, &RenderStyle::initialBorderRadius>::createHandler());
     setPropertyHandler(CSSPropertyBorderTopRightRadius, ApplyPropertyBorderRadius<&RenderStyle::borderTopRightRadius, &RenderStyle::setBorderTopRightRadius, &RenderStyle::initialBorderRadius>::createHandler());
-    setPropertyHandler(CSSPropertyBorderTopWidth, ApplyPropertyComputeLength<float, &RenderStyle::borderTopWidth, &RenderStyle::setBorderTopWidth, &RenderStyle::initialBorderWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     setPropertyHandler(CSSPropertyClip, ApplyPropertyClip::createHandler());
     setPropertyHandler(CSSPropertyColor, ApplyPropertyColor<InheritFromParent, &RenderStyle::color, &RenderStyle::setColor, &RenderStyle::setVisitedLinkColor, &RenderStyle::invalidColor, RenderStyle::initialColor>::createHandler());
     setPropertyHandler(CSSPropertyCounterIncrement, ApplyPropertyCounter<Increment>::createHandler());
@@ -2387,8 +2327,6 @@
 #if ENABLE(CSS_IMAGE_RESOLUTION)
     setPropertyHandler(CSSPropertyImageResolution, ApplyPropertyImageResolution::createHandler());
 #endif
-    setPropertyHandler(CSSPropertyLetterSpacing, ApplyPropertyComputeLength<float, &RenderStyle::letterSpacing, &RenderStyle::setLetterSpacing, &RenderStyle::initialLetterSpacing, NormalEnabled, ThicknessDisabled, SVGZoomEnabled>::createHandler());
-
 #if ENABLE(IOS_TEXT_AUTOSIZING)
     setPropertyHandler(CSSPropertyLineHeight, ApplyPropertyLineHeightForIOSTextAutosizing::createHandler());
 #else
@@ -2397,9 +2335,7 @@
     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(CSSPropertyOutlineOffset, ApplyPropertyComputeLength<int, &RenderStyle::outlineOffset, &RenderStyle::setOutlineOffset, &RenderStyle::initialOutlineOffset>::createHandler());
     setPropertyHandler(CSSPropertyOutlineStyle, ApplyPropertyOutlineStyle::createHandler());
-    setPropertyHandler(CSSPropertyOutlineWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth, &RenderStyle::initialOutlineWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     setPropertyHandler(CSSPropertyResize, ApplyPropertyResize::createHandler());
     setPropertyHandler(CSSPropertySize, ApplyPropertyPageSize::createHandler());
     setPropertyHandler(CSSPropertyTextAlign, ApplyPropertyTextAlign::createHandler());
@@ -2424,13 +2360,10 @@
     setPropertyHandler(CSSPropertyWebkitBackgroundComposite, ApplyPropertyFillLayer<CompositeOperator, CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSToStyleMap::mapFillComposite>::createHandler());
     setPropertyHandler(CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundOrigin);
     setPropertyHandler(CSSPropertyWebkitBackgroundSize, CSSPropertyBackgroundSize);
-    setPropertyHandler(CSSPropertyWebkitBorderHorizontalSpacing, ApplyPropertyComputeLength<short, &RenderStyle::horizontalBorderSpacing, &RenderStyle::setHorizontalBorderSpacing, &RenderStyle::initialHorizontalBorderSpacing>::createHandler());
     setPropertyHandler(CSSPropertyWebkitBorderImage, ApplyPropertyBorderImage<BorderImage, CSSPropertyWebkitBorderImage, &RenderStyle::borderImage, &RenderStyle::setBorderImage>::createHandler());
-    setPropertyHandler(CSSPropertyWebkitBorderVerticalSpacing, ApplyPropertyComputeLength<short, &RenderStyle::verticalBorderSpacing, &RenderStyle::setVerticalBorderSpacing, &RenderStyle::initialVerticalBorderSpacing>::createHandler());
     setPropertyHandler(CSSPropertyWebkitColumnCount, ApplyPropertyAuto<unsigned short, &RenderStyle::columnCount, &RenderStyle::setColumnCount, &RenderStyle::hasAutoColumnCount, &RenderStyle::setHasAutoColumnCount>::createHandler());
     setPropertyHandler(CSSPropertyWebkitColumnGap, ApplyPropertyAuto<float, &RenderStyle::columnGap, &RenderStyle::setColumnGap, &RenderStyle::hasNormalColumnGap, &RenderStyle::setHasNormalColumnGap, ComputeLength, CSSValueNormal>::createHandler());
     setPropertyHandler(CSSPropertyWebkitColumnRuleColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::columnRuleColor, &RenderStyle::setColumnRuleColor, &RenderStyle::setVisitedLinkColumnRuleColor, &RenderStyle::color>::createHandler());
-    setPropertyHandler(CSSPropertyWebkitColumnRuleWidth, ApplyPropertyComputeLength<unsigned short, &RenderStyle::columnRuleWidth, &RenderStyle::setColumnRuleWidth, &RenderStyle::initialColumnRuleWidth, NormalDisabled, ThicknessEnabled>::createHandler());
     setPropertyHandler(CSSPropertyWebkitColumnWidth, ApplyPropertyAuto<float, &RenderStyle::columnWidth, &RenderStyle::setColumnWidth, &RenderStyle::hasAutoColumnWidth, &RenderStyle::setHasAutoColumnWidth, ComputeLength>::createHandler());
 #if ENABLE(CSS_REGIONS)
     setPropertyHandler(CSSPropertyWebkitFlowFrom, ApplyPropertyString<MapNoneToNull, &RenderStyle::regionThread, &RenderStyle::setRegionThread, &RenderStyle::initialRegionThread>::createHandler());
@@ -2469,7 +2402,6 @@
     setPropertyHandler(CSSPropertyWebkitTextEmphasisStyle, ApplyPropertyTextEmphasisStyle::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextFillColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textFillColor, &RenderStyle::setTextFillColor, &RenderStyle::setVisitedLinkTextFillColor, &RenderStyle::color>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTextStrokeColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textStrokeColor, &RenderStyle::setTextStrokeColor, &RenderStyle::setVisitedLinkTextStrokeColor, &RenderStyle::color>::createHandler());
-    setPropertyHandler(CSSPropertyWebkitTransformOriginZ, ApplyPropertyComputeLength<float, &RenderStyle::transformOriginZ, &RenderStyle::setTransformOriginZ, &RenderStyle::initialTransformOriginZ>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTransitionDelay, ApplyPropertyAnimation<double, &Animation::delay, &Animation::setDelay, &Animation::isDelaySet, &Animation::clearDelay, &Animation::initialAnimationDelay, &CSSToStyleMap::mapAnimationDelay, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTransitionDuration, ApplyPropertyAnimation<double, &Animation::duration, &Animation::setDuration, &Animation::isDurationSet, &Animation::clearDuration, &Animation::initialAnimationDuration, &CSSToStyleMap::mapAnimationDuration, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());
     setPropertyHandler(CSSPropertyWebkitTransitionProperty, ApplyPropertyAnimation<CSSPropertyID, &Animation::property, &Animation::setProperty, &Animation::isPropertySet, &Animation::clearProperty, &Animation::initialAnimationProperty, &CSSToStyleMap::mapAnimationProperty, &RenderStyle::accessTransitions, &RenderStyle::transitions>::createHandler());

Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (175168 => 175169)


--- trunk/Source/WebCore/css/StyleBuilderConverter.h	2014-10-24 18:13:30 UTC (rev 175168)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h	2014-10-24 18:32:34 UTC (rev 175169)
@@ -40,6 +40,9 @@
     static Length convertLengthOrAuto(StyleResolver&, CSSValue&);
     static Length convertLengthSizing(StyleResolver&, CSSValue&);
     static Length convertLengthMaxSizing(StyleResolver&, CSSValue&);
+    template <typename T> static T convertComputedLength(StyleResolver&, CSSValue&);
+    template <typename T> static T convertLineWidth(StyleResolver&, CSSValue&);
+    static float convertSpacing(StyleResolver&, CSSValue&);
 };
 
 inline Length StyleBuilderConverter::convertLength(StyleResolver& styleResolver, CSSValue& value)
@@ -105,6 +108,52 @@
     return convertLengthSizing(styleResolver, value);
 }
 
+template <typename T>
+inline T StyleBuilderConverter::convertComputedLength(StyleResolver& styleResolver, CSSValue& value)
+{
+    return downcast<CSSPrimitiveValue>(value).computeLength<T>(styleResolver.state().cssToLengthConversionData());
+}
+
+template <typename T>
+inline T StyleBuilderConverter::convertLineWidth(StyleResolver& styleResolver, CSSValue& value)
+{
+    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+    switch (primitiveValue.getValueID()) {
+    case CSSValueThin:
+        return 1;
+    case CSSValueMedium:
+        return 3;
+    case CSSValueThick:
+        return 5;
+    case CSSValueInvalid: {
+        // Any original result that was >= 1 should not be allowed to fall below 1.
+        // This keeps border lines from vanishing.
+        T result = convertComputedLength<T>(styleResolver, value);
+        if (styleResolver.state().style()->effectiveZoom() < 1.0f && result < 1.0) {
+            T originalLength = primitiveValue.computeLength<T>(styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(1.0));
+            if (originalLength >= 1.0)
+                return 1;
+        }
+        return result;
+    }
+    default:
+        ASSERT_NOT_REACHED();
+        return 0;
+    }
+}
+
+inline float StyleBuilderConverter::convertSpacing(StyleResolver& styleResolver, CSSValue& value)
+{
+    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+    if (primitiveValue.getValueID() == CSSValueNormal)
+        return 0.f;
+
+    CSSToLengthConversionData conversionData = styleResolver.useSVGZoomRulesForLength() ?
+        styleResolver.state().cssToLengthConversionData().copyWithAdjustedZoom(1.0f)
+        : styleResolver.state().cssToLengthConversionData();
+    return primitiveValue.computeLength<float>(conversionData);
+}
+
 } // namespace WebCore
 
 #endif // StyleBuilderConverter_h
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to