Index: third_party/WebKit/Source/core/css/CSSGradientValue.cpp |
diff --git a/third_party/WebKit/Source/core/css/CSSGradientValue.cpp b/third_party/WebKit/Source/core/css/CSSGradientValue.cpp |
index 8caf960546495d5d102d393136c07afc5fcbf2e7..02f61c556082f2eefc89552e26f4f27874cfb6cf 100644 |
--- a/third_party/WebKit/Source/core/css/CSSGradientValue.cpp |
+++ b/third_party/WebKit/Source/core/css/CSSGradientValue.cpp |
@@ -28,6 +28,7 @@ |
#include "core/CSSValueKeywords.h" |
#include "core/css/CSSCalculationValue.h" |
+#include "core/css/CSSIdentifierValue.h" |
#include "core/css/CSSToLengthConversionData.h" |
#include "core/css/CSSValuePair.h" |
#include "core/dom/NodeComputedStyle.h" |
@@ -46,6 +47,24 @@ |
namespace blink { |
+namespace { |
+ |
+static bool colorIsDerivedFromElement(const CSSIdentifierValue& value) |
+{ |
+ CSSValueID valueID = value.getValueID(); |
+ switch (valueID) { |
+ case CSSValueInternalQuirkInherit: |
+ case CSSValueWebkitLink: |
+ case CSSValueWebkitActivelink: |
+ case CSSValueCurrentcolor: |
+ return true; |
+ default: |
+ return false; |
+ } |
+} |
+ |
+} |
+ |
DEFINE_TRACE(CSSGradientColorStop) |
{ |
visitor->trace(m_position); |
@@ -491,7 +510,7 @@ static float positionFromValue(const CSSValue* value, const CSSToLengthConversio |
// [ top | bottom | right | left ] [ <percentage> | <length> ]. |
if (value->isValuePair()) { |
const CSSValuePair& pair = toCSSValuePair(*value); |
- CSSValueID originID = toCSSPrimitiveValue(pair.first()).getValueID(); |
+ CSSValueID originID = toCSSIdentifierValue(pair.first()).getValueID(); |
value = &pair.second(); |
if (originID == CSSValueRight || originID == CSSValueBottom) { |
@@ -501,6 +520,28 @@ static float positionFromValue(const CSSValue* value, const CSSToLengthConversio |
} |
} |
+ if (value->isIdentifierValue()) { |
+ switch (toCSSIdentifierValue(value)->getValueID()) { |
+ case CSSValueTop: |
+ DCHECK(!isHorizontal); |
+ return 0; |
+ case CSSValueLeft: |
+ DCHECK(isHorizontal); |
+ return 0; |
+ case CSSValueBottom: |
+ DCHECK(!isHorizontal); |
+ return size.height(); |
+ case CSSValueRight: |
+ DCHECK(isHorizontal); |
+ return size.width(); |
+ case CSSValueCenter: |
+ return origin + sign * .5f * edgeDistance; |
+ default: |
+ NOTREACHED(); |
+ break; |
+ } |
+ } |
+ |
const CSSPrimitiveValue* primitiveValue = toCSSPrimitiveValue(value); |
if (primitiveValue->isNumber()) |
@@ -512,25 +553,6 @@ static float positionFromValue(const CSSValue* value, const CSSToLengthConversio |
if (primitiveValue->isCalculatedPercentageWithLength()) |
return origin + sign * primitiveValue->cssCalcValue()->toCalcValue(conversionData)->evaluate(edgeDistance); |
- switch (primitiveValue->getValueID()) { |
- 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(); |
- case CSSValueCenter: |
- return origin + sign * .5f * edgeDistance; |
- default: |
- break; |
- } |
- |
return origin + sign * primitiveValue->computeLength<float>(conversionData); |
} |
@@ -552,7 +574,7 @@ bool CSSGradientValue::isCacheable() const |
for (size_t i = 0; i < m_stops.size(); ++i) { |
const CSSGradientColorStop& stop = m_stops[i]; |
- if (!stop.isHint() && stop.m_color->isPrimitiveValue() && toCSSPrimitiveValue(*stop.m_color).colorIsDerivedFromElement()) |
+ if (!stop.isHint() && stop.m_color->isIdentifierValue() && colorIsDerivedFromElement(toCSSIdentifierValue(*stop.m_color))) |
return false; |
if (!stop.m_position) |
@@ -648,7 +670,7 @@ String CSSLinearGradientValue::customCSSText() const |
if (m_angle && m_angle->computeDegrees() != 180) { |
result.append(m_angle->cssText()); |
wroteSomething = true; |
- } else if ((m_firstX || m_firstY) && !(!m_firstX && m_firstY && m_firstY->isPrimitiveValue() && toCSSPrimitiveValue(m_firstY.get())->getValueID() == CSSValueBottom)) { |
+ } else if ((m_firstX || m_firstY) && !(!m_firstX && m_firstY && m_firstY->isIdentifierValue() && toCSSIdentifierValue(m_firstY.get())->getValueID() == CSSValueBottom)) { |
result.append("to "); |
if (m_firstX && m_firstY) { |
result.append(m_firstX->cssText()); |
@@ -784,9 +806,9 @@ PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(const CSSToLengthCon |
// "Magic" corners, so the 50% line touches two corners. |
float rise = size.width(); |
float run = size.height(); |
- if (m_firstX && m_firstX->isPrimitiveValue() && toCSSPrimitiveValue(m_firstX.get())->getValueID() == CSSValueLeft) |
+ if (m_firstX && m_firstX->isIdentifierValue() && toCSSIdentifierValue(m_firstX.get())->getValueID() == CSSValueLeft) |
run *= -1; |
- if (m_firstY && m_firstY->isPrimitiveValue() && toCSSPrimitiveValue(m_firstY.get())->getValueID() == CSSValueBottom) |
+ if (m_firstY && m_firstY->isIdentifierValue() && toCSSIdentifierValue(m_firstY.get())->getValueID() == CSSValueBottom) |
rise *= -1; |
// Compute angle, and flip it back to "bearing angle" degrees. |
float angle = 90 - rad2deg(atan2(rise, run)); |