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

Unified Diff: Source/platform/graphics/Gradient.cpp

Issue 206493002: Minor Gradient cleanup. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 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
« no previous file with comments | « Source/platform/graphics/Gradient.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/graphics/Gradient.cpp
diff --git a/Source/platform/graphics/Gradient.cpp b/Source/platform/graphics/Gradient.cpp
index 0741e855616bb1f6e756c5c9ee32b8dd92351708..9c10bed4648e69caae3ca5535ff33b1bb2396249 100644
--- a/Source/platform/graphics/Gradient.cpp
+++ b/Source/platform/graphics/Gradient.cpp
@@ -68,27 +68,23 @@ Gradient::~Gradient()
{
}
-void Gradient::addColorStop(float value, const Color& color)
+static inline bool compareStops(const Gradient::ColorStop& a, const Gradient::ColorStop& b)
{
- m_stops.append(ColorStop(value, color));
-
- m_stopsSorted = false;
- m_gradient.clear();
+ return a.stop < b.stop;
}
void Gradient::addColorStop(const Gradient::ColorStop& stop)
{
- m_stops.append(stop);
+ if (m_stops.isEmpty()) {
+ m_stopsSorted = true;
+ } else {
+ m_stopsSorted = m_stopsSorted && compareStops(m_stops.last(), stop);
+ }
- m_stopsSorted = false;
+ m_stops.append(stop);
m_gradient.clear();
}
-static inline bool compareStops(const Gradient::ColorStop& a, const Gradient::ColorStop& b)
-{
- return a.stop < b.stop;
-}
-
void Gradient::sortStopsIfNecessary()
{
if (m_stopsSorted)
« no previous file with comments | « Source/platform/graphics/Gradient.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698