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

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

Issue 2755493004: Replace ASSERT, ASSERT_NOT_REACHED, and RELEASE_ASSERT in core/css/ (Closed)
Patch Set: Worked on Review Comments done Created 3 years, 9 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
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 7887781901993dfdfa18d81660c95b5f9c319f19..aa8806ec82c2d1120bfa204cba884778659275b0 100644
--- a/third_party/WebKit/Source/core/css/CSSGradientValue.cpp
+++ b/third_party/WebKit/Source/core/css/CSSGradientValue.cpp
@@ -151,7 +151,7 @@ static void replaceColorHintsWithColorStops(
// The current index of the stops vector.
size_t x = i + indexOffset;
- ASSERT(x >= 1);
+ DCHECK_GE(x, static_cast<unsigned>(1));
tkent 2017/03/28 14:44:55 static_cast<unsigned>(1) -> 1u
nikhil.sahni 2017/03/30 12:17:57 Done.
// offsetLeft offset offsetRight
// |-------------------|---------------------------------|
@@ -167,7 +167,8 @@ static void replaceColorHintsWithColorStops(
Color leftColor = stops[x - 1].color;
Color rightColor = stops[x + 1].color;
- ASSERT(offsetLeft <= offset && offset <= offsetRight);
+ DCHECK_LE(offsetLeft, offset);
+ DCHECK_LE(offset, offsetRight);
if (WebCoreFloatNearlyEqual(leftDist, rightDist)) {
stops.remove(x);
@@ -225,7 +226,7 @@ static Color resolveStopColor(const CSSValue& stopColor,
void CSSGradientValue::addDeprecatedStops(Gradient* gradient,
const LayoutObject& object) {
- ASSERT(m_gradientType == CSSDeprecatedLinearGradient ||
+ DCHECK(m_gradientType == CSSDeprecatedLinearGradient ||
m_gradientType == CSSDeprecatedRadialGradient);
if (!m_stopsSorted) {
@@ -267,7 +268,7 @@ static bool requiresStopsNormalization(const Vector<GradientStop>& stops,
// gradient.
static bool normalizeAndAddStops(const Vector<GradientStop>& stops,
Gradient* gradient) {
- ASSERT(stops.size() > 1);
+ DCHECK_GT(stops.size(), static_cast<unsigned>(1));
tkent 2017/03/28 14:44:55 static_cast<unsigned>(1) -> 1u
nikhil.sahni 2017/03/30 12:17:57 Done.
const float firstOffset = stops.front().offset;
const float lastOffset = stops.back().offset;
@@ -288,14 +289,15 @@ static bool normalizeAndAddStops(const Vector<GradientStop>& stops,
return false;
}
- ASSERT(span > 0);
+ DCHECK_GT(span, 0);
for (size_t i = 0; i < stops.size(); ++i) {
const float normalizedOffset = (stops[i].offset - firstOffset) / span;
// stop offsets should be monotonically increasing in [0 , 1]
- ASSERT(normalizedOffset >= 0 && normalizedOffset <= 1);
- ASSERT(i == 0 ||
+ DCHECK_GE(normalizedOffset, 0);
+ DCHECK_LE(normalizedOffset, 1);
+ DCHECK(i == 0 ||
normalizedOffset >= (stops[i - 1].offset - firstOffset) / span);
gradient->addColorStop(normalizedOffset, stops[i].color);
@@ -315,7 +317,7 @@ static void clampNegativeOffsets(Vector<GradientStop>& stops) {
if (i > 0) {
// We found the negative -> positive offset transition: compute an
// interpolated color value for 0 and use it with the last clamped stop.
- ASSERT(lastNegativeOffset < 0);
+ DCHECK_LT(lastNegativeOffset, 0);
float lerpRatio =
-lastNegativeOffset / (currentOffset - lastNegativeOffset);
stops[i - 1].color =
@@ -335,8 +337,8 @@ static void clampNegativeOffsets(Vector<GradientStop>& stops) {
static void adjustGradientPointsForOffsetRange(Gradient* gradient,
float firstOffset,
float lastOffset) {
- ASSERT(!gradient->isRadial());
- ASSERT(firstOffset <= lastOffset);
+ DCHECK(!gradient->isRadial());
+ DCHECK(firstOffset <= lastOffset);
tkent 2017/03/28 14:44:55 Use DCHECK_LE
nikhil.sahni 2017/03/30 12:17:57 Done.
const FloatPoint p0 = gradient->p0();
const FloatPoint p1 = gradient->p1();
@@ -351,20 +353,20 @@ static void adjustGradientPointsForOffsetRange(Gradient* gradient,
static void adjustGradientRadiiForOffsetRange(Gradient* gradient,
float firstOffset,
float lastOffset) {
- ASSERT(gradient->isRadial());
- ASSERT(firstOffset <= lastOffset);
+ DCHECK(gradient->isRadial());
+ DCHECK_LE(firstOffset, lastOffset);
// Radial offsets are relative to the [0 , endRadius] segment.
float adjustedR0 = gradient->endRadius() * firstOffset;
float adjustedR1 = gradient->endRadius() * lastOffset;
- ASSERT(adjustedR0 <= adjustedR1);
+ DCHECK_LE(adjustedR0, adjustedR1);
// Unlike linear gradients (where we can adjust the points arbitrarily),
// we cannot let our radii turn negative here.
if (adjustedR0 < 0) {
// For the non-repeat case, this can never happen: clampNegativeOffsets()
// ensures we don't have to deal with negative offsets at this point.
- ASSERT(gradient->spreadMethod() == SpreadMethodRepeat);
+ DCHECK_EQ(gradient->spreadMethod(), SpreadMethodRepeat);
// When in repeat mode, we deal with it by repositioning both radii in the
// positive domain - shifting them by a multiple of the radius span (which
@@ -375,8 +377,8 @@ static void adjustGradientRadiiForOffsetRange(Gradient* gradient,
adjustedR0 += shiftToPositive;
adjustedR1 += shiftToPositive;
}
- ASSERT(adjustedR0 >= 0);
- ASSERT(adjustedR1 >= adjustedR0);
+ DCHECK_GE(adjustedR0, 0);
+ DCHECK_GE(adjustedR1, adjustedR0);
gradient->setStartRadius(adjustedR0);
gradient->setEndRadius(adjustedR1);
@@ -428,7 +430,7 @@ void CSSGradientValue::addStops(Gradient* gradient,
->evaluate(gradientLength);
stops[i].offset = (gradientLength > 0) ? length / gradientLength : 0;
} else {
- ASSERT_NOT_REACHED();
+ NOTREACHED();
stops[i].offset = 0;
}
stops[i].specified = true;
@@ -461,7 +463,8 @@ void CSSGradientValue::addStops(Gradient* gradient,
}
}
- ASSERT(stops.front().specified && stops.back().specified);
+ DCHECK(stops.front().specified);
+ DCHECK(stops.back().specified);
// If any color-stop still does not have a position, then, for each run of
// adjacent color-stops without positions, set their positions so that they
@@ -494,7 +497,7 @@ void CSSGradientValue::addStops(Gradient* gradient,
}
}
- ASSERT(stops.size() == m_stops.size());
+ DCHECK_EQ(stops.size(), m_stops.size());
if (hasHints) {
replaceColorHintsWithColorStops(stops, m_stops);
}
@@ -816,7 +819,7 @@ PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(
const CSSToLengthConversionData& conversionData,
const IntSize& size,
const LayoutObject& object) {
- ASSERT(!size.isEmpty());
+ DCHECK(!size.isEmpty());
FloatPoint firstPoint;
FloatPoint secondPoint;
@@ -874,7 +877,7 @@ PassRefPtr<Gradient> CSSLinearGradientValue::createGradient(
secondPoint.setY(size.height());
break;
default:
- ASSERT_NOT_REACHED();
+ NOTREACHED();
}
}
@@ -1118,7 +1121,7 @@ FloatSize radiusToSide(const FloatPoint& point,
if (shape == CircleEndShape)
return compare(dx, dy) ? FloatSize(dx, dx) : FloatSize(dy, dy);
- ASSERT(shape == EllipseEndShape);
+ DCHECK_EQ(shape, EllipseEndShape);
return FloatSize(dx, dy);
}
@@ -1160,7 +1163,7 @@ FloatSize radiusToCorner(const FloatPoint& point,
if (shape == CircleEndShape)
return FloatSize(distance, distance);
- ASSERT(shape == EllipseEndShape);
+ DCHECK_EQ(shape, EllipseEndShape);
// If the end shape is an ellipse, the gradient-shape has the same ratio of
// width to height that it would if closest-side or farthest-side were
// specified, as appropriate.
@@ -1177,7 +1180,7 @@ PassRefPtr<Gradient> CSSRadialGradientValue::createGradient(
const CSSToLengthConversionData& conversionData,
const IntSize& size,
const LayoutObject& object) {
- ASSERT(!size.isEmpty());
+ DCHECK(!size.isEmpty());
FloatPoint firstPoint =
computeEndPoint(m_firstX.get(), m_firstY.get(), conversionData, size);

Powered by Google App Engine
This is Rietveld 408576698