Diff
Modified: trunk/Source/WebCore/ChangeLog (88803 => 88804)
--- trunk/Source/WebCore/ChangeLog 2011-06-14 15:03:51 UTC (rev 88803)
+++ trunk/Source/WebCore/ChangeLog 2011-06-14 15:46:24 UTC (rev 88804)
@@ -1,3 +1,26 @@
+2011-06-14 Luke Macpherson <[email protected]>
+
+ Reviewed by Eric Seidel.
+
+ Implement CSS border radius properies in CSSStyleApplyProperty
+ https://bugs.webkit.org/show_bug.cgi?id=62265
+
+ No new tests / refactoring only.
+
+ * css/CSSStyleApplyProperty.cpp:
+ Implement new class to culculate border radius, initialize for appropriate properties.
+ (WebCore::ApplyPropertyBorderRadius::ApplyPropertyBorderRadius):
+ (WebCore::ApplyPropertyBorderRadius::applyValue):
+ (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty):
+ * css/CSSStyleSelector.cpp:
+ Remove old implementations.
+ (WebCore::CSSStyleSelector::applyProperty):
+ * page/animation/AnimationBase.cpp:
+ Pass LengthSize by value.
+ (WebCore::AnimationBase::ensurePropertyMap):
+ * rendering/style/RenderStyle.h:
+ Pass LengthSize by value consistently.
+
2011-06-14 Carlos Garcia Campos <[email protected]>
Reviewed by Martin Robinson.
Modified: trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp (88803 => 88804)
--- trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-06-14 15:03:51 UTC (rev 88803)
+++ trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp 2011-06-14 15:46:24 UTC (rev 88804)
@@ -30,6 +30,7 @@
#include "CSSValueList.h"
#include "Document.h"
#include "Element.h"
+#include "Pair.h"
#include "RenderStyle.h"
#include <wtf/StdLibExtras.h>
#include <wtf/UnusedParam.h>
@@ -251,6 +252,47 @@
}
};
+class ApplyPropertyBorderRadius : public ApplyPropertyDefaultBase<LengthSize> {
+public:
+ ApplyPropertyBorderRadius(GetterFunction getter, SetterFunction setter, InitialFunction initial)
+ : ApplyPropertyDefaultBase<LengthSize>(getter, setter, initial)
+ {
+ }
+private:
+ virtual void applyValue(CSSStyleSelector* selector, CSSValue* value) const
+ {
+ if (!value->isPrimitiveValue())
+ return;
+
+ CSSPrimitiveValue* primitiveValue = static_cast<CSSPrimitiveValue*>(value);
+ Pair* pair = primitiveValue->getPairValue();
+ if (!pair || !pair->first() || !pair->second())
+ return;
+
+ Length radiusWidth;
+ Length radiusHeight;
+ if (pair->first()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
+ radiusWidth = Length(pair->first()->getDoubleValue(), Percent);
+ else
+ radiusWidth = Length(max(intMinForLength, min(intMaxForLength, pair->first()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed);
+ if (pair->second()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
+ radiusHeight = Length(pair->second()->getDoubleValue(), Percent);
+ else
+ radiusHeight = Length(max(intMinForLength, min(intMaxForLength, pair->second()->computeLength<int>(selector->style(), selector->rootElementStyle(), selector->style()->effectiveZoom()))), Fixed);
+ int width = radiusWidth.value();
+ int height = radiusHeight.value();
+ if (width < 0 || height < 0)
+ return;
+ if (!width)
+ radiusHeight = radiusWidth; // Null out the other value.
+ else if (!height)
+ radiusWidth = radiusHeight; // Null out the other value.
+
+ LengthSize size(radiusWidth, radiusHeight);
+ setValue(selector->style(), size);
+ }
+};
+
template <typename T>
class ApplyPropertyFillLayer : public ApplyPropertyBase {
public:
@@ -557,6 +599,13 @@
setPropertyHandler(CSSPropertyBorderColor, new ApplyPropertyExpanding<SuppressValue>(propertyHandler(CSSPropertyBorderTopColor), propertyHandler(CSSPropertyBorderRightColor), propertyHandler(CSSPropertyBorderBottomColor), propertyHandler(CSSPropertyBorderLeftColor)));
setPropertyHandler(CSSPropertyBorder, new ApplyPropertyExpanding<SuppressValue>(propertyHandler(CSSPropertyBorderStyle), propertyHandler(CSSPropertyBorderWidth), propertyHandler(CSSPropertyBorderColor)));
+ setPropertyHandler(CSSPropertyBorderTopLeftRadius, new ApplyPropertyBorderRadius(&RenderStyle::borderTopLeftRadius, &RenderStyle::setBorderTopLeftRadius, &RenderStyle::initialBorderRadius));
+ setPropertyHandler(CSSPropertyBorderTopRightRadius, new ApplyPropertyBorderRadius(&RenderStyle::borderTopRightRadius, &RenderStyle::setBorderTopRightRadius, &RenderStyle::initialBorderRadius));
+ setPropertyHandler(CSSPropertyBorderBottomLeftRadius, new ApplyPropertyBorderRadius(&RenderStyle::borderBottomLeftRadius, &RenderStyle::setBorderBottomLeftRadius, &RenderStyle::initialBorderRadius));
+ setPropertyHandler(CSSPropertyBorderBottomRightRadius, new ApplyPropertyBorderRadius(&RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius, &RenderStyle::initialBorderRadius));
+ setPropertyHandler(CSSPropertyBorderRadius, new ApplyPropertyExpanding<ExpandValue>(propertyHandler(CSSPropertyBorderTopLeftRadius), propertyHandler(CSSPropertyBorderTopRightRadius), propertyHandler(CSSPropertyBorderBottomLeftRadius), propertyHandler(CSSPropertyBorderBottomRightRadius)));
+ setPropertyHandler(CSSPropertyWebkitBorderRadius, CSSPropertyBorderRadius);
+
setPropertyHandler(CSSPropertyFontStyle, new ApplyPropertyFont<FontItalic>(&FontDescription::italic, &FontDescription::setItalic, FontItalicOff));
setPropertyHandler(CSSPropertyFontVariant, new ApplyPropertyFont<FontSmallCaps>(&FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff));
setPropertyHandler(CSSPropertyTextRendering, new ApplyPropertyFont<TextRenderingMode>(&FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering));
Modified: trunk/Source/WebCore/css/CSSStyleSelector.cpp (88803 => 88804)
--- trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-06-14 15:03:51 UTC (rev 88803)
+++ trunk/Source/WebCore/css/CSSStyleSelector.cpp 2011-06-14 15:46:24 UTC (rev 88804)
@@ -4546,88 +4546,6 @@
m_style->setMaskBoxImage(image);
return;
}
-
- case CSSPropertyBorderRadius:
- case CSSPropertyWebkitBorderRadius:
- if (isInherit) {
- m_style->setBorderTopLeftRadius(m_parentStyle->borderTopLeftRadius());
- m_style->setBorderTopRightRadius(m_parentStyle->borderTopRightRadius());
- m_style->setBorderBottomLeftRadius(m_parentStyle->borderBottomLeftRadius());
- m_style->setBorderBottomRightRadius(m_parentStyle->borderBottomRightRadius());
- return;
- }
- if (isInitial) {
- m_style->resetBorderRadius();
- return;
- }
- // Fall through
- case CSSPropertyBorderTopLeftRadius:
- case CSSPropertyBorderTopRightRadius:
- case CSSPropertyBorderBottomLeftRadius:
- case CSSPropertyBorderBottomRightRadius: {
- if (isInherit) {
- HANDLE_INHERIT_COND(CSSPropertyBorderTopLeftRadius, borderTopLeftRadius, BorderTopLeftRadius)
- HANDLE_INHERIT_COND(CSSPropertyBorderTopRightRadius, borderTopRightRadius, BorderTopRightRadius)
- HANDLE_INHERIT_COND(CSSPropertyBorderBottomLeftRadius, borderBottomLeftRadius, BorderBottomLeftRadius)
- HANDLE_INHERIT_COND(CSSPropertyBorderBottomRightRadius, borderBottomRightRadius, BorderBottomRightRadius)
- return;
- }
-
- if (isInitial) {
- HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderTopLeftRadius, BorderTopLeftRadius, BorderRadius)
- HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderTopRightRadius, BorderTopRightRadius, BorderRadius)
- HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderBottomLeftRadius, BorderBottomLeftRadius, BorderRadius)
- HANDLE_INITIAL_COND_WITH_VALUE(CSSPropertyBorderBottomRightRadius, BorderBottomRightRadius, BorderRadius)
- return;
- }
-
- if (!primitiveValue)
- return;
-
- Pair* pair = primitiveValue->getPairValue();
- if (!pair || !pair->first() || !pair->second())
- return;
-
- Length radiusWidth;
- Length radiusHeight;
- if (pair->first()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
- radiusWidth = Length(pair->first()->getDoubleValue(), Percent);
- else
- radiusWidth = Length(max(intMinForLength, min(intMaxForLength, pair->first()->computeLength<int>(style(), m_rootElementStyle, zoomFactor))), Fixed);
- if (pair->second()->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE)
- radiusHeight = Length(pair->second()->getDoubleValue(), Percent);
- else
- radiusHeight = Length(max(intMinForLength, min(intMaxForLength, pair->second()->computeLength<int>(style(), m_rootElementStyle, zoomFactor))), Fixed);
- int width = radiusWidth.value();
- int height = radiusHeight.value();
- if (width < 0 || height < 0)
- return;
- if (width == 0)
- radiusHeight = radiusWidth; // Null out the other value.
- else if (height == 0)
- radiusWidth = radiusHeight; // Null out the other value.
-
- LengthSize size(radiusWidth, radiusHeight);
- switch (id) {
- case CSSPropertyBorderTopLeftRadius:
- m_style->setBorderTopLeftRadius(size);
- break;
- case CSSPropertyBorderTopRightRadius:
- m_style->setBorderTopRightRadius(size);
- break;
- case CSSPropertyBorderBottomLeftRadius:
- m_style->setBorderBottomLeftRadius(size);
- break;
- case CSSPropertyBorderBottomRightRadius:
- m_style->setBorderBottomRightRadius(size);
- break;
- default:
- m_style->setBorderRadius(size);
- break;
- }
- return;
- }
-
case CSSPropertyOutlineOffset:
HANDLE_INHERIT_AND_INITIAL(outlineOffset, OutlineOffset)
m_style->setOutlineOffset(primitiveValue->computeLength<int>(style(), m_rootElementStyle, zoomFactor));
@@ -5423,6 +5341,12 @@
case CSSPropertyBorderRight:
case CSSPropertyBorderBottom:
case CSSPropertyBorderLeft:
+ case CSSPropertyBorderRadius:
+ case CSSPropertyWebkitBorderRadius:
+ case CSSPropertyBorderTopLeftRadius:
+ case CSSPropertyBorderTopRightRadius:
+ case CSSPropertyBorderBottomLeftRadius:
+ case CSSPropertyBorderBottomRightRadius:
case CSSPropertyFontStyle:
case CSSPropertyFontVariant:
case CSSPropertyTextRendering:
Modified: trunk/Source/WebCore/page/animation/AnimationBase.cpp (88803 => 88804)
--- trunk/Source/WebCore/page/animation/AnimationBase.cpp 2011-06-14 15:03:51 UTC (rev 88803)
+++ trunk/Source/WebCore/page/animation/AnimationBase.cpp 2011-06-14 15:46:24 UTC (rev 88804)
@@ -736,10 +736,10 @@
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyWebkitTransformOriginX, &RenderStyle::transformOriginX, &RenderStyle::setTransformOriginX));
gPropertyWrappers->append(new PropertyWrapper<Length>(CSSPropertyWebkitTransformOriginY, &RenderStyle::transformOriginY, &RenderStyle::setTransformOriginY));
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyWebkitTransformOriginZ, &RenderStyle::transformOriginZ, &RenderStyle::setTransformOriginZ));
- gPropertyWrappers->append(new PropertyWrapper<const LengthSize&>(CSSPropertyBorderTopLeftRadius, &RenderStyle::borderTopLeftRadius, &RenderStyle::setBorderTopLeftRadius));
- gPropertyWrappers->append(new PropertyWrapper<const LengthSize&>(CSSPropertyBorderTopRightRadius, &RenderStyle::borderTopRightRadius, &RenderStyle::setBorderTopRightRadius));
- gPropertyWrappers->append(new PropertyWrapper<const LengthSize&>(CSSPropertyBorderBottomLeftRadius, &RenderStyle::borderBottomLeftRadius, &RenderStyle::setBorderBottomLeftRadius));
- gPropertyWrappers->append(new PropertyWrapper<const LengthSize&>(CSSPropertyBorderBottomRightRadius, &RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius));
+ gPropertyWrappers->append(new PropertyWrapper<LengthSize>(CSSPropertyBorderTopLeftRadius, &RenderStyle::borderTopLeftRadius, &RenderStyle::setBorderTopLeftRadius));
+ gPropertyWrappers->append(new PropertyWrapper<LengthSize>(CSSPropertyBorderTopRightRadius, &RenderStyle::borderTopRightRadius, &RenderStyle::setBorderTopRightRadius));
+ gPropertyWrappers->append(new PropertyWrapper<LengthSize>(CSSPropertyBorderBottomLeftRadius, &RenderStyle::borderBottomLeftRadius, &RenderStyle::setBorderBottomLeftRadius));
+ gPropertyWrappers->append(new PropertyWrapper<LengthSize>(CSSPropertyBorderBottomRightRadius, &RenderStyle::borderBottomRightRadius, &RenderStyle::setBorderBottomRightRadius));
gPropertyWrappers->append(new PropertyWrapper<EVisibility>(CSSPropertyVisibility, &RenderStyle::visibility, &RenderStyle::setVisibility));
gPropertyWrappers->append(new PropertyWrapper<float>(CSSPropertyZoom, &RenderStyle::zoom, &RenderStyle::setZoom));
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (88803 => 88804)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2011-06-14 15:03:51 UTC (rev 88803)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2011-06-14 15:46:24 UTC (rev 88804)
@@ -420,10 +420,10 @@
const NinePieceImage& borderImage() const { return surround->border.image(); }
- const LengthSize& borderTopLeftRadius() const { return surround->border.topLeft(); }
- const LengthSize& borderTopRightRadius() const { return surround->border.topRight(); }
- const LengthSize& borderBottomLeftRadius() const { return surround->border.bottomLeft(); }
- const LengthSize& borderBottomRightRadius() const { return surround->border.bottomRight(); }
+ LengthSize borderTopLeftRadius() const { return surround->border.topLeft(); }
+ LengthSize borderTopRightRadius() const { return surround->border.topRight(); }
+ LengthSize borderBottomLeftRadius() const { return surround->border.bottomLeft(); }
+ LengthSize borderBottomRightRadius() const { return surround->border.bottomRight(); }
bool hasBorderRadius() const { return surround->border.hasBorderRadius(); }
unsigned short borderLeftWidth() const { return surround->border.borderLeftWidth(); }
@@ -849,12 +849,12 @@
void setBorderImage(const NinePieceImage& b) { SET_VAR(surround, border.m_image, b) }
- void setBorderTopLeftRadius(const LengthSize& s) { SET_VAR(surround, border.m_topLeft, s) }
- void setBorderTopRightRadius(const LengthSize& s) { SET_VAR(surround, border.m_topRight, s) }
- void setBorderBottomLeftRadius(const LengthSize& s) { SET_VAR(surround, border.m_bottomLeft, s) }
- void setBorderBottomRightRadius(const LengthSize& s) { SET_VAR(surround, border.m_bottomRight, s) }
+ void setBorderTopLeftRadius(LengthSize s) { SET_VAR(surround, border.m_topLeft, s) }
+ void setBorderTopRightRadius(LengthSize s) { SET_VAR(surround, border.m_topRight, s) }
+ void setBorderBottomLeftRadius(LengthSize s) { SET_VAR(surround, border.m_bottomLeft, s) }
+ void setBorderBottomRightRadius(LengthSize s) { SET_VAR(surround, border.m_bottomRight, s) }
- void setBorderRadius(const LengthSize& s)
+ void setBorderRadius(LengthSize s)
{
setBorderTopLeftRadius(s);
setBorderTopRightRadius(s);