| 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 22 matching lines...) Expand all Loading... |
| 33 | 33 |
| 34 using namespace WebCore; | 34 using namespace WebCore; |
| 35 using namespace std; | 35 using namespace std; |
| 36 | 36 |
| 37 TimeRanges::TimeRanges(double start, double end) | 37 TimeRanges::TimeRanges(double start, double end) |
| 38 { | 38 { |
| 39 ScriptWrappable::init(this); | 39 ScriptWrappable::init(this); |
| 40 add(start, end); | 40 add(start, end); |
| 41 } | 41 } |
| 42 | 42 |
| 43 PassRefPtr<TimeRanges> TimeRanges::create(const blink::WebTimeRanges& webRanges) |
| 44 { |
| 45 RefPtr<TimeRanges> ranges = TimeRanges::create(); |
| 46 |
| 47 unsigned size = webRanges.size(); |
| 48 for (unsigned i = 0; i < size; ++i) |
| 49 ranges->add(webRanges[i].start, webRanges[i].end); |
| 50 |
| 51 return ranges.release(); |
| 52 } |
| 53 |
| 43 PassRefPtr<TimeRanges> TimeRanges::copy() const | 54 PassRefPtr<TimeRanges> TimeRanges::copy() const |
| 44 { | 55 { |
| 45 RefPtr<TimeRanges> newSession = TimeRanges::create(); | 56 RefPtr<TimeRanges> newSession = TimeRanges::create(); |
| 46 | 57 |
| 47 unsigned size = m_ranges.size(); | 58 unsigned size = m_ranges.size(); |
| 48 for (unsigned i = 0; i < size; i++) | 59 for (unsigned i = 0; i < size; i++) |
| 49 newSession->add(m_ranges[i].m_start, m_ranges[i].m_end); | 60 newSession->add(m_ranges[i].m_start, m_ranges[i].m_end); |
| 50 | 61 |
| 51 return newSession.release(); | 62 return newSession.release(); |
| 52 } | 63 } |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 double endTime = end(ndx, IGNORE_EXCEPTION); | 192 double endTime = end(ndx, IGNORE_EXCEPTION); |
| 182 if (time >= startTime && time <= endTime) | 193 if (time >= startTime && time <= endTime) |
| 183 return time; | 194 return time; |
| 184 if (fabs(startTime - time) < closest) | 195 if (fabs(startTime - time) < closest) |
| 185 closest = fabsf(startTime - time); | 196 closest = fabsf(startTime - time); |
| 186 else if (fabs(endTime - time) < closest) | 197 else if (fabs(endTime - time) < closest) |
| 187 closest = fabsf(endTime - time); | 198 closest = fabsf(endTime - time); |
| 188 } | 199 } |
| 189 return closest; | 200 return closest; |
| 190 } | 201 } |
| OLD | NEW |