Move "Auto" CSS properties to the new StyleBuilder
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Dec 2014 10:38:57 +0000 (10:38 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 22 Dec 2014 10:38:57 +0000 (10:38 +0000)
https://bugs.webkit.org/show_bug.cgi?id=139858

Reviewed by Antti Koivisto.

Move "Auto" CSS properties from DeprecatedStyleBuilder to the new
StyleBuilder, by adding support in the generator for using hasAutoXXX()
/ setHasAutoXXX() methods on RenderStyle.

No new tests, no web-exposed behavior change.

* css/CSSPropertyNames.in:
* css/DeprecatedStyleBuilder.cpp:
(WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
(WebCore::ApplyPropertyAuto::setValue): Deleted.
(WebCore::ApplyPropertyAuto::value): Deleted.
(WebCore::ApplyPropertyAuto::hasAuto): Deleted.
(WebCore::ApplyPropertyAuto::setAuto): Deleted.
(WebCore::ApplyPropertyAuto::applyInheritValue): Deleted.
(WebCore::ApplyPropertyAuto::applyInitialValue): Deleted.
(WebCore::ApplyPropertyAuto::applyValue): Deleted.
(WebCore::ApplyPropertyAuto::createHandler): Deleted.
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyInitialColumnGap):
(WebCore::StyleBuilderCustom::applyInheritColumnGap):
(WebCore::StyleBuilderCustom::applyValueColumnGap):
* css/makeprop.pl:
(getNameForMethods):
(getAutoGetter):
(getAutoSetter):
(generateInitialValueSetter):
(generateInheritValueSetter):
(generateValueSetter):

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

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

index fb84c36..c9dbf70 100644 (file)
@@ -1,3 +1,39 @@
+2014-12-22  Chris Dumez  <cdumez@apple.com>
+
+        Move "Auto" CSS properties to the new StyleBuilder
+        https://bugs.webkit.org/show_bug.cgi?id=139858
+
+        Reviewed by Antti Koivisto.
+
+        Move "Auto" CSS properties from DeprecatedStyleBuilder to the new
+        StyleBuilder, by adding support in the generator for using hasAutoXXX()
+        / setHasAutoXXX() methods on RenderStyle.
+
+        No new tests, no web-exposed behavior change.
+
+        * css/CSSPropertyNames.in:
+        * css/DeprecatedStyleBuilder.cpp:
+        (WebCore::DeprecatedStyleBuilder::DeprecatedStyleBuilder):
+        (WebCore::ApplyPropertyAuto::setValue): Deleted.
+        (WebCore::ApplyPropertyAuto::value): Deleted.
+        (WebCore::ApplyPropertyAuto::hasAuto): Deleted.
+        (WebCore::ApplyPropertyAuto::setAuto): Deleted.
+        (WebCore::ApplyPropertyAuto::applyInheritValue): Deleted.
+        (WebCore::ApplyPropertyAuto::applyInitialValue): Deleted.
+        (WebCore::ApplyPropertyAuto::applyValue): Deleted.
+        (WebCore::ApplyPropertyAuto::createHandler): Deleted.
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyInitialColumnGap):
+        (WebCore::StyleBuilderCustom::applyInheritColumnGap):
+        (WebCore::StyleBuilderCustom::applyValueColumnGap):
+        * css/makeprop.pl:
+        (getNameForMethods):
+        (getAutoGetter):
+        (getAutoSetter):
+        (generateInitialValueSetter):
+        (generateInheritValueSetter):
+        (generateValueSetter):
+
 2014-12-21  Shivakumar JM  <shiva.jm@samsung.com>
 
         HTMLSelectElement add() should support adding group of options element (HTMLOptGroupElement).
index 5fb1a8b..aef2af5 100644 (file)
 // If special handling is also needed to apply inherit or initial value, use
 // Custom=All. Alternatively, several '|'-separated options can be passed:
 // e.g. 'Custom=Inherit|Value".
+//
+// * AutoFunctions:
+// Indicates that this CSS property requires handling of "auto" and has
+// corresponding hasAutoXXX() / setHasAutoXXX() methods on RenderStyle.
 
 
 // high-priority property names have to be listed first, to simplify the check
@@ -203,7 +207,7 @@ opacity [TypeName=float]
 // Honor -webkit-opacity as a synonym for opacity. This was the only syntax that worked in Safari 1.1,
 // and may be in use on some websites and widgets.
 -webkit-opacity = opacity
-orphans [Inherited, LegacyStyleBuilder]
+orphans [Inherited, TypeName=short, AutoFunctions]
 outline [LegacyStyleBuilder]
 outline-color [LegacyStyleBuilder]
 outline-offset [Converter=ComputedLength<int>]
@@ -267,13 +271,13 @@ unicode-range [LegacyStyleBuilder]
 vertical-align [Custom=Value]
 visibility [Inherited]
 white-space [Inherited]
-widows [Inherited, LegacyStyleBuilder]
+widows [Inherited, TypeName=short, AutoFunctions]
 width [Initial=initialSize, Converter=LengthSizing]
 word-break [Inherited]
 -epub-word-break = word-break
 word-spacing [Inherited, Custom=Value]
 word-wrap [Inherited=EOverflowWrap, NameForMethods=OverflowWrap]
-z-index [LegacyStyleBuilder]
+z-index [TypeName=int, AutoFunctions]
 alt [LegacyStyleBuilder]
 -webkit-alt = alt
 -webkit-animation [LegacyStyleBuilder]
@@ -337,11 +341,11 @@ alt [LegacyStyleBuilder]
 -webkit-column-break-after [TypeName=EPageBreak, Initial=initialPageBreak]
 -webkit-column-break-before [TypeName=EPageBreak, Initial=initialPageBreak]
 -webkit-column-break-inside [TypeName=EPageBreak, Initial=initialPageBreak]
-column-count [LegacyStyleBuilder]
+column-count [TypeName=unsigned short, AutoFunctions]
 -webkit-column-count = column-count
 column-fill [TypeName=ColumnFill]
 -webkit-column-fill = column-fill
-column-gap [LegacyStyleBuilder]
+column-gap [Custom=All]
 -webkit-column-gap = column-gap
 column-progression [TypeName=ColumnProgression]
 -webkit-column-progression = column-progression
@@ -355,7 +359,7 @@ column-rule-width [Converter=LineWidth<unsigned short>]
 -webkit-column-rule-width = column-rule-width
 column-span [TypeName=ColumnSpan]
 -webkit-column-span = column-span
-column-width [LegacyStyleBuilder]
+column-width [TypeName=float, AutoFunctions, Converter=ComputedLength<float>]
 -webkit-column-width = column-width
 columns [LegacyStyleBuilder]
 -webkit-columns = columns
index 8166c00..941c1d9 100644 (file)
@@ -41,42 +41,6 @@ namespace WebCore {
 
 using namespace HTMLNames;
 
-enum AutoValueType {Number = 0, ComputeLength};
-template <typename T, T (RenderStyle::*getterFunction)() const, void (RenderStyle::*setterFunction)(T), bool (RenderStyle::*hasAutoFunction)() const, void (RenderStyle::*setAutoFunction)(), AutoValueType valueType = Number, int autoIdentity = CSSValueAuto>
-class ApplyPropertyAuto {
-public:
-    static void setValue(RenderStyle* style, T value) { (style->*setterFunction)(value); }
-    static T value(RenderStyle* style) { return (style->*getterFunction)(); }
-    static bool hasAuto(RenderStyle* style) { return (style->*hasAutoFunction)(); }
-    static void setAuto(RenderStyle* style) { (style->*setAutoFunction)(); }
-
-    static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
-    {
-        if (hasAuto(styleResolver->parentStyle()))
-            setAuto(styleResolver->style());
-        else
-            setValue(styleResolver->style(), value(styleResolver->parentStyle()));
-    }
-
-    static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver) { setAuto(styleResolver->style()); }
-
-    static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
-    {
-        if (!is<CSSPrimitiveValue>(*value))
-            return;
-
-        CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
-        if (primitiveValue.getValueID() == autoIdentity)
-            setAuto(styleResolver->style());
-        else if (valueType == Number)
-            setValue(styleResolver->style(), primitiveValue);
-        else if (valueType == ComputeLength)
-            setValue(styleResolver->style(), primitiveValue.computeLength<T>(styleResolver->state().cssToLengthConversionData()));
-    }
-
-    static PropertyHandler createHandler() { return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue); }
-};
-
 enum ColorInherit {NoInheritFromParent = 0, InheritFromParent};
 Color defaultInitialColor();
 Color defaultInitialColor() { return Color(); }
@@ -586,7 +550,6 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder()
     setPropertyHandler(CSSPropertyFontSize, ApplyPropertyFontSize::createHandler());
     setPropertyHandler(CSSPropertyFontStyle, ApplyPropertyFont<FontItalic, &FontDescription::italic, &FontDescription::setItalic, FontItalicOff>::createHandler());
     setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::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(CSSPropertyWebkitTextDecorationColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::textDecorationColor, &RenderStyle::setTextDecorationColor, &RenderStyle::setVisitedLinkTextDecorationColor, &RenderStyle::color>::createHandler());
     setPropertyHandler(CSSPropertyTextRendering, ApplyPropertyFont<TextRenderingMode, &FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering>::createHandler());
@@ -612,10 +575,7 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder()
     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(CSSPropertyColumnCount, ApplyPropertyAuto<unsigned short, &RenderStyle::columnCount, &RenderStyle::setColumnCount, &RenderStyle::hasAutoColumnCount, &RenderStyle::setHasAutoColumnCount>::createHandler());
-    setPropertyHandler(CSSPropertyColumnGap, ApplyPropertyAuto<float, &RenderStyle::columnGap, &RenderStyle::setColumnGap, &RenderStyle::hasNormalColumnGap, &RenderStyle::setHasNormalColumnGap, ComputeLength, CSSValueNormal>::createHandler());
     setPropertyHandler(CSSPropertyColumnRuleColor, ApplyPropertyColor<NoInheritFromParent, &RenderStyle::columnRuleColor, &RenderStyle::setColumnRuleColor, &RenderStyle::setVisitedLinkColumnRuleColor, &RenderStyle::color>::createHandler());
-    setPropertyHandler(CSSPropertyColumnWidth, ApplyPropertyAuto<float, &RenderStyle::columnWidth, &RenderStyle::setColumnWidth, &RenderStyle::hasAutoColumnWidth, &RenderStyle::setHasAutoColumnWidth, ComputeLength>::createHandler());
     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());
@@ -635,10 +595,6 @@ DeprecatedStyleBuilder::DeprecatedStyleBuilder()
     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());
     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(CSSPropertyZIndex, ApplyPropertyAuto<int, &RenderStyle::zIndex, &RenderStyle::setZIndex, &RenderStyle::hasAutoZIndex, &RenderStyle::setHasAutoZIndex>::createHandler());
 }
 
-
 }
index e269af2..7209638 100644 (file)
@@ -35,6 +35,7 @@
 #include "LocaleToScriptMapping.h"
 #include "Rect.h"
 #include "SVGElement.h"
+#include "StyleBuilderConverter.h"
 #include "StyleFontSizeFunctions.h"
 #include "StyleResolver.h"
 
@@ -55,6 +56,7 @@ public:
     DECLARE_PROPERTY_CUSTOM_HANDLERS(BorderImageWidth);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(BoxShadow);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(Clip);
+    DECLARE_PROPERTY_CUSTOM_HANDLERS(ColumnGap);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(CounterIncrement);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(CounterReset);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(Cursor);
@@ -1179,6 +1181,27 @@ inline void StyleBuilderCustom::applyValueFontWeight(StyleResolver& styleResolve
     styleResolver.setFontDescription(fontDescription);
 }
 
+inline void StyleBuilderCustom::applyInitialColumnGap(StyleResolver& styleResolver)
+{
+    styleResolver.style()->setHasNormalColumnGap();
+}
+
+inline void StyleBuilderCustom::applyInheritColumnGap(StyleResolver& styleResolver)
+{
+    if (styleResolver.parentStyle()->hasNormalColumnGap())
+        styleResolver.style()->setHasNormalColumnGap();
+    else
+        styleResolver.style()->setColumnGap(styleResolver.parentStyle()->columnGap());
+}
+
+inline void StyleBuilderCustom::applyValueColumnGap(StyleResolver& styleResolver, CSSValue& value)
+{
+    if (downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueNormal)
+        styleResolver.style()->setHasNormalColumnGap();
+    else
+        styleResolver.style()->setColumnGap(StyleBuilderConverter::convertComputedLength<float>(styleResolver, value));
+}
+
 } // namespace WebCore
 
 #endif // StyleBuilderCustom_h
index eb8c855..b373727 100755 (executable)
@@ -43,7 +43,8 @@ my @names = ();
 my %nameIsInherited;
 my %propertiesWithStyleBuilderOptions;
 my %styleBuilderOptions = (
-  Converter => 1, # Defined in Source/WebCore/css/StyleBuilderConverter.h
+  AutoFunctions => 1, # Defined in Source/WebCore/css/StyleBuilderConverter.h
+  Converter => 1,
   Custom => 1,
   Getter => 1,
   Initial => 1,
@@ -337,11 +338,36 @@ sub getScopeForFunction {
   return $propertiesWithStyleBuilderOptions{$name}{"Custom"}{$builderFunction} ? "StyleBuilderCustom" : "StyleBuilderFunctions";
 }
 
+sub getNameForMethods {
+  my $name = shift;
+
+  my $nameForMethods = $nameToId{$name};
+  $nameForMethods =~ s/Webkit//g;
+  if (exists($propertiesWithStyleBuilderOptions{$name}{"NameForMethods"})) {
+    $nameForMethods = $propertiesWithStyleBuilderOptions{$name}{"NameForMethods"};
+  }
+  return $nameForMethods;
+}
+
+sub getAutoGetter {
+  my $name = shift;
+  my $renderStyle = shift;
+
+  return $renderStyle . "->hasAuto" . getNameForMethods($name) . "()";
+}
+
+sub getAutoSetter {
+  my $name = shift;
+  my $renderStyle = shift;
+
+  return $renderStyle . "->setHasAuto" . getNameForMethods($name) . "()";
+}
+
 foreach my $name (@names) {
   # Skip properties still using the legacy style builder.
   next unless exists($propertiesWithStyleBuilderOptions{$name});
 
-  my $nameForMethods = $nameToId{$name};
+  my $nameForMethods = getNameForMethods($name);
   $nameForMethods =~ s/Webkit//g;
   if (exists($propertiesWithStyleBuilderOptions{$name}{"NameForMethods"})) {
     $nameForMethods = $propertiesWithStyleBuilderOptions{$name}{"NameForMethods"};
@@ -368,6 +394,74 @@ foreach my $name (@names) {
   $propertiesWithStyleBuilderOptions{$name}{"Custom"} = \%customValues;
 }
 
+sub generateInitialValueSetter {
+  my $name = shift;
+  my $indent = shift;
+
+  my $setterContent = "";
+  $setterContent .= $indent . "inline void applyInitial" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
+  $setterContent .= $indent . "{\n";
+  my $style = "styleResolver.style()";
+  if (exists $propertiesWithStyleBuilderOptions{$name}{"AutoFunctions"}) {
+    $setterContent .= $indent . "    " . getAutoSetter($name, $style) . ";\n";
+  } else {
+    my $setValue = $style . "->" . $propertiesWithStyleBuilderOptions{$name}{"Setter"};
+    $setterContent .= $indent . "    " . $setValue . "(RenderStyle::" . $propertiesWithStyleBuilderOptions{$name}{"Initial"} . "());\n";
+  }
+  $setterContent .= $indent . "}\n";
+
+  return $setterContent;
+}
+
+sub generateInheritValueSetter {
+  my $name = shift;
+  my $indent = shift;
+
+  my $setterContent = "";
+  $setterContent .= $indent . "inline void applyInherit" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
+  $setterContent .= $indent . "{\n";
+  my $parentStyle = "styleResolver.parentStyle()";
+  my $style = "styleResolver.style()";
+  if (exists $propertiesWithStyleBuilderOptions{$name}{"AutoFunctions"}) {
+    $setterContent .= $indent . "    if (" . getAutoGetter($name, $parentStyle) . ") {\n";
+    $setterContent .= $indent . "        " . getAutoSetter($name, $style) . ";\n";
+    $setterContent .= $indent . "        return;\n";
+    $setterContent .= $indent . "    }\n";
+  }
+  my $setValue = $style . "->" . $propertiesWithStyleBuilderOptions{$name}{"Setter"};
+  $setterContent .= $indent . "    " . $setValue . "(" . $parentStyle . "->" .  $propertiesWithStyleBuilderOptions{$name}{"Getter"} . "());\n";
+  $setterContent .= $indent . "}\n";
+
+  return $setterContent;
+}
+
+sub generateValueSetter {
+  my $name = shift;
+  my $indent = shift;
+
+  my $setterContent = "";
+  $setterContent .= $indent . "inline void applyValue" . $nameToId{$name} . "(StyleResolver& styleResolver, CSSValue& value)\n";
+  $setterContent .= $indent . "{\n";
+  my $convertedValue;
+  if (exists($propertiesWithStyleBuilderOptions{$name}{"Converter"})) {
+    $convertedValue = "StyleBuilderConverter::convert" . $propertiesWithStyleBuilderOptions{$name}{"Converter"} . "(styleResolver, value)";
+  } else {
+    $convertedValue = "static_cast<" . $propertiesWithStyleBuilderOptions{$name}{"TypeName"} . ">(downcast<CSSPrimitiveValue>(value))";
+  }
+  my $style = "styleResolver.style()";
+  if (exists $propertiesWithStyleBuilderOptions{$name}{"AutoFunctions"}) {
+    $setterContent .= $indent . "    if (downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueAuto) {\n";
+    $setterContent .= $indent . "        ". getAutoSetter($name, $style) . ";\n";
+    $setterContent .= $indent . "        return;\n";
+    $setterContent .= $indent . "    }\n";
+  }
+  my $setValue = $style . "->" . $propertiesWithStyleBuilderOptions{$name}{"Setter"};
+  $setterContent .= $indent . "    " . $setValue . "(" . $convertedValue . ");\n";
+  $setterContent .= $indent . "}\n";
+
+  return $setterContent;
+}
+
 open STYLEBUILDER, ">StyleBuilder.cpp" || die "Could not open StyleBuilder.cpp for writing";
 print STYLEBUILDER << "EOF";
 /* This file is automatically generated from CSSPropertyNames.in by makeprop, do not edit */
@@ -391,30 +485,15 @@ foreach my $name (@names) {
   # Skip properties still using the legacy style builder.
   next unless exists($propertiesWithStyleBuilderOptions{$name});
 
-  my $setValue = "styleResolver.style()->" . $propertiesWithStyleBuilderOptions{$name}{"Setter"};
+  my $indent = "    ";
   if (!$propertiesWithStyleBuilderOptions{$name}{"Custom"}{"Initial"}) {
-    print STYLEBUILDER "    inline void applyInitial" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
-    print STYLEBUILDER "    {\n";
-    print STYLEBUILDER "        " . $setValue . "(RenderStyle::" . $propertiesWithStyleBuilderOptions{$name}{"Initial"} . "());\n";
-    print STYLEBUILDER "    }\n";
+    print STYLEBUILDER generateInitialValueSetter($name, $indent);
   }
   if (!$propertiesWithStyleBuilderOptions{$name}{"Custom"}{"Inherit"}) {
-    print STYLEBUILDER "    inline void applyInherit" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
-    print STYLEBUILDER "    {\n";
-    print STYLEBUILDER "        " . $setValue . "(styleResolver.parentStyle()->" .  $propertiesWithStyleBuilderOptions{$name}{"Getter"} . "());\n";
-    print STYLEBUILDER "    }\n";
+    print STYLEBUILDER generateInheritValueSetter($name, $indent);
   }
   if (!$propertiesWithStyleBuilderOptions{$name}{"Custom"}{"Value"}) {
-    print STYLEBUILDER "    inline void applyValue" . $nameToId{$name} . "(StyleResolver& styleResolver, CSSValue& value)\n";
-    print STYLEBUILDER "    {\n";
-    my $convertedValue;
-    if (exists($propertiesWithStyleBuilderOptions{$name}{"Converter"})) {
-      $convertedValue = "StyleBuilderConverter::convert" . $propertiesWithStyleBuilderOptions{$name}{"Converter"} . "(styleResolver, value)";
-    } else {
-      $convertedValue = "static_cast<" . $propertiesWithStyleBuilderOptions{$name}{"TypeName"} . ">(downcast<CSSPrimitiveValue>(value))";
-    }
-    print STYLEBUILDER "        " . $setValue . "(" . $convertedValue . ");\n";
-    print STYLEBUILDER "    }\n";
+    print STYLEBUILDER generateValueSetter($name, $indent);
   }
 }