Changeset 85289 in webkit
- Timestamp:
- Apr 28, 2011 7:25:12 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r85286 r85289 1 2011-04-28 Luke Macpherson <macpherson@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Implement CSS border width and related properties in CSSStyleApplyProperty. 6 https://bugs.webkit.org/show_bug.cgi?id=59414 7 8 No new tests as no functionality added. 9 10 * css/CSSStyleApplyProperty.cpp: 11 Separated ApplyPropertyDefault into parent and child so that other classes could inherit 12 the applyInheritValue and applyInitialValue methods only. 13 This was necessary to avoid casting from CSSPrimitiveValue to inappropriate types in ApplyPropertyDefault::applyValue(). 14 15 Added ApplyPropertyWidth class for handling width based CSS properties. 16 * css/CSSStyleSelector.cpp: 17 Removed no-longer-required code for handling width based CSS properties. 18 * css/CSSStyleSelector.h: 19 Added a getter for m_rootElementStyle. 20 1 21 2011-04-28 Kent Tamura <tkent@chromium.org> 2 22 -
trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp
r85069 r85289 83 83 84 84 template <typename T> 85 class ApplyPropertyDefault : public ApplyPropertyBase {85 class ApplyPropertyDefaultBase : public ApplyPropertyBase { 86 86 public: 87 87 typedef T (RenderStyle::*GetterFunction)() const; … … 89 89 typedef T (*InitialFunction)(); 90 90 91 ApplyPropertyDefault (GetterFunction getter, SetterFunction setter, InitialFunction initial)91 ApplyPropertyDefaultBase(GetterFunction getter, SetterFunction setter, InitialFunction initial) 92 92 : m_getter(getter) 93 93 , m_setter(setter) … … 96 96 } 97 97 98 private: 98 99 virtual void applyInheritValue(CSSStyleSelector* selector) const 99 100 { … … 104 105 { 105 106 (selector->style()->*m_setter)((*m_initial)()); 106 }107 108 virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const109 {110 if (value->isPrimitiveValue())111 (selector->style()->*m_setter)(*(static_cast<CSSPrimitiveValue*>(value)));112 107 } 113 108 … … 118 113 }; 119 114 120 // CSSPropertyColor 115 116 template <typename T> 117 class ApplyPropertyDefault : public ApplyPropertyDefaultBase<T> { 118 public: 119 ApplyPropertyDefault(typename ApplyPropertyDefaultBase<T>::GetterFunction getter, typename ApplyPropertyDefaultBase<T>::SetterFunction setter, typename ApplyPropertyDefaultBase<T>::InitialFunction initial) 120 : ApplyPropertyDefaultBase<T>(getter, setter, initial) 121 { 122 } 123 124 protected: 125 virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const 126 { 127 if (value->isPrimitiveValue()) 128 (selector->style()->*ApplyPropertyDefaultBase<T>::m_setter)(*static_cast<CSSPrimitiveValue*>(value)); 129 } 130 }; 131 121 132 class ApplyPropertyColor : public ApplyPropertyBase { 122 133 public: … … 134 145 } 135 146 147 private: 136 148 virtual void applyInheritValue(CSSStyleSelector* selector) const 137 149 { … … 152 164 if (!value->isPrimitiveValue()) 153 165 return; 166 154 167 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 155 168 if (m_initial && primitiveValue->getIdent() == CSSValueCurrentcolor) … … 159 172 } 160 173 161 private:162 174 GetterFunction m_getter; 163 175 SetterFunction m_setter; … … 169 181 class ApplyPropertyDirection : public ApplyPropertyDefault<TextDirection> { 170 182 public: 171 ApplyPropertyDirection( TextDirection (RenderStyle::*getter)() const, void (RenderStyle::*setter)(TextDirection), TextDirection (*initial)())183 ApplyPropertyDirection(GetterFunction getter, SetterFunction setter, InitialFunction initial) 172 184 : ApplyPropertyDefault<TextDirection>(getter, setter, initial) 173 185 { 174 186 } 175 187 188 private: 176 189 virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const 177 190 { … … 203 216 } 204 217 218 private: 205 219 virtual void applyInheritValue(CSSStyleSelector* selector) const 206 220 { … … 276 290 }; 277 291 292 class ApplyPropertyWidth : public ApplyPropertyDefaultBase<unsigned short> { 293 public: 294 ApplyPropertyWidth(GetterFunction getter, SetterFunction setter, InitialFunction initial) 295 : ApplyPropertyDefaultBase<unsigned short>(getter, setter, initial) 296 { 297 } 298 299 private: 300 virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const 301 { 302 if (!value->isPrimitiveValue()) 303 return; 304 305 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 306 short width; 307 switch (primitiveValue->getIdent()) { 308 case CSSValueThin: 309 width = 1; 310 break; 311 case CSSValueMedium: 312 width = 3; 313 break; 314 case CSSValueThick: 315 width = 5; 316 break; 317 case CSSValueInvalid: 318 width = primitiveValue->computeLengthShort(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()); 319 // CSS2 box model does not allow negative lengths for borders. 320 if (width < 0) 321 return; 322 break; 323 default: 324 return; 325 } 326 327 (selector->style()->*m_setter)(width); 328 } 329 }; 330 278 331 const CSSStyleApplyProperty& CSSStyleApplyProperty::sharedCSSStyleApplyProperty() 279 332 { … … 359 412 setPropertyValue(CSSPropertyBorderLeftStyle, new ApplyPropertyDefault<EBorderStyle>(&RenderStyle::borderLeftStyle, &RenderStyle::setBorderLeftStyle, &RenderStyle::initialBorderStyle)); 360 413 414 setPropertyValue(CSSPropertyBorderTopWidth, new ApplyPropertyWidth(&RenderStyle::borderTopWidth, &RenderStyle::setBorderTopWidth, &RenderStyle::initialBorderWidth)); 415 setPropertyValue(CSSPropertyBorderRightWidth, new ApplyPropertyWidth(&RenderStyle::borderRightWidth, &RenderStyle::setBorderRightWidth, &RenderStyle::initialBorderWidth)); 416 setPropertyValue(CSSPropertyBorderBottomWidth, new ApplyPropertyWidth(&RenderStyle::borderBottomWidth, &RenderStyle::setBorderBottomWidth, &RenderStyle::initialBorderWidth)); 417 setPropertyValue(CSSPropertyBorderLeftWidth, new ApplyPropertyWidth(&RenderStyle::borderLeftWidth, &RenderStyle::setBorderLeftWidth, &RenderStyle::initialBorderWidth)); 418 setPropertyValue(CSSPropertyOutlineWidth, new ApplyPropertyWidth(&RenderStyle::outlineWidth, &RenderStyle::setOutlineWidth, &RenderStyle::initialBorderWidth)); 419 setPropertyValue(CSSPropertyWebkitColumnRuleWidth, new ApplyPropertyWidth(&RenderStyle::columnRuleWidth, &RenderStyle::setColumnRuleWidth, &RenderStyle::initialBorderWidth)); 420 361 421 setPropertyValue(CSSPropertyOutlineColor, new ApplyPropertyColor(&RenderStyle::outlineColor, &RenderStyle::setOutlineColor, &RenderStyle::color)); 362 422 -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r85267 r85289 3840 3840 } 3841 3841 3842 // length3843 case CSSPropertyBorderTopWidth:3844 case CSSPropertyBorderRightWidth:3845 case CSSPropertyBorderBottomWidth:3846 case CSSPropertyBorderLeftWidth:3847 case CSSPropertyOutlineWidth:3848 case CSSPropertyWebkitColumnRuleWidth:3849 {3850 if (isInherit) {3851 HANDLE_INHERIT_COND(CSSPropertyBorderTopWidth, borderTopWidth, BorderTopWidth)3852 HANDLE_INHERIT_COND(CSSPropertyBorderRightWidth, borderRightWidth, BorderRightWidth)3853 HANDLE_INHERIT_COND(CSSPropertyBorderBottomWidth, borderBottomWidth, BorderBottomWidth)3854 HANDLE_INHERIT_COND(CSSPropertyBorderLeftWidth, borderLeftWidth, BorderLeftWidth)3855 HANDLE_INHERIT_COND(CSSPropertyOutlineWidth, outlineWidth, OutlineWidth)3856 HANDLE_INHERIT_COND(CSSPropertyWebkitColumnRuleWidth, columnRuleWidth, ColumnRuleWidth)3857 return;3858 }3859 else if (isInitial) {3860 HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderTopWidth, BorderTopWidth, BorderWidth)3861 HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderRightWidth, BorderRightWidth, BorderWidth)3862 HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderBottomWidth, BorderBottomWidth, BorderWidth)3863 HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderLeftWidth, BorderLeftWidth, BorderWidth)3864 HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyOutlineWidth, OutlineWidth, BorderWidth)3865 HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyWebkitColumnRuleWidth, ColumnRuleWidth, BorderWidth)3866 return;3867 }3868 3869 if (!primitiveValue)3870 return;3871 short width = 3;3872 switch (primitiveValue->getIdent()) {3873 case CSSValueThin:3874 width = 1;3875 break;3876 case CSSValueMedium:3877 width = 3;3878 break;3879 case CSSValueThick:3880 width = 5;3881 break;3882 case CSSValueInvalid:3883 width = primitiveValue->computeLengthShort(style(), m_rootElementStyle, zoomFactor);3884 break;3885 default:3886 return;3887 }3888 3889 if (width < 0) return;3890 switch (id) {3891 case CSSPropertyBorderTopWidth:3892 m_style->setBorderTopWidth(width);3893 break;3894 case CSSPropertyBorderRightWidth:3895 m_style->setBorderRightWidth(width);3896 break;3897 case CSSPropertyBorderBottomWidth:3898 m_style->setBorderBottomWidth(width);3899 break;3900 case CSSPropertyBorderLeftWidth:3901 m_style->setBorderLeftWidth(width);3902 break;3903 case CSSPropertyOutlineWidth:3904 m_style->setOutlineWidth(width);3905 break;3906 case CSSPropertyWebkitColumnRuleWidth:3907 m_style->setColumnRuleWidth(width);3908 break;3909 default:3910 return;3911 }3912 return;3913 }3914 3915 3842 case CSSPropertyWebkitFontSmoothing: { 3916 3843 FontDescription fontDescription = m_style->fontDescription(); … … 5997 5924 case CSSPropertyBorderBottomStyle: 5998 5925 case CSSPropertyBorderLeftStyle: 5926 case CSSPropertyBorderTopWidth: 5927 case CSSPropertyBorderRightWidth: 5928 case CSSPropertyBorderBottomWidth: 5929 case CSSPropertyBorderLeftWidth: 5930 case CSSPropertyOutlineWidth: 5931 case CSSPropertyWebkitColumnRuleWidth: 5999 5932 case CSSPropertyOutlineColor: 6000 5933 case CSSPropertyWebkitColumnRuleColor: -
trunk/Source/WebCore/css/CSSStyleSelector.h
r84991 r85289 110 110 RenderStyle* style() const { return m_style.get(); } 111 111 RenderStyle* parentStyle() const { return m_parentStyle; } 112 RenderStyle* rootElementStyle() const { return m_rootElementStyle; } 112 113 Element* element() const { return m_element; } 113 114
Note: See TracChangeset
for help on using the changeset viewer.