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

Changeset 176593 in webkit


Ignore:
Timestamp:
Dec 1, 2014, 10:42:52 AM (12 years ago)
Author:
Chris Dumez
Message:

Transform StyleBuilderCustom into a class and mark it as a friend of RenderStyle
https://bugs.webkit.org/show_bug.cgi?id=138999

Reviewed by Sam Weinig.

Transform StyleBuilderCustom into a class and mark it as a friend of
RenderStyle. This is needed because some of the StyleBuilderCustom
functions need to access RenderStyle's private API.

No new tests, no behavior change.

  • css/StyleBuilderCustom.h: Move functions from StyleBuilderFunctions namespace to StyleBuilderCustom class.
  • css/makeprop.pl: Use StyleBuilderCustom scope instead of StyleBuilderFunctions for custom implementation.
  • rendering/style/RenderStyle.h: Mark StyleBuilderCustom class as a friend, similarly to what was already done for DeprecatedStyleBuilder and StyleResolver.
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176592 r176593  
     12014-12-01  Chris Dumez  <cdumez@apple.com>
     2
     3        Transform StyleBuilderCustom into a class and mark it as a friend of RenderStyle
     4        https://bugs.webkit.org/show_bug.cgi?id=138999
     5
     6        Reviewed by Sam Weinig.
     7
     8        Transform StyleBuilderCustom into a class and mark it as a friend of
     9        RenderStyle. This is needed because some of the StyleBuilderCustom
     10        functions need to access RenderStyle's private API.
     11
     12        No new tests, no behavior change.
     13
     14        * css/StyleBuilderCustom.h:
     15          Move functions from StyleBuilderFunctions namespace to
     16          StyleBuilderCustom class.
     17
     18        * css/makeprop.pl:
     19          Use StyleBuilderCustom scope instead of StyleBuilderFunctions for
     20          custom implementation.
     21
     22        * rendering/style/RenderStyle.h:
     23          Mark StyleBuilderCustom class as a friend, similarly to what was
     24          already done for DeprecatedStyleBuilder and StyleResolver.
     25
    1262014-11-17  Oliver Hunt  <oliver@apple.com>
    227
  • trunk/Source/WebCore/css/StyleBuilderCustom.h

    r176584 r176593  
    4040
    4141// Note that we assume the CSS parser only allows valid CSSValue types.
    42 namespace StyleBuilderFunctions {
    43 
    44 inline void applyValueWebkitMarqueeIncrement(StyleResolver& styleResolver, CSSValue& value)
     42class StyleBuilderCustom {
     43public:
     44    static void applyValueWebkitMarqueeIncrement(StyleResolver&, CSSValue&);
     45
     46    static void applyValueDirection(StyleResolver&, CSSValue&);
     47
     48    static void applyInitialZoom(StyleResolver&);
     49    static void applyInheritZoom(StyleResolver&);
     50    static void applyValueZoom(StyleResolver&, CSSValue&);
     51
     52#if ENABLE(CSS_SHAPES)
     53    static void applyValueWebkitShapeOutside(StyleResolver&, CSSValue&);
     54#endif // ENABLE(CSS_SHAPES)
     55
     56    static void applyValueVerticalAlign(StyleResolver&, CSSValue&);
     57
     58#if ENABLE(CSS_IMAGE_RESOLUTION)
     59    static void applyInheritImageResolution(StyleResolver&);
     60    static void applyInitialImageResolution(StyleResolver&);
     61    static void applyValueImageResolution(StyleResolver&, CSSValue&);
     62#endif // ENABLE(CSS_IMAGE_RESOLUTION)
     63
     64    static void applyInheritSize(StyleResolver&);
     65    static void applyInitialSize(StyleResolver&);
     66    static void applyValueSize(StyleResolver&, CSSValue&);
     67
     68    static void applyInheritTextIndent(StyleResolver&);
     69    static void applyInitialTextIndent(StyleResolver&);
     70    static void applyValueTextIndent(StyleResolver&, CSSValue&);
     71
     72#define DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(type, modifier) \
     73    static void applyInherit##type##modifier(StyleResolver&); \
     74    static void applyInitial##type##modifier(StyleResolver&); \
     75    static void applyValue##type##modifier(StyleResolver&, CSSValue&)
     76
     77    DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(BorderImage, Outset);
     78    DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(BorderImage, Repeat);
     79    DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(BorderImage, Slice);
     80    DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(BorderImage, Width);
     81    DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Outset);
     82    DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Repeat);
     83    DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Slice);
     84    DECLARE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Width);
     85
     86    static void applyValueWordSpacing(StyleResolver&, CSSValue&);
     87
     88#if ENABLE(IOS_TEXT_AUTOSIZING)
     89    static void applyInheritLineHeight(StyleResolver&);
     90    static void applyInitialLineHeight(StyleResolver&);
     91#endif // ENABLE(IOS_TEXT_AUTOSIZING)
     92    static void applyValueLineHeight(StyleResolver&, CSSValue&);
     93
     94    static void applyInheritOutlineStyle(StyleResolver&);
     95    static void applyInitialOutlineStyle(StyleResolver&);
     96    static void applyValueOutlineStyle(StyleResolver&, CSSValue&);
     97
     98    static void applyInitialClip(StyleResolver&);
     99    static void applyInheritClip(StyleResolver&);
     100    static void applyValueClip(StyleResolver&, CSSValue&);
     101
     102    static void applyValueWebkitLocale(StyleResolver&, CSSValue&);
     103    static void applyValueWebkitWritingMode(StyleResolver&, CSSValue&);
     104    static void applyValueWebkitTextOrientation(StyleResolver&, CSSValue&);
     105    static void applyValueWebkitJustifySelf(StyleResolver&, CSSValue&);
     106    static void applyValueWebkitPerspective(StyleResolver&, CSSValue&);
     107
     108private:
     109    static void resetEffectiveZoom(StyleResolver&);
     110    static CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver&);
     111    static bool convertLineHeight(StyleResolver&, const CSSValue&, Length&, float multiplier = 1.f);
     112
     113    static Length mmLength(double mm);
     114    static Length inchLength(double inch);
     115    static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height);
     116};
     117
     118inline void StyleBuilderCustom::applyValueWebkitMarqueeIncrement(StyleResolver& styleResolver, CSSValue& value)
    45119{
    46120    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     
    66140}
    67141
    68 inline void applyValueDirection(StyleResolver& styleResolver, CSSValue& value)
     142inline void StyleBuilderCustom::applyValueDirection(StyleResolver& styleResolver, CSSValue& value)
    69143{
    70144    styleResolver.style()->setDirection(downcast<CSSPrimitiveValue>(value));
     
    75149}
    76150
    77 inline void resetEffectiveZoom(StyleResolver& styleResolver)
     151inline void StyleBuilderCustom::resetEffectiveZoom(StyleResolver& styleResolver)
    78152{
    79153    // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect.
     
    81155}
    82156
    83 inline void applyInitialZoom(StyleResolver& styleResolver)
     157inline void StyleBuilderCustom::applyInitialZoom(StyleResolver& styleResolver)
    84158{
    85159    resetEffectiveZoom(styleResolver);
     
    87161}
    88162
    89 inline void applyInheritZoom(StyleResolver& styleResolver)
     163inline void StyleBuilderCustom::applyInheritZoom(StyleResolver& styleResolver)
    90164{
    91165    resetEffectiveZoom(styleResolver);
     
    93167}
    94168
    95 inline void applyValueZoom(StyleResolver& styleResolver, CSSValue& value)
     169inline void StyleBuilderCustom::applyValueZoom(StyleResolver& styleResolver, CSSValue& value)
    96170{
    97171    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     
    119193
    120194#if ENABLE(CSS_SHAPES)
    121 inline void applyValueWebkitShapeOutside(StyleResolver& styleResolver, CSSValue& value)
     195inline void StyleBuilderCustom::applyValueWebkitShapeOutside(StyleResolver& styleResolver, CSSValue& value)
    122196{
    123197    if (is<CSSPrimitiveValue>(value)) {
     
    153227#endif // ENABLE(CSS_SHAPES)
    154228
    155 inline Length mmLength(double mm)
     229inline Length StyleBuilderCustom::mmLength(double mm)
    156230{
    157231    Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(mm, CSSPrimitiveValue::CSS_MM));
    158232    return value.get().computeLength<Length>(CSSToLengthConversionData());
    159233}
    160 inline Length inchLength(double inch)
     234inline Length StyleBuilderCustom::inchLength(double inch)
    161235{
    162236    Ref<CSSPrimitiveValue> value(CSSPrimitiveValue::create(inch, CSSPrimitiveValue::CSS_IN));
    163237    return value.get().computeLength<Length>(CSSToLengthConversionData());
    164238}
    165 static bool getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height)
     239bool StyleBuilderCustom::getPageSizeFromName(CSSPrimitiveValue* pageSizeName, CSSPrimitiveValue* pageOrientation, Length& width, Length& height)
    166240{
    167241    static NeverDestroyed<Length> a5Width(mmLength(148));
     
    237311}
    238312
    239 inline void applyValueVerticalAlign(StyleResolver& styleResolver, CSSValue& value)
     313inline void StyleBuilderCustom::applyValueVerticalAlign(StyleResolver& styleResolver, CSSValue& value)
    240314{
    241315    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     
    247321
    248322#if ENABLE(CSS_IMAGE_RESOLUTION)
    249 inline void applyInheritImageResolution(StyleResolver& styleResolver)
     323inline void StyleBuilderCustom::applyInheritImageResolution(StyleResolver& styleResolver)
    250324{
    251325    styleResolver.style()->setImageResolutionSource(styleResolver.parentStyle()->imageResolutionSource());
     
    254328}
    255329
    256 inline void applyInitialImageResolution(StyleResolver& styleResolver)
     330inline void StyleBuilderCustom::applyInitialImageResolution(StyleResolver& styleResolver)
    257331{
    258332    styleResolver.style()->setImageResolutionSource(RenderStyle::initialImageResolutionSource());
     
    261335}
    262336
    263 inline void applyValueImageResolution(StyleResolver& styleResolver, CSSValue& value)
     337inline void StyleBuilderCustom::applyValueImageResolution(StyleResolver& styleResolver, CSSValue& value)
    264338{
    265339    ImageResolutionSource source = RenderStyle::initialImageResolutionSource();
     
    281355#endif // ENABLE(CSS_IMAGE_RESOLUTION)
    282356
    283 inline void applyInheritSize(StyleResolver&) { }
    284 inline void applyInitialSize(StyleResolver&) { }
    285 inline void applyValueSize(StyleResolver& styleResolver, CSSValue& value)
     357inline void StyleBuilderCustom::applyInheritSize(StyleResolver&) { }
     358inline void StyleBuilderCustom::applyInitialSize(StyleResolver&) { }
     359inline void StyleBuilderCustom::applyValueSize(StyleResolver& styleResolver, CSSValue& value)
    286360{
    287361    styleResolver.style()->resetPageSizeType();
     
    357431}
    358432
    359 inline void applyInheritTextIndent(StyleResolver& styleResolver)
     433inline void StyleBuilderCustom::applyInheritTextIndent(StyleResolver& styleResolver)
    360434{
    361435    styleResolver.style()->setTextIndent(styleResolver.parentStyle()->textIndent());
     
    366440}
    367441
    368 inline void applyInitialTextIndent(StyleResolver& styleResolver)
     442inline void StyleBuilderCustom::applyInitialTextIndent(StyleResolver& styleResolver)
    369443{
    370444    styleResolver.style()->setTextIndent(RenderStyle::initialTextIndent());
     
    375449}
    376450
    377 inline void applyValueTextIndent(StyleResolver& styleResolver, CSSValue& value)
     451inline void StyleBuilderCustom::applyValueTextIndent(StyleResolver& styleResolver, CSSValue& value)
    378452{
    379453    Length lengthOrPercentageValue;
     
    472546
    473547private:
    474     static inline const NinePieceImage& getValue(RenderStyle* style)
     548    static const NinePieceImage& getValue(RenderStyle* style)
    475549    {
    476550        return type == BorderImage ? style->borderImage() : style->maskBoxImage();
    477551    }
    478552
    479     static inline void setValue(RenderStyle* style, const NinePieceImage& value)
     553    static void setValue(RenderStyle* style, const NinePieceImage& value)
    480554    {
    481555        return type == BorderImage ? style->setBorderImage(value) : style->setMaskBoxImage(value);
     
    484558
    485559#define DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(type, modifier) \
    486 inline void applyInherit##type##modifier(StyleResolver& styleResolver) \
     560inline void StyleBuilderCustom::applyInherit##type##modifier(StyleResolver& styleResolver) \
    487561{ \
    488562    ApplyPropertyBorderImageModifier<type, modifier>::applyInheritValue(styleResolver); \
    489563} \
    490 inline void applyInitial##type##modifier(StyleResolver& styleResolver) \
     564inline void StyleBuilderCustom::applyInitial##type##modifier(StyleResolver& styleResolver) \
    491565{ \
    492566    ApplyPropertyBorderImageModifier<type, modifier>::applyInitialValue(styleResolver); \
    493567} \
    494 inline void applyValue##type##modifier(StyleResolver& styleResolver, CSSValue& value) \
     568inline void StyleBuilderCustom::applyValue##type##modifier(StyleResolver& styleResolver, CSSValue& value) \
    495569{ \
    496570    ApplyPropertyBorderImageModifier<type, modifier>::applyValue(styleResolver, value); \
     
    506580DEFINE_BORDER_IMAGE_MODIFIER_HANDLER(WebkitMaskBoxImage, Width)
    507581
    508 inline CSSToLengthConversionData csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver)
     582inline CSSToLengthConversionData StyleBuilderCustom::csstoLengthConversionDataWithTextZoomFactor(StyleResolver& styleResolver)
    509583{
    510584    if (Frame* frame = styleResolver.document().frame())
     
    514588}
    515589
    516 inline bool convertLineHeight(StyleResolver& styleResolver, const CSSValue& value, Length& length, float multiplier = 1.f)
     590inline bool StyleBuilderCustom::convertLineHeight(StyleResolver& styleResolver, const CSSValue& value, Length& length, float multiplier)
    517591{
    518592    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     
    540614}
    541615
    542 inline void applyValueWordSpacing(StyleResolver& styleResolver, CSSValue& value)
     616inline void StyleBuilderCustom::applyValueWordSpacing(StyleResolver& styleResolver, CSSValue& value)
    543617{
    544618    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     
    560634#if ENABLE(IOS_TEXT_AUTOSIZING)
    561635
    562 inline void applyInheritLineHeight(StyleResolver& styleResolver)
     636inline void StyleBuilderCustom::applyInheritLineHeight(StyleResolver& styleResolver)
    563637{
    564638    styleResolver.style()->setLineHeight(styleResolver.parentStyle()->lineHeight());
     
    566640}
    567641
    568 inline void applyInitialLineHeight(StyleResolver& styleResolver)
     642inline void StyleBuilderCustom::applyInitialLineHeight(StyleResolver& styleResolver)
    569643{
    570644    styleResolver.style()->setLineHeight(RenderStyle::initialLineHeight());
     
    572646}
    573647
    574 inline void applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)
     648inline void StyleBuilderCustom::applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)
    575649{
    576650    Length lineHeight;
     
    585659#else
    586660
    587 inline void applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)
     661inline void StyleBuilderCustom::applyValueLineHeight(StyleResolver& styleResolver, CSSValue& value)
    588662{
    589663    Length lineHeight;
     
    596670#endif
    597671
    598 inline void applyInheritOutlineStyle(StyleResolver& styleResolver)
     672inline void StyleBuilderCustom::applyInheritOutlineStyle(StyleResolver& styleResolver)
    599673{
    600674    styleResolver.style()->setOutlineStyleIsAuto(styleResolver.parentStyle()->outlineStyleIsAuto());
     
    602676}
    603677
    604 inline void applyInitialOutlineStyle(StyleResolver& styleResolver)
     678inline void StyleBuilderCustom::applyInitialOutlineStyle(StyleResolver& styleResolver)
    605679{
    606680    styleResolver.style()->setOutlineStyleIsAuto(RenderStyle::initialOutlineStyleIsAuto());
     
    608682}
    609683
    610 inline void applyValueOutlineStyle(StyleResolver& styleResolver, CSSValue& value)
     684inline void StyleBuilderCustom::applyValueOutlineStyle(StyleResolver& styleResolver, CSSValue& value)
    611685{
    612686    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     
    616690}
    617691
    618 inline void applyInitialClip(StyleResolver& styleResolver)
     692inline void StyleBuilderCustom::applyInitialClip(StyleResolver& styleResolver)
    619693{
    620694    styleResolver.style()->setClip(Length(), Length(), Length(), Length());
     
    622696}
    623697
    624 inline void applyInheritClip(StyleResolver& styleResolver)
     698inline void StyleBuilderCustom::applyInheritClip(StyleResolver& styleResolver)
    625699{
    626700    RenderStyle* parentStyle = styleResolver.parentStyle();
     
    631705}
    632706
    633 inline void applyValueClip(StyleResolver& styleResolver, CSSValue& value)
     707inline void StyleBuilderCustom::applyValueClip(StyleResolver& styleResolver, CSSValue& value)
    634708{
    635709    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     
    649723}
    650724
    651 inline void applyValueWebkitLocale(StyleResolver& styleResolver, CSSValue& value)
     725inline void StyleBuilderCustom::applyValueWebkitLocale(StyleResolver& styleResolver, CSSValue& value)
    652726{
    653727    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     
    663737}
    664738
    665 inline void applyValueWebkitWritingMode(StyleResolver& styleResolver, CSSValue& value)
     739inline void StyleBuilderCustom::applyValueWebkitWritingMode(StyleResolver& styleResolver, CSSValue& value)
    666740{
    667741    styleResolver.setWritingMode(downcast<CSSPrimitiveValue>(value));
     
    673747}
    674748
    675 inline void applyValueWebkitTextOrientation(StyleResolver& styleResolver, CSSValue& value)
     749inline void StyleBuilderCustom::applyValueWebkitTextOrientation(StyleResolver& styleResolver, CSSValue& value)
    676750{
    677751    styleResolver.setTextOrientation(downcast<CSSPrimitiveValue>(value));
    678752}
    679753
    680 inline void applyValueWebkitJustifySelf(StyleResolver& styleResolver, CSSValue& value)
     754inline void StyleBuilderCustom::applyValueWebkitJustifySelf(StyleResolver& styleResolver, CSSValue& value)
    681755{
    682756    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     
    689763}
    690764
    691 inline void applyValueWebkitPerspective(StyleResolver& styleResolver, CSSValue& value)
     765inline void StyleBuilderCustom::applyValueWebkitPerspective(StyleResolver& styleResolver, CSSValue& value)
    692766{
    693767    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     
    714788}
    715789
    716 } // namespace StyleBuilderFunctions
    717 
    718790} // namespace WebCore
    719791
  • trunk/Source/WebCore/css/makeprop.pl

    r176491 r176593  
    418418  next unless exists($propertiesWithStyleBuilderOptions{$name});
    419419
     420  my $scope = $propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "All" ? "StyleBuilderCustom" : "StyleBuilderFunctions";
     421  my $valueScope = $propertiesWithStyleBuilderOptions{$name}{"Custom"} eq "Value" ? "StyleBuilderCustom" : $scope;
     422
    420423  print STYLEBUILDER "    case CSSProperty" . $nameToId{$name} . ":\n";
    421424  print STYLEBUILDER "        if (isInitial)\n";
    422   print STYLEBUILDER "            StyleBuilderFunctions::applyInitial" . $nameToId{$name} . "(styleResolver);\n";
     425  print STYLEBUILDER "            " . $scope . "::applyInitial" . $nameToId{$name} . "(styleResolver);\n";
    423426  print STYLEBUILDER "        else if (isInherit)\n";
    424   print STYLEBUILDER "            StyleBuilderFunctions::applyInherit" . $nameToId{$name} . "(styleResolver);\n";
     427  print STYLEBUILDER "            " . $scope . "::applyInherit" . $nameToId{$name} . "(styleResolver);\n";
    425428  print STYLEBUILDER "        else\n";
    426   print STYLEBUILDER "            StyleBuilderFunctions::applyValue" . $nameToId{$name} . "(styleResolver, value);\n";
     429  print STYLEBUILDER "            " . $valueScope . "::applyValue" . $nameToId{$name} . "(styleResolver, value);\n";
    427430  print STYLEBUILDER "        return true;\n";
    428431}
  • trunk/Source/WebCore/rendering/style/RenderStyle.h

    r176369 r176593  
    129129    friend class RenderSVGResource; // FIXME: Needs to alter the visited state by hand. Should clean the SVG code up and move it into RenderStyle perhaps.
    130130    friend class RenderTreeAsText; // FIXME: Only needed so the render tree can keep lying and dump the wrong colors.  Rebaselining would allow this to be yanked.
     131    friend class StyleBuilderCustom; // Sets members directly.
    131132    friend class StyleResolver; // Sets members directly.
    132133
Note: See TracChangeset for help on using the changeset viewer.