Changeset 88804 in webkit
- Timestamp:
- Jun 14, 2011 8:46:24 AM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r88802 r88804 1 2011-06-14 Luke Macpherson <macpherson@chromium.org> 2 3 Reviewed by Eric Seidel. 4 5 Implement CSS border radius properies in CSSStyleApplyProperty 6 https://bugs.webkit.org/show_bug.cgi?id=62265 7 8 No new tests / refactoring only. 9 10 * css/CSSStyleApplyProperty.cpp: 11 Implement new class to culculate border radius, initialize for appropriate properties. 12 (WebCore::ApplyPropertyBorderRadius::ApplyPropertyBorderRadius): 13 (WebCore::ApplyPropertyBorderRadius::applyValue): 14 (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty): 15 * css/CSSStyleSelector.cpp: 16 Remove old implementations. 17 (WebCore::CSSStyleSelector::applyProperty): 18 * page/animation/AnimationBase.cpp: 19 Pass LengthSize by value. 20 (WebCore::AnimationBase::ensurePropertyMap): 21 * rendering/style/RenderStyle.h: 22 Pass LengthSize by value consistently. 23 1 24 2011-06-14 Carlos Garcia Campos <cgarcia@igalia.com> 2 25 -
trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp
r88553 r88804 31 31 #include "Document.h" 32 32 #include "Element.h" 33 #include "Pair.h" 33 34 #include "RenderStyle.h" 34 35 #include <wtf/StdLibExtras.h> … … 249 250 setValue(selector->style(), Length(primitiveValue->getDoubleValue(), Percent)); 250 251 } 252 } 253 }; 254 255 class ApplyPropertyBorderRadius : public ApplyPropertyDefaultBase<LengthSize> { 256 public: 257 ApplyPropertyBorderRadius(GetterFunction getter, SetterFunction setter, InitialFunction initial) 258 : ApplyPropertyDefaultBase<LengthSize>(getter, setter, initial) 259 { 260 } 261 private: 262 virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const 263 { 264 if (!value->isPrimitiveValue()) 265 return; 266 267 CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value); 268 Pair* pair = primitiveValue->getPairValue(); 269 if (!pair || !pair->first() || !pair->second()) 270 return; 271 272 Length radiusWidth; 273 Length radiusHeight; 274 if (pair->first()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE) 275 radiusWidth = Length(pair->first()->getDoubleValue(), Percent); 276 else 277 radiusWidth = Length(max(intMinForLength, min(intMaxForLength, pair->first()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed); 278 if (pair->second()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE) 279 radiusHeight = Length(pair->second()->getDoubleValue(), Percent); 280 else 281 radiusHeight = Length(max(intMinForLength, min(intMaxForLength, pair->second()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed); 282 int width = radiusWidth.value(); 283 int height = radiusHeight.value(); 284 if (width < 0 || height < 0) 285 return; 286 if (!width) 287 radiusHeight = radiusWidth; // Null out the other value. 288 else if (!height) 289 radiusWidth = radiusHeight; // Null out the other value. 290 291 LengthSize size(radiusWidth, radiusHeight); 292 setValue(selector->style(), size); 251 293 } 252 294 }; … … 558 600 setPropertyHandler(CSSPropertyBorder, new ApplyPropertyExpanding<SuppressValue>(propertyHandler(CSSPropertyBorderStyle), propertyHandler(CSSPropertyBorderWidth), propertyHandler(CSSPropertyBorderColor))); 559 601 602 setPropertyHandler(CSSPropertyBorderTopLeftRadius, new ApplyPropertyBorderRadius(&RenderStyle::borderTopLeftRadius, &RenderStyle::setBorderTopLeftRadius, &RenderStyle::initialBorderRadius)); 603 setPropertyHandler(CSSPropertyBorderTopRightRadius, new ApplyPropertyBorderRadius(&RenderStyle::borderTopRightRadius, &RenderStyle::setBorderTopRightRadius, &RenderStyle::initialBorderRadius)); 604 setPropertyHandler(CSSPropertyBorderBottomLeftRadius, new ApplyPropertyBorderRadius(&RenderStyle::borderBottomLeftRadius, &RenderStyle::setBorderBottomLeftRadius, &RenderStyle::initialBorderRadius)); 605 setPropertyHandler(CSSPropertyBorderBottomRightRadius, new ApplyPropertyBorderRadius(&RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius, &RenderStyle::initialBorderRadius)); 606 setPropertyHandler(CSSPropertyBorderRadius, new ApplyPropertyExpanding<ExpandValue>(propertyHandler(CSSPropertyBorderTopLeftRadius), propertyHandler(CSSPropertyBorderTopRightRadius), propertyHandler(CSSPropertyBorderBottomLeftRadius), propertyHandler(CSSPropertyBorderBottomRightRadius))); 607 setPropertyHandler(CSSPropertyWebkitBorderRadius, CSSPropertyBorderRadius); 608 560 609 setPropertyHandler(CSSPropertyFontStyle, new ApplyPropertyFont<FontItalic>(&FontDescription::italic, &FontDescription::setItalic, FontItalicOff)); 561 610 setPropertyHandler(CSSPropertyFontVariant, new ApplyPropertyFont<FontSmallCaps>(&FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff)); -
trunk/Source/WebCore/css/CSSStyleSelector.cpp
r88793 r88804 4547 4547 return; 4548 4548 } 4549 4550 case CSSPropertyBorderRadius:4551 case CSSPropertyWebkitBorderRadius:4552 if (isInherit) {4553 m_style->setBorderTopLeftRadius(m_parentStyle->borderTopLeftRadius());4554 m_style->setBorderTopRightRadius(m_parentStyle->borderTopRightRadius());4555 m_style->setBorderBottomLeftRadius(m_parentStyle->borderBottomLeftRadius());4556 m_style->setBorderBottomRightRadius(m_parentStyle->borderBottomRightRadius());4557 return;4558 }4559 if (isInitial) {4560 m_style->resetBorderRadius();4561 return;4562 }4563 // Fall through4564 case CSSPropertyBorderTopLeftRadius:4565 case CSSPropertyBorderTopRightRadius:4566 case CSSPropertyBorderBottomLeftRadius:4567 case CSSPropertyBorderBottomRightRadius: {4568 if (isInherit) {4569 HANDLE_INHERIT_COND(CSSPropertyBorderTopLeftRadius, borderTopLeftRadius, BorderTopLeftRadius)4570 HANDLE_INHERIT_COND(CSSPropertyBorderTopRightRadius, borderTopRightRadius, BorderTopRightRadius)4571 HANDLE_INHERIT_COND(CSSPropertyBorderBottomLeftRadius, borderBottomLeftRadius, BorderBottomLeftRadius)4572 HANDLE_INHERIT_COND(CSSPropertyBorderBottomRightRadius, borderBottomRightRadius, BorderBottomRightRadius)4573 return;4574 }4575 4576 if (isInitial) {4577 HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderTopLeftRadius, BorderTopLeftRadius, BorderRadius)4578 HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderTopRightRadius, BorderTopRightRadius, BorderRadius)4579 HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderBottomLeftRadius, BorderBottomLeftRadius, BorderRadius)4580 HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderBottomRightRadius, BorderBottomRightRadius, BorderRadius)4581 return;4582 }4583 4584 if (!primitiveValue)4585 return;4586 4587 Pair* pair = primitiveValue->getPairValue();4588 if (!pair || !pair->first() || !pair->second())4589 return;4590 4591 Length radiusWidth;4592 Length radiusHeight;4593 if (pair->first()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)4594 radiusWidth = Length(pair->first()->getDoubleValue(), Percent);4595 else4596 radiusWidth = Length(max(intMinForLength, min(intMaxForLength, pair->first()->computeLength<int>(style(), m_rootElementStyle, zoomFactor))), Fixed);4597 if (pair->second()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)4598 radiusHeight = Length(pair->second()->getDoubleValue(), Percent);4599 else4600 radiusHeight = Length(max(intMinForLength, min(intMaxForLength, pair->second()->computeLength<int>(style(), m_rootElementStyle, zoomFactor))), Fixed);4601 int width = radiusWidth.value();4602 int height = radiusHeight.value();4603 if (width < 0 || height < 0)4604 return;4605 if (width == 0)4606 radiusHeight = radiusWidth; // Null out the other value.4607 else if (height == 0)4608 radiusWidth = radiusHeight; // Null out the other value.4609 4610 LengthSize size(radiusWidth, radiusHeight);4611 switch (id) {4612 case CSSPropertyBorderTopLeftRadius:4613 m_style->setBorderTopLeftRadius(size);4614 break;4615 case CSSPropertyBorderTopRightRadius:4616 m_style->setBorderTopRightRadius(size);4617 break;4618 case CSSPropertyBorderBottomLeftRadius:4619 m_style->setBorderBottomLeftRadius(size);4620 break;4621 case CSSPropertyBorderBottomRightRadius:4622 m_style->setBorderBottomRightRadius(size);4623 break;4624 default:4625 m_style->setBorderRadius(size);4626 break;4627 }4628 return;4629 }4630 4631 4549 case CSSPropertyOutlineOffset: 4632 4550 HANDLE_INHERIT_AND_INITIAL(outlineOffset, OutlineOffset) … … 5424 5342 case CSSPropertyBorderBottom: 5425 5343 case CSSPropertyBorderLeft: 5344 case CSSPropertyBorderRadius: 5345 case CSSPropertyWebkitBorderRadius: 5346 case CSSPropertyBorderTopLeftRadius: 5347 case CSSPropertyBorderTopRightRadius: 5348 case CSSPropertyBorderBottomLeftRadius: 5349 case CSSPropertyBorderBottomRightRadius: 5426 5350 case CSSPropertyFontStyle: 5427 5351 case CSSPropertyFontVariant: -
trunk/Source/WebCore/page/animation/AnimationBase.cpp
r88218 r88804 737 737 gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyWebkitTransformOriginY, &RenderStyle::transformOriginY, &RenderStyle::setTransformOriginY)); 738 738 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyWebkitTransformOriginZ, &RenderStyle::transformOriginZ, &RenderStyle::setTransformOriginZ)); 739 gPropertyWrappers->append(new PropertyWrapper< const LengthSize&>(CSSPropertyBorderTopLeftRadius, &RenderStyle::borderTopLeftRadius, &RenderStyle::setBorderTopLeftRadius));740 gPropertyWrappers->append(new PropertyWrapper< const LengthSize&>(CSSPropertyBorderTopRightRadius, &RenderStyle::borderTopRightRadius, &RenderStyle::setBorderTopRightRadius));741 gPropertyWrappers->append(new PropertyWrapper< const LengthSize&>(CSSPropertyBorderBottomLeftRadius, &RenderStyle::borderBottomLeftRadius, &RenderStyle::setBorderBottomLeftRadius));742 gPropertyWrappers->append(new PropertyWrapper< const LengthSize&>(CSSPropertyBorderBottomRightRadius, &RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius));739 gPropertyWrappers->append(new PropertyWrapper<LengthSize>(CSSPropertyBorderTopLeftRadius, &RenderStyle::borderTopLeftRadius, &RenderStyle::setBorderTopLeftRadius)); 740 gPropertyWrappers->append(new PropertyWrapper<LengthSize>(CSSPropertyBorderTopRightRadius, &RenderStyle::borderTopRightRadius, &RenderStyle::setBorderTopRightRadius)); 741 gPropertyWrappers->append(new PropertyWrapper<LengthSize>(CSSPropertyBorderBottomLeftRadius, &RenderStyle::borderBottomLeftRadius, &RenderStyle::setBorderBottomLeftRadius)); 742 gPropertyWrappers->append(new PropertyWrapper<LengthSize>(CSSPropertyBorderBottomRightRadius, &RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius)); 743 743 gPropertyWrappers->append(new PropertyWrapper<EVisibility>(CSSPropertyVisibility, &RenderStyle::visibility, &RenderStyle::setVisibility)); 744 744 gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyZoom, &RenderStyle::zoom, &RenderStyle::setZoom)); -
trunk/Source/WebCore/rendering/style/RenderStyle.h
r88526 r88804 421 421 const NinePieceImage& borderImage() const { return surround->border.image(); } 422 422 423 const LengthSize&borderTopLeftRadius() const { return surround->border.topLeft(); }424 const LengthSize&borderTopRightRadius() const { return surround->border.topRight(); }425 const LengthSize&borderBottomLeftRadius() const { return surround->border.bottomLeft(); }426 const LengthSize&borderBottomRightRadius() const { return surround->border.bottomRight(); }423 LengthSize borderTopLeftRadius() const { return surround->border.topLeft(); } 424 LengthSize borderTopRightRadius() const { return surround->border.topRight(); } 425 LengthSize borderBottomLeftRadius() const { return surround->border.bottomLeft(); } 426 LengthSize borderBottomRightRadius() const { return surround->border.bottomRight(); } 427 427 bool hasBorderRadius() const { return surround->border.hasBorderRadius(); } 428 428 … … 850 850 void setBorderImage(const NinePieceImage& b) { SET_VAR(surround, border.m_image, b) } 851 851 852 void setBorderTopLeftRadius( const LengthSize&s) { SET_VAR(surround, border.m_topLeft, s) }853 void setBorderTopRightRadius( const LengthSize&s) { SET_VAR(surround, border.m_topRight, s) }854 void setBorderBottomLeftRadius( const LengthSize&s) { SET_VAR(surround, border.m_bottomLeft, s) }855 void setBorderBottomRightRadius( const LengthSize&s) { SET_VAR(surround, border.m_bottomRight, s) }856 857 void setBorderRadius( const LengthSize&s)852 void setBorderTopLeftRadius(LengthSize s) { SET_VAR(surround, border.m_topLeft, s) } 853 void setBorderTopRightRadius(LengthSize s) { SET_VAR(surround, border.m_topRight, s) } 854 void setBorderBottomLeftRadius(LengthSize s) { SET_VAR(surround, border.m_bottomLeft, s) } 855 void setBorderBottomRightRadius(LengthSize s) { SET_VAR(surround, border.m_bottomRight, s) } 856 857 void setBorderRadius(LengthSize s) 858 858 { 859 859 setBorderTopLeftRadius(s);
Note: See TracChangeset
for help on using the changeset viewer.