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

Side by Side Diff: third_party/WebKit/Source/core/html/TimeRanges.cpp

Issue 2615953003: Rename IGNORE_EXCEPTION to IGNORE_EXCEPTION_FOR_TESTING (Closed)
Patch Set: temp Created 3 years, 11 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2009, 2010 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2009, 2010 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 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 } 165 }
166 } 166 }
167 } 167 }
168 168
169 // Now that we are sure we don't overlap with any range, just add it. 169 // Now that we are sure we don't overlap with any range, just add it.
170 m_ranges.insert(overlappingArcIndex, addedRange); 170 m_ranges.insert(overlappingArcIndex, addedRange);
171 } 171 }
172 172
173 bool TimeRanges::contain(double time) const { 173 bool TimeRanges::contain(double time) const {
174 for (unsigned n = 0; n < length(); n++) { 174 for (unsigned n = 0; n < length(); n++) {
175 if (time >= start(n, IGNORE_EXCEPTION) && time <= end(n, IGNORE_EXCEPTION)) 175 if (time >= start(n, IGNORE_EXCEPTION_FOR_TESTING) &&
176 time <= end(n, IGNORE_EXCEPTION_FOR_TESTING))
176 return true; 177 return true;
177 } 178 }
178 return false; 179 return false;
179 } 180 }
180 181
181 double TimeRanges::nearest(double newPlaybackPosition, 182 double TimeRanges::nearest(double newPlaybackPosition,
182 double currentPlaybackPosition) const { 183 double currentPlaybackPosition) const {
183 unsigned count = length(); 184 unsigned count = length();
184 double bestMatch = 0; 185 double bestMatch = 0;
185 double bestDelta = std::numeric_limits<double>::infinity(); 186 double bestDelta = std::numeric_limits<double>::infinity();
186 for (unsigned ndx = 0; ndx < count; ndx++) { 187 for (unsigned ndx = 0; ndx < count; ndx++) {
187 double startTime = start(ndx, IGNORE_EXCEPTION); 188 double startTime = start(ndx, IGNORE_EXCEPTION_FOR_TESTING);
188 double endTime = end(ndx, IGNORE_EXCEPTION); 189 double endTime = end(ndx, IGNORE_EXCEPTION_FOR_TESTING);
189 if (newPlaybackPosition >= startTime && newPlaybackPosition <= endTime) 190 if (newPlaybackPosition >= startTime && newPlaybackPosition <= endTime)
190 return newPlaybackPosition; 191 return newPlaybackPosition;
191 192
192 double delta, match; 193 double delta, match;
193 if (newPlaybackPosition < startTime) { 194 if (newPlaybackPosition < startTime) {
194 delta = startTime - newPlaybackPosition; 195 delta = startTime - newPlaybackPosition;
195 match = startTime; 196 match = startTime;
196 } else { 197 } else {
197 delta = newPlaybackPosition - endTime; 198 delta = newPlaybackPosition - endTime;
198 match = endTime; 199 match = endTime;
199 } 200 }
200 201
201 if (delta < bestDelta || 202 if (delta < bestDelta ||
202 (delta == bestDelta && 203 (delta == bestDelta &&
203 std::abs(currentPlaybackPosition - match) < 204 std::abs(currentPlaybackPosition - match) <
204 std::abs(currentPlaybackPosition - bestMatch))) { 205 std::abs(currentPlaybackPosition - bestMatch))) {
205 bestDelta = delta; 206 bestDelta = delta;
206 bestMatch = match; 207 bestMatch = match;
207 } 208 }
208 } 209 }
209 return bestMatch; 210 return bestMatch;
210 } 211 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/html/HTMLTitleElement.cpp ('k') | third_party/WebKit/Source/core/html/TimeRangesTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698