OLD | NEW |
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 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 if (index >= length()) { | 128 if (index >= length()) { |
129 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde
xExceedsMaximumBound("index", index, length())); | 129 exceptionState.throwDOMException(IndexSizeError, ExceptionMessages::inde
xExceedsMaximumBound("index", index, length())); |
130 return 0; | 130 return 0; |
131 } | 131 } |
132 return m_ranges[index].m_end; | 132 return m_ranges[index].m_end; |
133 } | 133 } |
134 | 134 |
135 void TimeRanges::add(double start, double end) | 135 void TimeRanges::add(double start, double end) |
136 { | 136 { |
137 ASSERT(start <= end); | 137 ASSERT(start <= end); |
138 unsigned int overlappingArcIndex; | 138 unsigned overlappingArcIndex; |
139 Range addedRange(start, end); | 139 Range addedRange(start, end); |
140 | 140 |
141 // For each present range check if we need to: | 141 // For each present range check if we need to: |
142 // - merge with the added range, in case we are overlapping or contiguous | 142 // - merge with the added range, in case we are overlapping or contiguous |
143 // - Need to insert in place, we we are completely, not overlapping and not
contiguous | 143 // - Need to insert in place, we we are completely, not overlapping and not
contiguous |
144 // in between two ranges. | 144 // in between two ranges. |
145 // | 145 // |
146 // TODO: Given that we assume that ranges are correctly ordered, this could
be optimized. | 146 // TODO: Given that we assume that ranges are correctly ordered, this could
be optimized. |
147 | 147 |
148 for (overlappingArcIndex = 0; overlappingArcIndex < m_ranges.size(); overlap
pingArcIndex++) { | 148 for (overlappingArcIndex = 0; overlappingArcIndex < m_ranges.size(); overlap
pingArcIndex++) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 double endTime = end(ndx, IGNORE_EXCEPTION); | 193 double endTime = end(ndx, IGNORE_EXCEPTION); |
194 if (time >= startTime && time <= endTime) | 194 if (time >= startTime && time <= endTime) |
195 return time; | 195 return time; |
196 if (fabs(startTime - time) < closest) | 196 if (fabs(startTime - time) < closest) |
197 closest = fabs(startTime - time); | 197 closest = fabs(startTime - time); |
198 else if (fabs(endTime - time) < closest) | 198 else if (fabs(endTime - time) < closest) |
199 closest = fabs(endTime - time); | 199 closest = fabs(endTime - time); |
200 } | 200 } |
201 return closest; | 201 return closest; |
202 } | 202 } |
OLD | NEW |