Changeset 92253 in webkit
- Timestamp:
- Aug 2, 2011 7:11:09 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r92252 r92253 1 2011-08-02 Luke Macpherson <macpherson@chromium.org> 2 3 Clean up value clampling in CSSStyleSelector and CSSPrimitiveValue. 4 https://bugs.webkit.org/show_bug.cgi?id=65441 5 6 Reviewed by Simon Fraser. 7 8 No new tests / refactoring only. 9 10 * css/CSSPrimitiveValue.h: 11 (WebCore::CSSPrimitiveValue::getFloatValue): 12 Implement in terms of the new templated getValue(). 13 (WebCore::CSSPrimitiveValue::getIntValue): 14 Implement in terms of the new templated getValue(). 15 (WebCore::CSSPrimitiveValue::getValue): 16 Templated getValue that works for all numeric types. 17 18 * css/CSSStyleSelector.cpp: 19 (WebCore::CSSStyleSelector::applyProperty): 20 Use getValue<short> instead of rolling-your-own clamp to short. 21 1 22 2011-08-02 Julien Chaffraix <jchaffraix@webkit.org> 2 23 -
trunk/Source/WebCore/css/CSSPrimitiveValue.h
r92106 r92253 158 158 159 159 void setFloatValue(unsigned short unitType, double floatValue, ExceptionCode&); 160 float getFloatValue(unsigned short unitType, ExceptionCode& ec) const { return clampToFloat(getDoubleValue(unitType, ec)); } 161 float getFloatValue(unsigned short unitType) const { return clampToFloat(getDoubleValue(unitType)); } 162 float getFloatValue() const { return clampToFloat(m_value.num); } 163 164 int getIntValue(unsigned short unitType, ExceptionCode& ec) const { return clampToInteger(getDoubleValue(unitType, ec)); } 165 int getIntValue(unsigned short unitType) const { return clampToInteger(getDoubleValue(unitType)); } 166 int getIntValue() const { return clampToInteger(m_value.num); } 160 float getFloatValue(unsigned short unitType, ExceptionCode& ec) const { return getValue<float>(unitType, ec); } 161 float getFloatValue(unsigned short unitType) const { return getValue<float>(unitType); } 162 float getFloatValue() const { return getValue<float>(); } 163 164 int getIntValue(unsigned short unitType, ExceptionCode& ec) const { return getValue<int>(unitType, ec); } 165 int getIntValue(unsigned short unitType) const { return getValue<int>(unitType); } 166 int getIntValue() const { return getValue<int>(); } 167 168 template<typename T> inline T getValue(unsigned short unitType, ExceptionCode& ec) const { return clampTo<T>(getDoubleValue(unitType, ec)); } 169 template<typename T> inline T getValue(unsigned short unitType) const { return clampTo<T>(getDoubleValue(unitType)); } 170 template<typename T> inline T getValue() const { return clampTo<T>(m_value.num); } 167 171 168 172 void setStringValue(unsigned short stringType, const String& stringValue, ExceptionCode&); -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r92243 r92253 4497 4497 return; // Error case. 4498 4498 // Clamp opacity to the range 0-1 4499 m_style->setOpacity( min(1.0f, max(0.0f, primitiveValue->getFloatValue())));4499 m_style->setOpacity(clampTo<float>(primitiveValue->getDoubleValue(), 0, 1)); 4500 4500 return; 4501 4501 case CSSPropertyWebkitBoxAlign: … … 4771 4771 m_style->setHyphenationLimitAfter(-1); 4772 4772 else 4773 m_style->setHyphenationLimitAfter( min(primitiveValue->getIntValue(CSSPrimitiveValue::CSS_NUMBER), static_cast<int>(numeric_limits<short>::max())));4773 m_style->setHyphenationLimitAfter(primitiveValue->getValue<short>(CSSPrimitiveValue::CSS_NUMBER)); 4774 4774 return; 4775 4775 } … … 4779 4779 m_style->setHyphenationLimitBefore(-1); 4780 4780 else 4781 m_style->setHyphenationLimitBefore( min(primitiveValue->getIntValue(CSSPrimitiveValue::CSS_NUMBER), static_cast<int>(numeric_limits<short>::max())));4781 m_style->setHyphenationLimitBefore(primitiveValue->getValue<short>(CSSPrimitiveValue::CSS_NUMBER)); 4782 4782 return; 4783 4783 }
Note: See TracChangeset
for help on using the changeset viewer.