OLD | NEW |
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 Loading... |
89 inline bool operator==(const SMILTime& a, const SMILTime& b) { | 89 inline bool operator==(const SMILTime& a, const SMILTime& b) { |
90 return (a.isUnresolved() && b.isUnresolved()) || a.value() == b.value(); | 90 return (a.isUnresolved() && b.isUnresolved()) || a.value() == b.value(); |
91 } | 91 } |
92 inline bool operator!(const SMILTime& a) { | 92 inline bool operator!(const SMILTime& a) { |
93 return !a.isFinite() || !a.value(); | 93 return !a.isFinite() || !a.value(); |
94 } | 94 } |
95 inline bool operator!=(const SMILTime& a, const SMILTime& b) { | 95 inline bool operator!=(const SMILTime& a, const SMILTime& b) { |
96 return !operator==(a, b); | 96 return !operator==(a, b); |
97 } | 97 } |
98 | 98 |
99 // Ordering of SMILTimes has to follow: finite < indefinite (Inf) < unresolved (
NaN). The first comparison is handled by IEEE754 but | 99 // Ordering of SMILTimes has to follow: finite < indefinite (Inf) < unresolved |
100 // NaN values must be checked explicitly to guarantee that unresolved is ordered
correctly too. | 100 // (NaN). The first comparison is handled by IEEE754 but NaN values must be |
| 101 // checked explicitly to guarantee that unresolved is ordered correctly too. |
101 inline bool operator>(const SMILTime& a, const SMILTime& b) { | 102 inline bool operator>(const SMILTime& a, const SMILTime& b) { |
102 return a.isUnresolved() || (a.value() > b.value()); | 103 return a.isUnresolved() || (a.value() > b.value()); |
103 } | 104 } |
104 inline bool operator<(const SMILTime& a, const SMILTime& b) { | 105 inline bool operator<(const SMILTime& a, const SMILTime& b) { |
105 return operator>(b, a); | 106 return operator>(b, a); |
106 } | 107 } |
107 inline bool operator>=(const SMILTime& a, const SMILTime& b) { | 108 inline bool operator>=(const SMILTime& a, const SMILTime& b) { |
108 return operator>(a, b) || operator==(a, b); | 109 return operator>(a, b) || operator==(a, b); |
109 } | 110 } |
110 inline bool operator<=(const SMILTime& a, const SMILTime& b) { | 111 inline bool operator<=(const SMILTime& a, const SMILTime& b) { |
111 return operator<(a, b) || operator==(a, b); | 112 return operator<(a, b) || operator==(a, b); |
112 } | 113 } |
113 inline bool operator<(const SMILTimeWithOrigin& a, | 114 inline bool operator<(const SMILTimeWithOrigin& a, |
114 const SMILTimeWithOrigin& b) { | 115 const SMILTimeWithOrigin& b) { |
115 return a.time() < b.time(); | 116 return a.time() < b.time(); |
116 } | 117 } |
117 | 118 |
118 inline SMILTime operator+(const SMILTime& a, const SMILTime& b) { | 119 inline SMILTime operator+(const SMILTime& a, const SMILTime& b) { |
119 return a.value() + b.value(); | 120 return a.value() + b.value(); |
120 } | 121 } |
121 inline SMILTime operator-(const SMILTime& a, const SMILTime& b) { | 122 inline SMILTime operator-(const SMILTime& a, const SMILTime& b) { |
122 return a.value() - b.value(); | 123 return a.value() - b.value(); |
123 } | 124 } |
124 // So multiplying times does not make too much sense but SMIL defines it for dur
ation * repeatCount | 125 // So multiplying times does not make too much sense but SMIL defines it for |
| 126 // duration * repeatCount |
125 SMILTime operator*(const SMILTime&, const SMILTime&); | 127 SMILTime operator*(const SMILTime&, const SMILTime&); |
126 | 128 |
127 inline bool operator!=(const SMILInterval& a, const SMILInterval& b) { | 129 inline bool operator!=(const SMILInterval& a, const SMILInterval& b) { |
128 // Compare the "raw" values since the operator!= for SMILTime always return | 130 // Compare the "raw" values since the operator!= for SMILTime always return |
129 // true for non-finite times. | 131 // true for non-finite times. |
130 return a.begin.value() != b.begin.value() || a.end.value() != b.end.value(); | 132 return a.begin.value() != b.begin.value() || a.end.value() != b.end.value(); |
131 } | 133 } |
132 | 134 |
133 struct SMILTimeHash { | 135 struct SMILTimeHash { |
134 STATIC_ONLY(SMILTimeHash); | 136 STATIC_ONLY(SMILTimeHash); |
(...skipping 22 matching lines...) Expand all Loading... |
157 slot = -std::numeric_limits<double>::infinity(); | 159 slot = -std::numeric_limits<double>::infinity(); |
158 } | 160 } |
159 static bool isDeletedValue(blink::SMILTime value) { | 161 static bool isDeletedValue(blink::SMILTime value) { |
160 return value == -std::numeric_limits<double>::infinity(); | 162 return value == -std::numeric_limits<double>::infinity(); |
161 } | 163 } |
162 }; | 164 }; |
163 | 165 |
164 } // namespace WTF | 166 } // namespace WTF |
165 | 167 |
166 #endif // SMILTime_h | 168 #endif // SMILTime_h |
OLD | NEW |