Changeset 85069 in webkit
- Timestamp:
- Apr 27, 2011 11:44:00 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r85067 r85069 1 2011-04-27 Nikolas Zimmermann <nzimmermann@rim.com> 2 3 Reviewed by Antti Koivisto. 4 5 Cleanup CSSStyleApplyProperty.cpp 6 https://bugs.webkit.org/show_bug.cgi?id=59623 7 8 As first step remove ApplyPropertyColorBase, merge it with ApplyPropertyColor, there's no need for two seperated classes. 9 Use typedefs instead of repating the function pointer declarations in a few places. 10 11 * css/CSSStyleApplyProperty.cpp: 12 (WebCore::ApplyPropertyDefault::ApplyPropertyDefault): 13 (WebCore::ApplyPropertyColor::ApplyPropertyColor): 14 (WebCore::ApplyPropertyColor::applyInheritValue): 15 (WebCore::ApplyPropertyColor::applyInitialValue): 16 (WebCore::ApplyPropertyColor::applyValue): 17 (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty): 18 1 19 2011-04-27 Dan Bernstein <mitz@apple.com> 2 20 -
trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp
r84887 r85069 85 85 class ApplyPropertyDefault : public ApplyPropertyBase { 86 86 public: 87 ApplyPropertyDefault(T (RenderStyle::*getter)() const, void (RenderStyle::*setter)(T), T (*initial)()) 87 typedef T (RenderStyle::*GetterFunction)() const; 88 typedef void (RenderStyle::*SetterFunction)(T); 89 typedef T (*InitialFunction)(); 90 91 ApplyPropertyDefault(GetterFunction getter, SetterFunction setter, InitialFunction initial) 88 92 : m_getter(getter) 89 93 , m_setter(setter) … … 109 113 110 114 protected: 111 T (RenderStyle::*m_getter)() const;112 void (RenderStyle::*m_setter)(T);113 T (*m_initial)();115 GetterFunction m_getter; 116 SetterFunction m_setter; 117 InitialFunction m_initial; 114 118 }; 115 119 116 120 // CSSPropertyColor 117 class ApplyPropertyColorBase : public ApplyPropertyBase { 118 public: 119 ApplyPropertyColorBase(const Color& (RenderStyle::*getter)() const, const Color& (RenderStyle::*defaultValue)() const, void (RenderStyle::*setter)(const Color&)) 121 class ApplyPropertyColor : public ApplyPropertyBase { 122 public: 123 typedef const Color& (RenderStyle::*GetterFunction)() const; 124 typedef void (RenderStyle::*SetterFunction)(const Color&); 125 typedef const Color& (RenderStyle::*DefaultFunction)() const; 126 typedef Color (*InitialFunction)(); 127 128 ApplyPropertyColor(GetterFunction getter, SetterFunction setter, DefaultFunction defaultFunction, InitialFunction initialFunction = 0) 120 129 : m_getter(getter) 121 , m_defaultValue(defaultValue)122 130 , m_setter(setter) 123 { 124 } 131 , m_default(defaultFunction) 132 , m_initial(initialFunction) 133 { 134 } 135 125 136 virtual void applyInheritValue(CSSStyleSelector* selector) const 126 137 { 127 138 const Color& color = (selector->parentStyle()->*m_getter)(); 128 if (m_default Value&& !color.isValid())129 (selector->style()->*m_setter)((selector->parentStyle()->*m_default Value)());139 if (m_default && !color.isValid()) 140 (selector->style()->*m_setter)((selector->parentStyle()->*m_default)()); 130 141 else 131 142 (selector->style()->*m_setter)(color); 132 143 } 144 133 145 virtual void applyInitialValue(CSSStyleSelector* selector) const 134 146 { 135 Color color; 136 (selector->style()->*m_setter)(color); 137 } 138 virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const 139 { 140 if (value->isPrimitiveValue()) 141 (selector->style()->*m_setter)(selector->getColorFromPrimitiveValue(static_cast<CSSPrimitiveValue*>(value))); 142 } 143 protected: 144 const Color& (RenderStyle::*m_getter)() const; 145 const Color& (RenderStyle::*m_defaultValue)() const; 146 void (RenderStyle::*m_setter)(const Color&); 147 }; 148 149 class ApplyPropertyColor : public ApplyPropertyColorBase { 150 public: 151 ApplyPropertyColor(const Color& (RenderStyle::*getter)() const, void (RenderStyle::*setter)(const Color&), Color (*initialValue)()) 152 : ApplyPropertyColorBase(getter, 0, setter) 153 , m_initialValue(initialValue) 154 { 155 } 156 157 virtual void applyInitialValue(CSSStyleSelector* selector) const 158 { 159 (selector->style()->*m_setter)(m_initialValue()); 147 (selector->style()->*m_setter)(m_initial ? m_initial() : Color()); 160 148 } 161 149 … … 164 152 if (!value->isPrimitiveValue()) 165 153 return; 166 167 if ( (static_cast<CSSPrimitiveValue*>(value))->getIdent() == CSSValueCurrentcolor)154 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 155 if (m_initial && primitiveValue->getIdent() == CSSValueCurrentcolor) 168 156 applyInheritValue(selector); 169 157 else 170 ApplyPropertyColorBase::applyValue(selector, value); 171 } 172 protected: 173 Color (*m_initialValue)(); 158 (selector->style()->*m_setter)(selector->getColorFromPrimitiveValue(primitiveValue)); 159 } 160 161 private: 162 GetterFunction m_getter; 163 SetterFunction m_setter; 164 DefaultFunction m_default; 165 InitialFunction m_initial; 174 166 }; 175 167 … … 295 287 m_propertyMap[i] = 0; 296 288 297 setPropertyValue(CSSPropertyColor, new ApplyPropertyColor(&RenderStyle::color, &RenderStyle::setColor, RenderStyle::initialColor));289 setPropertyValue(CSSPropertyColor, new ApplyPropertyColor(&RenderStyle::color, &RenderStyle::setColor, 0, RenderStyle::initialColor)); 298 290 setPropertyValue(CSSPropertyDirection, new ApplyPropertyDirection(&RenderStyle::direction, &RenderStyle::setDirection, RenderStyle::initialDirection)); 299 291 … … 356 348 setPropertyValue(CSSPropertyWebkitMaskRepeat, new ApplyPropertyExpandingSuppressValue(propertyValue(CSSPropertyBackgroundRepeatX), propertyValue(CSSPropertyBackgroundRepeatY))); 357 349 358 setPropertyValue(CSSPropertyBackgroundColor, new ApplyPropertyColor Base(&RenderStyle::backgroundColor, 0, &RenderStyle::setBackgroundColor));359 setPropertyValue(CSSPropertyBorderBottomColor, new ApplyPropertyColor Base(&RenderStyle::borderBottomColor, &RenderStyle::color, &RenderStyle::setBorderBottomColor));360 setPropertyValue(CSSPropertyBorderLeftColor, new ApplyPropertyColor Base(&RenderStyle::borderLeftColor, &RenderStyle::color, &RenderStyle::setBorderLeftColor));361 setPropertyValue(CSSPropertyBorderRightColor, new ApplyPropertyColor Base(&RenderStyle::borderRightColor, &RenderStyle::color, &RenderStyle::setBorderRightColor));362 setPropertyValue(CSSPropertyBorderTopColor, new ApplyPropertyColor Base(&RenderStyle::borderTopColor, &RenderStyle::color, &RenderStyle::setBorderTopColor));350 setPropertyValue(CSSPropertyBackgroundColor, new ApplyPropertyColor(&RenderStyle::backgroundColor, &RenderStyle::setBackgroundColor, 0)); 351 setPropertyValue(CSSPropertyBorderBottomColor, new ApplyPropertyColor(&RenderStyle::borderBottomColor, &RenderStyle::setBorderBottomColor, &RenderStyle::color)); 352 setPropertyValue(CSSPropertyBorderLeftColor, new ApplyPropertyColor(&RenderStyle::borderLeftColor, &RenderStyle::setBorderLeftColor, &RenderStyle::color)); 353 setPropertyValue(CSSPropertyBorderRightColor, new ApplyPropertyColor(&RenderStyle::borderRightColor, &RenderStyle::setBorderRightColor, &RenderStyle::color)); 354 setPropertyValue(CSSPropertyBorderTopColor, new ApplyPropertyColor(&RenderStyle::borderTopColor, &RenderStyle::setBorderTopColor, &RenderStyle::color)); 363 355 364 356 setPropertyValue(CSSPropertyBorderTopStyle, new ApplyPropertyDefault<EBorderStyle>(&RenderStyle::borderTopStyle, &RenderStyle::setBorderTopStyle, &RenderStyle::initialBorderStyle)); … … 367 359 setPropertyValue(CSSPropertyBorderLeftStyle, new ApplyPropertyDefault<EBorderStyle>(&RenderStyle::borderLeftStyle, &RenderStyle::setBorderLeftStyle, &RenderStyle::initialBorderStyle)); 368 360 369 setPropertyValue(CSSPropertyOutlineColor, new ApplyPropertyColor Base(&RenderStyle::outlineColor, &RenderStyle::color, &RenderStyle::setOutlineColor));361 setPropertyValue(CSSPropertyOutlineColor, new ApplyPropertyColor(&RenderStyle::outlineColor, &RenderStyle::setOutlineColor, &RenderStyle::color)); 370 362 371 363 setPropertyValue(CSSPropertyOverflowX, new ApplyPropertyDefault<EOverflow>(&RenderStyle::overflowX, &RenderStyle::setOverflowX, &RenderStyle::initialOverflowX)); … … 373 365 setPropertyValue(CSSPropertyOverflow, new ApplyPropertyExpanding(propertyValue(CSSPropertyOverflowX), propertyValue(CSSPropertyOverflowY))); 374 366 375 setPropertyValue(CSSPropertyWebkitColumnRuleColor, new ApplyPropertyColor Base(&RenderStyle::columnRuleColor, &RenderStyle::color, &RenderStyle::setColumnRuleColor));376 setPropertyValue(CSSPropertyWebkitTextEmphasisColor, new ApplyPropertyColor Base(&RenderStyle::textEmphasisColor, &RenderStyle::color, &RenderStyle::setTextEmphasisColor));377 setPropertyValue(CSSPropertyWebkitTextFillColor, new ApplyPropertyColor Base(&RenderStyle::textFillColor, &RenderStyle::color, &RenderStyle::setTextFillColor));378 setPropertyValue(CSSPropertyWebkitTextStrokeColor, new ApplyPropertyColor Base(&RenderStyle::textStrokeColor, &RenderStyle::color, &RenderStyle::setTextStrokeColor));367 setPropertyValue(CSSPropertyWebkitColumnRuleColor, new ApplyPropertyColor(&RenderStyle::columnRuleColor, &RenderStyle::setColumnRuleColor, &RenderStyle::color)); 368 setPropertyValue(CSSPropertyWebkitTextEmphasisColor, new ApplyPropertyColor(&RenderStyle::textEmphasisColor, &RenderStyle::setTextEmphasisColor, &RenderStyle::color)); 369 setPropertyValue(CSSPropertyWebkitTextFillColor, new ApplyPropertyColor(&RenderStyle::textFillColor, &RenderStyle::setTextFillColor, &RenderStyle::color)); 370 setPropertyValue(CSSPropertyWebkitTextStrokeColor, new ApplyPropertyColor(&RenderStyle::textStrokeColor, &RenderStyle::setTextStrokeColor, &RenderStyle::color)); 379 371 } 380 372
Note: See TracChangeset
for help on using the changeset viewer.