Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(392)

Unified Diff: Source/core/css/CSSGradientValue.cpp

Issue 1226123008: CSSValue Immediates: Replace CSSPrimitiveValue usage with const references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@cssvalue_patch_4_attempt_2
Patch Set: Rebase Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/css/CSSCrossfadeValue.cpp ('k') | Source/core/css/CSSMatrix.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/CSSGradientValue.cpp
diff --git a/Source/core/css/CSSGradientValue.cpp b/Source/core/css/CSSGradientValue.cpp
index 0467195962303cc25e9cf1f7a4ddb6c1bf47567e..f22bba76ec1cd4cfdad0cad06e15ed248c0b3df5 100644
--- a/Source/core/css/CSSGradientValue.cpp
+++ b/Source/core/css/CSSGradientValue.cpp
@@ -87,8 +87,8 @@ PassRefPtr<Image> CSSGradientValue::image(LayoutObject* layoutObject, const IntS
// Should only ever be called for deprecated gradients.
static inline bool compareStops(const CSSGradientColorStop& a, const CSSGradientColorStop& b)
{
- double aVal = toCSSPrimitiveValue(*a.m_position).getDoubleValue();
- double bVal = toCSSPrimitiveValue(*b.m_position).getDoubleValue();
+ double aVal = toCSSPrimitiveValue(a.m_position).getDoubleValue();
+ double bVal = toCSSPrimitiveValue(b.m_position).getDoubleValue();
return aVal < bVal;
}
@@ -209,12 +209,12 @@ void CSSGradientValue::addDeprecatedStops(Gradient* gradient, const LayoutObject
for (const auto& stop : m_stops) {
float offset;
- if (toCSSPrimitiveValue(*stop.m_position).isPercentage())
- offset = toCSSPrimitiveValue(*stop.m_position).getFloatValue() / 100;
+ if (toCSSPrimitiveValue(stop.m_position).isPercentage())
+ offset = toCSSPrimitiveValue(stop.m_position).getFloatValue() / 100;
else
- offset = toCSSPrimitiveValue(*stop.m_position).getFloatValue();
+ offset = toCSSPrimitiveValue(stop.m_position).getFloatValue();
- gradient->addColorStop(offset, resolveStopColor(toCSSPrimitiveValue(*stop.m_color), object));
+ gradient->addColorStop(offset, resolveStopColor(toCSSPrimitiveValue(stop.m_color), object));
}
}
@@ -376,12 +376,12 @@ void CSSGradientValue::addStops(Gradient* gradient, const CSSToLengthConversionD
if (stop.isHint())
hasHints = true;
else
- stops[i].color = resolveStopColor(toCSSPrimitiveValue(*stop.m_color), object);
+ stops[i].color = resolveStopColor(toCSSPrimitiveValue(stop.m_color), object);
if (stop.m_position) {
- CSSPrimitiveValue stopPosition = toCSSPrimitiveValue(*stop.m_position);
+ const CSSPrimitiveValue& stopPosition = toCSSPrimitiveValue(stop.m_position);
if (stopPosition.isPercentage()) {
- stops[i].offset = toCSSPrimitiveValue(*stop.m_position).getFloatValue() / 100;
+ stops[i].offset = toCSSPrimitiveValue(stop.m_position).getFloatValue() / 100;
} else if (stopPosition.isLength() || stopPosition.isCalculatedPercentageWithLength()) {
float length;
if (stopPosition.isLength())
@@ -490,8 +490,8 @@ static float positionFromValue(CSSPrimitiveValue value, const CSSToLengthConvers
// In this case the center of the gradient is given relative to an edge in the form of:
// [ top | bottom | right | left ] [ <percentage> | <length> ].
if (Pair* pair = value.getPairValue()) {
- CSSValueID originID = toCSSPrimitiveValue(*pair->first()).getValueID();
- value = toCSSPrimitiveValue(*pair->second());
+ CSSValueID originID = pair->first().getValueID();
+ value = pair->second();
if (originID == CSSValueRight || originID == CSSValueBottom) {
// For right/bottom, the offset is relative to the far edge.
@@ -534,10 +534,10 @@ FloatPoint CSSGradientValue::computeEndPoint(NullableCSSValue horizontal, Nullab
FloatPoint result;
if (horizontal)
- result.setX(positionFromValue(toCSSPrimitiveValue(*horizontal), conversionData, size, true));
+ result.setX(positionFromValue(toCSSPrimitiveValue(horizontal), conversionData, size, true));
if (vertical)
- result.setY(positionFromValue(toCSSPrimitiveValue(*vertical), conversionData, size, false));
+ result.setY(positionFromValue(toCSSPrimitiveValue(vertical), conversionData, size, false));
return result;
}
@@ -547,13 +547,13 @@ bool CSSGradientValue::isCacheable() const
for (size_t i = 0; i < m_stops.size(); ++i) {
const CSSGradientColorStop& stop = m_stops[i];
- if (!stop.isHint() && toCSSPrimitiveValue(*stop.m_color).colorIsDerivedFromElement())
+ if (!stop.isHint() && toCSSPrimitiveValue(stop.m_color).colorIsDerivedFromElement())
return false;
if (!stop.m_position)
continue;
- if (toCSSPrimitiveValue(*stop.m_position).isFontRelativeLength())
+ if (toCSSPrimitiveValue(stop.m_position).isFontRelativeLength())
return false;
}
@@ -564,7 +564,7 @@ bool CSSGradientValue::knownToBeOpaque(const LayoutObject* object) const
{
ASSERT(object);
for (auto& stop : m_stops) {
- if (!stop.isHint() && resolveStopColor(toCSSPrimitiveValue(*stop.m_color), *object).hasAlpha())
+ if (!stop.isHint() && resolveStopColor(toCSSPrimitiveValue(stop.m_color), *object).hasAlpha())
return false;
}
return true;
@@ -634,10 +634,10 @@ String CSSLinearGradientValue::customCSSText() const
bool wroteSomething = false;
- if (m_angle && toCSSPrimitiveValue(*m_angle).computeDegrees() != 180) {
+ if (m_angle && toCSSPrimitiveValue(m_angle).computeDegrees() != 180) {
result.append(m_angle->cssText());
wroteSomething = true;
- } else if ((m_firstX || m_firstY) && !(!m_firstX && m_firstY && toCSSPrimitiveValue(*m_firstY).getValueID() == CSSValueBottom)) {
+ } else if ((m_firstX || m_firstY) && !(!m_firstX && m_firstY && toCSSPrimitiveValue(m_firstY).getValueID() == CSSValueBottom)) {
result.appendLiteral("to ");
if (m_firstX && m_firstY) {
result.append(m_firstX->cssText());
@@ -746,7 +746,7 @@ PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(const CSSToLengthCon
FloatPoint firstPoint;
FloatPoint secondPoint;
if (m_angle) {
- float angle = toCSSPrimitiveValue(*m_angle).computeDegrees();
+ float angle = toCSSPrimitiveValue(m_angle).computeDegrees();
endPointsFromAngle(angle, size, firstPoint, secondPoint, m_gradientType);
} else {
switch (m_gradientType) {
@@ -773,9 +773,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 && toCSSPrimitiveValue(*m_firstX).getValueID() == CSSValueLeft)
+ if (m_firstX && toCSSPrimitiveValue(m_firstX).getValueID() == CSSValueLeft)
run *= -1;
- if (m_firstY && toCSSPrimitiveValue(*m_firstY).getValueID() == CSSValueBottom)
+ if (m_firstY && toCSSPrimitiveValue(m_firstY).getValueID() == CSSValueBottom)
rise *= -1;
// Compute angle, and flip it back to "bearing angle" degrees.
float angle = 90 - rad2deg(atan2(rise, run));
@@ -849,7 +849,7 @@ inline void CSSGradientValue::appendCSSTextForDeprecatedColorStops(StringBuilder
for (unsigned i = 0; i < m_stops.size(); i++) {
const CSSGradientColorStop& stop = m_stops[i];
result.appendLiteral(", ");
- double stopValue = toCSSPrimitiveValue(*stop.m_position).getDoubleValue();
+ double stopValue = toCSSPrimitiveValue(stop.m_position).getDoubleValue();
if (stopValue == 0) {
result.appendLiteral("from(");
result.append(stop.m_color->cssText());
@@ -942,12 +942,12 @@ String CSSRadialGradientValue::customCSSText() const
// The only ambiguous case that needs an explicit shape to be provided
// is when a sizing keyword is used (or all sizing is omitted).
- if (m_shape && toCSSPrimitiveValue(*m_shape).getValueID() != CSSValueEllipse && (m_sizingBehavior || (!m_sizingBehavior && !m_endHorizontalSize))) {
+ if (m_shape && toCSSPrimitiveValue(m_shape).getValueID() != CSSValueEllipse && (m_sizingBehavior || (!m_sizingBehavior && !m_endHorizontalSize))) {
result.appendLiteral("circle");
wroteSomething = true;
}
- if (m_sizingBehavior && toCSSPrimitiveValue(*m_sizingBehavior).getValueID() != CSSValueFarthestCorner) {
+ if (m_sizingBehavior && toCSSPrimitiveValue(m_sizingBehavior).getValueID() != CSSValueFarthestCorner) {
if (wroteSomething)
result.append(' ');
result.append(m_sizingBehavior->cssText());
@@ -1102,26 +1102,26 @@ PassRefPtr<Gradient> CSSRadialGradientValue::createGradient(const CSSToLengthCon
float firstRadius = 0;
if (m_firstRadius)
- firstRadius = resolveRadius(toCSSPrimitiveValue(*m_firstRadius), conversionData);
+ firstRadius = resolveRadius(toCSSPrimitiveValue(m_firstRadius), conversionData);
FloatSize secondRadius(0, 0);
if (m_secondRadius) {
- secondRadius.setWidth(resolveRadius(toCSSPrimitiveValue(*m_secondRadius), conversionData));
+ secondRadius.setWidth(resolveRadius(toCSSPrimitiveValue(m_secondRadius), conversionData));
secondRadius.setHeight(secondRadius.width());
} else if (m_endHorizontalSize) {
float width = size.width();
float height = size.height();
- secondRadius.setWidth(resolveRadius(toCSSPrimitiveValue(*m_endHorizontalSize), conversionData, &width));
+ secondRadius.setWidth(resolveRadius(toCSSPrimitiveValue(m_endHorizontalSize), conversionData, &width));
secondRadius.setHeight(m_endVerticalSize
- ? resolveRadius(toCSSPrimitiveValue(*m_endVerticalSize), conversionData, &height)
+ ? resolveRadius(toCSSPrimitiveValue(m_endVerticalSize), conversionData, &height)
: secondRadius.width());
} else {
- EndShapeType shape = (m_shape && toCSSPrimitiveValue(*m_shape).getValueID() == CSSValueCircle)
+ EndShapeType shape = (m_shape && toCSSPrimitiveValue(m_shape).getValueID() == CSSValueCircle)
|| (!m_shape && !m_sizingBehavior && m_endHorizontalSize && !m_endVerticalSize)
? CircleEndShape
: EllipseEndShape;
- switch (m_sizingBehavior ? toCSSPrimitiveValue(*m_sizingBehavior).getValueID() : 0) {
+ switch (m_sizingBehavior ? toCSSPrimitiveValue(m_sizingBehavior).getValueID() : 0) {
case CSSValueContain:
case CSSValueClosestSide:
secondRadius = radiusToSide(secondPoint, size, shape,
« no previous file with comments | « Source/core/css/CSSCrossfadeValue.cpp ('k') | Source/core/css/CSSMatrix.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698