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

Side by Side Diff: Source/core/svg/animation/SMILTime.h

Issue 499933002: Simplify SMILTime operators (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Move +/- operators to the header. Created 6 years, 3 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 | « no previous file | Source/core/svg/animation/SMILTime.cpp » ('j') | 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 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 inline bool operator!=(const SMILTime& a, const SMILTime& b) { return !operator= =(a, b); } 89 inline bool operator!=(const SMILTime& a, const SMILTime& b) { return !operator= =(a, b); }
90 90
91 // Ordering of SMILTimes has to follow: finite < indefinite (Inf) < unresolved ( NaN). The first comparison is handled by IEEE754 but 91 // Ordering of SMILTimes has to follow: finite < indefinite (Inf) < unresolved ( NaN). The first comparison is handled by IEEE754 but
92 // NaN values must be checked explicitly to guarantee that unresolved is ordered correctly too. 92 // NaN values must be checked explicitly to guarantee that unresolved is ordered correctly too.
93 inline bool operator>(const SMILTime& a, const SMILTime& b) { return a.isUnresol ved() || (a.value() > b.value()); } 93 inline bool operator>(const SMILTime& a, const SMILTime& b) { return a.isUnresol ved() || (a.value() > b.value()); }
94 inline bool operator<(const SMILTime& a, const SMILTime& b) { return operator>(b , a); } 94 inline bool operator<(const SMILTime& a, const SMILTime& b) { return operator>(b , a); }
95 inline bool operator>=(const SMILTime& a, const SMILTime& b) { return operator>( a, b) || operator==(a, b); } 95 inline bool operator>=(const SMILTime& a, const SMILTime& b) { return operator>( a, b) || operator==(a, b); }
96 inline bool operator<=(const SMILTime& a, const SMILTime& b) { return operator<( a, b) || operator==(a, b); } 96 inline bool operator<=(const SMILTime& a, const SMILTime& b) { return operator<( a, b) || operator==(a, b); }
97 inline bool operator<(const SMILTimeWithOrigin& a, const SMILTimeWithOrigin& b) { return a.time() < b.time(); } 97 inline bool operator<(const SMILTimeWithOrigin& a, const SMILTimeWithOrigin& b) { return a.time() < b.time(); }
98 98
99 SMILTime operator+(const SMILTime&, const SMILTime&); 99 inline SMILTime operator+(const SMILTime& a, const SMILTime& b) { return a.value () + b.value(); }
100 SMILTime operator-(const SMILTime&, const SMILTime&); 100 inline SMILTime operator-(const SMILTime& a, const SMILTime& b) { return a.value () - b.value(); }
101 // So multiplying times does not make too much sense but SMIL defines it for dur ation * repeatCount 101 // So multiplying times does not make too much sense but SMIL defines it for dur ation * repeatCount
102 SMILTime operator*(const SMILTime&, const SMILTime&); 102 SMILTime operator*(const SMILTime&, const SMILTime&);
103 103
104 inline bool operator!=(const SMILInterval& a, const SMILInterval& b) 104 inline bool operator!=(const SMILInterval& a, const SMILInterval& b)
105 { 105 {
106 // Compare the "raw" values since the operator!= for SMILTime always return 106 // Compare the "raw" values since the operator!= for SMILTime always return
107 // true for non-finite times. 107 // true for non-finite times.
108 return a.begin.value() != b.begin.value() || a.end.value() != b.end.value(); 108 return a.begin.value() != b.begin.value() || a.end.value() != b.end.value();
109 } 109 }
110 110
(...skipping 13 matching lines...) Expand all
124 124
125 template<> struct HashTraits<blink::SMILTime> : GenericHashTraits<blink::SMILTim e> { 125 template<> struct HashTraits<blink::SMILTime> : GenericHashTraits<blink::SMILTim e> {
126 static blink::SMILTime emptyValue() { return blink::SMILTime::unresolved(); } 126 static blink::SMILTime emptyValue() { return blink::SMILTime::unresolved(); }
127 static void constructDeletedValue(blink::SMILTime& slot) { slot = -std::nume ric_limits<double>::infinity(); } 127 static void constructDeletedValue(blink::SMILTime& slot) { slot = -std::nume ric_limits<double>::infinity(); }
128 static bool isDeletedValue(blink::SMILTime value) { return value == -std::nu meric_limits<double>::infinity(); } 128 static bool isDeletedValue(blink::SMILTime value) { return value == -std::nu meric_limits<double>::infinity(); }
129 }; 129 };
130 130
131 } // namespace WTF 131 } // namespace WTF
132 132
133 #endif // SMILTime_h 133 #endif // SMILTime_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/svg/animation/SMILTime.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698