Index: Source/core/css/CSSGradientValue.cpp |
diff --git a/Source/core/css/CSSGradientValue.cpp b/Source/core/css/CSSGradientValue.cpp |
index 277162fd89ba49b8b354817c3e4bca249a68a349..454e55be078301da1d85b411f01f6af3544b826a 100644 |
--- a/Source/core/css/CSSGradientValue.cpp |
+++ b/Source/core/css/CSSGradientValue.cpp |
@@ -29,6 +29,7 @@ |
#include "core/CSSValueKeywords.h" |
#include "core/css/CSSCalculationValue.h" |
#include "core/css/CSSToLengthConversionData.h" |
+#include "core/css/Pair.h" |
#include "core/dom/NodeRenderStyle.h" |
#include "core/dom/TextLinkColors.h" |
#include "core/rendering/RenderObject.h" |
@@ -387,12 +388,33 @@ void CSSGradientValue::addStops(Gradient* gradient, const CSSToLengthConversionD |
gradient->addColorStop(stops[i].offset, stops[i].color); |
} |
+static float positionFromPairValue(CSSPrimitiveValue* value, int edgeDistance, const CSSToLengthConversionData& conversionData) |
f(malita)
2014/06/26 20:33:43
I think we can fold this into the original method,
|
+{ |
+ if (value->isNumber()) |
+ return edgeDistance - (value->getFloatValue() * conversionData.zoom()); |
+ if (value->isPercentage()) |
+ return (100 - value->getFloatValue()) / 100.f * edgeDistance; |
+ if (value->isCalculatedPercentageWithLength()) |
+ return edgeDistance - value->cssCalcValue()->toCalcValue(conversionData)->evaluate(edgeDistance); |
+ return edgeDistance - value->computeLength<float>(conversionData); |
+} |
+ |
static float positionFromValue(CSSPrimitiveValue* value, const CSSToLengthConversionData& conversionData, const IntSize& size, bool isHorizontal) |
f(malita)
2014/06/26 20:33:43
How about something like this instead:
static flo
|
{ |
+ int edgeDistance = isHorizontal ? size.width() : size.height(); |
+ if (Pair* pair = value->getPairValue()) { |
f(malita)
2014/06/26 20:33:42
We should probably add an inline comment describin
|
+ CSSValueID keyword = pair->first()->getValueID(); |
+ CSSPrimitiveValue* offsetValue = pair->second(); |
+ |
+ if (keyword == CSSValueRight || keyword == CSSValueBottom) |
+ return positionFromPairValue(offsetValue, edgeDistance, conversionData); |
+ |
+ value = offsetValue; |
+ } |
+ |
if (value->isNumber()) |
return value->getFloatValue() * conversionData.zoom(); |
- int edgeDistance = isHorizontal ? size.width() : size.height(); |
if (value->isPercentage()) |
return value->getFloatValue() / 100.f * edgeDistance; |