Changeset 83700 in webkit


Ignore:
Timestamp:
Apr 12, 2011 10:12:39 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-12 Luke Macpherson <macpherson@chromium.org>

Reviewed by Dimitri Glazkov.

Implement remaining Background and Mask css properties in CSSStyleApplyProperty
https://bugs.webkit.org/show_bug.cgi?id=58390

No new tests required as no functionality changed.

  • css/CSSStyleApplyProperty.cpp: (WebCore::ApplyPropertyExpanding): Class to expand one property to 0-4 properties. (WebCore::ApplyPropertyExpandingSuppressValue): Expand properties but suppress applyValue.

(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
(WebCore::CSSStyleSelector::applyProperty): Remove implementations that have been moved to CSSStyleApplyProperty.

Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r83699 r83700  
     12011-04-12  Luke Macpherson   <macpherson@chromium.org>
     2
     3        Reviewed by Dimitri Glazkov.
     4
     5        Implement remaining Background and Mask css properties in CSSStyleApplyProperty
     6        https://bugs.webkit.org/show_bug.cgi?id=58390
     7
     8        No new tests required as no functionality changed.
     9
     10        * css/CSSStyleApplyProperty.cpp:
     11        (WebCore::ApplyPropertyExpanding): Class to expand one property to 0-4 properties.
     12        (WebCore::ApplyPropertyExpandingSuppressValue): Expand properties but suppress applyValue.
     13
     14        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
     15        (WebCore::CSSStyleSelector::applyProperty): Remove implementations that have been moved to CSSStyleApplyProperty.
     16
    1172011-04-12  Sergey Glazunov  <serg.glazunov@gmail.com>
    218
  • trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp

    r83417 r83700  
    3939namespace WebCore {
    4040
    41 class ApplyPropertyNull : public ApplyPropertyBase {
    42 public:
    43     virtual void applyInheritValue(CSSStyleSelector*) const {}
    44     virtual void applyInitialValue(CSSStyleSelector*) const {}
    45     virtual void applyValue(CSSStyleSelector*, CSSValue*) const {}
     41class ApplyPropertyExpanding : public ApplyPropertyBase {
     42public:
     43    ApplyPropertyExpanding(ApplyPropertyBase* one = 0, ApplyPropertyBase* two = 0, ApplyPropertyBase *three = 0, ApplyPropertyBase* four = 0)
     44    {
     45        m_propertyMap[0] = one;
     46        m_propertyMap[1] = two;
     47        m_propertyMap[2] = three;
     48        m_propertyMap[3] = four;
     49        m_propertyMap[4] = 0; // always null terminated
     50    }
     51
     52    virtual void applyInheritValue(CSSStyleSelector* selector) const
     53    {
     54        for (ApplyPropertyBase* const* e = m_propertyMap; *e; e++)
     55            (*e)->applyInheritValue(selector);
     56    }
     57
     58    virtual void applyInitialValue(CSSStyleSelector* selector) const
     59    {
     60        for (ApplyPropertyBase* const* e = m_propertyMap; *e; e++)
     61            (*e)->applyInitialValue(selector);
     62    }
     63
     64    virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const
     65    {
     66        for (ApplyPropertyBase* const* e = m_propertyMap; *e; e++)
     67            (*e)->applyValue(selector, value);
     68    }
     69private:
     70    ApplyPropertyBase* m_propertyMap[5];
     71};
     72
     73class ApplyPropertyExpandingSuppressValue : public ApplyPropertyExpanding {
     74public:
     75    ApplyPropertyExpandingSuppressValue(ApplyPropertyBase* one = 0, ApplyPropertyBase* two = 0, ApplyPropertyBase *three = 0, ApplyPropertyBase* four = 0)
     76        : ApplyPropertyExpanding(one, two, three, four) {}
     77
     78    virtual void applyValue(CSSStyleSelector*, CSSValue*)
     79    {
     80        ASSERT_NOT_REACHED();
     81    }
    4682};
    4783
     
    269305    setPropertyValue(CSSPropertyWebkitBackgroundComposite, new ApplyPropertyFillLayer<CompositeOperator>(CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
    270306            &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSStyleSelector::mapFillComposite));
     307
     308    setPropertyValue(CSSPropertyBackgroundImage, new ApplyPropertyFillLayer<StyleImage*>(CSSPropertyBackgroundImage, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
     309                &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSStyleSelector::mapFillImage));
     310
    271311    setPropertyValue(CSSPropertyBackgroundOrigin, new ApplyPropertyFillLayer<EFillBox>(CSSPropertyBackgroundOrigin, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
    272312            &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSStyleSelector::mapFillOrigin));
    273313    setPropertyValue(CSSPropertyWebkitBackgroundOrigin, CSSPropertyBackgroundOrigin);
     314
     315    setPropertyValue(CSSPropertyBackgroundPositionX, new ApplyPropertyFillLayer<Length>(CSSPropertyBackgroundPositionX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
     316                &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &CSSStyleSelector::mapFillXPosition));
     317    setPropertyValue(CSSPropertyBackgroundPositionY, new ApplyPropertyFillLayer<Length>(CSSPropertyBackgroundPositionY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
     318                    &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &CSSStyleSelector::mapFillYPosition));
     319    setPropertyValue(CSSPropertyBackgroundPosition, new ApplyPropertyExpandingSuppressValue(propertyValue(CSSPropertyBackgroundPositionX), propertyValue(CSSPropertyBackgroundPositionY)));
     320
     321    setPropertyValue(CSSPropertyBackgroundRepeatX, new ApplyPropertyFillLayer<EFillRepeat>(CSSPropertyBackgroundRepeatX, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
     322                &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &CSSStyleSelector::mapFillRepeatX));
     323    setPropertyValue(CSSPropertyBackgroundRepeatY, new ApplyPropertyFillLayer<EFillRepeat>(CSSPropertyBackgroundRepeatY, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
     324                    &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &CSSStyleSelector::mapFillRepeatY));
     325    setPropertyValue(CSSPropertyBackgroundRepeat, new ApplyPropertyExpandingSuppressValue(propertyValue(CSSPropertyBackgroundRepeatX), propertyValue(CSSPropertyBackgroundRepeatY)));
     326
    274327    setPropertyValue(CSSPropertyBackgroundSize, new ApplyPropertyFillLayer<FillSize>(CSSPropertyBackgroundSize, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers,
    275328            &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSStyleSelector::mapFillSize));
     
    282335    setPropertyValue(CSSPropertyWebkitMaskComposite, new ApplyPropertyFillLayer<CompositeOperator>(CSSPropertyWebkitMaskComposite, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
    283336            &FillLayer::isCompositeSet, &FillLayer::composite, &FillLayer::setComposite, &FillLayer::clearComposite, &FillLayer::initialFillComposite, &CSSStyleSelector::mapFillComposite));
     337
     338    setPropertyValue(CSSPropertyWebkitMaskImage, new ApplyPropertyFillLayer<StyleImage*>(CSSPropertyWebkitMaskImage, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
     339                &FillLayer::isImageSet, &FillLayer::image, &FillLayer::setImage, &FillLayer::clearImage, &FillLayer::initialFillImage, &CSSStyleSelector::mapFillImage));
     340
    284341    setPropertyValue(CSSPropertyWebkitMaskOrigin, new ApplyPropertyFillLayer<EFillBox>(CSSPropertyWebkitMaskOrigin, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
    285342            &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSStyleSelector::mapFillOrigin));
     343    setPropertyValue(CSSPropertyWebkitMaskSize, new ApplyPropertyFillLayer<FillSize>(CSSPropertyWebkitMaskSize, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
     344            &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSStyleSelector::mapFillSize));
     345
     346    setPropertyValue(CSSPropertyWebkitMaskPositionX, new ApplyPropertyFillLayer<Length>(CSSPropertyWebkitMaskPositionX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
     347                &FillLayer::isXPositionSet, &FillLayer::xPosition, &FillLayer::setXPosition, &FillLayer::clearXPosition, &FillLayer::initialFillXPosition, &CSSStyleSelector::mapFillXPosition));
     348    setPropertyValue(CSSPropertyWebkitMaskPositionY, new ApplyPropertyFillLayer<Length>(CSSPropertyWebkitMaskPositionY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
     349                    &FillLayer::isYPositionSet, &FillLayer::yPosition, &FillLayer::setYPosition, &FillLayer::clearYPosition, &FillLayer::initialFillYPosition, &CSSStyleSelector::mapFillYPosition));
     350    setPropertyValue(CSSPropertyWebkitMaskPosition, new ApplyPropertyExpandingSuppressValue(propertyValue(CSSPropertyWebkitMaskPositionX), propertyValue(CSSPropertyWebkitMaskPositionY)));
     351
     352    setPropertyValue(CSSPropertyWebkitMaskRepeatX, new ApplyPropertyFillLayer<EFillRepeat>(CSSPropertyWebkitMaskRepeatX, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
     353                &FillLayer::isRepeatXSet, &FillLayer::repeatX, &FillLayer::setRepeatX, &FillLayer::clearRepeatX, &FillLayer::initialFillRepeatX, &CSSStyleSelector::mapFillRepeatX));
     354    setPropertyValue(CSSPropertyWebkitMaskRepeatY, new ApplyPropertyFillLayer<EFillRepeat>(CSSPropertyWebkitMaskRepeatY, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
     355                    &FillLayer::isRepeatYSet, &FillLayer::repeatY, &FillLayer::setRepeatY, &FillLayer::clearRepeatY, &FillLayer::initialFillRepeatY, &CSSStyleSelector::mapFillRepeatY));
     356    setPropertyValue(CSSPropertyWebkitMaskRepeat, new ApplyPropertyExpandingSuppressValue(propertyValue(CSSPropertyBackgroundRepeatX), propertyValue(CSSPropertyBackgroundRepeatY)));
     357
    286358    setPropertyValue(CSSPropertyWebkitMaskSize, new ApplyPropertyFillLayer<FillSize>(CSSPropertyWebkitMaskSize, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers,
    287359            &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSStyleSelector::mapFillSize));
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r83518 r83700  
    160160    m_style->set##Prop(*primitiveValue);
    161161
    162 #define HANDLE_FILL_LAYER_INHERIT_AND_INITIAL(layerType, LayerType, prop, Prop) \
    163 if (isInherit) { \
    164     FillLayer* currChild = m_style->access##LayerType##Layers(); \
    165     FillLayer* prevChild = 0; \
    166     const FillLayer* currParent = m_parentStyle->layerType##Layers(); \
    167     while (currParent && currParent->is##Prop##Set()) { \
    168         if (!currChild) { \
    169             /* Need to make a new layer.*/ \
    170             currChild = new FillLayer(LayerType##FillLayer); \
    171             prevChild->setNext(currChild); \
    172         } \
    173         currChild->set##Prop(currParent->prop()); \
    174         prevChild = currChild; \
    175         currChild = prevChild->next(); \
    176         currParent = currParent->next(); \
    177     } \
    178     \
    179     while (currChild) { \
    180         /* Reset any remaining layers to not have the property set. */ \
    181         currChild->clear##Prop(); \
    182         currChild = currChild->next(); \
    183     } \
    184 } else if (isInitial) { \
    185     FillLayer* currChild = m_style->access##LayerType##Layers(); \
    186     currChild->set##Prop(FillLayer::initialFill##Prop(LayerType##FillLayer)); \
    187     for (currChild = currChild->next(); currChild; currChild = currChild->next()) \
    188         currChild->clear##Prop(); \
    189 }
    190 
    191 #define HANDLE_FILL_LAYER_VALUE(layerType, LayerType, prop, Prop, value) { \
    192 HANDLE_FILL_LAYER_INHERIT_AND_INITIAL(layerType, LayerType, prop, Prop) \
    193 if (isInherit || isInitial) \
    194     return; \
    195 FillLayer* currChild = m_style->access##LayerType##Layers(); \
    196 FillLayer* prevChild = 0; \
    197 if (value->isValueList()) { \
    198     /* Walk each value and put it into a layer, creating new layers as needed. */ \
    199     CSSValueList* valueList = static_cast<CSSValueList*>(value); \
    200     for (unsigned int i = 0; i < valueList->length(); i++) { \
    201         if (!currChild) { \
    202             /* Need to make a new layer to hold this value */ \
    203             currChild = new FillLayer(LayerType##FillLayer); \
    204             prevChild->setNext(currChild); \
    205         } \
    206         mapFill##Prop(property, currChild, valueList->itemWithoutBoundsCheck(i)); \
    207         prevChild = currChild; \
    208         currChild = currChild->next(); \
    209     } \
    210 } else { \
    211     mapFill##Prop(property, currChild, value); \
    212     currChild = currChild->next(); \
    213 } \
    214 while (currChild) { \
    215     /* Reset all remaining layers to not have the property set. */ \
    216     currChild->clear##Prop(); \
    217     currChild = currChild->next(); \
    218 } }
    219 
    220 #define HANDLE_BACKGROUND_INHERIT_AND_INITIAL(prop, Prop) \
    221 HANDLE_FILL_LAYER_INHERIT_AND_INITIAL(background, Background, prop, Prop)
    222 
    223 #define HANDLE_BACKGROUND_VALUE(prop, Prop, value) \
    224 HANDLE_FILL_LAYER_VALUE(background, Background, prop, Prop, value)
    225 
    226 #define HANDLE_MASK_INHERIT_AND_INITIAL(prop, Prop) \
    227 HANDLE_FILL_LAYER_INHERIT_AND_INITIAL(mask, Mask, prop, Prop)
    228 
    229 #define HANDLE_MASK_VALUE(prop, Prop, value) \
    230 HANDLE_FILL_LAYER_VALUE(mask, Mask, prop, Prop, value)
    231 
    232162#define HANDLE_ANIMATION_INHERIT_AND_INITIAL(prop, Prop) \
    233163if (isInherit) { \
     
    39113841        HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(whiteSpace, WhiteSpace)
    39123842        return;
    3913 
    3914     case CSSPropertyBackgroundPosition:
    3915         HANDLE_BACKGROUND_INHERIT_AND_INITIAL(xPosition, XPosition);
    3916         HANDLE_BACKGROUND_INHERIT_AND_INITIAL(yPosition, YPosition);
    3917         return;
    3918     case CSSPropertyBackgroundPositionX: {
    3919         HANDLE_BACKGROUND_VALUE(xPosition, XPosition, value)
    3920         return;
    3921     }
    3922     case CSSPropertyBackgroundPositionY: {
    3923         HANDLE_BACKGROUND_VALUE(yPosition, YPosition, value)
    3924         return;
    3925     }
    3926     case CSSPropertyWebkitMaskPosition:
    3927         HANDLE_MASK_INHERIT_AND_INITIAL(xPosition, XPosition);
    3928         HANDLE_MASK_INHERIT_AND_INITIAL(yPosition, YPosition);
    3929         return;
    3930     case CSSPropertyWebkitMaskPositionX: {
    3931         HANDLE_MASK_VALUE(xPosition, XPosition, value)
    3932         return;
    3933     }
    3934     case CSSPropertyWebkitMaskPositionY: {
    3935         HANDLE_MASK_VALUE(yPosition, YPosition, value)
    3936         return;
    3937     }
    3938     case CSSPropertyBackgroundRepeat:
    3939         HANDLE_BACKGROUND_INHERIT_AND_INITIAL(repeatX, RepeatX);
    3940         HANDLE_BACKGROUND_INHERIT_AND_INITIAL(repeatY, RepeatY);
    3941         return;
    3942     case CSSPropertyBackgroundRepeatX:
    3943         HANDLE_BACKGROUND_VALUE(repeatX, RepeatX, value)
    3944         return;
    3945     case CSSPropertyBackgroundRepeatY:
    3946         HANDLE_BACKGROUND_VALUE(repeatY, RepeatY, value)
    3947         return;
    3948     case CSSPropertyWebkitMaskRepeat:
    3949         HANDLE_MASK_INHERIT_AND_INITIAL(repeatX, RepeatX);
    3950         HANDLE_MASK_INHERIT_AND_INITIAL(repeatY, RepeatY);
    3951         return;
    3952     case CSSPropertyWebkitMaskRepeatX:
    3953         HANDLE_MASK_VALUE(repeatX, RepeatX, value)
    3954         return;
    3955     case CSSPropertyWebkitMaskRepeatY:
    3956         HANDLE_MASK_VALUE(repeatY, RepeatY, value)
    3957         return;
    39583843    case CSSPropertyBorderSpacing: {
    39593844        if (isInherit) {
     
    40223907   
    40233908// uri || inherit
    4024     case CSSPropertyBackgroundImage:
    4025         HANDLE_BACKGROUND_VALUE(image, Image, value)
    4026         return;
    4027     case CSSPropertyWebkitMaskImage:
    4028         HANDLE_MASK_VALUE(image, Image, value)
    4029         return;
    40303909    case CSSPropertyListStyleImage:
    40313910    {
     
    61746053    case CSSPropertyBackgroundOrigin:
    61756054    case CSSPropertyWebkitBackgroundOrigin:
     6055    case CSSPropertyBackgroundImage:
    61766056    case CSSPropertyBackgroundSize:
    61776057    case CSSPropertyWebkitBackgroundSize:
     
    61806060    case CSSPropertyWebkitMaskComposite:
    61816061    case CSSPropertyWebkitMaskOrigin:
     6062    case CSSPropertyWebkitMaskImage:
    61826063    case CSSPropertyWebkitMaskSize:
    61836064    case CSSPropertyBackgroundColor:
     
    61916072    case CSSPropertyWebkitTextFillColor:
    61926073    case CSSPropertyWebkitTextStrokeColor:
     6074    case CSSPropertyBackgroundPosition:
     6075    case CSSPropertyBackgroundPositionX:
     6076    case CSSPropertyBackgroundPositionY:
     6077    case CSSPropertyWebkitMaskPosition:
     6078    case CSSPropertyWebkitMaskPositionX:
     6079    case CSSPropertyWebkitMaskPositionY:
     6080    case CSSPropertyBackgroundRepeat:
     6081    case CSSPropertyBackgroundRepeatX:
     6082    case CSSPropertyBackgroundRepeatY:
     6083    case CSSPropertyWebkitMaskRepeat:
     6084    case CSSPropertyWebkitMaskRepeatX:
     6085    case CSSPropertyWebkitMaskRepeatY:
    61936086        ASSERT_NOT_REACHED();
    61946087        return;
Note: See TracChangeset for help on using the changeset viewer.