Changeset 175467 in webkit


Ignore:
Timestamp:
Nov 3, 2014 3:08:33 AM (9 years ago)
Author:
Chris Dumez
Message:

Move 'zoom' CSS property to the new StyleBuilder
https://bugs.webkit.org/show_bug.cgi?id=138297

Reviewed by Antti Koivisto.

Move 'zoom' CSS property from DeprecatedStyleBuilder to the new
StyleBuilder by using custom code as it requires special handling.

No new tests, no behavior change.

  • css/makeprop.pl:

Add support for Custom=All StyleBuilder option to indicate
that the property requires custom code to set the initial,
inherit and current values.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r175466 r175467  
     12014-11-03  Chris Dumez  <cdumez@apple.com>
     2
     3        Move 'zoom' CSS property to the new StyleBuilder
     4        https://bugs.webkit.org/show_bug.cgi?id=138297
     5
     6        Reviewed by Antti Koivisto.
     7
     8        Move 'zoom' CSS property from DeprecatedStyleBuilder to the new
     9        StyleBuilder by using custom code as it requires special handling.
     10
     11        No new tests, no behavior change.
     12
     13        * css/makeprop.pl:
     14        Add support for Custom=All StyleBuilder option to indicate
     15        that the property requires custom code to set the initial,
     16        inherit and current values.
     17
    1182014-11-03  Sungmann Cho  <sungmann.cho@navercorp.com>
    219
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r175464 r175467  
    4545// css/StyleBuilderConverter.h should be used.
    4646//
    47 // * Custom=Value:
    48 // This option is used to indicate that the CSS property requires special
     47// * Custom=[Value|All]:
     48// Custom=Value option is used to indicate that the CSS property requires special
    4949// handling to set its value, and a regular Converter helper cannot be
    5050// used. The Custom code for the property should be located in
    5151// css/StyleBuilderCustom.h and named applyValue[CSSPropertyName]().
     52// If special handling is also needed to apply inherit or initial value, use
     53// Custom=All.
    5254
    5355
     
    7678-webkit-writing-mode [Inherited]
    7779-epub-writing-mode = -webkit-writing-mode
    78 zoom
     80zoom [NewStyleBuilder, Custom=All]
    7981
    8082// line height needs to be right after the above high-priority properties
  • trunk/Source/WebCore/css/DeprecatedStyleBuilder.cpp

    r175464 r175467  
    17011701        styleResolver->style()->setAspectRatioDenominator(aspectRatioValue.denominatorValue());
    17021702        styleResolver->style()->setAspectRatioNumerator(aspectRatioValue.numeratorValue());
    1703     }
    1704 
    1705     static PropertyHandler createHandler()
    1706     {
    1707         return PropertyHandler(&applyInheritValue, &applyInitialValue, &applyValue);
    1708     }
    1709 };
    1710 
    1711 class ApplyPropertyZoom {
    1712 private:
    1713     static void resetEffectiveZoom(StyleResolver* styleResolver)
    1714     {
    1715         // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect.
    1716         styleResolver->setEffectiveZoom(styleResolver->parentStyle() ? styleResolver->parentStyle()->effectiveZoom() : RenderStyle::initialZoom());
    1717     }
    1718 
    1719 public:
    1720     static void applyInheritValue(CSSPropertyID, StyleResolver* styleResolver)
    1721     {
    1722         resetEffectiveZoom(styleResolver);
    1723         styleResolver->setZoom(styleResolver->parentStyle()->zoom());
    1724     }
    1725 
    1726     static void applyInitialValue(CSSPropertyID, StyleResolver* styleResolver)
    1727     {
    1728         resetEffectiveZoom(styleResolver);
    1729         styleResolver->setZoom(RenderStyle::initialZoom());
    1730     }
    1731 
    1732     static void applyValue(CSSPropertyID, StyleResolver* styleResolver, CSSValue* value)
    1733     {
    1734         CSSPrimitiveValue& primitiveValue = downcast<CSSPrimitiveValue>(*value);
    1735 
    1736         if (primitiveValue.getValueID() == CSSValueNormal) {
    1737             resetEffectiveZoom(styleResolver);
    1738             styleResolver->setZoom(RenderStyle::initialZoom());
    1739         } else if (primitiveValue.getValueID() == CSSValueReset) {
    1740             styleResolver->setEffectiveZoom(RenderStyle::initialZoom());
    1741             styleResolver->setZoom(RenderStyle::initialZoom());
    1742         } else if (primitiveValue.getValueID() == CSSValueDocument) {
    1743             float docZoom = styleResolver->rootElementStyle() ? styleResolver->rootElementStyle()->zoom() : RenderStyle::initialZoom();
    1744             styleResolver->setEffectiveZoom(docZoom);
    1745             styleResolver->setZoom(docZoom);
    1746         } else if (primitiveValue.isPercentage()) {
    1747             resetEffectiveZoom(styleResolver);
    1748             if (float percent = primitiveValue.getFloatValue())
    1749                 styleResolver->setZoom(percent / 100.0f);
    1750         } else if (primitiveValue.isNumber()) {
    1751             resetEffectiveZoom(styleResolver);
    1752             if (float number = primitiveValue.getFloatValue())
    1753                 styleResolver->setZoom(number);
    1754         }
    17551703    }
    17561704
     
    21302078
    21312079    setPropertyHandler(CSSPropertyZIndex, ApplyPropertyAuto<int, &RenderStyle::zIndex, &RenderStyle::setZIndex, &RenderStyle::hasAutoZIndex, &RenderStyle::setHasAutoZIndex>::createHandler());
    2132     setPropertyHandler(CSSPropertyZoom, ApplyPropertyZoom::createHandler());
    21332080}
    21342081
  • trunk/Source/WebCore/css/StyleBuilderCustom.h

    r175458 r175467  
    6767}
    6868
     69static inline void resetEffectiveZoom(StyleResolver& styleResolver)
     70{
     71    // Reset the zoom in effect. This allows the setZoom method to accurately compute a new zoom in effect.
     72    styleResolver.setEffectiveZoom(styleResolver.parentStyle() ? styleResolver.parentStyle()->effectiveZoom() : RenderStyle::initialZoom());
     73}
     74
     75inline void applyInitialZoom(StyleResolver& styleResolver)
     76{
     77    resetEffectiveZoom(styleResolver);
     78    styleResolver.setZoom(RenderStyle::initialZoom());
     79}
     80
     81inline void applyInheritZoom(StyleResolver& styleResolver)
     82{
     83    resetEffectiveZoom(styleResolver);
     84    styleResolver.setZoom(styleResolver.parentStyle()->zoom());
     85}
     86
     87inline void applyValueZoom(StyleResolver& styleResolver, CSSValue& value)
     88{
     89    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
     90
     91    if (primitiveValue.getValueID() == CSSValueNormal) {
     92        resetEffectiveZoom(styleResolver);
     93        styleResolver.setZoom(RenderStyle::initialZoom());
     94    } else if (primitiveValue.getValueID() == CSSValueReset) {
     95        styleResolver.setEffectiveZoom(RenderStyle::initialZoom());
     96        styleResolver.setZoom(RenderStyle::initialZoom());
     97    } else if (primitiveValue.getValueID() == CSSValueDocument) {
     98        float docZoom = styleResolver.rootElementStyle() ? styleResolver.rootElementStyle()->zoom() : RenderStyle::initialZoom();
     99        styleResolver.setEffectiveZoom(docZoom);
     100        styleResolver.setZoom(docZoom);
     101    } else if (primitiveValue.isPercentage()) {
     102        resetEffectiveZoom(styleResolver);
     103        if (float percent = primitiveValue.getFloatValue())
     104            styleResolver.setZoom(percent / 100.0f);
     105    } else if (primitiveValue.isNumber()) {
     106        resetEffectiveZoom(styleResolver);
     107        if (float number = primitiveValue.getFloatValue())
     108            styleResolver.setZoom(number);
     109    }
     110}
     111
    69112} // namespace StyleBuilderFunctions
    70113
  • trunk/Source/WebCore/css/makeprop.pl

    r175267 r175467  
    380380  next unless exists($propertiesUsingNewStyleBuilder{$name});
    381381
     382  next if $propertiesUsingNewStyleBuilder{$name}{"Custom"} eq "All";
     383
    382384  my $setValue = "styleResolver.style()->" . $propertiesUsingNewStyleBuilder{$name}{"Setter"};
    383385  print STYLEBUILDER "    inline void applyInitial" . $nameToId{$name} . "(StyleResolver& styleResolver)\n";
Note: See TracChangeset for help on using the changeset viewer.