diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-03 09:55:33 +0100 |
---|---|---|
committer | Simon Hausmann <simon.hausmann@nokia.com> | 2012-02-03 09:55:33 +0100 |
commit | cd44dc59cdfc39534aef4d417e9f3c412e3be139 (patch) | |
tree | 8d89889ba95ed6ec9322e733846cc9cce9d7dff1 /Source/WebCore/css/CSSGradientValue.cpp | |
parent | d11f84f5b5cdc0d92a08af01b13472fdd5f9acb9 (diff) | |
download | qtwebkit-cd44dc59cdfc39534aef4d417e9f3c412e3be139.tar.gz |
Imported WebKit commit fce473cb4d55aa9fe9d0b0322a2fffecb731b961 (http://svn.webkit.org/repository/webkit/trunk@106560)
Diffstat (limited to 'Source/WebCore/css/CSSGradientValue.cpp')
-rw-r--r-- | Source/WebCore/css/CSSGradientValue.cpp | 86 |
1 files changed, 39 insertions, 47 deletions
diff --git a/Source/WebCore/css/CSSGradientValue.cpp b/Source/WebCore/css/CSSGradientValue.cpp index 41977fb03..d8d7253d1 100644 --- a/Source/WebCore/css/CSSGradientValue.cpp +++ b/Source/WebCore/css/CSSGradientValue.cpp @@ -117,7 +117,7 @@ void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, Rend Color color = renderer->document()->styleSelector()->colorFromPrimitiveValue(stop.m_color.get()); float offset; - if (stop.m_position->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE) + if (stop.m_position->isPercentage()) offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) / 100; else offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_NUMBER); @@ -150,10 +150,9 @@ void CSSGradientValue::addStops(Gradient* gradient, RenderObject* renderer, Rend stops[i].color = renderer->document()->styleSelector()->colorFromPrimitiveValue(stop.m_color.get()); if (stop.m_position) { - int type = stop.m_position->primitiveType(); - if (type == CSSPrimitiveValue::CSS_PERCENTAGE) + if (stop.m_position->isPercentage()) stops[i].offset = stop.m_position->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE) / 100; - else if (CSSPrimitiveValue::isUnitTypeLength(type)) { + else if (stop.m_position->isLength()) { float length = stop.m_position->computeLength<float>(style, rootStyle, style->effectiveZoom()); if (!computedGradientLength) { FloatSize gradientSize(gradientStart - gradientEnd); @@ -363,32 +362,28 @@ static float positionFromValue(CSSPrimitiveValue* value, RenderStyle* style, Ren { float zoomFactor = style->effectiveZoom(); - switch (value->primitiveType()) { - case CSSPrimitiveValue::CSS_NUMBER: + if (value->isNumber()) return value->getFloatValue() * zoomFactor; - case CSSPrimitiveValue::CSS_PERCENTAGE: + if (value->isPercentage()) return value->getFloatValue() / 100.f * (isHorizontal ? size.width() : size.height()); - case CSSPrimitiveValue::CSS_IDENT: - switch (value->getIdent()) { - case CSSValueTop: - ASSERT(!isHorizontal); - return 0; - case CSSValueLeft: - ASSERT(isHorizontal); - return 0; - case CSSValueBottom: - ASSERT(!isHorizontal); - return size.height(); - case CSSValueRight: - ASSERT(isHorizontal); - return size.width(); - } - - default: - return value->computeLength<float>(style, rootStyle, zoomFactor); + switch (value->getIdent()) { + case CSSValueTop: + ASSERT(!isHorizontal); + return 0; + case CSSValueLeft: + ASSERT(isHorizontal); + return 0; + case CSSValueBottom: + ASSERT(!isHorizontal); + return size.height(); + case CSSValueRight: + ASSERT(isHorizontal); + return size.width(); } + + return value->computeLength<float>(style, rootStyle, zoomFactor); } FloatPoint CSSGradientValue::computeEndPoint(CSSPrimitiveValue* first, CSSPrimitiveValue* second, RenderStyle* style, RenderStyle* rootStyle, const IntSize& size) @@ -416,8 +411,7 @@ bool CSSGradientValue::isCacheable() const if (!stop.m_position) continue; - unsigned short unitType = stop.m_position->primitiveType(); - if (unitType == CSSPrimitiveValue::CSS_EMS || unitType == CSSPrimitiveValue::CSS_EXS || unitType == CSSPrimitiveValue::CSS_REMS) + if (stop.m_position->isFontRelativeLength()) return false; } @@ -640,9 +634,9 @@ float CSSRadialGradientValue::resolveRadius(CSSPrimitiveValue* radius, RenderSty float zoomFactor = style->effectiveZoom(); float result = 0; - if (radius->primitiveType() == CSSPrimitiveValue::CSS_NUMBER) // Can the radius be a percentage? + if (radius->isNumber()) // Can the radius be a percentage? result = radius->getFloatValue() * zoomFactor; - else if (widthOrHeight && radius->primitiveType() == CSSPrimitiveValue::CSS_PERCENTAGE) + else if (widthOrHeight && radius->isPercentage()) result = *widthOrHeight * radius->getFloatValue() / 100; else result = radius->computeLength<float>(style, rootStyle, zoomFactor); @@ -761,29 +755,27 @@ PassRefPtr<Gradient> CSSRadialGradientValue::createGradient(RenderObject* render } else { enum GradientShape { Circle, Ellipse }; GradientShape shape = Ellipse; - if (m_shape && m_shape->primitiveType() == CSSPrimitiveValue::CSS_IDENT && m_shape->getIdent() == CSSValueCircle) + if (m_shape && m_shape->getIdent() == CSSValueCircle) shape = Circle; enum GradientFill { ClosestSide, ClosestCorner, FarthestSide, FarthestCorner }; GradientFill fill = FarthestCorner; - if (m_sizingBehavior && m_sizingBehavior->primitiveType() == CSSPrimitiveValue::CSS_IDENT) { - switch (m_sizingBehavior->getIdent()) { - case CSSValueContain: - case CSSValueClosestSide: - fill = ClosestSide; - break; - case CSSValueClosestCorner: - fill = ClosestCorner; - break; - case CSSValueFarthestSide: - fill = FarthestSide; - break; - case CSSValueCover: - case CSSValueFarthestCorner: - fill = FarthestCorner; - break; - } + switch (m_sizingBehavior ? m_sizingBehavior->getIdent() : 0) { + case CSSValueContain: + case CSSValueClosestSide: + fill = ClosestSide; + break; + case CSSValueClosestCorner: + fill = ClosestCorner; + break; + case CSSValueFarthestSide: + fill = FarthestSide; + break; + case CSSValueCover: + case CSSValueFarthestCorner: + fill = FarthestCorner; + break; } // Now compute the end radii based on the second point, shape and fill. |