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

Unified Diff: Source/core/platform/animation/TimingFunction.h

Issue 57563002: Adding operator== for ChainedTimingFunction (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Remove EQ reflectivity fix. Created 7 years, 1 month 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 | « no previous file | Source/core/platform/animation/TimingFunctionTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/platform/animation/TimingFunction.h
diff --git a/Source/core/platform/animation/TimingFunction.h b/Source/core/platform/animation/TimingFunction.h
index abbaf4ed80228d32b76db7d9d2c0db8435178c66..52b791168da3d1c866ac6a2789faf4deea7e8490 100644
--- a/Source/core/platform/animation/TimingFunction.h
+++ b/Source/core/platform/animation/TimingFunction.h
@@ -291,9 +291,21 @@ public:
virtual bool operator==(const TimingFunction& other) const
{
- // This class is not exposed to CSS, so this method is not required.
- ASSERT_NOT_REACHED();
- return false;
+ if (other.type() != ChainedFunction)
+ return false;
+
+ if (this == &other)
+ return true;
+
+ const ChainedTimingFunction* ctf = static_cast<const ChainedTimingFunction*>(&other);
+ if (ctf->m_segments.size() != m_segments.size())
+ return false;
+
+ for (size_t i = 0; i < m_segments.size(); i++) {
+ if (m_segments[i] != ctf->m_segments[i])
+ return false;
+ }
+ return true;
}
private:
@@ -311,6 +323,27 @@ private:
return scaleFromLocal(m_timingFunction->evaluate(scaleToLocal(fraction), accuracy));
}
+ bool operator==(const Segment& other) const
+ {
+ if (this == &other)
+ return true;
+
+ bool minMaxEq = m_min == other.m_min && m_max == other.m_max;
+ if (!minMaxEq)
+ return false;
+
+ if (m_timingFunction == other.m_timingFunction)
+ return true;
+
+ if (!m_timingFunction || !other.m_timingFunction)
+ return false;
+
+ return (*m_timingFunction.get()) == (*other.m_timingFunction.get());
+ }
+ bool operator!=(const Segment& other) const
+ {
+ return !operator==(other);
+ }
private:
double scaleToLocal(double x) const { return (x - m_min) / (m_max - m_min); }
double scaleFromLocal(double x) const { return blend(m_min, m_max, x); }
« no previous file with comments | « no previous file | Source/core/platform/animation/TimingFunctionTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698