Changeset 83700 in webkit
- Timestamp:
- Apr 12, 2011 10:12:39 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r83699 r83700 1 2011-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 1 17 2011-04-12 Sergey Glazunov <serg.glazunov@gmail.com> 2 18 -
trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp
r83417 r83700 39 39 namespace WebCore { 40 40 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 {} 41 class ApplyPropertyExpanding : public ApplyPropertyBase { 42 public: 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 } 69 private: 70 ApplyPropertyBase* m_propertyMap[5]; 71 }; 72 73 class ApplyPropertyExpandingSuppressValue : public ApplyPropertyExpanding { 74 public: 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 } 46 82 }; 47 83 … … 269 305 setPropertyValue(CSSPropertyWebkitBackgroundComposite, new ApplyPropertyFillLayer<CompositeOperator>(CSSPropertyWebkitBackgroundComposite, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, 270 306 &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 271 311 setPropertyValue(CSSPropertyBackgroundOrigin, new ApplyPropertyFillLayer<EFillBox>(CSSPropertyBackgroundOrigin, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, 272 312 &FillLayer::isOriginSet, &FillLayer::origin, &FillLayer::setOrigin, &FillLayer::clearOrigin, &FillLayer::initialFillOrigin, &CSSStyleSelector::mapFillOrigin)); 273 313 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 274 327 setPropertyValue(CSSPropertyBackgroundSize, new ApplyPropertyFillLayer<FillSize>(CSSPropertyBackgroundSize, BackgroundFillLayer, &RenderStyle::accessBackgroundLayers, &RenderStyle::backgroundLayers, 275 328 &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSStyleSelector::mapFillSize)); … … 282 335 setPropertyValue(CSSPropertyWebkitMaskComposite, new ApplyPropertyFillLayer<CompositeOperator>(CSSPropertyWebkitMaskComposite, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, 283 336 &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 284 341 setPropertyValue(CSSPropertyWebkitMaskOrigin, new ApplyPropertyFillLayer<EFillBox>(CSSPropertyWebkitMaskOrigin, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, 285 342 &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 286 358 setPropertyValue(CSSPropertyWebkitMaskSize, new ApplyPropertyFillLayer<FillSize>(CSSPropertyWebkitMaskSize, MaskFillLayer, &RenderStyle::accessMaskLayers, &RenderStyle::maskLayers, 287 359 &FillLayer::isSizeSet, &FillLayer::size, &FillLayer::setSize, &FillLayer::clearSize, &FillLayer::initialFillSize, &CSSStyleSelector::mapFillSize)); -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r83518 r83700 160 160 m_style->set##Prop(*primitiveValue); 161 161 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 232 162 #define HANDLE_ANIMATION_INHERIT_AND_INITIAL(prop, Prop) \ 233 163 if (isInherit) { \ … … 3911 3841 HANDLE_INHERIT_AND_INITIAL_AND_PRIMITIVE(whiteSpace, WhiteSpace) 3912 3842 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;3958 3843 case CSSPropertyBorderSpacing: { 3959 3844 if (isInherit) { … … 4022 3907 4023 3908 // 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;4030 3909 case CSSPropertyListStyleImage: 4031 3910 { … … 6174 6053 case CSSPropertyBackgroundOrigin: 6175 6054 case CSSPropertyWebkitBackgroundOrigin: 6055 case CSSPropertyBackgroundImage: 6176 6056 case CSSPropertyBackgroundSize: 6177 6057 case CSSPropertyWebkitBackgroundSize: … … 6180 6060 case CSSPropertyWebkitMaskComposite: 6181 6061 case CSSPropertyWebkitMaskOrigin: 6062 case CSSPropertyWebkitMaskImage: 6182 6063 case CSSPropertyWebkitMaskSize: 6183 6064 case CSSPropertyBackgroundColor: … … 6191 6072 case CSSPropertyWebkitTextFillColor: 6192 6073 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: 6193 6086 ASSERT_NOT_REACHED(); 6194 6087 return;
Note: See TracChangeset
for help on using the changeset viewer.