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

Side by Side Diff: third_party/WebKit/Source/core/css/CSSGradientValue.cpp

Issue 2221793004: Fixed crash with zero/infinite aspect ratio radial gradients (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added layout test Created 4 years, 4 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/gradients/css3-radial-gradients-zero-radius-crash.html ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2015 Google Inc. All rights reserved. 3 * Copyright (C) 2015 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 1035 matching lines...) Expand 10 before | Expand all | Expand 10 after
1046 return compare(dx, dy) ? FloatSize(dx, dx) : FloatSize(dy, dy); 1046 return compare(dx, dy) ? FloatSize(dx, dx) : FloatSize(dy, dy);
1047 1047
1048 ASSERT(shape == EllipseEndShape); 1048 ASSERT(shape == EllipseEndShape);
1049 return FloatSize(dx, dy); 1049 return FloatSize(dx, dy);
1050 } 1050 }
1051 1051
1052 // Compute the radius of an ellipse with center at 0,0 which passes through p, a nd has 1052 // Compute the radius of an ellipse with center at 0,0 which passes through p, a nd has
1053 // width/height given by aspectRatio. 1053 // width/height given by aspectRatio.
1054 inline FloatSize ellipseRadius(const FloatPoint& p, float aspectRatio) 1054 inline FloatSize ellipseRadius(const FloatPoint& p, float aspectRatio)
1055 { 1055 {
1056 // If the aspectRatio is 0 or infinite, the ellipse is completely flat.
1057 // TODO(sashab): Implement Degenerate Radial Gradients, see crbug.com/635727 .
1058 if (aspectRatio == 0 || std::isinf(aspectRatio))
1059 return FloatSize(0, 0);
1060
1056 // x^2/a^2 + y^2/b^2 = 1 1061 // x^2/a^2 + y^2/b^2 = 1
1057 // a/b = aspectRatio, b = a/aspectRatio 1062 // a/b = aspectRatio, b = a/aspectRatio
1058 // a = sqrt(x^2 + y^2/(1/r^2)) 1063 // a = sqrt(x^2 + y^2/(1/r^2))
1059 float a = sqrtf(p.x() * p.x() + p.y() * p.y() * aspectRatio * aspectRatio); 1064 float a = sqrtf(p.x() * p.x() + p.y() * p.y() * aspectRatio * aspectRatio);
1060 return FloatSize(clampTo<float>(a), clampTo<float>(a / aspectRatio)); 1065 return FloatSize(clampTo<float>(a), clampTo<float>(a / aspectRatio));
1061 } 1066 }
1062 1067
1063 // Compute the radius to the closest/farthest corner (depending on the compare f unctor). 1068 // Compute the radius to the closest/farthest corner (depending on the compare f unctor).
1064 FloatSize radiusToCorner(const FloatPoint& point, const FloatSize& size, EndShap eType shape, 1069 FloatSize radiusToCorner(const FloatPoint& point, const FloatSize& size, EndShap eType shape,
1065 bool (*compare)(float, float)) 1070 bool (*compare)(float, float))
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
1222 visitor->trace(m_firstRadius); 1227 visitor->trace(m_firstRadius);
1223 visitor->trace(m_secondRadius); 1228 visitor->trace(m_secondRadius);
1224 visitor->trace(m_shape); 1229 visitor->trace(m_shape);
1225 visitor->trace(m_sizingBehavior); 1230 visitor->trace(m_sizingBehavior);
1226 visitor->trace(m_endHorizontalSize); 1231 visitor->trace(m_endHorizontalSize);
1227 visitor->trace(m_endVerticalSize); 1232 visitor->trace(m_endVerticalSize);
1228 CSSGradientValue::traceAfterDispatch(visitor); 1233 CSSGradientValue::traceAfterDispatch(visitor);
1229 } 1234 }
1230 1235
1231 } // namespace blink 1236 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/fast/gradients/css3-radial-gradients-zero-radius-crash.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698